|
@@ -4,18 +4,11 @@ Router.configure({
|
|
notFoundTemplate: 'notFound',
|
|
notFoundTemplate: 'notFound',
|
|
waitOn: function () {
|
|
waitOn: function () {
|
|
return [
|
|
return [
|
|
- Meteor.subscribe('posts'),
|
|
|
|
Meteor.subscribe('notifications')
|
|
Meteor.subscribe('notifications')
|
|
];
|
|
];
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
-// C'est un nom de route, pas un nom de template. Mais IR le prend comme nom de
|
|
|
|
-// template par défaut.
|
|
|
|
-Router.route('/', {
|
|
|
|
- name: 'postsList'
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
Router.route('/posts/:_id', {
|
|
Router.route('/posts/:_id', {
|
|
name: 'postPage',
|
|
name: 'postPage',
|
|
waitOn: function () {
|
|
waitOn: function () {
|
|
@@ -29,6 +22,9 @@ Router.route('/posts/:_id', {
|
|
|
|
|
|
Router.route('/posts/:_id/edit', {
|
|
Router.route('/posts/:_id/edit', {
|
|
name: 'postEdit',
|
|
name: 'postEdit',
|
|
|
|
+ waitOn: function () {
|
|
|
|
+ return Meteor.subscribe('singlePost', this.params._id);
|
|
|
|
+ },
|
|
data: function () {
|
|
data: function () {
|
|
// "this" is the matched route.
|
|
// "this" is the matched route.
|
|
return Posts.findOne(this.params._id);
|
|
return Posts.findOne(this.params._id);
|
|
@@ -39,6 +35,29 @@ Router.route('/submit', {
|
|
name: 'postSubmit'
|
|
name: 'postSubmit'
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+// C'est un nom de route, pas un nom de template. Mais IR le prend comme nom de
|
|
|
|
+// template par défaut.
|
|
|
|
+Router.route('/:postLimit?', {
|
|
|
|
+ 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()) {
|