v1.18.x
Barış Soner Uşaklı 8 years ago
parent 458cbfd603
commit 9079ee5b14

@ -59,7 +59,8 @@ module.exports = function (middleware) {
};
templateValues.configJSON = JSON.stringify(res.locals.config);
async.waterfall([
function (next) {
async.parallel({
scripts: function (next) {
plugins.fireHook('filter:scripts.get', [], next);
@ -100,11 +101,9 @@ module.exports = function (middleware) {
tags: async.apply(meta.tags.parse, res.locals.metaTags, res.locals.linkTags),
banned: async.apply(user.isBanned, req.uid),
banReason: async.apply(user.getBannedReason, req.uid)
}, function (err, results) {
if (err) {
return callback(err);
}
}, next);
},
function (results, next) {
if (results.banned) {
req.logout();
return res.redirect('/?banned=' + (results.banReason || 'no-reason'));
@ -151,23 +150,31 @@ module.exports = function (middleware) {
modifyTitle(templateValues);
}
plugins.fireHook('filter:middleware.renderHeader', {templateValues: templateValues, req: req, res: res}, function (err, data) {
if (err) {
return callback(err);
plugins.fireHook('filter:middleware.renderHeader', {
req: req,
res: res,
templateValues: templateValues
}, next);
},
function (data, next) {
req.app.render('header', data.templateValues, next);
}
req.app.render('header', data.templateValues, callback);
});
});
], callback);
};
middleware.renderFooter = function (req, res, data, callback) {
plugins.fireHook('filter:middleware.renderFooter', {templateValues: data, req: req, res: res}, function (err, data) {
if (err) {
return callback(err);
async.waterfall([
function (next) {
plugins.fireHook('filter:middleware.renderFooter', {
req: req,
res: res,
templateValues: data,
}, next);
},
function (data, next) {
req.app.render('footer', data.templateValues, next);
}
req.app.render('footer', data.templateValues, callback);
});
], callback);
};
function modifyTitle(obj) {

Loading…
Cancel
Save