mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
prevent a potentially badly written theme.json from blowing up your forum
This commit is contained in:
@@ -61,26 +61,37 @@
|
|||||||
function loadServer() {
|
function loadServer() {
|
||||||
var loaded = templatesToLoad.length;
|
var loaded = templatesToLoad.length;
|
||||||
|
|
||||||
for (var t in templatesToLoad) {
|
function getTemplates(directory) {
|
||||||
(function (file) {
|
for (var t in templatesToLoad) {
|
||||||
fs.readFile((customTemplateDir ? customTemplateDir : __dirname + '/../templates') + '/' + file + '.tpl', function (err, html) {
|
(function (file) {
|
||||||
var template = function () {
|
fs.readFile(directory + '/' + file + '.tpl', function (err, html) {
|
||||||
this.toString = function () {
|
var template = function () {
|
||||||
return this.html;
|
this.toString = function () {
|
||||||
};
|
return this.html;
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
|
||||||
template.prototype.file = file;
|
template.prototype.file = file;
|
||||||
template.prototype.parse = parse;
|
template.prototype.parse = parse;
|
||||||
template.prototype.html = String(html);
|
template.prototype.html = String(html);
|
||||||
|
|
||||||
global.templates[file] = new template;
|
global.templates[file] = new template;
|
||||||
|
|
||||||
loaded--;
|
loaded--;
|
||||||
if (loaded == 0) templates.ready();
|
if (loaded == 0) templates.ready();
|
||||||
});
|
});
|
||||||
}(templatesToLoad[t]));
|
}(templatesToLoad[t]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (customTemplateDir) {
|
||||||
|
fs.exists(customTemplateDir, function (exists) {
|
||||||
|
var directory = (exists ? customTemplateDir : __dirname + '/../templates');
|
||||||
|
getTemplates(customTemplateDir);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
getTemplates(__dirname + '/../templates');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadClient() {
|
function loadClient() {
|
||||||
|
|||||||
Reference in New Issue
Block a user