mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-13 17:35:46 +01:00
@@ -64,9 +64,7 @@ var async = require('async'),
|
||||
category.isIgnored = results.isIgnored[0];
|
||||
category.topic_row_size = 'col-md-9';
|
||||
|
||||
plugins.fireHook('filter:category.get', {category: category, uid: data.uid}, function(err, data) {
|
||||
callback(err, data ? data.category : null);
|
||||
});
|
||||
callback(null, category);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -22,12 +22,7 @@ categoriesController.recent = function(req, res, next) {
|
||||
|
||||
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
|
||||
|
||||
plugins.fireHook('filter:category.get', {category: data, uid: uid}, function(err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
res.render('recent', data.category);
|
||||
});
|
||||
res.render('recent', data);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -49,24 +44,22 @@ categoriesController.popular = function(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
topics.getPopular(term, uid, meta.config.topicsPerList, function(err, data) {
|
||||
topics.getPopular(term, uid, meta.config.topicsPerList, function(err, topics) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
data['feeds:disableRSS'] = parseInt(meta.config['feeds:disableRSS'], 10) === 1;
|
||||
var data = {
|
||||
topics: topics,
|
||||
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1
|
||||
};
|
||||
|
||||
plugins.fireHook('filter:category.get', {category: {topics: data}, uid: uid}, function(err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (uid === 0) {
|
||||
anonCache[term] = data.category;
|
||||
anonCache[term] = data;
|
||||
lastUpdateTime = Date.now();
|
||||
}
|
||||
|
||||
res.render('popular', data.category);
|
||||
});
|
||||
res.render('popular', data);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -78,12 +71,7 @@ categoriesController.unread = function(req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:category.get', {category: data, uid: uid}, function(err, data) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
res.render('unread', data.category);
|
||||
});
|
||||
res.render('unread', data);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -32,24 +32,21 @@ module.exports = function(Topics) {
|
||||
}
|
||||
|
||||
function getTopics(tids, uid, count, callback) {
|
||||
Topics.getTopicsFields(tids, ['tid', 'postcount'], function(err, topics) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
Topics.getTopicsFields(tids, ['tid', 'postcount'], next);
|
||||
},
|
||||
function(topics, next) {
|
||||
tids = topics.sort(function(a, b) {
|
||||
return b.postcount - a.postcount;
|
||||
}).slice(0, count).map(function(topic) {
|
||||
return topic.tid;
|
||||
});
|
||||
|
||||
privileges.topics.filter('read', tids, uid, function(err, tids) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
privileges.topics.filter('read', tids, uid, next);
|
||||
},
|
||||
function(tids, next) {
|
||||
Topics.getTopicsByTids(tids, uid, next);
|
||||
}
|
||||
|
||||
Topics.getTopicsByTids(tids, uid, callback);
|
||||
});
|
||||
});
|
||||
], callback);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user