From 500733eeb791b3960e0a7b116499ad8a27d207cf Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 29 Oct 2013 11:21:29 +0000 Subject: [PATCH 1/2] Default API_URL to SITE_URL if missing Otherwise file uploads and other calls where broken when using CKAN in a non-root location. --- ckan/public/base/javascript/client.js | 2 +- ckan/public/base/javascript/main.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ckan/public/base/javascript/client.js b/ckan/public/base/javascript/client.js index 45940c0086d..e1c60ccf24e 100644 --- a/ckan/public/base/javascript/client.js +++ b/ckan/public/base/javascript/client.js @@ -370,7 +370,7 @@ }); ckan.sandbox.setup(function (instance) { - instance.client = new Client({endpoint: ckan.API_ROOT}); + instance.client = new Client({endpoint: ckan.SITE_ROOT}); }); ckan.Client = Client; diff --git a/ckan/public/base/javascript/main.js b/ckan/public/base/javascript/main.js index 42c76dfd15f..843dc47442d 100644 --- a/ckan/public/base/javascript/main.js +++ b/ckan/public/base/javascript/main.js @@ -29,7 +29,9 @@ this.ckan = this.ckan || {}; ckan.SITE_ROOT = getRootFromData('siteRoot'); ckan.LOCALE_ROOT = getRootFromData('localeRoot'); - ckan.API_ROOT = getRootFromData('apiRoot'); + + // Not used, kept for backwards compatibility + ckan.API_ROOT = body.data('apiRoot') || ckan.SITE_ROOT; // Load the localisations before instantiating the modules. ckan.sandbox().client.getLocaleData(locale).done(function (data) { From 04d65785c97a6b8d44d70c8f6bdff4de50caf3b7 Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 5 Nov 2013 16:03:23 +0000 Subject: [PATCH 2/2] [#960] Remove ckan.api_url completely on 2.2 --- CHANGELOG.rst | 2 ++ ckan/lib/app_globals.py | 1 - ckan/public/base/javascript/main.js | 3 --- ckan/templates/base.html | 2 +- doc/configuration.rst | 18 ------------------ doc/legacy-api.rst | 6 ------ 6 files changed, 3 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b97798a4522..17dfb5069c2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,6 +12,8 @@ v2.2 API changes and deprecations: + +* The `ckan.api_url` has been completely removed and it can no longer be used * The edit() and after_update() methods of IPackageController plugins are now called when updating a resource using the web frontend or the resource_update API action [#1052] diff --git a/ckan/lib/app_globals.py b/ckan/lib/app_globals.py index 38c777f7555..38138e87815 100644 --- a/ckan/lib/app_globals.py +++ b/ckan/lib/app_globals.py @@ -44,7 +44,6 @@ 'ckan.template_footer_end': {}, 'ckan.dumps_url': {}, 'ckan.dumps_format': {}, - 'ckan.api_url': {}, 'ofs.impl': {'name': 'ofs_impl'}, 'ckan.homepage_style': {'default': '1'}, diff --git a/ckan/public/base/javascript/main.js b/ckan/public/base/javascript/main.js index 843dc47442d..c5f36ef7176 100644 --- a/ckan/public/base/javascript/main.js +++ b/ckan/public/base/javascript/main.js @@ -30,9 +30,6 @@ this.ckan = this.ckan || {}; ckan.SITE_ROOT = getRootFromData('siteRoot'); ckan.LOCALE_ROOT = getRootFromData('localeRoot'); - // Not used, kept for backwards compatibility - ckan.API_ROOT = body.data('apiRoot') || ckan.SITE_ROOT; - // Load the localisations before instantiating the modules. ckan.sandbox().client.getLocaleData(locale).done(function (data) { ckan.i18n.load(data); diff --git a/ckan/templates/base.html b/ckan/templates/base.html index 6012bf65928..b6290af0ad0 100644 --- a/ckan/templates/base.html +++ b/ckan/templates/base.html @@ -85,7 +85,7 @@ {# Allows custom attributes to be added to the tag #} - + {# The page block allows you to add content to the page. Most of the time it is diff --git a/doc/configuration.rst b/doc/configuration.rst index 0b623c5e656..c0768e148ab 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -130,24 +130,6 @@ site use this setting. This setting should not have a trailing / on the end. -.. _ckan.api_url: - -ckan.api_url -^^^^^^^^^^^^ - -.. deprecated:: 2 - No longer used. - -Example:: - - ckan.api_url = http://scotdata.ckan.net/api - -Default value: ``/api`` - -The URL that resolves to the CKAN API part of the site. This is useful if the -API is hosted on a different domain, for example when a third-party site uses -the forms API. - .. _apikey_header_name: apikey_header_name diff --git a/doc/legacy-api.rst b/doc/legacy-api.rst index b10841fc976..7ab990dc371 100644 --- a/doc/legacy-api.rst +++ b/doc/legacy-api.rst @@ -434,12 +434,6 @@ front-end javascript. All Util APIs are read-only. The response format is JSON. Javascript calls may want to use the JSONP formatting. -.. Note:: - - Some CKAN deployments have the API deployed at a different domain to the main CKAN website. To make sure that the AJAX calls in the Web UI work, you'll need to configue the ckan.api_url. e.g.:: - - ckan.api_url = http://api.example.com/ - dataset autocomplete ````````````````````