Merge branch 'toporder' of https://github.com/ReshefElisha/rtv into ReshefElisha-toporder
This commit is contained in:
10
rtv/docs.py
10
rtv/docs.py
@@ -145,3 +145,13 @@ OAUTH_SUCCESS = """\
|
||||
<p><span style="font-weight: bold">Reddit Terminal Viewer</span>
|
||||
will now log in, you can close this window.</p>
|
||||
"""
|
||||
|
||||
TIME_ORDER_MENU = """
|
||||
Links from:
|
||||
[1] Past hour
|
||||
[2] Past 24 hours
|
||||
[3] Past week
|
||||
[4] Past month
|
||||
[5] Past year
|
||||
[6] All time
|
||||
"""
|
||||
|
||||
39
rtv/page.py
39
rtv/page.py
@@ -93,7 +93,26 @@ class Page(object):
|
||||
|
||||
@PageController.register(Command('SORT_TOP'))
|
||||
def sort_content_top(self):
|
||||
if (self.content.order and 'top' not in self.content.order) or 'front' in self.content.name:
|
||||
self.refresh_content(order='top')
|
||||
return
|
||||
else:
|
||||
ch = self.term.show_notification(
|
||||
docs.TIME_ORDER_MENU.strip('\n').splitlines())
|
||||
if ch not in range(ord('1'), ord('6') + 1):
|
||||
self.term.show_notification('Invalid option')
|
||||
return
|
||||
ord_choices = {
|
||||
ord('1'): 'top-hour',
|
||||
ord('2'): 'top-day',
|
||||
ord('3'): 'top-week',
|
||||
ord('4'): 'top-month',
|
||||
ord('5'): 'top-year',
|
||||
ord('6'): 'top-all',
|
||||
}
|
||||
order = ord_choices[ch]
|
||||
|
||||
self.refresh_content(order=order)
|
||||
|
||||
@PageController.register(Command('SORT_RISING'))
|
||||
def sort_content_rising(self):
|
||||
@@ -105,7 +124,27 @@ class Page(object):
|
||||
|
||||
@PageController.register(Command('SORT_CONTROVERSIAL'))
|
||||
def sort_content_controversial(self):
|
||||
if (self.content.order and 'controversial' not in self.content.order) or 'front' in self.content.name:
|
||||
self.refresh_content(order='controversial')
|
||||
return
|
||||
else:
|
||||
ch = self.term.show_notification(
|
||||
docs.TIME_ORDER_MENU.strip('\n').splitlines())
|
||||
if ch not in range(ord('1'), ord('6') + 1):
|
||||
self.term.show_notification('Invalid option')
|
||||
return
|
||||
ord_choices = {
|
||||
ord('1'): 'controversial-hour',
|
||||
ord('2'): 'controversial-day',
|
||||
ord('3'): 'controversial-week',
|
||||
ord('4'): 'controversial-month',
|
||||
ord('5'): 'controversial-year',
|
||||
ord('6'): 'controversial-all',
|
||||
}
|
||||
order = ord_choices[ch]
|
||||
|
||||
self.refresh_content(order=order)
|
||||
|
||||
|
||||
@PageController.register(Command('MOVE_UP'))
|
||||
def move_cursor_up(self):
|
||||
|
||||
Reference in New Issue
Block a user