Merge pull request #365 from michael-lazar/open_submission_from_comments_page
Allow opening of submission link from the comments page with the `o` key
This commit is contained in:
@@ -94,15 +94,18 @@ class SubmissionPage(Page):
|
|||||||
"Open the selected item with the webbrowser"
|
"Open the selected item with the webbrowser"
|
||||||
|
|
||||||
data = self.get_selected_item()
|
data = self.get_selected_item()
|
||||||
url = data.get('permalink')
|
if data['type'] == 'Submission':
|
||||||
if url:
|
self.term.open_link(data['url_full'])
|
||||||
self.term.open_browser(url)
|
self.config.history.add(data['url_full'])
|
||||||
|
elif data['type'] == 'Comment' and data['permalink']:
|
||||||
|
self.term.open_browser(data['permalink'])
|
||||||
else:
|
else:
|
||||||
self.term.flash()
|
self.term.flash()
|
||||||
|
|
||||||
@SubmissionController.register(Command('SUBMISSION_OPEN_IN_PAGER'))
|
@SubmissionController.register(Command('SUBMISSION_OPEN_IN_PAGER'))
|
||||||
def open_pager(self):
|
def open_pager(self):
|
||||||
"Open the selected item with the system's pager"
|
"Open the selected item with the system's pager"
|
||||||
|
|
||||||
data = self.get_selected_item()
|
data = self.get_selected_item()
|
||||||
if data['type'] == 'Submission':
|
if data['type'] == 'Submission':
|
||||||
text = '\n\n'.join((data['permalink'], data['text']))
|
text = '\n\n'.join((data['permalink'], data['text']))
|
||||||
@@ -279,7 +282,9 @@ class SubmissionPage(Page):
|
|||||||
self.term.add_line(win, ' {created} {subreddit}'.format(**data))
|
self.term.add_line(win, ' {created} {subreddit}'.format(**data))
|
||||||
|
|
||||||
row = len(data['split_title']) + 2
|
row = len(data['split_title']) + 2
|
||||||
attr = curses.A_UNDERLINE | Color.BLUE
|
seen = (data['url_full'] in self.config.history)
|
||||||
|
link_color = Color.MAGENTA if seen else Color.BLUE
|
||||||
|
attr = curses.A_UNDERLINE | link_color
|
||||||
self.term.add_line(win, '{url}'.format(**data), row, 1, attr)
|
self.term.add_line(win, '{url}'.format(**data), row, 1, attr)
|
||||||
offset = len(data['split_title']) + 3
|
offset = len(data['split_title']) + 3
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user