From b3bb16cce4a04d53fdb37098165708a5765ec2e5 Mon Sep 17 00:00:00 2001 From: Hendrik L Date: Mon, 9 Dec 2024 13:39:05 +0100 Subject: [PATCH 1/5] reduce duplication in post template --- app/templates/post/_post_full.html | 79 +++++++++--------------------- 1 file changed, 24 insertions(+), 55 deletions(-) diff --git a/app/templates/post/_post_full.html b/app/templates/post/_post_full.html index e38ebc55..2b2eb26b 100644 --- a/app/templates/post/_post_full.html +++ b/app/templates/post/_post_full.html @@ -1,6 +1,5 @@
- {% if post.type == POST_TYPE_IMAGE -%} -
+
-

{{ post.title }} - {% if current_user.is_authenticated -%} - {% include 'post/_post_notification_toggle.html' -%} - {% endif -%} - {% if post.nsfw -%}nsfw{% endif -%} - {% if post.nsfl -%}nsfl{% endif -%} -

- {% if post.url -%} -

{{ post.url|shorten_url }} -

- {% endif -%} -

{% if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator(current_user) -%} - - {% endif -%}submitted {{ arrow.get(post.posted_at).humanize(locale=locale) }} by {{ render_username(post.author) }} - {% if post.edited_at -%} edited {{ arrow.get(post.edited_at).humanize(locale=locale) }}{% endif -%} -

-
- {% if post.image_id -%} - {% if low_bandwidth -%} - {{ post.image.alt_text if post.image.alt_text else post.title }} - {% else -%} - - {{ post.image.alt_text if post.image.alt_text else post.title }} - - {% endif -%} - {% else -%} - - {% endif -%} -
-
- {{ post.body_html|community_links|safe if post.body_html else '' }} - {% if post.licence_id -%} -

Licence: {{ post.licence.name }}

- {% endif -%} -
-
- {% else -%} -
-

{{ post.title }} {% if current_user.is_authenticated -%} {% include 'post/_post_notification_toggle.html' -%} @@ -72,6 +20,9 @@ {{ post.image.alt_text if post.image.alt_text else '' }}

+ {% elif post.type == POST_TYPE_IMAGE and post.url -%} +

{{ post.url|shorten_url }} +

{% endif -%}

{% if post.reports > 0 and current_user.is_authenticated and post.community.is_moderator(current_user) -%} @@ -79,7 +30,26 @@ {{ render_username(post.author) }} {% if post.edited_at -%} edited {{ arrow.get(post.edited_at).humanize(locale=locale) }}{% endif -%}

- {% if post.type == POST_TYPE_LINK -%} + {% if post.type == POST_TYPE_IMAGE -%} +
+ {% if post.image_id -%} + {% if low_bandwidth -%} + {{ post.image.alt_text if post.image.alt_text else post.title }} + {% else -%} + + {{ post.image.alt_text if post.image.alt_text else post.title }} + + {% endif -%} + {% else -%} + + {% endif -%} +
+ {% elif post.type == POST_TYPE_LINK -%}

{{ post.url|shorten_url }}

{% if post.url.endswith('.mp3') -%} @@ -189,7 +159,6 @@
{% endif -%}
- {% endif -%} {% if post.tags.count() > 0 -%}