gemini/incl/util.scm
2025-08-22 09:55:48 -05:00

30 lines
869 B
Scheme

;;; incl/util.scm
;; A bunch of utilities that I'll probably want to just build into stxge
(define (join-path type x . xs)
;; Join (cons x xs) into a slash-delimited string
(string-join (cons x xs) "/" type))
(define (make-relative-uri type x . xs)
(build-uri-reference #:path (apply join-path type (cons x xs))))
(define (make-capsule-uri-builder prefix)
;; Generate a function that creates URIs relative to the capsule's root
(lambda (x . xs) (apply make-relative-uri 'prefix prefix x xs)))
(define build-uri/capsule (make-capsule-uri-builder "~snit"))
(define (append-map-with-line-breaks proc lst)
(drop-right (append-map (lambda (x) `(,@(proc x) (p))) lst) 1))
(define header-uris
(list (cons (build-uri-reference #:path "/") "Root")
(cons (build-uri/capsule "") "Home")
(cons (build-uri-reference #:path "..") "Back")))