0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Improved theme loading

- In some cases, Ghost exploded when the active theme did not have a partials directory
- Added handling for if the active theme was not present
- Probably will conflict with #574 I need to fix this.
This commit is contained in:
Hannah Wolfe 2013-09-02 11:16:01 +01:00
parent 76c2ff6818
commit 56b7f925da

View file

@ -303,9 +303,20 @@ Ghost.prototype.initTheme = function (app) {
express['static'].mime.define({'application/font-woff': ['woff']});
if (!res.isAdmin) {
if (!self.themeDirectories.hasOwnProperty(self.settings().activeTheme)) {
// Throw an error if the theme is not available...
// TODO: move this to happen on app start
errors.logAndThrowError('The currently active theme ' + self.settings().activeTheme + ' is missing.');
} else if (self.themeDirectories[self.settings().activeTheme].hasOwnProperty('partials')) {
// Check that the theme has a partials directory before trying to use it
app.engine('hbs', hbs.express3(
{partialsDir: path.join(self.paths().activeTheme, 'partials')}
));
} else {
// No partial dir, so no need to configure it
app.engine('hbs', hbs.express3());
}
app.set('views', self.paths().activeTheme);
} else {
app.engine('hbs', hbs.express3({partialsDir: self.paths().adminViews + 'partials'}));