From 0f3eff8f883f3f9fd62926f7e9ca10a75753959d Mon Sep 17 00:00:00 2001 From: zaziemo Date: Wed, 9 Sep 2015 15:24:00 +0200 Subject: [PATCH] add correct attributions for map tiles of Heidelberg University remove personal credentials from mapbox and refactored some code #5813 Signed-off-by: zaziemo --- .../javascripts/app/views/location_stream.js | 14 ++++++---- .../single_post_content_view.js | 17 +++++------ config/defaults.yml | 4 +-- config/diaspora.yml.example | 4 +-- spec/models/reshare_spec.rb | 28 +++++++++---------- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/app/assets/javascripts/app/views/location_stream.js b/app/assets/javascripts/app/views/location_stream.js index 25687585b..63f7a6560 100644 --- a/app/assets/javascripts/app/views/location_stream.js +++ b/app/assets/javascripts/app/views/location_stream.js @@ -15,16 +15,18 @@ app.views.LocationStream = app.views.Content.extend({ mapContainer.css("height", "150px"); if (location.lat) { - // If the mapbox option is enabled in the defaults the mapbox tiles with the podmin's credentials are used. - // If mapbox is not enabled the OpenMapSurfer tiles are used, which don't need credentials. + + // If the mapbox option is enabled in the diaspora.yml, the mapbox tiles with the podmin's credentials are used. + // If mapbox is not enabled the Maptiles from the Heidelberg University are used, which don't need credentials. var mapsource = gon.appConfig.map.mapbox.enabled ? gon.appConfig.map.mapbox : ""; var tileLayerSource = mapsource ? "https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}" : "http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}"; - var tileAttribution = mapsource ? "Mapbox" - : "OpenMapSurfer"; + var tileAttribution = mapsource ? "CC-BY-SA, " + + "Imagery © Mapbox" + : "rendering " + + "GIScience Research Group @ Heidelberg University"; var attribution = "Map data © OpenStreetMap contributors, " + - "CC-BY-SA, " + - "Imagery © "+ tileAttribution; + tileAttribution; var map = L.map(mapContainer[0]).setView([location.lat, location.lng], 14); L.tileLayer(tileLayerSource, { diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_content_view.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_content_view.js index 7cca84507..a5d1c8679 100644 --- a/app/assets/javascripts/app/views/single-post-viewer/single_post_content_view.js +++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_content_view.js @@ -5,7 +5,7 @@ app.views.SinglePostContent = app.views.Base.extend({ "click .near-from": "toggleMap" }, - templateName: 'single-post-viewer/single-post-content', + templateName: "single-post-viewer/single-post-content", tooltipSelector: "time, .post_scope", subviews : { @@ -14,7 +14,7 @@ app.views.SinglePostContent = app.views.Base.extend({ "#real-post-content" : "postContentView", ".oembed" : "oEmbedView", ".opengraph" : "openGraphView", - '.poll': 'pollView', + ".poll": "pollView", }, initialize : function() { @@ -37,16 +37,17 @@ app.views.SinglePostContent = app.views.Base.extend({ // get location data and render map var location = this.model.get("location"); - // If the mapbox option is enabled in the defaults the mapbox tiles with the podmin's credentials are used. - // If mapbox is not enabled the OpenMapSurfer tiles are used, which don't need credentials. + // If the mapbox option is enabled in the diaspora.yml, the mapbox tiles with the podmin's credentials are used. + // If mapbox is not enabled the Maptiles from the Heidelberg University are used, which don't need credentials. var mapsource = gon.appConfig.map.mapbox.enabled ? gon.appConfig.map.mapbox : ""; var tileLayerSource = mapsource ? "https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}" : "http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}"; - var tileAttribution = mapsource ? "Mapbox" - : "OpenMapSurfer"; + var tileAttribution = mapsource ? "CC-BY-SA, " + + "Imagery © Mapbox" + : "rendering " + + "GIScience Research Group @ Heidelberg University"; var attribution = "Map data © OpenStreetMap contributors, " + - "CC-BY-SA, " + - "Imagery © "+ tileAttribution; + tileAttribution; var map = L.map(mapContainer[0]).setView([location.lat, location.lng], 14); L.tileLayer(tileLayerSource, { diff --git a/config/defaults.yml b/config/defaults.yml index 3d558d167..c876a2fa1 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -79,8 +79,8 @@ defaults: enabled: true mapbox: enabled: false - id: "zaziemo.mpn66kn8" - access_token: "pk.eyJ1IjoiemF6aWVtbyIsImEiOiI3ODVjMzVjNmM2ZTU3YWM3YTE5YWYwMTRhODljM2M1MSJ9.-nVgyS4PLnV4m9YkvMB5wA" + id: + access_token: privacy: jquery_cdn: false google_analytics_key: diff --git a/config/diaspora.yml.example b/config/diaspora.yml.example index fb01cadd1..f72fdf370 100644 --- a/config/diaspora.yml.example +++ b/config/diaspora.yml.example @@ -334,9 +334,9 @@ configuration: ## Section ## and access_token. map: ##Section - # enable: false + # enabled: true # mapbox: - # enable: false + # enabled: false # id: 'your.id' # access_token: 'youraccesstoken' diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb index bfaff0dc6..0e13aacd4 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -292,24 +292,24 @@ describe Reshare, type: :model do end describe "#post_location" do - let(:status_message) { build(:status_message, text: "This is a status_message", author: bob.person, public: true) } - let(:reshare) { create(:reshare, root: status_message) } + let(:status_message) { build(:status_message, text: "This is a status_message", author: bob.person, public: true) } + let(:reshare) { create(:reshare, root: status_message) } - context "with location" do - let(:location) { build(:location) } + context "with location" do + let(:location) { build(:location) } - it "should deliver address and coordinates" do - status_message.location = location - expect(reshare.post_location).to include(address: location.address, lat: location.lat, lng: location.lng) - end + it "should deliver address and coordinates" do + status_message.location = location + expect(reshare.post_location).to include(address: location.address, lat: location.lat, lng: location.lng) end + end - context "without location" do - it "should deliver empty address and coordinates" do - expect(reshare.post_location[:address]).to be_nil - expect(reshare.post_location[:lat]).to be_nil - expect(reshare.post_location[:lng]).to be_nil - end + context "without location" do + it "should deliver empty address and coordinates" do + expect(reshare.post_location[:address]).to be_nil + expect(reshare.post_location[:lat]).to be_nil + expect(reshare.post_location[:lng]).to be_nil end end end +end