mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-05 09:50:34 +03:00
c8c02a65fa
fixes #1575 - Moves most code that was in ghost.js into ./core/server/index.js - Creates ./core/server/config/theme.js to hold all theme configurations (which previously lived on ghost.blogGlobals()) - Removed ghost.server, passing it in as an argument where needed and allowing middleware to hold onto a reference for lazy use.
43 lines
1.2 KiB
JavaScript
43 lines
1.2 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 and config 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.
|
|
// And we can't require('./index') from here because it is circular.
|
|
function update(api, config) {
|
|
return when.all([
|
|
api.settings.read('title'),
|
|
api.settings.read('description'),
|
|
api.settings.read('logo'),
|
|
api.settings.read('cover')
|
|
]).then(function (globals) {
|
|
|
|
themeConfig.path = config.paths().path;
|
|
|
|
themeConfig.url = config().url;
|
|
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;
|