Added functionality to open the submission link in the browser.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import curses
|
import curses
|
||||||
import sys
|
import sys
|
||||||
|
import webbrowser
|
||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
|
|
||||||
from .errors import SubredditNameError
|
from .errors import SubredditNameError
|
||||||
@@ -38,6 +39,9 @@ class SubredditPage(BasePage):
|
|||||||
self.open_submission()
|
self.open_submission()
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
|
elif cmd == ord('o'):
|
||||||
|
self.open_link()
|
||||||
|
|
||||||
# Enter edit mode to change subreddit
|
# Enter edit mode to change subreddit
|
||||||
elif cmd == ord('/'):
|
elif cmd == ord('/'):
|
||||||
self.prompt_subreddit()
|
self.prompt_subreddit()
|
||||||
@@ -128,3 +132,7 @@ class SubredditPage(BasePage):
|
|||||||
win.addnstr(row, 1, text, n_cols-1, curses.A_BOLD)
|
win.addnstr(row, 1, text, n_cols-1, curses.A_BOLD)
|
||||||
text = ' {subreddit}'.format(**data)
|
text = ' {subreddit}'.format(**data)
|
||||||
win.addnstr(text, n_cols - win.getyx()[1], Color.YELLOW)
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user