Ghost/core/server/config/theme.js
Jacob Gable 7e9880ce8d Settings API Primary Document refactor
Closes #2606

- Refactor settings api responses to { settings: [ ] } format
- Update all code using api.settings to handle new response format
- Update test stubs to return new format
- Update client site settings model to parse new format into one object of key/value pairs
- Refactor to include all setting values
- Remove unused settingsCollection method
- Update settingsCache to store all attributes
- Update settingsResult to send all attributes
- Remove unnecessary when() wraps
- Reject if editing a setting that doesn't exist
- Reject earlier if setting key is empty
- Update tests with new error messages
- Use setting.add instead of edit that was incorrectly adding
- Update importer to properly import activePlugins and installedPlugins
- Update expected setting result fields
- Fix a weird situation where hasOwnProperty didn't exist 🤷
2014-04-30 23:15:27 -05:00

38 lines
1.2 KiB
JavaScript

// Holds all theme configuration information
// that as mostly used by templates and handlebar helpers.
var when = require('when'),
// Variables
themeConfig = {};
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, configUrl) {
return when.all([
settings.read('title'),
settings.read('description'),
settings.read('logo'),
settings.read('cover')
]).then(function (globals) {
// normalise the URL by removing any trailing slash
themeConfig.url = configUrl.replace(/\/$/, '');
themeConfig.title = globals[0].settings[0].value;
themeConfig.description = globals[1].settings[0].value;
themeConfig.logo = globals[2].settings[0] ? globals[2].settings[0].value : '';
themeConfig.cover = globals[3].settings[0] ? globals[3].settings[0].value : '';
return;
});
}
module.exports = theme;
module.exports.update = update;