mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 08:17:58 -05:00
Add a listing of random articles, similar to serendipity, but because
it's a listing, it can be pulled via RSS or JSON. Available at /randomrising
This commit is contained in:
@@ -92,7 +92,7 @@ def make_map(global_conf={}, app_conf={}):
|
||||
|
||||
mc('/', controller='hot', action='listing')
|
||||
|
||||
listing_controllers = "hot|saved|toplinks|new|recommended|normalized"
|
||||
listing_controllers = "hot|saved|toplinks|new|recommended|normalized|randomrising"
|
||||
|
||||
mc('/:controller', action='listing',
|
||||
requirements=dict(controller=listing_controllers))
|
||||
|
||||
@@ -30,6 +30,7 @@ from listingcontroller import RecommendedController
|
||||
from listingcontroller import MessageController
|
||||
from listingcontroller import RedditsController
|
||||
from listingcontroller import MyredditsController
|
||||
from listingcontroller import RandomrisingController
|
||||
|
||||
from feedback import FeedbackController
|
||||
from front import FrontController
|
||||
|
||||
@@ -35,6 +35,9 @@ from r2.lib import organic
|
||||
|
||||
from pylons.i18n import _
|
||||
|
||||
import random
|
||||
|
||||
|
||||
class ListingController(RedditController):
|
||||
"""Generalized controller for pages with lists of links."""
|
||||
|
||||
@@ -133,7 +136,6 @@ class ListingController(RedditController):
|
||||
|
||||
@staticmethod
|
||||
def builder_wrapper(thing):
|
||||
""""""
|
||||
if c.user.pref_compress and isinstance(thing, Link):
|
||||
thing.__class__ = LinkCompressed
|
||||
thing.score_fmt = Score.points
|
||||
@@ -333,6 +335,26 @@ class BrowseController(ListingController):
|
||||
return ListingController.GET_listing(self, **env)
|
||||
|
||||
|
||||
class RandomrisingController(ListingController):
|
||||
where = 'randomrising'
|
||||
builder_cls = IDBuilder
|
||||
title_text = _('you\'re really bored now, eh?')
|
||||
|
||||
def query(self):
|
||||
links = get_rising(c.site)
|
||||
|
||||
if not links:
|
||||
# just pull from the new page if the rising page isn't
|
||||
# populated for some reason
|
||||
q = Link._query(limit = 200,
|
||||
data = True,
|
||||
sort = desc('_date'))
|
||||
links = [ x._fullname for x in q ]
|
||||
|
||||
random.shuffle(links)
|
||||
|
||||
return links
|
||||
|
||||
class RecommendedController(ListingController):
|
||||
where = 'recommended'
|
||||
builder_cls = IDBuilder
|
||||
|
||||
Reference in New Issue
Block a user