mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 04:13:30 +03:00
Merge pull request #1218 from halfdan/1212-themable-error-pages
Allow themes to provide custom error template.
This commit is contained in:
commit
40ba763f0f
@ -198,6 +198,9 @@ function activateTheme() {
|
|||||||
if (stackLocation) {
|
if (stackLocation) {
|
||||||
server.stack[stackLocation].handle = whenEnabled(server.get('activeTheme'), middleware.staticTheme(ghost));
|
server.stack[stackLocation].handle = whenEnabled(server.get('activeTheme'), middleware.staticTheme(ghost));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update user error template
|
||||||
|
errors.updateActiveTheme(ghost.settings('activeTheme'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ### ManageAdminAndTheme Middleware
|
// ### ManageAdminAndTheme Middleware
|
||||||
|
@ -6,17 +6,22 @@ var _ = require('underscore'),
|
|||||||
errors,
|
errors,
|
||||||
|
|
||||||
// Paths for views
|
// Paths for views
|
||||||
appRoot = path.resolve(__dirname, '../'),
|
appRoot = path.resolve(__dirname, '..', '..'),
|
||||||
themePath = path.resolve(appRoot + '/content/themes'),
|
themePath = path.resolve(appRoot, 'content', 'themes'),
|
||||||
adminTemplatePath = path.resolve(appRoot + '/server/views/'),
|
adminTemplatePath = path.resolve(appRoot, 'core', 'server', 'views'),
|
||||||
defaultErrorTemplatePath = path.resolve(adminTemplatePath + '/user-error.hbs'),
|
defaultErrorTemplatePath = path.resolve(adminTemplatePath, 'user-error.hbs'),
|
||||||
userErrorTemplatePath = path.resolve(themePath + '/error.hbs'),
|
userErrorTemplatePath = path.resolve(themePath, 'error.hbs'),
|
||||||
userErrorTemplateExists;
|
userErrorTemplateExists;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic error handling helpers
|
* Basic error handling helpers
|
||||||
*/
|
*/
|
||||||
errors = {
|
errors = {
|
||||||
|
updateActiveTheme: function (activeTheme) {
|
||||||
|
userErrorTemplatePath = path.resolve(themePath, activeTheme, 'error.hbs');
|
||||||
|
userErrorTemplateExists = undefined;
|
||||||
|
},
|
||||||
|
|
||||||
throwError: function (err) {
|
throwError: function (err) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
err = new Error("An error occurred");
|
err = new Error("An error occurred");
|
||||||
@ -104,7 +109,7 @@ errors = {
|
|||||||
renderErrorPage: function (code, err, req, res, next) {
|
renderErrorPage: function (code, err, req, res, next) {
|
||||||
|
|
||||||
function parseStack(stack) {
|
function parseStack(stack) {
|
||||||
if (typeof stack !== 'string') {
|
if (_.isString(stack)) {
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user