diff --git a/rtv/docs.py b/rtv/docs.py index d055cce..bc1b9aa 100644 --- a/rtv/docs.py +++ b/rtv/docs.py @@ -145,3 +145,13 @@ OAUTH_SUCCESS = """\
Reddit Terminal Viewer will now log in, you can close this window.
""" + +TIME_ORDER_MENU = """ +Links from: + [1] Past hour + [2] Past 24 hours + [3] Past week + [4] Past month + [5] Past year + [6] All time +""" \ No newline at end of file diff --git a/rtv/page.py b/rtv/page.py index b315cc2..3a64c11 100644 --- a/rtv/page.py +++ b/rtv/page.py @@ -93,7 +93,26 @@ class Page(object): @PageController.register(Command('SORT_TOP')) def sort_content_top(self): - self.refresh_content(order='top') + 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): @@ -107,6 +126,8 @@ class Page(object): def sort_content_controversial(self): self.refresh_content(order='controversial') + ##TODO: ADD CONTROVERSIAL SUBSORTS + @PageController.register(Command('MOVE_UP')) def move_cursor_up(self): self._move_cursor(-1)