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:
commit
18638d378e
1 changed files with 14 additions and 1 deletions
|
@ -94,7 +94,10 @@ function configHbsForContext(req, res, next) {
|
||||||
}
|
}
|
||||||
|
|
||||||
hbs.updateTemplateOptions({data: {blog: themeData}});
|
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
|
// Pass 'secure' flag to the view engine
|
||||||
// so that templates can choose 'url' vs 'urlSSL'
|
// so that templates can choose 'url' vs 'urlSSL'
|
||||||
|
@ -110,6 +113,7 @@ function configHbsForContext(req, res, next) {
|
||||||
function updateActiveTheme(req, res, next) {
|
function updateActiveTheme(req, res, next) {
|
||||||
api.settings.read({context: {internal: true}, key: 'activeTheme'}).then(function (response) {
|
api.settings.read({context: {internal: true}, key: 'activeTheme'}).then(function (response) {
|
||||||
var activeTheme = response.settings[0];
|
var activeTheme = response.settings[0];
|
||||||
|
|
||||||
// Check if the theme changed
|
// Check if the theme changed
|
||||||
if (activeTheme.value !== blogApp.get('activeTheme')) {
|
if (activeTheme.value !== blogApp.get('activeTheme')) {
|
||||||
// Change theme
|
// Change theme
|
||||||
|
@ -117,6 +121,15 @@ function updateActiveTheme(req, res, next) {
|
||||||
if (!res.isAdmin) {
|
if (!res.isAdmin) {
|
||||||
// Throw an error if the theme is not available, but not on the admin UI
|
// 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.');
|
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 {
|
} else {
|
||||||
activateTheme(activeTheme.value);
|
activateTheme(activeTheme.value);
|
||||||
|
|
Loading…
Add table
Reference in a new issue