mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-30 01:08:32 -05:00
Split rising out of new to its own tab
Also redirect any requests for the old rising URL to the new one Redirect POST requests to GET (should only be necessary during push)
This commit is contained in:
@@ -174,7 +174,7 @@ def make_map():
|
||||
|
||||
mc('/', controller='hot', action='listing')
|
||||
|
||||
listing_controllers = "hot|new|randomrising|comments"
|
||||
listing_controllers = "hot|new|rising|randomrising|comments"
|
||||
|
||||
mc('/:controller', action='listing',
|
||||
requirements=dict(controller=listing_controllers))
|
||||
|
||||
@@ -42,6 +42,7 @@ def load_controllers():
|
||||
from listingcontroller import ListingController
|
||||
from listingcontroller import HotController
|
||||
from listingcontroller import NewController
|
||||
from listingcontroller import RisingController
|
||||
from listingcontroller import BrowseController
|
||||
from listingcontroller import MessageController
|
||||
from listingcontroller import RedditsController
|
||||
|
||||
@@ -28,7 +28,7 @@ from r2.models.query_cache import CachedQuery, MergedCachedQuery
|
||||
from r2.config.extensions import is_api
|
||||
from r2.lib.pages import *
|
||||
from r2.lib.pages.things import wrap_links
|
||||
from r2.lib.menus import NewMenu, TimeMenu, SortMenu, RecSortMenu, ProfileSortMenu
|
||||
from r2.lib.menus import TimeMenu, SortMenu, RecSortMenu, ProfileSortMenu
|
||||
from r2.lib.menus import ControversyTimeMenu
|
||||
from r2.lib.rising import get_rising
|
||||
from r2.lib.wrapped import Wrapped
|
||||
@@ -398,10 +398,6 @@ class NewController(ListingController):
|
||||
where = 'new'
|
||||
title_text = _('newest submissions')
|
||||
|
||||
@property
|
||||
def menus(self):
|
||||
return [NewMenu(default = self.sort)]
|
||||
|
||||
def keep_fn(self):
|
||||
def keep(item):
|
||||
"""Avoid showing links that are too young, to give time
|
||||
@@ -425,24 +421,27 @@ class NewController(ListingController):
|
||||
return keep
|
||||
|
||||
def query(self):
|
||||
if self.sort == 'rising':
|
||||
return get_rising(c.site)
|
||||
else:
|
||||
return c.site.get_links('new', 'all')
|
||||
return c.site.get_links('new', 'all')
|
||||
|
||||
@validate(sort = VMenu('controller', NewMenu))
|
||||
def POST_listing(self, sort, **env):
|
||||
# VMenu validator will save the value of sort before we reach this
|
||||
# point. Now just redirect to GET mode.
|
||||
return self.redirect(request.fullpath + query_string(dict(sort=sort)))
|
||||
def POST_listing(self, **env):
|
||||
# Redirect to GET mode in case of any legacy requests
|
||||
return self.redirect(request.fullpath)
|
||||
|
||||
@require_oauth2_scope("read")
|
||||
@validate(sort = VMenu('controller', NewMenu))
|
||||
@listing_api_doc(uri='/new')
|
||||
def GET_listing(self, sort, **env):
|
||||
self.sort = sort
|
||||
def GET_listing(self, **env):
|
||||
if request.params.get('sort') == 'rising':
|
||||
return self.redirect('/rising')
|
||||
|
||||
return ListingController.GET_listing(self, **env)
|
||||
|
||||
class RisingController(NewController):
|
||||
where = 'rising'
|
||||
title_text = _('rising submissions')
|
||||
|
||||
def query(self):
|
||||
return get_rising(c.site)
|
||||
|
||||
class BrowseController(ListingController):
|
||||
where = 'browse'
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class MenuHandler(StringHandler):
|
||||
# selected menu styles, primarily used on the main nav bar
|
||||
menu_selected=StringHandler(hot = _("what's hot"),
|
||||
new = _("what's new"),
|
||||
rising = _("what's rising"),
|
||||
top = _("top scoring"),
|
||||
controversial= _("most controversial"),
|
||||
saved = _("saved"),
|
||||
@@ -495,23 +496,6 @@ class RecSortMenu(SortMenu):
|
||||
default = 'new'
|
||||
options = ('hot', 'new', 'top', 'controversial', 'relevance')
|
||||
|
||||
class NewMenu(SimplePostMenu):
|
||||
name = 'sort'
|
||||
default = 'rising'
|
||||
options = ('new', 'rising')
|
||||
type = 'flatlist'
|
||||
use_post = True
|
||||
|
||||
def __init__(self, **kw):
|
||||
kw['title'] = ""
|
||||
SimplePostMenu.__init__(self, **kw)
|
||||
|
||||
@classmethod
|
||||
def operator(self, sort):
|
||||
if sort == 'new':
|
||||
return operators.desc('_date')
|
||||
|
||||
|
||||
class KindMenu(SimplePostMenu):
|
||||
name = 'kind'
|
||||
default = 'all'
|
||||
|
||||
@@ -478,6 +478,7 @@ class Reddit(Templated):
|
||||
else:
|
||||
main_buttons = [NamedButton('hot', dest='', aliases=['/hot']),
|
||||
NamedButton('new'),
|
||||
NamedButton('rising'),
|
||||
NamedButton('controversial'),
|
||||
NamedButton('top'),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user