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
 | 
			
		||||
         web-server/http
 | 
			
		||||
         "application-globals.rkt"
 | 
			
		||||
         "data.rkt"
 | 
			
		||||
         "url-utils.rkt"
 | 
			
		||||
         "xexpr-utils.rkt")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -14,12 +15,18 @@
 | 
			
		|||
  (define wikiname (dict-ref (url-query (request-uri req)) 'wikiname #f))
 | 
			
		||||
  (define q (dict-ref (url-query (request-uri req)) 'q #f))
 | 
			
		||||
  (response-handler
 | 
			
		||||
   (if (not (and wikiname q))
 | 
			
		||||
   (cond
 | 
			
		||||
     [(not wikiname)
 | 
			
		||||
      (response/output
 | 
			
		||||
       #:code 400
 | 
			
		||||
       #:mime-type "text/plain"
 | 
			
		||||
       (λ (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"
 | 
			
		||||
                                 wikiname
 | 
			
		||||
                                  (params->query `(("q" . ,q))))))))
 | 
			
		||||
                                 (params->query `(("q" . ,q)))))])))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,7 +40,7 @@
 | 
			
		|||
                 (input (@ (name "wikiname") (class "paired__input") (type "text") (placeholder "pokemon") (required))))
 | 
			
		||||
          (label (@ (class "paired__label"))
 | 
			
		||||
                 "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"))
 | 
			
		||||
    (h2 "Example pages")
 | 
			
		||||
    (ul
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue