-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
.Gruntfile.coffee
327 lines (320 loc) · 12.7 KB
/
.Gruntfile.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
321
322
323
324
325
326
327
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
clean:
codemirror:
src: [
'client/codemirror/*.js'
]
css:
src: [
'client/*.min.css'
]
old: # used to be copied via Grunt
src: [
'client/bootstrap/bootstrap-slider.min.css'
]
less:
options: ## Based on node_modules/bootstrap/Gruntfile.js
ieCompat: true
strictMath: true
light:
src: 'node_modules/bootstrap/less/bootstrap.less'
dest: '.bootstrap/light.css'
options:
modifyVars:
'blockquote-font-size': '@font-size-base' # usually * 1.25
dark:
## Colors based in part on Cyborg theme distributed under MIT License:
## https://github.com/thomaspark/bootswatch/blob/v3/cyborg/variables.less
options:
modifyVars:
'blockquote-font-size': '@font-size-base' # usually * 1.25
#'brand-primary': '#2A9FD6'
#'brand-success': '#77B300'
#'brand-info': '#9933CC'
#'brand-warning': '#FF8800'
#'brand-danger': '#CC0000'
'body-bg': '#060606'
'link-color': 'lighten(@brand-primary, 25%)'
'text-color': '@gray-lighter'
'panel-bg': '@body-bg'
'panel-inner-border': '@gray-dark'
'panel-footer-bg': 'lighten(@gray-darker, 10%)'
'panel-default-text': '@text-color'
'panel-default-border': '@gray-darker'
'panel-default-heading-bg': '@gray-darker'
'btn-default-color': '@text-color'
'btn-default-bg': 'lighten(@gray-dark, 10%)'
'btn-default-border': 'darken(@btn-default-bg, 5%)'
'btn-info-color': '#000'
'btn-success-color': '#000'
'btn-warning-color': '#000'
'link-hover-color': 'lighten(@link-color, 15%);' # usually darken
'tooltip-bg': '@gray-darker'
'navbar-default-color': '@text-color'
'navbar-default-bg': '@gray-darker'
'navbar-default-link-color': '@text-color'
'navbar-default-link-hover-color': '#fff'
'navbar-default-link-active-color': '#fff'
'navbar-default-link-active-bg': 'transparent'
'navbar-default-link-disabled-color': '@gray-light'
'navbar-default-brand-color': '#fff'
'navbar-default-brand-hover-color': '#fff'
'navbar-default-toggle-hover-bg': '@gray-dark'
'navbar-default-toggle-icon-bar-bg': '#ccc'
'navbar-default-toggle-border-color': '@gray-dark'
'nav-link-hover-bg': '@gray-darker'
'nav-tabs-border-color': '@gray-dark'
'nav-tabs-link-hover-border-color': 'transparent'
'nav-tabs-active-link-hover-bg': '@brand-primary'
'nav-tabs-active-link-hover-color': '#fff'
'nav-tabs-active-link-hover-border-color': '@gray-dark'
'pre-bg': '@gray-darker'
'pre-color': '@gray-lighter'
'pre-border-color': '@gray-dark'
'dropdown-bg': '@gray-darker'
'dropdown-border': 'rgba(255,255,255,0.1)'
'dropdown-fallback-border': '#444'
'dropdown-divider-bg': 'rgba(255,255,255,0.1)'
'dropdown-link-color': '#fff'
'dropdown-link-hover-color': 'darken(@dropdown-link-color, 0%)'
'dropdown-link-hover-bg': '@gray'
'table-bg': 'darken(@gray-darker, 4%)'
'table-bg-accent': 'darken(@table-bg, 6%)'
'table-bg-hover': '@gray-dark'
'table-border-color': '@gray-dark'
'state-success-text': '#fff'
'state-success-bg': 'darken(@brand-success, 35%)'
'state-info-text': '#fff'
'state-info-bg': 'darken(@brand-info, 45%)'
'state-warning-text': '#fff'
'state-warning-bg': 'darken(@brand-warning, 45%)'
'state-danger-text': '#fff'
'state-danger-bg': 'darken(@brand-danger, 35%)'
'modal-content-bg': 'lighten(@body-bg, 10%)'
'modal-header-border-color': '@gray-dark'
'input-bg': '@gray-darker'
'input-color': '@text-color'
'input-border': '@gray-dark'
'input-color-placeholder': '@gray-light'
'input-bg-disabled': '@gray-dark'
'legend-color': '@text-color'
'legend-border-color': '@gray-dark'
'progress-bg': '@gray-darker'
'list-group-bg': '@gray-darker'
'list-group-border': '@gray-dark'
'list-group-hover-bg': 'lighten(@list-group-bg, 15%)'
'list-group-link-color': '@text-color'
'list-group-link-heading-color': '#fff'
'label-color': '#000'
'label-link-hover-color': '#000'
'blockquote-border-color': '@gray-dark'
src: 'node_modules/bootstrap/less/bootstrap.less'
dest: '.bootstrap/dark.css'
copy:
katex_fonts:
expand: true
cwd: 'node_modules/katex/dist/fonts/'
src: '**'
dest: 'public/katex/fonts/'
codemirrorCSS:
expand: true
flatten: true
src: [
'node_modules/codemirror/theme/blackboard.css'
#'node_modules/codemirror/theme/eclipse.css'
'node_modules/codemirror/addon/dialog/dialog.css'
'node_modules/codemirror/addon/fold/foldgutter.css'
'node_modules/codemirror/addon/hint/show-hint.css'
]
dest: 'client/codemirror/'
pdfjs:
expand: true
flatten: true
src: 'node_modules/pdfjs-dist/build/pdf.worker.min.js'
dest: 'public/'
bootstrap:
expand: true
flatten: true
src: [
'node_modules/bootstrap/dist/js/bootstrap.min.js'
]
dest: 'client/bootstrap/'
replace:
katex:
options:
patterns: [
match: /url\(fonts/g
replacement: 'url(/katex/fonts'
]
files: [
expand: true
flatten: true
src: 'node_modules/katex/dist/katex.min.css'
dest: 'client/'
]
codemirrorCSS:
options:
patterns: [
## This rule causes enumerated lists in Markdown to get
## highlighted, overriding math highlighting for example.
match: /\.cm[-a-z]* span\.cm-variable-[23].*/g
replacement: ''
]
files: [
expand: true
flatten: true
src: 'node_modules/codemirror/theme/eclipse.css'
dest: 'client/codemirror/'
]
codemirror:
options:
patterns: [
match: /require\("codemirror\/lib\/codemirror"\)/
replacement: 'require("codemirror")'
,
match: /require\("..\//g
replacement: 'require("codemirror/mode/'
,
match: /require\("..\/..\//g
replacement: 'require("codemirror/'
# match: /\(function[^]*?function\(CodeMirror\) {/
# replacement: 'const CodeMirror = require("meteor/edemaine:sharejs-codemirror/node_modules/codemirror/lib/codemirror.js");'
#,
# match: /}\);\s*$/
# replacement: ''
,
match: /\|coap\|/
replacement: '|coap|coauthor|'
,
match: /newlineAndIndentContinueMarkdownList/
replacement: 'xnewlineAndIndentContinueMarkdownList'
,
match: /cm\.getMode\(\)\.innerMode\(/
replacement: 'CodeMirror.innerMode(cm.getMode(), '
]
files: [
expand: true
flatten: true
src: [
'node_modules/codemirror/addon/hint/show-hint.js'
#'node_modules/codemirror/mode/markdown/markdown.js'
'node_modules/codemirror/mode/gfm/gfm.js'
#'node_modules/codemirror/mode/xml/xml.js'
#'node_modules/codemirror/mode/meta.js'
#'node_modules/codemirror/mode/stex/stex.js'
#'node_modules/codemirror/keymap/vim.js'
#'node_modules/codemirror/keymap/emacs.js'
#'node_modules/codemirror/addon/dialog/dialog.js'
#'node_modules/codemirror/addon/edit/matchbrackets.js'
'node_modules/codemirror/addon/edit/continuelist.js'
#'node_modules/codemirror/addon/fold/foldcode.js'
#'node_modules/codemirror/addon/fold/foldgutter.js'
#'node_modules/codemirror/addon/fold/markdown-fold.js'
#'node_modules/codemirror/addon/fold/xml-fold.js'
#'node_modules/codemirror/addon/mode/overlay.js'
#'node_modules/codemirror/addon/search/searchcursor.js'
#'node_modules/codemirror/addon/search/search.js'
#'node_modules/codemirror/addon/search/jump-to-line.js' # alt-G
#'node_modules/codemirror/addon/selection/active-line.js'
]
dest: 'client/codemirror/'
]
bootstrap:
options:
patterns: [
match: /@font-face\s*{\s*font-family:\s*"Glyphicons[^]*?\*/
replacement: '*'
]
files: [
expand: true
flatten: true
src: [
'.bootstrap/dark.css'
'.bootstrap/light.css'
]
dest: '.bootstrap/noglyphicon'
]
cssmin:
options: ## Based on node_modules/bootstrap/Gruntfile.js
compatibility: 'ie8'
level:
1:
specialComments: 'all'
light:
src: '.bootstrap/noglyphicon/light.css'
dest: 'public/bootstrap/light.min.css'
dark:
src: '.bootstrap/noglyphicon/dark.css'
dest: 'public/bootstrap/dark.min.css'
grunt.loadNpmTasks 'grunt-contrib-clean'
grunt.loadNpmTasks 'grunt-contrib-copy'
grunt.loadNpmTasks 'grunt-replace-regex'
grunt.loadNpmTasks 'grunt-contrib-less'
grunt.loadNpmTasks 'grunt-contrib-cssmin'
grunt.registerTask 'default', [
'clean'
'less'
'copy'
'replace'
'cssmin'
]
## Convert timezones into autocompletion list
fs = require 'fs'
meta = JSON.parse fs.readFileSync 'node_modules/moment-timezone/data/meta/latest.json', encoding: 'utf8'
zones = JSON.parse fs.readFileSync 'node_modules/moment-timezone/data/packed/latest.json', encoding: 'utf8'
timezones =
for zone in zones.zones
#name = zone.name ## unpacked format
name = zone
name = name[...name.indexOf '|'] if '|' in name ## packed format
if name of meta.zones
countries = meta.zones[name].countries
countries = (meta.countries[country].name for country in countries)
name += " (#{countries.join ', '})"
name
fs.writeFileSync 'public/timezones.json', JSON.stringify timezones
## Compute mapping of highlight.js language aliases to language imports
highlight = require 'highlight.js'
aliases = {}
for language in highlight.listLanguages()
for alias in highlight.getLanguage(language).aliases ? []
aliases[alias] = language
quote = (x) ->
if /^[a-zA-Z]+$/.test x
x
else
"'#{x}'"
fs.writeFileSync 'client/lib/highlight.coffee', """
## File generated automatically by ../../.Gruntfile.coffee -- DO NOT EDIT
## This client-side version loads highlight.js languages as needed.
import hljs from 'highlight.js/lib/core' # minimal library
languages =
#{(
for language in highlight.listLanguages()
" #{quote language}: -> import('highlight.js/lib/languages/#{language}')"
).join '\n'}
aliases =
#{(
for key, value of aliases
" #{quote key}: '#{value}'"
).join '\n'}
loaded = new ReactiveDict
@highlight = (text, lang) ->
return '' unless lang
if hljs.getLanguage lang
try
return hljs.highlight text,
language: lang
ignoreIllegals: true
.value
else
lang = aliases[lang] if lang of aliases
if lang of languages
loaded.get lang # reload when loaded
languages[lang]().then (module) ->
hljs.registerLanguage lang, module.default unless hljs.getLanguage lang
loaded.set lang, true
'' ## markdown-it's default formatting
"""