-
Notifications
You must be signed in to change notification settings - Fork 941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Put api keys directly in js layer definitions #5352
base: master
Are you sure you want to change the base?
Put api keys directly in js layer definitions #5352
Conversation
I'm sure this could be improved, but a massive multi line block of ruby embedded is a js file is definitely not the answer to my mind at least. |
25279c4
to
37ce56f
Compare
I moved that ruby code to a module, but now there's no dependency on it. If it's changed, |
32d95eb
to
7571bdf
Compare
Also don't generate definitions for layers that have require missing api keys.
7571bdf
to
2588e2b
Compare
@@ -42,7 +42,7 @@ | |||
code: "T" | |||
layerId: "transportmap" | |||
nameId: "transport_map" | |||
apiKeyId: "THUNDERFOREST_KEY" | |||
apiKeyId: "thunderforest_key" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this is used in embed.js.erb as well, that file would need to be accommodated too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @hlfan says this will need modifying to support embed.js.erb
now - possibly the block of ruby code there should become an extra method in the MapLayers
library that this introduces?
Maybe something along the lines of this? def self.embedDefinitions(layers_filename)
self.definitions(layers_filename)
.select { |entry| entry["canEmbed"] }
.each_with_object({}) do |entry, obj|
obj[entry["layerId"]] = {
layer: entry["leafletOsmId"],
darkLayer: entry["leafletOsmDarkId"],
apikey: entry["apikey"]
}.compact
end
end But I'm no ruby expert |
Currently map layer API keys have one extra level of indirection:
osm.js.erb
reads them from the settings and writes them toOSM.THUNDERFOREST_KEY
andOSM.TRACESTRACK_KEY
layers.yml
contain names ofOSM
properties to check for keysInstead of this
osm.js.erb
could write keys directly to layer definitions, skippingOSM.THUNDERFOREST_KEY
andOSM.TRACESTRACK_KEY
.layers.yml
could contain the corresponding settings names. The advantage is that Thunderforest and Tracestrack keys are no longer special. A new key can be added just by editingsettings.yml
andlayers.yml
. Also it's possible to skip layer definitions if they require a key and that key is missing.