From 6b20cf5cff9acd43c4b490f11672fe337379c729 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sat, 6 Dec 2014 16:05:00 -0500 Subject: [PATCH] #2508 --- app.js | 5 ++--- src/meta/themes.js | 10 +++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 1db84c307a..3efdf2c8e5 100644 --- a/app.js +++ b/app.js @@ -150,8 +150,6 @@ function start() { plugins = require('./src/plugins'), upgrade = require('./src/upgrade'); - meta.themes.setupPaths(); - templates.setGlobal('relative_path', nconf.get('relative_path')); upgrade.check(function(schema_ok) { @@ -159,12 +157,13 @@ function start() { webserver.init(); sockets.init(webserver.server); - if (nconf.get('isPrimary')) { + if (nconf.get('isPrimary') === 'true') { require('./src/notifications').init(); require('./src/user').startJobs(); } async.waterfall([ + async.apply(meta.themes.setupPaths), async.apply(plugins.ready), async.apply(meta.templates.compile), async.apply(webserver.listen) diff --git a/src/meta/themes.js b/src/meta/themes.js index e3dcb67d01..77f1e41523 100644 --- a/src/meta/themes.js +++ b/src/meta/themes.js @@ -108,7 +108,7 @@ module.exports = function(Meta) { } }; - Meta.themes.setupPaths = function() { + Meta.themes.setupPaths = function(callback) { async.parallel({ themesData: Meta.themes.get, currentThemeId: function(next) { @@ -116,7 +116,7 @@ module.exports = function(Meta) { } }, function(err, data) { if (err) { - return winston.error(err.stack); + return callback(err); } var themeId = data.currentThemeId || 'nodebb-theme-vanilla'; @@ -125,12 +125,16 @@ module.exports = function(Meta) { return themeObj.id === themeId; })[0]; - if (process.env.NODE_ENV === 'development') { winston.info('[themes] Using theme ' + themeId); } + if (!themeObj) { + return callback(new Error('[[error:theme-not-found]]')); + } + Meta.themes.setPath(themeObj); + callback(); }); };