From 3588f1844cb96b0f31d0d919cee74cbcbb03365f Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 29 Jun 2022 15:22:18 +0530 Subject: web: server: Pre-fill search box with current query. * tissue/web/server.scm (make-search-page): Accept query argument. (handler): Pass query argument to make-search-page. --- tissue/web/server.scm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tissue/web/server.scm b/tissue/web/server.scm index fb6dd9f..c5c67b5 100644 --- a/tissue/web/server.scm +++ b/tissue/web/server.scm @@ -117,9 +117,9 @@ a.tag-chore { color: black; }") -(define (make-search-page results css) - "Return SXML for a page with search RESULTS. CSS is a URI to a -stylesheet." +(define (make-search-page results query css) + "Return SXML for a page with search RESULTS produced for QUERY. CSS is +a URI to a stylesheet." `(html (head (title "Tissue search") @@ -131,7 +131,10 @@ stylesheet." (list))) (body (form (@ (action "/search") (method "GET")) - (input (@ (type "search") (name "query") (placeholder "Enter search query"))) + (input (@ (type "text") + (name "query") + (value ,query) + (placeholder "Enter search query"))) (input (@ (type "submit") (value "Search")))) (ul ,@results)))) @@ -159,7 +162,7 @@ to a stylesheet." (cond ((string=? path "/") (values '((content-type . (text/html))) - (sxml->html (make-search-page '() css)))) + (sxml->html (make-search-page '() "" css)))) ((string=? "/search" path) (values '((content-type . (text/html))) (sxml->html @@ -169,6 +172,7 @@ to a stylesheet." (search-map document->sxml db (assoc-ref parameters "query")))) + (assoc-ref parameters "query") css)))) (else (values (build-response #:code 404) -- cgit v1.2.3