summary refs log tree commit diff
diff options
context:
space:
mode:
authorArun Isaac2022-06-29 15:25:46 +0530
committerArun Isaac2022-06-29 15:25:46 +0530
commitd9c130eb1119153874abdcdc7d4e8e84580b40ca (patch)
treea6043960298ad173f6948831bfabb977fa6e93a7
parent3588f1844cb96b0f31d0d919cee74cbcbb03365f (diff)
downloadtissue-d9c130eb1119153874abdcdc7d4e8e84580b40ca.tar.gz
tissue-d9c130eb1119153874abdcdc7d4e8e84580b40ca.tar.lz
tissue-d9c130eb1119153874abdcdc7d4e8e84580b40ca.zip
web: server: List search results even on home page.
* tissue/web/server.scm (handler): List search results even on home
page.
-rw-r--r--tissue/web/server.scm25
1 files changed, 11 insertions, 14 deletions
diff --git a/tissue/web/server.scm b/tissue/web/server.scm
index c5c67b5..55e57e1 100644
--- a/tissue/web/server.scm
+++ b/tissue/web/server.scm
@@ -160,20 +160,17 @@ to a stylesheet."
             (request-method request)
             path)
     (cond
-     ((string=? path "/")
-      (values '((content-type . (text/html)))
-              (sxml->html (make-search-page '() "" css))))
-     ((string=? "/search" path)
-      (values '((content-type . (text/html)))
-              (sxml->html
-               (make-search-page
-                (call-with-database xapian-index
-                  (lambda (db)
-                    (search-map document->sxml
-                                db
-                                (assoc-ref parameters "query"))))
-                (assoc-ref parameters "query")
-                css))))
+     ((member path (list "/" "/search"))
+      (let ((search-query (or (assoc-ref parameters "query")
+                              "")))
+        (values '((content-type . (text/html)))
+                (sxml->html
+                 (make-search-page
+                  (call-with-database xapian-index
+                    (lambda (db)
+                      (search-map document->sxml db search-query)))
+                  search-query
+                  css)))))
      (else
       (values (build-response #:code 404)
               (string-append "Resource not found: "