summaryrefslogtreecommitdiffstats
path: root/client/config/router.js
blob: 4545f220bd79f7f7484a907b69dbe1b913db66e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
FlowRouter.route('/', {
  name: 'home',
  triggersEnter: [AccountsTemplates.ensureSignedIn],
  action: function() {
    EscapeActions.executeAll();
    Filter.reset();

    Session.set('currentBoard', '');

    BlazeLayout.render('defaultLayout', { content: 'boardList' });
  }
});

FlowRouter.route('/b/:id/:slug', {
  name: 'board',
  action: function(params) {
    EscapeActions.executeAll();

    Session.set('currentBoard', params.id);
    Session.set('currentCard', null);

    BlazeLayout.render('defaultLayout', { content: 'board' });
  }
});

FlowRouter.route('/b/:boardId/:slug/:cardId', {
  name: 'card',
  action: function(params) {
    Session.set('currentBoard', params.boardId);
    Session.set('currentCard', params.cardId);
    EscapeActions.executeUpTo('popup-close');

    BlazeLayout.render('defaultLayout', { content: 'board' });
  }
});

FlowRouter.notFound = {
  action: function() {
    BlazeLayout.render('defaultLayout', { content: 'notFound' });
  }
}

// We maintain a list of redirections to ensure that we don't break old URLs
// when we change our routing scheme.
var redirections = {
  '/boards': '/',
  '/boards/:id/:slug': '/b/:id/:slug',
  '/boards/:id/:slug/:cardId': '/b/:id/:slug/:cardId'
};

_.each(redirections, function(newPath, oldPath) {
  FlowRouter.route(oldPath, {
    triggersEnter: [function(context, redirect) {
      redirect(FlowRouter.path(newPath, context.params));
    }]
  });
});