From 211737a8e83e923db35ae99068381993aca29ec5 Mon Sep 17 00:00:00 2001 From: amercader Date: Wed, 26 Jun 2019 16:05:08 +0200 Subject: [PATCH] [#4874] Allow to provide a custom DataProxy URL Adds support for providing a custom DataProxy URL via config option. This will pave the way for deprecating it and completely removing it in the near future. If someone really wants to use it they can host it themselves and update the URL that Recline uses. --- ckanext/reclineview/plugin.py | 9 ++++++++- ckanext/reclineview/theme/public/recline_view.js | 6 +++++- ckanext/reclineview/theme/templates/recline_view.html | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ckanext/reclineview/plugin.py b/ckanext/reclineview/plugin.py index d17ec967a35..6e3866647be 100644 --- a/ckanext/reclineview/plugin.py +++ b/ckanext/reclineview/plugin.py @@ -21,6 +21,12 @@ def get_mapview_config(): if k.startswith(namespace)]) +def get_dataproxy_url(): + ''' + Returns the value of the ckan.recline.dataproxy_url config option + ''' + return config.get('ckan.recline.dataproxy_url', '//jsonpdataproxy.appspot.com') + def in_list(list_possible_values): ''' Validator that checks that the input value is one of the given @@ -83,7 +89,8 @@ def view_template(self, context, data_dict): def get_helpers(self): return { - 'get_map_config': get_mapview_config + 'get_map_config': get_mapview_config, + 'get_dataproxy_url': get_dataproxy_url, } diff --git a/ckanext/reclineview/theme/public/recline_view.js b/ckanext/reclineview/theme/public/recline_view.js index 0aa873d0737..65a539d2b82 100644 --- a/ckanext/reclineview/theme/public/recline_view.js +++ b/ckanext/reclineview/theme/public/recline_view.js @@ -2,7 +2,8 @@ this.ckan.module('recline_view', function (jQuery) { return { options: { site_url: "", - controlsClassName: "controls" + controlsClassName: "controls", + dataproxyUrl: "//jsonpdataproxy.appspot.com" }, initialize: function () { @@ -44,6 +45,9 @@ this.ckan.module('recline_view', function (jQuery) { if (!resourceData.datastore_active) { recline.Backend.DataProxy.timeout = 10000; + + recline.Backend.DataProxy.dataproxy_url = this.options.dataproxyUrl; + resourceData.backend = 'dataproxy'; } else { resourceData.backend = 'ckan'; diff --git a/ckanext/reclineview/theme/templates/recline_view.html b/ckanext/reclineview/theme/templates/recline_view.html index 213a8382af6..1b9fe8f2f00 100644 --- a/ckanext/reclineview/theme/templates/recline_view.html +++ b/ckanext/reclineview/theme/templates/recline_view.html @@ -8,6 +8,7 @@ data-module-resource = "{{ h.dump_json(resource_json) }}"; data-module-resource-view = "{{ h.dump_json(resource_view_json) }}"; data-module-map_config= "{{ h.dump_json(map_config) }}"; + data-module-dataproxy-url= "{{ h.get_dataproxy_url() }}" >