mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Including theme partials in a way that supports symbolically linked directories
closes #1937 - using fs.stat() instead of hasOwnProperty() to test for directory existence
This commit is contained in:
parent
c82d2eadba
commit
6437f343c1
1 changed files with 9 additions and 3 deletions
|
@ -10,6 +10,7 @@ var middleware = require('./middleware'),
|
|||
slashes = require('connect-slashes'),
|
||||
errors = require('../errorHandling'),
|
||||
api = require('../api'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
hbs = require('express-hbs'),
|
||||
config = require('../config'),
|
||||
|
@ -91,6 +92,7 @@ function initViews(req, res, next) {
|
|||
// Helper for manageAdminAndTheme
|
||||
function activateTheme(activeTheme) {
|
||||
var hbsOptions,
|
||||
themePartials = path.join(config.paths().themePath, activeTheme, 'partials'),
|
||||
stackLocation = _.indexOf(expressServer.stack, _.find(expressServer.stack, function (stackItem) {
|
||||
return stackItem.route === config.paths().subdir && stackItem.handle.name === 'settingEnabled';
|
||||
}));
|
||||
|
@ -106,10 +108,14 @@ function activateTheme(activeTheme) {
|
|||
|
||||
// set view engine
|
||||
hbsOptions = { partialsDir: [ config.paths().helperTemplates ] };
|
||||
if (config.paths().availableThemes[activeTheme].hasOwnProperty('partials')) {
|
||||
|
||||
fs.stat(themePartials, function (err, stats) {
|
||||
// Check that the theme has a partials directory before trying to use it
|
||||
hbsOptions.partialsDir.push(path.join(config.paths().themePath, activeTheme, 'partials'));
|
||||
}
|
||||
if (!err && stats && stats.isDirectory()) {
|
||||
hbsOptions.partialsDir.push(themePartials);
|
||||
}
|
||||
});
|
||||
|
||||
expressServer.set('theme view engine', hbs.express3(hbsOptions));
|
||||
|
||||
// Update user error template
|
||||
|
|
Loading…
Reference in a new issue