From d301344af2ad677188c2791d89863c6d2e804df7 Mon Sep 17 00:00:00 2001
From: tvluke <tvluke@chaotikum.org>
Date: Mon, 11 Nov 2024 17:03:34 +0100
Subject: [PATCH] infrainfo

---
 _includes/infrainfo.html | 43 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 _includes/infrainfo.html

diff --git a/_includes/infrainfo.html b/_includes/infrainfo.html
new file mode 100644
index 00000000..2053b87b
--- /dev/null
+++ b/_includes/infrainfo.html
@@ -0,0 +1,43 @@
+{% assign display_info =  0 -%}
+
+{% if component.out_of_service -%}
+	{% assign display_info =  1 -%}
+{% endif -%}
+
+{% capture nowunix %}{{'now' | date: '%s'}}{% endcapture %}
+{%- capture next_week %}{{'now'  | date: '%s' | plus: 604800 }}{%- endcapture -%}
+
+{% for maintenance in site.maintenance -%}
+	{% capture eventdate %}{{maintenance.eventdate | date: '%s'}}{% endcapture %}
+	{% capture eventend %}{{maintenance.eventend | date: '%s'}}{% endcapture %}
+	{% if maintenance.components -%}
+		{% if maintenance.components contains component.uid -%}
+			{% if  eventdate < nowunix -%}
+				{% if  nowunix < eventend -%}
+					{% assign display_info =  2 -%}
+				{% endif -%}
+			{% endif -%}
+			{% if eventdate < next_week -%}
+				{% assign display_info =  3 -%}
+			{% endif -%}
+		{% endif -%}
+	{% endif -%}
+{% endfor -%}
+
+{% if display_info == 1 -%}
+<div style="line-height: 18pt; margin:10px 0; width: 100%; background-color: #FFB390; border-width: thick; border-color: #e67206; border-radius: 10px; min-height: 40pt; ">
+	<span style="float: left; color: #e67206; font-size: 40pt; display:block; width: 50pt; height: 40pt; text-align:center; line-height: 40pt;">⚠</span><p style="vertical-align: middle;">Ist aktuell außer Betrieb.</p>
+</div>
+{% endif -%}
+
+{% if display_info == 2 -%}
+<div style="line-height: 18pt; margin:10px 0; width: 100%; background-color: #FFB390; border-width: thick; border-color: #e67206; border-radius: 10px; min-height: 40pt; ">
+	<span style="float: left; color: #e67206; font-size: 40pt; display:block; width: 50pt; height: 40pt; text-align:center; line-height: 40pt;">âš </span><p style="vertical-align: middle;">Laufende Wartung.</p>
+</div>
+{% endif -%}
+
+{% if display_info == 3 -%}
+<div style="line-height: 18pt; margin:10px 0; width: 100%; background-color: #FFF8DC; border-width: thick; border-color: #e67206; border-radius: 10px; min-height: 40pt; ">
+	<span style="float: left; color: #e67206; font-size: 40pt; display:block; width: 50pt; height: 40pt; text-align:center; line-height: 40pt;">⚠</span><p style="vertical-align: middle;">Innerhalb der nächsten 7 Tage ist eine Wartung geplant.</p>
+</div>
+{% endif -%}
\ No newline at end of file
-- 
GitLab