From 2b5d0e89a5e77f53aafb0a229ad536529169514b Mon Sep 17 00:00:00 2001 From: psychobunny Date: Mon, 29 Sep 2014 18:55:00 -0400 Subject: [PATCH] up'ing templates.js --- src/meta/themes.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/meta/themes.js b/src/meta/themes.js index f41620cc1b..d7511592c0 100644 --- a/src/meta/themes.js +++ b/src/meta/themes.js @@ -92,6 +92,9 @@ module.exports = function(Meta) { themeData['theme:src'] = ''; db.setObject('config', themeData, next); + + // Re-set the themes path (for when NodeBB is reloaded) + Meta.themes.setPath(config); } ], callback); @@ -104,4 +107,17 @@ module.exports = function(Meta) { } }; + Meta.themes.setPath = function(themeObj) { + console.log(themeObj); + // Theme's templates path + var themePath = nconf.get('base_templates_path'), + fallback = path.join(nconf.get('themes_path'), themeObj.id, 'templates'); + if (themeObj.templates) { + themePath = path.join(nconf.get('themes_path'), themeObj.id, themeObj.templates); + } else if (fs.existsSync(fallback)) { + themePath = fallback; + } + + nconf.set('theme_templates_path', themePath); + }; }; \ No newline at end of file