From 03f28482835ad56f2fcee1ebde4a405d28b54b56 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Fri, 15 Oct 2021 16:28:59 +0200 Subject: [PATCH] templates: Extract media_entry and link_entry to macros --- server/templates/collection_element.htm | 21 ++----------------- server/templates/macros.htm | 28 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/server/templates/collection_element.htm b/server/templates/collection_element.htm index e9bfb64..c75571e 100644 --- a/server/templates/collection_element.htm +++ b/server/templates/collection_element.htm @@ -29,14 +29,7 @@ Next Episode: {% set link = collection.next_episode %} {% if link %} - {{ macros.media_element_buttons(link.element) }} - {{ link.element.title }} - {%- if link.season != 0 -%} - , Season {{ link.season }} - {% endif %} - {%- if link.episode != 0 -%} - , Episode {{ link.episode }} - {% endif %} + {{ macros.link_entry_content(link) }} {% else %} no next episode {% endif %} @@ -48,17 +41,7 @@

Episodes

Links

diff --git a/server/templates/macros.htm b/server/templates/macros.htm index 3937a59..d03e373 100644 --- a/server/templates/macros.htm +++ b/server/templates/macros.htm @@ -52,3 +52,31 @@ {{ post_form(api_uri, "ignored", "true", "Ignore", fragment) }} {% endif %} {% endmacro %} + +{% macro media_entry_content(element) %} + {{ media_element_buttons(element) }} + {{ element.release_date.strftime("%d.%m.%Y") }} + {{ element.title }} +{%- endmacro %} + +{% macro link_entry_content(link) %} + {{ media_entry_content(link.element) -}} + {%- if link.season != 0 -%} + , Season {{ link.season }} + {%- endif -%} + {%- if link.episode != 0 -%} + , Episode {{ link.episode }} + {%- endif -%} +{%- endmacro %} + +{% macro media_entry(element) %} +
  • + {{ media_entry_content(element) }} +
  • +{%- endmacro %} + +{% macro link_entry(link) %} +
  • + {{ link_entry_content(link) }} +
  • +{%- endmacro %}