From 77b1cd03d62bf51acbfaddb6392fe43a01106a99 Mon Sep 17 00:00:00 2001 From: Lawrence Vanderpool Date: Wed, 4 Mar 2015 15:31:42 -0500 Subject: [PATCH 1/2] Added functionality to open the submission link in the browser. --- rtv/subreddit.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rtv/subreddit.py b/rtv/subreddit.py index d2501c0..d477d7d 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -1,5 +1,6 @@ import curses import sys +import webbrowser from requests.exceptions import HTTPError from .errors import SubredditNameError @@ -38,6 +39,9 @@ class SubredditPage(BasePage): self.open_submission() self.draw() + elif cmd == ord('o'): + self.open_link() + # Enter edit mode to change subreddit elif cmd == ord('/'): self.prompt_subreddit() @@ -128,3 +132,7 @@ class SubredditPage(BasePage): win.addnstr(row, 1, text, n_cols-1, curses.A_BOLD) text = ' {subreddit}'.format(**data) win.addnstr(text, n_cols - win.getyx()[1], Color.YELLOW) + + def open_link(self): + url = self.content.get(self.nav.absolute_index)['url'] + webbrowser.open_new_tab(url) From f25ab62d48f62c027e1f8d6424d0d2ddfccd4fa2 Mon Sep 17 00:00:00 2001 From: Lawrence Vanderpool Date: Wed, 4 Mar 2015 15:37:19 -0500 Subject: [PATCH 2/2] Updated README to reflect 'o' command --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index c3e9e92..4be1e42 100644 --- a/README.rst +++ b/README.rst @@ -54,6 +54,7 @@ In subreddit mode you can browse through the top submissions on either the front :``Right`` or ``Enter``: Open the currently selected submission in a new page. :``/``: Open a prompt to switch to a different subreddit. For example, pressing ``/`` and typing *python* will open */r/python*. You can return to Reddit's front page by using the alias */r/front*. +:``o``: Opens the url for a link-post in the default browser. **Submission Mode**