forked from meteor-blog/meteor-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.coffee
64 lines (55 loc) · 1.7 KB
/
router.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
Router.map ->
@route 'blogIndex',
path: '/blog'
before: ->
if Blog.settings.blogIndexTemplate
@template = Blog.settings.blogIndexTemplate
waitOn: ->
[ Meteor.subscribe 'posts'
Meteor.subscribe 'authors' ]
fastRender: true
data: ->
posts: Post.where { published: true }, { sort: { publishedAt: -1 }}
@route 'blogShow',
path: '/blog/:slug'
notFoundTemplate: 'blogNotFound'
before: ->
if Blog.settings.blogShowTemplate
@template = Blog.settings.blogShowTemplate
Session.set 'postSlug', @params.slug
waitOn: ->
[ Meteor.subscribe 'singlePost', this.params.slug
Meteor.subscribe 'authors' ]
fastRender: true
data: ->
Post.first slug: @params.slug
@route 'blogAdmin',
path: '/admin/blog'
waitOn: ->
[ Meteor.subscribe 'posts'
Meteor.subscribe 'authors' ]
before: ->
if Meteor.loggingIn()
return @stop()
if not Meteor.user() || not Roles.userIsInRole(Meteor.user(), 'blogAdmin')
return @redirect('/blog')
@route 'blogAdminNew',
path: '/admin/blog/new'
before: ->
if Meteor.loggingIn()
return @stop()
if not Meteor.user() || not Roles.userIsInRole(Meteor.user(), 'blogAdmin')
return @redirect('/blog')
@route 'blogAdminEdit',
path: '/admin/blog/edit/:slug'
waitOn: ->
[ Meteor.subscribe 'posts'
Meteor.subscribe 'authors' ]
data: ->
Post.first slug: @params.slug
before: ->
if Meteor.loggingIn()
return @stop()
if not Meteor.user() || not Roles.userIsInRole(Meteor.user(), 'blogAdmin')
return @redirect('/blog')
Session.set 'postSlug', @params.slug