0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Merge pull request #5191 from jaswilli/issue-5155

Allow admin app to run when active theme missing
This commit is contained in:
Hannah Wolfe 2015-04-26 08:47:17 +01:00
commit 18638d378e

View file

@ -94,7 +94,10 @@ function configHbsForContext(req, res, next) {
}
hbs.updateTemplateOptions({data: {blog: themeData}});
blogApp.set('views', path.join(config.paths.themePath, blogApp.get('activeTheme')));
if (config.paths.themePath && blogApp.get('activeTheme')) {
blogApp.set('views', path.join(config.paths.themePath, blogApp.get('activeTheme')));
}
// Pass 'secure' flag to the view engine
// so that templates can choose 'url' vs 'urlSSL'
@ -110,6 +113,7 @@ function configHbsForContext(req, res, next) {
function updateActiveTheme(req, res, next) {
api.settings.read({context: {internal: true}, key: 'activeTheme'}).then(function (response) {
var activeTheme = response.settings[0];
// Check if the theme changed
if (activeTheme.value !== blogApp.get('activeTheme')) {
// Change theme
@ -117,6 +121,15 @@ function updateActiveTheme(req, res, next) {
if (!res.isAdmin) {
// Throw an error if the theme is not available, but not on the admin UI
return errors.throwError('The currently active theme ' + activeTheme.value + ' is missing.');
} else {
// At this point the activated theme is not present and the current
// request is for the admin client. In order to allow the user access
// to the admin client we set an hbs instance on the app so that middleware
// processing can continue.
blogApp.engine('hbs', hbs.express3());
errors.logWarn('The currently active theme "' + activeTheme.value + '" is missing.');
return next();
}
} else {
activateTheme(activeTheme.value);