searching in help desk now says 'no results' if there are no results, and the help desk menu item in drscheme opens the front page of the manuals

svn: r8227

original commit: 379f2a162beec900f6132dd94e40f216e36965cf
This commit is contained in:
Robby Findler 2008-01-05 22:39:32 +00:00
parent fed85187e3
commit 4a193f0031
2 changed files with 17 additions and 9 deletions

View File

@ -1,8 +1,6 @@
#lang scheme/base #lang scheme/base
(require "search.ss" (require "search.ss"
net/sendurl
setup/dirs
scheme/cmdline) scheme/cmdline)
(define exact-search? #f) (define exact-search? #f)
@ -18,7 +16,6 @@
(error 'plt-help "expected a single search term, got ~s" search-term)) (error 'plt-help "expected a single search term, got ~s" search-term))
(send-exact-results (car search-term))] (send-exact-results (car search-term))]
[(null? search-term) [(null? search-term)
(let ([dest-path (build-path (find-doc-dir) "start" "index.html")]) (send-main-page)]
(send-url (format "file://~a" (path->string dest-path))))]
[else [else
(generate-search-results search-term)])) (generate-search-results search-term)]))

View File

@ -10,11 +10,17 @@
(prefix-in scheme: scribble/scheme) (prefix-in scheme: scribble/scheme)
net/sendurl net/sendurl
net/uri-codec net/uri-codec
mzlib/contract) mzlib/contract
setup/dirs)
(provide/contract (provide/contract
[generate-search-results (-> (listof string?) void?)] [generate-search-results (-> (listof string?) void?)]
[send-exact-results (-> string? void?)]) [send-exact-results (-> string? void?)]
[send-main-page (-> void?)])
(define (send-main-page)
(let ([dest-path (build-path (find-doc-dir) "start" "index.html")])
(send-url (format "file://~a" (path->string dest-path)))))
;; if there is exactly one exact match for this search key, go directly ;; if there is exactly one exact match for this search key, go directly
;; to that place. Otherwise, go to a page that lists all of the matches. ;; to that place. Otherwise, go to a page that lists all of the matches.
@ -58,9 +64,14 @@
[matching-entries (filter (has-match search-regexps) index)] [matching-entries (filter (has-match search-regexps) index)]
[exact-matches (filter (has-match exact-search-regexps) matching-entries)] [exact-matches (filter (has-match exact-search-regexps) matching-entries)]
[inexact-matches (filter (compose not (has-match exact-search-regexps)) matching-entries)]) [inexact-matches (filter (compose not (has-match exact-search-regexps)) matching-entries)])
(append (cond
(build-itemization "Exact matches" exact-matches) [(and (null? exact-matches)
(build-itemization "Containing matches" inexact-matches))))) (null? inexact-matches))
(list (make-element "schemeerror" (list "No results found.")))]
[else
(append
(build-itemization "Exact matches" exact-matches)
(build-itemization "Containing matches" inexact-matches))]))))
file) file)
(send-url (format "file://~a" (path->string file))) (send-url (format "file://~a" (path->string file)))
(void)))) (void))))