2013-12-06 18:13:15 +04:00
|
|
|
// Holds all theme configuration information
|
|
|
|
// that as mostly used by templates and handlebar helpers.
|
|
|
|
|
2014-08-17 10:17:23 +04:00
|
|
|
var Promise = require('bluebird'),
|
2013-12-06 18:13:15 +04:00
|
|
|
|
|
|
|
// Variables
|
2013-12-26 16:15:10 +04:00
|
|
|
themeConfig = {};
|
2013-12-06 18:13:15 +04:00
|
|
|
|
|
|
|
|
|
|
|
function theme() {
|
|
|
|
return themeConfig;
|
|
|
|
}
|
|
|
|
|
2013-12-10 08:41:58 +04:00
|
|
|
// We must pass the api.settings object
|
2013-12-06 18:13:15 +04:00
|
|
|
// 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.
|
2013-12-26 16:15:10 +04:00
|
|
|
function update(settings, configUrl) {
|
2014-05-07 04:49:25 +04:00
|
|
|
// TODO: Pass the context into this method instead of hard coding internal: true?
|
2014-08-17 10:17:23 +04:00
|
|
|
return Promise.all([
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 16:41:19 +04:00
|
|
|
settings.read('title'),
|
|
|
|
settings.read('description'),
|
|
|
|
settings.read('logo'),
|
|
|
|
settings.read('cover')
|
2013-12-06 18:13:15 +04:00
|
|
|
]).then(function (globals) {
|
2013-12-28 20:01:08 +04:00
|
|
|
// normalise the URL by removing any trailing slash
|
|
|
|
themeConfig.url = configUrl.replace(/\/$/, '');
|
2014-04-28 03:28:50 +04:00
|
|
|
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 : '';
|
2013-12-06 18:13:15 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = theme;
|
|
|
|
module.exports.update = update;
|