From a84e1e2153fd92e856896b85170f9b085f1ca525 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 3 May 2026 16:25:16 +0200 Subject: [PATCH] Behebe Layoutauswahl unter aktuellem Hugo. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die layouts/_default/*.calendar.html-Vorlagen werden in Hugo ≥0.158 fälschlich für die HTML-Ausgabe ausgewählt, sodass alle Sektions- und Einzelseiten VCALENDAR- statt HTML-Inhalt enthielten. Die Vorlagen waren ohnehin nie funktionsfähig (Warnung „found no layout file for calendar"); die ICS-Feeds liefern die abschnittsspezifischen Vorlagen unter layouts/{veranstaltungen,datengarten,page}/. list.xml.html bekommt aus demselben Grund die korrekte Endung .xml. tools/gen_upcoming.py vergleicht Datumsangaben jetzt zeitzonenneutral, damit Events mit Z-Suffix keinen TypeError auslösen. Co-Authored-By: Claude Opus 4.7 (1M context) Signed-off-by: Hauke Mehrtens --- layouts/_default/baseof.calendar.html | 1 - layouts/_default/list.calendar.html | 21 ------------------- .../_default/{list.xml.html => list.xml.xml} | 0 layouts/_default/single.calendar.html | 21 ------------------- tools/gen_upcoming.py | 12 ++++++++++- 5 files changed, 11 insertions(+), 44 deletions(-) delete mode 100644 layouts/_default/baseof.calendar.html delete mode 100644 layouts/_default/list.calendar.html rename layouts/_default/{list.xml.html => list.xml.xml} (100%) delete mode 100644 layouts/_default/single.calendar.html diff --git a/layouts/_default/baseof.calendar.html b/layouts/_default/baseof.calendar.html deleted file mode 100644 index bddf04a..0000000 --- a/layouts/_default/baseof.calendar.html +++ /dev/null @@ -1 +0,0 @@ -{{ block "main" . }}{{ .Content }}{{ end }} diff --git a/layouts/_default/list.calendar.html b/layouts/_default/list.calendar.html deleted file mode 100644 index 3259690..0000000 --- a/layouts/_default/list.calendar.html +++ /dev/null @@ -1,21 +0,0 @@ -BEGIN:VCALENDAR -VERSION:2.0 -PRODID:-//CCCB//Calendar//DE -{{ with .Title }} -X-WR-CALNAME:{{ . }} -{{ end }} -CALSCALE:GREGORIAN -METHOD:PUBLISH -{{ range .Pages }} -{{ if .Date }} -BEGIN:VEVENT -UID:{{ .File.UniqueID }}@berlin.ccc.de -DTSTAMP:{{ .Date.Format "20060102T150405Z" }} -DTSTART:{{ .Date.Format "20060102T150405Z" }} -SUMMARY:{{ .Title }} -DESCRIPTION:{{ .Summary | plainify }} -URL:{{ .Permalink }} -END:VEVENT -{{ end }} -{{ end }} -END:VCALENDAR diff --git a/layouts/_default/list.xml.html b/layouts/_default/list.xml.xml similarity index 100% rename from layouts/_default/list.xml.html rename to layouts/_default/list.xml.xml diff --git a/layouts/_default/single.calendar.html b/layouts/_default/single.calendar.html deleted file mode 100644 index 5a22ec4..0000000 --- a/layouts/_default/single.calendar.html +++ /dev/null @@ -1,21 +0,0 @@ -BEGIN:VCALENDAR -VERSION:2.0 -PRODID:-//CCCB//Calendar//DE -{{ with .Title }} -X-WR-CALNAME:{{ . }} -{{ end }} -CALSCALE:GREGORIAN -METHOD:PUBLISH -{{ if .Date }} -BEGIN:VEVENT -UID:{{ .File.UniqueID }}@berlin.ccc.de -DTSTAMP:{{ .Date.Format "20060102T150405Z" }} -DTSTART:{{ .Date.Format "20060102T150405Z" }} -{{ with .Params.event.end }}DTEND:{{ dateFormat "20060102T150405Z" . }}{{ end }} -SUMMARY:{{ .Title }} -DESCRIPTION:{{ .Summary | plainify }} -URL:{{ .Permalink }} -{{ with .Params.location }}LOCATION:{{ . }}{{ end }} -END:VEVENT -{{ end }} -END:VCALENDAR diff --git a/tools/gen_upcoming.py b/tools/gen_upcoming.py index 0f69f6a..33b093d 100755 --- a/tools/gen_upcoming.py +++ b/tools/gen_upcoming.py @@ -3,13 +3,23 @@ import sys import logging import locale -from dateutil.parser import parse +from dateutil.parser import parse as _parse from datetime import datetime, timedelta from dateutil.rrule import rruleset, rrulestr import icalendar +def parse(value): + # Some templates emit DTSTART with a trailing "Z" (e.g. 20260507T190000Z) + # which produces tz-aware datetimes, while others emit naive local times. + # Normalize to naive so comparisons and sorting don't mix the two. + dt = _parse(value) + if dt.tzinfo is not None: + dt = dt.replace(tzinfo=None) + return dt + + def vevent_to_event(event, rrstart=None): if rrstart == None: begin = parse(event["DTSTART"].to_ical())