]> git.ameliathe1st.gay Git - site-web.git/commitdiff
Portage OCaml
authorAmélia Coutard-Sander <git@ameliathe1st.gay>
Fri, 19 Sep 2025 17:27:32 +0000 (19:27 +0200)
committerAmélia Coutard-Sander <git@ameliathe1st.gay>
Fri, 19 Sep 2025 17:27:32 +0000 (19:27 +0200)
Makefile
docs/meta.ml [new file with mode: 0644]
docs/meta.rec [deleted file]
esh.sh [deleted file]
html/atom.xml.esh [deleted file]
html/atom.xml.ml [new file with mode: 0644]
html/index.html.ml [moved from html/index.html.esh with 87% similarity]

index 207e90fbe85ea5226a06d377c0fd00fca6320596..bf61492649422b7dbe318ca21f8c4802a69f536d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
 .PHONY: build clean
 
-ESH=$(patsubst html/%.esh,out/%,$(shell find html -name '*.esh'))
-STATIC=$(patsubst html/%,out/%,$(shell find html -type f -and -not -name '*.esh'))
-DOCS=$(patsubst %,out/docs/%,$(shell recsel -P file docs/meta.rec))
+ESH=$(patsubst html/%.ml,out/%,$(shell find html -name '*.ml'))
+STATIC=$(patsubst html/%,out/%,$(shell find html -type f -and -not -name '*.ml'))
+DOCS=$(patsubst %,out/docs/%,$(shell ocaml docs/meta.ml print-doc-files))
 
 build: $(ESH) $(STATIC) $(DOCS)
 clean:
@@ -21,10 +21,10 @@ out/docs/%.otf: docs/%.sfd
 out/%: html/%
        mkdir -p "$(@D)"
        cp "$<" "$@"
-out/%: html/%.esh
+out/%: html/%.ml
        mkdir -p "$(@D)"
-       sh esh.sh < "$<" > "$@"
+       cd html; ocaml "$*.ml" > "../$@"
 
 # Deps
 
