-
Notifications
You must be signed in to change notification settings - Fork 41
/
router.js
61 lines (52 loc) · 1.45 KB
/
router.js
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
58
59
60
61
var app = require('ampersand-app');
var Router = require('ampersand-router');
var HomePage = require('./pages/home');
var CollectionDemo = require('./pages/collection-demo');
var InfoPage = require('./pages/info');
var PersonAddPage = require('./pages/person-add');
var PersonEditPage = require('./pages/person-edit');
var PersonViewPage = require('./pages/person-view');
module.exports = Router.extend({
routes: {
'': 'home',
'collections': 'collectionDemo',
'info': 'info',
'person/add': 'personAdd',
'person/:id': 'personView',
'person/:id/edit': 'personEdit',
'(*path)': 'catchAll'
},
// ------- ROUTE HANDLERS ---------
home: function () {
app.trigger('page', new HomePage({
model: app.me
}));
},
collectionDemo: function () {
app.trigger('page', new CollectionDemo({
model: app.me,
collection: app.people
}));
},
info: function () {
app.trigger('page', new InfoPage({
model: app.me
}));
},
personAdd: function () {
app.trigger('page', new PersonAddPage());
},
personEdit: function (id) {
app.trigger('page', new PersonEditPage({
id: id
}));
},
personView: function (id) {
app.trigger('page', new PersonViewPage({
id: id
}));
},
catchAll: function () {
this.redirectTo('');
}
});