Vulcan/packages/telescope-daily/lib/client/templates/posts_daily.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2014-08-27 10:23:56 +09:00
var getPosts = function (date) {
var terms = {
2014-08-27 16:43:41 +09:00
view: 'digest',
after: moment(date).startOf('day').toDate(),
before: moment(date).endOf('day').toDate()
};
2014-08-27 10:23:56 +09:00
var parameters = getParameters(terms);
var posts = Posts.find(parameters.find, parameters.options).map(function (post, index, cursor) {
post.rank = index;
return post;
});
return posts;
}
2014-08-27 09:24:37 +09:00
Template[getTemplate('postsDaily')].helpers({
2014-08-27 16:43:41 +09:00
postsLoaded: function () {
return !!Session.get('postsLoaded');
},
2014-08-27 09:24:37 +09:00
post_item: function () {
return getTemplate('post_item');
},
2014-08-27 10:23:56 +09:00
days: function () {
var daysArray = [];
2014-08-28 07:55:13 +09:00
// var days = this.days;
var days = Session.get('postsDays');
for (i = 0; i < days; i++) {
2014-08-27 10:23:56 +09:00
daysArray.push({
date: moment().subtract('days', i).startOf('day').toDate()
2014-08-27 09:24:37 +09:00
});
}
2014-08-27 10:23:56 +09:00
return daysArray;
},
posts: function () {
return getPosts(this.date);
2014-08-27 09:24:37 +09:00
},
loadMoreUrl: function () {
2014-08-28 07:55:13 +09:00
var count = parseInt(Session.get('postsDays')) + 3;
return '/daily/' + count;
2014-08-27 09:24:37 +09:00
}
2014-08-27 16:43:41 +09:00
});
// Template[getTemplate('postsDaily')].events({
// 'click .more-button': function (e) {
// e.preventDefault();
2014-08-28 07:55:13 +09:00
// var count = parseInt(Session.get('postsDays')) + 3;
// Session.set('postsDays', count);
2014-08-27 16:43:41 +09:00
// }
// });