From d9fb23496c8adc2c62fb2afa8100f995190eaf2e Mon Sep 17 00:00:00 2001 From: Sebastian Gierlinger Date: Fri, 6 Sep 2013 13:34:44 +0200 Subject: [PATCH] Clean up config (non-env based settings) closes #625 - removed defaultLang, forceI18n and activePlugins from config - added values to default-settings.json - updated to use values from settings --- config.js | 16 ---------------- core/ghost.js | 6 +++--- core/server/data/default-settings.json | 11 ++++++++++- core/server/helpers/index.js | 2 +- core/shared/lang/i18n.js | 2 +- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/config.js b/config.js index 5172fbcfc2..c0206dc662 100644 --- a/config.js +++ b/config.js @@ -3,22 +3,6 @@ var path = require('path'), config = {}; -// ## Admin settings - -// Default language -config.defaultLang = 'en'; - -// Force i18n to be on -config.forceI18n = true; - -// ## Plugins - -// Current active plugins -config.activePlugins = [ - 'FancyFirstChar' -]; - - // ## Default Navigation Items // Add new objects here to extend the menu output by {{nav}} config.nav = [ diff --git a/core/ghost.js b/core/ghost.js index 97758a478d..b037b3de3e 100644 --- a/core/ghost.js +++ b/core/ghost.js @@ -146,11 +146,11 @@ Ghost.prototype.init = function () { instance.mail.init(self) ).then(function () { return models.Settings.populateDefaults(); - }).then(function () { - return self.initPlugins(); }).then(function () { // Initialize the settings cache return self.updateSettingsCache(); + }).then(function () { + return self.initPlugins(); }).then(function () { // Initialize the permissions actions and objects return permissions.init(); @@ -301,7 +301,7 @@ Ghost.prototype.doFilter = function (name, args, callback) { // Initialise plugins. Will load from config.activePlugins by default Ghost.prototype.initPlugins = function (pluginsToLoad) { - pluginsToLoad = pluginsToLoad || config.activePlugins; + pluginsToLoad = pluginsToLoad || models.Settings.activePlugins; var self = this; diff --git a/core/server/data/default-settings.json b/core/server/data/default-settings.json index d0dd67abc9..4748e3a50d 100644 --- a/core/server/data/default-settings.json +++ b/core/server/data/default-settings.json @@ -44,10 +44,19 @@ "value": "", "type": "blog" }, + { + "key": "defaultLang", + "value": "en", + "type": "blog" + }, + { + "key": "forceI18n", + "value": true, + "type": "blog" + }, { "key": "postsPerPage", "value": "6", "type": "blog" } - ] diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index 05aaefad01..d6b4475540 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -223,7 +223,7 @@ coreHelpers = function (ghost) { ghost.registerThemeHelper('e', function (key, defaultString, options) { var output; - if (ghost.config().defaultLang === 'en' && _.isEmpty(options.hash) && !ghost.config().forceI18n) { + if (ghost.settings().defaultLang === 'en' && _.isEmpty(options.hash) && !ghost.settings().forceI18n) { output = defaultString; } else { output = ghost.polyglot().t(key, options.hash); diff --git a/core/shared/lang/i18n.js b/core/shared/lang/i18n.js index b8a29fb21c..1e5ee87977 100644 --- a/core/shared/lang/i18n.js +++ b/core/shared/lang/i18n.js @@ -8,7 +8,7 @@ var fs = require('fs'), I18n = function (ghost) { // TODO: validate - var lang = ghost.config().defaultLang, + var lang = ghost.settings().defaultLang, path = ghost.paths().lang, langFilePath = path + lang + '.json';