mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
closes #2088
This commit is contained in:
@@ -25,7 +25,11 @@ module.exports = function(Categories) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Categories.getRecentTopicReplies = function(categoryData, uid, callback) {
|
Categories.getRecentTopicReplies = function(categoryData, uid, callback) {
|
||||||
|
if (!Array.isArray(categoryData) || !categoryData.length) {
|
||||||
|
return callback(null, []);
|
||||||
|
}
|
||||||
async.map(categoryData, getRecentTopicPids, function(err, results) {
|
async.map(categoryData, getRecentTopicPids, function(err, results) {
|
||||||
|
|
||||||
var pids = _.flatten(results);
|
var pids = _.flatten(results);
|
||||||
|
|
||||||
pids = pids.filter(function(pid, index, array) {
|
pids = pids.filter(function(pid, index, array) {
|
||||||
|
|||||||
@@ -68,13 +68,27 @@ Controllers.home = function(req, res, next) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
var childCategories = [];
|
||||||
|
|
||||||
// Remove child categories, as they don't belong on the home page
|
for(var i=categoryData.length - 1; i>=0; --i) {
|
||||||
categoryData = categoryData.filter(function(categoryObj) {
|
|
||||||
return !categoryObj.parent;
|
|
||||||
});
|
|
||||||
|
|
||||||
categories.getRecentTopicReplies(categoryData, uid, function(err) {
|
if (Array.isArray(categoryData[i].children) && categoryData[i].children.length) {
|
||||||
|
childCategories.push.apply(childCategories, categoryData[i].children);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (categoryData[i].parent) {
|
||||||
|
categoryData.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async.parallel([
|
||||||
|
function(next) {
|
||||||
|
categories.getRecentTopicReplies(categoryData, uid, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
categories.getRecentTopicReplies(childCategories, uid, next);
|
||||||
|
}
|
||||||
|
], function(err) {
|
||||||
next(err, categoryData);
|
next(err, categoryData);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -182,7 +196,7 @@ Controllers.confirmEmail = function(req, res, next) {
|
|||||||
|
|
||||||
Controllers.sitemap = function(req, res, next) {
|
Controllers.sitemap = function(req, res, next) {
|
||||||
if (meta.config['feeds:disableSitemap'] === '1') {
|
if (meta.config['feeds:disableSitemap'] === '1') {
|
||||||
return res.redirect(nconf.get('relative_path') + '/404')
|
return res.redirect(nconf.get('relative_path') + '/404');
|
||||||
}
|
}
|
||||||
|
|
||||||
var sitemap = require('../sitemap.js');
|
var sitemap = require('../sitemap.js');
|
||||||
|
|||||||
@@ -221,6 +221,10 @@ var async = require('async'),
|
|||||||
options.stripTags = options.hasOwnProperty('stripTags') ? options.stripTags : false;
|
options.stripTags = options.hasOwnProperty('stripTags') ? options.stripTags : false;
|
||||||
options.parse = options.hasOwnProperty('parse') ? options.parse : true;
|
options.parse = options.hasOwnProperty('parse') ? options.parse : true;
|
||||||
|
|
||||||
|
if (!Array.isArray(pids) || !pids.length) {
|
||||||
|
return callback(null, []);
|
||||||
|
}
|
||||||
|
|
||||||
var keys = pids.map(function(pid) {
|
var keys = pids.map(function(pid) {
|
||||||
return 'post:' + pid;
|
return 'post:' + pid;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user