Node.js based forum software built for the modern web
themes - added ability to route custom templates serverside
psychobunny1d5a2088968c
diff --git a/app.js b/app.jsindex 4324d6f2e4..e8b662bbd4 100644--- a/app.js+++ b/app.js@@ -96,6 +96,8 @@global.translator = translator;translator.loadServer();++ var customTemplates = meta.config['theme:templates'] ? path.join(__dirname, 'node_modules', meta.config['theme:id'], meta.config['theme:templates']) : false;// todo: replace below with read directory code, derp.templates.init([@@ -104,7 +106,8 @@'emails/header', 'emails/footer','noscript/header', 'noscript/home', 'noscript/category', 'noscript/topic'- ]);+ ], customTemplates);+templates.ready(webserver.init);diff --git a/public/src/templates.js b/public/src/templates.jsindex 5e9d5e35f5..3329d2782b 100644--- a/public/src/templates.js+++ b/public/src/templates.js@@ -57,13 +57,13 @@return template;};- function loadTemplates(templatesToLoad) {+ function loadTemplates(templatesToLoad, customTemplateDir) {function loadServer() {var loaded = templatesToLoad.length;for (var t in templatesToLoad) {(function (file) {- fs.readFile(__dirname + '/../templates/' + file + '.tpl', function (err, html) {+ fs.readFile((customTemplateDir ? customTemplateDir : __dirname + '/../templates') + '/' + file + '.tpl', function (err, html) {var template = function () {this.toString = function () {return this.html;@@ -96,8 +96,8 @@}- templates.init = function (templates_to_load) {- loadTemplates(templates_to_load || []);+ templates.init = function (templates_to_load, custom_templates) {+ loadTemplates(templates_to_load || [], custom_templates || false);}templates.getTemplateNameFromUrl = function (url) {