Merge remote-tracking branch 'origin/master' into woorst-more_listings
Conflicts: rtv/rtv.cfg tests/test_subreddit.py
This commit is contained in:
@@ -42,6 +42,7 @@ In subreddit mode you can browse through the top submissions on either the front
|
|||||||
:``o`` or ``ENTER``: Open the submission link with your web browser
|
:``o`` or ``ENTER``: Open the submission link with your web browser
|
||||||
:``/``: Open a prompt to switch subreddits
|
:``/``: Open a prompt to switch subreddits
|
||||||
:``f``: Open a prompt to search the current subreddit
|
:``f``: Open a prompt to search the current subreddit
|
||||||
|
:``p``: Toggle between the front page and the last visited subreddit
|
||||||
|
|
||||||
The ``/`` prompt accepts subreddits in the following formats
|
The ``/`` prompt accepts subreddits in the following formats
|
||||||
|
|
||||||
|
|||||||
29
README.rst
29
README.rst
@@ -67,30 +67,13 @@ Controls
|
|||||||
|
|
||||||
Move the cursor using either the arrow keys or *Vim* style movement
|
Move the cursor using either the arrow keys or *Vim* style movement
|
||||||
|
|
||||||
- Press **up** and **down** to scroll through submissions.
|
- Press **up** and **down** to scroll through submissions
|
||||||
- Press **right** to view the selected submission and **left** to return.
|
- Press **right** to view the selected submission and **left** to return
|
||||||
- Press **?** to open the help screen.
|
- Press **u** to login using OAuth
|
||||||
|
- Press **space** to expand/collapse comments
|
||||||
|
- Press **?** to open the help screen
|
||||||
|
|
||||||
See `CONTROLS <https://github.com/michael-lazar/rtv/blob/master/CONTROLS.rst>`_ for the complete list of available commands.
|
See `CONTROLS <https://github.com/michael-lazar/rtv/blob/master/CONTROLS.rst>`_ for the full list of commands.
|
||||||
|
|
||||||
--------------
|
|
||||||
Authentication
|
|
||||||
--------------
|
|
||||||
|
|
||||||
RTV enables you to login to your reddit account in order to perform actions like voting and leaving comments.
|
|
||||||
The login process uses OAuth [#]_ and follows these steps:
|
|
||||||
|
|
||||||
1. Initiate the login by pressing the ``u`` key.
|
|
||||||
2. Open a new webpage where reddit will ask you to authorize the application.
|
|
||||||
3. Click **Accept**.
|
|
||||||
|
|
||||||
RTV will retrieve an auth token with your information and store it locally in ``{HOME}/.config/rtv/refresh-token``.
|
|
||||||
You can disable storing the token by setting ``persistent=False`` in the config.
|
|
||||||
|
|
||||||
Note that RTV no longer allows you to input your username/password directly. This method of cookie based authentication has been deprecated by reddit [#]_.
|
|
||||||
|
|
||||||
.. [#] `<https://github.com/reddit/reddit/wiki/OAuth2>`_
|
|
||||||
.. [#] `<https://www.reddit.com/r/redditdev/comments/2ujhkr/important_api_licensing_terms_clarified/>`_
|
|
||||||
|
|
||||||
========
|
========
|
||||||
Settings
|
Settings
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ HELP = """
|
|||||||
`l` or `RIGHT` : Enter the selected submission
|
`l` or `RIGHT` : Enter the selected submission
|
||||||
`/` : Open a prompt to switch subreddits
|
`/` : Open a prompt to switch subreddits
|
||||||
`f` : Open a prompt to search the current subreddit
|
`f` : Open a prompt to search the current subreddit
|
||||||
|
'p' : Toggle between the front page and last visited subreddit
|
||||||
|
|
||||||
[Submission Mode]
|
[Submission Mode]
|
||||||
`h` or `LEFT` : Return to subreddit mode
|
`h` or `LEFT` : Return to subreddit mode
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ SUBREDDIT_OPEN = l, <KEY_RIGHT>
|
|||||||
SUBREDDIT_OPEN_IN_BROWSER = o, <LF>, <KEY_ENTER>, <KEY_ENTER>
|
SUBREDDIT_OPEN_IN_BROWSER = o, <LF>, <KEY_ENTER>, <KEY_ENTER>
|
||||||
SUBREDDIT_OPEN_SUBSCRIPTIONS = s
|
SUBREDDIT_OPEN_SUBSCRIPTIONS = s
|
||||||
SUBREDDIT_OPEN_MULTIREDDITS = S
|
SUBREDDIT_OPEN_MULTIREDDITS = S
|
||||||
|
SUBREDDIT_FRONTPAGE = p
|
||||||
|
|
||||||
; Subscription page
|
; Subscription page
|
||||||
SUBSCRIPTION_SELECT = l, <LF>, <KEY_ENTER>, <KEY_RIGHT>
|
SUBSCRIPTION_SELECT = l, <LF>, <KEY_ENTER>, <KEY_RIGHT>
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class SubredditPage(Page):
|
|||||||
self.controller = SubredditController(self, keymap=config.keymap)
|
self.controller = SubredditController(self, keymap=config.keymap)
|
||||||
self.content = SubredditContent.from_name(reddit, name, term.loader)
|
self.content = SubredditContent.from_name(reddit, name, term.loader)
|
||||||
self.nav = Navigator(self.content.get)
|
self.nav = Navigator(self.content.get)
|
||||||
|
self._toggled_subreddit = None
|
||||||
|
|
||||||
@SubredditController.register(Command('REFRESH'))
|
@SubredditController.register(Command('REFRESH'))
|
||||||
def refresh_content(self, order=None, name=None):
|
def refresh_content(self, order=None, name=None):
|
||||||
@@ -73,6 +74,23 @@ class SubredditPage(Page):
|
|||||||
if name is not None:
|
if name is not None:
|
||||||
self.refresh_content(order='ignore', name=name)
|
self.refresh_content(order='ignore', name=name)
|
||||||
|
|
||||||
|
@SubredditController.register(Command('SUBREDDIT_FRONTPAGE'))
|
||||||
|
def show_frontpage(self):
|
||||||
|
"""
|
||||||
|
If on a subreddit, remember it and head back to the front page.
|
||||||
|
If this was pressed on the front page, go back to the last subreddit.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not self.content.name == '/r/front':
|
||||||
|
target = '/r/front'
|
||||||
|
self._toggled_subreddit = self.content.name
|
||||||
|
else:
|
||||||
|
target = self._toggled_subreddit
|
||||||
|
|
||||||
|
# target still may be empty string if this command hasn't yet been used
|
||||||
|
if target is not None:
|
||||||
|
self.refresh_content(order='ignore', name=target)
|
||||||
|
|
||||||
@SubredditController.register(Command('SUBREDDIT_OPEN'))
|
@SubredditController.register(Command('SUBREDDIT_OPEN'))
|
||||||
def open_submission(self, url=None):
|
def open_submission(self, url=None):
|
||||||
"Select the current submission to view posts"
|
"Select the current submission to view posts"
|
||||||
|
|||||||
3088
tests/cassettes/test_subreddit_frontpage_toggle.yaml
Normal file
3088
tests/cassettes/test_subreddit_frontpage_toggle.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -226,3 +226,13 @@ def test_subreddit_draw_header(subreddit_page, refresh_token, terminal):
|
|||||||
subreddit_page.draw()
|
subreddit_page.draw()
|
||||||
text = 'My Submissions'.encode('utf-8')
|
text = 'My Submissions'.encode('utf-8')
|
||||||
terminal.stdscr.subwin.addstr.assert_any_call(0, 0, text)
|
terminal.stdscr.subwin.addstr.assert_any_call(0, 0, text)
|
||||||
|
|
||||||
|
|
||||||
|
def test_subreddit_frontpage_toggle(subreddit_page, terminal):
|
||||||
|
|
||||||
|
with mock.patch.object(terminal, 'prompt_input'):
|
||||||
|
terminal.prompt_input.return_value = 'aww'
|
||||||
|
subreddit_page.controller.trigger('/')
|
||||||
|
assert subreddit_page.content.name == '/r/aww'
|
||||||
|
subreddit_page.controller.trigger('p')
|
||||||
|
assert subreddit_page.content.name == '/r/front'
|
||||||
|
|||||||
Reference in New Issue
Block a user