mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 04:16:37 -04:00
harmonise post lists controllers
This commit is contained in:
parent
a6b1040b78
commit
9f7e87f722
13 changed files with 35 additions and 57 deletions
|
@ -1,44 +1,28 @@
|
|||
var PostsDailyController = RouteController.extend({
|
||||
Posts.controllers.daily = Posts.controllers.list.extend({
|
||||
|
||||
onBeforeAction: function () {
|
||||
this.render('postListTop', {to: 'postListTop'});
|
||||
this.next();
|
||||
},
|
||||
view: "daily",
|
||||
|
||||
template: function() {
|
||||
// use a function to make sure the template is evaluated *after* any template overrides
|
||||
// TODO: still needed?
|
||||
return 'postsDaily';
|
||||
},
|
||||
|
||||
subscriptions: function () {
|
||||
// this.days = this.params.days ? this.params.days : daysPerPage;
|
||||
// TODO: find a way to preload the first n posts of the first 5 days?
|
||||
},
|
||||
|
||||
data: function () {
|
||||
this.days = this.params.days ? this.params.days : daysPerPage;
|
||||
Session.set('postsDays', this.days);
|
||||
return {
|
||||
days: this.days
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
getTitle: function () {
|
||||
return i18n.t('daily');
|
||||
},
|
||||
|
||||
getDescription: function () {
|
||||
return i18n.t('day_by_day_view');
|
||||
},
|
||||
|
||||
fastRender: true
|
||||
});
|
||||
|
||||
Meteor.startup(function () {
|
||||
|
||||
Router.route('/daily/:days?', {
|
||||
name: 'postsDaily',
|
||||
controller: PostsDailyController
|
||||
controller: Posts.controllers.daily
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<template name="postListTop">
|
||||
<template name="post_list_top">
|
||||
{{> modules "postListTop"}}
|
||||
</template>
|
||||
|
|
|
@ -10,7 +10,7 @@ Posts.controllers.list = RouteController.extend({
|
|||
var showViewsNav = (typeof this.showViewsNav === 'undefined') ? true : this.showViewsNav;
|
||||
|
||||
if (showViewsNav) {
|
||||
this.render('postListTop', {to: 'postListTop'});
|
||||
this.render('post_list_top', {to: 'postListTop'});
|
||||
}
|
||||
this.next();
|
||||
},
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"singleday": "Single Day",
|
||||
"the_top_5_posts_of_each_day": "The top 5 posts of each day.",
|
||||
"previous_day": "Previous Day",
|
||||
"next_day": "Next Day",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"singleday": "A la journée",
|
||||
"the_top_5_posts_of_each_day": "5 meilleurs post par jours",
|
||||
"previous_day": "Jour précédent",
|
||||
"next_day": "Jour suivant",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template name="singleDay">
|
||||
<template name="single_day">
|
||||
{{#if showDateNav}}
|
||||
{{> singleDayNav}}
|
||||
{{> single_day_nav}}
|
||||
{{/if}}
|
||||
{{> postsListController}}
|
||||
</template>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Template.singleDay.helpers({
|
||||
Template.single_day.helpers({
|
||||
showDateNav: function () {
|
||||
return (typeof this.showDateNav === 'undefined') ? true : this.showDateNav;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<template name="singleDayNav">
|
||||
<template name="single_day_nav">
|
||||
<div class="grid">
|
||||
<div class="grid-block">
|
||||
{{#if showPreviousDate}}
|
||||
|
|
|
@ -7,7 +7,7 @@ var getDateURL = function (moment) {
|
|||
};
|
||||
|
||||
|
||||
Template.singleDayNav.onCreated(function(){
|
||||
Template.single_day_nav.onCreated(function(){
|
||||
|
||||
$(document).unbind('keyup'); //remove any potential existing bindings to avoid duplicates
|
||||
|
||||
|
@ -25,7 +25,7 @@ Template.singleDayNav.onCreated(function(){
|
|||
|
||||
});
|
||||
|
||||
Template.singleDayNav.helpers({
|
||||
Template.single_day_nav.helpers({
|
||||
currentDate: function(){
|
||||
var currentDate = moment(this.terms.date);
|
||||
var today = moment(new Date());
|
||||
|
|
|
@ -1,36 +1,22 @@
|
|||
// Controller for post digest
|
||||
|
||||
PostsSingledayController = RouteController.extend({
|
||||
Posts.controllers.singleday = Posts.controllers.list.extend({
|
||||
|
||||
template: 'singleDay',
|
||||
|
||||
onBeforeAction: function () {
|
||||
this.render('postListTop', {to: 'postListTop'});
|
||||
this.next();
|
||||
},
|
||||
view: 'singleday',
|
||||
|
||||
template: 'single_day', // use single_day template to get prev/next day navigation
|
||||
|
||||
data: function() {
|
||||
var currentDate = this.params.day ? new Date(this.params.year, this.params.month-1, this.params.day) : Session.get('today');
|
||||
return {
|
||||
terms: {
|
||||
view: 'singleday',
|
||||
date: currentDate,
|
||||
after: moment(currentDate).startOf('day').toDate(),
|
||||
before: moment(currentDate).endOf('day').toDate()
|
||||
}
|
||||
var terms = {
|
||||
view: 'singleday',
|
||||
date: currentDate,
|
||||
after: moment(currentDate).startOf('day').toDate(),
|
||||
before: moment(currentDate).endOf('day').toDate()
|
||||
};
|
||||
return {terms: terms};
|
||||
},
|
||||
|
||||
getTitle: function () {
|
||||
return i18n.t('single_day');
|
||||
},
|
||||
|
||||
getDescription: function () {
|
||||
return i18n.t('posts_of_a_single_day');
|
||||
},
|
||||
|
||||
fastRender: true
|
||||
|
||||
});
|
||||
|
||||
Meteor.startup(function () {
|
||||
|
@ -39,12 +25,12 @@ Meteor.startup(function () {
|
|||
|
||||
Router.route('/day/:year/:month/:day', {
|
||||
name: 'postsSingleDay',
|
||||
controller: PostsSingledayController
|
||||
controller: Posts.controllers.singleday
|
||||
});
|
||||
|
||||
Router.route('/day', {
|
||||
name: 'postsSingleDayDefault',
|
||||
controller: PostsSingledayController
|
||||
controller: Posts.controllers.singleday
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@ Meteor.startup(function () {
|
|||
showViewsNav: false,
|
||||
|
||||
onBeforeAction: function () {
|
||||
this.render('categoryTitle', {to: 'postListTop'});
|
||||
this.render('category_title', {to: 'postListTop'});
|
||||
this.next();
|
||||
},
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<template name="categoryTitle">
|
||||
<template name="category_title">
|
||||
<h2 class="category-title post-list-title">{{title}}</h2>
|
||||
</template>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
Template.category_title.helpers({
|
||||
title: function () {
|
||||
var category = Categories.findOne({slug: this.terms.category});
|
||||
return category.name;
|
||||
}
|
||||
});
|
Loading…
Add table
Reference in a new issue