mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 02:25:55 +01:00
closes #4831
This commit is contained in:
@@ -196,7 +196,7 @@ module.exports = function(Meta) {
|
|||||||
Meta.css[destination] = result.css;
|
Meta.css[destination] = result.css;
|
||||||
|
|
||||||
// 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' && (nconf.get('local-assets') === undefined || nconf.get('local-assets') !== false)) {
|
||||||
return Meta.css.commitToFile(destination, function() {
|
return Meta.css.commitToFile(destination, function() {
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(null, result.css);
|
callback(null, result.css);
|
||||||
|
|||||||
@@ -154,6 +154,12 @@ module.exports = function(Meta) {
|
|||||||
winston.verbose('[meta/js] ' + target + ' minification complete');
|
winston.verbose('[meta/js] ' + target + ' minification complete');
|
||||||
minifier.kill();
|
minifier.kill();
|
||||||
|
|
||||||
|
function done() {
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (process.send && Meta.js.target['nodebb.min.js'] && Meta.js.target['acp.min.js']) {
|
if (process.send && Meta.js.target['nodebb.min.js'] && Meta.js.target['acp.min.js']) {
|
||||||
process.send({
|
process.send({
|
||||||
action: 'js-propagate',
|
action: 'js-propagate',
|
||||||
@@ -161,11 +167,12 @@ module.exports = function(Meta) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Meta.js.commitToFile(target, function() {
|
if (nconf.get('local-assets') === undefined || nconf.get('local-assets') !== false) {
|
||||||
if (typeof callback === 'function') {
|
return Meta.js.commitToFile(target, done);
|
||||||
callback();
|
} else {
|
||||||
}
|
emitter.emit('meta:js.compiled');
|
||||||
});
|
return done();
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'error':
|
case 'error':
|
||||||
|
|||||||
@@ -83,7 +83,9 @@ module.exports = function(Meta) {
|
|||||||
fs.readdir(path.join(__dirname, '../../public/uploads/sounds'), next);
|
fs.readdir(path.join(__dirname, '../../public/uploads/sounds'), next);
|
||||||
},
|
},
|
||||||
function(uploaded, next) {
|
function(uploaded, next) {
|
||||||
uploaded = uploaded.map(function(filename) {
|
uploaded = uploaded.filter(function(filename) {
|
||||||
|
return !filename.startsWith('.');
|
||||||
|
}).map(function(filename) {
|
||||||
return path.join(__dirname, '../../public/uploads/sounds', filename);
|
return path.join(__dirname, '../../public/uploads/sounds', filename);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -93,6 +95,21 @@ module.exports = function(Meta) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nconf.get('local-assets') === false) {
|
||||||
|
// Don't regenerate the public/sounds/ directory. Instead, create a mapping for the router to use
|
||||||
|
Meta.sounds._filePathHash = filePaths.reduce(function(hash, filePath) {
|
||||||
|
hash[path.basename(filePath)] = filePath;
|
||||||
|
return hash;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
winston.verbose('[sounds] Sounds OK');
|
||||||
|
if (typeof next === 'function') {
|
||||||
|
return next();
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Clear the sounds directory
|
// Clear the sounds directory
|
||||||
async.series([
|
async.series([
|
||||||
function(next) {
|
function(next) {
|
||||||
@@ -121,8 +138,8 @@ module.exports = function(Meta) {
|
|||||||
winston.error('[sounds] Could not initialise sounds: ' + err.message);
|
winston.error('[sounds] Could not initialise sounds: ' + err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof callback === 'function') {
|
if (typeof next === 'function') {
|
||||||
callback();
|
next();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var nconf = require('nconf');
|
||||||
|
|
||||||
var meta = require('../meta');
|
var meta = require('../meta');
|
||||||
|
|
||||||
@@ -29,6 +30,16 @@ function sendACPStylesheet(req, res) {
|
|||||||
res.type('text/css').status(200).send(meta.css.acpCache);
|
res.type('text/css').status(200).send(meta.css.acpCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sendSoundFile(req, res, next) {
|
||||||
|
var resolved = meta.sounds._filePathHash[path.basename(req.path)];
|
||||||
|
|
||||||
|
if (resolved) {
|
||||||
|
res.status(200).sendFile(resolved);
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = function(app, middleware, controllers) {
|
module.exports = function(app, middleware, controllers) {
|
||||||
app.get('/stylesheet.css', middleware.addExpiresHeaders, sendStylesheet);
|
app.get('/stylesheet.css', middleware.addExpiresHeaders, sendStylesheet);
|
||||||
app.get('/admin.css', middleware.addExpiresHeaders, sendACPStylesheet);
|
app.get('/admin.css', middleware.addExpiresHeaders, sendACPStylesheet);
|
||||||
@@ -42,4 +53,8 @@ module.exports = function(app, middleware, controllers) {
|
|||||||
app.get('/robots.txt', controllers.robots);
|
app.get('/robots.txt', controllers.robots);
|
||||||
app.get('/manifest.json', controllers.manifest);
|
app.get('/manifest.json', controllers.manifest);
|
||||||
app.get('/css/previews/:theme', controllers.admin.themes.get);
|
app.get('/css/previews/:theme', controllers.admin.themes.get);
|
||||||
|
|
||||||
|
if (nconf.get('local-assets') === false) {
|
||||||
|
app.get('/sounds/*', middleware.addExpiresHeaders, sendSoundFile);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user