mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
working on main posts list subscriptions
This commit is contained in:
parent
632ddd5b00
commit
e4937a7f38
12 changed files with 89 additions and 43 deletions
|
@ -25,7 +25,9 @@ canEditComment
|
|||
|
||||
hasCompletedProfile
|
||||
|
||||
|
||||
---------------------------------------------------------------
|
||||
# Subscription Functions #
|
||||
---------------------------------------------------------------
|
||||
|
||||
---------------------------------------------------------------
|
||||
# Routes #
|
||||
|
@ -92,6 +94,10 @@ Router.configure({
|
|||
//--------------------------------------------- Filters --------------------------------------------//
|
||||
//--------------------------------------------------------------------------------------------------//
|
||||
|
||||
subs = {
|
||||
|
||||
}
|
||||
|
||||
var filters = {
|
||||
|
||||
// isLoggedIn: function(page) {
|
||||
|
@ -192,8 +198,40 @@ var filters = {
|
|||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------//
|
||||
//------------------------------------- Subscription Functions -------------------------------------//
|
||||
//--------------------------------------------------------------------------------------------------//
|
||||
|
||||
// Posts Lists
|
||||
STATUS_PENDING=1;
|
||||
STATUS_APPROVED=2;
|
||||
STATUS_REJECTED=3;
|
||||
|
||||
var selectTop = function() {
|
||||
return selectPosts({name: 'top', status: STATUS_APPROVED, slug: Session.get('categorySlug')});
|
||||
}
|
||||
|
||||
var selectNew = function() {
|
||||
return selectPosts({name: 'new', status: STATUS_APPROVED, slug: Session.get('categorySlug')});
|
||||
}
|
||||
|
||||
var selectBest = function() {
|
||||
return selectPosts({name: 'best', status: STATUS_APPROVED, slug: Session.get('categorySlug')});
|
||||
}
|
||||
|
||||
var selectPending = function() {
|
||||
return selectPosts({name: 'pending', status: STATUS_PENDING, slug: Session.get('categorySlug')});
|
||||
}
|
||||
|
||||
// put it all together with pagination
|
||||
var postListSubscription = function(find, options, per_page) {
|
||||
var handle = Meteor.subscribeWithPagination('paginatedPosts', find, options, per_page);
|
||||
handle.fetch = function() {
|
||||
var ourFind = _.isFunction(find) ? find() : find;
|
||||
return limitDocuments(Posts.find(ourFind, options), handle.loaded());
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------//
|
||||
//--------------------------------------------- Routes ---------------------------------------------//
|
||||
|
@ -205,28 +243,43 @@ Router.map(function() {
|
|||
template: 'posts_top'
|
||||
});
|
||||
|
||||
this.route('posts_top', {path: '/top'});
|
||||
this.route('posts_new', {path: '/new'});
|
||||
this.route('posts_best', {path: '/best'});
|
||||
this.route('posts_pending', {path: '/pending'});
|
||||
|
||||
// Top
|
||||
|
||||
// TODO
|
||||
|
||||
// waitOn: subs.topPostHandle = postListSubscription(selectTop, sortPosts('score'), 10);
|
||||
this.route('home', {
|
||||
path: '/',
|
||||
template:'posts_top',
|
||||
waitOn: subs.topPostsHandle = postListSubscription(selectTop, sortPosts('score'), 10)
|
||||
});
|
||||
|
||||
this.route('posts_top', {
|
||||
path: '/top',
|
||||
waitOn: subs.topPostsHandle = postListSubscription(selectTop, sortPosts('score'), 10)
|
||||
});
|
||||
|
||||
// New
|
||||
|
||||
// TODO
|
||||
this.route('posts_new', {
|
||||
path: '/new',
|
||||
waitOn: subs.newPostsHandle = postListSubscription(selectNew, sortPosts('submitted'), 10)
|
||||
});
|
||||
|
||||
// Best
|
||||
|
||||
// TODO
|
||||
this.route('posts_best', {
|
||||
path: '/best',
|
||||
waitOn: subs.bestPostsHandle = postListSubscription(selectBest, sortPosts('baseScore'), 10)
|
||||
});
|
||||
|
||||
// Pending
|
||||
|
||||
// TODO
|
||||
this.route('posts_pending', {
|
||||
path: '/pending',
|
||||
waitOn: subs.pendingPostsHandle = postListSubscription(selectPending, sortPosts('createdAt'), 10)
|
||||
});
|
||||
|
||||
// Categories
|
||||
|
||||
|
|
|
@ -46,10 +46,10 @@ postListSubscription = function(find, options, per_page) {
|
|||
}
|
||||
|
||||
// note: the "name" property is for internal debugging purposes only
|
||||
selectTop = function() {
|
||||
return selectPosts({name: 'top', status: STATUS_APPROVED, slug: Session.get('categorySlug')});
|
||||
}
|
||||
topPostsHandle = postListSubscription(selectTop, sortPosts('score'), 10);
|
||||
// selectTop = function() {
|
||||
// return selectPosts({name: 'top', status: STATUS_APPROVED, slug: Session.get('categorySlug')});
|
||||
// }
|
||||
// topPostsHandle = postListSubscription(selectTop, sortPosts('score'), 10);
|
||||
|
||||
selectNew = function() {
|
||||
return selectPosts({name: 'new', status: STATUS_APPROVED, slug: Session.get('categorySlug')});
|
||||
|
|
3
client/views/posts/posts_best.html
Normal file
3
client/views/posts/posts_best.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<template name="posts_best">
|
||||
{{> posts_list bestPostsHandle}}
|
||||
</template>
|
3
client/views/posts/posts_best.js
Normal file
3
client/views/posts/posts_best.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
Template.posts_best.bestPostsHandle = function() {
|
||||
return subs.bestPostsHandle;
|
||||
}
|
|
@ -11,22 +11,4 @@
|
|||
{{else}}
|
||||
<div>Loading... </div>
|
||||
{{/if}}
|
||||
</template>
|
||||
|
||||
<!-- and the various pages that use the above template -->
|
||||
<!-- XXX: makes me want to be able to set a context from the router... -->
|
||||
<template name="posts_top">
|
||||
{{> posts_list topPostsHandle}}
|
||||
</template>
|
||||
|
||||
<template name="posts_new">
|
||||
{{> posts_list newPostsHandle}}
|
||||
</template>
|
||||
|
||||
<template name="posts_best">
|
||||
{{> posts_list bestPostsHandle}}
|
||||
</template>
|
||||
|
||||
<template name="posts_pending">
|
||||
{{> posts_list pendingPostsHandle}}
|
||||
</template>
|
|
@ -1,16 +1,3 @@
|
|||
Template.posts_top.topPostsHandle = function() {
|
||||
return topPostsHandle;
|
||||
}
|
||||
Template.posts_new.newPostsHandle = function() {
|
||||
return newPostsHandle;
|
||||
}
|
||||
Template.posts_best.bestPostsHandle = function() {
|
||||
return bestPostsHandle;
|
||||
}
|
||||
Template.posts_pending.pendingPostsHandle = function() {
|
||||
return pendingPostsHandle;
|
||||
}
|
||||
|
||||
Template.posts_list.helpers({
|
||||
posts: function() {
|
||||
return this.fetch();
|
||||
|
|
3
client/views/posts/posts_new.html
Normal file
3
client/views/posts/posts_new.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<template name="posts_new">
|
||||
{{> posts_list newPostsHandle}}
|
||||
</template>
|
3
client/views/posts/posts_new.js
Normal file
3
client/views/posts/posts_new.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
Template.posts_new.newPostsHandle = function() {
|
||||
return subs.newPostsHandle;
|
||||
}
|
3
client/views/posts/posts_pending.html
Normal file
3
client/views/posts/posts_pending.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<template name="posts_pending">
|
||||
{{> posts_list pendingPostsHandle}}
|
||||
</template>
|
3
client/views/posts/posts_pending.js
Normal file
3
client/views/posts/posts_pending.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
Template.posts_pending.pendingPostsHandle = function() {
|
||||
return subs.pendingPostsHandle;
|
||||
}
|
3
client/views/posts/posts_top.html
Normal file
3
client/views/posts/posts_top.html
Normal file
|
@ -0,0 +1,3 @@
|
|||
<template name="posts_top">
|
||||
{{> posts_list topPostsHandle}}
|
||||
</template>
|
3
client/views/posts/posts_top.js
Normal file
3
client/views/posts/posts_top.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
Template.posts_top.topPostsHandle = function() {
|
||||
return subs.topPostsHandle;
|
||||
}
|
Loading…
Add table
Reference in a new issue