* some fixes to make-search.ss

* rename search-context.html to .htm to avoid being deleted by
  setup/scribble
* added context to help/search interface

svn: r10717
This commit is contained in:
Eli Barzilay 2008-07-11 09:50:29 +00:00
parent dc5211f363
commit bb562f9ee4
3 changed files with 11 additions and 5 deletions

View File

@ -3,7 +3,7 @@
(require setup/dirs net/sendurl net/uri-codec) (require setup/dirs net/sendurl net/uri-codec)
(provide perform-search send-main-page) (provide perform-search send-main-page)
(define search-page "search/index.html") (define search-dir "search/")
;; Almost nothing to do here -- the real work is done in the browser, ;; Almost nothing to do here -- the real work is done in the browser,
;; using javascript. ;; using javascript.
@ -14,5 +14,10 @@
[path (if (file-exists? path) path (build-path (find-doc-dir) sub))]) [path (if (file-exists? path) path (build-path (find-doc-dir) sub))])
(send-url/file path #:fragment fragment #:query query))) (send-url/file path #:fragment fragment #:query query)))
(define (perform-search str) (define (perform-search str [context #f])
(send-main-page #:sub search-page #:query (format "q=~a" (uri-encode str)))) (let* ([page (if context "search-context.htm" "index.html")]
[query (format "q=~a" (uri-encode str))]
[query (if context
(format "~a&hq=~a" query (uri-encode context))
query)])
(send-main-page #:sub (string-append search-dir page) #:query query)))

View File

@ -9,6 +9,7 @@
scheme/list scheme/list
scheme/string scheme/string
scheme/match scheme/match
scheme/path
net/url net/url
(only-in scheme/class send) (only-in scheme/class send)
(only-in xml xexpr->string) (only-in xml xexpr->string)
@ -23,7 +24,7 @@
;; this file is used as a trampoline to set a context (a pre-filter cookie) and ;; this file is used as a trampoline to set a context (a pre-filter cookie) and
;; then hop over to the search page (the search page can do it itself, but it's ;; then hop over to the search page (the search page can do it itself, but it's
;; to heavy to load twice). ;; to heavy to load twice).
(define-runtime-path search-context-page "search-context.html") (define-runtime-path search-context-page "search-context.htm")
(define (quote-string str) (define (quote-string str)
(define (hex4 ch) (define (hex4 ch)
@ -172,7 +173,7 @@
@||}))) @||})))
(for ([src (list search-script search-context-page)]) (for ([src (list search-script search-context-page)])
(define dest (build-path dest-dir (file-name-from-path file))) (define dest (build-path dest-dir (file-name-from-path src)))
(when (file-exists? dest) (delete-file dest)) (when (file-exists? dest) (delete-file dest))
(copy-file src dest)) (copy-file src dest))