diff --git a/core/ghost.js b/core/ghost.js index d822f46c63..d37364e67f 100644 --- a/core/ghost.js +++ b/core/ghost.js @@ -93,17 +93,22 @@ Ghost = function () { config: function () { return config[process.env.NODE_ENV]; }, // there's no management here to be sure this has loaded - settings: function () { return instance.settingsCache; }, + settings: function (key) { + if (key) { + return instance.settingsCache[key].value; + } + return instance.settingsCache; + }, dataProvider: models, blogGlobals: function () { /* this is a bit of a hack until we have a better way to combine settings and config * this data is what becomes globally available to themes */ return { url: instance.config().url, - title: instance.settings().title.value, - description: instance.settings().description.value, - logo: instance.settings().logo.value, - cover: instance.settings().cover.value + title: instance.settings('title'), + description: instance.settings('description'), + logo: instance.settings('logo'), + cover: instance.settings('cover') }; }, statuses: function () { return statuses; }, @@ -196,16 +201,9 @@ Ghost.prototype.readSettingsResult = function (result) { return when(_.map(result.models, function (member) { if (!settings.hasOwnProperty(member.attributes.key)) { var val = {}; - if (member.attributes.key === 'activeTheme') { - member.attributes.value = member.attributes.value.substring(member.attributes.value.lastIndexOf('/') + 1); - val.value = member.attributes.value; - val.type = member.attributes.type; - settings[member.attributes.key] = val; - } else { - val.value = member.attributes.value; - val.type = member.attributes.type; - settings[member.attributes.key] = val; - } + val.value = member.attributes.value; + val.type = member.attributes.type; + settings[member.attributes.key] = val; } })).then(function () { return when(instance.paths().availableThemes).then(function (themes) { @@ -353,11 +351,11 @@ Ghost.prototype.initTheme = function (app) { // self.globals is a hack til we have a better way of getting combined settings & config hbsOptions = {templateOptions: {data: {blog: self.blogGlobals()}}}; - if (!self.themeDirectories.hasOwnProperty(self.settings().activeTheme.value)) { + if (!self.themeDirectories.hasOwnProperty(self.settings('activeTheme'))) { // Throw an error if the theme is not available... // TODO: move this to happen on app start - errors.logAndThrowError('The currently active theme ' + self.settings().activeTheme.value + ' is missing.'); - } else if (self.themeDirectories[self.settings().activeTheme.value].hasOwnProperty('partials')) { + errors.logAndThrowError('The currently active theme ' + self.settings('activeTheme') + ' is missing.'); + } else if (self.themeDirectories[self.settings('activeTheme')].hasOwnProperty('partials')) { // Check that the theme has a partials directory before trying to use it hbsOptions.partialsDir = path.join(self.paths().activeTheme, 'partials'); } diff --git a/core/server/controllers/frontend.js b/core/server/controllers/frontend.js index 90c9315791..19857f1cd0 100644 --- a/core/server/controllers/frontend.js +++ b/core/server/controllers/frontend.js @@ -15,7 +15,7 @@ frontendControllers = { 'homepage': function (req, res) { // Parse the page number var pageParam = req.params.page !== undefined ? parseInt(req.params.page, 10) : 1, - postsPerPage = parseInt(ghost.settings().postsPerPage.value, 10), + postsPerPage = parseInt(ghost.settings('postsPerPage'), 10), options = {}; // No negative pages @@ -67,10 +67,10 @@ frontendControllers = { // Initialize RSS var siteUrl = ghost.config().url, feed = new RSS({ - title: ghost.settings().title.value, - description: ghost.settings().description.value, + title: ghost.settings('title'), + description: ghost.settings('description'), generator: 'Ghost v' + res.locals.version, - author: ghost.settings().author.value, + author: ghost.settings('author'), feed_url: siteUrl + '/rss/', site_url: siteUrl, ttl: '60' diff --git a/core/server/helpers/index.js b/core/server/helpers/index.js index ff09154f88..e3de0b76a3 100644 --- a/core/server/helpers/index.js +++ b/core/server/helpers/index.js @@ -234,7 +234,7 @@ coreHelpers = function (ghost) { ghost.registerThemeHelper('e', function (key, defaultString, options) { var output; - if (ghost.settings().defaultLang.value === 'en' && _.isEmpty(options.hash) && !ghost.settings().forceI18n.value) { + 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/server/mail.js b/core/server/mail.js index 5468918c98..d41f08a3a5 100644 --- a/core/server/mail.js +++ b/core/server/mail.js @@ -96,7 +96,7 @@ GhostMailer.prototype.send = function (message) { } var from = 'ghost-mailer@' + url.parse(this.ghost.config().url).hostname, - to = message.to || this.ghost.settings().email.value, + to = message.to || this.ghost.settings('email'), sendMail = nodefn.lift(this.transport.sendMail.bind(this.transport)); message = _.extend(message, { diff --git a/core/shared/lang/i18n.js b/core/shared/lang/i18n.js index dc02e31f28..3eb8a4c69d 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.settings().defaultLang.value, + var lang = ghost.settings('defaultLang'), path = ghost.paths().lang, langFilePath = path + lang + '.json';