forked from zenorocha/browser-diet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docpad.coffee
108 lines (90 loc) · 3.62 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
module.exports =
# =================================
# Template Data
templateData:
# -----------------------------
# Language Definition
currentLang: 'en'
lang:
en:
title: 'How to lose weight (in the browser)'
titleHTML: '<h1>How to lose <span>weight</span></h1><h2>in the browser</h2>'
slogan: 'The definitive front-end performance guide'
url: 'http://browserdiet.com'
bonus: 'Bonus'
images: 'Images'
server: 'Server'
edit: 'Edit'
goTop: 'Go to the top'
htmlLang: 'en-US'
pt:
title: 'Como perder peso (no browser)'
titleHTML: '<h1>Como perder <span>peso</span></h1><h2>no browser</h2>'
slogan: 'O guia definitivo de performance para o desenvolvedor front-end'
url: 'http://browserdiet.com/pt'
bonus: 'Bônus'
images: 'Imagens'
server: 'Servidor'
edit: 'Editar'
goTop: 'Ir para o topo'
htmlLang: 'pt-BR'
# -----------------------------
# Site Information
site:
assets: 'http://browserdiet.com'
getGruntedStyles: ->
_ = require 'underscore'
styles = []
gruntConfig = require('./grunt-config.json')
_.each gruntConfig, (value, key) ->
styles = styles.concat _.flatten _.pluck value, 'dest'
styles = _.filter styles, (value) ->
return value.indexOf('.min.css') > -1
_.map styles, (value) ->
return value.replace 'out', ''
getGruntedScripts: ->
_ = require 'underscore'
scripts = []
gruntConfig = require('./grunt-config.json')
_.each gruntConfig, (value, key) ->
scripts = scripts.concat _.flatten _.pluck value, 'dest'
scripts = _.filter scripts, (value) ->
return value.indexOf('.min.js') > -1
_.map scripts, (value) ->
return value.replace 'out', ''
getLang: ->
currentLang = @currentLang.toString()
return @lang[currentLang]
# =================================
# Environments
environments:
development:
templateData:
site:
url: 'http://localhost:9778'
assets: 'http://localhost:9778/assets'
# =================================
# DocPad Events
events:
# Write After
# Used to minify our assets with grunt
writeAfter: (opts,next) ->
# Prepare
docpad = @docpad
rootPath = docpad.config.rootPath
balUtil = require 'bal-util'
_ = require 'underscore'
# Make sure to register a grunt `default` task
command = ["#{rootPath}/node_modules/.bin/grunt", 'default']
# Execute
balUtil.spawn command, {cwd:rootPath,output:true}, ->
src = []
gruntConfig = require './grunt-config.json'
_.each gruntConfig, (value, key) ->
src = src.concat _.flatten _.pluck value, 'src'
_.each src, (value) ->
balUtil.spawn ['rm', value], {cwd:rootPath, output:false}, ->
balUtil.spawn ['find', '.', '-type', 'd', '-empty', '-exec', 'rmdir', '{}', '\;'], {cwd:rootPath+'/out', output:false}, ->
next()
# Chain
@