Removing the gilded sorting option from the submission and search result pages
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,7 +4,6 @@
|
||||
!.gitignore
|
||||
!.gitattributes
|
||||
!.coveragerc
|
||||
!CONTROLS.rst
|
||||
*~
|
||||
*.pyc
|
||||
*.log
|
||||
|
||||
@@ -56,6 +56,7 @@ The ``/`` prompt accepts subreddits in the following formats
|
||||
* ``/r/python``
|
||||
* ``/r/python/new``
|
||||
* ``/r/python/controversial-year``
|
||||
# ``/r/python/gilded``
|
||||
* ``/r/python+linux`` supports multireddits
|
||||
* ``/r/front`` will redirect to the front page
|
||||
* ``/u/me`` will display your submissions
|
||||
|
||||
@@ -90,10 +90,14 @@ https://github.com/michael-lazar/rtv
|
||||
- /domain/python.org (search by domain)
|
||||
"""
|
||||
|
||||
BANNER = """
|
||||
BANNER_SUBREDDIT = """
|
||||
[1]hot [2]top [3]rising [4]new [5]controversial [6]gilded
|
||||
"""
|
||||
|
||||
BANNER_SUBMISSION = """
|
||||
[1]hot [2]top [3]rising [4]new [5]controversial
|
||||
"""
|
||||
|
||||
BANNER_SEARCH = """
|
||||
[1]relevance [2]top [3]comments [4]new
|
||||
"""
|
||||
|
||||
21
rtv/page.py
21
rtv/page.py
@@ -39,6 +39,7 @@ class PageController(Controller):
|
||||
|
||||
class Page(object):
|
||||
|
||||
BANNER = None
|
||||
FOOTER = None
|
||||
|
||||
def __init__(self, reddit, term, config, oauth):
|
||||
@@ -353,7 +354,9 @@ class Page(object):
|
||||
continue
|
||||
|
||||
def draw(self):
|
||||
|
||||
"""
|
||||
Clear the terminal screen and redraw all of the sub-windows
|
||||
"""
|
||||
n_rows, n_cols = self.term.stdscr.getmaxyx()
|
||||
if n_rows < self.term.MIN_HEIGHT or n_cols < self.term.MIN_WIDTH:
|
||||
# TODO: Will crash when you try to navigate if the terminal is too
|
||||
@@ -369,7 +372,9 @@ class Page(object):
|
||||
self.term.stdscr.refresh()
|
||||
|
||||
def _draw_header(self):
|
||||
|
||||
"""
|
||||
Draw the title bar at the top of the screen
|
||||
"""
|
||||
n_rows, n_cols = self.term.stdscr.getmaxyx()
|
||||
|
||||
# Note: 2 argument form of derwin breaks PDcurses on Windows 7!
|
||||
@@ -427,13 +432,15 @@ class Page(object):
|
||||
self._row += 1
|
||||
|
||||
def _draw_banner(self):
|
||||
|
||||
"""
|
||||
Draw the banner with sorting options at the top of the page
|
||||
"""
|
||||
n_rows, n_cols = self.term.stdscr.getmaxyx()
|
||||
window = self.term.stdscr.derwin(1, n_cols, self._row, 0)
|
||||
window.erase()
|
||||
window.bkgd(str(' '), self.term.attr('OrderBar'))
|
||||
|
||||
banner = docs.BANNER_SEARCH if self.content.query else docs.BANNER
|
||||
banner = docs.BANNER_SEARCH if self.content.query else self.BANNER
|
||||
items = banner.strip().split(' ')
|
||||
|
||||
distance = (n_cols - sum(len(t) for t in items) - 1) / (len(items) - 1)
|
||||
@@ -452,7 +459,6 @@ class Page(object):
|
||||
"""
|
||||
Loop through submissions and fill up the content page.
|
||||
"""
|
||||
|
||||
n_rows, n_cols = self.term.stdscr.getmaxyx()
|
||||
window = self.term.stdscr.derwin(n_rows - self._row - 1, n_cols, self._row, 0)
|
||||
window.erase()
|
||||
@@ -525,7 +531,9 @@ class Page(object):
|
||||
self._row += win_n_rows
|
||||
|
||||
def _draw_footer(self):
|
||||
|
||||
"""
|
||||
Draw the key binds help bar at the bottom of the screen
|
||||
"""
|
||||
n_rows, n_cols = self.term.stdscr.getmaxyx()
|
||||
window = self.term.stdscr.derwin(1, n_cols, self._row, 0)
|
||||
window.erase()
|
||||
@@ -548,7 +556,6 @@ class Page(object):
|
||||
self.term.flash()
|
||||
|
||||
def _prompt_period(self, order):
|
||||
|
||||
choices = {
|
||||
'\n': order,
|
||||
'1': '{0}-hour'.format(order),
|
||||
|
||||
@@ -17,6 +17,7 @@ class SubmissionController(PageController):
|
||||
|
||||
class SubmissionPage(Page):
|
||||
|
||||
BANNER = docs.BANNER_SUBMISSION
|
||||
FOOTER = docs.FOOTER_SUBMISSION
|
||||
|
||||
def __init__(self, reddit, term, config, oauth, url=None, submission=None):
|
||||
@@ -48,10 +49,6 @@ class SubmissionPage(Page):
|
||||
def sort_content_rising(self):
|
||||
self.refresh_content(order='rising')
|
||||
|
||||
@SubmissionController.register(Command('SORT_GILDED'))
|
||||
def sort_content_gilded(self):
|
||||
self.refresh_content(order='gilded')
|
||||
|
||||
@SubmissionController.register(Command('SORT_NEW'))
|
||||
def sort_content_new(self):
|
||||
self.refresh_content(order='new')
|
||||
|
||||
@@ -19,6 +19,7 @@ class SubredditController(PageController):
|
||||
|
||||
class SubredditPage(Page):
|
||||
|
||||
BANNER = docs.BANNER_SUBREDDIT
|
||||
FOOTER = docs.FOOTER_SUBREDDIT
|
||||
|
||||
def __init__(self, reddit, term, config, oauth, name):
|
||||
@@ -66,7 +67,6 @@ class SubredditPage(Page):
|
||||
else:
|
||||
self.refresh_content(order='hot')
|
||||
|
||||
|
||||
@SubredditController.register(Command('SORT_TOP'))
|
||||
def sort_content_top(self):
|
||||
order = self._prompt_period('top')
|
||||
@@ -86,17 +86,6 @@ class SubredditPage(Page):
|
||||
else:
|
||||
self.refresh_content(order='rising')
|
||||
|
||||
@SubredditController.register(Command('SORT_GILDED'))
|
||||
def sort_content_gilded(self):
|
||||
if self.content.query:
|
||||
order = self._prompt_period('comments')
|
||||
if order is None:
|
||||
self.term.show_notification('Invalid option')
|
||||
else:
|
||||
self.refresh_content(order=order)
|
||||
else:
|
||||
self.refresh_content(order='gilded')
|
||||
|
||||
@SubredditController.register(Command('SORT_NEW'))
|
||||
def sort_content_new(self):
|
||||
self.refresh_content(order='new')
|
||||
@@ -112,6 +101,13 @@ class SubredditPage(Page):
|
||||
else:
|
||||
self.refresh_content(order=order)
|
||||
|
||||
@SubredditController.register(Command('SORT_GILDED'))
|
||||
def sort_content_gilded(self):
|
||||
if self.content.query:
|
||||
self.term.flash()
|
||||
else:
|
||||
self.refresh_content(order='gilded')
|
||||
|
||||
@SubredditController.register(Command('SUBREDDIT_SEARCH'))
|
||||
def search_subreddit(self, name=None):
|
||||
"""
|
||||
|
||||
@@ -13,6 +13,7 @@ class SubscriptionController(PageController):
|
||||
|
||||
class SubscriptionPage(Page):
|
||||
|
||||
BANNER = None
|
||||
FOOTER = docs.FOOTER_SUBSCRIPTION
|
||||
|
||||
def __init__(self, reddit, term, config, oauth, content_type='subreddit'):
|
||||
|
||||
Reference in New Issue
Block a user