From 41ed7571b4ee823e226de7f40dd49f46a5f8dff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 1 Feb 2021 13:19:39 +0100 Subject: Add only-future checkbox on search page. --- module/calp/html/view/search.scm | 2 ++ module/calp/server/routes.scm | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'module') diff --git a/module/calp/html/view/search.scm b/module/calp/html/view/search.scm index 00f00bb0..fd5000df 100644 --- a/module/calp/html/view/search.scm +++ b/module/calp/html/view/search.scm @@ -24,6 +24,8 @@ ,(when has-query? (with-output-to-string (lambda () (pretty-print search-term)))))) + (label (@ (for "onlyfuture")) "limit to future occurences") + (input (@ (name "onlyfuture") (id "onlyfuture") (type checkbox))) (input (@ (type submit)))) ,@(if errors `((h2 "Error searching") diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm index 368c7cb0..db4e819b 100644 --- a/module/calp/server/routes.scm +++ b/module/calp/server/routes.scm @@ -361,8 +361,12 @@ (prop event 'SUMMARY))))) )))))) - (GET "/search" (q p) - (define search-term (and=> q prepare-string)) + (GET "/search" (q p onlyfuture) + (define search-term + (if onlyfuture + `(and (date/-time<=? ,(current-datetime) (prop event 'DTSTART)) + ,(and=> q prepare-string)) + (and=> q prepare-string))) ;; keep original string for links below. Should guarantee that it's correct. (define q= (if (not q) -- cgit v1.2.3