+++ /dev/null
-var fs = require('fs'),\r
- uglifyJS = require('uglify-js'),\r
- _ = require('lodash'),\r
- po2json = require('po2json'),\r
- config = require('../server/configuration.js'),\r
- package_json = require('../package.json');\r
-\r
-var FILE_ENCODING = 'utf-8',\r
- EOL = '\n';\r
-\r
-\r
-function concat(file_list, callback) {\r
- var num_files = file_list.length,\r
- files = [],\r
- loaded = 0,\r
- error = false;\r
-\r
- file_list.forEach(function (file_path, idx) {\r
- if (error) {\r
- return;\r
- }\r
- fs.readFile(file_path, { encoding: FILE_ENCODING }, function (err, data) {\r
- if (error) {\r
- return;\r
- } else if (err) {\r
- error = true;\r
- return callback(err);\r
- }\r
- files[idx] = data + '\n\n';\r
- if (++loaded === num_files) {\r
- callback(null, files.join(EOL));\r
- }\r
- });\r
- });\r
-}\r
-\r
-\r
-\r
-config.loadConfig();\r
-\r
-\r
-var source_files = [\r
- __dirname + '/src/app.js',\r
- __dirname + '/src/models/application.js',\r
- __dirname + '/src/models/gateway.js',\r
- __dirname + '/src/models/network.js',\r
- __dirname + '/src/models/member.js',\r
- __dirname + '/src/models/memberlist.js',\r
- __dirname + '/src/models/newconnection.js',\r
- __dirname + '/src/models/panel.js',\r
- __dirname + '/src/models/panellist.js',\r
- __dirname + '/src/models/networkpanellist.js',\r
- __dirname + '/src/models/channel.js',\r
- __dirname + '/src/models/query.js',\r
- __dirname + '/src/models/server.js',\r
- __dirname + '/src/models/applet.js',\r
- __dirname + '/src/models/pluginmanager.js',\r
- __dirname + '/src/models/datastore.js',\r
- __dirname + '/src/models/channelinfo.js',\r
-\r
- __dirname + '/src/views/panel.js',\r
- __dirname + '/src/views/channel.js',\r
- __dirname + '/src/views/applet.js',\r
- __dirname + '/src/views/application.js',\r
- __dirname + '/src/views/apptoolbar.js',\r
- __dirname + '/src/views/controlbox.js',\r
- __dirname + '/src/views/favicon.js',\r
- __dirname + '/src/views/mediamessage.js',\r
- __dirname + '/src/views/member.js',\r
- __dirname + '/src/views/memberlist.js',\r
- __dirname + '/src/views/menubox.js',\r
- __dirname + '/src/views/networktabs.js',\r
- __dirname + '/src/views/nickchangebox.js',\r
- __dirname + '/src/views/resizehandler.js',\r
- __dirname + '/src/views/serverselect.js',\r
- __dirname + '/src/views/statusmessage.js',\r
- __dirname + '/src/views/tabs.js',\r
- __dirname + '/src/views/topicbar.js',\r
- __dirname + '/src/views/userbox.js',\r
- __dirname + '/src/views/channeltools.js',\r
- __dirname + '/src/views/channelinfo.js',\r
- __dirname + '/src/views/rightbar.js',\r
- __dirname + '/src/views/notification.js',\r
-\r
- __dirname + '/src/misc/clientuicommands.js',\r
-\r
- __dirname + '/src/applets/settings.js',\r
- __dirname + '/src/applets/chanlist.js',\r
- __dirname + '/src/applets/scripteditor.js',\r
- __dirname + '/src/applets/startup.js'\r
-];\r
-\r
-\r
-var helpers_path = __dirname + '/src/helpers/';\r
-var helpers_sources = fs.readdirSync(helpers_path)\r
- .map(function(file){\r
- return helpers_path + file;\r
- });\r
-\r
-source_files = source_files.concat(helpers_sources);\r
-\r
-\r
-/**\r
- * Build the kiwi.js/kiwi.min.js files\r
- */\r
-concat(source_files, function (err, src) {\r
- if (!err) {\r
- src = '(function (global, undefined) {\n\n' + src + '\n\n})(window);';\r
-\r
- fs.writeFile(__dirname + '/assets/kiwi.js', src, { encoding: FILE_ENCODING }, function (err) {\r
- if (!err) {\r
- console.log('Built kiwi.js');\r
- } else {\r
- console.error('Error building kiwi.js:', err);\r
- }\r
- });\r
-\r
- // Uglify can take take an array of filenames to produce minified code\r
- // but it's not wraped in an IIFE and produces a slightly larger file\r
- //src = uglifyJS.minify(source_files);\r
-\r
- var ast = uglifyJS.parse(src, {filename: 'kiwi.js'});\r
- ast.figure_out_scope();\r
- ast = ast.transform(uglifyJS.Compressor({warnings: false}));\r
- ast.figure_out_scope();\r
- ast.compute_char_frequency();\r
- ast.mangle_names();\r
- src = ast.print_to_string();\r
-\r
- fs.writeFile(__dirname + '/assets/kiwi.min.js', src, { encoding: FILE_ENCODING }, function (err) {\r
- if (!err) {\r
- console.log('Built kiwi.min.js');\r
- } else {\r
- console.error('Error building kiwi.min.js:', err);\r
- }\r
- });\r
- } else {\r
- console.error('Error building kiwi.js and kiwi.min.js:', err);\r
- }\r
-});\r
-\r
-\r
-\r
-\r
-\r
-\r
-/**\r
- * Build the engineio client + tools libs\r
- */\r
-concat([__dirname + '/assets/libs/engine.io.js', __dirname + '/assets/libs/engine.io.tools.js'], function (err, src) {\r
- if (!err) {\r
- fs.writeFile(__dirname + '/assets/libs/engine.io.bundle.js', src, { encoding: FILE_ENCODING }, function (err) {\r
- if (!err) {\r
- console.log('Built engine.io.bundle.js');\r
- } else {\r
- console.error('Error building engine.io.bundle.js:', err);\r
- }\r
- });\r
-\r
- var ast = uglifyJS.parse(src, {filename: 'engine.io.bundle.js'});\r
- ast.figure_out_scope();\r
- ast = ast.transform(uglifyJS.Compressor({warnings: false}));\r
- ast.figure_out_scope();\r
- ast.compute_char_frequency();\r
- ast.mangle_names();\r
- src = ast.print_to_string();\r
-\r
- fs.writeFile(__dirname + '/assets/libs/engine.io.bundle.min.js', src, { encoding: FILE_ENCODING }, function (err) {\r
- if (!err) {\r
- console.log('Built engine.io.bundle.min.js');\r
- } else {\r
- console.error('Error building engine.io.bundle.min.js:', err);\r
- }\r
- });\r
- } else {\r
- console.error('Error building engine.io.bundle.js and engine.io.bundle.min.js:', err);\r
- }\r
-});\r
-\r
-\r
-\r
-\r
-\r
-\r
-/**\r
-* Convert translations from .po to .json\r
-*/\r
-if (!fs.existsSync(__dirname + '/assets/locales')) {\r
- fs.mkdirSync(__dirname + '/assets/locales');\r
-}\r
-fs.readdir(__dirname + '/src/translations', function (err, translation_files) {\r
- if (!err) {\r
- translation_files.forEach(function (file) {\r
- var locale = file.slice(0, -3);\r
-\r
- if ((file.slice(-3) === '.po') && (locale !== 'template')) {\r
- po2json.parseFile(__dirname + '/src/translations/' + file, {format: 'jed', domain: locale}, function (err, json) {\r
- if (!err) {\r
-\r
- fs.writeFile(__dirname + '/assets/locales/' + locale + '.json', JSON.stringify(json), function (err) {\r
- if (!err) {\r
- console.log('Built translation file %s.json', locale);\r
- } else {\r
- console.error('Error building translation file %s.json:', locale, err);\r
- }\r
- });\r
- } else {\r
- console.error('Error building translation file %s.json: ', locale, err);\r
- }\r
- });\r
- }\r
- });\r
- } else {\r
- console.error('Error building translation files:', err);\r
- }\r
-});\r
-\r
-\r
-\r
-\r
-\r
-\r
-/**\r
- * Build the index.html file\r
- */\r
-var build_time = new Date().getTime();\r
-var base_path = config.get().http_base_path || '';\r
-\r
-// Trim off any trailing slashes\r
-if (base_path.substr(base_path.length - 1) === '/') {\r
- base_path = base_path.substr(0, base_path.length - 1);\r
-}\r
-\r
-var index_src = fs.readFileSync(__dirname + '/src/index.html.tmpl', FILE_ENCODING)\r
- .replace(new RegExp('<%base_path%>', 'g'), base_path)\r
- .replace(new RegExp('<%build_version%>', 'g'), package_json.version)\r
- .replace(new RegExp('<%build_time%>', 'g'), build_time);\r
-\r
-fs.writeFile(__dirname + '/index.html', index_src, { encoding: FILE_ENCODING }, function (err) {\r
- if (!err) {\r
- console.log('Built index.html');\r
- } else {\r
- console.error('Error building index.html');\r
- }\r
-});\r
--- /dev/null
+var fs = require('fs'),\r
+ uglifyJS = require('uglify-js'),\r
+ _ = require('lodash'),\r
+ po2json = require('po2json'),\r
+ config = require('./configuration.js'),\r
+ package_json = require('../package.json');\r
+\r
+var FILE_ENCODING = 'utf-8',\r
+ EOL = '\n';\r
+\r
+\r
+function concat(file_list, callback) {\r
+ var num_files = file_list.length,\r
+ files = [],\r
+ loaded = 0,\r
+ error = false;\r
+\r
+ file_list.forEach(function (file_path, idx) {\r
+ if (error) {\r
+ return;\r
+ }\r
+ fs.readFile(file_path, { encoding: FILE_ENCODING }, function (err, data) {\r
+ if (error) {\r
+ return;\r
+ } else if (err) {\r
+ error = true;\r
+ return callback(err);\r
+ }\r
+ files[idx] = data + '\n\n';\r
+ if (++loaded === num_files) {\r
+ callback(null, files.join(EOL));\r
+ }\r
+ });\r
+ });\r
+}\r
+\r
+\r
+\r
+// Load the config, using -c argument if available\r
+(function (argv) {\r
+ var conf_switch = argv.indexOf('-c');\r
+ if (conf_switch !== -1) {\r
+ if (argv[conf_switch + 1]) {\r
+ return config.loadConfig(argv[conf_switch + 1]);\r
+ }\r
+ }\r
+\r
+ config.loadConfig();\r
+\r
+})(process.argv);\r
+\r
+\r
+\r
+\r
+var source_files = [\r
+ global.config.public_http + '/src/app.js',\r
+ global.config.public_http + '/src/models/application.js',\r
+ global.config.public_http + '/src/models/gateway.js',\r
+ global.config.public_http + '/src/models/network.js',\r
+ global.config.public_http + '/src/models/member.js',\r
+ global.config.public_http + '/src/models/memberlist.js',\r
+ global.config.public_http + '/src/models/newconnection.js',\r
+ global.config.public_http + '/src/models/panel.js',\r
+ global.config.public_http + '/src/models/panellist.js',\r
+ global.config.public_http + '/src/models/networkpanellist.js',\r
+ global.config.public_http + '/src/models/channel.js',\r
+ global.config.public_http + '/src/models/query.js',\r
+ global.config.public_http + '/src/models/server.js',\r
+ global.config.public_http + '/src/models/applet.js',\r
+ global.config.public_http + '/src/models/pluginmanager.js',\r
+ global.config.public_http + '/src/models/datastore.js',\r
+ global.config.public_http + '/src/models/channelinfo.js',\r
+\r
+ global.config.public_http + '/src/views/panel.js',\r
+ global.config.public_http + '/src/views/channel.js',\r
+ global.config.public_http + '/src/views/applet.js',\r
+ global.config.public_http + '/src/views/application.js',\r
+ global.config.public_http + '/src/views/apptoolbar.js',\r
+ global.config.public_http + '/src/views/controlbox.js',\r
+ global.config.public_http + '/src/views/favicon.js',\r
+ global.config.public_http + '/src/views/mediamessage.js',\r
+ global.config.public_http + '/src/views/member.js',\r
+ global.config.public_http + '/src/views/memberlist.js',\r
+ global.config.public_http + '/src/views/menubox.js',\r
+ global.config.public_http + '/src/views/networktabs.js',\r
+ global.config.public_http + '/src/views/nickchangebox.js',\r
+ global.config.public_http + '/src/views/resizehandler.js',\r
+ global.config.public_http + '/src/views/serverselect.js',\r
+ global.config.public_http + '/src/views/statusmessage.js',\r
+ global.config.public_http + '/src/views/tabs.js',\r
+ global.config.public_http + '/src/views/topicbar.js',\r
+ global.config.public_http + '/src/views/userbox.js',\r
+ global.config.public_http + '/src/views/channeltools.js',\r
+ global.config.public_http + '/src/views/channelinfo.js',\r
+ global.config.public_http + '/src/views/rightbar.js',\r
+ global.config.public_http + '/src/views/notification.js',\r
+\r
+ global.config.public_http + '/src/misc/clientuicommands.js',\r
+\r
+ global.config.public_http + '/src/applets/settings.js',\r
+ global.config.public_http + '/src/applets/chanlist.js',\r
+ global.config.public_http + '/src/applets/scripteditor.js',\r
+ global.config.public_http + '/src/applets/startup.js'\r
+];\r
+\r
+\r
+var helpers_path = global.config.public_http + '/src/helpers/';\r
+var helpers_sources = fs.readdirSync(helpers_path)\r
+ .map(function(file){\r
+ return helpers_path + file;\r
+ });\r
+\r
+source_files = source_files.concat(helpers_sources);\r
+\r
+\r
+/**\r
+ * Build the kiwi.js/kiwi.min.js files\r
+ */\r
+concat(source_files, function (err, src) {\r
+ if (!err) {\r
+ src = '(function (global, undefined) {\n\n' + src + '\n\n})(window);';\r
+\r
+ fs.writeFile(global.config.public_http + '/assets/kiwi.js', src, { encoding: FILE_ENCODING }, function (err) {\r
+ if (!err) {\r
+ console.log('Built kiwi.js');\r
+ } else {\r
+ console.error('Error building kiwi.js:', err);\r
+ }\r
+ });\r
+\r
+ // Uglify can take take an array of filenames to produce minified code\r
+ // but it's not wraped in an IIFE and produces a slightly larger file\r
+ //src = uglifyJS.minify(source_files);\r
+\r
+ var ast = uglifyJS.parse(src, {filename: 'kiwi.js'});\r
+ ast.figure_out_scope();\r
+ ast = ast.transform(uglifyJS.Compressor({warnings: false}));\r
+ ast.figure_out_scope();\r
+ ast.compute_char_frequency();\r
+ ast.mangle_names();\r
+ src = ast.print_to_string();\r
+\r
+ fs.writeFile(global.config.public_http + '/assets/kiwi.min.js', src, { encoding: FILE_ENCODING }, function (err) {\r
+ if (!err) {\r
+ console.log('Built kiwi.min.js');\r
+ } else {\r
+ console.error('Error building kiwi.min.js:', err);\r
+ }\r
+ });\r
+ } else {\r
+ console.error('Error building kiwi.js and kiwi.min.js:', err);\r
+ }\r
+});\r
+\r
+\r
+\r
+\r
+\r
+\r
+/**\r
+ * Build the engineio client + tools libs\r
+ */\r
+concat([global.config.public_http + '/assets/libs/engine.io.js', global.config.public_http + '/assets/libs/engine.io.tools.js'], function (err, src) {\r
+ if (!err) {\r
+ fs.writeFile(global.config.public_http + '/assets/libs/engine.io.bundle.js', src, { encoding: FILE_ENCODING }, function (err) {\r
+ if (!err) {\r
+ console.log('Built engine.io.bundle.js');\r
+ } else {\r
+ console.error('Error building engine.io.bundle.js:', err);\r
+ }\r
+ });\r
+\r
+ var ast = uglifyJS.parse(src, {filename: 'engine.io.bundle.js'});\r
+ ast.figure_out_scope();\r
+ ast = ast.transform(uglifyJS.Compressor({warnings: false}));\r
+ ast.figure_out_scope();\r
+ ast.compute_char_frequency();\r
+ ast.mangle_names();\r
+ src = ast.print_to_string();\r
+\r
+ fs.writeFile(global.config.public_http + '/assets/libs/engine.io.bundle.min.js', src, { encoding: FILE_ENCODING }, function (err) {\r
+ if (!err) {\r
+ console.log('Built engine.io.bundle.min.js');\r
+ } else {\r
+ console.error('Error building engine.io.bundle.min.js:', err);\r
+ }\r
+ });\r
+ } else {\r
+ console.error('Error building engine.io.bundle.js and engine.io.bundle.min.js:', err);\r
+ }\r
+});\r
+\r
+\r
+\r
+\r
+\r
+\r
+/**\r
+* Convert translations from .po to .json\r
+*/\r
+if (!fs.existsSync(global.config.public_http + '/assets/locales')) {\r
+ fs.mkdirSync(global.config.public_http + '/assets/locales');\r
+}\r
+fs.readdir(global.config.public_http + '/src/translations', function (err, translation_files) {\r
+ if (!err) {\r
+ translation_files.forEach(function (file) {\r
+ var locale = file.slice(0, -3);\r
+\r
+ if ((file.slice(-3) === '.po') && (locale !== 'template')) {\r
+ po2json.parseFile(global.config.public_http + '/src/translations/' + file, {format: 'jed', domain: locale}, function (err, json) {\r
+ if (!err) {\r
+\r
+ fs.writeFile(global.config.public_http + '/assets/locales/' + locale + '.json', JSON.stringify(json), function (err) {\r
+ if (!err) {\r
+ console.log('Built translation file %s.json', locale);\r
+ } else {\r
+ console.error('Error building translation file %s.json:', locale, err);\r
+ }\r
+ });\r
+ } else {\r
+ console.error('Error building translation file %s.json: ', locale, err);\r
+ }\r
+ });\r
+ }\r
+ });\r
+ } else {\r
+ console.error('Error building translation files:', err);\r
+ }\r
+});\r
+\r
+\r
+\r
+\r
+\r
+\r
+/**\r
+ * Build the index.html file\r
+ */\r
+var build_time = new Date().getTime();\r
+var base_path = config.get().http_base_path || '';\r
+\r
+// Trim off any trailing slashes\r
+if (base_path.substr(base_path.length - 1) === '/') {\r
+ base_path = base_path.substr(0, base_path.length - 1);\r
+}\r
+\r
+var index_src = fs.readFileSync(global.config.public_http + '/src/index.html.tmpl', FILE_ENCODING)\r
+ .replace(new RegExp('<%base_path%>', 'g'), base_path)\r
+ .replace(new RegExp('<%build_version%>', 'g'), package_json.version)\r
+ .replace(new RegExp('<%build_time%>', 'g'), build_time);\r
+\r
+fs.writeFile(global.config.public_http + '/index.html', index_src, { encoding: FILE_ENCODING }, function (err) {\r
+ if (!err) {\r
+ console.log('Built index.html');\r
+ } else {\r
+ console.error('Error building index.html');\r
+ }\r
+});\r