Refactoring base ui app config reader

merge-requests/7/head
dilanua 8 years ago
parent c12630e65c
commit d04cb54ae8

@ -17,12 +17,13 @@
*/ */
var config = function () { var config = function () {
var conf = application.get("UI_CONFIG"); var conf = application.get("UI_CONF");
if (!conf) { if (!conf) {
conf = require("/app/conf/config.json");
var pinch = require("/app/conf/reader/pinch.min.js")["pinch"]; var pinch = require("/app/conf/reader/pinch.min.js")["pinch"];
var config = require("/app/conf/config.json");
var server = require("carbon")["server"]; var server = require("carbon")["server"];
pinch(config, /^/, function (path, key, value) { pinch(conf, /^/,
function (path, key, value) {
if ((typeof value === "string") && value.indexOf("%https.ip%") > -1) { if ((typeof value === "string") && value.indexOf("%https.ip%") > -1) {
return value.replace("%https.ip%", server.address("https")); return value.replace("%https.ip%", server.address("https"));
} else if ((typeof value === "string") && value.indexOf("%http.ip%") > -1) { } else if ((typeof value === "string") && value.indexOf("%http.ip%") > -1) {
@ -32,9 +33,9 @@ var config = function () {
return value.replace("%date-year%", year); return value.replace("%date-year%", year);
} }
return value; return value;
}); }
application.put("UI_CONFIG", config); );
conf = config; application.put("UI_CONF", conf);
} }
return conf; return conf;
}; };
Loading…
Cancel
Save