xposts should now work for subreddits.

This commit is contained in:
Michael Lazar
2016-07-08 00:33:34 -07:00
parent fa28b8fa7d
commit d26097e398
5 changed files with 797 additions and 2 deletions

View File

@@ -158,6 +158,7 @@ class Content(object):
data['nsfw'] = sub.over_18
data['stickied'] = sub.stickied
data['hidden'] = False
data['xpost_subreddit'] = None
data['index'] = None # This is filled in later by the method caller
if sub.url.split('/r/')[-1] == sub.permalink.split('/r/')[-1]:
@@ -167,6 +168,7 @@ class Content(object):
# Strip the subreddit name from the permalink to avoid having
# submission.subreddit.url make a separate API call
url_parts = sub.url.split('/')
data['xpost_subreddit'] = url_parts[4]
data['url'] = 'self.{0}'.format(url_parts[4])
if 'comments' in url_parts:
data['url_type'] = 'x-post submission'

View File

@@ -289,7 +289,7 @@ class Page(object):
else:
title = sub_name
title = title + ' - rtv {0}'.format(__version__)
title += ' - rtv {0}'.format(__version__)
sys.stdout.write('\x1b]2;{0}\x07'.format(title))
sys.stdout.flush()

View File

@@ -100,7 +100,9 @@ class SubredditPage(Page):
data = self.content.get(self.nav.absolute_index)
if data['url_type'] == 'selfpost':
self.open_submission()
elif data['url_type'] == 'x-post comment':
elif data['url_type'] == 'x-post subreddit':
self.refresh_content(order='ignore', name=data['xpost_subreddit'])
elif data['url_type'] == 'x-post submission':
self.open_submission(url=data['url_full'])
self.config.history.add(data['url_full'])
else: