1 var fs
= require('fs'),
2 uglyfyJS
= require('uglify-js'),
3 _
= require('underscore'),
4 config
= require('./../../../server/configuration.js');
6 var FILE_ENCODING
= 'utf-8',
10 function concat(src
) {
12 var out
= file_list
.map(function(file_path
){
13 return fs
.readFileSync(file_path
, FILE_ENCODING
) + '\n\n';
28 * Build the _kiwi.js files
32 __dirname
+ '/app.js',
33 __dirname
+ '/model_application.js',
34 __dirname
+ '/model_gateway.js',
35 __dirname
+ '/model_member.js',
36 __dirname
+ '/model_memberlist.js',
37 __dirname
+ '/model_panel.js',
38 __dirname
+ '/model_panellist.js',
39 __dirname
+ '/model_query.js',
40 __dirname
+ '/model_channel.js',
41 __dirname
+ '/model_server.js',
42 __dirname
+ '/model_applet.js',
43 __dirname
+ '/model_pluginmanager.js',
45 __dirname
+ '/applet_settings.js',
46 __dirname
+ '/applet_nickserv.js',
47 __dirname
+ '/applet_chanlist.js',
49 __dirname
+ '/utils.js',
50 __dirname
+ '/view.js'
54 src
= '(function (global, undefined) {\n\n' + src
+ '\n\n})(window);';
57 fs
.writeFileSync(__dirname
+ '/../kiwi.js', src
, FILE_ENCODING
);
60 src
= uglyfyJS
.parser
.parse(src
);
61 src
= uglyfyJS
.uglify
.ast_mangle(src
);
62 src
= uglyfyJS
.uglify
.ast_squeeze(src
);
63 fs
.writeFileSync(__dirname
+ '/../kiwi.min.js', uglyfyJS
.uglify
.gen_code(src
), FILE_ENCODING
);
68 console
.log('kiwi.js and kiwi.min.js built');
80 * Build the index.html file
83 var index_src
= fs
.readFileSync(__dirname
+ '/index.html.tmpl', FILE_ENCODING
);
85 base_path
: config
.get().http_base_path
,
86 cache_buster
: Math
.ceil(Math
.random() * 9000).toString()
89 _
.each(vars
, function(value
, key
) {
90 index_src
= index_src
.replace(new RegExp('<%' + key
+ '%>', 'g'), value
);
93 fs
.writeFileSync(__dirname
+ '/../../index.html', index_src
, FILE_ENCODING
);
96 console
.log('index.html built');