cripslock

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 9e004945385859ce2ea61eccfd1b692526c49429
parent 250da8fe4ed5bfc92e496687fc03e7fe12ab8d5e
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 22 Jul 2025 19:31:15 +0100

add post header and footer

Diffstat:
Mmain.fnl | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/main.fnl b/main.fnl @@ -92,6 +92,27 @@ (string.match pathname "%.txt$") "text/plain" "application/octet-stream")) +(fn post-header [post stream] + (stream:write_chunk + (string.format + "<html><head><link href=\"/static/css/default.css\" rel=\"stylesheet\"><link href=\"/news.rss\" rel=\"alternate\" title=\"RSS\" type=\"application/rss+xml\"><title>%s @ telent</title></head> +<body> +<header><a href=\"/\"><div class=\"title\">diary @ telent</div></a></header> +<article><div class=\"entry\"> +<h1 class=\"title\">%s<span class=\"permalink\"><a href=%q>#</a></span></h1> +<h2 class=\"date\">%s</h2> +" + post.title + post.title + post.url-path + (os.date "%c" post.date) + ))) + +(fn post-footer [post stream] + (stream:write_chunk + "<aside>hey</aside> +<footer><div>Powered by <a href=\"https://gti.telent.net/dan/cripslock\">cripslock</a>. Copyright &copy; 2001-2025 Daniel Barlow</div></footer></body></html>")) + (fn dispatch [route stream] (let [s { :write #(stream:write_chunk $2) } ] (case route.command @@ -103,12 +124,14 @@ (with-open [f (io.open path )] (when f (f:seek :set post.body-offset) + (post-header post stream) (if (string.match path "%.textile$") (each [_ el (ipairs (textile.parse f))] (textile.to-html s el)) (stream:write_chunk (lcmark.convert (f:read "*a") "html" { :yaml_parser #($1) })) ))) + (post-footer post stream) (stream:write_chunk "" true)) :sendfile (with-open [f (io.open route.pathname :r)]