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

48 lines
1.2 KiB
JavaScript
Raw Normal View History

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