From c42758ba350cc2b5350cd43b150a20e742108ef7 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Thu, 30 Mar 2017 00:21:41 +0200 Subject: [PATCH] [TASK] Default and custom config - merge --- config.default.json | 20 ++++++++++++++++++++ config.json | 23 +++-------------------- gulp/config.js | 2 +- gulp/tasks/html.js | 9 +++++++-- 4 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 config.default.json diff --git a/config.default.json b/config.default.json new file mode 100644 index 0000000..385d278 --- /dev/null +++ b/config.default.json @@ -0,0 +1,20 @@ +// Gulp will remove all comments +{ + "reverseGeocodingApi": "https://nominatim.openstreetmap.org/reverse", + "maxAge": 14, + "maxAgeAlert": 3, + "nodeZoom": 18, + "labelZoom": 13, + "clientZoom": 15, + "nodeInfobox": { + "contact": false, + "hardwareUsage": true + }, + "supportedLocale": [ + "en", + "de", + "fr", + "ru" + ], + "cacheBreaker": "" +} diff --git a/config.json b/config.json index 0fe63e4..c645126 100644 --- a/config.json +++ b/config.json @@ -25,17 +25,7 @@ ], // String or array of data provider are supported "dataPath": "https://regensburg.freifunk.net/data/", - "reverseGeocodingApi": "https://nominatim.openstreetmap.org/reverse", "siteName": "Freifunk Regensburg", - "maxAge": 14, - "maxAgeAlert": 3, - "nodeZoom": 18, - "labelZoom": 13, - "clientZoom": 15, - "nodeInfobox": { - "contact": false, - "hardwareUsage": true - }, "mapLayers": [ { "name": "Freifunk Regensburg", @@ -44,7 +34,7 @@ "config": { "maxZoom": 22, "subdomains": "1234", - "attribution": "© Mapbox © OpenStreetMap Improve this map", + "attribution": "© Mapbox © OpenStreetMap Improve this map", "start": 6 } }, @@ -55,7 +45,7 @@ "config": { "maxZoom": 22, "subdomains": "1234", - "attribution": "© Mapbox © OpenStreetMap Improve this map", + "attribution": "© Mapbox © OpenStreetMap Improve this map", "mode": "night", "start": 19, "end": 7 @@ -121,12 +111,5 @@ "site": "ffrgb", "name": "Regensburg" } - ], - "supportedLocale": [ - "en", - "de", - "fr", - "ru" - ], - "cacheBreaker": "" + ] } diff --git a/gulp/config.js b/gulp/config.js index f34cd8e..20001c1 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -8,7 +8,7 @@ module.exports = function () { sass: 'scss/**/*.scss', javascript: ['app.js', 'lib/**/*.js'], json: 'locale/*.json', - html: ['html/index.html', 'config.json'] + html: ['html/index.html', 'config.json', 'config.default.json'] }, clean: [build + '/*.map', build + '/vendor', build + '/main.css'], autoprefixer: ['> 1% in DE'], diff --git a/gulp/tasks/html.js b/gulp/tasks/html.js index 4994e6d..6f33537 100644 --- a/gulp/tasks/html.js +++ b/gulp/tasks/html.js @@ -4,9 +4,14 @@ module.exports = function (gulp, plugins, config, env) { return gulp.src(env.production() ? config.build + '/*.html' : 'html/*.html') .pipe(plugins.inject(gulp.src(['config.json']), { starttag: '', - transform: function (filePath, file) { + transform: function (filePath, customConfig) { + var defaultConfig = fs.readFileSync('config.default.json', 'utf8'); + var buildConfig = Object.assign( + JSON.parse(JSON.minify(defaultConfig)), + JSON.parse(JSON.minify(customConfig.contents.toString('utf8'))) + ); return ''