v1.18.x
Julian Lam 9 years ago
parent 49f0aca7f6
commit 55bcc28e0e

@ -196,7 +196,7 @@ module.exports = function(Meta) {
Meta.css[destination] = result.css;
// 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() {
if (typeof callback === 'function') {
callback(null, result.css);

@ -154,6 +154,12 @@ module.exports = function(Meta) {
winston.verbose('[meta/js] ' + target + ' minification complete');
minifier.kill();
function done() {
if (typeof callback === 'function') {
callback();
}
}
if (process.send && Meta.js.target['nodebb.min.js'] && Meta.js.target['acp.min.js']) {
process.send({
action: 'js-propagate',
@ -161,11 +167,12 @@ module.exports = function(Meta) {
});
}
Meta.js.commitToFile(target, function() {
if (typeof callback === 'function') {
callback();
if (nconf.get('local-assets') === undefined || nconf.get('local-assets') !== false) {
return Meta.js.commitToFile(target, done);
} else {
emitter.emit('meta:js.compiled');
return done();
}
});
break;
case 'error':

@ -83,7 +83,9 @@ module.exports = function(Meta) {
fs.readdir(path.join(__dirname, '../../public/uploads/sounds'), 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);
});
@ -93,6 +95,21 @@ module.exports = function(Meta) {
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
async.series([
function(next) {
@ -121,8 +138,8 @@ module.exports = function(Meta) {
winston.error('[sounds] Could not initialise sounds: ' + err.message);
}
if (typeof callback === 'function') {
callback();
if (typeof next === 'function') {
next();
}
});
});

@ -1,6 +1,7 @@
"use strict";
var path = require('path');
var nconf = require('nconf');
var meta = require('../meta');
@ -29,6 +30,16 @@ function sendACPStylesheet(req, res) {
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) {
app.get('/stylesheet.css', middleware.addExpiresHeaders, sendStylesheet);
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('/manifest.json', controllers.manifest);
app.get('/css/previews/:theme', controllers.admin.themes.get);
if (nconf.get('local-assets') === false) {
app.get('/sounds/*', middleware.addExpiresHeaders, sendSoundFile);
}
};

Loading…
Cancel
Save