Change "reddit" to "subreddit" where appropriate

This also adds new routes for /subreddits/ replacing /reddits/, though
the old routes are kept as well for backwards-compatibility
This commit is contained in:
Chad Birch
2013-03-12 20:20:30 -06:00
parent 6976b8d4e6
commit 9354da77cd
27 changed files with 89 additions and 78 deletions

View File

@@ -206,7 +206,7 @@ class SubredditMiddleware(object):
if sr:
environ['subreddit'] = sr.groups()[0]
environ['PATH_INFO'] = self.sr_pattern.sub('', path) or '/'
elif path.startswith("/reddits"):
elif path.startswith(('/subreddits', '/reddits')):
environ['subreddit'] = 'r'
return self.app(environ, start_response)

View File

@@ -68,6 +68,18 @@ def make_map():
mc('/about/:location', controller='front', action='editreddit',
location='about')
mc('/subreddits/create', controller='front', action='newreddit')
mc('/subreddits/search', controller='front', action='search_reddits')
mc('/subreddits/login', controller='forms', action='login')
mc('/subreddits/:where', controller='reddits', action='listing',
where='popular', requirements=dict(where="popular|new|banned"))
mc('/subreddits/mine/:where', controller='myreddits', action='listing',
where='subscriber',
requirements=dict(where='subscriber|contributor|moderator'))
# These routes are kept for backwards-compatibility reasons
# Using the above /subreddits/ ones instead is preferable
mc('/reddits/create', controller='front', action='newreddit')
mc('/reddits/search', controller='front', action='search_reddits')
mc('/reddits/login', controller='forms', action='login')

View File

