]> git.armaanb.net Git - bettersearch.git/blobdiff - server.rkt
Update HTML templates
[bettersearch.git] / server.rkt
index 81abf7cb1b0cbdd5fe3edf0bcf9260dea6f7b530..42da28635db7c462026ea9d7e36b0516f858f056 100644 (file)
 
 (define-values (dispatch generate-url)
   (dispatch-rules
-    [("index") do-index]
+    [("") do-index]
     [("search") do-search]
     ))
 
+(define (do-head title)
+  (include-template "templates/head.html"))
+
+(define (do-footer)
+  (include-template "templates/footer.html"))
+
 (define (do-index req)
-      (http-response (include-template "index.html")))
+  (http-response (string-append
+                  (do-head "Web Search")
+                  (include-template "templates/index.html")
+                  (do-footer))))
 
 (define (search query)
   (define engine (string->url
@@ -36,7 +45,7 @@
     #"OK"                ; HTTP response message.
     (current-seconds)    ; Timestamp.
     TEXT/HTML-MIME-TYPE  ; MIME type for content.
-    '()                  ; Additional HTTP headers.
+    '()                  ; Additional HTTP heads.
     (list                ; Content (in bytes) to send to the browser.
       (string->bytes/utf-8 content))))
 
                          ht
                      ))
                    (hash-ref (search query) 'results)))))
-      (http-response (include-template "search.html")))
-    (do-index req)))
+      (http-response (string-append
+                      (do-head (string-append query " | Web Search"))
+                      (include-template "templates/search.html")
+                      (do-footer))))
+    (redirect-to "/")))
 
 (serve/servlet dispatch
               #:command-line? #t