diff --git a/public/src/utils.js b/public/src/utils.js index 0c58817411..b48b4345ae 100644 --- a/public/src/utils.js +++ b/public/src/utils.js @@ -365,6 +365,18 @@ } return i < 0; }; + + String.prototype.endsWith = function(suffix) { + if (this.length < suffix.length) { + return false; + } + var len = this.length; + var suffixLen = suffix.length; + for (var i=1; (i <= suffixLen && this[len - i] === suffix[suffixLen - i]); ++i) { + continue; + } + return i > suffixLen; + }; } if ('undefined' !== typeof window) { diff --git a/src/meta/css.js b/src/meta/css.js index d45b61f280..a8682b1038 100644 --- a/src/meta/css.js +++ b/src/meta/css.js @@ -10,7 +10,8 @@ var winston = require('winston'), plugins = require('../plugins'), emitter = require('../emitter'), - db = require('../database'); + db = require('../database'), + utils = require('../../public/src/utils'); module.exports = function(Meta) { @@ -21,30 +22,46 @@ module.exports = function(Meta) { Meta.css.defaultBranding = {}; Meta.css.minify = function(callback) { - if (nconf.get('isPrimary') === 'true') { - winston.verbose('[meta/css] Minifying LESS/CSS'); - db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) { - var themeId = (themeData['theme:id'] || 'nodebb-theme-vanilla'), - baseThemePath = path.join(nconf.get('themes_path'), (themeData['theme:type'] && themeData['theme:type'] === 'local' ? themeId : 'nodebb-theme-vanilla')), - paths = [ - baseThemePath, - path.join(__dirname, '../../node_modules'), - path.join(__dirname, '../../public/vendor/fontawesome/less'), - path.join(__dirname, '../../public/vendor/bootstrap/less') - ], - source = '@import "font-awesome";', - acpSource, - x; - - - plugins.lessFiles = filterMissingFiles(plugins.lessFiles); - for(x=0; x