forked from nbproject/nbproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grunt.js
455 lines (423 loc) · 20.9 KB
/
grunt.js
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
/*global module:false console:true require:false*/
module.exports = function(grunt) {
var execSync = require('execSync');
var servername = execSync.stdout("python -c 'from __future__ import print_function;from apps.settings import NB_SERVERNAME;print(NB_SERVERNAME, end=\"\")'");
var serverport = execSync.stdout("python -c 'from __future__ import print_function;from apps.settings import NB_HTTP_PORT;print(NB_HTTP_PORT, end=\"\")'");
if (serverport !== "80"){
servername += ":"+serverport;
}
var addPrefix = function(prefix, names){
/*
* given a prefix and an array, returns a new array where each element
* is prefixed by the prefix
*/
var output = [];
for (var i in names){
output.push(prefix+names[i]);
}
return output;
};
var unique = function(names){
/*
* returns a new array with the subsequent occurences of a string removed.
* for instance unique(["a", "b", "c", "a", "d", "a"]) returns ["a", "b", "c", "d"]
*/
var index = {};
var output = [];
for (var i in names){
if (!(names[i] in index)){
index[names[i]] = null;
output.push(names[i]);
}
}
return output;
};
var MODULE_DIR = "content/modules/";
var UI_DIR = "content/ui/admin/";
var UITEST_DIR = "content/ui/test/";
var DEST_DIR = "content/compiled/";
/* MODS are modules that serve as building blocks, without being built themselves */
var MODS = {};
MODS.CONTEXTMENU = {
src_js: addPrefix(MODULE_DIR,["contextmenu/jquery.contextMenu.js"]),
src_css: addPrefix(MODULE_DIR, ["contextmenu/jquery.contextMenu.css"])
};
MODS.TREEVIEW = {
src_js: addPrefix(MODULE_DIR,["jstree/jquery.jstree.js", "dev/ui.treeview7.js"]),
src_css: addPrefix(MODULE_DIR, ["jstree/themes/default/style.css" , "dev/ui.treeview.css"])
};
MODS.FILESVIEW = {
src_js: [].concat(
MODS.CONTEXTMENU.src_js,
addPrefix(MODULE_DIR,["tablesorter/jquery.tablesorter.min.js", "calendrical/jquery.calendrical.js", "dev/ui.filesview4.js"])),
src_css: [].concat(
MODS.CONTEXTMENU.src_css,
addPrefix(MODULE_DIR, ["tablesorter/style.css", "calendrical/calendrical.css", "dev/ui.filesview.css"]))
};
MODS.DOCVIEW = {
src_js: addPrefix(MODULE_DIR,["dev/ui.drawable4.js", "dev/ui.docView8.js" ]),
src_css: addPrefix(MODULE_DIR, ["dev/ui.drawable.css", "dev/ui.docView.css"])
};
MODS.DOCVIEW_COLLAGE = {
src_js: addPrefix(MODULE_DIR,["dev/ui.drawable4.js", "dev/ui.docView9.js" ]),
src_css: addPrefix(MODULE_DIR, ["dev/ui.drawable.css", "dev/ui.docView.css"])
};
MODS.DOCVIEW_SPREADSHEET = {
src_js: addPrefix(MODULE_DIR,["dev/ui.drawable4.js", "dev/ui.docView10.js" ]),
src_css: addPrefix(MODULE_DIR, ["dev/ui.drawable.css", "dev/ui.docView.css"])
};
MODS.DOCVIEW_YOUTUBE = {
src_js: addPrefix(MODULE_DIR,["dev/ui.drawable4.js", "dev/ui.docView11.js" ]),
src_css: addPrefix(MODULE_DIR, ["dev/ui.drawable.css", "dev/ui.docView.css"])
};
MODS.NOTEPANEVIEW_DOC = {
src_js: [].concat(
MODS.CONTEXTMENU.src_js,
addPrefix(MODULE_DIR,["dev/ui.notepaneView8.js"])),
src_css: [].concat(
MODS.CONTEXTMENU.src_css,
addPrefix(MODULE_DIR, ["dev/ui.notepaneView.css"]))
};
MODS.NOTEPANEVIEW_COLLAGE = {
src_js: [].concat(
MODS.CONTEXTMENU.src_js,
addPrefix(MODULE_DIR,["dev/ui.notepaneView9.js"])),
src_css: [].concat(
MODS.CONTEXTMENU.src_css,
addPrefix(MODULE_DIR, ["dev/ui.notepaneView.css"]))
};
MODS.NOTEPANEVIEW_SPREADSHEET = {
src_js: [].concat(
MODS.CONTEXTMENU.src_js,
addPrefix(MODULE_DIR,["dateformat/date.format.js"]),
addPrefix(MODULE_DIR,["dev/ui.notepaneView10.js"])),
src_css: [].concat(
MODS.CONTEXTMENU.src_css,
addPrefix(MODULE_DIR, ["dev/ui.notepaneView.css"]))
};
MODS.NOTEPANEVIEW_YOUTUBE = {
src_js: [].concat(
MODS.CONTEXTMENU.src_js,
addPrefix(MODULE_DIR,["dev/ui.notepaneView11.js"])),
src_css: [].concat(
MODS.CONTEXTMENU.src_css,
addPrefix(MODULE_DIR, ["dev/ui.notepaneView.css"]))
};
MODS.THREADVIEW = {
src_js: [].concat(
MODS.CONTEXTMENU.src_js,
addPrefix(MODULE_DIR,["dateformat/date.format.js"]),
addPrefix(MODULE_DIR,["dev/ui.threadview.js"])),
src_css: [].concat(
MODS.CONTEXTMENU.src_css,
addPrefix(MODULE_DIR, ["dev/ui.threadview.css"]))
};
MODS.EDITORVIEW = {
src_js: addPrefix(MODULE_DIR,["dev/ui.editorview.js" ]),
src_css: addPrefix(MODULE_DIR, ["dev/ui.editorview.css"])
};
MODS.RANGY = {
src_js: addPrefix(MODULE_DIR+"rangy/",["rangy-core.js", "rangy-cssclassapplier.js", "rangy-textrange.js", "termfix.js" ]),
src_css: []
};
MODS.SPREADSHEETVIEW = {
src_js: addPrefix(MODULE_DIR,["dev/ui.spreadsheetView1.js" ]),
src_css: addPrefix(MODULE_DIR, ["dev/ui.spreadsheetView1.css"])
};
/* TARGETS are modules that are built (but they can also serve as building blocks) */
var TARGETS = {};
TARGETS.API = {
src_js: addPrefix(MODULE_DIR, ["NB.js", "auth.js", "dom.js", "mvc.js", "dev/models.js"]),
dest_js: DEST_DIR+"apidev_NB.js"
};
TARGETS.TRAIL = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "dev/ui.concierge.js"]),
addPrefix(MODULE_DIR, ["dateformat/date.format.js"]),
TARGETS.API.src_js,
addPrefix(UI_DIR,["conf.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js", "dev/buildTrail.js"])
),
dest_js: DEST_DIR+"buildTrail_NB.js"
};
TARGETS.EMBED = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "jquery_ui/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js", "dev/ui.concierge.js"]),
addPrefix(MODULE_DIR, ["dev/ui.view.js", "dev/ui.perspective.js"]),
MODS.NOTEPANEVIEW_DOC.src_js,
MODS.THREADVIEW.src_js,
MODS.EDITORVIEW.src_js,
TARGETS.API.src_js,
MODS.RANGY.src_js,
addPrefix(MODULE_DIR, ["wgxpath/wgxpath.install.js"]),
addPrefix(MODULE_DIR+"wgxpath/",["termfix.js" ]),
addPrefix(UI_DIR,["conf.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js", "dev/docviewHtml5.js", "dev/buildEmbed.js"])
),
dest_js: DEST_DIR+"embed_NB.js",
src_css: [].concat(
addPrefix(MODULE_DIR, ["jquery_ui/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css", "ui.perspective.css", "ui.viewport.css", "ui.menu.css", "ui.view.css", "dev/buildEmbed.css"]),
addPrefix(UI_DIR, ["template.css"]),
MODS.NOTEPANEVIEW_DOC.src_css,
MODS.THREADVIEW.src_css,
MODS.EDITORVIEW.src_css
),
dest_css: DEST_DIR+"embed_NB.css",
servername: servername
};
TARGETS.DESKTOP = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "jquery_ui/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js", "dev/ui.concierge.js"]),
addPrefix(MODULE_DIR, ["dev/ui.view.js", "dev/ui.perspective.js"]),
TARGETS.API.src_js,
MODS.TREEVIEW.src_js,
MODS.FILESVIEW.src_js,
addPrefix(UI_DIR,["conf.js", "conf_local.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js", "dev/files.js"]),
addPrefix(UI_DIR, ["step21.js", "launch.js"])
),
src_css: [].concat(
addPrefix(MODULE_DIR, ["jquery_ui/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css", "ui.perspective.css", "ui.viewport.css", "ui.menu.css", "ui.view.css"]),
addPrefix(UI_DIR, ["template.css"]),
MODS.TREEVIEW.src_css,
MODS.FILESVIEW.src_css
),
dest_js: DEST_DIR+"desktop_NB.js",
dest_css: DEST_DIR+"desktop.css"
};
TARGETS.LOGIN = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "dev/ui.concierge.js"]),
TARGETS.API.src_js,
addPrefix(UI_DIR,["conf.js", "conf_local.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js"]),
addPrefix(UI_DIR, ["login.js"])
),
src_css: [].concat(
addPrefix(UI_DIR, ["template.css"])
),
dest_js: DEST_DIR+"login_NB.js",
dest_css: DEST_DIR+"login.css"
};
TARGETS.PDFVIEWER = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "jquery_ui/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js", "dev/ui.concierge.js"]),
addPrefix(MODULE_DIR, ["dev/ui.view.js", "dev/ui.perspective.js"]),
TARGETS.API.src_js,
MODS.DOCVIEW.src_js,
MODS.NOTEPANEVIEW_DOC.src_js,
MODS.THREADVIEW.src_js,
MODS.EDITORVIEW.src_js,
addPrefix(UI_DIR,["conf.js", "conf_local.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js"]),
addPrefix(UI_DIR, ["step16.js", "launch.js"])
),
src_css: [].concat(
addPrefix(MODULE_DIR, ["jquery_ui/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css", "ui.perspective.css", "ui.viewport.css", "ui.menu.css", "ui.view.css"]),
addPrefix(UI_DIR, ["template.css"]),
MODS.DOCVIEW.src_css,
MODS.NOTEPANEVIEW_DOC.src_css,
MODS.THREADVIEW.src_css,
MODS.EDITORVIEW.src_css
),
dest_js: DEST_DIR+"pdfviewer_NB.js",
dest_css: DEST_DIR+"pdfviewer.css"
};
TARGETS.YOUTUBEVIEWER = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "jquery_ui/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js", "dev/ui.concierge.js"]),
addPrefix(MODULE_DIR, ["dev/ui.view.js", "dev/ui.perspective.js"]),
TARGETS.API.src_js,
MODS.DOCVIEW_YOUTUBE.src_js,
MODS.NOTEPANEVIEW_YOUTUBE.src_js,
MODS.THREADVIEW.src_js,
MODS.EDITORVIEW.src_js,
addPrefix(UI_DIR,["conf.js", "conf_local.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js"]),
addPrefix(UI_DIR, ["step22.js", "launch.js"])
),
src_css: [].concat(
addPrefix(MODULE_DIR, ["jquery_ui/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css", "ui.perspective.css", "ui.viewport.css", "ui.menu.css", "ui.view.css"]),
addPrefix(UI_DIR, ["template.css"]),
MODS.DOCVIEW_YOUTUBE.src_css,
MODS.NOTEPANEVIEW_YOUTUBE.src_css,
MODS.THREADVIEW.src_css,
MODS.EDITORVIEW.src_css
),
dest_js: DEST_DIR+"youtubeviewer_NB.js",
dest_css: DEST_DIR+"youtubeviewer.css"
};
TARGETS.COLLAGE = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "jquery_ui/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js", "dev/ui.concierge.js"]),
addPrefix(MODULE_DIR, ["dev/ui.view.js", "dev/ui.perspective.js"]),
TARGETS.API.src_js,
MODS.DOCVIEW_COLLAGE.src_js,
MODS.NOTEPANEVIEW_COLLAGE.src_js,
MODS.THREADVIEW.src_js,
MODS.EDITORVIEW.src_js,
addPrefix(UI_DIR,["conf.js", "conf_local.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js"]),
addPrefix(UI_DIR, ["step18.js", "launch.js"])
),
src_css: [].concat(
addPrefix(MODULE_DIR, ["jquery_ui/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css", "ui.perspective.css", "ui.viewport.css", "ui.menu.css", "ui.view.css"]),
addPrefix(UI_DIR, ["template.css"]),
MODS.DOCVIEW_COLLAGE.src_css,
MODS.NOTEPANEVIEW_COLLAGE.src_css,
MODS.THREADVIEW.src_css,
MODS.EDITORVIEW.src_css
),
dest_js: DEST_DIR+"collage_NB.js",
dest_css: DEST_DIR+"collage.css"
};
TARGETS.LOGOUT = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "dev/ui.concierge.js"]),
TARGETS.API.src_js,
addPrefix(UI_DIR,["conf.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js"]),
addPrefix(UI_DIR,["logout.js"])
),
src_css: [],
dest_js: DEST_DIR+"logout_NB.js"
};
TARGETS.PASSWORD = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "dev/ui.concierge.js"]),
TARGETS.API.src_js,
addPrefix(UI_DIR,["conf.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js"]),
addPrefix(UI_DIR,["password_reminder.js"])
),
src_css: [],
dest_js: DEST_DIR+"password_reminder_NB.js"
};
TARGETS.SPREADSHEET = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "jquery_ui/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js", "dev/ui.concierge.js"]),
addPrefix(MODULE_DIR, ["dev/ui.view.js", "dev/ui.perspective.js"]),
TARGETS.API.src_js,
MODS.SPREADSHEETVIEW.src_js,
MODS.NOTEPANEVIEW_SPREADSHEET.src_js,
MODS.DOCVIEW_SPREADSHEET.src_js,
MODS.EDITORVIEW.src_js,
addPrefix(UI_DIR,["conf.js", "conf_local.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js"]),
addPrefix(UI_DIR, ["step19.js", "launch.js"])
),
src_css: [].concat(
addPrefix(MODULE_DIR, ["jquery_ui/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css", "ui.perspective.css", "ui.viewport.css", "ui.menu.css", "ui.view.css"]),
addPrefix(UI_DIR, ["template.css"]),
MODS.SPREADSHEETVIEW.src_css,
MODS.NOTEPANEVIEW_SPREADSHEET.src_css,
MODS.DOCVIEW_SPREADSHEET.src_css,
MODS.EDITORVIEW.src_css
),
dest_js: DEST_DIR+"spreadsheet_NB.js",
dest_css: DEST_DIR+"spreadsheet.css"
};
TARGETS.EMBEDOPENID = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "dev/ui.concierge.js"]),
TARGETS.API.src_js,
addPrefix(UI_DIR,["conf.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js"]),
addPrefix(UI_DIR,["embedopenid.js"])
),
dest_js: DEST_DIR+"embedopenid_NB.js"
};
TARGETS.SETTINGS = {
src_js: [].concat(
addPrefix(MODULE_DIR, ["jquery/1.8.3/jquery.min.js", "jquery_ui/jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js", "dev/ui.concierge.js"]),
addPrefix(MODULE_DIR, ["dev/ui.view.js", "dev/ui.perspective.js"]),
TARGETS.API.src_js,
addPrefix(UI_DIR,["conf.js"]),
addPrefix(MODULE_DIR, ["dev/pers.js"]),
addPrefix(UI_DIR,["your_settings.js"])
),
src_css: [].concat(
addPrefix(MODULE_DIR, ["jquery_ui/jquery-ui-1.9.2.custom/css/smoothness/jquery-ui-1.9.2.custom.css", "ui.perspective.css", "ui.viewport.css", "dev/ui.view.css"]),
addPrefix(UI_DIR, ["template.css", "your_settings.css"])
),
dest_js: DEST_DIR+"settings_NB.js",
dest_css: DEST_DIR+"settings.css"
};
var JS_TARGETS = {};
var i, src;
for (i in TARGETS){
src = unique(TARGETS[i].src_js);
if (src.length){
JS_TARGETS[i] = {src: src, dest: TARGETS[i].dest_js};
}
}
var CSS_TARGETS = {};
for (i in TARGETS){
src = unique(TARGETS[i].src_css);
if (src.length){
CSS_TARGETS[i] = {src: src, dest: TARGETS[i].dest_css };
}
if (TARGETS[i].servername){
CSS_TARGETS[i].servername = "http://"+TARGETS[i].servername+"/";
}
}
var ALL_TARGETS = {};
for (i in JS_TARGETS){
ALL_TARGETS[i+"_js"] = JS_TARGETS[i];
}
for (i in CSS_TARGETS){
ALL_TARGETS[i+"_css"] = CSS_TARGETS[i];
}
// console.log(JSON.stringify(CSS_TARGETS));
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
lint: {
files: ['grunt.js', 'content/ui/admin/*.js', 'content/modules/dev/*.js']
},
qunit: {
files: ['templates/web/*.html']
},
concat: JS_TARGETS,
csslint: CSS_TARGETS,
cssmin: CSS_TARGETS,
min: {
dist: {
src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
dest: 'dist/<%= pkg.name %>.min.js'
}
},
watch: {
files: '<config:lint.files>',
tasks: 'lint qunit'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {}
},
uglify: {}
});
grunt.loadNpmTasks('grunt-css');
// Default task.
// grunt.registerTask('default', 'lint qunit concat min');
grunt.registerTask('default', 'lint concat cssmin');
};