mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-28 00:07:57 -05:00
redirect domain subreddit button request rather than 404. Clean up and remove tracking from error pages.
This commit is contained in:
@@ -24,7 +24,7 @@ from r2.lib.pages import Button, ButtonNoBody, ButtonEmbed, ButtonLite, \
|
||||
ButtonDemoPanel, WidgetDemoPanel, Bookmarklets, BoringPage, Socialite
|
||||
from r2.models import *
|
||||
from r2.lib.strings import Score
|
||||
from r2.lib.utils import tup
|
||||
from r2.lib.utils import tup, query_string
|
||||
from pylons import c, request
|
||||
from validator import *
|
||||
from pylons.i18n import _
|
||||
@@ -78,7 +78,8 @@ class ButtonsController(RedditController):
|
||||
|
||||
# no buttons on domain listings
|
||||
if isinstance(c.site, DomainSR):
|
||||
return self.abort404()
|
||||
c.site = Default
|
||||
return self.redirect(request.path + query_string(request.GET))
|
||||
|
||||
l = self.wrap_link(link or self.get_link(url))
|
||||
if l: url = l.url
|
||||
|
||||
@@ -106,26 +106,17 @@ class ErrorController(RedditController):
|
||||
def send403(self):
|
||||
c.response.status_code = 403
|
||||
c.site = Default
|
||||
title = _("forbidden (%(domain)s)") % dict(domain=g.domain)
|
||||
return pages.BoringPage(title, loginbox=False,
|
||||
show_sidebar = False,
|
||||
content=pages.ErrorPage()).render()
|
||||
res = pages.RedditError(_("forbidden (%(domain)s)") %
|
||||
dict(domain=g.domain))
|
||||
return res.render()
|
||||
|
||||
def send404(self):
|
||||
c.response.status_code = 404
|
||||
if c.site._spam and not c.user_is_admin:
|
||||
msg = _("this reddit has been banned.")
|
||||
res = pages.BoringPage(msg, loginbox = False,
|
||||
show_sidebar = False,
|
||||
content = pages.ErrorPage(message = msg))
|
||||
res = pages.RedditError(_("this reddit has been banned."))
|
||||
return res.render()
|
||||
else:
|
||||
ch=rand.choice(['a','b','c','d','e'])
|
||||
res = pages.BoringPage(_("page not found"),
|
||||
loginbox=False,
|
||||
show_sidebar = False,
|
||||
content=pages.UnfoundPage(choice=ch))
|
||||
return res.render()
|
||||
return pages.Reddit404().render()
|
||||
|
||||
def GET_document(self):
|
||||
try:
|
||||
|
||||
@@ -35,7 +35,7 @@ from r2.lib.menus import SubredditButton, SubredditMenu, menu
|
||||
from r2.lib.strings import plurals, rand_strings, strings
|
||||
from r2.lib.utils import title_to_url, query_string, UrlParser, to_js
|
||||
from r2.lib.template_helpers import add_sr, get_domain
|
||||
import sys
|
||||
import sys, random
|
||||
|
||||
datefmt = _force_utf8(_('%d %b %Y'))
|
||||
|
||||
@@ -72,6 +72,7 @@ class Reddit(Wrapped):
|
||||
searchbox = True
|
||||
extension_handling = True
|
||||
enable_login_cover = True
|
||||
site_tracking = True
|
||||
|
||||
def __init__(self, space_compress = True, nav_menus = None, loginbox = True,
|
||||
infotext = '', content = None, title = '', robots = None,
|
||||
@@ -620,11 +621,27 @@ class InfoBar(Wrapped):
|
||||
def __init__(self, message = ''):
|
||||
Wrapped.__init__(self, message = message)
|
||||
|
||||
|
||||
class RedditError(BoringPage):
|
||||
site_tracking = False
|
||||
def __init__(self, msg):
|
||||
BoringPage.__init__(self, msg, loginbox=False,
|
||||
show_sidebar = False,
|
||||
content=ErrorPage(msg))
|
||||
|
||||
class Reddit404(BoringPage):
|
||||
site_tracking = False
|
||||
def __init__(self):
|
||||
ch=random.choice(['a','b','c','d','e'])
|
||||
BoringPage.__init__(self, _("page not found"), loginbox=False,
|
||||
show_sidebar = False,
|
||||
content=UnfoundPage(ch))
|
||||
|
||||
class UnfoundPage(Wrapped):
|
||||
"""Wrapper for the 404 page"""
|
||||
def __init__(self, choice='a'):
|
||||
Wrapped.__init__(self, choice=choice)
|
||||
|
||||
def __init__(self, choice):
|
||||
Wrapped.__init__(self, choice = choice)
|
||||
|
||||
class ErrorPage(Wrapped):
|
||||
"""Wrapper for an error message"""
|
||||
def __init__(self, message = _("you aren't allowed to do that.")):
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
${_("(c) %(year)d CondeNet, Inc. All rights reserved.") % \
|
||||
dict(year=datetime.datetime.now().timetuple()[0])}
|
||||
</p>
|
||||
%if g.tracker_url:
|
||||
%if g.tracker_url and thing.site_tracking:
|
||||
<img alt="" src="${tracking.UserInfo.gen_url()}"/>
|
||||
%endif
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user