Vulcan/packages/telescope-daily/lib/client/routes.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-09-01 09:52:40 +09:00
var daysPerPage = 5;
2014-08-28 10:16:17 +09:00
var coreSubscriptions = new SubsManager({
// cache recent 50 subscriptions
cacheLimit: 50,
// expire any subscription after 30 minutes
expireIn: 30
});
// note: FastRender not defined here?
PostsDailyController = RouteController.extend({
2014-08-28 10:16:17 +09:00
template: getTemplate('posts_daily'),
onBeforeAction: function() {
2014-09-01 09:52:40 +09:00
this.days = this.params.days ? this.params.days : daysPerPage;
2014-08-28 10:16:17 +09:00
// this.days = Session.get('postsDays') ? Session.get('postsDays') : 3;
var terms = {
view: 'daily',
days: this.days,
after: moment().subtract(this.days, 'days').startOf('day').toDate()
2014-08-28 10:16:17 +09:00
};
this.postsSubscription = coreSubscriptions.subscribe('postsList', terms, function() {
Session.set('postsLoaded', true);
});
2014-08-27 09:24:37 +09:00
2014-08-28 10:16:17 +09:00
this.postsUsersSubscription = coreSubscriptions.subscribe('postsListUsers', terms);
return [this.postsSubscription, this.postsUsersSubscription];
},
data: function() {
Session.set('postsDays', this.days);
return {
days: this.days
};
}
});
Meteor.startup(function () {
2014-08-27 10:23:56 +09:00
2014-08-27 09:24:37 +09:00
Router.map(function() {
2014-08-27 16:43:41 +09:00
this.route('postsDaily', {
2014-08-27 09:24:37 +09:00
path: '/daily/:days?',
controller: PostsDailyController
});
});
});