| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | /** * @file * * * User: marand * Date: 30/08/15 * Time: 16:47 */Router.configure({  layoutTemplate: "layout",  loadingTemplate: "loading",  notFoundTemplate: "notFound",  waitOn: function () {    return Meteor.subscribe('posts');  }});// 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', {  name: 'postPage',  data: function () {    // "this" is the matched route.    return Posts.findOne(this.params._id);  }});Router.route('/posts/:_id/edit', {  name: 'postEdit',  data: function () {    // "this" is the matched route.    return Posts.findOne(this.params._id);  }});Router.route('/submit', {  name: 'postSubmit'});// Faire une 404 si la page matche la route postPage, mais pas son argument.// Déclenché pour toute valeur "falsy" (null, false, undefined, empty).Router.onBeforeAction('dataNotFound', {  only: 'postPage'});var requireLogin = function () {  if (!Meteor.user()) {    if (Meteor.loggingIn()) {      // Défini dans Router.configure().      this.render(this.loadingTemplate);    }    else {      this.render('accessDenied');    }  }  else {    this.next();  }};// Appliquer le contrôle d'accès à la route postSubmit.Router.onBeforeAction(requireLogin, {  only: 'postSubmit'});
 |