diff options
| author | Valentin <valentin@fricklerhandwerk.de> | 2025-12-22 19:08:49 +0100 |
|---|---|---|
| committer | Valentin <valentin@fricklerhandwerk.de> | 2025-12-22 19:08:55 +0100 |
| commit | a44365cdbdc1444416b279d5df7a396bdadd1093 (patch) | |
| tree | 40aef7209cbe23fb2d6119a36daaf3ca67258636 /www/termine.nix | |
| parent | e2f0ca2c8c56600ae148c307b59b280abc1ff8b0 (diff) | |
Bestehende Termine in strukturierte Daten umgewandelt
Diffstat (limited to 'www/termine.nix')
| -rw-r--r-- | www/termine.nix | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/www/termine.nix b/www/termine.nix new file mode 100644 index 0000000..331f284 --- /dev/null +++ b/www/termine.nix @@ -0,0 +1,134 @@ +{ self, ... }: +{ + perSystem = + { ... }: + { + websites.${self.domain} = + { lib, ... }: + let + inherit (lib) mkOption types; + in + { + options = { + # Erweiterung zwecks ad-hoc tempplating + events = mkOption { + type = + with types; + attrsOf ( + submodule ( + { name, ... }: + { + options.name = mkOption { + type = str; + readOnly = true; + default = name; + }; + options.__toString = mkOption { + type = functionTo str; + readOnly = true; + default = self: '' + <dt id="${self.name}"><a href="#${self.name}">${self.title}</a></dt> + <dd> + <time datetime="${self.date.start} ${self.time.start}">${ + # TODO: Lokalisierte Zeitdarstellung + self.datetime-range-text + }</time> + + <address> + ${self.address.name}<br> + <a target="_blank" href="${ + let + type = with lib; head (attrNames self.address.openstreetmap); + id = self.address.openstreetmap.${type}; + in + "https://www.openstreetmap.org/${type}/${toString id}" + }">${with lib; concatStringsSep ", " (splitString "\n" (trim self.address.text))}</a> + </address> + + ${ + if !isNull self.summary then + '' + <details><summary>${self.summary}</summary> + ${self.description} + </details> + '' + else if !isNull self.description then + '' + ${self.description} + '' + else + "" + } + + ${lib.optionalString (!isNull self.aside) ''<aside>${self.aside}</aside>''} + + ${ + with lib; + optionalString (self.data != [ ]) '' + <dl> + ${concatMapStringsSep "\n" (entry: '' + <dt>${entry.name}</dt> + <dd>${entry.value}</dd> + '') self.data} + </dl> + '' + } + + ${ + with lib; + let + print-host = host: ''<a target="_blank" href="${host.url}">${host.name}</a>''; + in + if self.hosts == [ ] then + "" + else if length self.hosts == 1 then + '' + <p>Veranstalter: ${print-host (head self.hosts)}</p> + '' + else + '' + <p>Veranstalter: + <ul> + ${concatMapStringsSep "\n" (host: '' + <li>${print-host host}</li> + '') self.hosts} + </ul> + </p> + '' + } + + ${ + with lib; + let + print-link = + link: + ''<a ${optionalString link.external ''target="_blank" ''}href="${link.url}">${link.text}</a>''; + in + if self.links == [ ] then + "" + else if length self.links == 1 then + '' + <p>Weitere Informationen: ${print-link (head self.links)}</p> + '' + else + '' + <p>Weitere Informationen: + <ul> + ${concatMapStringsSep "\n" (link: '' + <li>${print-link link}</li> + '') self.links} + </ul> + </p> + '' + } + </dd> + ''; + }; + } + ) + ); + }; + }; + }; + }; +} |
