Move map tiles provider server and map tiles attribution to secrets.

This commit is contained in:
Senén Rodero Rodríguez
2017-08-08 16:07:33 +02:00
parent 5113fefef6
commit 5a09b79da4
4 changed files with 11 additions and 22 deletions

View File

@@ -15,12 +15,11 @@ App.Map =
markerLongitude = $(element).data('marker-longitude')
zoom = $(element).data('map-zoom')
mapTilesProvider = $(element).data('map-tiles-provider')
mapAttributionSelector = $(element).data('map-tiles-attribution-selector')
mapAttribution = $(element).data('map-tiles-provider-attribution')
latitudeInputSelector = $(element).data('latitude-input-selector')
longitudeInputSelector = $(element).data('longitude-input-selector')
zoomInputSelector = $(element).data('zoom-input-selector')
removeMarkerSelector = $(element).data('marker-remove-selector')
attribution = $(mapAttributionSelector)
editable = $(element).data('marker-editable')
marker = null;
markerIcon = L.divIcon(
@@ -68,7 +67,7 @@ App.Map =
mapCenterLatLng = new (L.LatLng)(mapCenterLatitude, mapCenterLongitude)
map = L.map(element.id).setView(mapCenterLatLng, zoom)
L.tileLayer(mapTilesProvider, attribution: attribution.html()).addTo map
L.tileLayer(mapTilesProvider, attribution: mapAttribution).addTo map
if markerLatitude && markerLongitude
marker = createMarker(markerLatitude, markerLongitude)

View File

@@ -20,10 +20,6 @@ module MapLocationsHelper
"#{prefix}_map_location_attributes_#{attribute}"
end
def map_location_attribution_id(map_location)
"attribution-#{dom_id(map_location)}"
end
def map_location_remove_marker_link_id(map_location)
"remove-marker-link-#{dom_id(map_location)}"
end
@@ -33,18 +29,10 @@ module MapLocationsHelper
map_location,
class: "map",
data: prepare_map_settings(map_location, editable, parent_class)
map += map_attributtion(map_location)
map += map_location_remove_marker(map_location, remove_marker_label) if editable
map
end
def map_attributtion(map_location, klass = nil)
content = "©#{link_to("OpenStreetMap", "http://osm.org/copyright")} contributors".html_safe
content_tag :div, id: map_location_attribution_id(map_location), class: "map-attributtion #{klass}" do
content
end
end
def map_location_remove_marker(map_location, text)
content_tag :div, class: "small-12 column text-right" do
content_tag :a,
@@ -63,8 +51,8 @@ module MapLocationsHelper
map_center_latitude: map_location_latitude(map_location),
map_center_longitude: map_location_longitude(map_location),
map_zoom: map_location_zoom(map_location),
map_tiles_attribution_selector: map_location_attribution_id(map_location),
map_tiles_provider: "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
map_tiles_provider: Rails.application.secrets.map_tiles_provider,
map_tiles_provider_attribution: Rails.application.secrets.map_tiles_provider_attribution,
marker_editable: editable,
marker_latitude: map_location.latitude,
marker_longitude: map_location.longitude,

View File

@@ -5,8 +5,8 @@
data-map-center-latitude="<%= Setting["map_latitude"] %>"
data-map-center-longitude="<%= Setting["map_longitude"] %>"
data-map-zoom="<%= Setting["map_zoom"] %>"
data-map-tiles-attribution-selector="#admin-map-attribution"
data-map-tiles-provider="//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
data-map-tiles-provider="<%= Rails.application.secrets.map_tiles_provider %>"
data-map-tiles-provider-attribution="<%= Rails.application.secrets.map_tiles_provider_attribution %>"
data-marker-editable="true"
data-marker-latitude="<%= Setting["map_latitude"] %>"
data-marker-longitude="<%= Setting["map_longitude"] %>"
@@ -14,9 +14,6 @@
data-longitude-input-selector="#longitude"
data-zoom-input-selector="#zoom">
</div>
<div id="admin-map-attribution" class="map-attributtion">
&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors
</div>
<%= form_tag admin_update_map_path, method: :put, id: 'map-form' do |f| %>

View File

@@ -1,5 +1,7 @@
default: &default
secret_key_base: "56792feef405a59b18ea7db57b4777e855103882b926413d4afdfb8c0ea8aa86ea6649da4e729c5f5ae324c0ab9338f789174cf48c544173bc18fdc3b14262e4"
map_tiles_provider: "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
map_tiles_provider_attribution: "&copy; <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors"
development:
<<: *default
@@ -36,6 +38,9 @@ production: &production
rollbar_server_token: ""
server_name: ""
map_tiles_provider: "//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
map_tiles_provider_attribution: "&copy; <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors"
preproduction:
server_name: ""
<<: *production