Merge branch 'master' into unicode_investigation
Conflicts: rtv/content.py rtv/main.py rtv/submission.py rtv/subreddit.py
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
.*
|
.*
|
||||||
*.pyc
|
*.pyc
|
||||||
|
scripts/*
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ RTV currently supports browsing both subreddits and individual submissions. In e
|
|||||||
:``▲``/``▼`` or ``j``/``k``: Scroll to the prev/next item
|
:``▲``/``▼`` or ``j``/``k``: Scroll to the prev/next item
|
||||||
:``o``: Open the selected item in the default web browser
|
:``o``: Open the selected item in the default web browser
|
||||||
:``r`` or ``F5``: Refresh the current page
|
:``r`` or ``F5``: Refresh the current page
|
||||||
|
:``?``: Show the help message
|
||||||
:``q``: Quit
|
:``q``: Quit
|
||||||
|
|
||||||
**Subreddit Mode**
|
**Subreddit Mode**
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from datetime import datetime
|
|||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
import praw
|
import praw
|
||||||
|
import six
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from .errors import SubmissionURLError, SubredditNameError
|
from .errors import SubmissionURLError, SubredditNameError
|
||||||
@@ -123,6 +124,7 @@ class BaseContent(object):
|
|||||||
sub_author = (comment.submission.author.name if
|
sub_author = (comment.submission.author.name if
|
||||||
getattr(comment.submission, 'author') else '[deleted]')
|
getattr(comment.submission, 'author') else '[deleted]')
|
||||||
data['is_author'] = (data['author'] == sub_author)
|
data['is_author'] = (data['author'] == sub_author)
|
||||||
|
data['flair'] = (comment.author_flair_text if comment.author_flair_text else "")
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -147,6 +149,7 @@ class BaseContent(object):
|
|||||||
else '[deleted]')
|
else '[deleted]')
|
||||||
data['permalink'] = sub.permalink
|
data['permalink'] = sub.permalink
|
||||||
data['subreddit'] = strip_subreddit_url(sub.permalink)
|
data['subreddit'] = strip_subreddit_url(sub.permalink)
|
||||||
|
data['flair'] = (sub.link_flair_text if sub.link_flair_text else "")
|
||||||
data['url_full'] = sub.url
|
data['url_full'] = sub.url
|
||||||
data['url'] = ('selfpost' if is_selfpost(sub.url) else sub.url)
|
data['url'] = ('selfpost' if is_selfpost(sub.url) else sub.url)
|
||||||
|
|
||||||
@@ -342,11 +345,11 @@ class SubredditContent(BaseContent):
|
|||||||
# there is is no other way to check things like multireddits that
|
# there is is no other way to check things like multireddits that
|
||||||
# don't have a real corresponding subreddit object.
|
# don't have a real corresponding subreddit object.
|
||||||
content = cls(display_name, submissions, loader)
|
content = cls(display_name, submissions, loader)
|
||||||
#try:
|
try:
|
||||||
content.get(0)
|
content.get(0)
|
||||||
#except:
|
except:
|
||||||
# # TODO: Trap specific errors
|
# TODO: Trap specific errors
|
||||||
# raise SubredditNameError(display_name)
|
raise SubredditNameError(display_name)
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ def main():
|
|||||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||||
parser.add_argument('-s', dest='subreddit', help='subreddit name')
|
parser.add_argument('-s', dest='subreddit', help='subreddit name')
|
||||||
parser.add_argument('-l', dest='link', help='full link to a submission')
|
parser.add_argument('-l', dest='link', help='full link to a submission')
|
||||||
parser.add_argument('--force-ascii', dest='force_ascii',
|
parser.add_argument('--unicode', help='enable unicode (beta)',
|
||||||
help='disable unicode', action='store_true')
|
action='store_true')
|
||||||
|
|
||||||
group = parser.add_argument_group(
|
group = parser.add_argument_group(
|
||||||
'authentication (optional)',
|
'authentication (optional)',
|
||||||
@@ -64,7 +64,7 @@ def main():
|
|||||||
if getattr(args, key) is None:
|
if getattr(args, key) is None:
|
||||||
setattr(args, key, val)
|
setattr(args, key, val)
|
||||||
|
|
||||||
utils.FORCE_ASCII = args.force_ascii
|
utils.UNICODE = args.unicode
|
||||||
|
|
||||||
if args.subreddit is None:
|
if args.subreddit is None:
|
||||||
args.subreddit = 'front'
|
args.subreddit = 'front'
|
||||||
|
|||||||
@@ -99,8 +99,7 @@ class SubmissionPage(BasePage):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def draw_comment(win, data, inverted=False):
|
def draw_comment(win, data, inverted=False):
|
||||||
import logging
|
|
||||||
_logger = logging.getLogger(__name__)
|
|
||||||
n_rows, n_cols = win.getmaxyx()
|
n_rows, n_cols = win.getmaxyx()
|
||||||
n_cols -= 1
|
n_cols -= 1
|
||||||
|
|
||||||
@@ -114,13 +113,15 @@ class SubmissionPage(BasePage):
|
|||||||
attr = curses.A_BOLD
|
attr = curses.A_BOLD
|
||||||
attr |= (Color.BLUE if not data['is_author'] else Color.GREEN)
|
attr |= (Color.BLUE if not data['is_author'] else Color.GREEN)
|
||||||
win.addnstr(row, 1, clean(text), n_cols-1, attr)
|
win.addnstr(row, 1, clean(text), n_cols-1, attr)
|
||||||
|
text = ' {flair}'.format(**data)
|
||||||
|
win.addnstr(clean(text), n_cols-win.getyx()[1], curses.A_BOLD | Color.YELLOW)
|
||||||
text = ' {score} {created}'.format(**data)
|
text = ' {score} {created}'.format(**data)
|
||||||
win.addnstr(clean(text), n_cols - win.getyx()[1])
|
win.addnstr(clean(text), n_cols - win.getyx()[1])
|
||||||
|
|
||||||
n_body = len(data['split_body'])
|
n_body = len(data['split_body'])
|
||||||
for row, text in enumerate(data['split_body'], start=offset+1):
|
for row, text in enumerate(data['split_body'], start=offset+1):
|
||||||
if row in valid_rows:
|
if row in valid_rows:
|
||||||
win.addnstr(row, 1, clean(text), n_cols-50)
|
win.addnstr(row, 1, clean(text), n_cols-1)
|
||||||
|
|
||||||
# Vertical line, unfortunately vline() doesn't support custom color so
|
# Vertical line, unfortunately vline() doesn't support custom color so
|
||||||
# we have to build it one chr at a time.
|
# we have to build it one chr at a time.
|
||||||
@@ -174,6 +175,8 @@ class SubmissionPage(BasePage):
|
|||||||
attr = curses.A_BOLD | Color.GREEN
|
attr = curses.A_BOLD | Color.GREEN
|
||||||
text = '{author}'.format(**data)
|
text = '{author}'.format(**data)
|
||||||
win.addnstr(row, 1, clean(text), n_cols, attr)
|
win.addnstr(row, 1, clean(text), n_cols, attr)
|
||||||
|
text = ' {flair}'.format(**data)
|
||||||
|
win.addnstr(clean(text), n_cols-win.getyx()[1], curses.A_BOLD | Color.YELLOW)
|
||||||
text = ' {created} {subreddit}'.format(**data)
|
text = ' {created} {subreddit}'.format(**data)
|
||||||
win.addnstr(clean(text), n_cols - win.getyx()[1])
|
win.addnstr(clean(text), n_cols - win.getyx()[1])
|
||||||
|
|
||||||
|
|||||||
@@ -150,3 +150,5 @@ class SubredditPage(BasePage):
|
|||||||
win.addnstr(row, 1, clean(text), n_cols-1, curses.A_BOLD)
|
win.addnstr(row, 1, clean(text), n_cols-1, curses.A_BOLD)
|
||||||
text = ' {subreddit}'.format(**data)
|
text = ' {subreddit}'.format(**data)
|
||||||
win.addnstr(clean(text), n_cols - win.getyx()[1], Color.YELLOW)
|
win.addnstr(clean(text), n_cols - win.getyx()[1], Color.YELLOW)
|
||||||
|
text = ' {flair}'.format(**data)
|
||||||
|
win.addnstr(clean(text), n_cols - win.getyx()[1], Color.RED)
|
||||||
|
|||||||
5
setup.py
5
setup.py
@@ -22,10 +22,7 @@ setup(
|
|||||||
'Operating System :: POSIX',
|
'Operating System :: POSIX',
|
||||||
'Natural Language :: English',
|
'Natural Language :: English',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
'Programming Language :: Python :: 3.1',
|
'Programming Language :: Python :: 3',
|
||||||
'Programming Language :: Python :: 3.2',
|
|
||||||
'Programming Language :: Python :: 3.3',
|
|
||||||
'Programming Language :: Python :: 3.4',
|
|
||||||
'Topic :: Terminals',
|
'Topic :: Terminals',
|
||||||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Message Boards',
|
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: Message Boards',
|
||||||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: News/Diary',
|
'Topic :: Internet :: WWW/HTTP :: Dynamic Content :: News/Diary',
|
||||||
|
|||||||
Reference in New Issue
Block a user