mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-09 08:07:37 +01:00
closes #2451
This commit is contained in:
@@ -59,16 +59,43 @@ module.exports = function(Meta) {
|
||||
};
|
||||
|
||||
Meta.configs.setMultiple = function(data, callback) {
|
||||
db.setObject('config', data, function(err) {
|
||||
processConfig(data, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
db.setObject('config', data, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
updateConfig(data);
|
||||
callback();
|
||||
updateConfig(data);
|
||||
callback();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function processConfig(data, callback) {
|
||||
if (data.customCSS) {
|
||||
saveRenderedCss(data, callback);
|
||||
return;
|
||||
}
|
||||
callback();
|
||||
}
|
||||
|
||||
function saveRenderedCss(data, callback) {
|
||||
var less = require('less');
|
||||
less.render(data.customCSS, {
|
||||
compress: true
|
||||
}, function(err, lessObject) {
|
||||
if (err) {
|
||||
winston.error('[less] Could not convert custom LESS to CSS! Please check your syntax.');
|
||||
return callback(null, '');
|
||||
}
|
||||
data.renderedCustomCSS = lessObject.css;
|
||||
callback(null, lessObject.css);
|
||||
});
|
||||
}
|
||||
|
||||
function updateConfig(data) {
|
||||
var msg = {action: 'config:update', data: data};
|
||||
if (process.send) {
|
||||
|
||||
@@ -198,7 +198,7 @@ middleware.checkAccountPermissions = function(req, res, next) {
|
||||
|
||||
middleware.buildHeader = function(req, res, next) {
|
||||
res.locals.renderHeader = true;
|
||||
|
||||
|
||||
middleware.applyCSRF(req, res, function() {
|
||||
async.parallel({
|
||||
config: function(next) {
|
||||
@@ -305,26 +305,10 @@ middleware.renderHeader = function(req, res, callback) {
|
||||
async.parallel({
|
||||
customCSS: function(next) {
|
||||
templateValues.useCustomCSS = parseInt(meta.config.useCustomCSS, 10) === 1;
|
||||
if (!templateValues.useCustomCSS) {
|
||||
if (!templateValues.useCustomCSS || !meta.config.customCSS || !meta.config.renderedCustomCSS) {
|
||||
return next(null, '');
|
||||
}
|
||||
|
||||
if (!meta.config.customCSS) {
|
||||
return next(null, '');
|
||||
}
|
||||
|
||||
var less = require('less');
|
||||
|
||||
less.render(meta.config.customCSS, {
|
||||
compress: true
|
||||
}, function(err, lessObject) {
|
||||
if (err) {
|
||||
winston.error('[less] Could not convert custom LESS to CSS! Please check your syntax.');
|
||||
return next(null, '');
|
||||
}
|
||||
|
||||
next(null, lessObject.css);
|
||||
});
|
||||
next(null, meta.config.renderedCustomCSS);
|
||||
},
|
||||
customJS: function(next) {
|
||||
templateValues.useCustomJS = parseInt(meta.config.useCustomJS, 10) === 1;
|
||||
|
||||
Reference in New Issue
Block a user