aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2022-07-27 14:23:49 +0200
committerDaniel Schadt <kingdread@gmx.de>2022-07-27 14:24:03 +0200
commit38f3d67eb385dfb93b1fe9a7301225b1e4993b77 (patch)
tree6de1762d2fb9b255e2b887f5d2e01cc464b38f5a
parentc8dabf56193abe520cd48fdb9b54987f182c28ec (diff)
downloadfietsboek-38f3d67eb385dfb93b1fe9a7301225b1e4993b77.tar.gz
fietsboek-38f3d67eb385dfb93b1fe9a7301225b1e4993b77.tar.bz2
fietsboek-38f3d67eb385dfb93b1fe9a7301225b1e4993b77.zip
allow embedding a Thunderforest API key
-rw-r--r--doc/administration/configuration.rst9
-rw-r--r--fietsboek/templates/layout.jinja28
2 files changed, 17 insertions, 0 deletions
diff --git a/doc/administration/configuration.rst b/doc/administration/configuration.rst
index 3927540..272ac71 100644
--- a/doc/administration/configuration.rst
+++ b/doc/administration/configuration.rst
@@ -74,3 +74,12 @@ Most of the configuration is in the ``[app:main]`` category and looks like this:
* ``email.username`` and ``email.password`` can be used to set the login
information for the SMTP server.
+* ``thunderforest.api_key`` can be set to an API key of `Thunderforest
+ <https://www.thunderforest.com/>`__ to enable support for the OpenCycleMap,
+ Landscape and Outdoors maps.
+
+.. warning::
+
+ The API key will be embedded in the source of the website, therefore it is
+ possible for visitors to "steal" the API key. Keep that in mind when
+ setting an API key for a publicly accessible site!
diff --git a/fietsboek/templates/layout.jinja2 b/fietsboek/templates/layout.jinja2
index 83a8f33..984a790 100644
--- a/fietsboek/templates/layout.jinja2
+++ b/fietsboek/templates/layout.jinja2
@@ -21,6 +21,14 @@
<script>
const FRIENDS_URL = "{{ request.route_url('json-friends') }}";
const LOCALE = "{{ request.localizer.locale_name.replace('_', '-') }}";
+{% if request.registry.settings.get("thunderforest.api_key") %}
+{% set api_key = request.registry.settings.get("thunderforest.api_key") %}
+window.JB = window.JB || {};
+window.JB.GPX2GM = window.JB.GPX2GM || {};
+window.JB.GPX2GM.OSM_Cycle_Api_Key = "{{ api_key }}";
+window.JB.GPX2GM.OSM_Landscape_Api_Key = "{{ api_key }}";
+window.JB.GPX2GM.OSM_Outdoors_Api_Key = "{{ api_key }}";
+{% endif %}
</script>
</head>