Baris Soner Usakli 11 years ago
commit 204913c63d

@ -27,8 +27,9 @@
async = require('async'),
semver = require('semver'),
winston = require('winston'),
pkg = require('./package.json'),
path = require('path'),
pkg = require('./package.json'),
utils = require('./public/src/utils.js'),
meta;
// Runtime environment
@ -108,15 +109,10 @@
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([
'header', 'footer', 'logout', 'outgoing', 'admin/header', 'admin/footer', 'admin/index',
'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext',
'emails/header', 'emails/footer',
'noscript/header', 'noscript/home', 'noscript/category', 'noscript/topic'
], customTemplates);
utils.walk(path.join(__dirname, 'public/templates'), function (err, tplsToLoad) {
templates.init(tplsToLoad, customTemplates);
});
plugins.ready(function() {
templates.ready(webserver.init);

@ -48,7 +48,7 @@
}
};
templates.prepare = function (raw_tpl, data) {
templates.prepare = function (raw_tpl) {
var template = {};
template.html = raw_tpl;
template.parse = parse;
@ -78,7 +78,9 @@
global.templates[file] = new template;
loaded--;
if (loaded == 0) templates.ready();
if (loaded === 0) {
templates.ready();
}
});
}(templatesToLoad[t]));
}

@ -807,7 +807,8 @@ var path = require('path'),
var custom_routes = {
'routes': [],
'api': []
'api': [],
'templates': []
};
plugins.ready(function() {
@ -843,6 +844,17 @@ var path = require('path'),
}
}
var templateRoutes = custom_routes.templates;
for (var route in templateRoutes) {
if (templateRoutes.hasOwnProperty(route)) {
(function(route) {
app.get('/templates/' + templateRoutes[route].template, function(req, res) {
res.send(templateRoutes[route].content);
});
}(route));
}
}
});
});

@ -106,12 +106,12 @@ websockets.init = function(io) {
socket.on('disconnect', function() {
var index = userSockets[uid].indexOf(socket);
var index = (userSockets[uid] || []).indexOf(socket);
if (index !== -1) {
userSockets[uid].splice(index, 1);
}
if (userSockets[uid].length === 0) {
if (userSockets[uid] && userSockets[uid].length === 0) {
delete users[sessionID];
delete userSockets[uid];
if (uid) {

Loading…
Cancel
Save