Fixed browser links to selfposts. Added links to the submission page. #21

This commit is contained in:
Michael Lazar
2015-03-04 22:58:36 -08:00
parent 46be3d6833
commit 4e5f564db5
3 changed files with 19 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
import curses
import sys
import webbrowser
import six
@@ -36,24 +37,23 @@ class SubmissionPage(BasePage):
self.move_cursor_down()
self.clear_input_queue()
# Refresh page
elif cmd in (curses.KEY_F5, ord('r')):
self.refresh_content()
self.draw()
# Show / hide a comment tree
elif cmd in (curses.KEY_RIGHT, curses.KEY_ENTER, ord('l')):
self.toggle_comment()
self.draw()
elif cmd == ord('o'):
self.open_link()
elif cmd == curses.KEY_RESIZE:
self.draw()
# Go back
elif cmd in (ESCAPE, curses.KEY_LEFT, ord('h')):
break
# Quit
elif cmd == ord('q'):
sys.exit()
@@ -70,6 +70,13 @@ class SubmissionPage(BasePage):
self.nav.page_index, self.nav.cursor_index = -1, 0
self.nav.inverted = False
def open_link(self):
# Always open the page for the submission
# May want to expand at some point to open comment permalinks
url = self.content.get(-1)['permalink']
webbrowser.open_new_tab(url)
def draw_item(self, win, data, inverted=False):
if data['type'] == 'MoreComments':