Added functionality to open the submission link in the browser.

This commit is contained in:
Lawrence Vanderpool
2015-03-04 15:31:42 -05:00
parent 1d41e6d3ad
commit 77b1cd03d6

View File

@@ -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)