diff options
| author | Valentin <valentin@fricklerhandwerk.de> | 2025-12-20 18:22:27 +0100 |
|---|---|---|
| committer | Valentin <valentin@fricklerhandwerk.de> | 2025-12-20 18:22:27 +0100 |
| commit | 8b0a011c7c37d882a2e12ea8de38acaa9e782d38 (patch) | |
| tree | 2daea25b800a0733baa6f45fd71afcadf02a9ffc /www | |
| parent | 9a5020deaed97df8ab1307068f34a382b2e24b31 (diff) | |
| parent | 0efd609dd832b11c4e4e20c008edc1cc52dbfbd9 (diff) | |
Merge branch 'nix-html'
HTML werden ab jetzt aus Nix-modulen generiert.
Diffstat (limited to 'www')
| -rw-r--r-- | www/caddy.nix | 24 | ||||
| -rw-r--r-- | www/flake-module.nix | 46 | ||||
| -rw-r--r-- | www/framework/default.nix | 140 | ||||
| -rw-r--r-- | www/html.nix | 57 | ||||
| -rw-r--r-- | www/html/Kalender/Kindertag-in-der-Mehrwertkultur.html (renamed from www/html/Kalender/Kindertag in der Mehrwertkultur.html) | 0 | ||||
| -rw-r--r-- | www/html/Kalender/Kindertag-in-der-Mehrwertkultur_html_290e08fdf9314385.jpg (renamed from www/html/Kalender/Kindertag in der Mehrwertkultur_html_290e08fdf9314385.jpg) | bin | 33207 -> 33207 bytes | |||
| -rw-r--r-- | www/html/Kalender/Kindertag-in-der-Mehrwertkultur_html_7312c2696b940296.png (renamed from www/html/Kalender/Kindertag in der Mehrwertkultur_html_7312c2696b940296.png) | bin | 325031 -> 325031 bytes | |||
| -rw-r--r-- | www/html/datenschutz.html | 38 | ||||
| -rw-r--r-- | www/html/img/Stadtteilbeirat-Heimfeld-Oktober-20.pdf (renamed from www/html/img/Stadtteilbeirat Heimfeld Oktober 20.pdf) | bin | 51362 -> 51362 bytes | |||
| -rw-r--r-- | www/html/impressum.html | 73 | ||||
| -rw-r--r-- | www/html/index.html | 12 | ||||
| -rw-r--r-- | www/html/style.css | 4 | ||||
| -rw-r--r-- | www/html/vergangene-termine.html | 12 | ||||
| -rw-r--r-- | www/index.nix | 41 |
14 files changed, 362 insertions, 85 deletions
diff --git a/www/caddy.nix b/www/caddy.nix index 6721316..9a5bd50 100644 --- a/www/caddy.nix +++ b/www/caddy.nix @@ -1,16 +1,11 @@ { self, lib, ... }: -let - html = - with lib.fileset; - toSource { - root = ./html; - fileset = ./html; - }; -in { flake.machines.tharos = { nixos = - { lib, ... }: + { config, lib, ... }: + let + website = self.websites.${config.nixpkgs.hostPlatform.system}.${self.domain}; + in { services.caddy.virtualHosts.${self.domain} = { serverAliases = [ "www.${self.domain}" ]; @@ -18,13 +13,15 @@ in file_server root * /var/www/${self.domain} encode gzip + + ${website.redirects.caddy} ''; }; systemd.tmpfiles.rules = [ # Verzeichnis für Web-Inhalte sofort anlegen, da der Webserver sonst nicht startet, # aber nur wenn es noch nicht existiert. - "C /var/www/${self.domain} - - - - ${html}" + "C /var/www/${self.domain} - - - - ${website.result}" ]; }; vm = @@ -52,10 +49,14 @@ in pkgs, lib, system, + config, self', ... }: { + # Website aus Quellcode generiert + packages.html = self'.websites.${self.domain}.result; + # Website-Inhalte auf den Server hochladen packages.publish = pkgs.writeShellApplication { name = "publish"; @@ -66,9 +67,6 @@ in }; # Lokale Vorschau - packages.html = pkgs.runCommand "source" { } '' - cp -r ${html} $out - ''; packages.preview = pkgs.devmode.override { buildArgs = '' "$(${lib.getExe pkgs.git} rev-parse --show-toplevel)" -A packages.${system}.html -vv diff --git a/www/flake-module.nix b/www/flake-module.nix new file mode 100644 index 0000000..880b395 --- /dev/null +++ b/www/flake-module.nix @@ -0,0 +1,46 @@ +{ + self, + config, + lib, + flake-parts-lib, + ... +}: +let + inherit (lib) + filterAttrs + mapAttrs + mkOption + optionalAttrs + types + ; + inherit (flake-parts-lib) + mkSubmoduleOptions + mkPerSystemOption + ; +in +{ + options = { + flake = mkSubmoduleOptions { + websites = mkOption { }; + }; + + perSystem = mkPerSystemOption ( + { pkgs, ... }: + { + _file = ./option.nix; + options = { + websites = mkOption { + type = + with types; + lazyAttrsOf (submoduleWith { + specialArgs = { inherit pkgs; }; + modules = [ ./framework ]; + }); + }; + }; + } + ); + }; + + config.transposition.websites = { }; +} diff --git a/www/framework/default.nix b/www/framework/default.nix new file mode 100644 index 0000000..0cc9049 --- /dev/null +++ b/www/framework/default.nix @@ -0,0 +1,140 @@ +{ + config, + pkgs, + lib, + ... +}: +let + inherit (lib) mkOption types; +in +{ + imports = + with lib.fileset; + toList (difference (fileFilter (file: file.hasExt "nix") ./.) ./default.nix); + + options = { + types = mkOption { + description = "Datentypen für Website-Inhalte"; + type = with types; lazyAttrsOf deferredModule; + default = { }; + }; + + title = mkOption { + description = "Titel, der bei allen Seiten vorangestellt wird"; + type = types.singleLineStr; + readOnly = true; + }; + + files = mkOption { + description = '' + Dateien, aus denen die Website besteht, als Abbildung vom Dateipfad zum Inhalt + ''; + type = with types; attrsOf (either path (submodule config.types.file)); + }; + + redirects.raw = mkOption { + description = '' + Weiterleitungen aller historischen Dateipfade auf Kanonische Pfade + ''; + type = with types; lazyAttrsOf str; + readOnly = true; + default = + with lib; + listToAttrs ( + concatMap ( + name: + if config.files.${name} ? locations then + map (loc: { + name = "/" + loc; + value = "/" + name; + }) (tail config.files.${name}.locations) + else + [ ] + ) (attrNames config.files) + ); + }; + + redirects.caddy = mkOption { + description = '' + Weiterleitungen im Caddyfile-Format + ''; + type = types.str; + readOnly = true; + default = + with lib; + let + lines = mapAttrsToList (name: value: ''redir "${name}" ${value} permanent'') config.redirects.raw; + in + concatStringsSep "\n" lines; + }; + + result = mkOption { + description = '' + Fertige Website als Verzeichnis + ''; + type = types.package; + readOnly = true; + default = + let + script = '' + mkdir $out + '' + + lib.concatStringsSep "\n" copy; + copy = lib.mapAttrsToList ( + path: file: + let + content = if file ? path then file.path else file; + in + '' + mkdir -p $out/$(dirname '${toString path}') + ${ + "" # `--no-preserve-mode` ist erforderlich da Nix store paths read-only sind, und man andernfalls `cp -r` nicht durchführen kann. + }cp -r --no-preserve=mode ${content} $out/'${toString path}' + '' + ) config.files; + in + pkgs.runCommand "source" { } script; + }; + }; + + config.types.document = + { lib, ... }: + let + inherit (lib) mkOption types; + in + { + options = { + locations = mkOption { + description = '' + Frühere Pfade dieses Dokuments + + Einträge sind relative Pfade. + Der erste Eintrag ist der kanonische Pfad. + Alle anderen Elemente werden für Weiterleitungen zum kanonischen Pfad benutzt. + ''; + type = with types; nonEmptyListOf str; + example = [ + "about/overview" + "index" + ]; + }; + }; + }; + + config.types.file = + { lib, ... }: + let + inherit (lib) mkOption types; + in + { + imports = [ config.types.document ]; + options = { + path = mkOption { + type = types.path; + description = '' + Datei mit manuell gesteuertem Pfad + ''; + }; + }; + }; +} diff --git a/www/html.nix b/www/html.nix new file mode 100644 index 0000000..97cf089 --- /dev/null +++ b/www/html.nix @@ -0,0 +1,57 @@ +{ self, ... }: +{ + perSystem = + { ... }: + { + websites.${self.domain} = + { lib, ... }: + let + inherit (lib) mkOption types; + in + { + files = + let + root = ./html; + files = with lib.fileset; toList root; + redirects = + with lib; + mapAttrsToList + (name: value: { + name = head value.locations; + inherit value; + }) + { + kindertag = { + path = ./html/Kalender/Kindertag-in-der-Mehrwertkultur.html; + locations = [ + "Kalender/Kindertag-in-der-Mehrwertkultur.html" + "Kalender/Kindertag in der Mehrwertkultur.html" + ]; + }; + kinder-banner = { + path = ./html/Kalender/Kindertag-in-der-Mehrwertkultur_html_7312c2696b940296.png; + locations = [ + "Kalender/Kindertag-in-der-Mehrwertkultur_html_7312c2696b940296.png" + "Kalender/Kindertag in der Mehrwertkultur_html_7312c2696b940296.png" + ]; + }; + contraZt-logo = { + path = ./html/Kalender/Kindertag-in-der-Mehrwertkultur_html_290e08fdf9314385.jpg; + locations = [ + "Kalender/Kindertag-in-der-Mehrwertkultur_html_290e08fdf9314385.jpg" + "Kalender/Kindertag in der Mehrwertkultur_html_290e08fdf9314385.jpg" + ]; + }; + }; + in + lib.listToAttrs ( + redirects + ++ map (file: { + name = lib.path.removePrefix root file; + value = lib.mkDefault file; + }) files + ); + }; + + }; +} diff --git a/www/html/Kalender/Kindertag in der Mehrwertkultur.html b/www/html/Kalender/Kindertag-in-der-Mehrwertkultur.html index 39b693d..39b693d 100644 --- a/www/html/Kalender/Kindertag in der Mehrwertkultur.html +++ b/www/html/Kalender/Kindertag-in-der-Mehrwertkultur.html diff --git a/www/html/Kalender/Kindertag in der Mehrwertkultur_html_290e08fdf9314385.jpg b/www/html/Kalender/Kindertag-in-der-Mehrwertkultur_html_290e08fdf9314385.jpg Binary files differindex aae5162..aae5162 100644 --- a/www/html/Kalender/Kindertag in der Mehrwertkultur_html_290e08fdf9314385.jpg +++ b/www/html/Kalender/Kindertag-in-der-Mehrwertkultur_html_290e08fdf9314385.jpg diff --git a/www/html/Kalender/Kindertag in der Mehrwertkultur_html_7312c2696b940296.png b/www/html/Kalender/Kindertag-in-der-Mehrwertkultur_html_7312c2696b940296.png Binary files differindex e558cae..e558cae 100644 --- a/www/html/Kalender/Kindertag in der Mehrwertkultur_html_7312c2696b940296.png +++ b/www/html/Kalender/Kindertag-in-der-Mehrwertkultur_html_7312c2696b940296.png diff --git a/www/html/datenschutz.html b/www/html/datenschutz.html index e5876e7..c1a55fc 100644 --- a/www/html/datenschutz.html +++ b/www/html/datenschutz.html @@ -1,21 +1,24 @@ <!DOCTYPE HTML > <html> <head> - <meta charset="utf-8" /> - <meta http-equiv="X-UA-Compatible" content="IE=edge" /> - <meta name="viewport" content="width=device-width"> - <title>Datenschutz</title> - - <link rel="shortcut icon" type="image/x-icon" href="/img/Kraniche-dreh-klein.gif"> + @head@ + @stylesheet@ + <title>@title@ – Datenschutz</title> </head> <body> - <a href="index.html">Zurück</a><br> + <header> + <nav> + <ul> + <li><a href="/">Stadtteilbeirat Heimfeld</a></li> + </ul> + </nav> + </header> <table border="0" cellspacing="2" cellpadding="2" width="100%"> <tbody> <tr> <td valign="top" width="15%"><br> </td> - <td valign="top" width="70%"> + <td class="content" valign="top" width="70%"> <h2>Datenschutzerklärung</h2> <p>Personenbezogene Daten (nachfolgend zumeist nur „Daten“ genannt) werden von uns nur im Rahmen der Erforderlichkeit @@ -164,16 +167,21 @@ href="https://www.ratgeberrecht.eu/leistungen/muster-datenschutzerklaerung.html" href="https://www.ratgeberrecht.eu/datenschutz/datenschutzerklaerung-generator-dsgvo.html"><font size="-1">Anwaltskanzlei Weiß & Partner</font></a></p> </td> - <td valign="top" align="center"><a -href="index.html">Zurück</a> + <td> </td> </tr> </tbody> </table> - <h2><br> - </h2> - <br> - <p align="right"> <br> - </p> + <footer> + <nav> + <ul> + <ul> + <li><a href="/">Stadtteilbeirat Heimfeld</a></li> + <li><a href="impressum.html">Impressum</a></li> + <li><a target="_blank" href="https://git.heimfeld.hamburg/infra">Quellcode</a></li> + </ul> + </nav> + <img src="img/Expose_Page_1_html_44cef0df.gif" alt="ComNetz" width="90" height="60"> + </footer> </body> </html> diff --git a/www/html/img/Stadtteilbeirat Heimfeld Oktober 20.pdf b/www/html/img/Stadtteilbeirat-Heimfeld-Oktober-20.pdf Binary files differindex a57f18c..a57f18c 100644 --- a/www/html/img/Stadtteilbeirat Heimfeld Oktober 20.pdf +++ b/www/html/img/Stadtteilbeirat-Heimfeld-Oktober-20.pdf diff --git a/www/html/impressum.html b/www/html/impressum.html index e6872db..e07ddf0 100644 --- a/www/html/impressum.html +++ b/www/html/impressum.html @@ -1,41 +1,36 @@ <!DOCTYPE HTML > <html> <head> - <meta charset="utf-8" /> - <meta http-equiv="X-UA-Compatible" content="IE=edge" /> - <meta name="viewport" content="width=device-width"> - <title>Impressum</title> - - <link rel="shortcut icon" type="image/x-icon" href="/img/Kraniche-dreh-klein.gif"> + @head@ + @stylesheet@ + <title>@title@ – Impressum</title> </head> <body> - <a href="index.html">Zurück</a><br> - <blockquote> - <blockquote> - <h1><font face="Bitstream Terminal" size="+3">Impressum / - Kontakt</font></h1> - <br> - <br> - Nicolas Stuebs<br> - Bansenstraße 5A<br> - D-21075 Hamburg-Heimfeld<br> - nicolas.stuebs (at) tharos-net.de<br> - <br> - <p> - <meta http-equiv="content-type" content="text/html; - charset=UTF-8"> - Inhaltlich Verantwortlicher gem. § 55 II RStV : Nicolas Stuebs<br> - <br> - </p> - </blockquote> - </blockquote> + <header> + <nav> + <ul> + <li><a href="/">Stadtteilbeirat Heimfeld</a></li> + </ul> + </nav> + </header> <br> <table border="0" cellspacing="2" cellpadding="2" width="100%"> <tbody> <tr> <td valign="top" width="15%"><br> </td> - <td valign="top" width="70%"> + <td class="content" valign="top" width="70%"> + <h1>Impressum / Kontakt</h1> + + <address> + Nicolas Stuebs<br> + Bansenstraße 5A<br> + D-21075 Hamburg-Heimfeld<br> + nicolas.stuebs (at) tharos-net.de<br> + </address> + <p> + Inhaltlich Verantwortlicher gem. § 55 II RStV : Nicolas Stuebs + </p> <p><strong>Nutzungsbedingungen/Copyright/Haftungsausschluss:</strong></p> <p><em>1. Inhalt des Onlineangebots</em><br> Die Inhalte (Text- und Bildmaterial) werden @@ -155,24 +150,22 @@ Inhalt und ihrer Gültigkeit davon unberührt.<br> <br> </p> - <p><font face="Khmer OS Freehand"><i>Nicolas Stuebs</i></font></p> + <p><i>Nicolas Stuebs</i></p> </td> <td valign="top" width="15%"><br> </td> </tr> - <tr> - <td valign="top"><br> - </td> - <td valign="top"><br> - </td> - <td valign="top" align="center"><a -href="index.html">Zurück</a> - <br> - </td> - </tr> </tbody> </table> - <div align="center"><br> - </div> + <footer> + <nav> + <ul> + <li><a href="/">Stadtteilbeirat Heimfeld</a></li> + <li><a target="_blank" href="https://git.heimfeld.hamburg/infra">Quellcode</a></li> + <li><a href="datenschutz.html">Datenschutz</a></li> + </ul> + </nav> + <img src="img/Expose_Page_1_html_44cef0df.gif" alt="ComNetz" width="90" height="60"> + </footer> </body> </html> diff --git a/www/html/index.html b/www/html/index.html index 967522b..885ae0f 100644 --- a/www/html/index.html +++ b/www/html/index.html @@ -1,15 +1,9 @@ <!DOCTYPE HTML > <html> <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, Stadtteilbeirat, Beirat, Stadtteilfest, Treffpunkthaus"> - <title>Stadtteilbeirat Heimfeld</title> - <link rel="shortcut icon" type="image/x-icon" href="/img/Kraniche-dreh-klein.gif"> - <link rel="stylesheet" type="text/css" href="style.css"> - <script async src="redirects.js"></script> + @head@ + @stylesheet@ + <title>@title@</title> </head> <body> <div class="table"> diff --git a/www/html/style.css b/www/html/style.css index aa80e22..ae35f45 100644 --- a/www/html/style.css +++ b/www/html/style.css @@ -79,6 +79,10 @@ div.column, section { flex-direction: column; gap: 1.5pt; } +.content { + background-color: var(--background-secondary); + padding: 1rem; +} .row { padding: 1rem; border: 1pt inset red; diff --git a/www/html/vergangene-termine.html b/www/html/vergangene-termine.html index cc9c576..f39defb 100644 --- a/www/html/vergangene-termine.html +++ b/www/html/vergangene-termine.html @@ -1,14 +1,9 @@ <!DOCTYPE HTML > <html> <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, Stadtteilbeirat, Beirat, Stadtteilfest, Treffpunkthaus"> - <title>Stadtteilbeirat Heimfeld – Vergangene Termine</title> - <link rel="shortcut icon" type="image/x-icon" href="/img/Kraniche-dreh-klein.gif"> - <link rel="stylesheet" type="text/css" href="style.css"> + @head@ + @stylesheet@ + <title>@title@ – Vergangene Termine</title> </head> <body> <header> @@ -331,6 +326,7 @@ <footer> <nav> <ul> + <li><a href="/">Stadtteilbeirat Heimfeld</a></li> <li><a href="impressum.html">Impressum</a></li> <li><a target="_blank" href="https://git.heimfeld.hamburg/infra">Quellcode</a></li> <li><a href="datenschutz.html">Datenschutz</a></li> diff --git a/www/index.nix b/www/index.nix new file mode 100644 index 0000000..b1b74dd --- /dev/null +++ b/www/index.nix @@ -0,0 +1,41 @@ +{ 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") root) ./html/Kalender); + replacements = { + "@title@" = config.title; + "@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> + ''; + }; + replace = file: with lib; replaceStrings (attrNames replacements) (attrValues replacements) file; + in + { + title = "Stadtteilbeirat Heimfeld"; + files = + with lib; + listToAttrs ( + map (path: { + name = lib.path.removePrefix root path; + value = with builtins; toFile (baseNameOf path) (replace (readFile path)); + }) files + ); + }; + }; +} |
