2017-03-13 19:30:35 +03:00
|
|
|
var debug = require('debug')('ghost:themes'),
|
|
|
|
events = require('../events'),
|
|
|
|
logging = require('../logging'),
|
|
|
|
i18n = require('../i18n'),
|
|
|
|
themeLoader = require('./loader'),
|
|
|
|
settingsCache = require('../settings/cache');
|
2017-02-22 02:26:19 +03:00
|
|
|
|
2017-03-02 19:53:48 +03:00
|
|
|
// @TODO: reduce the amount of things we expose to the outside world
|
|
|
|
// Make this a nice clean sensible API we can all understand!
|
2017-02-22 02:26:19 +03:00
|
|
|
module.exports = {
|
2017-03-13 19:30:35 +03:00
|
|
|
// Init themes module
|
|
|
|
// TODO: move this once we're clear what needs to happen here
|
|
|
|
init: function initThemes() {
|
|
|
|
var activeThemeName = settingsCache.get('activeTheme');
|
|
|
|
debug('init themes', activeThemeName);
|
|
|
|
|
|
|
|
// Register a listener for server-start to load all themes
|
|
|
|
events.on('server:start', function readAllThemesOnServerStart() {
|
|
|
|
themeLoader.loadAllThemes();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Just read the active theme for now
|
|
|
|
return themeLoader
|
|
|
|
.loadOneTheme(activeThemeName)
|
|
|
|
.catch(function () {
|
|
|
|
// Active theme is missing, we don't want to exit because the admin panel will still work
|
|
|
|
logging.warn(i18n.t('errors.middleware.themehandler.missingTheme', {theme: activeThemeName}));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
// Load themes, soon to be removed and exposed via specific function.
|
2017-03-02 19:53:48 +03:00
|
|
|
loadAll: themeLoader.loadAllThemes,
|
|
|
|
loadOne: themeLoader.loadOneTheme,
|
|
|
|
list: require('./list'),
|
2017-03-13 14:44:44 +03:00
|
|
|
validate: require('./validate'),
|
|
|
|
toJSON: require('./to-json')
|
2017-02-22 02:26:19 +03:00
|
|
|
};
|