mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 19:21:04 +01:00
themes - added ability to route custom templates serverside
This commit is contained in:
5
app.js
5
app.js
@@ -97,6 +97,8 @@
|
|||||||
|
|
||||||
translator.loadServer();
|
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.
|
// todo: replace below with read directory code, derp.
|
||||||
templates.init([
|
templates.init([
|
||||||
'header', 'footer', 'logout', 'outgoing', 'admin/header', 'admin/footer', 'admin/index',
|
'header', 'footer', 'logout', 'outgoing', 'admin/header', 'admin/footer', 'admin/index',
|
||||||
@@ -104,7 +106,8 @@
|
|||||||
'emails/header', 'emails/footer',
|
'emails/header', 'emails/footer',
|
||||||
|
|
||||||
'noscript/header', 'noscript/home', 'noscript/category', 'noscript/topic'
|
'noscript/header', 'noscript/home', 'noscript/category', 'noscript/topic'
|
||||||
]);
|
], customTemplates);
|
||||||
|
|
||||||
|
|
||||||
templates.ready(webserver.init);
|
templates.ready(webserver.init);
|
||||||
|
|
||||||
|
|||||||
@@ -57,13 +57,13 @@
|
|||||||
return template;
|
return template;
|
||||||
};
|
};
|
||||||
|
|
||||||
function loadTemplates(templatesToLoad) {
|
function loadTemplates(templatesToLoad, customTemplateDir) {
|
||||||
function loadServer() {
|
function loadServer() {
|
||||||
var loaded = templatesToLoad.length;
|
var loaded = templatesToLoad.length;
|
||||||
|
|
||||||
for (var t in templatesToLoad) {
|
for (var t in templatesToLoad) {
|
||||||
(function (file) {
|
(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 () {
|
var template = function () {
|
||||||
this.toString = function () {
|
this.toString = function () {
|
||||||
return this.html;
|
return this.html;
|
||||||
@@ -96,8 +96,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
templates.init = function (templates_to_load) {
|
templates.init = function (templates_to_load, custom_templates) {
|
||||||
loadTemplates(templates_to_load || []);
|
loadTemplates(templates_to_load || [], custom_templates || false);
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.getTemplateNameFromUrl = function (url) {
|
templates.getTemplateNameFromUrl = function (url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user