Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Julian Lam
2018-02-23 14:48:38 -05:00
453 changed files with 1073 additions and 513 deletions

View File

@@ -1,5 +1,7 @@
'use strict';
var os = require('os');
var meta = require('../meta');
module.exports = function (middleware) {
@@ -15,6 +17,10 @@ module.exports = function (middleware) {
headers['Access-Control-Allow-Origin'] = encodeURI(meta.config['access-control-allow-origin']);
}
if (process.env.NODE_ENV === 'development') {
headers['X-Upstream-Hostname'] = os.hostname();
}
for (var key in headers) {
if (headers.hasOwnProperty(key) && headers[key]) {
res.setHeader(key, headers[key]);

View File

@@ -211,7 +211,7 @@ middleware.templatesOnDemand = function (req, res, next) {
if (!filePath.endsWith('.js')) {
return next();
}
var tplPath = filePath.replace(/\.js$/, '.tpl');
if (workingCache[filePath]) {
workingCache[filePath].push(next);
return;
@@ -234,12 +234,9 @@ middleware.templatesOnDemand = function (req, res, next) {
}
workingCache[filePath] = [next];
fs.readFile(filePath.replace(/\.js$/, '.tpl'), 'utf8', cb);
fs.readFile(tplPath, 'utf8', cb);
},
function (source, cb) {
if (!source) {
return cb(new Error('[[error:templatesOnDemand.source-template-empty]]'));
}
Benchpress.precompile({
source: source,
minify: global.env !== 'development',
@@ -247,7 +244,7 @@ middleware.templatesOnDemand = function (req, res, next) {
},
function (compiled, cb) {
if (!compiled) {
return cb(new Error('[[error:templatesOnDemand.compiled-template-empty]]'));
return cb(new Error('[[error:templatesOnDemand.compiled-template-empty, ' + tplPath + ']]'));
}
fs.writeFile(filePath, compiled, cb);
},