|
|
@ -1,7 +1,6 @@
|
|
|
|
'use strict';
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
var async = require('async');
|
|
|
|
var async = require('async');
|
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
var path = require('path');
|
|
|
|
var path = require('path');
|
|
|
|
var csrf = require('csurf');
|
|
|
|
var csrf = require('csurf');
|
|
|
|
var validator = require('validator');
|
|
|
|
var validator = require('validator');
|
|
|
@ -13,6 +12,7 @@ var plugins = require('../plugins');
|
|
|
|
var meta = require('../meta');
|
|
|
|
var meta = require('../meta');
|
|
|
|
var user = require('../user');
|
|
|
|
var user = require('../user');
|
|
|
|
var groups = require('../groups');
|
|
|
|
var groups = require('../groups');
|
|
|
|
|
|
|
|
var file = require('../file');
|
|
|
|
|
|
|
|
|
|
|
|
var analytics = require('../analytics');
|
|
|
|
var analytics = require('../analytics');
|
|
|
|
|
|
|
|
|
|
|
@ -143,24 +143,25 @@ middleware.applyBlacklist = function (req, res, next) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
middleware.processTimeagoLocales = function (req, res) {
|
|
|
|
middleware.processTimeagoLocales = function (req, res, next) {
|
|
|
|
var fallback = req.path.indexOf('-short') === -1 ? 'jquery.timeago.en.js' : 'jquery.timeago.en-short.js';
|
|
|
|
var fallback = req.path.indexOf('-short') === -1 ? 'jquery.timeago.en.js' : 'jquery.timeago.en-short.js';
|
|
|
|
var localPath = path.join(__dirname, '../../public/vendor/jquery/timeago/locales', req.path);
|
|
|
|
var localPath = path.join(__dirname, '../../public/vendor/jquery/timeago/locales', req.path);
|
|
|
|
var exists;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
async.waterfall([
|
|
|
|
exists = fs.accessSync(localPath, fs.F_OK | fs.R_OK);
|
|
|
|
function (next) {
|
|
|
|
} catch (e) {
|
|
|
|
file.exists(localPath, next);
|
|
|
|
exists = false;
|
|
|
|
},
|
|
|
|
}
|
|
|
|
function (exists, next) {
|
|
|
|
|
|
|
|
if (exists) {
|
|
|
|
if (exists) {
|
|
|
|
next(null, localPath);
|
|
|
|
res.status(200).sendFile(localPath, {
|
|
|
|
} else {
|
|
|
|
maxAge: req.app.enabled('cache') ? 5184000000 : 0,
|
|
|
|
next(null, path.join(__dirname, '../../public/vendor/jquery/timeago/locales', fallback));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
},
|
|
|
|
res.status(200).sendFile(path.join(__dirname, '../../public/vendor/jquery/timeago/locales', fallback), {
|
|
|
|
function (path) {
|
|
|
|
maxAge: req.app.enabled('cache') ? 5184000000 : 0,
|
|
|
|
res.status(200).sendFile(path, {
|
|
|
|
});
|
|
|
|
maxAge: req.app.enabled('cache') ? 5184000000 : 0,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
], next);
|
|
|
|
};
|
|
|
|
};
|
|
|
|