mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
e060a4f811
no issue 🎨 simplify loader - use loadOneTheme for init - use loadOneTheme for init - move updateThemeList to the one place that it is used - this just reduces the surface area of the loader 🎨 Move init up to index temporarily - need to figure out what stuff goes in here as well as loading themes - will move it again later once I've got it figured out 🎨 Reorder & cleanup theme middleware - move the order in blog/app.js so that theme middleware isn't called for shared assets - add comments & cleanup in the middleware itself, for clarity 🎨 Simplify the logic in themes middleware - Separate out config dependent on settings changing and config dependent on request - Move blogApp.set('views') - no reason why this isn't in the theme activation method as it's actually simpler if it is there, we already know the active theme exists & can remove the if-guard 🎨 Improve error handling for missing theme - ensure we display a warning - don't have complex logic for handling errors - move loading of an empty hbs object into the error-handler as this will support more cases 🐛 Fix assetHash clearing bug on theme switch - asset hash wasn't correctly being set on theme switch 🎨 Remove themes.read & test loader instead - Previously, we've simplified loader & improved error handling - We are now able to completely remove theme.read as it's nothing more than a wrapper for package.read - This also means we can change our tests from testing the theme reader to loader
37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
var debug = require('debug')('ghost:themes'),
|
|
events = require('../events'),
|
|
logging = require('../logging'),
|
|
i18n = require('../i18n'),
|
|
themeLoader = require('./loader'),
|
|
settingsCache = require('../settings/cache');
|
|
|
|
// @TODO: reduce the amount of things we expose to the outside world
|
|
// Make this a nice clean sensible API we can all understand!
|
|
module.exports = {
|
|
// 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.
|
|
loadAll: themeLoader.loadAllThemes,
|
|
loadOne: themeLoader.loadOneTheme,
|
|
list: require('./list'),
|
|
validate: require('./validate'),
|
|
toJSON: require('./to-json')
|
|
};
|