From 96d6e05653b99c9958fe9ff1c2b8a48237d25ea5 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Sun, 11 Feb 2024 22:44:15 +0100 Subject: Simplify cgit about-filter program --- tw/system/lud.scm | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/tw/system/lud.scm b/tw/system/lud.scm index 7d41eae0..dd0d39a9 100644 --- a/tw/system/lud.scm +++ b/tw/system/lud.scm @@ -136,29 +136,18 @@ that I just want to host somewhere.") (about-filter (program-file "cgit-about-filter" (with-extensions (list guile-commonmark) - (with-imported-modules '((guix build utils)) - #~(begin - (use-modules ((guix build utils) #:select (dump-port)) - ((commonmark) #:select (commonmark->sxml)) - ((sxml simple) #:select (sxml->xml))) - (define file-name (cadr (command-line))) - (cond - ((string-suffix? ".md" file-name) - (sxml->xml (commonmark->sxml))) - ((string-suffix? ".html" file-name) - (dump-port (current-input-port) (current-output-port))) - (else - (display "
")
-                            (do ((ch (read-char) (read-char)))
-                                ((eof-object? ch))
-                              (case ch
-                                ((#\") (display """))
-                                ((#\') (display "'"))
-                                ((#\&) (display "&"))
-                                ((#\<) (display "<"))
-                                ((#\>) (display ">"))
-                                (else => write-char)))
-                            (display "
")))))))) + #~(begin + (use-modules ((ice-9 textual-ports) #:select (get-string-all)) + ((commonmark) #:select (commonmark->sxml)) + ((sxml simple) #:select (sxml->xml))) + (define file-name (cadr (command-line))) + (cond + ((string-suffix? ".md" file-name) + (sxml->xml (commonmark->sxml))) + ((string-suffix? ".html" file-name) + (display (get-string-all))) + (else + (sxml->xml `((pre ,(get-string-all)))))))))) (nginx (list (nginx-server-configuration -- cgit v1.2.3