mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	This commit is contained in:
		| @@ -69,9 +69,9 @@ | ||||
|       "nodebb-plugin-spam-be-gone": "0.5.1", | ||||
|       "nodebb-rewards-essentials": "0.0.9", | ||||
|       "nodebb-theme-lavender": "5.0.0", | ||||
|       "nodebb-theme-persona": "7.2.5", | ||||
|       "nodebb-theme-persona": "7.2.6", | ||||
|       "nodebb-theme-slick": "1.1.2", | ||||
|       "nodebb-theme-vanilla": "8.1.2", | ||||
|       "nodebb-theme-vanilla": "8.1.3", | ||||
|       "nodebb-widget-essentials": "4.0.1", | ||||
|       "nodemailer": "4.4.0", | ||||
|       "passport": "^0.4.0", | ||||
|   | ||||
| @@ -66,6 +66,7 @@ | ||||
| 	"topics": "Topics", | ||||
| 	"posts": "Posts", | ||||
| 	"best": "Best", | ||||
| 	"votes": "Votes", | ||||
| 	"upvoters": "Upvoters", | ||||
| 	"upvoted": "Upvoted", | ||||
| 	"downvoters": "Downvoters", | ||||
|   | ||||
| @@ -138,6 +138,8 @@ module.exports = function (Categories) { | ||||
|  | ||||
| 		if (sort === 'most_posts') { | ||||
| 			set = 'cid:' + cid + ':tids:posts'; | ||||
| 		} else if (sort === 'most_votes') { | ||||
| 			set = 'cid:' + cid + ':tids:votes'; | ||||
| 		} | ||||
|  | ||||
| 		if (data.targetUid) { | ||||
| @@ -163,7 +165,7 @@ module.exports = function (Categories) { | ||||
|  | ||||
| 	Categories.getSortedSetRangeDirection = function (sort, callback) { | ||||
| 		sort = sort || 'newest_to_oldest'; | ||||
| 		var direction = sort === 'newest_to_oldest' || sort === 'most_posts' ? 'highest-to-lowest' : 'lowest-to-highest'; | ||||
| 		var direction = sort === 'newest_to_oldest' || sort === 'most_posts' || sort === 'most_votes' ? 'highest-to-lowest' : 'lowest-to-highest'; | ||||
| 		plugins.fireHook('filter:categories.getSortedSetRangeDirection', { | ||||
| 			sort: sort, | ||||
| 			direction: direction, | ||||
|   | ||||
| @@ -19,6 +19,7 @@ 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('/popular.rss', middleware.maintenanceMode, generateForPopular); | ||||
| 	app.get('/popular/:term.rss', middleware.maintenanceMode, generateForPopular); | ||||
| 	app.get('/recentposts.rss', middleware.maintenanceMode, generateForRecentPosts); | ||||
| @@ -209,6 +210,34 @@ function generateForRecent(req, res, next) { | ||||
| 	], next); | ||||
| } | ||||
|  | ||||
| function generateForTop(req, res, next) { | ||||
| 	if (parseInt(meta.config['feeds:disableRSS'], 10) === 1) { | ||||
| 		return controllers404.send404(req, res); | ||||
| 	} | ||||
|  | ||||
| 	async.waterfall([ | ||||
| 		function (next) { | ||||
| 			if (req.query.token && req.query.uid) { | ||||
| 				db.getObjectField('user:' + req.query.uid, 'rss_token', next); | ||||
| 			} else { | ||||
| 				next(null, null); | ||||
| 			} | ||||
| 		}, | ||||
| 		function (token, next) { | ||||
| 			next(null, token && token === req.query.token ? req.query.uid : req.uid); | ||||
| 		}, | ||||
| 		function (uid, next) { | ||||
| 			generateForTopics({ | ||||
| 				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); | ||||
| 		}, | ||||
| 	], next); | ||||
| } | ||||
|  | ||||
| function generateForPopular(req, res, next) { | ||||
| 	if (parseInt(meta.config['feeds:disableRSS'], 10) === 1) { | ||||
| 		return controllers404.send404(req, res); | ||||
|   | ||||
| @@ -449,6 +449,15 @@ describe('Controllers', function () { | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('should load recent rss feed', function (done) { | ||||
| 		request(nconf.get('url') + '/top.rss', function (err, res, body) { | ||||
| 			assert.ifError(err); | ||||
| 			assert.equal(res.statusCode, 200); | ||||
| 			assert(body); | ||||
| 			done(); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	it('should load popular rss feed', function (done) { | ||||
| 		request(nconf.get('url') + '/popular.rss', function (err, res, body) { | ||||
| 			assert.ifError(err); | ||||
|   | ||||
| @@ -53,6 +53,7 @@ describe('feeds', function () { | ||||
| 			nconf.get('url') + '/topic/' + tid + '.rss', | ||||
| 			nconf.get('url') + '/category/' + cid + '.rss', | ||||
| 			nconf.get('url') + '/recent.rss', | ||||
| 			nconf.get('url') + '/top.rss', | ||||
| 			nconf.get('url') + '/popular.rss', | ||||
| 			nconf.get('url') + '/popular/day.rss', | ||||
| 			nconf.get('url') + '/recentposts.rss', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user