From a5d9a3a916a15e4dc8bed03b1c530ffdad275893 Mon Sep 17 00:00:00 2001
From: Eshel Yaron <me@eshelyaron.com>
Date: Wed, 30 Aug 2023 20:03:36 +0200
Subject: [PATCH] Generate Sweep HTML pages from the Texinfo manual

---
 esy-publish.el   | 61 +++++++++++++++++++++++++++++++++++++++++-------
 source/style.css |  7 ++++++
 source/sweep.org |  1 -
 3 files changed, 60 insertions(+), 9 deletions(-)
 delete mode 120000 source/sweep.org

diff --git a/esy-publish.el b/esy-publish.el
index 473bc0b..0ac71a2 100644
--- a/esy-publish.el
+++ b/esy-publish.el
@@ -446,13 +446,9 @@
     (rename-file tmp file t)))
 
 (defun esy-publish--sweep-texinfo (plist)
-  (with-current-buffer
-      (find-file-noselect
-       (expand-file-name "sweep/README.org" esy-publish-root-directory))
-    (org-texinfo-export-to-texinfo)
-    (push (current-buffer) esy-publish--buffers))
   (make-directory esy-publish-local-man-directory t)
-  (let ((out (expand-file-name "sweep" esy-publish-local-man-directory)))
+  (let ((no-split (expand-file-name "sweep.html" esy-publish-local-directory))
+        (out (expand-file-name "sweep" esy-publish-local-man-directory)))
     (call-process "texi2any"
                   nil nil nil
                   "--html"
@@ -500,10 +496,59 @@
                                               "© "
                                               (time ((class . "copyright-year")) "2023")
                                               " Eshel Yaron"))))
-                  ;; TODO - also add @contents
                   "--output" out
                   (expand-file-name "sweep/sweep.texi" esy-publish-root-directory))
-    (dolist (file (directory-files out t (rx ".html" eos)))
+    (call-process "texi2any"
+                  nil nil nil
+                  "--html"
+                  "--no-split"
+                  "--css-ref" "../style.css"
+                  "-c" "TREE_TRANSFORMATIONS=regenerate_master_menu"
+                  "-c" (concat "AFTER_BODY_OPEN="
+                               (esy-publish--dom-to-string
+                                '(div ((id . "preamble")
+                                       (class . "status"))
+                                      (nav ((id . "icon-links")
+                                            (class . "icon-links"))
+                                           (div ((class . "home-link"))
+                                                (a ((href . "/"))
+                                                   (img ((src . "/home.svg")
+                                                         (height . "35")
+                                                         (width . "35")
+                                                         (alt . "Home")))))
+                                           (div ((class . "other-links"))
+                                                (a ((href . "mailto:me@eshelyaron.com"))
+                                                   (img ((src . "/mail.svg")
+                                                         (height . "30")
+                                                         (width . "30")
+                                                         (alt . "Mail"))))
+                                                " "
+                                                (a ((href . "https://emacs.ch/@eshel")
+                                                    (rel . "me"))
+                                                   (img ((src . "/mastodon.svg")
+                                                         (height . "28")
+                                                         (width . "28")
+                                                         (alt . "Mastodon"))))
+                                                " "
+                                                (a ((href . "/rss.xml"))
+                                                   (img ((src . "/rss.svg")
+                                                         (height . "30")
+                                                         (width . "30")
+                                                         (alt . "RSS Feed")))))))
+                                '(hr nil)))
+                  "-c" (concat "PRE_BODY_CLOSE="
+                               (esy-publish--dom-to-string
+                                '(div ((id . "postamble")
+                                       (class . "status"))
+                                      (footer ((id . "footer")
+                                               (class . "footer"))
+                                              (hr nil)
+                                              "© "
+                                              (time ((class . "copyright-year")) "2023")
+                                              " Eshel Yaron"))))
+                  "--output" no-split
+                  (expand-file-name "sweep/sweep.texi" esy-publish-root-directory))
+    (dolist (file (cons no-split (directory-files out t (rx ".html" eos))))
       (esy-publish-fontify-examples file))))
 
 (defun esy-publish--prepare-indices (&rest _)
diff --git a/source/style.css b/source/style.css
index ee39b28..a24fc4b 100644
--- a/source/style.css
+++ b/source/style.css
@@ -77,6 +77,13 @@ pre {
 code {
     color: #78afff;
     font-family: Hack,monospace;
+    font-size: 0.9em;
+}
+
+kbd {
+    color: #af9fff;
+    font-family: Hack,monospace;
+    font-size: 0.9em;
 }
 
 h2 {
diff --git a/source/sweep.org b/source/sweep.org
deleted file mode 120000
index b077d19..0000000
--- a/source/sweep.org
+++ /dev/null
@@ -1 +0,0 @@
-../sweep/README.org
\ No newline at end of file
-- 
2.39.5