Redirect /t/timereddit/* to /r/t:timereddit/*.

This commit is contained in:
Logan Hanks
2012-04-02 11:38:20 -07:00
committed by Neil Williams
parent 72ae91d220
commit 4740772d23
2 changed files with 16 additions and 1 deletions

View File

@@ -106,6 +106,11 @@ def make_map(global_conf={}, app_conf={}):
where='overview')
mc('/u/:username', controller='redirect', action='user_redirect')
# preserve timereddit URLs from 4/1/2012
mc('/t/:timereddit', controller='redirect', action='timereddit_redirect')
mc('/t/:timereddit/*rest', controller='redirect',
action='timereddit_redirect')
mc('/prefs/:location', controller='forms',
action='prefs', location='options')

View File

@@ -22,7 +22,7 @@
from pylons.controllers.util import abort, redirect_to
from r2.lib.base import BaseController
from pylons import c
from validator import chkuser
from validator import chkuser, chksrname
class RedirectController(BaseController):
def GET_redirect(self, dest):
@@ -33,3 +33,13 @@ class RedirectController(BaseController):
if not user:
abort(400)
return redirect_to("/user/" + user, _code=301)
def GET_timereddit_redirect(self, timereddit, rest=None):
tr_name = chksrname(timereddit)
if not tr_name:
abort(400)
if rest:
rest = str(rest)
else:
rest = ''
return redirect_to("/r/t:%s/%s" % (tr_name, rest), _code=301)