harmonise post lists controllers

This commit is contained in:
Sacha Greif 2015-05-07 15:44:12 +09:00
parent a6b1040b78
commit 9f7e87f722
13 changed files with 35 additions and 57 deletions

View file

@ -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
});
});

View file

@ -1,3 +1,3 @@
<template name="postListTop">
<template name="post_list_top">
{{> modules "postListTop"}}
</template>

View file

@ -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();
},

View file

@ -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",

View file

@ -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",

View file

@ -1,6 +1,6 @@
<template name="singleDay">
<template name="single_day">
{{#if showDateNav}}
{{> singleDayNav}}
{{> single_day_nav}}
{{/if}}
{{> postsListController}}
</template>

View file

@ -1,4 +1,4 @@
Template.singleDay.helpers({
Template.single_day.helpers({
showDateNav: function () {
return (typeof this.showDateNav === 'undefined') ? true : this.showDateNav;
}

View file

@ -1,4 +1,4 @@
<template name="singleDayNav">
<template name="single_day_nav">
<div class="grid">
<div class="grid-block">
{{#if showPreviousDate}}

View file

@ -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());

View file

@ -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
});
});

View file

@ -9,7 +9,7 @@ Meteor.startup(function () {
showViewsNav: false,
onBeforeAction: function () {
this.render('categoryTitle', {to: 'postListTop'});
this.render('category_title', {to: 'postListTop'});
this.next();
},

View file

@ -1,3 +1,3 @@
<template name="categoryTitle">
<template name="category_title">
<h2 class="category-title post-list-title">{{title}}</h2>
</template>

View file

@ -0,0 +1,6 @@
Template.category_title.helpers({
title: function () {
var category = Categories.findOne({slug: this.terms.category});
return category.name;
}
});