Merge branch 'zambonin-master'
This commit is contained in:
@@ -135,17 +135,19 @@ class BaseContent(object):
|
|||||||
data['nsfw'] = sub.over_18
|
data['nsfw'] = sub.over_18
|
||||||
data['index'] = None # This is filled in later by the method caller
|
data['index'] = None # This is filled in later by the method caller
|
||||||
|
|
||||||
if data['permalink'].split('/r/')[-1] == data['url_full'].split('/r/')[-1]:
|
if data['flair'] and not data['flair'].startswith('['):
|
||||||
|
data['flair'] = '[{}]'.format(data['flair'].strip())
|
||||||
|
|
||||||
|
url_full = data['url_full']
|
||||||
|
if data['permalink'].split('/r/')[-1] == url_full.split('/r/')[-1]:
|
||||||
data['url_type'] = 'selfpost'
|
data['url_type'] = 'selfpost'
|
||||||
data['url'] = 'selfpost'
|
data['url'] = 'self.{}'.format(data['subreddit'])
|
||||||
|
elif reddit_link.match(url_full):
|
||||||
elif reddit_link.match(data['url_full']):
|
|
||||||
data['url_type'] = 'x-post'
|
data['url_type'] = 'x-post'
|
||||||
data['url'] = 'x-post via {}'.format(strip_subreddit_url(data['url_full']))
|
data['url'] = 'self.{}'.format(strip_subreddit_url(url_full)[3:])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
data['url_type'] = 'external'
|
data['url_type'] = 'external'
|
||||||
data['url'] = data['url_full']
|
data['url'] = url_full
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -164,6 +166,7 @@ class BaseContent(object):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
class SubmissionContent(BaseContent):
|
class SubmissionContent(BaseContent):
|
||||||
"""
|
"""
|
||||||
Grab a submission from PRAW and lazily store comments to an internal
|
Grab a submission from PRAW and lazily store comments to an internal
|
||||||
@@ -387,6 +390,7 @@ class SubredditContent(BaseContent):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
class SubscriptionContent(BaseContent):
|
class SubscriptionContent(BaseContent):
|
||||||
|
|
||||||
def __init__(self, subscriptions, loader):
|
def __init__(self, subscriptions, loader):
|
||||||
@@ -409,8 +413,8 @@ class SubscriptionContent(BaseContent):
|
|||||||
|
|
||||||
def get(self, index, n_cols=70):
|
def get(self, index, n_cols=70):
|
||||||
"""
|
"""
|
||||||
Grab the `i`th subscription, with the title field formatted to fit inside
|
Grab the `i`th subscription, with the title field formatted to fit
|
||||||
of a window of width `n_cols`
|
inside of a window of width `n_cols`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if index < 0:
|
if index < 0:
|
||||||
|
|||||||
32
rtv/page.py
32
rtv/page.py
@@ -265,7 +265,15 @@ class BasePage(object):
|
|||||||
|
|
||||||
@BaseController.register('q')
|
@BaseController.register('q')
|
||||||
def exit(self):
|
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('?')
|
@BaseController.register('?')
|
||||||
def help(self):
|
def help(self):
|
||||||
@@ -350,8 +358,12 @@ class BasePage(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if self.reddit.is_oauth_session():
|
if self.reddit.is_oauth_session():
|
||||||
self.oauth.clear_oauth_data()
|
ch = prompt_input(self.stdscr, "Log out? (y/n): ")
|
||||||
show_notification(self.stdscr, ['Logged out'])
|
if ch == 'y':
|
||||||
|
self.oauth.clear_oauth_data()
|
||||||
|
show_notification(self.stdscr, ['Logged out'])
|
||||||
|
elif ch != 'n':
|
||||||
|
curses.flash()
|
||||||
else:
|
else:
|
||||||
self.oauth.authorize()
|
self.oauth.authorize()
|
||||||
|
|
||||||
@@ -370,7 +382,7 @@ class BasePage(object):
|
|||||||
curses.flash()
|
curses.flash()
|
||||||
return
|
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)
|
char = prompt_input(self.stdscr, prompt)
|
||||||
if char != 'y':
|
if char != 'y':
|
||||||
show_notification(self.stdscr, ['Aborted'])
|
show_notification(self.stdscr, ['Aborted'])
|
||||||
@@ -446,18 +458,6 @@ class BasePage(object):
|
|||||||
continue
|
continue
|
||||||
self.stdscr.nodelay(0)
|
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
|
@property
|
||||||
def safe_call(self):
|
def safe_call(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user