mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 19:21:04 +01:00
closes #5994
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var nconf = require('nconf');
|
||||
var topics = require('../topics');
|
||||
var meta = require('../meta');
|
||||
var helpers = require('./helpers');
|
||||
|
||||
var popularController = {};
|
||||
var popularController = module.exports;
|
||||
|
||||
var anonCache = {};
|
||||
var lastUpdateTime = 0;
|
||||
@@ -38,36 +39,35 @@ popularController.get = function (req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
topics.getPopular(term, req.uid, meta.config.topicsPerList, function (err, topics) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
topics.getPopular(term, req.uid, meta.config.topicsPerList, next);
|
||||
},
|
||||
function (topics) {
|
||||
var data = {
|
||||
topics: topics,
|
||||
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1,
|
||||
rssFeedUrl: nconf.get('relative_path') + '/popular/' + (req.params.term || 'daily') + '.rss',
|
||||
title: '[[pages:popular-' + term + ']]',
|
||||
term: term,
|
||||
};
|
||||
|
||||
var data = {
|
||||
topics: topics,
|
||||
'feeds:disableRSS': parseInt(meta.config['feeds:disableRSS'], 10) === 1,
|
||||
rssFeedUrl: nconf.get('relative_path') + '/popular/' + (req.params.term || 'daily') + '.rss',
|
||||
title: '[[pages:popular-' + term + ']]',
|
||||
term: term,
|
||||
};
|
||||
if (req.path.startsWith('/api/popular') || req.path.startsWith('/popular')) {
|
||||
var breadcrumbs = [{ text: termToBreadcrumb[term] }];
|
||||
|
||||
if (req.path.startsWith('/api/popular') || req.path.startsWith('/popular')) {
|
||||
var breadcrumbs = [{ text: termToBreadcrumb[term] }];
|
||||
if (req.params.term) {
|
||||
breadcrumbs.unshift({ text: '[[global:header.popular]]', url: '/popular' });
|
||||
}
|
||||
|
||||
if (req.params.term) {
|
||||
breadcrumbs.unshift({ text: '[[global:header.popular]]', url: '/popular' });
|
||||
data.breadcrumbs = helpers.buildBreadcrumbs(breadcrumbs);
|
||||
}
|
||||
|
||||
data.breadcrumbs = helpers.buildBreadcrumbs(breadcrumbs);
|
||||
}
|
||||
if (!req.uid) {
|
||||
anonCache[term] = data;
|
||||
lastUpdateTime = Date.now();
|
||||
}
|
||||
|
||||
if (!req.uid) {
|
||||
anonCache[term] = data;
|
||||
lastUpdateTime = Date.now();
|
||||
}
|
||||
|
||||
res.render('popular', data);
|
||||
});
|
||||
res.render('popular', data);
|
||||
},
|
||||
], next);
|
||||
};
|
||||
|
||||
module.exports = popularController;
|
||||
|
||||
Reference in New Issue
Block a user