Merge remote-tracking branch 'origin/master' into v0.8.x

v1.18.x
barisusakli 10 years ago
commit 5d56e4f835

@ -11,7 +11,7 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
var term = data.term; var term = data.term;
// Detect if a tid was specified // Detect if a tid was specified
var topicSearch = term.match(/in:topic-([\d]+)/); var topicSearch = term.match(/^in:topic-([\d]+) /);
if (!topicSearch) { if (!topicSearch) {
term = term.replace(/^[ ?#]*/, ''); term = term.replace(/^[ ?#]*/, '');
@ -28,8 +28,10 @@ define('search', ['navigator', 'translator'], function(nav, translator) {
var cleanedTerm = term.replace(topicSearch[0], ''), var cleanedTerm = term.replace(topicSearch[0], ''),
tid = topicSearch[1]; tid = topicSearch[1];
if (cleanedTerm.length > 0) {
Search.queryTopic(tid, cleanedTerm, callback); Search.queryTopic(tid, cleanedTerm, callback);
} }
}
}; };
function createQueryString(data) { function createQueryString(data) {

@ -125,7 +125,7 @@
if (typeof language === 'function') { if (typeof language === 'function') {
callback = language; callback = language;
if ('undefined' !== typeof window && config) { if ('undefined' !== typeof window && config) {
language = config.userLang || 'en_GB'; language = utils.params().lang || config.userLang || 'en_GB';
} else { } else {
var meta = require('../../../src/meta'); var meta = require('../../../src/meta');
language = meta.config.defaultLang || 'en_GB'; language = meta.config.defaultLang || 'en_GB';

@ -156,7 +156,7 @@ var async = require('async'),
} }
category.name = validator.escape(category.name); 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'; category.icon = category.icon || 'hidden';
if (category.hasOwnProperty('post_count')) { if (category.hasOwnProperty('post_count')) {
category.post_count = category.totalPostCount = category.post_count || 0; 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.maximumFileSize = meta.config.maximumFileSize;
config['theme:id'] = meta.config['theme:id']; config['theme:id'] = meta.config['theme:id'];
config.defaultLang = meta.config.defaultLang || 'en_GB'; 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.environment = process.env.NODE_ENV;
config.loggedIn = !!req.user; config.loggedIn = !!req.user;
config['cache-buster'] = meta.config['cache-buster'] || ''; config['cache-buster'] = meta.config['cache-buster'] || '';
@ -89,7 +89,7 @@ apiController.getConfig = function(req, res, next) {
config.topicsPerPage = settings.topicsPerPage; config.topicsPerPage = settings.topicsPerPage;
config.postsPerPage = settings.postsPerPage; config.postsPerPage = settings.postsPerPage;
config.notificationSounds = settings.notificationSounds; config.notificationSounds = settings.notificationSounds;
config.userLang = settings.userLang || config.defaultLang; config.userLang = req.query.lang || settings.userLang || config.defaultLang;
config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab; config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab;
config.topicPostSort = settings.topicPostSort || config.topicPostSort; config.topicPostSort = settings.topicPostSort || config.topicPostSort;
config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort; config.categoryTopicSort = settings.categoryTopicSort || config.categoryTopicSort;

@ -30,11 +30,11 @@ unreadController.unread = function(req, res, next) {
}, },
function(_results, next) { function(_results, next) {
results = _results; 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) { function(categories, next) {
categories = categories.filter(function(category) { categories = categories.filter(function(category) {
return category && !category.link; return category && !category.link && !category.disabled;
}); });
categories.forEach(function(category) { categories.forEach(function(category) {
category.selected = parseInt(category.cid, 10) === parseInt(cid, 10); 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) { middleware.buildHeader = function(req, res, next) {
res.locals.renderHeader = true; res.locals.renderHeader = true;
res.locals.isAPI = false;
middleware.applyCSRF(req, res, function() { middleware.applyCSRF(req, res, function() {
async.parallel({ async.parallel({
@ -347,6 +348,7 @@ middleware.processRender = function(req, res, next) {
} }
str = template + str; str = template + str;
var language = res.locals.config ? res.locals.config.userLang || 'en_GB' : 'en_GB'; var language = res.locals.config ? res.locals.config.userLang || 'en_GB' : 'en_GB';
language = req.query.lang || language;
translator.translate(str, language, function(translated) { translator.translate(str, language, function(translated) {
fn(err, translated); fn(err, translated);
}); });

@ -72,6 +72,11 @@ module.exports = function(Posts) {
}); });
async.map(posts, function(post, next) { 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.user = results.users[post.uid];
post.topic = results.topics[post.tid]; post.topic = results.topics[post.tid];
post.category = results.categories[post.topic.cid]; post.category = results.categories[post.topic.cid];

@ -57,6 +57,11 @@ module.exports = function(Topics) {
var tidToPost = {}; var tidToPost = {};
async.each(postData, function(post, next) { 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.user = users[post.uid];
post.timestamp = utils.toISOString(post.timestamp); post.timestamp = utils.toISOString(post.timestamp);
tidToPost[post.tid] = post; tidToPost[post.tid] = post;

Loading…
Cancel
Save