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:
Chad Birch
2013-02-22 12:21:09 -07:00
parent e80bf458f3
commit 9f5c86a5cd
5 changed files with 20 additions and 35 deletions

View File

@@ -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))

View File

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

View File

@@ -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'

View File

@@ -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'

View File

@@ -478,6 +478,7 @@ class Reddit(Templated):
else:
main_buttons = [NamedButton('hot', dest='', aliases=['/hot']),
NamedButton('new'),
NamedButton('rising'),
NamedButton('controversial'),
NamedButton('top'),
]