mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-29 14:17:29 +02:00
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
@@ -38,7 +38,7 @@ module.exports = function (middleware) {
|
||||
plugins: [],
|
||||
authentication: [],
|
||||
};
|
||||
|
||||
res.locals.config = res.locals.config || {};
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
@@ -51,9 +51,6 @@ module.exports = function (middleware) {
|
||||
custom_header: function (next) {
|
||||
plugins.fireHook('filter:admin.header.build', custom_header, next);
|
||||
},
|
||||
config: function (next) {
|
||||
controllers.api.getConfig(req, res, next);
|
||||
},
|
||||
configs: function (next) {
|
||||
meta.configs.list(next);
|
||||
},
|
||||
@@ -64,8 +61,6 @@ module.exports = function (middleware) {
|
||||
userData.uid = req.uid;
|
||||
userData['email:confirmed'] = parseInt(userData['email:confirmed'], 10) === 1;
|
||||
|
||||
res.locals.config = results.config;
|
||||
|
||||
var acpPath = req.path.slice(1).split('/');
|
||||
acpPath.forEach(function (path, i) {
|
||||
acpPath[i] = path.charAt(0).toUpperCase() + path.slice(1);
|
||||
@@ -73,9 +68,9 @@ module.exports = function (middleware) {
|
||||
acpPath = acpPath.join(' > ');
|
||||
|
||||
var templateValues = {
|
||||
config: results.config,
|
||||
configJSON: jsesc(JSON.stringify(results.config), { isScriptContext: true }),
|
||||
relative_path: results.config.relative_path,
|
||||
config: res.locals.config,
|
||||
configJSON: jsesc(JSON.stringify(res.locals.config), { isScriptContext: true }),
|
||||
relative_path: res.locals.config.relative_path,
|
||||
adminConfigJSON: encodeURIComponent(JSON.stringify(results.configs)),
|
||||
user: userData,
|
||||
userJSON: jsesc(JSON.stringify(userData), { isScriptContext: true }),
|
||||
|
||||
@@ -283,7 +283,7 @@ module.exports = function (middleware) {
|
||||
}
|
||||
|
||||
if (skinToUse) {
|
||||
obj.bootswatchCSS = '//maxcdn.bootstrapcdn.com/bootswatch/latest/' + skinToUse + '/bootstrap.min.css';
|
||||
obj.bootswatchCSS = '//maxcdn.bootstrapcdn.com/bootswatch/3.3.7/' + skinToUse + '/bootstrap.min.css';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,12 +237,18 @@ middleware.templatesOnDemand = function (req, res, next) {
|
||||
fs.readFile(filePath.replace(/\.js$/, '.tpl'), 'utf8', cb);
|
||||
},
|
||||
function (source, cb) {
|
||||
if (!source) {
|
||||
return cb(new Error('[[error:templatesOnDemand.source-template-empty]]'));
|
||||
}
|
||||
Benchpress.precompile({
|
||||
source: source,
|
||||
minify: global.env !== 'development',
|
||||
}, cb);
|
||||
},
|
||||
function (compiled, cb) {
|
||||
if (!compiled) {
|
||||
return cb(new Error('[[error:templatesOnDemand.compiled-template-empty]]'));
|
||||
}
|
||||
fs.writeFile(filePath, compiled, cb);
|
||||
},
|
||||
], function (err) {
|
||||
|
||||
@@ -41,8 +41,7 @@ module.exports = function (middleware) {
|
||||
options.template = { name: template };
|
||||
options.template[template] = true;
|
||||
options.url = (req.baseUrl + req.path.replace(/^\/api/, ''));
|
||||
options.bodyClass = buildBodyClass(req, options);
|
||||
|
||||
options.bodyClass = buildBodyClass(req, res, options);
|
||||
plugins.fireHook('filter:' + template + '.build', { req: req, res: res, templateData: options }, next);
|
||||
},
|
||||
function (data, next) {
|
||||
@@ -120,13 +119,16 @@ module.exports = function (middleware) {
|
||||
|
||||
function translate(str, req, res, next) {
|
||||
var language = (res.locals.config && res.locals.config.userLang) || 'en-GB';
|
||||
if (res.locals.renderAdminHeader) {
|
||||
language = (res.locals.config && res.locals.config.acpLang) || 'en-GB';
|
||||
}
|
||||
language = req.query.lang ? validator.escape(String(req.query.lang)) : language;
|
||||
translator.translate(str, language, function (translated) {
|
||||
next(null, translator.unescape(translated));
|
||||
});
|
||||
}
|
||||
|
||||
function buildBodyClass(req, templateData) {
|
||||
function buildBodyClass(req, res, templateData) {
|
||||
var clean = req.path.replace(/^\/api/, '').replace(/^\/|\/$/g, '');
|
||||
var parts = clean.split('/').slice(0, 3);
|
||||
parts.forEach(function (p, index) {
|
||||
@@ -145,6 +147,7 @@ module.exports = function (middleware) {
|
||||
parts.push('page-topic-category-' + utils.slugify(templateData.category.name));
|
||||
}
|
||||
|
||||
parts.push('page-status-' + res.statusCode);
|
||||
return parts.join(' ');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user