|
|
@ -11,18 +11,47 @@ var path = require('path'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function sendMinifiedJS(req, res, next) {
|
|
|
|
function sendMinifiedJS(req, res, next) {
|
|
|
|
|
|
|
|
if (!minificationEnabled) {
|
|
|
|
|
|
|
|
res.set('X-SourceMap', '/nodebb.min.js.map');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return res.type('text/javascript').send(meta.js.cache);
|
|
|
|
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) {
|
|
|
|
function sendStylesheet(req, res, next) {
|
|
|
|
res.type('text/css').send(200, meta.css.cache);
|
|
|
|
res.type('text/css').send(200, meta.css.cache);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function(app, middleware, controllers) {
|
|
|
|
function setupPluginSourceMapping(app) {
|
|
|
|
minificationEnabled = app.enabled('minification');
|
|
|
|
/*
|
|
|
|
|
|
|
|
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('/stylesheet.css', sendStylesheet);
|
|
|
|
app.get('/nodebb.min.js', sendMinifiedJS);
|
|
|
|
app.get('/nodebb.min.js', sendMinifiedJS);
|
|
|
|
app.get('/sitemap.xml', controllers.sitemap);
|
|
|
|
app.get('/sitemap.xml', controllers.sitemap);
|
|
|
|
app.get('/robots.txt', controllers.robots);
|
|
|
|
app.get('/robots.txt', controllers.robots);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!minificationEnabled) {
|
|
|
|
|
|
|
|
app.get('/nodebb.min.js.map', sendSourceMap);
|
|
|
|
|
|
|
|
setupPluginSourceMapping(app);
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|