Merge remote-tracking branch 'origin/master' into require.js

Conflicts:
	src/meta.js
This commit is contained in:
psychobunny
2014-05-30 15:18:17 -04:00
6 changed files with 81 additions and 33 deletions

View File

@@ -323,7 +323,8 @@ var fs = require('fs'),
minifier.on('message', function(payload) {
if (payload.action !== 'error') {
winston.info('[meta/js] Compilation complete');
Meta.js.cache = payload.data;
Meta.js.cache = payload.data.js;
Meta.js.map = payload.data.map;
minifier.kill();
} else {
winston.error('[meta/js] Could not compile client-side scripts!');
@@ -336,7 +337,8 @@ var fs = require('fs'),
Meta.js.loadRJS(function() {
Meta.js.prepare(function() {
minifier.send({
action: minify ? 'js.minify' : 'js.concatenate',
action: 'js',
minify: minify,
scripts: Meta.js.scripts
});
});

View File

@@ -11,18 +11,47 @@ var path = require('path'),
function sendMinifiedJS(req, res, next) {
if (!minificationEnabled) {
res.set('X-SourceMap', '/nodebb.min.js.map');
}
return res.type('text/javascript').send(meta.js.cache);
}
function sendSourceMap(req, res) {
return res.type('application/json').send(meta.js.map);
}
function sendStylesheet(req, res, next) {
res.type('text/css').send(200, meta.css.cache);
}
module.exports = function(app, middleware, controllers) {
minificationEnabled = app.enabled('minification');
function setupPluginSourceMapping(app) {
/*
These mappings are utilised by the source map file, as client-side
scripts defined in `scripts` in plugin.json are not normally
served to the end-user. These mappings are only accessible via
development mode (`./nodebb dev`)
*/
var routes = plugins.clientScripts,
mapping;
routes.forEach(function(route) {
mapping = '/' + route.split('/').slice(7).join('/');
app.get(mapping, function(req, res) {
res.type('text/javascript').sendfile(route);
});
});
}
module.exports = function(app, middleware, controllers) {
app.get('/stylesheet.css', sendStylesheet);
app.get('/nodebb.min.js', sendMinifiedJS);
app.get('/sitemap.xml', controllers.sitemap);
app.get('/robots.txt', controllers.robots);
if (!minificationEnabled) {
app.get('/nodebb.min.js.map', sendSourceMap);
setupPluginSourceMapping(app);
}
};