added function to update branding colors

v1.18.x
psychobunny 11 years ago
parent 70b5f9addc
commit ec5cdd178a

@ -329,6 +329,8 @@ var fs = require('fs'),
/* Themes */ /* Themes */
Meta.css = {}; Meta.css = {};
Meta.css.cache = undefined; Meta.css.cache = undefined;
Meta.css.branding = {};
Meta.css.minify = function() { Meta.css.minify = function() {
winston.info('[meta/css] Minifying LESS/CSS'); winston.info('[meta/css] Minifying LESS/CSS');
db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) { 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, var re = /.brand-([\S]*?)[ ]*?{[\s\S]*?color:([\S\s]*?)}/gi,
match, match;
branding = {};
while (match = re.exec(css)) { 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; 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 */ /* Sounds */
Meta.sounds = {}; Meta.sounds = {};
Meta.sounds.init = function() { Meta.sounds.init = function() {

Loading…
Cancel
Save