mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
fe90cf2be2
no issue * ✨ Add new server start & stop events * 🔥 Get rid of unused availableApps concept - when we need an API endpoint for a list of apps, we'll build one 😝 * ✨ Move theme loading into a module - move loading from API method to a module method and use as needed - wire up read one vs read all as per LTS - read one (the active theme) on boot, and read the rest after - fudge validation - this isn't all that helpful * Settings API tests need to preload themes - this used to automatically happen as part of loading settings - now we need to trigger this to happen specifically for this test
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
var debug = require('debug')('ghost:themes:loader'),
|
|
config = require('../config'),
|
|
events = require('../events'),
|
|
read = require('./read'),
|
|
settingsApi = require('../api/settings'),
|
|
updateConfigAndCache,
|
|
loadThemes,
|
|
initThemes;
|
|
|
|
updateConfigAndCache = function updateConfigAndCache(themes) {
|
|
debug('loading themes', themes);
|
|
config.set('paths:availableThemes', themes);
|
|
settingsApi.updateSettingsCache();
|
|
};
|
|
|
|
loadThemes = function loadThemes() {
|
|
return read
|
|
.all(config.getContentPath('themes'))
|
|
.then(updateConfigAndCache);
|
|
};
|
|
|
|
initThemes = function initThemes() {
|
|
debug('init themes', settingsApi.cache.get('activeTheme'));
|
|
|
|
// Register a listener for server-start to load all themes
|
|
events.on('server:start', function readAllThemesOnServerStart() {
|
|
loadThemes();
|
|
});
|
|
|
|
// Just read the active theme for now
|
|
return read
|
|
.one(config.getContentPath('themes'), settingsApi.cache.get('activeTheme'))
|
|
.then(updateConfigAndCache);
|
|
};
|
|
|
|
module.exports = {
|
|
init: initThemes,
|
|
load: loadThemes
|
|
};
|