mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-06 15:42:52 +01:00
Split up customJS into customHTML and customJS for better organisation (#5981)
* WIP * fixed customJS not actually working in footer * Moving scripts to footer, #5980 * Added upgrade scripts for #5980
This commit is contained in:
@@ -65,9 +65,6 @@ module.exports = function (middleware) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
scripts: function (next) {
|
||||
plugins.fireHook('filter:scripts.get', [], next);
|
||||
},
|
||||
isAdmin: function (next) {
|
||||
user.isAdministrator(req.uid, next);
|
||||
},
|
||||
@@ -143,8 +140,8 @@ module.exports = function (middleware) {
|
||||
templateValues.userJSON = JSON.stringify(results.user);
|
||||
templateValues.useCustomCSS = parseInt(meta.config.useCustomCSS, 10) === 1 && meta.config.customCSS;
|
||||
templateValues.customCSS = templateValues.useCustomCSS ? (meta.config.renderedCustomCSS || '') : '';
|
||||
templateValues.useCustomJS = parseInt(meta.config.useCustomJS, 10) === 1;
|
||||
templateValues.customJS = templateValues.useCustomJS ? meta.config.customJS : '';
|
||||
templateValues.useCustomHTML = parseInt(meta.config.useCustomHTML, 10) === 1;
|
||||
templateValues.customHTML = templateValues.useCustomHTML ? meta.config.customHTML : '';
|
||||
templateValues.maintenanceHeader = parseInt(meta.config.maintenanceMode, 10) === 1 && !results.isAdmin;
|
||||
templateValues.defaultLang = meta.config.defaultLang || 'en-GB';
|
||||
templateValues.userLang = res.locals.config.userLang;
|
||||
@@ -155,12 +152,6 @@ module.exports = function (middleware) {
|
||||
templateValues.template = { name: res.locals.template };
|
||||
templateValues.template[res.locals.template] = true;
|
||||
|
||||
templateValues.scripts = results.scripts.map(function (script) {
|
||||
return { src: script };
|
||||
});
|
||||
|
||||
addTimeagoLocaleScript(templateValues.scripts, res.locals.config.userLang);
|
||||
|
||||
if (req.route && req.route.path === '/') {
|
||||
modifyTitle(templateValues);
|
||||
}
|
||||
@@ -192,6 +183,21 @@ module.exports = function (middleware) {
|
||||
}, next);
|
||||
},
|
||||
function (data, next) {
|
||||
async.parallel({
|
||||
scripts: async.apply(plugins.fireHook, 'filter:scripts.get', []),
|
||||
}, function (err, results) {
|
||||
next(err, data, results);
|
||||
});
|
||||
},
|
||||
function (data, results, next) {
|
||||
data.templateValues.scripts = results.scripts.map(function (script) {
|
||||
return { src: script };
|
||||
});
|
||||
addTimeagoLocaleScript(data.templateValues.scripts, res.locals.config.userLang);
|
||||
|
||||
data.templateValues.useCustomJS = parseInt(meta.config.useCustomJS, 10) === 1;
|
||||
data.templateValues.customJS = data.templateValues.useCustomJS ? meta.config.customJS : '';
|
||||
|
||||
req.app.render('footer', data.templateValues, next);
|
||||
},
|
||||
], callback);
|
||||
|
||||
Reference in New Issue
Block a user