have the server parse the settings file using minify and strip commas

This commit is contained in:
s1341 2013-11-26 10:20:59 +02:00
parent 7550be0921
commit 9b7203d4d2
1 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/** /**
* The Settings Modul reads the settings out of settings.json and provides * The Settings Modul reads the settings out of settings.json and provides
* this information to the other modules * this information to the other modules
*/ */
@ -24,7 +24,7 @@ var os = require("os");
var path = require('path'); var path = require('path');
var argv = require('./Cli').argv; var argv = require('./Cli').argv;
var npm = require("npm/lib/npm.js"); var npm = require("npm/lib/npm.js");
var vm = require('vm'); var jsonminify = require("jsonminify");
var log4js = require("log4js"); var log4js = require("log4js");
var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
@ -48,7 +48,7 @@ exports.faviconTimeslider = "../../" + exports.favicon;
* The IP ep-lite should listen to * The IP ep-lite should listen to
*/ */
exports.ip = "0.0.0.0"; exports.ip = "0.0.0.0";
/** /**
* The Port ep-lite should listen to * The Port ep-lite should listen to
*/ */
@ -166,8 +166,8 @@ exports.reloadSettings = function reloadSettings() {
var settings; var settings;
try { try {
if(settingsStr) { if(settingsStr) {
settings = vm.runInContext('exports = '+settingsStr, vm.createContext(), "settings.json"); settingsStr = jsonminify(settingsStr).replace(",]","]").replace(",}","}");
settings = JSON.parse(JSON.stringify(settings)); // fix objects having constructors of other vm.context settings = JSON.parse(settingsStr);
} }
}catch(e){ }catch(e){
console.error('There was an error processing your settings.json file: '+e.message); console.error('There was an error processing your settings.json file: '+e.message);
@ -195,7 +195,7 @@ exports.reloadSettings = function reloadSettings() {
console.warn("Unknown Setting: '" + i + "'. This setting doesn't exist or it was removed"); console.warn("Unknown Setting: '" + i + "'. This setting doesn't exist or it was removed");
} }
} }
log4js.configure(exports.logconfig);//Configure the logging appenders log4js.configure(exports.logconfig);//Configure the logging appenders
log4js.setGlobalLogLevel(exports.loglevel);//set loglevel log4js.setGlobalLogLevel(exports.loglevel);//set loglevel
log4js.replaceConsole(); log4js.replaceConsole();