Merge branch '0.5.1' into csrf-excision

This commit is contained in:
Julian Lam
2014-09-17 14:39:51 -04:00
282 changed files with 2219 additions and 473 deletions

View File

@@ -366,7 +366,7 @@ var db = require('./database'),
if (categories[i]) {
categories[i]['unread-class'] = (parseInt(categories[i].topic_count, 10) === 0 || (hasRead[i] && uid !== 0)) ? '' : 'unread';
categories[i].children = results.children[i];
categories[i].parent = results.parents[i];
categories[i].parent = results.parents[i] && !results.parents[i].disabled ? results.parents[i] : null;
}
}
@@ -402,9 +402,10 @@ var db = require('./database'),
Categories.getCategoriesData(cids, next);
},
function (categories, next) {
// Filter categories to isolate children, and remove disabled categories
async.map(cids, function(cid, next) {
next(null, categories.filter(function(category) {
return parseInt(category.parentCid, 10) === parseInt(cid, 10);
return parseInt(category.parentCid, 10) === parseInt(cid, 10) && !category.disabled;
}));
}, next);
}

View File

@@ -13,7 +13,6 @@ module.exports = function(Categories) {
function updateCategory(cid, next) {
var category = modified[cid];
var fields = Object.keys(category);
console.log('updating', cid, 'fields:', fields);
async.each(fields, function(key, next) {
updateCategoryField(cid, key, category[key], next);

View File

@@ -69,6 +69,11 @@ Controllers.home = function(req, res, next) {
return next(err);
}
// Remove child categories, as they don't belong on the home page
categoryData = categoryData.filter(function(categoryObj) {
return !categoryObj.parent;
});
categories.getRecentTopicReplies(categoryData, uid, function(err) {
next(err, categoryData);
});

View File

@@ -1,6 +1,7 @@
'use strict';
var user = require('../user'),
var winston = require('winston'),
user = require('../user'),
translator = require('../../public/src/translator');
module.exports = function(Meta) {
@@ -14,7 +15,14 @@ module.exports = function(Meta) {
};
Meta.title.build = function (urlFragment, language, callback) {
Meta.title.parseFragment(decodeURIComponent(urlFragment), language, function(err, title) {
var uri = '';
try {
uri = decodeURIComponent(urlFragment);
} catch(e) {
winston.error('Invalid url fragment : ' + urlFragment, e.stack);
return callback(null, Meta.config.browserTitle || 'NodeBB');
}
Meta.title.parseFragment(uri, language, function(err, title) {
if (err) {
title = Meta.config.browserTitle || 'NodeBB';
} else {

View File

@@ -63,7 +63,15 @@ function routeCurrentTheme(app, themeId, themesData) {
}
// Theme's templates path
nconf.set('theme_templates_path', themeObj.templates ? path.join(themesPath, themeObj.id, themeObj.templates) : nconf.get('base_templates_path'));
var themePath = nconf.get('base_templates_path'),
fallback = path.join(themesPath, themeObj.id, 'templates');
if (themeObj.templates) {
themePath = path.join(themesPath, themeObj.id, themeObj.templates);
} else if (fs.existsSync(fallback)) {
themePath = fallback;
}
nconf.set('theme_templates_path', themePath);
}
module.exports = function(app, data) {

View File

@@ -295,7 +295,7 @@ var async = require('async'),
}
posts = posts.filter(function(post) {
return parseInt(results.topics[post.tid].deleted, 10) !== 1;
return results.topics[post.tid] && parseInt(results.topics[post.tid].deleted, 10) !== 1;
});
async.map(posts, function(post, next) {

View File

@@ -173,9 +173,9 @@ var async = require('async'),
Topics.getTopicsData(tids, function(err, topics) {
function mapFilter(array, field) {
return array.map(function(topic) {
return topic[field];
return topic && topic[field];
}).filter(function(value, index, array) {
return array.indexOf(value) === index;
return value && array.indexOf(value) === index;
});
}
@@ -218,21 +218,23 @@ var async = require('async'),
});
for (var i=0; i<topics.length; ++i) {
topics[i].category = categories[topics[i].cid];
topics[i].category.disabled = parseInt(topics[i].category.disabled, 10) === 1;
topics[i].user = users[topics[i].uid];
topics[i].teaser = results.teasers[i];
topics[i].tags = results.tags[i];
if (topics[i]) {
topics[i].category = categories[topics[i].cid];
topics[i].category.disabled = parseInt(topics[i].category.disabled, 10) === 1;
topics[i].user = users[topics[i].uid];
topics[i].teaser = results.teasers[i];
topics[i].tags = results.tags[i];
topics[i].pinned = parseInt(topics[i].pinned, 10) === 1;
topics[i].locked = parseInt(topics[i].locked, 10) === 1;
topics[i].deleted = parseInt(topics[i].deleted, 10) === 1;
topics[i].unread = !(results.hasRead[i] && parseInt(uid, 10) !== 0);
topics[i].unreplied = parseInt(topics[i].postcount, 10) <= 1;
topics[i].pinned = parseInt(topics[i].pinned, 10) === 1;
topics[i].locked = parseInt(topics[i].locked, 10) === 1;
topics[i].deleted = parseInt(topics[i].deleted, 10) === 1;
topics[i].unread = !(results.hasRead[i] && parseInt(uid, 10) !== 0);
topics[i].unreplied = parseInt(topics[i].postcount, 10) <= 1;
}
}
topics = topics.filter(function(topic) {
return !topic.category.disabled &&
return topic && !topic.category.disabled &&
(!topic.deleted || (topic.deleted && isAdminOrMod[topic.cid]) ||
parseInt(topic.uid, 10) === parseInt(uid, 10));
});