mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 12:36:39 -04:00
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
![]() |
// Controller for post digest
|
||
|
|
||
|
PostsDigestController = RouteController.extend({
|
||
|
template: getTemplate('posts_digest'),
|
||
|
waitOn: function() {
|
||
|
// if day is set, use that. If not default to today
|
||
|
var currentDate = this.params.day ? new Date(this.params.year, this.params.month-1, this.params.day) : new Date(),
|
||
|
terms = {
|
||
|
view: 'digest',
|
||
|
after: moment(currentDate).startOf('day').toDate(),
|
||
|
before: moment(currentDate).endOf('day').toDate()
|
||
|
};
|
||
|
return [
|
||
|
coreSubscriptions.subscribe('postsList', terms),
|
||
|
coreSubscriptions.subscribe('postsListUsers', terms)
|
||
|
];
|
||
|
},
|
||
|
data: function() {
|
||
|
var currentDate = this.params.day ? new Date(this.params.year, this.params.month-1, this.params.day) : Session.get('today'),
|
||
|
terms = {
|
||
|
view: 'digest',
|
||
|
after: moment(currentDate).startOf('day').toDate(),
|
||
|
before: moment(currentDate).endOf('day').toDate()
|
||
|
},
|
||
|
parameters = getPostsParameters(terms);
|
||
|
Session.set('currentDate', currentDate);
|
||
|
|
||
|
parameters.find.createdAt = { $lte: Session.get('listPopulatedAt') };
|
||
|
var posts = Posts.find(parameters.find, parameters.options);
|
||
|
|
||
|
// Incoming posts
|
||
|
parameters.find.createdAt = { $gt: Session.get('listPopulatedAt') };
|
||
|
var postsIncoming = Posts.find(parameters.find, parameters.options);
|
||
|
|
||
|
return {
|
||
|
incoming: postsIncoming,
|
||
|
posts: posts
|
||
|
};
|
||
|
},
|
||
|
fastRender: true
|
||
|
});
|
||
|
|
||
|
Meteor.startup(function () {
|
||
|
|
||
|
// Digest
|
||
|
|
||
|
Router.route('/digest/:year/:month/:day', {
|
||
|
name: 'posts_digest',
|
||
|
controller: PostsDigestController
|
||
|
});
|
||
|
|
||
|
Router.route('/digest', {
|
||
|
name: 'posts_digest_default',
|
||
|
controller: PostsDigestController
|
||
|
});
|
||
|
|
||
|
});
|