From a9a5b5052fd87d1d7fd66ff68764ab87a2379a80 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Sat, 27 Nov 2021 23:24:21 -0500 Subject: [PATCH] Update HTML templates --- index.html | 13 ------------- server.rkt | 22 +++++++++++++++++----- templates/footer.html | 6 ++++++ templates/head.html | 6 ++++++ templates/index.html | 6 ++++++ search.html => templates/search.html | 11 ++--------- 6 files changed, 37 insertions(+), 27 deletions(-) delete mode 100644 index.html create mode 100644 templates/footer.html create mode 100644 templates/head.html create mode 100644 templates/index.html rename search.html => templates/search.html (63%) diff --git a/index.html b/index.html deleted file mode 100644 index 0d401e9..0000000 --- a/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - -

Search

-
- - - -
- - diff --git a/server.rkt b/server.rkt index 81abf7c..42da286 100644 --- a/server.rkt +++ b/server.rkt @@ -14,12 +14,21 @@ (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)))) @@ -68,8 +77,11 @@ 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 diff --git a/templates/footer.html b/templates/footer.html new file mode 100644 index 0000000..9185fab --- /dev/null +++ b/templates/footer.html @@ -0,0 +1,6 @@ +
+

This search provided via the Better Search Engine. +
+Source code + + diff --git a/templates/head.html b/templates/head.html new file mode 100644 index 0000000..67556c5 --- /dev/null +++ b/templates/head.html @@ -0,0 +1,6 @@ + + + + @title + + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..3c014ec --- /dev/null +++ b/templates/index.html @@ -0,0 +1,6 @@ +

Web Search

+
+ + + +
diff --git a/search.html b/templates/search.html similarity index 63% rename from search.html rename to templates/search.html index 2662d28..58bf146 100644 --- a/search.html +++ b/templates/search.html @@ -1,12 +1,7 @@ - - - - - -

Search results

+

Search Results

- +
@@ -21,5 +16,3 @@ }
- - -- 2.39.2