From 278306daa40b4df243af6df07eaa02ffc0d5a10b Mon Sep 17 00:00:00 2001 From: CasperVerswijvelt Date: Wed, 21 Apr 2021 20:13:49 +0200 Subject: [PATCH] Add custom location url from environment variable --- TEMPLATE.env | 11 ++++++++++- app.json | 5 +++++ .../templates/dashboard/pages/service_session.html | 2 +- shynet/dashboard/templatetags/helpers.py | 4 ++++ shynet/shynet/settings.py | 3 +++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/TEMPLATE.env b/TEMPLATE.env index d40ebb7..95388dd 100644 --- a/TEMPLATE.env +++ b/TEMPLATE.env @@ -82,4 +82,13 @@ BLOCK_ALL_IPS=False # that IP collection is also disabled, and external keys (primary # keys) aren't supplied. It will also prevent sessions from spanning # one day to another. -AGGRESSIVE_HASH_SALTING=True \ No newline at end of file +AGGRESSIVE_HASH_SALTING=True + +# Custom location url to link to in frontend. +# $LATITUDE$ will get replaced by the latitude, $LONGITUDE$ will get +# replaced by the longitude. +# Examples: +# - https://www.openstreetmap.org/?mlat=$LATITUDE$&mlon=$LONGITUDE$ (default) +# - https://www.google.com/maps/search/?api=1&query=$LATITUDE$,$LONGITUDE$ +# - https://www.mapquest.com/near-$LATITUDE$,$LONGITUDE$ +LOCATION_URL=https://www.openstreetmap.org/?mlat=$LATITUDE$&mlon=$LONGITUDE$ \ No newline at end of file diff --git a/app.json b/app.json index 329ff37..68b9b97 100644 --- a/app.json +++ b/app.json @@ -122,6 +122,11 @@ "description": "Set to 'False' if you do not want the version to be displayed on the frontend.", "value": "True", "required": false + }, + "LOCATION_URL": { + "description": "Custom location url to link to in frontend.", + "value": "https://www.openstreetmap.org/?mlat=$LATITUDE$&mlon=$LONGITUDE$", + "required": false } } } diff --git a/shynet/dashboard/templates/dashboard/pages/service_session.html b/shynet/dashboard/templates/dashboard/pages/service_session.html index c201a02..cf5cc8b 100644 --- a/shynet/dashboard/templates/dashboard/pages/service_session.html +++ b/shynet/dashboard/templates/dashboard/pages/service_session.html @@ -51,7 +51,7 @@

Location

{% if session.latitude %} - Open + Open in Maps ↗ {% else %} Unknown diff --git a/shynet/dashboard/templatetags/helpers.py b/shynet/dashboard/templatetags/helpers.py index a494c2c..82b5192 100644 --- a/shynet/dashboard/templatetags/helpers.py +++ b/shynet/dashboard/templatetags/helpers.py @@ -184,3 +184,7 @@ def urldisplay(url): ) else: return url + +@register.filter +def locationUrl(session): + return settings.LOCATION_URL.replace("$LATITUDE$", str(session.latitude)).replace("$LONGITUDE$", str(session.longitude)) \ No newline at end of file diff --git a/shynet/shynet/settings.py b/shynet/shynet/settings.py index 9bd510e..c5f2d7d 100644 --- a/shynet/shynet/settings.py +++ b/shynet/shynet/settings.py @@ -339,3 +339,6 @@ BLOCK_ALL_IPS = os.getenv("BLOCK_ALL_IPS", "False") == "True" # Include date and service ID in salt? AGGRESSIVE_HASH_SALTING = os.getenv("AGGRESSIVE_HASH_SALTING", "False") == "True" + +# What location url should be linked to in the frontend? +LOCATION_URL = os.getenv("LOCATION_URL", "https://www.openstreetmap.org/?mlat=$LATITUDE$&mlon=$LONGITUDE$")