aboutsummaryrefslogtreecommitdiff
path: root/www/index.nix
blob: 7559b493ef8d9ef6af7dde7e1e5448e2421548df (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
{ self, ... }:
{
  perSystem =
    { ... }:
    {
      websites.${self.domain} =
        { config, lib, ... }:
        let
          inherit (lib) mkOption types;
          root = ./html;
          files =
            with lib.fileset;
            toList (
              difference (fileFilter (file: file.hasExt "html" || file.hasExt "js") root) ./html/Kalender
            );
          replacements =
            let
              events =
                with lib;
                let
                  as-list = mapAttrsToList (name: value: {
                    slug = name;
                    start = value.date.start + value.time.start;
                    value = toString value;
                  }) config.events;
                in
                sortOn (event: event.start) as-list;
            in
            {
              "@title@" = config.title;
              "@published@" = config.published;
              "@stylesheet@" = ''<link rel="stylesheet" type="text/css" href="style.css">'';
              "@head@" = ''
                <meta charset="utf-8" />
                <meta http-equiv="X-UA-Compatible" content="IE=edge" />
                <meta name="viewport" content="width=device-width">
                <meta name="description" content="Informationen zum Stadtteil Heimfeld und seinem Stadtteilbeirat">
                <meta name="keywords" content="Heimfeld, Stadtteil, Hamburg, Stadtteilbeirat, Beirat, Stadtteilfest, Treffpunkthaus">
                <link rel="shortcut icon" type="image/x-icon" href="/img/Kraniche-dreh-klein.gif">
                <script async src="redirects.js"></script>
              '';
              "@past-events@" = ''
                <dl class="events">
                ${
                  with lib;
                  concatMapStringsSep "\n" (event: event.value) (
                    filter (event: event.start < config.published) (reverseList events)
                  )
                }
                </dl>
              '';
              "@future-events@" = ''
                <dl class="events">
                ${
                  with lib;
                  concatMapStringsSep "\n" (event: event.value) (
                    filter (event: event.start >= config.published) events
                  )
                }
                </dl>
              '';
              "@events-redirects@" =
                with lib;
                concatMapStringsSep ",\n" (event: ''"${event.slug}": "vergangene-termine.html#${event.slug}"'')

                  (filter (event: event.start < config.published) (reverseList events));
            };
          replace = file: with lib; replaceStrings (attrNames replacements) (attrValues replacements) file;
        in
        {
          title = "Stadtteilbeirat Heimfeld";
          published = "2026-01-24";
          events =
            with lib;
            listToAttrs (
              map (file: {
                name = removeSuffix ".nix" (toString (baseNameOf file));
                value = import file;
              }) (fileset.toList ./termine)
            );
          files =
            with lib;
            listToAttrs (
              map (path: {
                name = lib.path.removePrefix root path;
                value = with builtins; toFile (baseNameOf path) (replace (readFile path));
              }) files
            );
        };
    };
}