2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Allow themes to provide custom error template.

fixes #1212, #1213
This commit is contained in:
Fabian Becker 2013-10-21 16:59:37 +00:00
parent cf9b5d9441
commit 57bd929d2c
2 changed files with 15 additions and 7 deletions

View file

@ -198,6 +198,9 @@ function activateTheme() {
if (stackLocation) {
server.stack[stackLocation].handle = whenEnabled(server.get('activeTheme'), middleware.staticTheme(ghost));
}
// Update user error template
errors.updateActiveTheme(ghost.settings('activeTheme'));
}
// ### ManageAdminAndTheme Middleware

View file

@ -6,17 +6,22 @@ var _ = require('underscore'),
errors,
// Paths for views
appRoot = path.resolve(__dirname, '../'),
themePath = path.resolve(appRoot + '/content/themes'),
adminTemplatePath = path.resolve(appRoot + '/server/views/'),
defaultErrorTemplatePath = path.resolve(adminTemplatePath + '/user-error.hbs'),
userErrorTemplatePath = path.resolve(themePath + '/error.hbs'),
appRoot = path.resolve(__dirname, '..', '..'),
themePath = path.resolve(appRoot, 'content', 'themes'),
adminTemplatePath = path.resolve(appRoot, 'core', 'server', 'views'),
defaultErrorTemplatePath = path.resolve(adminTemplatePath, 'user-error.hbs'),
userErrorTemplatePath = path.resolve(themePath, 'error.hbs'),
userErrorTemplateExists;
/**
* Basic error handling helpers
*/
errors = {
updateActiveTheme: function (activeTheme) {
userErrorTemplatePath = path.resolve(themePath, activeTheme, 'error.hbs');
userErrorTemplateExists = undefined;
},
throwError: function (err) {
if (!err) {
err = new Error("An error occurred");
@ -104,7 +109,7 @@ errors = {
renderErrorPage: function (code, err, req, res, next) {
function parseStack(stack) {
if (typeof stack !== 'string') {
if (_.isString(stack)) {
return stack;
}
@ -208,4 +213,4 @@ _.bindAll(
'error500'
);
module.exports = errors;
module.exports = errors;