mirror of
https://github.com/vale981/Vulcan
synced 2025-03-09 04:16:37 -04: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
|
hasCompletedProfile
|
||||||
|
|
||||||
|
---------------------------------------------------------------
|
||||||
|
# Subscription Functions #
|
||||||
|
---------------------------------------------------------------
|
||||||
|
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
# Routes #
|
# Routes #
|
||||||
|
@ -92,6 +94,10 @@ Router.configure({
|
||||||
//--------------------------------------------- Filters --------------------------------------------//
|
//--------------------------------------------- Filters --------------------------------------------//
|
||||||
//--------------------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
subs = {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
var filters = {
|
var filters = {
|
||||||
|
|
||||||
// isLoggedIn: function(page) {
|
// 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 ---------------------------------------------//
|
//--------------------------------------------- Routes ---------------------------------------------//
|
||||||
|
@ -205,28 +243,43 @@ Router.map(function() {
|
||||||
template: 'posts_top'
|
template: 'posts_top'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.route('posts_top', {path: '/top'});
|
|
||||||
this.route('posts_new', {path: '/new'});
|
this.route('posts_new', {path: '/new'});
|
||||||
this.route('posts_best', {path: '/best'});
|
this.route('posts_best', {path: '/best'});
|
||||||
this.route('posts_pending', {path: '/pending'});
|
this.route('posts_pending', {path: '/pending'});
|
||||||
|
|
||||||
// Top
|
// Top
|
||||||
|
|
||||||
// TODO
|
this.route('home', {
|
||||||
|
path: '/',
|
||||||
|
template:'posts_top',
|
||||||
|
waitOn: subs.topPostsHandle = postListSubscription(selectTop, sortPosts('score'), 10)
|
||||||
|
});
|
||||||
|
|
||||||
// waitOn: subs.topPostHandle = postListSubscription(selectTop, sortPosts('score'), 10);
|
this.route('posts_top', {
|
||||||
|
path: '/top',
|
||||||
|
waitOn: subs.topPostsHandle = postListSubscription(selectTop, sortPosts('score'), 10)
|
||||||
|
});
|
||||||
|
|
||||||
// New
|
// New
|
||||||
|
|
||||||
// TODO
|
this.route('posts_new', {
|
||||||
|
path: '/new',
|
||||||
|
waitOn: subs.newPostsHandle = postListSubscription(selectNew, sortPosts('submitted'), 10)
|
||||||
|
});
|
||||||
|
|
||||||
// Best
|
// Best
|
||||||
|
|
||||||
// TODO
|
this.route('posts_best', {
|
||||||
|
path: '/best',
|
||||||
|
waitOn: subs.bestPostsHandle = postListSubscription(selectBest, sortPosts('baseScore'), 10)
|
||||||
|
});
|
||||||
|
|
||||||
// Pending
|
// Pending
|
||||||
|
|
||||||
// TODO
|
this.route('posts_pending', {
|
||||||
|
path: '/pending',
|
||||||
|
waitOn: subs.pendingPostsHandle = postListSubscription(selectPending, sortPosts('createdAt'), 10)
|
||||||
|
});
|
||||||
|
|
||||||
// Categories
|
// Categories
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,10 @@ postListSubscription = function(find, options, per_page) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: the "name" property is for internal debugging purposes only
|
// note: the "name" property is for internal debugging purposes only
|
||||||
selectTop = function() {
|
// selectTop = function() {
|
||||||
return selectPosts({name: 'top', status: STATUS_APPROVED, slug: Session.get('categorySlug')});
|
// return selectPosts({name: 'top', status: STATUS_APPROVED, slug: Session.get('categorySlug')});
|
||||||
}
|
// }
|
||||||
topPostsHandle = postListSubscription(selectTop, sortPosts('score'), 10);
|
// topPostsHandle = postListSubscription(selectTop, sortPosts('score'), 10);
|
||||||
|
|
||||||
selectNew = function() {
|
selectNew = function() {
|
||||||
return selectPosts({name: 'new', status: STATUS_APPROVED, slug: Session.get('categorySlug')});
|
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;
|
||||||
|
}
|
|
@ -12,21 +12,3 @@
|
||||||
<div>Loading... </div>
|
<div>Loading... </div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</template>
|
</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({
|
Template.posts_list.helpers({
|
||||||
posts: function() {
|
posts: function() {
|
||||||
return this.fetch();
|
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