forked from Openki/Openki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
routing.js
129 lines (113 loc) · 3.15 KB
/
routing.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Router.configure({
layoutTemplate: 'layout',
notFoundTemplate: 'notFound',
loadingTemplate: 'loading',
});
webpagename = 'Hmmm - Course Organisation Platform - ' // global (document title init)
Router.map(function () { ///////// startpage /////////
this.route('home', {
path: '/',
template: 'start',
waitOn: function () {
var region = Session.get('region')
return Meteor.subscribe('coursesFind', region, false, {});
},
data: function() {
return {
results: Courses.find()
}
},
onAfterAction: function() {
document.title = webpagename + 'Home'
}
})
this.route('locationDetails',{ ///////// locationdetails /////////
path: 'locations/:_id',
template: 'location_details',
waitOn: function () {
return Meteor.subscribe('locations');
},
data: function () {
return Locations.findOne({_id: this.params._id})
},
onAfterAction: function() {
var location = Locations.findOne({_id: this.params._id})
if (!location) return; // wtf
document.title = webpagename + 'Location: ' + location.name
}
})
this.route('locations',{ ///////// locationlist /////////
path: 'locations',
template: 'locationlist',
waitOn: function () {
return Meteor.subscribe('locations');
},
onAfterAction: function() {
document.title = webpagename + 'Location list'
}
})
this.route('categorylist',{ ///////// categories /////////
waitOn: function () {
return Meteor.subscribe('categories'); // TODO: Anchor tags don't work anyway
},
onAfterAction: function() {
document.title = webpagename + 'Category list'
}
})
this.route('pages', { ///////// static /////////
path: 'page/:page_name',
action: function() {
this.render(this.params.page_name)
},
onAfterAction: function() {
document.title = webpagename + '' + this.params.page_name
}
})
this.route('proposeCourse', { ///////// propose /////////
path: 'courses/propose',
template: 'proposecourse',
waitOn: function () {
return Meteor.subscribe('categories');
},
onAfterAction: function() {
document.title = webpagename + 'Propose new course'
}
})
this.route('createCourse', { ///////// create /////////
path: 'courses/create',
template: 'createcourse',
waitOn: function () {
return Meteor.subscribe('categories');
},
onAfterAction: function() {
document.title = webpagename + 'Create new course'
}
})
this.route('userprofile', { ///////// userprofile /////////
path: 'user/:_id/:username?',
waitOn: function () {
return Meteor.subscribe('users');
},
data: function () {
return Meteor.users.findOne({_id: this.params._id})
},
onAfterAction: function() {
var user = Meteor.users.findOne({_id: this.params._id})
if (!user) return; // wtf
document.title = webpagename + '' + user.username + "'s Profile"
}
})
this.route('calendar', { ///////// calendar /////////
path: 'calendar',
template: 'calendar',
waitOn: function () {
return Meteor.subscribe('courses');
},
onAfterAction: function() {
document.title = webpagename + 'Calendar'
}
})
this.route('admin', { ///////// admin /////////
template: 'admin'
})
})