|
@@ -17,7 +17,7 @@ PostsListController = RouteController.extend({
|
|
},
|
|
},
|
|
findOptions: function () {
|
|
findOptions: function () {
|
|
return {
|
|
return {
|
|
- sort: { submitted: -1 },
|
|
|
|
|
|
+ sort: this.sort,
|
|
limit: this.postsLimit()
|
|
limit: this.postsLimit()
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -29,17 +29,34 @@ PostsListController = RouteController.extend({
|
|
},
|
|
},
|
|
data: function () {
|
|
data: function () {
|
|
var hasMore = this.posts().count() === this.postsLimit();
|
|
var hasMore = this.posts().count() === this.postsLimit();
|
|
- var nextPath = this.route.path({
|
|
|
|
- postsLimit: this.postsLimit() + this.increment
|
|
|
|
- });
|
|
|
|
return {
|
|
return {
|
|
posts: this.posts(),
|
|
posts: this.posts(),
|
|
ready: this.postSub.ready,
|
|
ready: this.postSub.ready,
|
|
- nextPath: hasMore ? nextPath : null
|
|
|
|
|
|
+ nextPath: hasMore ? this.nextPath() : null
|
|
};
|
|
};
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+NewPostsController = PostsListController.extend({
|
|
|
|
+ sort: { submitted: -1, _id: -1 },
|
|
|
|
+ nextPath: function () {
|
|
|
|
+ return Router.routes.newPosts.path({
|
|
|
|
+ postsLimit: this.postsLimit() + this.increment
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+BestPostsController = PostsListController.extend({
|
|
|
|
+ sort: { votes: -1, submitted: -1, _id: -1 },
|
|
|
|
+ nextPath: function () {
|
|
|
|
+ return Router.routes.bestPosts.path({
|
|
|
|
+ postsLimit: this.postsLimit() + this.increment
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+});
|
|
|
|
+
|
|
Router.route('/posts/:_id', {
|
|
Router.route('/posts/:_id', {
|
|
name: 'postPage',
|
|
name: 'postPage',
|
|
waitOn: function () {
|
|
waitOn: function () {
|
|
@@ -71,10 +88,14 @@ Router.route('/submit', {
|
|
|
|
|
|
// C'est un nom de route, pas un nom de template. Mais IR le prend comme nom de
|
|
// C'est un nom de route, pas un nom de template. Mais IR le prend comme nom de
|
|
// template par défaut.
|
|
// template par défaut.
|
|
-Router.route('/:postsLimit?', {
|
|
|
|
- name: 'postsList'
|
|
|
|
|
|
+Router.route('/', {
|
|
|
|
+ name: 'home',
|
|
|
|
+ controller: 'NewPostsController',
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+Router.route('/new/:postsLimit?', { name: 'newPosts' });
|
|
|
|
+Router.route('/best/:postsLimit?', { name: 'bestPosts' });
|
|
|
|
+
|
|
var requireLogin = function () {
|
|
var requireLogin = function () {
|
|
if (!Meteor.user()) {
|
|
if (!Meteor.user()) {
|
|
if (Meteor.loggingIn()) {
|
|
if (Meteor.loggingIn()) {
|