v1.18.x
Barış Soner Uşaklı 7 years ago
parent 5cf662e565
commit 9912c400b6

@ -6,7 +6,10 @@
"popular-month": "Popular topics this month",
"popular-alltime": "All time popular topics",
"recent": "Recent Topics",
"top": "Top Voted Topics",
"top-day": "Top voted topics today",
"top-week": "Top voted topics this week",
"top-month": "Top voted topics this month",
"top-alltime": "Top Voted Topics",
"moderator-tools": "Moderator Tools",
"flagged-content": "Flagged Content",
"ip-blacklist": "IP Blacklist",

@ -3,7 +3,7 @@
var async = require('async');
var nconf = require('nconf');
var validator = require('validator');
var helpers = require('./helpers');
var recentController = require('./recent');
@ -26,7 +26,7 @@ popularController.get = function (req, res, next) {
data.breadcrumbs = helpers.buildBreadcrumbs(breadcrumbs);
}
var feedQs = data.rssFeedUrl.split('?')[1];
data.rssFeedUrl = nconf.get('relative_path') + '/popular/' + (req.query.term || 'alltime') + '.rss';
data.rssFeedUrl = nconf.get('relative_path') + '/popular/' + (validator.escape(String(req.query.term)) || 'alltime') + '.rss';
if (req.loggedIn) {
data.rssFeedUrl += '?' + feedQs;
}

@ -37,7 +37,7 @@ recentController.getData = function (req, url, sort, callback) {
var rssToken;
if (!helpers.validFilters[filter] || (!term && req.query.term)) {
return callback();
return callback(null, null);
}
term = term || 'alltime';

@ -2,6 +2,10 @@
'use strict';
var async = require('async');
var nconf = require('nconf');
var validator = require('validator');
var helpers = require('./helpers');
var recentController = require('./recent');
var topController = module.exports;
@ -15,6 +19,16 @@ topController.get = function (req, res, next) {
if (!data) {
return next();
}
var term = helpers.terms[req.query.term] || 'alltime';
if (req.originalUrl.startsWith(nconf.get('relative_path') + '/api/top') || req.originalUrl.startsWith(nconf.get('relative_path') + '/top')) {
data.title = '[[pages:top-' + term + ']]';
}
var feedQs = data.rssFeedUrl.split('?')[1];
data.rssFeedUrl = nconf.get('relative_path') + '/top/' + (validator.escape(String(req.query.term)) || 'alltime') + '.rss';
if (req.loggedIn) {
data.rssFeedUrl += '?' + feedQs;
}
res.render('top', data);
},
], next);

@ -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([

Loading…
Cancel
Save