.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:
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
--- /dev/null
+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
+++ /dev/null
-%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
+++ /dev/null
-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
+++ /dev/null
-<?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>
--- /dev/null
+#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
-<!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>
</ul>
</body>
</html>
+|}]