mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 20:11:26 +01:00
Merge remote-tracking branch 'origin/master' into v0.8.x
This commit is contained in:
@@ -11,7 +11,7 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
|
||||
var term = data.term;
|
||||
|
||||
// Detect if a tid was specified
|
||||
var topicSearch = term.match(/in:topic-([\d]+)/);
|
||||
var topicSearch = term.match(/^in:topic-([\d]+) /);
|
||||
|
||||
if (!topicSearch) {
|
||||
term = term.replace(/^[ ?#]*/, '');
|
||||
@@ -28,7 +28,9 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
|
||||
var cleanedTerm = term.replace(topicSearch[0], ''),
|
||||
tid = topicSearch[1];
|
||||
|
||||
Search.queryTopic(tid, cleanedTerm, callback);
|
||||
if (cleanedTerm.length > 0) {
|
||||
Search.queryTopic(tid, cleanedTerm, callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
if (typeof language === 'function') {
|
||||
callback = language;
|
||||
if ('undefined' !== typeof window && config) {
|
||||
language = config.userLang || 'en_GB';
|
||||
language = utils.params().lang || config.userLang || 'en_GB';
|
||||
} else {
|
||||
var meta = require('../../../src/meta');
|
||||
language = meta.config.defaultLang || 'en_GB';
|
||||
|
||||
@@ -156,7 +156,7 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
category.name = validator.escape(category.name);
|
||||
category.disabled = parseInt(category.disabled, 10) === 1;
|
||||
category.disabled = category.hasOwnProperty('disabled') ? parseInt(category.disabled, 10) === 1 : undefined;
|
||||
category.icon = category.icon || 'hidden';
|
||||
if (category.hasOwnProperty('post_count')) {
|
||||
category.post_count = category.totalPostCount = category.post_count || 0;
|
||||
|
||||
@@ -64,7 +64,7 @@ apiController.getConfig = function(req, res, next) {
|
||||
config.maximumFileSize = meta.config.maximumFileSize;
|
||||
config['theme:id'] = meta.config['theme:id'];
|
||||
config.defaultLang = meta.config.defaultLang || 'en_GB';
|
||||
config.userLang = config.defaultLang;
|
||||
config.userLang = req.query.lang || config.defaultLang;
|
||||
config.environment = process.env.NODE_ENV;
|
||||
config.loggedIn = !!req.user;
|
||||
config['cache-buster'] = meta.config['cache-buster'] || '';
|
||||
@@ -89,7 +89,7 @@ apiController.getConfig = function(req, res, next) {
|
||||
config.topicsPerPage = settings.topicsPerPage;
|
||||
config.postsPerPage = settings.postsPerPage;
|
||||
config.notificationSounds = settings.notificationSounds;
|
||||
config.userLang = settings.userLang || config.defaultLang;
|
||||
config.userLang = req.query.lang || settings.userLang || config.defaultLang;
|
||||
config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab;
|
||||
config.topicPostSort = settings.topicPostSort || config.topicPostSort;
|
||||
config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort;
|
||||
|
||||
@@ -30,11 +30,11 @@ unreadController.unread = function(req, res, next) {
|
||||
},
|
||||
function(_results, next) {
|
||||
results = _results;
|
||||
categories.getMultipleCategoryFields(results.watchedCategories, ['cid', 'name', 'slug', 'icon', 'link'], next);
|
||||
categories.getMultipleCategoryFields(results.watchedCategories, ['cid', 'name', 'slug', 'icon', 'link', 'disabled'], next);
|
||||
},
|
||||
function(categories, next) {
|
||||
categories = categories.filter(function(category) {
|
||||
return category && !category.link;
|
||||
return category && !category.link && !category.disabled;
|
||||
});
|
||||
categories.forEach(function(category) {
|
||||
category.selected = parseInt(category.cid, 10) === parseInt(cid, 10);
|
||||
|
||||
@@ -168,6 +168,7 @@ middleware.isAdmin = function(req, res, next) {
|
||||
|
||||
middleware.buildHeader = function(req, res, next) {
|
||||
res.locals.renderHeader = true;
|
||||
res.locals.isAPI = false;
|
||||
|
||||
middleware.applyCSRF(req, res, function() {
|
||||
async.parallel({
|
||||
@@ -347,6 +348,7 @@ middleware.processRender = function(req, res, next) {
|
||||
}
|
||||
str = template + str;
|
||||
var language = res.locals.config ? res.locals.config.userLang || 'en_GB' : 'en_GB';
|
||||
language = req.query.lang || language;
|
||||
translator.translate(str, language, function(translated) {
|
||||
fn(err, translated);
|
||||
});
|
||||
|
||||
@@ -72,6 +72,11 @@ module.exports = function(Posts) {
|
||||
});
|
||||
|
||||
async.map(posts, function(post, next) {
|
||||
// If the post author isn't represented in the retrieved users' data, then it means they were deleted, assume guest.
|
||||
if (!results.users.hasOwnProperty(post.uid)) {
|
||||
post.uid = 0;
|
||||
}
|
||||
|
||||
post.user = results.users[post.uid];
|
||||
post.topic = results.topics[post.tid];
|
||||
post.category = results.categories[post.topic.cid];
|
||||
|
||||
@@ -57,6 +57,11 @@ module.exports = function(Topics) {
|
||||
var tidToPost = {};
|
||||
|
||||
async.each(postData, function(post, next) {
|
||||
// If the post author isn't represented in the retrieved users' data, then it means they were deleted, assume guest.
|
||||
if (!users.hasOwnProperty(post.uid)) {
|
||||
post.uid = 0;
|
||||
}
|
||||
|
||||
post.user = users[post.uid];
|
||||
post.timestamp = utils.toISOString(post.timestamp);
|
||||
tidToPost[post.tid] = post;
|
||||
|
||||
Reference in New Issue
Block a user