commit 560e424661273522a6bbbc8f6d943b1603e53b84
parent 0db44d2418fb278efc229e700f1e90caae059356
Author: lou woell <lou@repetitions.de>
Date: Thu, 5 Nov 2026 13:31:32 +0100
pass metadata through special variables
Diffstat:
3 files changed, 42 insertions(+), 46 deletions(-)
diff --git a/html/ethics.chtml b/html/ethics.chtml
@@ -15,7 +15,7 @@
<hr>
</nav>
<div class="container">
- <c:node node="tree" vkey="vkey" types="types"/>
+ <c:node node="tree"/>
</div>
</body>
</html>
diff --git a/html/node.chtml b/html/node.chtml
@@ -16,15 +16,14 @@
</c:splice>
</div>
</c:when>
- <c:md class="node-body"
- md="(gethash vkey node)"/>
+ <c:md class="node-body" node="node"/>
<c:when test="refs">
<div class="refs" >
<label>References:</label>
<c:splice iterate="refs">
<c:let target="*">
- <a href="#{target}"
- fill="href *"
+ <a fill="href *"
+ href="#{target}"
lquery="(text target)">
</a>
</c:let>
@@ -33,10 +32,7 @@
</c:when>
<when test="children">
<div class="node-children" iterate="children">
- <c:node node="*"
- vkey="(** :vkey)"
- types="(** :types)"
- level="(** :level)"/>
+ <c:node node="*"/>
</div>
</when>
</div>
diff --git a/lisp/ethics.lisp b/lisp/ethics.lisp
@@ -13,9 +13,17 @@
'(:build-dir #p"../build/"
:template-dir #p"../html/"
:data-dir #p"../data/"
- :versions ("en_elwes" "la_spinoza")))
-
-(defvar *template-cache* (make-hash-table))
+ :versions ("en_elwes"
+ "la_spinoza"
+ "de_stern"
+ "de_auerbach"
+ "fr_saisset"
+ "fr_appuhn")))
+
+(defparameter *template-cache* (make-hash-table))
+(defvar *vkey* nil)
+(defvar *level* nil)
+(defvar *types* nil)
(defun get-template (template config)
(declare (type pathname template))
@@ -26,7 +34,6 @@
(let ((path (merge-pathnames template (getf config :template-dir))))
(plump:parse path))))))
-
(defun read-version (key dir tbl)
(format t "Reading: ~a~&" key)
(loop :with meta := nil
@@ -105,18 +112,18 @@
bindings)
out)))
-(defun make-node (node vkey types &optional (level 0))
- (clip:process
- (get-template #p"node.chtml" config)
- :node node
- :level (1+ (or level 0))
- :vkey vkey
- :types types
- :id (gethash "id" node)
- :type (gethash "type" node)
- :refs (gethash "refs" node)
- :backlinks (gethash :links node)
- :children (gethash :child-nodes node)))
+(defun make-node (node)
+ (let ((*level* (1+ (or *level* 0))))
+ (clip:process
+ (get-template #p"node.chtml" config)
+ :node node
+ :level *level*
+ :types *types*
+ :id (gethash "id" node)
+ :type (gethash "type" node)
+ :refs (gethash "ref" node)
+ :backlinks (gethash :links node)
+ :children (gethash :child-nodes node))))
(defun write-ethics (config)
(destructuring-bind (ethica &rest versions)
@@ -126,45 +133,38 @@
(merge-pathnames #p"index.html" (getf config :build-dir))
:versions versions)
(dolist (version versions)
- (let ((key (getf version :key)))
- (format t "Writing: ~a~&" key)
+ (let ((*vkey* (getf version :key))
+ (*types* (getf version :types)))
+ (format t "Writing: ~a~&" *vkey*)
(process-to-file
(get-template #p "ethics.chtml" config)
(merge-pathnames (getf version :file)
(getf config :build-dir))
:tree (gethash "ethica" ethica)
:name (getf version :name)
- :vkey key
- :language (getf version :language)
- :types (getf version :types))))))
+ :types *types*
+ :language (getf version :language))))))
;; --- tag defs
(clip:define-tag-processor md (xml-node)
(clip:process-attributes xml-node)
(setf (plump:tag-name xml-node) "div")
- (let ((md (clip:resolve-attribute xml-node "md" "")))
- (lquery:$1 xml-node (html (markdown:parse md))))
- (plump:remove-attribute xml-node "md"))
+ (let ((node (clip:resolve-attribute xml-node "node")))
+ (lquery:$1 xml-node (html (markdown:parse (gethash *vkey* node)))))
+ (plump:remove-attribute xml-node "node"))
(clip:define-tag-processor node (xml-node)
- (clip:process-attributes xml-node)
-
- ;; order of attribute strings must be according to the order of
- ;; arguments for `make-node'.
-
- (loop :for attr :in '("node" "vkey" "types" "level")
- :collect (clip:resolve-attribute xml-node attr)
- :into result
- :do (plump:remove-attribute xml-node attr)
- :finally (lquery:$1 xml-node (html (apply #'make-node result))))
-
- (clip:process-tag "splice" xml-node))
+ ;; (clip:process-attributes xml-node)
+ (let ((result (clip:resolve-attribute xml-node "node")))
+ (plump:remove-attribute xml-node "node")
+ (lquery:$1 xml-node (html (make-node result)))
+ (clip:process-tag "splice" xml-node)))
;; --- plumbing
(defmacro parse-args (&rest args)
- `(loop :with version := nil
+ `(loop :with versions := nil
:for arg :on (uiop:command-line-arguments) :by #'cddr
:as flag := (car arg)
:as value := (cadr arg)