-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.coffee
76 lines (60 loc) · 2.03 KB
/
routes.coffee
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
Router.configure
lodingTemplate: 'loading'
notFoundTemplate: 'notfound'
###
Router.onBeforeAction ->
if this.ready()
Session.set( SessEnum.loading , false)
this.next()
else
Session.set( SessEnum.loading , true)
###
Meteor.startup ->
Router.map ->
this.route 'home',
path: '/', layoutTemplate: 'page'
template: 'videofeed'
yieldTemplates:
header: {to: 'header'}
footer: {to: 'footer'}
onRun: ->
Session.set( SessEnum.post.watching , undefined )
this.route 'post.watch',
path: '/w/:_id', layoutTemplate: 'page'
template: 'post_watch'
data: ->
return Models.Posts.findOne({_id: this.params._id})
yieldTemplates:
header: {to: 'header'}
footer: {to: 'footer'}
onRun: ->
post = Models.Posts.findOne({_id: this.params._id})
Session.set( SessEnum.post.watching , post )
this.route 'channel',
path: '/r/:channel_slug', layoutTemplate: 'page'
template: 'channel_overview'
waitOn: ->
Session.set( SessEnum.channels.selected, this.params.channel_slug )
yieldTemplates:
header: {to: 'header'}
footer: {to: 'footer'}
onRun: ->
AppLog.log('router:channel', this.params )
Session.set( SessEnum.channels.selected , this.params.channel_slug )
this.route 'signOut',
path: '/sign-out',
onBeforeAction: () ->
Meteor.logout ->
Router.go('/')
next()
this.route 'notfound', {path: '*'}
# Common subscription that need to be loaded on all routes
###
@preloadSubs = []
preloadSubs.push('settings')
if(Meteor.isServer)
Router.onAllRoutes ->
router = this
_.each @preloadSubs, (sub) ->
router.subscribe(sub)
###