mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
This commit is contained in:
2
app.js
2
app.js
@@ -152,14 +152,12 @@ function start() {
|
|||||||
case 'js-propagate':
|
case 'js-propagate':
|
||||||
meta.js.cache = message.cache;
|
meta.js.cache = message.cache;
|
||||||
meta.js.map = message.map;
|
meta.js.map = message.map;
|
||||||
meta.js.hash = message.hash;
|
|
||||||
emitter.emit('meta:js.compiled');
|
emitter.emit('meta:js.compiled');
|
||||||
winston.verbose('[cluster] Client-side javascript and mapping propagated to worker %s', process.pid);
|
winston.verbose('[cluster] Client-side javascript and mapping propagated to worker %s', process.pid);
|
||||||
break;
|
break;
|
||||||
case 'css-propagate':
|
case 'css-propagate':
|
||||||
meta.css.cache = message.cache;
|
meta.css.cache = message.cache;
|
||||||
meta.css.acpCache = message.acpCache;
|
meta.css.acpCache = message.acpCache;
|
||||||
meta.css.hash = message.hash;
|
|
||||||
emitter.emit('meta:css.compiled');
|
emitter.emit('meta:css.compiled');
|
||||||
winston.verbose('[cluster] Stylesheets propagated to worker %s', process.pid);
|
winston.verbose('[cluster] Stylesheets propagated to worker %s', process.pid);
|
||||||
break;
|
break;
|
||||||
|
|||||||
14
loader.js
14
loader.js
@@ -90,8 +90,7 @@ Loader.addWorkerEvents = function(worker) {
|
|||||||
worker.send({
|
worker.send({
|
||||||
action: 'js-propagate',
|
action: 'js-propagate',
|
||||||
cache: Loader.js.cache,
|
cache: Loader.js.cache,
|
||||||
map: Loader.js.map,
|
map: Loader.js.map
|
||||||
hash: Loader.js.hash
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,8 +98,7 @@ Loader.addWorkerEvents = function(worker) {
|
|||||||
worker.send({
|
worker.send({
|
||||||
action: 'css-propagate',
|
action: 'css-propagate',
|
||||||
cache: Loader.css.cache,
|
cache: Loader.css.cache,
|
||||||
acpCache: Loader.css.acpCache,
|
acpCache: Loader.css.acpCache
|
||||||
hash: Loader.css.hash
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,25 +115,21 @@ Loader.addWorkerEvents = function(worker) {
|
|||||||
case 'js-propagate':
|
case 'js-propagate':
|
||||||
Loader.js.cache = message.cache;
|
Loader.js.cache = message.cache;
|
||||||
Loader.js.map = message.map;
|
Loader.js.map = message.map;
|
||||||
Loader.js.hash = message.hash;
|
|
||||||
|
|
||||||
Loader.notifyWorkers({
|
Loader.notifyWorkers({
|
||||||
action: 'js-propagate',
|
action: 'js-propagate',
|
||||||
cache: message.cache,
|
cache: message.cache,
|
||||||
map: message.map,
|
map: message.map
|
||||||
hash: message.hash
|
|
||||||
}, worker.pid);
|
}, worker.pid);
|
||||||
break;
|
break;
|
||||||
case 'css-propagate':
|
case 'css-propagate':
|
||||||
Loader.css.cache = message.cache;
|
Loader.css.cache = message.cache;
|
||||||
Loader.css.acpCache = message.acpCache;
|
Loader.css.acpCache = message.acpCache;
|
||||||
Loader.css.hash = message.hash;
|
|
||||||
|
|
||||||
Loader.notifyWorkers({
|
Loader.notifyWorkers({
|
||||||
action: 'css-propagate',
|
action: 'css-propagate',
|
||||||
cache: message.cache,
|
cache: message.cache,
|
||||||
acpCache: message.acpCache,
|
acpCache: message.acpCache
|
||||||
hash: message.hash
|
|
||||||
}, worker.pid);
|
}, worker.pid);
|
||||||
break;
|
break;
|
||||||
case 'templates:compiled':
|
case 'templates:compiled':
|
||||||
|
|||||||
12
minifier.js
12
minifier.js
@@ -47,17 +47,7 @@ function minifyScripts(scripts, callback) {
|
|||||||
var minified = uglifyjs.minify(scripts, {
|
var minified = uglifyjs.minify(scripts, {
|
||||||
// outSourceMap: "nodebb.min.js.map",
|
// outSourceMap: "nodebb.min.js.map",
|
||||||
compress: false
|
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*/);
|
callback(minified.code/*, minified.map*/);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
|||||||
@@ -146,19 +146,19 @@ app.cacheBuster = null;
|
|||||||
var modal = $(dialog.apply(this, arguments)[0]);
|
var modal = $(dialog.apply(this, arguments)[0]);
|
||||||
translate(modal);
|
translate(modal);
|
||||||
return modal;
|
return modal;
|
||||||
}
|
};
|
||||||
|
|
||||||
bootbox.prompt = function() {
|
bootbox.prompt = function() {
|
||||||
var modal = $(prompt.apply(this, arguments)[0]);
|
var modal = $(prompt.apply(this, arguments)[0]);
|
||||||
translate(modal);
|
translate(modal);
|
||||||
return modal;
|
return modal;
|
||||||
}
|
};
|
||||||
|
|
||||||
bootbox.confirm = function() {
|
bootbox.confirm = function() {
|
||||||
var modal = $(confirm.apply(this, arguments)[0]);
|
var modal = $(confirm.apply(this, arguments)[0]);
|
||||||
translate(modal);
|
translate(modal);
|
||||||
return modal;
|
return modal;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function overrideTimeago() {
|
function overrideTimeago() {
|
||||||
@@ -563,14 +563,9 @@ app.cacheBuster = null;
|
|||||||
app.showEmailConfirmWarning();
|
app.showEmailConfirmWarning();
|
||||||
|
|
||||||
socket.removeAllListeners('event:nodebb.ready');
|
socket.removeAllListeners('event:nodebb.ready');
|
||||||
socket.on('event:nodebb.ready', function(cacheBusters) {
|
socket.on('event:nodebb.ready', function(data) {
|
||||||
if (
|
if (!app.cacheBusters || app.cacheBusters['cache-buster'] !== data['cache-buster']) {
|
||||||
!app.cacheBusters ||
|
app.cacheBusters = data;
|
||||||
app.cacheBusters.general !== cacheBusters.general ||
|
|
||||||
app.cacheBusters.css !== cacheBusters.css ||
|
|
||||||
app.cacheBusters.js !== cacheBusters.js
|
|
||||||
) {
|
|
||||||
app.cacheBusters = cacheBusters;
|
|
||||||
|
|
||||||
app.alert({
|
app.alert({
|
||||||
alert_id: 'forum_updated',
|
alert_id: 'forum_updated',
|
||||||
|
|||||||
@@ -92,8 +92,7 @@ module.exports = function(Meta) {
|
|||||||
process.send({
|
process.send({
|
||||||
action: 'css-propagate',
|
action: 'css-propagate',
|
||||||
cache: minified[0],
|
cache: minified[0],
|
||||||
acpCache: minified[1],
|
acpCache: minified[1]
|
||||||
hash: Meta.css.hash
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,14 +185,6 @@ module.exports = function(Meta) {
|
|||||||
|
|
||||||
Meta.css[destination] = lessOutput.css;
|
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
|
// Save the compiled CSS in public/ so things like nginx can serve it
|
||||||
if (nconf.get('isPrimary') === 'true') {
|
if (nconf.get('isPrimary') === 'true') {
|
||||||
Meta.css.commitToFile(destination);
|
Meta.css.commitToFile(destination);
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ module.exports = function(Meta) {
|
|||||||
Meta.js = {
|
Meta.js = {
|
||||||
cache: '',
|
cache: '',
|
||||||
map: '',
|
map: '',
|
||||||
hash: +new Date(),
|
|
||||||
scripts: {
|
scripts: {
|
||||||
base: [
|
base: [
|
||||||
'public/vendor/jquery/js/jquery.js',
|
'public/vendor/jquery/js/jquery.js',
|
||||||
@@ -142,8 +141,7 @@ module.exports = function(Meta) {
|
|||||||
process.send({
|
process.send({
|
||||||
action: 'js-propagate',
|
action: 'js-propagate',
|
||||||
cache: Meta.js.cache,
|
cache: Meta.js.cache,
|
||||||
map: Meta.js.map,
|
map: Meta.js.map
|
||||||
hash: Meta.js.hash
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,9 +159,6 @@ module.exports = function(Meta) {
|
|||||||
Meta.js.map = message.sourceMap;
|
Meta.js.map = message.sourceMap;
|
||||||
onComplete();
|
onComplete();
|
||||||
break;
|
break;
|
||||||
case 'hash':
|
|
||||||
Meta.js.hash = message.payload;
|
|
||||||
break;
|
|
||||||
case 'error':
|
case 'error':
|
||||||
winston.error('[meta/js] Could not compile client-side scripts! ' + message.payload.message);
|
winston.error('[meta/js] Could not compile client-side scripts! ' + message.payload.message);
|
||||||
minifier.kill();
|
minifier.kill();
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ SocketMeta.reconnected = function(socket, data, callback) {
|
|||||||
|
|
||||||
emitter.on('nodebb:ready', function() {
|
emitter.on('nodebb:ready', function() {
|
||||||
websockets.server.sockets.emit('event:nodebb.ready', {
|
websockets.server.sockets.emit('event:nodebb.ready', {
|
||||||
general: meta.config['cache-buster'],
|
'cache-buster': meta.config['cache-buster']
|
||||||
css: meta.css.hash,
|
|
||||||
js: meta.js.hash
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user