1 var fs
= require('fs'),
2 uglyfyJS
= require('uglify-js'),
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_network.js',
36 __dirname
+ '/model_member.js',
37 __dirname
+ '/model_memberlist.js',
38 __dirname
+ 'dev/model_newconnection.js',
39 __dirname
+ '/model_panel.js',
40 __dirname
+ '/model_panellist.js',
41 __dirname
+ '/model_networkpanellist.js',
42 __dirname
+ '/model_query.js',
43 __dirname
+ '/model_channel.js',
44 __dirname
+ '/model_server.js',
45 __dirname
+ '/model_applet.js',
46 __dirname
+ '/model_pluginmanager.js',
47 __dirname
+ '/model_datastore.js',
49 __dirname
+ '/applet_settings.js',
50 __dirname
+ '/applet_nickserv.js',
51 __dirname
+ '/applet_chanlist.js',
52 __dirname
+ '/applet_scripteditor.js',
54 __dirname
+ '/utils.js',
55 __dirname
+ '/view.js'
59 src
= '(function (global, undefined) {\n\n' + src
+ '\n\n})(window);';
62 fs
.writeFileSync(__dirname
+ '/../kiwi.js', src
, FILE_ENCODING
);
65 src
= uglyfyJS
.parser
.parse(src
);
66 src
= uglyfyJS
.uglify
.ast_mangle(src
);
67 src
= uglyfyJS
.uglify
.ast_squeeze(src
);
68 fs
.writeFileSync(__dirname
+ '/../kiwi.min.js', uglyfyJS
.uglify
.gen_code(src
), FILE_ENCODING
);
73 console
.log('kiwi.js and kiwi.min.js built');
85 * Build the index.html file
88 var index_src
= fs
.readFileSync(__dirname
+ '/index.html.tmpl', FILE_ENCODING
);
90 base_path
: config
.get().http_base_path
|| '/kiwi',
91 cache_buster
: Math
.ceil(Math
.random() * 9000).toString(),
96 // Any restricted server mode set?
97 if (config
.get().restrict_server
) {
98 vars
.server_settings
= {
100 server
: config
.get().restrict_server
,
101 port
: config
.get().restrict_server_port
|| 6667,
102 ssl
: config
.get().restrict_server_ssl
,
103 channel
: config
.get().restrict_server_channel
,
104 nick
: config
.get().restrict_server_nick
,
110 // Any client default settings?
111 if (config
.get().client
) {
112 vars
.server_settings
.client
= config
.get().client
;
115 // Any client plugins?
116 if (config
.get().client_plugins
&& config
.get().client_plugins
.length
> 0) {
117 vars
.client_plugins
= config
.get().client_plugins
;
120 _
.each(vars
, function(value
, key
) {
121 if (typeof value
=== 'object') value
= JSON
.stringify(value
);
122 index_src
= index_src
.replace(new RegExp('<%' + key
+ '%>', 'g'), value
);
125 fs
.writeFileSync(__dirname
+ '/../../index.html', index_src
, FILE_ENCODING
);
128 console
.log('index.html built');