Ghost/core/server/config/theme.js
Harry Wolff 058b82bba1 Update config.theme() after every settings edit
fixes #1645

- removes server.get('ghost root') as it is only an alias
to config.paths().path, and adds unnecessary indirection
- removes config.theme().path as its just an alias to
config.paths().path, updated all relevant references
- update config.theme.update to only require the api/settings object,
and no longer need the config object
- modify api/settings.edit to call config.theme.update so that
the themeObject is ready for next rendering of template
2013-12-12 08:25:08 -05:00

39 lines
1.0 KiB
JavaScript

// Holds all theme configuration information
// that as mostly used by templates and handlebar helpers.
var when = require('when'),
// Variables
theme,
themeConfig = {},
update;
function theme() {
return themeConfig;
}
// We must pass the api.settings object
// into this method due to circular dependencies.
// If we were to require the api module here
// there would be a race condition where the ./models/base
// tries to access the config() object before it is created.
function update(settings) {
return when.all([
settings.read('title'),
settings.read('description'),
settings.read('logo'),
settings.read('cover')
]).then(function (globals) {
themeConfig.title = globals[0].value;
themeConfig.description = globals[1].value;
themeConfig.logo = globals[2] ? globals[2].value : '';
themeConfig.cover = globals[3] ? globals[3].value : '';
return;
});
}
module.exports = theme;
module.exports.update = update;