cripslock

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

commit a139f8e797859f017146af8256dbad6cf8862f26
parent 7eec9e9f1b3610f4c61e38e3d924c71ad99eac31
Author: Daniel Barlow <dan@telent.net>
Date:   Tue,  5 Aug 2025 22:35:28 +0100

add /refresh endpoint to reindex the site

Diffstat:
Mmain.fnl | 7++++++-
Msite.fnl | 21+++++++++++----------
2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/main.fnl b/main.fnl @@ -23,6 +23,7 @@ (local handlers [ #(if (= $2 "/") [ :home { :limit 5 } ]) + #(if (= $2 "/refresh") [ :refresh {} ]) #(if (= $2 "/news.rss") [ :rss { :limit 10 } ]) #(case (string.match $2 "^/(%d+)/(%d+)/") (year month) @@ -38,7 +39,7 @@ #(case (string.match $2 "^/([%w_]+)$") slug [ :show { : slug }]) -]) + ]) (define-tests :route-request (expect= (route-request :get "/" handlers) @@ -264,6 +265,10 @@ href=\"https://axillae.telent.net/\">@dan@axillae.telent.net</a> (send-post-page stream slug) [:rss] (send-rss stream) + [:refresh _] + (do + (print "refreshing") + (post-index:refresh)) [:month { : month : year }] (send-month-page stream year month) [:static { : path }] diff --git a/site.fnl b/site.fnl @@ -222,16 +222,17 @@ posts))) (fn for-pathname [path] - (let [posts (index-posts path)] - { - :get #(. posts $2) - :search #(search-posts posts $2) - :path path - :static-file (fn [_ name] - (static-path-if-safe path name)) - :topics #(topics posts) - :weighted-topics #(weighted-topics posts) - })) + (var posts (index-posts path)) + { + :get #(. posts $2) + :search #(search-posts posts $2) + :path path + :static-file (fn [_ name] + (static-path-if-safe path name)) + :topics #(topics posts) + :weighted-topics #(weighted-topics posts) + :refresh #(set posts (index-posts path)) + }) (define-tests :static-path (expect (static-path-if-safe "./" "/README.md"))