mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
This commit is contained in:
2
app.js
2
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;
|
||||
|
||||
14
loader.js
14
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':
|
||||
|
||||
10
minifier.js
10
minifier.js
@@ -47,16 +47,6 @@ 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*/);
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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']
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user