|
@@ -9,6 +9,28 @@ Router.configure({
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+PostsListController = RouteController.extend({
|
|
|
|
+ template: 'postsList',
|
|
|
|
+ increment: 5,
|
|
|
|
+ postsLimit: function () {
|
|
|
|
+ return parseInt(this.params.postsLimit) || this.increment;
|
|
|
|
+ },
|
|
|
|
+ findOptions: function () {
|
|
|
|
+ return {
|
|
|
|
+ sort: { submitted: -1 },
|
|
|
|
+ limit: this.postsLimit()
|
|
|
|
+ };
|
|
|
|
+ },
|
|
|
|
+ waitOn: function () {
|
|
|
|
+ return Meteor.subscribe('posts', this.findOptions());
|
|
|
|
+ },
|
|
|
|
+ data: function () {
|
|
|
|
+ return {
|
|
|
|
+ posts: Posts.find({}, this.findOptions())
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+});
|
|
|
|
+
|
|
Router.route('/posts/:_id', {
|
|
Router.route('/posts/:_id', {
|
|
name: 'postPage',
|
|
name: 'postPage',
|
|
waitOn: function () {
|
|
waitOn: function () {
|
|
@@ -39,25 +61,8 @@ Router.route('/submit', {
|
|
// template par défaut.
|
|
// template par défaut.
|
|
Router.route('/:postLimit?', {
|
|
Router.route('/:postLimit?', {
|
|
name: 'postsList',
|
|
name: 'postsList',
|
|
- waitOn: function () {
|
|
|
|
- var limit = parseInt(this.params.postLimit) || 5;
|
|
|
|
- return Meteor.subscribe('posts', {
|
|
|
|
- sort: { submitted: -1 },
|
|
|
|
- limit: limit
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- data: function () {
|
|
|
|
- var limit = parseInt(this.params.postLimit) || 5;
|
|
|
|
- return {
|
|
|
|
- posts: Posts.find({}, {
|
|
|
|
- sort: { submitted: -1 },
|
|
|
|
- limit: limit
|
|
|
|
- })
|
|
|
|
- };
|
|
|
|
- }
|
|
|
|
});
|
|
});
|
|
|
|
|
|
-
|
|
|
|
var requireLogin = function () {
|
|
var requireLogin = function () {
|
|
if (!Meteor.user()) {
|
|
if (!Meteor.user()) {
|
|
if (Meteor.loggingIn()) {
|
|
if (Meteor.loggingIn()) {
|