|
|
|
@ -16,11 +16,19 @@ var db = require('../database');
|
|
|
|
|
var utils = require('../utils');
|
|
|
|
|
var controllers404 = require('../controllers/404.js');
|
|
|
|
|
|
|
|
|
|
var terms = {
|
|
|
|
|
daily: 'day',
|
|
|
|
|
weekly: 'week',
|
|
|
|
|
monthly: 'month',
|
|
|
|
|
alltime: 'alltime',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = function (app, middleware) {
|
|
|
|
|
app.get('/topic/:topic_id.rss', middleware.maintenanceMode, generateForTopic);
|
|
|
|
|
app.get('/category/:category_id.rss', middleware.maintenanceMode, generateForCategory);
|
|
|
|
|
app.get('/recent.rss', middleware.maintenanceMode, generateForRecent);
|
|
|
|
|
app.get('/top.rss', middleware.maintenanceMode, generateForTop);
|
|
|
|
|
app.get('/top/:term.rss', middleware.maintenanceMode, generateForTop);
|
|
|
|
|
app.get('/popular.rss', middleware.maintenanceMode, generateForPopular);
|
|
|
|
|
app.get('/popular/:term.rss', middleware.maintenanceMode, generateForPopular);
|
|
|
|
|
app.get('/recentposts.rss', middleware.maintenanceMode, generateForRecentPosts);
|
|
|
|
@ -212,7 +220,8 @@ function generateForTop(req, res, next) {
|
|
|
|
|
if (parseInt(meta.config['feeds:disableRSS'], 10) === 1) {
|
|
|
|
|
return controllers404.send404(req, res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var term = terms[req.params.term] || 'day';
|
|
|
|
|
var uid;
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function (next) {
|
|
|
|
|
if (req.query.token && req.query.uid) {
|
|
|
|
@ -222,13 +231,27 @@ function generateForTop(req, res, next) {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function (token, next) {
|
|
|
|
|
generateForTopics({
|
|
|
|
|
uid: token && token === req.query.token ? req.query.uid : req.uid,
|
|
|
|
|
uid = token && token === req.query.token ? req.query.uid : req.uid;
|
|
|
|
|
|
|
|
|
|
topics.getSortedTopics({
|
|
|
|
|
uid: uid,
|
|
|
|
|
start: 0,
|
|
|
|
|
stop: 19,
|
|
|
|
|
term: term,
|
|
|
|
|
sort: 'votes',
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
function (result, next) {
|
|
|
|
|
generateTopicsFeed({
|
|
|
|
|
uid: uid,
|
|
|
|
|
title: 'Top Voted Topics',
|
|
|
|
|
description: 'A list of topics that have received the most votes',
|
|
|
|
|
feed_url: '/top.rss',
|
|
|
|
|
site_url: '/top',
|
|
|
|
|
}, 'topics:votes', req, res, next);
|
|
|
|
|
feed_url: '/top/' + (req.params.term || 'daily') + '.rss',
|
|
|
|
|
site_url: '/top/' + (req.params.term || 'daily'),
|
|
|
|
|
}, result.topics, next);
|
|
|
|
|
},
|
|
|
|
|
function (feed) {
|
|
|
|
|
sendFeed(feed, res);
|
|
|
|
|
},
|
|
|
|
|
], next);
|
|
|
|
|
}
|
|
|
|
@ -237,12 +260,7 @@ function generateForPopular(req, res, next) {
|
|
|
|
|
if (parseInt(meta.config['feeds:disableRSS'], 10) === 1) {
|
|
|
|
|
return controllers404.send404(req, res);
|
|
|
|
|
}
|
|
|
|
|
var terms = {
|
|
|
|
|
daily: 'day',
|
|
|
|
|
weekly: 'week',
|
|
|
|
|
monthly: 'month',
|
|
|
|
|
alltime: 'alltime',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var term = terms[req.params.term] || 'day';
|
|
|
|
|
var uid;
|
|
|
|
|
async.waterfall([
|
|
|
|
|