+++ /dev/null
-<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>
+++ /dev/null
-<html>
-<head>
- <link rel="stylesheet" type="text/css" href="/styles.css">
-</head>
-<body>
-<h1>Search results</h1>
- <form action="/search">
- <label for="q">Search Query</label>
- <input type="text" name="q" id="q">
- <input type="submit">
- </form>
-<dl>
-@in[r results]{
- <div class="result">
- <dt>@(hash-ref r "title")</dt>
- <dd>
- <a href="@(hash-ref r "url")">@(hash-ref r "url")</a>
- <br>
- @(hash-ref r "content")
- </dd>
- </div>
-}
-</dl>
-<body>
-</html>
(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
#"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
--- /dev/null
+<hr>
+<p>This search provided via the Better Search Engine.
+<br>
+<a href="https://git.armaanb.net/bettersearch">Source code</a>
+<body>
+</html>
--- /dev/null
+<html>
+<head>
+ <link rel="stylesheet" type="text/css" href="/styles.css">
+ <title> @title </title>
+</head>
+<body>
--- /dev/null
+<h1>Web Search</h1>
+<form action="/search">
+ <label for="q">Search Query</label>
+ <input type="text" name="q" id="q">
+ <input type="submit">
+</form>
--- /dev/null
+<h1>Search Results</h1>
+ <form action="/search">
+ <label for="q">Search Query</label>
+ <input type="text" name="q" id="q" value="@query">
+ <input type="submit">
+ </form>
+<dl>
+@in[r results]{
+ <div class="result">
+ <dt>@(hash-ref r "title")</dt>
+ <dd>
+ <a href="@(hash-ref r "url")">@(hash-ref r "url")</a>
+ <br>
+ @(hash-ref r "content")
+ </dd>
+ </div>
+}
+</dl>