Added an extra sort option for 'gilded'
Implemented 'gilded' sort both in the banner bar (by pushing the '6' key), and in the prompt (by entering '/subreddit/gilded')
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@
|
|||||||
!.gitignore
|
!.gitignore
|
||||||
!.gitattributes
|
!.gitattributes
|
||||||
!.coveragerc
|
!.coveragerc
|
||||||
|
!CONTROLS.rst
|
||||||
*~
|
*~
|
||||||
*.pyc
|
*.pyc
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Basic Commands
|
|||||||
:``j``/``k`` or ``▲``/``▼``: Move the cursor up/down
|
:``j``/``k`` or ``▲``/``▼``: Move the cursor up/down
|
||||||
:``m``/``n`` or ``PgUp``/``PgDn``: Jump to the previous/next page
|
:``m``/``n`` or ``PgUp``/``PgDn``: Jump to the previous/next page
|
||||||
:``gg``/``G``: Jump to the top/bottom of the page
|
:``gg``/``G``: Jump to the top/bottom of the page
|
||||||
:``1-5``: Toggle post order (*hot*, *top*, *rising*, *new*, *controversial*)
|
:``1-6``: Toggle post order (*hot*, *top*, *rising*, *new*, *controversial*, *gilded*)
|
||||||
:``r`` or ``F5``: Refresh page content
|
:``r`` or ``F5``: Refresh page content
|
||||||
:``u``: Log in or switch accounts
|
:``u``: Log in or switch accounts
|
||||||
:``/``: Open a prompt to switch subreddits
|
:``/``: Open a prompt to switch subreddits
|
||||||
|
|||||||
0
rtv/__main__.py
Normal file → Executable file
0
rtv/__main__.py
Normal file → Executable file
@@ -543,7 +543,7 @@ class SubredditContent(Content):
|
|||||||
orders = ['relevance', 'top', 'comments', 'new', None]
|
orders = ['relevance', 'top', 'comments', 'new', None]
|
||||||
period_allowed = ['top', 'comments']
|
period_allowed = ['top', 'comments']
|
||||||
else:
|
else:
|
||||||
orders = ['hot', 'top', 'rising', 'new', 'controversial', None]
|
orders = ['hot', 'top', 'rising', 'new', 'controversial', 'gilded', None]
|
||||||
period_allowed = ['top', 'controversial']
|
period_allowed = ['top', 'controversial']
|
||||||
|
|
||||||
if order not in orders:
|
if order not in orders:
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ https://github.com/michael-lazar/rtv
|
|||||||
3 : Sort by rising
|
3 : Sort by rising
|
||||||
4 : Sort by new
|
4 : Sort by new
|
||||||
5 : Sort by controversial
|
5 : Sort by controversial
|
||||||
|
6 : Sort by gilded
|
||||||
p : Return to the front page
|
p : Return to the front page
|
||||||
r : Refresh page
|
r : Refresh page
|
||||||
u : Login or logout
|
u : Login or logout
|
||||||
@@ -77,6 +78,7 @@ https://github.com/michael-lazar/rtv
|
|||||||
- /r/python
|
- /r/python
|
||||||
- /r/python/new (sort)
|
- /r/python/new (sort)
|
||||||
- /r/python/controversial-year (sort and order)
|
- /r/python/controversial-year (sort and order)
|
||||||
|
- /r/python/gilded (gilded within subreddit)
|
||||||
- /r/python+linux (multireddit)
|
- /r/python+linux (multireddit)
|
||||||
- /r/python/comments/30rwj2 (submission comments)
|
- /r/python/comments/30rwj2 (submission comments)
|
||||||
- /comments/30rwj2 (submission comments shorthand)
|
- /comments/30rwj2 (submission comments shorthand)
|
||||||
@@ -89,7 +91,7 @@ https://github.com/michael-lazar/rtv
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
BANNER = """
|
BANNER = """
|
||||||
[1]hot [2]top [3]rising [4]new [5]controversial
|
[1]hot [2]top [3]rising [4]new [5]controversial [6]gilded
|
||||||
"""
|
"""
|
||||||
|
|
||||||
BANNER_SEARCH = """
|
BANNER_SEARCH = """
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ class Config(object): # pylint: disable=R0903
|
|||||||
'friends': 'prefs/friends/',
|
'friends': 'prefs/friends/',
|
||||||
'gild_thing': 'api/v1/gold/gild/{fullname}/',
|
'gild_thing': 'api/v1/gold/gild/{fullname}/',
|
||||||
'gild_user': 'api/v1/gold/give/{username}/',
|
'gild_user': 'api/v1/gold/give/{username}/',
|
||||||
|
'gilded': 'gilded/',
|
||||||
'help': 'help/',
|
'help': 'help/',
|
||||||
'hide': 'api/hide/',
|
'hide': 'api/hide/',
|
||||||
'ignore_reports': 'api/ignore_reports/',
|
'ignore_reports': 'api/ignore_reports/',
|
||||||
@@ -841,7 +842,7 @@ class UnauthenticatedReddit(BaseReddit):
|
|||||||
|
|
||||||
:param domain: The domain to generate a submission listing for.
|
:param domain: The domain to generate a submission listing for.
|
||||||
:param sort: When provided must be one of 'hot', 'new', 'rising',
|
:param sort: When provided must be one of 'hot', 'new', 'rising',
|
||||||
'controversial, or 'top'. Defaults to 'hot'.
|
'controversial', 'gilded', or 'top'. Defaults to 'hot'.
|
||||||
:param period: When sort is either 'controversial', or 'top' the period
|
:param period: When sort is either 'controversial', or 'top' the period
|
||||||
can be either None (for account default), 'all', 'year', 'month',
|
can be either None (for account default), 'all', 'year', 'month',
|
||||||
'week', 'day', or 'hour'.
|
'week', 'day', or 'hour'.
|
||||||
@@ -851,7 +852,7 @@ class UnauthenticatedReddit(BaseReddit):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
# Verify arguments
|
# Verify arguments
|
||||||
if sort not in ('controversial', 'hot', 'new', 'rising', 'top'):
|
if sort not in ('controversial', 'hot', 'new', 'rising', 'top', 'gilded'):
|
||||||
raise TypeError('Invalid sort parameter.')
|
raise TypeError('Invalid sort parameter.')
|
||||||
if period not in (None, 'all', 'day', 'hour', 'month', 'week', 'year'):
|
if period not in (None, 'all', 'day', 'hour', 'month', 'week', 'year'):
|
||||||
raise TypeError('Invalid period parameter.')
|
raise TypeError('Invalid period parameter.')
|
||||||
@@ -1172,6 +1173,20 @@ class UnauthenticatedReddit(BaseReddit):
|
|||||||
"""
|
"""
|
||||||
return self.get_content(self.config['top'], *args, **kwargs)
|
return self.get_content(self.config['top'], *args, **kwargs)
|
||||||
|
|
||||||
|
@decorators.restrict_access(scope='read')
|
||||||
|
def get_gilded(self, *args, **kwargs):
|
||||||
|
"""Return a get_content generator for gilded submissions.
|
||||||
|
|
||||||
|
Corresponds to the submissions provided by
|
||||||
|
``https://www.reddit.com/gilded/`` for the session.
|
||||||
|
|
||||||
|
The additional parameters are passed directly into
|
||||||
|
:meth:`.get_content`. Note: the `url` parameter cannot be altered.
|
||||||
|
|
||||||
|
"""
|
||||||
|
return self.get_content(self.config['gilded'], *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
# There exists a `modtraffic` scope, but it is unused.
|
# There exists a `modtraffic` scope, but it is unused.
|
||||||
@decorators.restrict_access(scope='modconfig')
|
@decorators.restrict_access(scope='modconfig')
|
||||||
def get_traffic(self, subreddit):
|
def get_traffic(self, subreddit):
|
||||||
|
|||||||
@@ -1579,6 +1579,7 @@ class Subreddit(Messageable, Refreshable):
|
|||||||
get_hot = _get_sorter('')
|
get_hot = _get_sorter('')
|
||||||
get_new = _get_sorter('new')
|
get_new = _get_sorter('new')
|
||||||
get_top = _get_sorter('top')
|
get_top = _get_sorter('top')
|
||||||
|
get_gilded = _get_sorter('gilded')
|
||||||
|
|
||||||
# Explicit listing selectors
|
# Explicit listing selectors
|
||||||
get_controversial_from_all = _get_sorter('controversial', t='all')
|
get_controversial_from_all = _get_sorter('controversial', t='all')
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ class SubmissionPage(Page):
|
|||||||
def sort_content_rising(self):
|
def sort_content_rising(self):
|
||||||
self.refresh_content(order='rising')
|
self.refresh_content(order='rising')
|
||||||
|
|
||||||
|
@SubmissionController.register(Command('SORT_GILDED'))
|
||||||
|
def sort_content_rising(self):
|
||||||
|
self.refresh_content(order='gilded')
|
||||||
|
|
||||||
@SubmissionController.register(Command('SORT_NEW'))
|
@SubmissionController.register(Command('SORT_NEW'))
|
||||||
def sort_content_new(self):
|
def sort_content_new(self):
|
||||||
self.refresh_content(order='new')
|
self.refresh_content(order='new')
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class SubredditPage(Page):
|
|||||||
else:
|
else:
|
||||||
self.refresh_content(order='hot')
|
self.refresh_content(order='hot')
|
||||||
|
|
||||||
|
|
||||||
@SubredditController.register(Command('SORT_TOP'))
|
@SubredditController.register(Command('SORT_TOP'))
|
||||||
def sort_content_top(self):
|
def sort_content_top(self):
|
||||||
order = self._prompt_period('top')
|
order = self._prompt_period('top')
|
||||||
@@ -85,6 +86,17 @@ class SubredditPage(Page):
|
|||||||
else:
|
else:
|
||||||
self.refresh_content(order='rising')
|
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'))
|
@SubredditController.register(Command('SORT_NEW'))
|
||||||
def sort_content_new(self):
|
def sort_content_new(self):
|
||||||
self.refresh_content(order='new')
|
self.refresh_content(order='new')
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ SORT_TOP = 2
|
|||||||
SORT_RISING = 3
|
SORT_RISING = 3
|
||||||
SORT_NEW = 4
|
SORT_NEW = 4
|
||||||
SORT_CONTROVERSIAL = 5
|
SORT_CONTROVERSIAL = 5
|
||||||
|
SORT_GILDED = 6
|
||||||
MOVE_UP = k, <KEY_UP>
|
MOVE_UP = k, <KEY_UP>
|
||||||
MOVE_DOWN = j, <KEY_DOWN>
|
MOVE_DOWN = j, <KEY_DOWN>
|
||||||
PREVIOUS_THEME = <KEY_F2>
|
PREVIOUS_THEME = <KEY_F2>
|
||||||
|
|||||||
Reference in New Issue
Block a user