-
Notifications
You must be signed in to change notification settings - Fork 126
/
boot.coffee
64 lines (50 loc) · 2.01 KB
/
boot.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
################################################################################
# Bootstrap Code
#
Blog.subs = new SubsManager
cacheLimit: 10, # Maximum number of cache subscriptions
expireIn: 5 # Any subscription will be expire after 5 minute, if it's not subscribed again
Meteor.startup ->
ShareIt.init Blog.settings.shareit
if Blog.settings.syntaxHighlightingTheme
# Syntax Highlighting
$('<link>',
href: '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.1/styles/' + Blog.settings.syntaxHighlightingTheme + '.min.css'
rel: 'stylesheet'
).appendTo 'head'
if Blog.settings.cdnFontAwesome
# Load Font Awesome
$('<link>',
href: '//netdna.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.css'
rel: 'stylesheet'
).appendTo 'head'
# Listen for any 'Load More' clicks
$('body').on 'click', '.blog-load-more', (e) ->
e.preventDefault()
if Session.get 'blog.postLimit'
Session.set 'blog.postLimit', Session.get('blog.postLimit') + Blog.settings.pageSize
################################################################################
# Register Global Helpers
#
Template.registerHelper 'BlogLanguage', () ->
return Blog.settings.language
Template.registerHelper "blogFormatDate", (date) ->
moment(new Date(date)).format Blog.settings.dateFormat
Template.registerHelper "blogFormatTags", (tags) ->
return if !tags?
for tag in tags
path = Blog.Router.pathFor 'blogTagged', tag: tag
if str?
str += ", <a href=\"#{path}\">#{tag}</a>"
else
str = "<a href=\"#{path}\">#{tag}</a>"
return new Spacebars.SafeString str
Template.registerHelper "blogJoinTags", (list) ->
if list
list.join ', '
Template.registerHelper "blogPager", ->
if Blog.Post.count() is Session.get 'blog.postLimit'
loadMore = Blog.settings.language.loadMore
return new Spacebars.SafeString '<a class="blog-load-more btn" href="#">' + loadMore + '</a>'
Template.registerHelper 'blogPathFor', (name, options) ->
return Blog.Router.pathFor name, @, options