diff --git a/package.json b/package.json index ed0af42..4b4c25a 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "devDependencies": { "body-parser": "~1.3.0", "compression": "~1.0.6", + "deep-extend": "~0.2.10", "express": "~4.4.1", "glob": "~4.0.2", "grunt": "~0.4.1", diff --git a/server/config.js b/server/config.js index 9ce81c6..97561bc 100644 --- a/server/config.js +++ b/server/config.js @@ -1,20 +1,20 @@ 'use strict'; -angular.module('ffffng').factory('config', function () { - return { +angular.module('ffffng').factory('config', function (fs, deepExtend) { + var defaultConfig = { server: { port: 8080, peersPath: '/tmp/peers' }, client: { community: { - name: 'Freifunk Hamburg', - domain: 'hamburg.freifunk.net', - contactEmail: 'kontakt@hamburg.freifunk.net' + name: 'Freifunk Musterstadt', + domain: 'musterstadt.freifunk.net', + contactEmail: 'kontakt@musterstadt.freifunk.net' }, map: { - graphUrl: 'http://graph.hamburg.freifunk.net/graph.html', - mapUrl: 'http://graph.hamburg.freifunk.net/geomap.html' + graphUrl: 'http://graph.musterstadt.freifunk.net/graph.html', + mapUrl: 'http://graph.musterstadt.freifunk.net/geomap.html' }, coordsSelector: { lat: 53.565278, @@ -23,4 +23,13 @@ angular.module('ffffng').factory('config', function () { } } }; + + var configJSONFile = __dirname + "/../config.json"; + var configJSON = undefined; + + if (fs.existsSync(configJSONFile)) { + configJSON = JSON.parse(fs.readFileSync(configJSONFile, 'utf8')); + } + + return deepExtend({}, defaultConfig, configJSON); }); diff --git a/server/libs.js b/server/libs.js index a7a53c2..5497a46 100644 --- a/server/libs.js +++ b/server/libs.js @@ -17,4 +17,5 @@ lib('crypto'); lib('fs'); lib('glob'); + lib('deepExtend', 'deep-extend'); })();