mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
working on daily view
This commit is contained in:
parent
735f0645db
commit
85679ded35
6 changed files with 113 additions and 0 deletions
40
packages/telescope-daily/lib/client/routes.js
Normal file
40
packages/telescope-daily/lib/client/routes.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
Meteor.startup(function () {
|
||||
|
||||
Router.map(function() {
|
||||
|
||||
PostsDailyController = FastRender.RouteController.extend({
|
||||
template: getTemplate('posts_daily'),
|
||||
waitOn: function() {
|
||||
// if number of days is set use that, else default to 3
|
||||
var days = this.params.days ? this.params.days : 3,
|
||||
terms = {
|
||||
view: 'daily',
|
||||
after: moment().subtract('days', days).startOf('day').toDate()
|
||||
};
|
||||
return [
|
||||
coreSubscriptions.subscribe('postsList', terms),
|
||||
coreSubscriptions.subscribe('postsListUsers', terms)
|
||||
];
|
||||
},
|
||||
data: function() {
|
||||
var days = this.params.days ? this.params.days : 3,
|
||||
terms = {
|
||||
view: 'daily',
|
||||
after: moment().subtract('days', days).startOf('day').toDate()
|
||||
},
|
||||
parameters = getParameters(terms);
|
||||
Session.set('currentDate', currentDate);
|
||||
return {
|
||||
posts: Posts.find(parameters.find, parameters.options)
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
this.route('posts_daily', {
|
||||
path: '/daily/:days?',
|
||||
controller: PostsDailyController
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
<template name="postsDaily">
|
||||
<div class="grid">
|
||||
{{#each day}}
|
||||
<div class="posts-day posts list">
|
||||
<h2 class="posts-day-heading">xyz</h2>
|
||||
{{#each posts}}
|
||||
{{> UI.dynamic template=post_item}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</template>
|
24
packages/telescope-daily/lib/client/templates/posts_daily.js
Normal file
24
packages/telescope-daily/lib/client/templates/posts_daily.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
Template[getTemplate('postsDaily')].helpers({
|
||||
post_item: function () {
|
||||
return getTemplate('post_item');
|
||||
},
|
||||
posts : function () {
|
||||
if(this.postsList){ // XXX
|
||||
this.postsList.rewind();
|
||||
var posts = this.postsList.map(function (post, index, cursor) {
|
||||
post.rank = index;
|
||||
return post;
|
||||
});
|
||||
return posts;
|
||||
}
|
||||
},
|
||||
hasMorePosts: function(){
|
||||
// as long as we ask for N posts and all N posts showed up, then keep showing the "load more" button
|
||||
return parseInt(Session.get('postsLimit')) == this.postsCount
|
||||
},
|
||||
loadMoreUrl: function () {
|
||||
var count = parseInt(Session.get('postsLimit')) + parseInt(getSetting('postsPerPage', 10));
|
||||
var categorySegment = Session.get('categorySlug') ? Session.get('categorySlug') + '/' : '';
|
||||
return '/' + Session.get('view') + '/' + categorySegment + count;
|
||||
}
|
||||
});
|
12
packages/telescope-daily/lib/daily.js
Normal file
12
packages/telescope-daily/lib/daily.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
viewParameters.daily = function (terms) {
|
||||
return {
|
||||
find: {
|
||||
postedAt: {
|
||||
$gte: terms.after
|
||||
}
|
||||
},
|
||||
options: {
|
||||
sort: {createdAt: -1, sticky: -1, baseScore: -1}
|
||||
}
|
||||
};
|
||||
}
|
0
packages/telescope-daily/lib/server/publications.js
Normal file
0
packages/telescope-daily/lib/server/publications.js
Normal file
25
packages/telescope-daily/package.js
Normal file
25
packages/telescope-daily/package.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
Package.describe({summary: "Telescope daily view"});
|
||||
|
||||
Package.on_use(function (api) {
|
||||
|
||||
api.use(['telescope-lib', 'telescope-base'], ['client', 'server']);
|
||||
|
||||
api.use([
|
||||
'jquery',
|
||||
'underscore',
|
||||
'iron-router',
|
||||
'templating'
|
||||
], 'client');
|
||||
|
||||
api.add_files(['lib/daily.js'], ['client', 'server']);
|
||||
|
||||
api.add_files([
|
||||
'lib/client/routes.js',
|
||||
'lib/client/templates/posts_daily.html',
|
||||
'lib/client/templates/posts_daily.js',
|
||||
], ['client']);
|
||||
|
||||
api.add_files(['lib/server/publications.js'], ['server']);
|
||||
|
||||
api.export([]);
|
||||
});
|
Loading…
Add table
Reference in a new issue