Add custom location url from environment variable

This commit is contained in:
CasperVerswijvelt 2021-04-21 20:13:49 +02:00
parent 9cb030ecbd
commit 278306daa4
5 changed files with 23 additions and 2 deletions

View File

@ -83,3 +83,12 @@ BLOCK_ALL_IPS=False
# keys) aren't supplied. It will also prevent sessions from spanning
# one day to another.
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$

View File

@ -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
}
}
}

View File

@ -51,7 +51,7 @@
<p>Location</p>
<p class="label">
{% if session.latitude %}
<a href="https://www.google.com/maps/search/?api=1&query={{session.latitude}},{{session.longitude}}">Open
<a href="{{session|locationUrl}}" target="_blank">Open
in Maps &nearr;</a>
{% else %}
Unknown

View File

@ -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))

View File

@ -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$")