mirror of
https://github.com/djohnlewis/stackdump
synced 2024-12-04 23:17:37 +00:00
Added an alias for questions for StackExchange style URLs.
This means site_key/questions/question_id is redirected to site_key/question_id.
This commit is contained in:
parent
5fc56e4329
commit
e776e95d84
@ -15,7 +15,7 @@ except ImportError:
|
||||
# For Python >= 2.6
|
||||
import json
|
||||
|
||||
from bottle import get, run, static_file, debug, request, error, HTTPError
|
||||
from bottle import get, run, static_file, debug, request, error, HTTPError, redirect
|
||||
from jinja2 import Environment, PackageLoader
|
||||
from sqlobject import sqlhub, connectionForURI, AND, OR, IN, SQLObjectNotFound
|
||||
from sqlobject.dberrors import OperationalError
|
||||
@ -381,6 +381,14 @@ def view_question(site_key, question_id):
|
||||
|
||||
return render_template('question.html', context)
|
||||
|
||||
@get('/:site_key#[\w\.]+#/questions/:question_id#\d+#')
|
||||
def view_question_redirect(site_key, question_id):
|
||||
'''
|
||||
Redirects users from the long-form, proper URLs to the shorter one used
|
||||
by Stackdump.
|
||||
'''
|
||||
redirect('%s%s/%s' % (settings['APP_URL_ROOT'], site_key, question_id))
|
||||
|
||||
# END WEB REQUEST METHODS
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user