From 3714342fb7e18697ddb8a3cd70c6e4cc47a34a59 Mon Sep 17 00:00:00 2001 From: amercader Date: Fri, 14 Jun 2019 14:10:02 +0200 Subject: [PATCH 1/4] [#4842] Move primer endpoint to new util blueprint --- ckan/config/routing.py | 1 - ckan/controllers/util.py | 5 ----- ckan/views/util.py | 27 +++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 ckan/views/util.py diff --git a/ckan/config/routing.py b/ckan/config/routing.py index 0332214fb97..248477a636c 100644 --- a/ckan/config/routing.py +++ b/ckan/config/routing.py @@ -137,7 +137,6 @@ def make_map(): with SubMapper(map, controller='util') as m: m.connect('/i18n/strings_{lang}.js', action='i18n_js_strings') m.connect('/util/redirect', action='redirect') - m.connect('/testing/primer', action='primer') # robots.txt map.connect('/(robots.txt)', controller='template', action='view') diff --git a/ckan/controllers/util.py b/ckan/controllers/util.py index 0f84ebe933f..db50238f217 100644 --- a/ckan/controllers/util.py +++ b/ckan/controllers/util.py @@ -22,11 +22,6 @@ def redirect(self): else: base.abort(403, _('Redirecting to external site is not allowed.')) - def primer(self): - ''' Render all html components out onto a single page. - This is useful for development/styling of ckan. ''' - return base.render('development/primer.html') - def i18_js_strings(self, lang): ''' This is used to produce the translations for javascript. ''' i18n.set_lang(lang) diff --git a/ckan/views/util.py b/ckan/views/util.py new file mode 100644 index 00000000000..c038e6b804f --- /dev/null +++ b/ckan/views/util.py @@ -0,0 +1,27 @@ +# encoding: utf-8 + +import re + +from flask import Blueprint + +import ckan.lib.base as base + +from ckan.common import g, config, _ + + +util = Blueprint(u'util', __name__) + + +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_rules = [ + (u'/testing/primer', primer), +] + +for rule, view_func in util_rules: + util.add_url_rule(rule, view_func=view_func) From 03c8242006a210e8909ece39157786f8e81b77f4 Mon Sep 17 00:00:00 2001 From: amercader Date: Fri, 14 Jun 2019 16:08:06 +0200 Subject: [PATCH 2/4] [#4842] [#4842] Move internal redirect endpoint --- ckan/config/routing.py | 1 - .../templates/snippets/language_selector.html | 2 +- ckan/views/util.py | 25 +++++++++++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ckan/config/routing.py b/ckan/config/routing.py index 248477a636c..861bcb88e31 100644 --- a/ckan/config/routing.py +++ b/ckan/config/routing.py @@ -136,7 +136,6 @@ def make_map(): with SubMapper(map, controller='util') as m: m.connect('/i18n/strings_{lang}.js', action='i18n_js_strings') - m.connect('/util/redirect', action='redirect') # robots.txt map.connect('/(robots.txt)', controller='template', action='view') diff --git a/ckan/templates/snippets/language_selector.html b/ckan/templates/snippets/language_selector.html index a092949b349..ae95e27fd43 100644 --- a/ckan/templates/snippets/language_selector.html +++ b/ckan/templates/snippets/language_selector.html @@ -1,5 +1,5 @@ {% set current_lang = request.environ.CKAN_LANG %} -
+