mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-17 14:00:29 +01:00
Compare commits
10 Commits
normalize-
...
v1.11.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c02e812967 | ||
|
|
c1042ee471 | ||
|
|
53c13976b6 | ||
|
|
1cdb6af5dc | ||
|
|
b0a44d866b | ||
|
|
77b767331b | ||
|
|
ab5035f4e2 | ||
|
|
2555d72c84 | ||
|
|
213582df8b | ||
|
|
543336070a |
@@ -2,7 +2,7 @@
|
|||||||
"name": "nodebb",
|
"name": "nodebb",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"description": "NodeBB Forum",
|
"description": "NodeBB Forum",
|
||||||
"version": "1.11.0",
|
"version": "1.11.1",
|
||||||
"homepage": "http://www.nodebb.org",
|
"homepage": "http://www.nodebb.org",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
@echo off && cd %~dp0 && node ./src/cli %*
|
@echo off && cd %~dp0 && node ./nodebb %*
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ define('topicList', [
|
|||||||
count: config.topicsPerPage,
|
count: config.topicsPerPage,
|
||||||
cid: query.cid,
|
cid: query.cid,
|
||||||
query: query,
|
query: query,
|
||||||
term: ajaxify.data.selectedTerm.term,
|
term: ajaxify.data.selectedTerm && ajaxify.data.selectedTerm.term,
|
||||||
filter: ajaxify.data.selectedFilter.filter,
|
filter: ajaxify.data.selectedFilter.filter,
|
||||||
set: topicListEl.attr('data-set') ? topicListEl.attr('data-set') : 'topics:recent',
|
set: topicListEl.attr('data-set') ? topicListEl.attr('data-set') : 'topics:recent',
|
||||||
}, callback);
|
}, callback);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
var async = require('async');
|
var async = require('async');
|
||||||
var nconf = require('nconf');
|
var nconf = require('nconf');
|
||||||
var jsesc = require('jsesc');
|
var jsesc = require('jsesc');
|
||||||
@@ -13,7 +14,9 @@ var plugins = require('../plugins');
|
|||||||
var navigation = require('../navigation');
|
var navigation = require('../navigation');
|
||||||
var translator = require('../translator');
|
var translator = require('../translator');
|
||||||
var privileges = require('../privileges');
|
var privileges = require('../privileges');
|
||||||
|
var languages = require('../languages');
|
||||||
var utils = require('../utils');
|
var utils = require('../utils');
|
||||||
|
var file = require('../file');
|
||||||
|
|
||||||
var controllers = {
|
var controllers = {
|
||||||
api: require('../controllers/api'),
|
api: require('../controllers/api'),
|
||||||
@@ -208,11 +211,6 @@ module.exports = function (middleware) {
|
|||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
function addTimeagoLocaleScript(scripts, userLang) {
|
|
||||||
var languageCode = utils.userLangToTimeagoCode(userLang);
|
|
||||||
scripts.push({ src: nconf.get('relative_path') + '/assets/vendor/jquery/timeago/locales/jquery.timeago.' + languageCode + '.js' });
|
|
||||||
}
|
|
||||||
|
|
||||||
middleware.renderFooter = function (req, res, data, callback) {
|
middleware.renderFooter = function (req, res, data, callback) {
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
@@ -225,15 +223,35 @@ module.exports = function (middleware) {
|
|||||||
function (data, next) {
|
function (data, next) {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
scripts: async.apply(plugins.fireHook, 'filter:scripts.get', []),
|
scripts: async.apply(plugins.fireHook, 'filter:scripts.get', []),
|
||||||
|
timeagoLocale: (next) => {
|
||||||
|
const userLang = res.locals.config.userLang;
|
||||||
|
const pathToLocaleFile = '/vendor/jquery/timeago/locales/jquery.timeago.' + utils.userLangToTimeagoCode(userLang) + '.js';
|
||||||
|
|
||||||
|
async.waterfall([
|
||||||
|
async.apply(languages.list),
|
||||||
|
(languages, next) => {
|
||||||
|
if (!languages.some(obj => obj.code === userLang)) {
|
||||||
|
return next(null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
file.exists(path.join(__dirname, '../../public', pathToLocaleFile), next);
|
||||||
|
},
|
||||||
|
(exists, next) => {
|
||||||
|
next(null, exists ? (nconf.get('relative_path') + '/assets' + pathToLocaleFile) : null);
|
||||||
|
},
|
||||||
|
], next);
|
||||||
|
},
|
||||||
}, function (err, results) {
|
}, function (err, results) {
|
||||||
next(err, data, results);
|
next(err, data, results);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function (data, results, next) {
|
function (data, results, next) {
|
||||||
|
if (results.timeagoLocale) {
|
||||||
|
results.scripts.push(results.timeagoLocale);
|
||||||
|
}
|
||||||
data.templateValues.scripts = results.scripts.map(function (script) {
|
data.templateValues.scripts = results.scripts.map(function (script) {
|
||||||
return { src: script };
|
return { src: script };
|
||||||
});
|
});
|
||||||
addTimeagoLocaleScript(data.templateValues.scripts, res.locals.config.userLang);
|
|
||||||
|
|
||||||
data.templateValues.useCustomJS = meta.config.useCustomJS;
|
data.templateValues.useCustomJS = meta.config.useCustomJS;
|
||||||
data.templateValues.customJS = data.templateValues.useCustomJS ? meta.config.customJS : '';
|
data.templateValues.customJS = data.templateValues.useCustomJS ? meta.config.customJS : '';
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ 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');
|
||||||
|
|
||||||
@@ -174,29 +173,6 @@ middleware.applyBlacklist = function (req, res, next) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
middleware.processTimeagoLocales = function (req, res, next) {
|
|
||||||
var fallback = !req.path.includes('-short') ? 'jquery.timeago.en.js' : 'jquery.timeago.en-short.js';
|
|
||||||
var localPath = path.join(__dirname, '../../public/vendor/jquery/timeago/locales', req.path);
|
|
||||||
|
|
||||||
async.waterfall([
|
|
||||||
function (next) {
|
|
||||||
file.exists(localPath, next);
|
|
||||||
},
|
|
||||||
function (exists, next) {
|
|
||||||
if (exists) {
|
|
||||||
next(null, localPath);
|
|
||||||
} else {
|
|
||||||
next(null, path.join(__dirname, '../../public/vendor/jquery/timeago/locales', fallback));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function (path) {
|
|
||||||
res.status(200).sendFile(path, {
|
|
||||||
maxAge: req.app.enabled('cache') ? 5184000000 : 0,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
], next);
|
|
||||||
};
|
|
||||||
|
|
||||||
middleware.delayLoading = function (req, res, next) {
|
middleware.delayLoading = function (req, res, next) {
|
||||||
// Introduces an artificial delay during load so that brute force attacks are effectively mitigated
|
// Introduces an artificial delay during load so that brute force attacks are effectively mitigated
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,6 @@ function addCoreRoutes(app, router, middleware, callback) {
|
|||||||
res.redirect(relativePath + '/assets/client.css?' + meta.config['cache-buster']);
|
res.redirect(relativePath + '/assets/client.css?' + meta.config['cache-buster']);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use(relativePath + '/assets/vendor/jquery/timeago/locales', middleware.processTimeagoLocales);
|
|
||||||
app.use(controllers['404'].handle404);
|
app.use(controllers['404'].handle404);
|
||||||
app.use(controllers.errors.handleURIErrors);
|
app.use(controllers.errors.handleURIErrors);
|
||||||
app.use(controllers.errors.handleErrors);
|
app.use(controllers.errors.handleErrors);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ module.exports = function (Topics) {
|
|||||||
if (!topicData.length) {
|
if (!topicData.length) {
|
||||||
return next(null, unreadTopics);
|
return next(null, unreadTopics);
|
||||||
}
|
}
|
||||||
|
Topics.calculateTopicIndices(topicData, params.start);
|
||||||
unreadTopics.topics = topicData;
|
unreadTopics.topics = topicData;
|
||||||
unreadTopics.nextStart = params.stop + 1;
|
unreadTopics.nextStart = params.stop + 1;
|
||||||
next(null, unreadTopics);
|
next(null, unreadTopics);
|
||||||
|
|||||||
@@ -1778,11 +1778,18 @@ describe('Controllers', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load timeago locale', function (done) {
|
it('should return not found if NodeBB language exists but timeago locale does not exist', function (done) {
|
||||||
request(nconf.get('url') + '/assets/vendor/jquery/timeago/locales/jquery.timeago.404.js', function (err, res, body) {
|
request(nconf.get('url') + '/assets/vendor/jquery/timeago/locales/jquery.timeago.ms.js', function (err, res, body) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
assert.equal(res.statusCode, 200);
|
assert.equal(res.statusCode, 404);
|
||||||
assert(body.includes('English'));
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return not found if NodeBB language does not exist', function (done) {
|
||||||
|
request(nconf.get('url') + '/assets/vendor/jquery/timeago/locales/jquery.timeago.muggle.js', function (err, res, body) {
|
||||||
|
assert.ifError(err);
|
||||||
|
assert.equal(res.statusCode, 404);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user