Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4843 from ckan/4842-migrate-util-controller
[#4842] Migrate util controller
- Loading branch information
Showing
5 changed files
with
43 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# encoding: utf-8 | ||
|
||
import re | ||
|
||
from flask import Blueprint | ||
|
||
import ckan.lib.base as base | ||
import ckan.lib.helpers as h | ||
from ckan.common import _, request | ||
|
||
|
||
util = Blueprint(u'util', __name__) | ||
|
||
|
||
def internal_redirect(): | ||
u''' Redirect to the url parameter. | ||
Only internal URLs are allowed''' | ||
|
||
url = request.form.get(u'url') or request.args.get(u'url') | ||
if not url: | ||
base.abort(400, _(u'Missing Value') + u': url') | ||
|
||
if h.url_is_local(url): | ||
return h.redirect_to(url) | ||
else: | ||
base.abort(403, _(u'Redirecting to external site is not allowed.')) | ||
|
||
|
||
def primer(): | ||
u''' Render all HTML components out onto a single page. | ||
This is useful for development/styling of CKAN. ''' | ||
|
||
return base.render(u'development/primer.html') | ||
|
||
|
||
util.add_url_rule( | ||
u'/util/redirect', view_func=internal_redirect, methods=(u'GET', u'POST',)) | ||
util.add_url_rule(u'/testing/primer', view_func=primer) |