forked from rigoneri/syte
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdocpad.coffee
320 lines (263 loc) · 11 KB
/
docpad.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# =================================
# Prepare
# Import
extendr = require('extendr')
moment = require('moment')
# Environment
envConfig = process.env
# =================================
# DocPad Configuration
# The DocPad Configuration File
# It is simply a CoffeeScript Object which is parsed by CSON
module.exports =
# =================================
# DocPad Options
# Regenerate Every
# Performs a Regenerate every x milliseconds, useful for always having the latest data
regenerateEvery: 60*60*1000 # hour
# regenerateEvery: 10*1000 # minute
# Turn on database caching to speed up importing
databaseCache: true
# =================================
# Template Data
# These are variables that will be accessible via our templates
# To access one of these within our templates, refer to the FAQ: https://github.com/bevry/docpad/wiki/FAQ
templateData:
# Extend
extend: extendr.deepExtend.bind(extendr)
# Moment
moment: moment
# Specify the theme we are using
theme: "metro"
# Specify some site properties
site:
# The production url of our website
url: (websiteUrl = "http://your-website.com")
# The default title of our website
title: "Your Website"
# The website author's name
author: "Your Name"
# The website author's email
email: "b@lupton.cc"
# The website heading to be displayed on the page
heading: 'Your Website'
# The website subheading to be displayed on the page
subheading: """
Welcome to your new <t>links.docpad</t> website!
"""
# Footer
footnote: """
This website was created with <t>links.bevry</t>’s <t>links.docpad</t>
"""
copyright: """
Your chosen license should go here...
Not sure what a license is? Refer to the
<code>README.md</code> file included in this website.
"""
# The website description (for SEO)
description: """
When your website appears in search results in say Google
, the text here will be shown underneath your website's title.
"""
# The website keywords (for SEO) separated by commas
keywords: """
place, your, website, keywords, here, keep
, them, related, to, the, content, of, your, website
"""
# Styles
styles: [
"/styles/styles.css"
"/fonts/syte/css/syte.css"
]
# Scripts
scripts: [
"/vendor/jquery.js"
"/vendor/log.js"
"/vendor/modernizr.js"
"/scripts/script.js"
]
# Specify some feeds available for the visitors of our website
feeds: [
# This is the feed generated by our DocPad website
# It contains all the posts, you can find the source file in src/documents/atom.xml.eco
href: "#{websiteUrl}/atom.xml"
name: 'Blog Posts'
]
# Do you have social accounts?
# Mention them here and our layout will include them in the sidebar
# If you specify a feed for the Feedr plugin (specified later on)
# then we will pull in their feed data too for recognised services
social:
# Twitter
twitter:
name: 'Twitter'
url: "//twitter.com/#{envConfig.TWITTER_USERNAME}"
#profile:
# feeds:
# tweets: 'twitter'
# GitHub
github:
name: 'GitHub'
url: "//github.com/#{envConfig.GITHUB_USERNAME}"
profile:
feeds:
user: 'githubUser'
repos: 'githubRepos'
# Vimeo
vimeo:
name: 'Vimeo'
url: "//vimeo.com/#{envConfig.VIMEO_USERNAME}"
# Flickr
flickr:
name: 'Flickr'
url: "//www.flickr.com/people/#{envConfig.FLICKR_USER_ID}"
profile:
feeds:
user: 'flickrUser'
photos: 'flickrPhotos'
# Soundcloud
soundcloud:
name: 'Soundcloud'
url: "//soundcloud.com/#{envConfig.SOUNDCLOUD_USERNAME}"
profile:
feeds:
user: 'soundcloudUser'
tracks: 'soundcloudTracks'
# Instagram
instagram:
name: 'Instagram'
url: "//instagram.com/#{envConfig.INSTAGRAM_USER_ID}"
profile:
feeds:
user: 'instagramUser'
media: 'instagramMedia'
# Codepen
Codepen:
name: 'Codepen'
url: "//codepen.io/#{envConfig.CODEPEN_USERNAME}"
feeds:
user: 'codepenUser'
# Geeklist
Geeklist:
name: 'Geeklist'
url: "//geekli.st/#{envConfig.GEEKLIST_USERNAME}"
profile:
feeds:
user: 'geeklistUser'
activity: 'geeklistActivity'
links: 'geeklistLinks'
hack4good: 'geeklistHack4Good'
me: 'geeklistMe'
# -----------------------------
# Common links used throughout the website
links:
docpad: '<a href="//github.com/bevry/docpad" title="Visit on GitHub">DocPad</a>'
historyjs: '<a href="//github.com/balupton/history.js" title="Visit on GitHub">History.js</a>'
bevry: '<a href="//bevry.me" title="Visit Website">Bevry</a>'
opensource: '<a href="//en.wikipedia.org/wiki/Open-source_software" title="Visit on Wikipedia">Open-Source</a>'
html5: '<a href="//en.wikipedia.org/wiki/HTML5" title="Visit on Wikipedia">HTML5</a>'
javascript: '<a href="//en.wikipedia.org/wiki/JavaScript" title="Visit on Wikipedia">JavaScript</a>'
nodejs: '<a href="//nodejs.org/" title="Visit Website">Node.js</a>'
author: '<a href="//balupton.com" title="Visit Website">Benjamin Lupton</a>'
cclicense: '<a href="//creativecommons.org/licenses/by/3.0/" title="Visit Website">Creative Commons Attribution License</a>'
mitlicense: '<a href="//creativecommons.org/licenses/MIT/" title="Visit Website">MIT License</a>'
contact: '<a href="mailto:b@bevry.me" title="Email me">Email</a>'
# -----------------------------
# Helper Functions
# Get Gravatar URL
getGravatarUrl: (email,size) ->
hash = require('crypto').createHash('md5').update(email).digest('hex')
url = "//www.gravatar.com/avatar/#{hash}.jpg"
if size then url += "?s=#{size}"
return url
# Get Profile Feeds
getSocialFeeds: (socialID) ->
feeds = {}
for feedID,feedKey of @site.social[socialID].profile.feeds
feeds[feedID] = @feedr.feeds[feedKey]
return feeds
# Get the prepared site/document title
# Often we would like to specify particular formatting to our page's title
# we can apply that formatting here
getPreparedTitle: ->
# if we have a document title, then we should use that and suffix the site's title onto it
if @document.title
"#{@document.title} | #{@site.title}"
# if our document does not have it's own title, then we should just use the site's title
else
@site.title
# Get the prepared site/document description
getPreparedDescription: ->
# if we have a document description, then we should use that, otherwise use the site's description
@document.description or @site.description
# Get the prepared site/document keywords
getPreparedKeywords: ->
# Merge the document keywords with the site keywords
@site.keywords.concat(@document.keywords or []).join(', ')
# =================================
# Collections
# These are special collections that our website makes available to us
collections:
# For instance, this one will fetch in all documents that have pageOrder set within their meta data
pages: (database) ->
database.findAllLive({pageOrder: $exists: true}, [pageOrder:1,title:1])
# This one, will fetch in all documents that have the tag "post" specified in their meta data
posts: (database) ->
database.findAllLive({tags: $has: 'post'}, [date:-1])
# =================================
# Plugin Configuration
# This is where we configure the different plugins that are loaded with DocPad
# To configure a plugin, specify it's name, and then the options you want to configure it with
plugins:
# Tumblr
tumblr:
extension: '.html.eco'
injectDocumentHelper: (document) ->
document.setMeta(
layout: 'page'
tags: (document.get('tags') or []).concat(['post'])
data: """
<%- @partial('content/'+@document.tumblr.type, @extend({}, @document, @document.tumblr)) %>
"""
)
# Tags
tags:
extension: '.html.eco'
injectDocumentHelper: (document) ->
document.setMeta(
layout: 'page'
data: """
<%- @partial('content/tag', @) %>
"""
)
# Configure the Feedr Plugin
# The Feedr Plugin will pull in remote feeds specified here and make their contents available to our templates
feedr:
# These are the feeds that Feedr will pull in
feeds:
# Twitter
# twitter: url: "//api.twitter.com/1/statuses/user_timeline.json?screen_name=#{envConfig.TWITTER_USERNAME}&count=50&include_entities=false&include_rts=false&exclude_replies=true"
# Github
githubUser: url: "//api.github.com/users/#{envConfig.GITHUB_USERNAME}?client_id=#{envConfig.GITHUB_CLIENT_ID}&client_secret=#{envConfig.GITHUB_CLIENT_SECRET}"
githubRepos: url: "//api.github.com/users/#{envConfig.GITHUB_USERNAME}/repos?sort=updated&client_id=#{envConfig.GITHUB_CLIENT_ID}&client_secret=#{envConfig.GITHUB_CLIENT_SECRET}"
# Vimeo
vimeo: url: "http://vimeo.com/api/v2/#{envConfig.VIMEO_USERNAME}/videos.json"
# Flickr
flickrUser:
url: "http://api.flickr.com/services/rest/?method=flickr.people.getInfo&api_key=#{envConfig.FLICKR_API_KEY}&user_id=#{envConfig.FLICKR_USER_ID}&format=json&nojsoncallback=1"
clean: true
flickrPhotos: url: "http://api.flickr.com/services/feeds/photos_public.gne?id=#{envConfig.FLICKR_USER_ID}&lang=en-us&format=json&nojsoncallback=1"
# Soundcloud
soundcloudUser: url: "//api.soundcloud.com/users/#{envConfig.SOUNDCLOUD_USERNAME}.json?client_id=#{envConfig.SOUNDCLOUD_CLIENT_ID}"
soundcloudTracks: url: "//api.soundcloud.com/users/#{envConfig.SOUNDCLOUD_USERNAME}/tracks.json?client_id=#{envConfig.SOUNDCLOUD_CLIENT_ID}"
# Instagram
instagramUser: url: "//api.instagram.com/v1/users/#{envConfig.INSTAGRAM_USER_ID}?client_id=#{envConfig.INSTAGRAM_CLIENT_ID}"
instagramMedia: url: "//api.instagram.com/v1/users/#{envConfig.INSTAGRAM_USER_ID}/media/recent?access_token=#{envConfig.INSTAGRAM_ACCESS_TOKEN}"
# Codepen
codepenUser: url: "http://codepen.io/#{envConfig.CODEPEN_USERNAME}/activity/feed"
# Geeklist
geeklistActivity: url: "//geekli.st/#{envConfig.GEEKLIST_USERNAME}/activity"
geeklistDiscovery: url: "//geekli.st/#discovery"
geeklistLinks: url: "//geekli.st/#link"
geeklistHack4Good: url: "//geekli.st/#hack4good"
geeklistUser: url: "//geekli.st/#at"