From 11a322a9c3438d508fdff483ec166d4e17fcbdc5 Mon Sep 17 00:00:00 2001 From: Gustavo Zambonin Date: Wed, 14 Oct 2015 00:37:51 -0300 Subject: [PATCH 1/5] content.py: name of the subreddit shown on selfpost 'url' all flairs now have brackets --- rtv/content.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rtv/content.py b/rtv/content.py index 62cfaaf..6384896 100644 --- a/rtv/content.py +++ b/rtv/content.py @@ -131,9 +131,12 @@ class BaseContent(object): data['flair'] = flair data['url_full'] = sub.url + if flair is not None and flair[0] != '[': + data['flair'] = '[{}]'.format(flair.strip()) + if data['permalink'].split('/r/')[-1] == data['url_full'].split('/r/')[-1]: data['url_type'] = 'selfpost' - data['url'] = 'selfpost' + data['url'] = 'self.{}'.format(data['subreddit']) elif reddit_link.match(data['url_full']): data['url_type'] = 'x-post' From 2358eed46ec09b59429c761bc105335e030991fb Mon Sep 17 00:00:00 2001 From: Gustavo Zambonin Date: Wed, 14 Oct 2015 00:39:47 -0300 Subject: [PATCH 2/5] page.py: exit prompt added logout prompt now works as intended --- rtv/oauth.py | 2 +- rtv/page.py | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/rtv/oauth.py b/rtv/oauth.py index 62aee86..6d73cc4 100644 --- a/rtv/oauth.py +++ b/rtv/oauth.py @@ -106,7 +106,7 @@ class OAuthTool(object): except (praw.errors.OAuthAppRequired, praw.errors.OAuthInvalidToken): show_notification(self.stdscr, ['Invalid OAuth data']) else: - message = ['Welcome {}!'.format(self.reddit.user.name)] + message = ['Welcome, {}!'.format(self.reddit.user.name)] show_notification(self.stdscr, message) def clear_oauth_data(self): diff --git a/rtv/page.py b/rtv/page.py index b4a4dde..396d5f7 100644 --- a/rtv/page.py +++ b/rtv/page.py @@ -265,7 +265,15 @@ class BasePage(object): @BaseController.register('q') def exit(self): - sys.exit() + """ + Prompt to exit the application. + """ + + ch = prompt_input(self.stdscr, "Do you really want to quit? (y/n): ") + if ch == 'y': + sys.exit() + elif ch != 'n': + curses.flash() @BaseController.register('?') def help(self): @@ -350,8 +358,12 @@ class BasePage(object): """ if self.reddit.is_oauth_session(): - self.oauth.clear_oauth_data() - show_notification(self.stdscr, ['Logged out']) + ch = prompt_input(self.stdscr, "Log out? (y/n): ") + if ch == 'y': + self.reddit.clear_authentication() + show_notification(self.stdscr, ['Logged out']) + elif ch != 'n': + curses.flash() else: self.oauth.authorize() @@ -370,7 +382,7 @@ class BasePage(object): curses.flash() return - prompt = 'Are you sure you want to delete this? (y/n):' + prompt = 'Are you sure you want to delete this? (y/n): ' char = prompt_input(self.stdscr, prompt) if char != 'y': show_notification(self.stdscr, ['Aborted']) @@ -446,18 +458,6 @@ class BasePage(object): continue self.stdscr.nodelay(0) - def logout(self): - """ - Prompt to log out of the user's account. - """ - - ch = prompt_input(self.stdscr, "Log out? (y/n):") - if ch == 'y': - self.reddit.clear_authentication() - show_notification(self.stdscr, ['Logged out']) - elif ch != 'n': - curses.flash() - @property def safe_call(self): """ From 21d5c7acca46179d4f51063608567f1845158a13 Mon Sep 17 00:00:00 2001 From: Gustavo Zambonin Date: Wed, 14 Oct 2015 18:54:21 -0300 Subject: [PATCH 3/5] content.py: empty flair case fixed x-post and self post are now consistent --- rtv/content.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rtv/content.py b/rtv/content.py index 6384896..8d32258 100644 --- a/rtv/content.py +++ b/rtv/content.py @@ -131,7 +131,7 @@ class BaseContent(object): data['flair'] = flair data['url_full'] = sub.url - if flair is not None and flair[0] != '[': + if flair and not flair.startswith('['): data['flair'] = '[{}]'.format(flair.strip()) if data['permalink'].split('/r/')[-1] == data['url_full'].split('/r/')[-1]: @@ -140,7 +140,7 @@ class BaseContent(object): elif reddit_link.match(data['url_full']): data['url_type'] = 'x-post' - data['url'] = 'x-post via {}'.format(strip_subreddit_url(data['url_full'])) + data['url'] = 'x-post via {}'.format(data['subreddit']) else: data['url_type'] = 'external' @@ -167,6 +167,7 @@ class BaseContent(object): return data + class SubmissionContent(BaseContent): """ Grab a submission from PRAW and lazily store comments to an internal @@ -387,6 +388,7 @@ class SubredditContent(BaseContent): return data + class SubscriptionContent(BaseContent): def __init__(self, subscriptions, loader): @@ -409,8 +411,8 @@ class SubscriptionContent(BaseContent): def get(self, index, n_cols=70): """ - Grab the `i`th subscription, with the title field formatted to fit inside - of a window of width `n_cols` + Grab the `i`th subscription, with the title field formatted to fit + inside of a window of width `n_cols` """ if index < 0: From c2065e00b5e500ac6f84fe82542eb69f790d1831 Mon Sep 17 00:00:00 2001 From: Gustavo Zambonin Date: Wed, 14 Oct 2015 19:12:02 -0300 Subject: [PATCH 4/5] content.py: correct subreddit on xpost info --- rtv/content.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rtv/content.py b/rtv/content.py index 8d32258..f8c5b68 100644 --- a/rtv/content.py +++ b/rtv/content.py @@ -140,7 +140,8 @@ class BaseContent(object): elif reddit_link.match(data['url_full']): data['url_type'] = 'x-post' - data['url'] = 'x-post via {}'.format(data['subreddit']) + data['url'] = 'x-post via {}'.format(strip_subreddit_url( + data['url_full'])[3:]) else: data['url_type'] = 'external' From b7f3f8db4b4300cada5de1e01e43c1ba5e18a3c3 Mon Sep 17 00:00:00 2001 From: Gustavo Zambonin Date: Wed, 14 Oct 2015 19:32:17 -0300 Subject: [PATCH 5/5] content.py: more standardization --- rtv/content.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rtv/content.py b/rtv/content.py index f8c5b68..89b38ea 100644 --- a/rtv/content.py +++ b/rtv/content.py @@ -140,8 +140,8 @@ class BaseContent(object): elif reddit_link.match(data['url_full']): data['url_type'] = 'x-post' - data['url'] = 'x-post via {}'.format(strip_subreddit_url( - data['url_full'])[3:]) + data['url'] = 'self.{}'.format(strip_subreddit_url( + data['url_full'])[3:]) else: data['url_type'] = 'external'