mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
deprecating use of templates.setGlobal on server side in favour of passing in api.config into res.locals (still needs work)
This commit is contained in:
@@ -13,7 +13,12 @@ var app,
|
||||
plugins = require('./../plugins'),
|
||||
meta = require('./../meta'),
|
||||
translator = require('./../../public/src/translator'),
|
||||
user = require('./../user');
|
||||
user = require('./../user'),
|
||||
|
||||
controllers = {
|
||||
api: require('./../controllers/api')
|
||||
};
|
||||
|
||||
|
||||
middleware.authenticate = function(req, res, next) {
|
||||
if(!req.user) {
|
||||
@@ -87,6 +92,12 @@ middleware.buildHeader = function(req, res, next) {
|
||||
res.locals.renderHeader = true;
|
||||
next();
|
||||
},
|
||||
function(next) {
|
||||
controllers.api.getConfig(req, res, function(err, config) {
|
||||
res.locals.config = config;
|
||||
next();
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
// this is slower than the original implementation because the rendered template is not cached
|
||||
// but I didn't bother to fix this because we will deprecate [filter:footer.build] in favour of the widgets system by 0.4x
|
||||
@@ -158,6 +169,12 @@ middleware.renderHeader = function (options, callback) {
|
||||
'"': '"'
|
||||
};
|
||||
|
||||
for (var key in options.res.locals.config) {
|
||||
if (options.res.locals.config.hasOwnProperty(key)) {
|
||||
templateValues[key] = options.res.locals.config[key];
|
||||
}
|
||||
}
|
||||
|
||||
var uid = '0';
|
||||
|
||||
templateValues.metaTags = defaultMetaTags.concat(options.res.locals.metaTags || []).map(function(tag) {
|
||||
|
||||
Reference in New Issue
Block a user