Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Delete unneccessary SubSR.
Browse files Browse the repository at this point in the history
  • Loading branch information
bsimpson63 committed Jul 22, 2015
1 parent 9853214 commit d261e17
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 51 deletions.
2 changes: 0 additions & 2 deletions r2/r2/config/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ def __call__(self, environ, start_response):
if sr:
environ['subreddit'] = sr.groups()[0]
environ['PATH_INFO'] = self.sr_pattern.sub('', path) or '/'
elif path.startswith(('/subreddits', '/reddits')):
environ['subreddit'] = 'r'
return self.app(environ, start_response)

class DomainListingMiddleware(object):
Expand Down
4 changes: 0 additions & 4 deletions r2/r2/controllers/reddit_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
Random,
RandomNSFW,
RandomSubscription,
Sub,
Subreddit,
valid_admin_cookie,
valid_feed,
Expand Down Expand Up @@ -369,9 +368,6 @@ def set_subreddit():
domain = ".".join((g.domain_prefix, domain))
path = 'http://%s%s' % (domain, sr.path)
abort(301, location=BaseController.format_output_url(path))
elif sr_name == 'r':
#reddits
c.site = Sub
elif '+' in sr_name:
name_filter = lambda name: Subreddit.is_valid_name(name,
allow_language_srs=True)
Expand Down
4 changes: 1 addition & 3 deletions r2/r2/lib/pages/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
RandomNSFW,
RandomSubscription,
StylesheetsEverywhere,
Sub,
SubSR,
Subreddit,
Target,
Trophy,
Expand Down Expand Up @@ -1279,7 +1277,7 @@ def __init__(self, pagename, css_class=None, **context):
Reddit.__init__(self, **context)

