cripslock

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

commit 7a8729c6aa0b1a9767422f34c4a7245550ad1b42
parent aa9b4fec051178ad6a2c43aadebd076a6cac45b0
Author: Daniel Barlow <dan@telent.net>
Date:   Wed, 23 Jul 2025 17:49:12 +0100

implement search offset and limit

Diffstat:
Mmain.fnl | 2++
Msite.fnl | 9++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/main.fnl b/main.fnl @@ -19,6 +19,7 @@ :filter nil :order {:date :descending} :offset 0 + :limit 5 }) #(case (string.match $2 "(/static/%g+)" 1) @@ -64,6 +65,7 @@ :filter nil :order {:date :descending} :offset 0 + :limit 5 }) (expect= (route-request :get "/pagename") diff --git a/site.fnl b/site.fnl @@ -141,7 +141,14 @@ (table.sort posts (if (= dir :ascending) cmp #(cmp $2 $1))))) - posts)) + (if (or limit offset) + (let [some-posts [] + start (+ 1 (or offset 0)) + stop (if limit (+ start (- limit 1)) (# posts))] + (table.move posts start stop 1 some-posts) + some-posts) + posts))) + (fn for-pathname [path]