@@ -381,10 +381,10 @@ class FrontController(RedditController, OAuth2ResourceController):
@validate(VUser(),
name=nop('name'))
def GET_newreddit(self, name):
"""Create a community form"""
title = _('create a reddit')
"""Create a subreddit form"""
title = _('create a subreddit')
content=CreateSubreddit(name=name or '')
res = FormPage(_("create a community"),
res = FormPage(_("create a subreddit"),
content=content,
).render()
return res
@@ -785,7 +785,7 @@ class FrontController(RedditController, OAuth2ResourceController):
@base_listing
@validate(query=nop('q'))
@api_doc(api_section.subreddits, uri='/reddits/search', extensions=['json', 'xml'])
@api_doc(api_section.subreddits, uri='/subreddits/search', extensions=['json', 'xml'])
def GET_search_reddits(self, query, reverse, after, count, num):
"""Search reddits by title and description."""
q = SubredditSearchQuery(query)

View File

@@ -924,7 +924,7 @@ class RedditsController(ListingController):
render_cls = SubredditsPage
def title(self):
return _('reddits')
return _('subreddits')
def keep_fn(self):
base_keep_fn = ListingController.keep_fn(self)
@@ -965,8 +965,8 @@ class RedditsController(ListingController):
return reddits
@listing_api_doc(section=api_section.subreddits,
uri='/reddits/{where}',
uri_variants=['/reddits/popular', '/reddits/new', '/reddits/banned'])
uri='/subreddits/{where}',
uri_variants=['/subreddits/popular', '/subreddits/new', '/subreddits/banned'])
def GET_listing(self, where, **env):
self.where = where
return ListingController.GET_listing(self, **env)
@@ -984,11 +984,11 @@ class MyredditsController(ListingController, OAuth2ResourceController):
NavButton(getattr(plurals, "approved submitter"), 'contributor'),
NavButton(plurals.moderator, 'moderator'))
return [NavMenu(buttons, base_path = '/reddits/mine/',
return [NavMenu(buttons, base_path = '/subreddits/mine/',
default = 'subscriber', type = "flatlist")]
def title(self):
return _('reddits: ') + self.where
return _('subreddits: ') + self.where
def query(self):
reddits = SRMember._query(SRMember.c._name == self.where,
@@ -1030,8 +1030,8 @@ class MyredditsController(ListingController, OAuth2ResourceController):
@require_oauth2_scope("mysubreddits")
@validate(VUser())
@listing_api_doc(section=api_section.subreddits,
uri='/reddits/mine/{where}',
uri_variants=['/reddits/mine/subscriber', '/reddits/mine/contributor', '/reddits/mine/moderator'])
uri='/subreddits/mine/{where}',
uri_variants=['/subreddits/mine/subscriber', '/subreddits/mine/contributor', '/subreddits/mine/moderator'])
def GET_listing(self, where='subscriber', **env):
self.where = where
return ListingController.GET_listing(self, **env)

View File

@@ -343,7 +343,7 @@ def set_subreddit():
elif '-' in sr_name:
sr_names = sr_name.split('-')
if not sr_names[0].lower() == All.name.lower():
redirect_to("/reddits/search?q=%s" % sr_name)
redirect_to("/subreddits/search?q=%s" % sr_name)
srs = Subreddit._by_name(sr_names[1:], stale=can_stale).values()
srs = [sr for sr in srs if not isinstance(sr, FakeSubreddit)]
if not srs:
@@ -356,7 +356,7 @@ def set_subreddit():
except NotFound:
sr_name = chksrname(sr_name)
if sr_name:
redirect_to("/reddits/search?q=%s" % sr_name)
redirect_to("/subreddits/search?q=%s" % sr_name)
elif not c.error_page and not request.path.startswith("/api/login/") :
abort(404)

View File

@@ -61,8 +61,8 @@ error_list = dict((
('BAD_STRING', _("you used a character here that we can't handle")),
('BAD_BID', _("your bid must be at least $%(min)d per day and no more than to $%(max)d in total.")),
('ALREADY_SUB', _("that link has already been submitted")),
('SUBREDDIT_EXISTS', _('that reddit already exists')),
('SUBREDDIT_NOEXIST', _('that reddit doesn\'t exist')),
('SUBREDDIT_EXISTS', _('that subreddit already exists')),
('SUBREDDIT_NOEXIST', _('that subreddit doesn\'t exist')),
('SUBREDDIT_NOTALLOWED', _("you aren't allowed to post there.")),
('SUBREDDIT_REQUIRED', _('you must specify a subreddit')),
('BAD_SR_NAME', _('that name isn\'t going to work')),
@@ -79,7 +79,7 @@ error_list = dict((
('BAD_EMAILS', _('the following emails are invalid: %(emails)s')),
('NO_EMAILS', _('please enter at least one email address')),
('TOO_MANY_EMAILS', _('please only share to %(num)s emails at a time.')),
('OVERSOLD', _('that reddit has already been oversold on %(start)s to %(end)s. Please pick another reddit or date.')),
('OVERSOLD', _('that subreddit has already been oversold on %(start)s to %(end)s. Please pick another subreddit or date.')),
('BAD_DATE', _('please provide a date of the form mm/dd/yyyy')),
('BAD_DATE_RANGE', _('the dates need to be in order and not identical')),
('DATE_RANGE_TOO_LARGE', _('you must choose a date range of less than %(days)s days')),
@@ -91,8 +91,8 @@ error_list = dict((
('NO_TEXT', _('we need something here')),
('INVALID_CODE', _("we've never seen that code before")),
('CLAIMED_CODE', _("that code has already been claimed -- perhaps by you?")),
('NO_SELFS', _("that reddit doesn't allow text posts")),
('NO_LINKS', _("that reddit only allows text posts")),
('NO_SELFS', _("that subreddit doesn't allow text posts")),
('NO_LINKS', _("that subreddit only allows text posts")),
('TOO_OLD', _("that's a piece of history now; it's too late to reply to it")),
('BAD_CSS_NAME', _('invalid css name')),
('BAD_CSS', _('invalid css')),

View File

@@ -236,7 +236,7 @@ class SubredditJsonTemplate(ThingJsonTemplate):
if (attr == "_ups" and g.lounge_reddit
and thing.name == g.lounge_reddit):
return 0
# Don't return accounts_active counts in /reddits
# Don't return accounts_active counts in /subreddits
elif (attr == "accounts_active" and isinstance(c.site, SubSR)):
return None
elif attr == 'description_html':

View File

@@ -118,7 +118,7 @@ menu = MenuHandler(hot = _('hot'),
home = _("home"),
about = _("about"),
edit_subscriptions = _("edit subscriptions"),
community_settings = _("community settings"),
community_settings = _("subreddit settings"),
moderators = _("edit moderators"),
modmail = _("moderator mail"),
contributors = _("edit approved submitters"),
@@ -137,7 +137,7 @@ menu = MenuHandler(hot = _('hot'),
popular = _("popular"),
create = _("create"),
mine = _("my reddits"),
mine = _("my subreddits"),
i18n = _("help translate"),
errors = _("errors"),

View File

@@ -397,8 +397,8 @@ class Reddit(Templated):
if self.create_reddit_box and c.user_is_loggedin:
delta = datetime.datetime.now(g.tz) - c.user._date
if delta.days >= g.min_membership_create_community:
ps.append(SideBox(_('Create your own community'),
'/reddits/create', 'create',
ps.append(SideBox(_('Create your own subreddit'),
'/subreddits/create', 'create',
subtitles = rand_strings.get("create_reddit", 2),
show_cover = True, nocname=True))
@@ -1376,12 +1376,12 @@ class SubredditsPage(Reddit):
if c.user_is_loggedin:
#add the aliases to "my reddits" stays highlighted
buttons.append(NamedButton("mine",
aliases=['/reddits/mine/subscriber',
'/reddits/mine/contributor',
'/reddits/mine/moderator']))
aliases=['/subreddits/mine/subscriber',
'/subreddits/mine/contributor',
'/subreddits/mine/moderator']))
return [PageNameNav('reddits'),
NavMenu(buttons, base_path = '/reddits', type="tabmenu")]
return [PageNameNav('subreddits'),
NavMenu(buttons, base_path = '/subreddits', type="tabmenu")]
def content(self):
return self.content_stack((self.interestbar, self.searchbar,
@@ -1395,7 +1395,7 @@ class SubredditsPage(Reddit):
subscribe_box = SubscriptionBox(srs,
multi_text=strings.subscribed_multi)
num_reddits = len(subscribe_box.srs)
ps.append(SideContentBox(_("your front page reddits (%s)") %
ps.append(SideContentBox(_("your front page subreddits (%s)") %
num_reddits, [subscribe_box]))
return ps
@@ -1656,9 +1656,9 @@ class SubredditTopBar(CachedTemplate):
drop_down_buttons.append(NavButton(menu.edit_subscriptions,
sr_path = False,
css_class = 'bottom-option',
dest = '/reddits/'))
dest = '/subreddits/'))
return SubredditMenu(drop_down_buttons,
title = _('my reddits'),
title = _('my subreddits'),
type = 'srdrop')
def subscribed_reddits(self):
@@ -1744,7 +1744,7 @@ class SubscriptionBox(Templated):
Subreddit.gold_limit - Subreddit.sr_limit)
visible = min(len(srs), Subreddit.gold_limit)
bonus = {"bonus": extra}
self.goldmsg = _("%(bonus)s bonus reddits") % bonus
self.goldmsg = _("%(bonus)s bonus subreddits") % bonus
self.prelink = ["/wiki/faq#wiki_how_many_reddits_can_i_subscribe_to.3F",
_("%s visible") % visible]
@@ -2050,7 +2050,7 @@ class SearchForm(Templated):
class SearchBar(Templated):
"""More detailed search box for /search and /reddits pages.
"""More detailed search box for /search and /subreddits pages.
Displays the previous search as well as info of the elapsed_time
and num_results if any."""
def __init__(self, header=None, num_results=0, prev_search='',

View File

@@ -68,7 +68,7 @@ string_dict = dict(
already_submitted = _("that link has already been submitted, but you can try to [submit it again](%s)."),
multiple_submitted = _("that link has been submitted to multiple reddits. you can try to [submit it again](%s)."),
multiple_submitted = _("that link has been submitted to multiple subreddits. you can try to [submit it again](%s)."),
user_deleted = _("your account has been deleted, but we won't judge you for it."),
@@ -84,21 +84,21 @@ string_dict = dict(
friends = _('to view reddit with only submissions from your friends, use [reddit.com/r/friends](%s)'),
sr_created = _('your reddit has been created'),
sr_created = _('your subreddit has been created'),
more_info_link = _("visit [%(link)s](%(link)s) for more information"),
sr_messages = dict(
empty = _('you have not subscribed to any reddits.'),
subscriber = _('below are the reddits you have subscribed to'),
contributor = _('below are the reddits that you are an approved submitter on.'),
moderator = _('below are the reddits that you have moderator access to.')
empty = _('you have not subscribed to any subreddits.'),
subscriber = _('below are the subreddits you have subscribed to'),
contributor = _('below are the subreddits that you are an approved submitter on.'),
moderator = _('below are the subreddits that you have moderator access to.')
),
sr_subscribe = _('click the `subscribe` or `unsubscribe` buttons to choose which reddits appear on your front page.'),
sr_subscribe = _('click the `subscribe` or `unsubscribe` buttons to choose which subreddits appear on your front page.'),
searching_a_reddit = _('you\'re searching within the [%(reddit_name)s](%(reddit_link)s) reddit. '+
'you can also search within [all reddits](%(all_reddits_link)s)'),
searching_a_reddit = _('you\'re searching within the [%(reddit_name)s](%(reddit_link)s) subreddit. '+
'you can also search within [all subreddits](%(all_reddits_link)s)'),
css_validator_messages = dict(
broken_url = _('"%(brokenurl)s" is not a valid URL'),

View File

@@ -521,17 +521,16 @@ class UrlParser(object):
def path_has_subreddit(self):
"""
utility method for checking if the path starts with a
subreddit specifier (namely /r/ or /reddits/).
subreddit specifier (namely /r/ or /subreddits/).
"""
return (self.path.startswith('/r/') or
self.path.startswith('/reddits/'))
return self.path.startswith(('/r/', '/subreddits/', '/reddits/'))
def get_subreddit(self):
"""checks if the current url refers to a subreddit and returns
that subreddit object. The cases here are:
* the hostname is unset or is g.domain, in which case it
looks for /r/XXXX or /reddits. The default in this case
looks for /r/XXXX or /subreddits. The default in this case
is Default.
* the hostname is a cname to a known subreddit.
@@ -543,7 +542,7 @@ class UrlParser(object):
if not self.hostname or self.hostname.startswith(g.domain):
if self.path.startswith('/r/'):
return Subreddit._by_name(self.path.split('/')[2])
elif self.path.startswith('/reddits/'):
elif self.path.startswith(('/subreddits/', '/reddits/')):
return Sub
else:
return DefaultSR()

View File

@@ -1257,7 +1257,7 @@ class VMessageRecipient(VExistingUname):
if isinstance(s, FakeSubreddit):
raise NotFound, "fake subreddit"
if s._spam:
raise NotFound, "banned community"
raise NotFound, "banned subreddit"
return s
except NotFound:
self.set_error(errors.SUBREDDIT_NOEXIST)

View File

@@ -87,7 +87,7 @@ class Subreddit(Thing, Printable):
over_18 = False,
exclude_banned_modqueue = False,
mod_actions = 0,
sponsorship_text = "this reddit is sponsored by",
sponsorship_text = "this subreddit is sponsored by",
sponsorship_url = None,
sponsorship_img = None,
sponsorship_name = None,
@@ -1282,7 +1282,7 @@ class SubSR(FakeSubreddit):
@property
def path(self):
return "/reddits/"
return "/subreddits/"
class DomainSR(FakeSubreddit):
@property

View File

@@ -214,7 +214,7 @@
%endif
>
<label for="allow_top">
${_("allow this reddit to be shown in the default set")}
${_("allow this subreddit to be shown in the default set")}
</label>
</li>
<li>

View File

@@ -44,11 +44,11 @@
<dt>Got a bug report?</dt>
<dd><a href="/r/bugs/">Check /r/bugs for other people with the same problem, or submit your own bug report.</a></dd>
<dt>Are you a new moderator? Having trouble staying out of the fray? Need advice?</dt>
<dd><a href="/r/modhelp">There's a reddit for that</a>.</dd>
<dd><a href="/r/modhelp">There's a subreddit for that</a>.</dd>
<dt>Want to advertise but don't know how?</dt>
<dd><a href="/ad_inq">The instructions are here</a>.</dd>
<dt>General questions? Need help?</dt>
<dd><a href="/r/help">There's a reddit for that, too</a>.</dd>
<dd><a href="/r/help">There's a subreddit for that, too</a>.</dd>
<dt>Frustrated? Need a break?</dt>
<% r = random.randint(0,2) %>
%if r == 0:

View File

@@ -27,7 +27,7 @@
checked="checked"
%endif
>
${_("Show my flair on this reddit. It looks like:")}
${_("Show my flair on this subreddit. It looks like:")}
</form>
<div class="tagline">${thing.wrapped_user}</div>
%endif

View File

@@ -24,7 +24,7 @@
<div class="content over18" style="text-align: center">
<p class="error">
${_("you must be at least eighteen to view this reddit")}
${_("you must be at least eighteen to view this subreddit")}
</p>
<img src="${static('over18.png')}" alt="" height="254" width="180" />

View File

@@ -28,9 +28,9 @@
</span>
</%def>
<%def name="reddits()">
<%def name="subreddits()">
<span class="hover pagename redditname">
${plain_link(_("reddits"), "/reddits/", _sr_path=False)}
${plain_link(_("subreddits"), "/subreddits/", _sr_path=False)}
</span>
</%def>

View File

@@ -31,9 +31,9 @@
</span>
</%def>
<%def name="reddits()">
<%def name="subreddits()">
<span class="hover pagename redditname">
${plain_link(_("reddits"), "/reddits/", _sr_path=False)}
${plain_link(_("subreddits"), "/subreddits/", _sr_path=False)}
</span>
</%def>

View File

@@ -26,9 +26,9 @@
</span>
</%def>
<%def name="reddits()">
<%def name="subreddits()">
<span class="hover pagename redditname">
<a href="/reddits/">${_("reddits")}</a>
<a href="/subreddits/">${_("subreddits")}</a>
</span>
</%def>

View File

@@ -116,7 +116,7 @@
%if not c.user.pref_compress:
${media_radio("on", _("show thumbnails next to links"))}
${media_radio("off", _("don't show thumbnails next to links"))}
${media_radio("subreddit", _("show thumbnails based on that reddit's media preferences"))}
${media_radio("subreddit", _("show thumbnails based on that subreddit's media preferences"))}
${checkbox(_("make safe(r) for work "), "no_profanity", disabled = not c.user.pref_over_18, disabled_text = "(requires over 18)")}
&#32;
<span class="little gray">
@@ -230,7 +230,7 @@
<tr>
<th>${_("display options")}</th>
<td class="prefright">
${checkbox(_("allow reddits to show me custom styles"), "show_stylesheets")}
${checkbox(_("allow subreddits to show me custom styles"), "show_stylesheets")}
<br/>
${checkbox(_("show user flair"), "show_flair")}
<br/>
@@ -246,7 +246,7 @@
<th>${_("content options")}</th>
<td class="prefright">
${checkbox(_("I am over eighteen years old and willing to view adult content"), "over_18")}
&#32;<span class="little gray">(${_("required to view some reddits")})</span>
&#32;<span class="little gray">(${_("required to view some subreddits")})</span>
<br/>
${checkbox(_("label posts that are not safe for work (NSFW)"), "label_nsfw", disabled = c.user.pref_no_profanity, disabled_text = "(requires not 'safer for work' mode)")}
<br/>

View File

@@ -160,7 +160,7 @@ ${self.javascript_setup()}
type="radio" value="one" name="targeting"
onclick="return targeting_on(this)" />
<label for="targeting">
enable targeting (runs on a specific reddit)
enable targeting (runs on a specific subreddit)
</label>
<p id="targeted_minimum" class="minimum-spend">minimum $30 / day</p>
<script type="text/javascript">
@@ -188,9 +188,9 @@ ${self.javascript_setup()}
</script>
<div class="targeting" style="display:none">
<ul>
<li>By targeting, your ad will only appear in front of users who subscribe to the reddit that you specify.</li>
<li>Your ad will also appear at the top of the hot listing for that reddit</li>
<li>You can only target one reddit per campaign. If you would like to submit to more than one reddit, add a new campaign (its easy, you just fill this form out again).</li>
<li>By targeting, your ad will only appear in front of users who subscribe to the subreddit that you specify.</li>
<li>Your ad will also appear at the top of the hot listing for that subreddit</li>
<li>You can only target one subreddit per campaign. If you would like to submit to more than one subreddit, add a new campaign (its easy, you just fill this form out again).</li>
</ul>
${error_field("OVERSOLD", "sr", "div")}
${reddit_selector(thing.default_sr, thing.sr_searches, thing.subreddits)}

View File

@@ -115,7 +115,7 @@
%if thing.other_ads:
<tr>
<td colspan="2" class="centered">
Ads not (yet) used on this reddit:
Ads not (yet) used on this subreddit:
</td>
</tr>
%endif

View File

@@ -30,7 +30,7 @@
<p>use the following search parameters to narrow your results:</p>
<dl>
<dt>reddit:<i>subreddit</i></dt>
<dt>subreddit:<i>subreddit</i></dt>
<dd>${_('find submissions in "subreddit"')}</dd>
<dt>author:<i>username</i></dt>
<dd>${_('find submissions by "username"')}</dd>
@@ -46,11 +46,11 @@
<dd>${_('include (or exclude) results marked as NSFW')}</dd>
</dl>
<p>e.g.&#32;<code>reddit:aww site:imgur.com dog</code></p>
<p>e.g.&#32;<code>subreddit:aww site:imgur.com dog</code></p>
<p><a href="http://www.reddit.com/wiki/search">${_('see the search faq for details.')}</a></p>
</div>
<p><a href="http://www.reddit.com/wiki/search" id="search_showmore">${_('advanced search: by author, community...')}</a></p>
<p><a href="http://www.reddit.com/wiki/search" id="search_showmore">${_('advanced search: by author, subreddit...')}</a></p>
</%def>
<form action="${add_sr('/search')}" id="search" role="search">

View File

@@ -82,7 +82,7 @@
<p>
${text_with_links(
_("You can access this tool at any time on the %(reddits)s page."),
reddits=dict(link_text="/reddits/", path="/reddits/")
reddits=dict(link_text="/subreddits/", path="/subreddits/")
)}
</p>
</div>

View File

@@ -56,7 +56,7 @@
title=_('leave'),
executed=_('you are no longer an approved submitter'),
question=_('stop being an approved submitter?'),
format=_('you are an approved submitter on this reddit. (%(leave)s)'),
format=_('you are an approved submitter on this subreddit. (%(leave)s)'),
format_arg='leave',
hidden_data=dict(
id=thing.sr._fullname))}
@@ -82,7 +82,7 @@
%if c.user_is_admin:
%if thing.sr._spam:
${state_button("approve", _("approve this reddit"),
${state_button("approve", _("approve this subreddit"),
"return change_state(this, 'approve');", _("approved"),
hidden_data = dict(id = thing.sr._fullname))}
%if thing.sr._spam and hasattr(thing.sr, "banner"):
@@ -90,7 +90,7 @@
%endif
%else:
${state_button("remove", _("ban this reddit"),
${state_button("remove", _("ban this subreddit"),
"return change_state(this, 'remove');", _("banned"),
hidden_data = dict(id = thing.sr._fullname))}
%endif

View File

@@ -39,6 +39,6 @@
</div>
${plain_link(unsafe(_(editmore) + " &raquo;"),
"/reddits/", id="sr-more-link")}
"/subreddits/", id="sr-more-link")}
</div>
</div>