From 0c7c0837b143df33a98ddcf0b15a532b7d3b8fcb Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Fri, 19 Aug 2016 13:36:43 -0400 Subject: [PATCH 1/3] Override URL for openlayers.js Fixes #489. The URL for openlayers.js in GeoDjango defaults to HTTP, but is configurable. --- python/cac_tripplanner/destinations/admin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/cac_tripplanner/destinations/admin.py b/python/cac_tripplanner/destinations/admin.py index 5547514e3..9d99ba16d 100644 --- a/python/cac_tripplanner/destinations/admin.py +++ b/python/cac_tripplanner/destinations/admin.py @@ -18,6 +18,10 @@ class DestinationAdmin(admin.OSMGeoAdmin): # Override map_template for custom address geocoding behavior map_template = 'admin/cac-geocoding-map.html' + # Override configurable URL for openlayers.js to support SSL + # default is: 'http://openlayers.org/api/2.13.1/OpenLayers.js' + openlayers_url = 'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js' + # Include geocoder dependencies jquery = 'https://code.jquery.com/jquery-2.1.3.min.js' if settings.DEBUG: From eb124635db3887380b71b38247ae89cf34e34a0a Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Fri, 19 Aug 2016 13:58:47 -0400 Subject: [PATCH 2/3] Add missing admin script in debug Fixes issue with SearchParams not being found for admin interface map in debug mode. --- python/cac_tripplanner/destinations/admin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/cac_tripplanner/destinations/admin.py b/python/cac_tripplanner/destinations/admin.py index 9d99ba16d..7ea1887b8 100644 --- a/python/cac_tripplanner/destinations/admin.py +++ b/python/cac_tripplanner/destinations/admin.py @@ -29,6 +29,7 @@ class DestinationAdmin(admin.OSMGeoAdmin): jquery, '/static/scripts/vendor/lodash.js', '/static/scripts/main/cac/cac.js', + '/static/scripts/main/cac/search/cac-search-params.js', '/static/scripts/main/cac/search/cac-geocoder.js' ] else: From 154e188e89b0348c25e066887859d401a960bcef Mon Sep 17 00:00:00 2001 From: Kathryn Killebrew Date: Fri, 19 Aug 2016 15:47:22 -0400 Subject: [PATCH 3/3] Explicitly load admin map tiles via SSL OpenLayers defaults to the site scheme, but we redirect to HTTPS, so explicitly load admin map tiles via HTTPS. Fixes admin interface map tiles not loading due to CSP. --- .../templates/admin/cac-geocoding-map.html | 2 +- .../templates/admin/cac-geocoding-map.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/python/cac_tripplanner/templates/admin/cac-geocoding-map.html b/python/cac_tripplanner/templates/admin/cac-geocoding-map.html index 07516891f..41c42a733 100644 --- a/python/cac_tripplanner/templates/admin/cac-geocoding-map.html +++ b/python/cac_tripplanner/templates/admin/cac-geocoding-map.html @@ -1,4 +1,4 @@ -{% extends 'gis/admin/osm.html' %} +{% extends "gis/admin/openlayers.html" %} {% block openlayers %} {% include 'admin/cac-geocoding-map.js' %} diff --git a/python/cac_tripplanner/templates/admin/cac-geocoding-map.js b/python/cac_tripplanner/templates/admin/cac-geocoding-map.js index 0123f8916..314531535 100644 --- a/python/cac_tripplanner/templates/admin/cac-geocoding-map.js +++ b/python/cac_tripplanner/templates/admin/cac-geocoding-map.js @@ -1,4 +1,12 @@ -{% extends 'gis/admin/osm.js' %} +{% extends "gis/admin/openlayers.js" %} +{% block base_layer %} +// explicitly load via SSL to deal with redirect to HTTPS +new OpenLayers.Layer.OSM("OpenStreetMap", [ + 'https://a.tile.openstreetmap.org/${z}/${x}/${y}.png', + 'https://b.tile.openstreetmap.org/${z}/${x}/${y}.png', + 'https://c.tile.openstreetmap.org/${z}/${x}/${y}.png' +]); +{% endblock %} {% block extra_layers %}