aboutsummaryrefslogtreecommitdiff
path: root/www/termine.nix
blob: e631afc8c6aefd0c0bf0cb3299875c2bf0b478bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{ self, ... }:
{
  perSystem =
    { ... }:
    {
      websites.${self.domain} =
        { lib, ... }:
        let
          inherit (lib) mkOption types;
        in
        {
          options = {
            # Erweiterung zwecks ad-hoc templating
            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 class="highlight-box">${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>
                        '';
                      };
                    }
                  )
                );
            };
          };
        };
    };
}