mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-22 07:23:01 +01:00
added function to update branding colors
This commit is contained in:
21
src/meta.js
21
src/meta.js
@@ -329,6 +329,8 @@ var fs = require('fs'),
|
||||
/* Themes */
|
||||
Meta.css = {};
|
||||
Meta.css.cache = undefined;
|
||||
Meta.css.branding = {};
|
||||
|
||||
Meta.css.minify = function() {
|
||||
winston.info('[meta/css] Minifying LESS/CSS');
|
||||
db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) {
|
||||
@@ -369,11 +371,14 @@ var fs = require('fs'),
|
||||
});
|
||||
|
||||
var re = /.brand-([\S]*?)[ ]*?{[\s\S]*?color:([\S\s]*?)}/gi,
|
||||
match,
|
||||
branding = {};
|
||||
match;
|
||||
|
||||
while (match = re.exec(css)) {
|
||||
branding[match[1]] = match[2];
|
||||
Meta.css.branding[match[1]] = match[2];
|
||||
}
|
||||
|
||||
if (typeof Meta.config.branding !== 'undefined') {
|
||||
Meta.css.updateBranding(Meta.config.branding);
|
||||
}
|
||||
|
||||
Meta.css.cache = css;
|
||||
@@ -382,6 +387,16 @@ var fs = require('fs'),
|
||||
});
|
||||
};
|
||||
|
||||
Meta.css.updateBranding = function(branding) {
|
||||
for (var b in branding) {
|
||||
if (branding.hasOwnProperty(b)) {
|
||||
Meta.css.replace(new RegExp(Meta.css.branding[b], 'g'), branding[b]);
|
||||
}
|
||||
}
|
||||
|
||||
Meta.css.branding = branding;
|
||||
};
|
||||
|
||||
/* Sounds */
|
||||
Meta.sounds = {};
|
||||
Meta.sounds.init = function() {
|
||||
|
||||
Reference in New Issue
Block a user