def build_toolbars(self):
if not isinstance(c.site, (DefaultSR, SubSR)) and not c.cname:
if not isinstance(c.site, DefaultSR) and not c.cname:
return [PageNameNav('subreddit', title = self.pagename)]
else:
return [PageNameNav('nomenu', title = self.pagename)]
Expand Down
4 changes: 1 addition & 3 deletions r2/r2/lib/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,15 +654,13 @@ def get_subreddit(self):
On failure to find a subreddit, returns None.
"""
from pylons import g
from r2.models import Subreddit, Sub, NotFound, DefaultSR
from r2.models import Subreddit, NotFound, DefaultSR
try:
if (not self.hostname or
is_subdomain(self.hostname, g.domain) or
self.hostname.startswith(g.domain)):
if self.path.startswith('/r/'):
return Subreddit._by_name(self.path.split('/')[2])
elif self.path.startswith(('/subreddits/', '/reddits/')):
return Sub
else:
return DefaultSR()
elif self.hostname:
Expand Down
19 changes: 0 additions & 19 deletions r2/r2/models/subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2368,24 +2368,6 @@ class ContribSR(ModContribSR):
query_param = "contributor"
path = "/r/contrib"

class SubSR(FakeSubreddit):
stylesheet = 'subreddit.css'
#this will make the javascript not send an SR parameter
name = ''
title = ''

def can_view(self, user):
return True

def can_comment(self, user):
return False

def can_submit(self, user, promotion=False):
return True

@property
def path(self):
return "/subreddits/"

class DomainSR(FakeSubreddit):
@property
Expand Down Expand Up @@ -2434,7 +2416,6 @@ def add_props(cls, user, wrapped):
Printable.add_props(user, wrapped)

Frontpage = DefaultSR()
Sub = SubSR()
Friends = FriendsSR()
Mod = ModSR()
Contrib = ContribSR()
Expand Down
3 changes: 0 additions & 3 deletions r2/r2/templates/listing.compact
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
## reddit Inc. All Rights Reserved.
###############################################################################

<%!
from r2.models import Sub
%>
<%namespace file="utils.html" import="plain_link" />

<%
Expand Down
5 changes: 2 additions & 3 deletions r2/r2/templates/listing.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

<%!
from r2.lib.template_helpers import format_html
from r2.models import Sub
%>
<%namespace file="utils.html" import="plain_link" />

Expand All @@ -43,13 +42,13 @@
<div class="nav-buttons">
<span class="nextprev">${_("view more:")}&#32;
%if thing.prev:
${plain_link(format_html("&lsaquo; %s", _("prev")), thing.prev, _sr_path = (c.site != Sub), rel="nofollow prev")}
${plain_link(format_html("&lsaquo; %s", _("prev")), thing.prev, rel="nofollow prev")}
%endif
%if thing.prev and thing.next:
<span class="separator"></span>
%endif
%if thing.next:
${plain_link(format_html("%s &rsaquo;", _("next")), thing.next, _sr_path = (c.site != Sub), rel="nofollow next")}
${plain_link(format_html("%s &rsaquo;", _("next")), thing.next, rel="nofollow next")}
%endif
</span>
%if thing.next_suggestions:
Expand Down
2 changes: 1 addition & 1 deletion r2/r2/templates/reddit.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from r2.lib import tracking
from pylons import request
from r2.lib.strings import strings
from r2.models import make_feedurl, Sub
from r2.models import make_feedurl
%>
<%namespace file="framebuster.html" import="framebuster"/>
<%namespace file="less.html" import="less_js, less_stylesheet"/>
Expand Down
2 changes: 1 addition & 1 deletion r2/r2/templates/redditheader.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
format_number,
header_url,
)
from r2.models import Sub, FakeSubreddit
from r2.models import FakeSubreddit
from r2.models.subreddit import DefaultSR
from r2.lib.pages import SearchForm
%>
Expand Down
2 changes: 1 addition & 1 deletion r2/r2/templates/redditheader.mobile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<%!
from r2.lib.template_helpers import static
from r2.models import Sub, FakeSubreddit
from r2.models import FakeSubreddit
%>
<%namespace file="utils.html" import="plain_link, img_link, separator"/>

Expand Down
5 changes: 2 additions & 3 deletions r2/r2/templates/searchlisting.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

<%!
from r2.lib.template_helpers import format_html
from r2.models import Sub
%>

<%namespace file="utils.html" import="plain_link" />
Expand Down Expand Up @@ -51,13 +50,13 @@
<div class="nav-buttons">
<span class="nextprev">${_("view more:")}&#32;
%if thing.prev:
${plain_link(format_html("&lsaquo; %s", _("prev")), thing.prev, _sr_path = (c.site != Sub), rel="nofollow prev")}
${plain_link(format_html("&lsaquo; %s", _("prev")), thing.prev, rel="nofollow prev")}
%endif
%if thing.prev and thing.next:
<span class="separator"></span>
%endif
%if thing.next:
${plain_link(format_html("%s &rsaquo;", _("next")), thing.next, _sr_path = (c.site != Sub), rel="nofollow next")}
${plain_link(format_html("%s &rsaquo;", _("next")), thing.next, rel="nofollow next")}
%endif
</span>
%if thing.next_suggestions:
Expand Down
7 changes: 3 additions & 4 deletions r2/r2/templates/tablelisting.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

<%!
from r2.lib.template_helpers import format_html
from r2.models import Sub
%>
<%namespace file="utils.html" import="plain_link" />

Expand All @@ -49,15 +48,15 @@
%if thing.nextprev and (thing.prev or thing.next):
<p class="nextprev"> ${_("view more:")}&#32;
%if thing.prev:
${plain_link(_("first"), thing.first, _sr_path = (c.site != Sub), rel="nofollow first")}
${plain_link(_("first"), thing.first, rel="nofollow first")}
<span class="separator"></span>
${plain_link(format_html("&lsaquo; %s", _("prev")), thing.prev, _sr_path = (c.site != Sub), rel="nofollow prev")}
${plain_link(format_html("&lsaquo; %s", _("prev")), thing.prev, rel="nofollow prev")}
%endif
%if thing.prev and thing.next:
<span class="separator"></span>
%endif
%if thing.next:
${plain_link(format_html("%s &rsaquo;", _("next")), thing.next, _sr_path = (c.site != Sub), rel="nofollow next")}
${plain_link(format_html("%s &rsaquo;", _("next")), thing.next, rel="nofollow next")}
%endif
</p>
%endif
Expand Down
7 changes: 3 additions & 4 deletions r2/r2/templates/userlisting.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

<%!
from r2.lib.template_helpers import format_html
from r2.models import Sub
%>
<%namespace file="utils.html" import="error_field, plain_link" />

Expand Down Expand Up @@ -104,15 +103,15 @@ <h1>
%if thing.nextprev and (thing.prev or thing.next):
<p class="nextprev"> ${_("view more:")}&#32;
%if thing.prev:
${plain_link(_("first"), thing.first, _sr_path = (c.site != Sub), rel="nofollow first")}
${plain_link(_("first"), thing.first, rel="nofollow first")}
<span class="separator"></span>
${plain_link(format_html("&lsaquo; %s", _("prev")), thing.prev, _sr_path = (c.site != Sub), rel="nofollow prev")}
${plain_link(format_html("&lsaquo; %s", _("prev")), thing.prev, rel="nofollow prev")}
%endif
%if thing.prev and thing.next:
<span class="separator"></span>
%endif
%if thing.next:
${plain_link(format_html("%s &rsaquo;", _("next")), thing.next, _sr_path = (c.site != Sub), rel="nofollow next")}
${plain_link(format_html("%s &rsaquo;", _("next")), thing.next, rel="nofollow next")}
%endif
</p>
%endif
Expand Down

0 comments on commit d261e17

Please sign in to comment.