Merge remote-tracking branch 'origin/master' into cleanup
This commit is contained in:
@@ -71,6 +71,7 @@ In subreddit mode you can browse through the top submissions on either the front
|
|||||||
:``►`` or ``l``: View comments for the selected submission
|
:``►`` or ``l``: View comments for the selected submission
|
||||||
:``/``: Open a prompt to switch subreddits
|
:``/``: Open a prompt to switch subreddits
|
||||||
:``f``: Open a prompt to search the current subreddit
|
:``f``: Open a prompt to search the current subreddit
|
||||||
|
:``p``: Post a Submission to the current subreddit
|
||||||
|
|
||||||
The ``/`` prompt accepts subreddits in the following formats
|
The ``/`` prompt accepts subreddits in the following formats
|
||||||
|
|
||||||
@@ -78,6 +79,7 @@ The ``/`` prompt accepts subreddits in the following formats
|
|||||||
* ``/r/python/new``
|
* ``/r/python/new``
|
||||||
* ``/r/python+linux`` supports multireddits
|
* ``/r/python+linux`` supports multireddits
|
||||||
* ``/r/front`` will redirect to the front page
|
* ``/r/front`` will redirect to the front page
|
||||||
|
* ``/r/me`` will show you your submissions on all subs
|
||||||
|
|
||||||
**Submission Mode**
|
**Submission Mode**
|
||||||
|
|
||||||
|
|||||||
@@ -304,6 +304,18 @@ class SubredditContent(BaseContent):
|
|||||||
|
|
||||||
return cls(display_name, submissions, loader)
|
return cls(display_name, submissions, loader)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_redditor(cls, reddit, loader, order='new'):
|
||||||
|
submissions = reddit.user.get_submitted(sort=order)
|
||||||
|
display_name = '/r/me'
|
||||||
|
content = cls(display_name, submissions, loader)
|
||||||
|
try:
|
||||||
|
content.get(0)
|
||||||
|
except (praw.errors.APIException, requests.HTTPError,
|
||||||
|
praw.errors.RedirectException):
|
||||||
|
raise SubredditError(display_name)
|
||||||
|
return content
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ Subreddit Mode
|
|||||||
`RIGHT` or `l` : View comments for the selected submission
|
`RIGHT` or `l` : View comments for the selected submission
|
||||||
`/` : Open a prompt to switch subreddits
|
`/` : Open a prompt to switch subreddits
|
||||||
`f` : Open a prompt to search the current subreddit
|
`f` : Open a prompt to search the current subreddit
|
||||||
|
`p` : Post a Submission to the current subreddit
|
||||||
|
|
||||||
Submission Mode
|
Submission Mode
|
||||||
`LEFT` or `h` : Return to subreddit mode
|
`LEFT` or `h` : Return to subreddit mode
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class SubmissionPage(BasePage):
|
|||||||
else:
|
else:
|
||||||
raise ValueError('Must specify url or submission')
|
raise ValueError('Must specify url or submission')
|
||||||
|
|
||||||
super(SubmissionPage, self).__init__(stdscr, reddit, content,
|
super(SubmissionPage, self).__init__(stdscr, reddit,
|
||||||
page_index=-1)
|
content, page_index=-1)
|
||||||
|
|
||||||
def loop(self):
|
def loop(self):
|
||||||
self.active = True
|
self.active = True
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ class SubredditPage(BasePage):
|
|||||||
@SubredditController.register(curses.KEY_F5, 'r')
|
@SubredditController.register(curses.KEY_F5, 'r')
|
||||||
def refresh_content(self, name=None):
|
def refresh_content(self, name=None):
|
||||||
name = name or self.content.name
|
name = name or self.content.name
|
||||||
|
if name == 'me' or name == '/r/me':
|
||||||
|
self.redditor_profile()
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
self.content = SubredditContent.from_name(
|
self.content = SubredditContent.from_name(
|
||||||
self.reddit, name, self.loader)
|
self.reddit, name, self.loader)
|
||||||
@@ -74,6 +76,16 @@ class SubredditPage(BasePage):
|
|||||||
if name is not None:
|
if name is not None:
|
||||||
self.refresh_content(name=name)
|
self.refresh_content(name=name)
|
||||||
|
|
||||||
|
def redditor_profile(self):
|
||||||
|
if self.reddit.is_logged_in():
|
||||||
|
try:
|
||||||
|
self.content = SubredditContent.from_redditor(
|
||||||
|
self.reddit, self.loader)
|
||||||
|
except requests.HTTPError:
|
||||||
|
show_notification(self.stdscr, ['Could not reach subreddit'])
|
||||||
|
else:
|
||||||
|
show_notification(self.stdscr, ['Log in to view your submissions'])
|
||||||
|
|
||||||
@SubredditController.register(curses.KEY_RIGHT, 'l')
|
@SubredditController.register(curses.KEY_RIGHT, 'l')
|
||||||
def open_submission(self):
|
def open_submission(self):
|
||||||
"Select the current submission to view posts"
|
"Select the current submission to view posts"
|
||||||
|
|||||||
Reference in New Issue
Block a user