feat: Add oxitraffic support

This commit is contained in:
moanos [he/him] 2024-05-31 17:30:58 +02:00
parent f4ac22ba3d
commit 4857447c29
3 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,4 @@
{% load custom_tags %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
@ -14,7 +15,7 @@
<link rel="apple-touch-icon" sizes="180x180" href="{% static 'fellchensammlung/favicon/apple-touch-icon.png' %}"> <link rel="apple-touch-icon" sizes="180x180" href="{% static 'fellchensammlung/favicon/apple-touch-icon.png' %}">
<link rel="icon" type="image/png" sizes="32x32" href="{% static 'fellchensammlung/favicon/favicon-32x32.png' %}"> <link rel="icon" type="image/png" sizes="32x32" href="{% static 'fellchensammlung/favicon/favicon-32x32.png' %}">
<link rel="icon" type="image/png" sizes="16x16" href="{% static 'fellchensammlung/favicon/favicon-16x16.png' %}"> <link rel="icon" type="image/png" sizes="16x16" href="{% static 'fellchensammlung/favicon/favicon-16x16.png' %}">
{% get_oxitraffic_script_if_enabled %}
</head> </head>
<body> <body>
{% block header %} {% block header %}

View File

@ -3,6 +3,7 @@ import markdown
from django import template from django import template
from django.template.defaultfilters import stringfilter from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from notfellchen import settings
register = template.Library() register = template.Library()
@ -30,6 +31,7 @@ def join_link(value, arg):
def get_type(value): def get_type(value):
return type(value) return type(value)
@register.filter @register.filter
@stringfilter @stringfilter
def render_markdown(value): def render_markdown(value):
@ -37,3 +39,11 @@ def render_markdown(value):
html = md.convert(value) html = md.convert(value)
return mark_safe(html) return mark_safe(html)
@register.simple_tag
def get_oxitraffic_script_if_enabled():
if settings.OXITRAFFIC_ENABLED:
return mark_safe(f'<script type="module" src="https://{settings.OXITRAFFIC_BASE_URL}/count.js"></script>')
else:
return ""

View File

@ -82,6 +82,10 @@ LOCALE_PATHS = [os.path.join(BASE_DIR, 'locale')]
""" GEOCODING """ """ GEOCODING """
GEOCODING_API_URL = config.get("geocoding", "api_url", fallback="https://nominatim.hyteck.de/search") GEOCODING_API_URL = config.get("geocoding", "api_url", fallback="https://nominatim.hyteck.de/search")
""" OxiTraffic"""
OXITRAFFIC_ENABLED = config.get("tracking", "oxitraffic_enabled", fallback=False)
OXITRAFFIC_BASE_URL = config.get("tracking", "oxitraffic_base_url", fallback="")
""" E-MAIL """ """ E-MAIL """
console_only = config.getboolean("mail", "console_only", fallback="true") console_only = config.getboolean("mail", "console_only", fallback="true")
EMAIL_SUBJECT_PREFIX = config.get("mail", "prefix", fallback="[notfellchen]]") EMAIL_SUBJECT_PREFIX = config.get("mail", "prefix", fallback="[notfellchen]]")