Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Add key bindings to open subreddit and user page #688

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rtv/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
SPACE : Mark the selected submission as hidden
p : Toggle between the currently viewed subreddit and /r/front
f : Open a prompt to search the current subreddit for a text string
v : Open the subreddit for the selected submission
V : Open the authors user page for the selected submission

[Submission Mode]
h : Close the submission and return to the previous page
Expand All @@ -78,6 +80,7 @@
b : Send the comment text to the system's urlviewer application
J : Move the cursor down the the next comment at the same indentation
K : Move the cursor up to the parent comment
V : Open the authors user page for the selected comment

[Subscription Mode]
h : Close your subscriptions and return to the previous page
Expand Down
24 changes: 24 additions & 0 deletions rtv/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,30 @@ def downvote(self):
if not self.term.loader.exception:
data['likes'] = None

@PageController.register(Command('OPEN_SUBREDDIT'))
def open_subreddit(self):
"""
Open the subreddit associated with the currently selected item.
"""
data = self.get_selected_item()
if 'subreddit' in data:
subreddit = data['subreddit']
self.selected_page = self.open_subreddit_page(subreddit)
else:
self.term.flash()

@PageController.register(Command('OPEN_USERPAGE'))
def open_userpage(self):
"""
Open the authors user page for the currently selected item.
"""
data = self.get_selected_item()
if 'author' in data:
author = data['author']
self.selected_page = self.open_subreddit_page('u/' + author)
else:
self.term.flash()

@PageController.register(Command('SAVE'))
@logged_in
def save(self):
Expand Down
2 changes: 2 additions & 0 deletions rtv/templates/rtv.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ COPY_URL = Y
PRIVATE_MESSAGE = C
SUBSCRIPTIONS = s
MULTIREDDITS = S
OPEN_SUBREDDIT = v
OPEN_USERPAGE = V

; Submission page
SUBMISSION_TOGGLE_COMMENT = 0x20
Expand Down