diff options
author | Timo Wilken | 2024-02-11 22:44:15 +0100 |
---|---|---|
committer | Timo Wilken | 2024-02-11 22:44:15 +0100 |
commit | 96d6e05653b99c9958fe9ff1c2b8a48237d25ea5 (patch) | |
tree | 18c105dccea96a728695dd86fd782a9c9def3d12 /tw | |
parent | 94bdfc84fcd9659f7363d82127ae02ca49fa8f4d (diff) |
Simplify cgit about-filter program
Diffstat (limited to 'tw')
-rw-r--r-- | tw/system/lud.scm | 35 |
1 files 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 "<pre>") - (do ((ch (read-char) (read-char))) - ((eof-object? ch)) - (case ch - ((#\") (display """)) - ((#\') (display "'")) - ((#\&) (display "&")) - ((#\<) (display "<")) - ((#\>) (display ">")) - (else => write-char))) - (display "</pre>")))))))) + #~(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 |