forked from cadence/breezewiki
Allow searching for nothing on BreezeWiki homepage
This commit is contained in:
parent
aab52bd92b
commit
02819a7459
2 changed files with 17 additions and 10 deletions
|
@ -4,6 +4,7 @@
|
||||||
net/url
|
net/url
|
||||||
web-server/http
|
web-server/http
|
||||||
"application-globals.rkt"
|
"application-globals.rkt"
|
||||||
|
"data.rkt"
|
||||||
"url-utils.rkt"
|
"url-utils.rkt"
|
||||||
"xexpr-utils.rkt")
|
"xexpr-utils.rkt")
|
||||||
|
|
||||||
|
@ -14,12 +15,18 @@
|
||||||
(define wikiname (dict-ref (url-query (request-uri req)) 'wikiname #f))
|
(define wikiname (dict-ref (url-query (request-uri req)) 'wikiname #f))
|
||||||
(define q (dict-ref (url-query (request-uri req)) 'q #f))
|
(define q (dict-ref (url-query (request-uri req)) 'q #f))
|
||||||
(response-handler
|
(response-handler
|
||||||
(if (not (and wikiname q))
|
(cond
|
||||||
|
[(not wikiname)
|
||||||
(response/output
|
(response/output
|
||||||
#:code 400
|
#:code 400
|
||||||
#:mime-type "text/plain"
|
#:mime-type "text/plain"
|
||||||
(λ (out)
|
(λ (out)
|
||||||
(displayln "Requires wikiname and q parameters." out)))
|
(displayln "Requires wikiname and q parameters." out)))]
|
||||||
|
[(or (not q) (equal? q ""))
|
||||||
|
(define siteinfo (siteinfo-fetch wikiname))
|
||||||
|
(define dest (format "/~a/wiki/~a" wikiname (or (siteinfo^-basepage siteinfo) "Main_Page")))
|
||||||
|
(generate-redirect dest)]
|
||||||
|
[#t
|
||||||
(generate-redirect (format "/~a/search?~a"
|
(generate-redirect (format "/~a/search?~a"
|
||||||
wikiname
|
wikiname
|
||||||
(params->query `(("q" . ,q))))))))
|
(params->query `(("q" . ,q)))))])))
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
(input (@ (name "wikiname") (class "paired__input") (type "text") (placeholder "pokemon") (required))))
|
(input (@ (name "wikiname") (class "paired__input") (type "text") (placeholder "pokemon") (required))))
|
||||||
(label (@ (class "paired__label"))
|
(label (@ (class "paired__label"))
|
||||||
"Search query"
|
"Search query"
|
||||||
(input (@ (name "q") (class "paired__input") (type "text") (placeholder "Eevee") (required))))
|
(input (@ (name "q") (class "paired__input") (type "text") (placeholder "Eevee"))))
|
||||||
(button "Search"))
|
(button "Search"))
|
||||||
(h2 "Example pages")
|
(h2 "Example pages")
|
||||||
(ul
|
(ul
|
||||||
|
|
Loading…
Reference in a new issue