make editing the title not change sidebar/banner

pull/225/head
Aevann 2024-02-21 22:28:26 +02:00
parent 92872444cf
commit 37c7fee1fb
2 changed files with 7 additions and 4 deletions

View File

@ -89,9 +89,8 @@ def selected_tab(request):
return 'home'
@app.template_filter("seeded_random")
def seeded_random(choices, url):
if url.startswith('/post/'):
random.seed(url)
def seeded_random(choices, seed):
random.seed(seed)
return random.choice(choices)

View File

@ -5,7 +5,11 @@
{%- endmacro -%}
{%- macro random_image(path) -%}
{{- SITE_FULL_IMAGES ~ "/" ~ path ~ "/" ~ listdir('files/' ~ path)|seeded_random(request.path) ~ '?x=7' -}}
{% if request.path.startswith('/post/') and p %}
{{- SITE_FULL_IMAGES ~ "/" ~ path ~ "/" ~ listdir('files/' ~ path)|seeded_random(p.id) ~ '?x=7' -}}
{% else %}
{{- SITE_FULL_IMAGES ~ "/" ~ path ~ "/" ~ listdir('files/' ~ path)|random() ~ '?x=7' -}}
{% endif %}
{%- endmacro -%}
{% macro post_meta(p) %}