Merge branch 'topnew'
Updating to master.
This commit is contained in:
@@ -299,6 +299,8 @@ class SubredditContent(BaseContent):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_name(cls, reddit, name, loader=default_loader):
|
def from_name(cls, reddit, name, loader=default_loader):
|
||||||
|
|
||||||
|
display_type = 'normal'
|
||||||
|
|
||||||
if name == 'front':
|
if name == 'front':
|
||||||
return cls('Front Page', reddit.get_front_page(limit=None), loader)
|
return cls('Front Page', reddit.get_front_page(limit=None), loader)
|
||||||
|
|
||||||
@@ -306,18 +308,37 @@ class SubredditContent(BaseContent):
|
|||||||
sub = reddit.get_subreddit(name)
|
sub = reddit.get_subreddit(name)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
if '/' in name:
|
||||||
|
parse = name.split('/')
|
||||||
|
name = parse[0]
|
||||||
|
|
||||||
|
if parse[1] == 'top':
|
||||||
|
display_type = 'top'
|
||||||
|
|
||||||
|
elif parse[1] == 'new':
|
||||||
|
display_type = 'new'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with loader():
|
with loader():
|
||||||
sub = reddit.get_subreddit(name, fetch=True)
|
sub = reddit.get_subreddit(name, fetch=True)
|
||||||
except praw.errors.ClientException:
|
except praw.errors.ClientException:
|
||||||
raise SubredditNameError(name)
|
raise SubredditNameError(name)
|
||||||
|
|
||||||
|
if display_type == 'top':
|
||||||
|
return cls('/r/'+sub.display_name, sub.get_top_from_all(limit=None), loader)
|
||||||
|
|
||||||
|
elif display_type == 'new':
|
||||||
|
return cls('/r/'+sub.display_name, sub.get_new(limit=None), loader)
|
||||||
|
|
||||||
|
else:
|
||||||
return cls('/r/'+sub.display_name, sub.get_hot(limit=None), loader)
|
return cls('/r/'+sub.display_name, sub.get_hot(limit=None), loader)
|
||||||
|
|
||||||
def get(self, index, n_cols=70):
|
def get(self, index, n_cols=70):
|
||||||
"""
|
"""
|
||||||
Grab the `i`th submission, with the title field formatted to fit inside
|
Grab the `i`th submission, with the title field formatted to fit inside
|
||||||
of a window of width `n`
|
of a window of width `n`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if index < 0:
|
if index < 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user