Got the prompt working from submissions / subscriptions.
This commit is contained in:
@@ -14,6 +14,7 @@ Basic Commands
|
||||
:``1-5``: Toggle post order (*hot*, *top*, *rising*, *new*, *controversial*)
|
||||
:``r`` or ``F5``: Refresh page content
|
||||
:``u``: Log in or switch accounts
|
||||
:``/``: Open a prompt to switch subreddits
|
||||
:``?``: Show the help screen
|
||||
:``q``/``Q``: Quit/Force quit
|
||||
|
||||
@@ -43,7 +44,6 @@ In subreddit mode you can browse through the top submissions on either the front
|
||||
|
||||
:``l`` or ``►``: Enter the selected submission
|
||||
:``o`` or ``ENTER``: Open the submission link with your web browser
|
||||
:``/``: Open a prompt to switch subreddits
|
||||
:``f``: Open a prompt to search the current subreddit
|
||||
:``p``: Toggle between the front page and the last visited subreddit
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ https://github.com/michael-lazar/rtv
|
||||
1-5 : Toggle post order
|
||||
r or F5 : Refresh page content
|
||||
u : Log in or switch accounts
|
||||
/ : Open a prompt to switch subreddits
|
||||
? : Show the help screen
|
||||
q/Q : Quit/Force quit
|
||||
|
||||
@@ -45,7 +46,6 @@ https://github.com/michael-lazar/rtv
|
||||
[Subreddit Commands]
|
||||
l or ► : Enter the selected submission
|
||||
o or ENTER : Open the submission link with your web browser
|
||||
/ : Open a prompt to switch subreddits
|
||||
f : Open a prompt to search the current subreddit
|
||||
p : Return to the front page
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ class SubmissionPage(Page):
|
||||
self.content = SubmissionContent(submission, term.loader)
|
||||
# Start at the submission post, which is indexed as -1
|
||||
self.nav = Navigator(self.content.get, page_index=-1)
|
||||
self.subreddit_name = None
|
||||
|
||||
@SubmissionController.register(Command('SUBMISSION_TOGGLE_COMMENT'))
|
||||
def toggle_comment(self):
|
||||
@@ -67,6 +68,15 @@ class SubmissionPage(Page):
|
||||
if not self.term.loader.exception:
|
||||
self.nav = Navigator(self.content.get, page_index=-1)
|
||||
|
||||
@SubmissionController.register(Command('PROMPT'))
|
||||
def prompt_subreddit(self):
|
||||
"Open a prompt to navigate to a different subreddit"
|
||||
|
||||
name = self.term.prompt_input('Enter page: /')
|
||||
if name is not None:
|
||||
self.subreddit_name = name
|
||||
self.active = False
|
||||
|
||||
@SubmissionController.register(Command('SUBMISSION_OPEN_IN_BROWSER'))
|
||||
def open_link(self):
|
||||
"Open the selected item with the webbrowser"
|
||||
|
||||
@@ -66,7 +66,7 @@ class SubredditPage(Page):
|
||||
if not self.term.loader.exception:
|
||||
self.nav = Navigator(self.content.get)
|
||||
|
||||
@SubredditController.register(Command('SUBREDDIT_PROMPT'))
|
||||
@SubredditController.register(Command('PROMPT'))
|
||||
def prompt_subreddit(self):
|
||||
"Open a prompt to navigate to a different subreddit"
|
||||
|
||||
@@ -111,6 +111,12 @@ class SubredditPage(Page):
|
||||
if data.get('url_type') == 'selfpost':
|
||||
self.config.history.add(data['url_full'])
|
||||
|
||||
if page.subreddit_name is not None:
|
||||
self.refresh_content(order='ignore',
|
||||
name=page.subreddit_name)
|
||||
else:
|
||||
self.refresh_content()
|
||||
|
||||
@SubredditController.register(Command('SUBREDDIT_OPEN_IN_BROWSER'))
|
||||
def open_link(self):
|
||||
"Open a link with the webbrowser"
|
||||
@@ -167,7 +173,11 @@ class SubredditPage(Page):
|
||||
|
||||
page.loop()
|
||||
|
||||
self.refresh_content()
|
||||
if page.subreddit_name is not None:
|
||||
self.refresh_content(order='ignore',
|
||||
name=page.subreddit_name)
|
||||
else:
|
||||
self.refresh_content()
|
||||
|
||||
@SubredditController.register(Command('SUBREDDIT_OPEN_SUBSCRIPTIONS'))
|
||||
@logged_in
|
||||
@@ -184,9 +194,9 @@ class SubredditPage(Page):
|
||||
|
||||
# When the user has chosen a subreddit in the subscriptions list,
|
||||
# refresh content with the selected subreddit
|
||||
if page.subreddit_data is not None:
|
||||
if page.subreddit_name is not None:
|
||||
self.refresh_content(order='ignore',
|
||||
name=page.subreddit_data['name'])
|
||||
name=page.subreddit_name)
|
||||
|
||||
@SubredditController.register(Command('SUBREDDIT_OPEN_MULTIREDDITS'))
|
||||
@logged_in
|
||||
@@ -203,9 +213,9 @@ class SubredditPage(Page):
|
||||
|
||||
# When the user has chosen a subreddit in the subscriptions list,
|
||||
# refresh content with the selected subreddit
|
||||
if page.subreddit_data is not None:
|
||||
if page.subreddit_name is not None:
|
||||
self.refresh_content(order='ignore',
|
||||
name=page.subreddit_data['name'])
|
||||
name=page.subreddit_name)
|
||||
|
||||
def _draw_item(self, win, data, inverted):
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class SubscriptionPage(Page):
|
||||
reddit, term.loader, content_type)
|
||||
self.nav = Navigator(self.content.get)
|
||||
self.content_type = content_type
|
||||
self.subreddit_data = None
|
||||
self.subreddit_name = None
|
||||
|
||||
@SubscriptionController.register(Command('REFRESH'))
|
||||
def refresh_content(self, order=None, name=None):
|
||||
@@ -39,11 +39,20 @@ class SubscriptionPage(Page):
|
||||
if not self.term.loader.exception:
|
||||
self.nav = Navigator(self.content.get)
|
||||
|
||||
@SubscriptionController.register(Command('PROMPT'))
|
||||
def prompt_subreddit(self):
|
||||
"Open a prompt to navigate to a different subreddit"
|
||||
|
||||
name = self.term.prompt_input('Enter page: /')
|
||||
if name is not None:
|
||||
self.subreddit_name = name
|
||||
self.active = False
|
||||
|
||||
@SubscriptionController.register(Command('SUBSCRIPTION_SELECT'))
|
||||
def select_subreddit(self):
|
||||
"Store the selected subreddit and return to the subreddit page"
|
||||
|
||||
self.subreddit_data = self.content.get(self.nav.absolute_index)
|
||||
self.subreddit_name = self.content.get(self.nav.absolute_index)['name']
|
||||
self.active = False
|
||||
|
||||
@SubscriptionController.register(Command('SUBSCRIPTION_EXIT'))
|
||||
|
||||
@@ -110,6 +110,7 @@ DELETE = d
|
||||
EDIT = e
|
||||
INBOX = i
|
||||
REFRESH = r, <KEY_F5>
|
||||
PROMPT = /
|
||||
SAVE = w
|
||||
|
||||
; Submission page
|
||||
@@ -122,7 +123,6 @@ SUBMISSION_OPEN_IN_URLVIEWER = b
|
||||
|
||||
; Subreddit page
|
||||
SUBREDDIT_SEARCH = f
|
||||
SUBREDDIT_PROMPT = /
|
||||
SUBREDDIT_POST = c
|
||||
SUBREDDIT_OPEN = l, <KEY_RIGHT>
|
||||
SUBREDDIT_OPEN_IN_BROWSER = o, <LF>, <KEY_ENTER>, <KEY_ENTER>
|
||||
|
||||
@@ -110,17 +110,17 @@ def test_subscription_select(subscription_page):
|
||||
|
||||
# Select a subreddit
|
||||
subscription_page.controller.trigger(curses.KEY_ENTER)
|
||||
assert subscription_page.subreddit_data is not None
|
||||
assert subscription_page.subreddit_name is not None
|
||||
assert subscription_page.active is False
|
||||
|
||||
|
||||
def test_subscription_close(subscription_page):
|
||||
|
||||
# Close the subscriptions page
|
||||
subscription_page.subreddit_data = None
|
||||
subscription_page.subreddit_name = None
|
||||
subscription_page.active = None
|
||||
subscription_page.controller.trigger('h')
|
||||
assert subscription_page.subreddit_data is None
|
||||
assert subscription_page.subreddit_name is None
|
||||
assert subscription_page.active is False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user