summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmaan Bhojwani <me@armaanb.net>2021-11-27 23:24:21 -0500
committerArmaan Bhojwani <me@armaanb.net>2021-11-27 23:24:21 -0500
commita9a5b5052fd87d1d7fd66ff68764ab87a2379a80 (patch)
tree1d7ee2fbe41731872205ac47092479fd309a1103
parenta0536c3fe9b8690ba944a4947df2bf6f8d7eefa7 (diff)
downloadbettersearch-a9a5b5052fd87d1d7fd66ff68764ab87a2379a80.tar.gz
Update HTML templates
-rw-r--r--index.html13
-rw-r--r--server.rkt22
-rw-r--r--templates/footer.html6
-rw-r--r--templates/head.html6
-rw-r--r--templates/index.html6
-rw-r--r--templates/search.html (renamed from search.html)11
6 files changed, 37 insertions, 27 deletions
diff --git a/index.html b/index.html
deleted file mode 100644
index 0d401e9..0000000
--- a/index.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<html>
-<head>
- <link rel="stylesheet" type="text/css" href="/styles.css">
-</head>
-<body>
-<h1>Search</h1>
- <form action="/search">
- <label for="q">Search Query</label>
- <input type="text" name="q" id="q">
- <input type="submit">
- </form>
-<body>
-</html>
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 @@
+<hr>
+<p>This search provided via the Better Search Engine.
+<br>
+<a href="https://git.armaanb.net/bettersearch">Source code</a>
+<body>
+</html>
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 @@
+<html>
+<head>
+ <link rel="stylesheet" type="text/css" href="/styles.css">
+ <title> @title </title>
+</head>
+<body>
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 @@
+<h1>Web Search</h1>
+<form action="/search">
+ <label for="q">Search Query</label>
+ <input type="text" name="q" id="q">
+ <input type="submit">
+</form>
diff --git a/search.html b/templates/search.html
index 2662d28..58bf146 100644
--- a/search.html
+++ b/templates/search.html
@@ -1,12 +1,7 @@
-<html>
-<head>
- <link rel="stylesheet" type="text/css" href="/styles.css">
-</head>
-<body>
-<h1>Search results</h1>
+<h1>Search Results</h1>
<form action="/search">
<label for="q">Search Query</label>
- <input type="text" name="q" id="q">
+ <input type="text" name="q" id="q" value="@query">
<input type="submit">
</form>
<dl>
@@ -21,5 +16,3 @@
</div>
}
</dl>
-<body>
-</html>