-out/index.html out/atom.xml: docs/meta.rec
+out/index.html out/atom.xml: docs/meta.ml
diff --git a/docs/meta.ml b/docs/meta.ml
new file mode 100644 (file)
index 0000000..53c14e4
--- /dev/null
@@ -0,0 +1,24 @@
+type doc = { file : string; title : string; date : string }
+
+let docs =
+  [
+    {
+      file = "AmyMono-Regular.otf";
+      title = "AmyMono Regular";
+      date = "2023-11-20";
+    };
+    {
+      file = "Little-Nightmares-II-Étude-For-A-Minor.pdf";
+      title = "Little Nightmares II - Étude For A Minor";
+      date = "2023-07-21";
+    };
+    { file = "Ma-oz-Tzur.pdf"; title = "Ma'oz Tzur"; date = "2024-06-16" };
+    {
+      file = "The-Owl-House-Outro-Theme.pdf";
+      title = "The Owl House - Outro Theme";
+      date = "2023-06-14";
+    };
+  ]
+
+let () = if Array.length Sys.argv = 2 && Sys.argv.(1) = "print-doc-files" then
+       List.iter (fun {file; _} -> Printf.printf "%s\n%!" file) docs
diff --git a/docs/meta.rec b/docs/meta.rec
deleted file mode 100644 (file)
index 48fc34b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-%rec: Doc
-%mandatory: file title date
-
-file: AmyMono-Regular.otf
-title: AmyMono Regular
-date: 2023-11-20
-
-file: Little-Nightmares-II-Étude-For-A-Minor.pdf
-title: Little Nightmares II - Étude For A Minor
-date: 2023-07-21
-
-file: Ma-oz-Tzur.pdf
-title: Ma'oz Tzur
-date: 2024-06-16
-
-file: The-Owl-House-Outro-Theme.pdf
-title: The Owl House - Outro Theme
-date: 2023-06-14
diff --git a/esh.sh b/esh.sh
deleted file mode 100755 (executable)
index d045f79..0000000
--- a/esh.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-while read -r line; do
-       case "$line" in
-       "#\""*) echo "echo \"$(echo "$line" | sed 's/#"//')\"";;
-       "#"*) echo "$(echo "$line" | sed "s/#//")";;
-       *) echo "echo '$(echo "$line" | sed "s/'/'\\\\''/g")'";;
-       esac
-done | sh
diff --git a/html/atom.xml.esh b/html/atom.xml.esh
deleted file mode 100644 (file)
index 99c6e38..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<feed xmlns="http://www.w3.org/2005/Atom">
-
-       <id>https://ameliathe1st.gay/</id>
-       <title>AméliaThe1st</title>
-       <link rel="self" href="https://ameliathe1st.gay/atom.xml"/>
-       #" <updated>$(recsel -P date docs/meta.rec -S date | tail -n 1)T00:00:00Z</updated>
-       <author>
-               <name>Amélia Coutard</name>
-               <email>contact@ameliathe1st.gay</email>
-               <uri>https://ameliathe1st.gay</uri>
-       </author>
-
-       # recsel -P file docs/meta.rec -C -S date | tail -n 10 | while read -r file; do
-       <entry>
-               #" <title>$(recsel -e "file = \"$file\"" -P title docs/meta.rec)</title>
-               #" <link rel='alternate' href='https://ameliathe1st.gay/docs/$(printf '%s' "$file" | jq -Rr @uri)'/>
-               #" <id>https://ameliathe1st.gay/docs/$(printf '%s' "$file" | jq -Rr @uri)</id>
-               #" <updated>$(recsel -e "file = \"$file\"" -P date docs/meta.rec)T00:00:00Z</updated>
-       </entry>
-       # done
-
-</feed>
diff --git a/html/atom.xml.ml b/html/atom.xml.ml
new file mode 100644 (file)
index 0000000..5f46f20
--- /dev/null
@@ -0,0 +1,52 @@
+#use "../docs/meta.ml"
+#use "topfind"
+#require "netstring"
+
+let rec take n = function
+  | [] -> []
+  | _ when n = 0 -> []
+  | v :: vs -> v :: take (n - 1) vs
+
+let latest_date =
+  List.hd
+  @@ List.sort (fun a b -> compare b a)
+  @@ List.map (fun { date; _ } -> date) docs
+
+let entries =
+  String.concat ""
+  @@ List.map (fun { title; file; date } ->
+         Printf.sprintf
+{|     <entry>
+               <title>%s</title>
+               <link rel='alternate' href='https://ameliathe1st.gay/docs/%s'/>
+               <id>https://ameliathe1st.gay/docs/%s</id>
+               <updated>%sT00:00:00Z</updated>
+       </entry>
+|}
+           title
+           (Netencoding.Url.encode file)
+           (Netencoding.Url.encode file)
+           date)
+  @@ take 10
+  @@ List.sort (fun a b -> compare b.date a.date) docs
+
+let () =
+  Printf.printf
+    {|
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+
+       <id>https://ameliathe1st.gay/</id>
+       <title>AméliaThe1st</title>
+       <link rel="self" href="https://ameliathe1st.gay/atom.xml"/>
+       <updated>%sT00:00:00Z</updated>
+       <author>
+               <name>Amélia Coutard</name>
+               <email>contact@ameliathe1st.gay</email>
+               <uri>https://ameliathe1st.gay</uri>
+       </author>
+
+       %s
+</feed>
+|}
+    latest_date entries
similarity index 87%
rename from html/index.html.esh
rename to html/index.html.ml
index 7f64eb8937c55d6775faeef05583ed461807fd32..bb1066f7aa8293198423f50d35462a5560ebe1a9 100644 (file)
@@ -1,4 +1,14 @@
-<!DOCTYPE html>
+#use "../docs/meta.ml"
+#use "topfind"
+#require "tyxml"
+#require "tyxml-ppx"
+
+open Tyxml
+
+let () =
+  Format.printf "%a" (Html.pp ())
+    [%html
+      {|
 <html>
 <head>
        <title> ameliathe1st.gay | Page Principale </title>
 </head>
 <body>
        <h3> Mes dernières publications: </h3>
-       <ul>
-               # recsel -P file docs/meta.rec -C | while read -r file; do
-               #" <li> <a href='/docs/$file'>$(recsel -e "file = \"$file\"" -P title docs/meta.rec)</a> </li>
-               # done
-       </ul>
+       <ul>|}
+        (List.map
+           (fun { file; title; _ } ->
+             [%html
+               "<li> <a href=" ("/docs/" ^ file) ">"
+                 [ Html.txt title ]
+                 "</a> </li>"])
+           docs)
+        {|</ul>
        <h3> Des liens: </h3>
        <ul>
                <li><a href='https://git.ameliathe1st.gay'>Des programmes que j'ai fait (et un canal guix pour s'en servir).</a></li>
@@ -45,3 +59,4 @@
        </ul>
 </body>
 </html>
+|}]