summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-06-29 15:22:18 +0530
committerArun Isaac2022-06-29 15:22:18 +0530
commit3588f1844cb96b0f31d0d919cee74cbcbb03365f (patch)
tree7d9e0050fa0f4a34b777ade2b9390738424b44ab
parent51625991ab841e7f7262090b4d21558d00606a0c (diff)
downloadtissue-3588f1844cb96b0f31d0d919cee74cbcbb03365f.tar.gz
tissue-3588f1844cb96b0f31d0d919cee74cbcbb03365f.tar.lz
tissue-3588f1844cb96b0f31d0d919cee74cbcbb03365f.zip
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.
-rw-r--r--tissue/web/server.scm14
1 files 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)