From a64cbbc6dfb469c7e128a5f8737f3e0fe2a5cc5f Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 11 Sep 2015 16:18:32 -0400 Subject: [PATCH] #3573 --- app.js | 2 -- loader.js | 14 ++++---------- minifier.js | 14 ++------------ public/src/app.js | 17 ++++++----------- src/meta/css.js | 11 +---------- src/meta/js.js | 7 +------ src/socket.io/meta.js | 4 +--- 7 files changed, 15 insertions(+), 54 deletions(-) diff --git a/app.js b/app.js index 4c4f6854bb..292b599335 100644 --- a/app.js +++ b/app.js @@ -152,14 +152,12 @@ function start() { case 'js-propagate': meta.js.cache = message.cache; meta.js.map = message.map; - meta.js.hash = message.hash; emitter.emit('meta:js.compiled'); winston.verbose('[cluster] Client-side javascript and mapping propagated to worker %s', process.pid); break; case 'css-propagate': meta.css.cache = message.cache; meta.css.acpCache = message.acpCache; - meta.css.hash = message.hash; emitter.emit('meta:css.compiled'); winston.verbose('[cluster] Stylesheets propagated to worker %s', process.pid); break; diff --git a/loader.js b/loader.js index c79756f09e..96c78da4ee 100644 --- a/loader.js +++ b/loader.js @@ -90,8 +90,7 @@ Loader.addWorkerEvents = function(worker) { worker.send({ action: 'js-propagate', cache: Loader.js.cache, - map: Loader.js.map, - hash: Loader.js.hash + map: Loader.js.map }); } @@ -99,8 +98,7 @@ Loader.addWorkerEvents = function(worker) { worker.send({ action: 'css-propagate', cache: Loader.css.cache, - acpCache: Loader.css.acpCache, - hash: Loader.css.hash + acpCache: Loader.css.acpCache }); } @@ -117,25 +115,21 @@ Loader.addWorkerEvents = function(worker) { case 'js-propagate': Loader.js.cache = message.cache; Loader.js.map = message.map; - Loader.js.hash = message.hash; Loader.notifyWorkers({ action: 'js-propagate', cache: message.cache, - map: message.map, - hash: message.hash + map: message.map }, worker.pid); break; case 'css-propagate': Loader.css.cache = message.cache; Loader.css.acpCache = message.acpCache; - Loader.css.hash = message.hash; Loader.notifyWorkers({ action: 'css-propagate', cache: message.cache, - acpCache: message.acpCache, - hash: message.hash + acpCache: message.acpCache }, worker.pid); break; case 'templates:compiled': diff --git a/minifier.js b/minifier.js index 7289843b2f..621d61fa08 100644 --- a/minifier.js +++ b/minifier.js @@ -6,7 +6,7 @@ var uglifyjs = require('uglify-js'), fs = require('fs'), crypto = require('crypto'), utils = require('./public/src/utils'), - + Minifier = { js: {} }; @@ -47,17 +47,7 @@ function minifyScripts(scripts, callback) { var minified = uglifyjs.minify(scripts, { // outSourceMap: "nodebb.min.js.map", compress: false - }), - hasher = crypto.createHash('md5'), - hash; - - // Calculate js hash - hasher.update(minified.code, 'utf-8'); - hash = hasher.digest('hex'); - process.send({ - type: 'hash', - payload: hash.slice(0, 8) - }); + }); callback(minified.code/*, minified.map*/); } catch(err) { diff --git a/public/src/app.js b/public/src/app.js index a55dc9d2ab..5993ba9e69 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -146,19 +146,19 @@ app.cacheBuster = null; var modal = $(dialog.apply(this, arguments)[0]); translate(modal); return modal; - } + }; bootbox.prompt = function() { var modal = $(prompt.apply(this, arguments)[0]); translate(modal); return modal; - } + }; bootbox.confirm = function() { var modal = $(confirm.apply(this, arguments)[0]); translate(modal); return modal; - } + }; } function overrideTimeago() { @@ -563,14 +563,9 @@ app.cacheBuster = null; app.showEmailConfirmWarning(); socket.removeAllListeners('event:nodebb.ready'); - socket.on('event:nodebb.ready', function(cacheBusters) { - if ( - !app.cacheBusters || - app.cacheBusters.general !== cacheBusters.general || - app.cacheBusters.css !== cacheBusters.css || - app.cacheBusters.js !== cacheBusters.js - ) { - app.cacheBusters = cacheBusters; + socket.on('event:nodebb.ready', function(data) { + if (!app.cacheBusters || app.cacheBusters['cache-buster'] !== data['cache-buster']) { + app.cacheBusters = data; app.alert({ alert_id: 'forum_updated', diff --git a/src/meta/css.js b/src/meta/css.js index a93be08d09..f3257e624f 100644 --- a/src/meta/css.js +++ b/src/meta/css.js @@ -92,8 +92,7 @@ module.exports = function(Meta) { process.send({ action: 'css-propagate', cache: minified[0], - acpCache: minified[1], - hash: Meta.css.hash + acpCache: minified[1] }); } @@ -186,14 +185,6 @@ module.exports = function(Meta) { Meta.css[destination] = lessOutput.css; - if (destination === 'cache') { - // Calculate css buster - var hasher = crypto.createHash('md5'); - - hasher.update(lessOutput.css, 'utf-8'); - Meta.css.hash = hasher.digest('hex').slice(0, 8); - } - // Save the compiled CSS in public/ so things like nginx can serve it if (nconf.get('isPrimary') === 'true') { Meta.css.commitToFile(destination); diff --git a/src/meta/js.js b/src/meta/js.js index 21dc1c4cee..c703f5332e 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -18,7 +18,6 @@ module.exports = function(Meta) { Meta.js = { cache: '', map: '', - hash: +new Date(), scripts: { base: [ 'public/vendor/jquery/js/jquery.js', @@ -142,8 +141,7 @@ module.exports = function(Meta) { process.send({ action: 'js-propagate', cache: Meta.js.cache, - map: Meta.js.map, - hash: Meta.js.hash + map: Meta.js.map }); } @@ -161,9 +159,6 @@ module.exports = function(Meta) { Meta.js.map = message.sourceMap; onComplete(); break; - case 'hash': - Meta.js.hash = message.payload; - break; case 'error': winston.error('[meta/js] Could not compile client-side scripts! ' + message.payload.message); minifier.kill(); diff --git a/src/socket.io/meta.js b/src/socket.io/meta.js index 2b18044d33..abe8d461d0 100644 --- a/src/socket.io/meta.js +++ b/src/socket.io/meta.js @@ -29,9 +29,7 @@ SocketMeta.reconnected = function(socket, data, callback) { emitter.on('nodebb:ready', function() { websockets.server.sockets.emit('event:nodebb.ready', { - general: meta.config['cache-buster'], - css: meta.css.hash, - js: meta.js.hash + 'cache-buster': meta.config['cache-buster'] }); });