diff --git a/r2/r2/controllers/reddit_base.py b/r2/r2/controllers/reddit_base.py index 4da039e05..e23021a10 100644 --- a/r2/r2/controllers/reddit_base.py +++ b/r2/r2/controllers/reddit_base.py @@ -30,7 +30,7 @@ from r2.lib.utils import http_utils, is_subdomain, UniqueIterator, ip_and_slash1 from r2.lib.cache import LocalCache, make_key, MemcachedError import random as rand from r2.models.account import valid_cookie, FakeAccount, valid_feed, valid_admin_cookie -from r2.models.subreddit import Subreddit +from r2.models.subreddit import Subreddit, Frontpage from r2.models import * from errors import ErrorSet from validator import * @@ -249,13 +249,12 @@ def set_subreddit(): can_stale = request.method.upper() in ('GET','HEAD') - default_sr = DefaultSR() - c.site = default_sr + c.site = Frontpage if not sr_name: #check for cnames sub_domain = request.environ.get('sub_domain') if sub_domain and not sub_domain.endswith(g.media_domain): - c.site = Subreddit._by_domain(sub_domain) or default_sr + c.site = Subreddit._by_domain(sub_domain) or Frontpage elif sr_name == 'r': #reddits c.site = Sub diff --git a/r2/r2/lib/menus.py b/r2/r2/lib/menus.py index 4392bb1ce..476306704 100644 --- a/r2/r2/lib/menus.py +++ b/r2/r2/lib/menus.py @@ -324,10 +324,14 @@ class OffsiteButton(NavButton): return [('path', self.path), ('title', self.title)] class SubredditButton(NavButton): + from r2.models.subreddit import Frontpage, Mod + # TRANSLATORS: these refer to /r/mod and the front page. + name_overrides = {Mod: _("mod"), + Frontpage: _("front")} + def __init__(self, sr): - from r2.models.subreddit import Mod self.path = sr.path - name = 'mod' if sr == Mod else sr.name + name = self.name_overrides.get(sr, sr.name) NavButton.__init__(self, name, sr.path, False, isselected = (c.site == sr)) diff --git a/r2/r2/lib/pages/pages.py b/r2/r2/lib/pages/pages.py index c280d852d..f2f4382dc 100644 --- a/r2/r2/lib/pages/pages.py +++ b/r2/r2/lib/pages/pages.py @@ -22,7 +22,7 @@ from r2.lib.wrapped import Wrapped, Templated, CachedTemplate from r2.models import Account, FakeAccount, DefaultSR, make_feedurl from r2.models import FakeSubreddit, Subreddit, Ad, AdSR -from r2.models import Friends, All, Sub, NotFound, DomainSR, Random, Mod, RandomNSFW, MultiReddit, ModSR +from r2.models import Friends, All, Sub, NotFound, DomainSR, Random, Mod, RandomNSFW, MultiReddit, ModSR, Frontpage from r2.models import Link, Printable, Trophy, bidding, PromotionWeights, Comment from r2.models import Flair, FlairTemplate, FlairTemplateBySubredditIndex from r2.models import USER_FLAIR, LINK_FLAIR @@ -1409,7 +1409,7 @@ class SubredditTopBar(CachedTemplate): css_class = 'sr-bar', _id = 'sr-bar') def special_reddits(self): - reddits = [All, Random] + reddits = [Frontpage, All, Random] if getattr(c.site, "over_18", False): reddits.append(RandomNSFW) if c.user_is_loggedin: diff --git a/r2/r2/models/subreddit.py b/r2/r2/models/subreddit.py index d6fe4e20d..839b5d2bf 100644 --- a/r2/r2/models/subreddit.py +++ b/r2/r2/models/subreddit.py @@ -985,6 +985,7 @@ class DomainSR(FakeSubreddit): # switched over to use the non-_old variety. return queries.get_domain_links(self.domain, sort, time) +Frontpage = DefaultSR() Sub = SubSR() Friends = FriendsSR() Mod = ModSR()