added a message when the search is truncated

svn: r8059

original commit: 3500ef305c1fa1dbc2547ab928ab6b4cdc6ce405
This commit is contained in:
Robby Findler 2007-12-19 04:12:10 +00:00
parent 197eadc9eb
commit 6bdb23bf75

View File

@ -115,33 +115,42 @@
search-regexps)) search-regexps))
(entry-words entry))) (entry-words entry)))
;; limit : exact-positive-integer
;; maximum number of hits to display
(define limit 500)
;; build-itemization : (listof entry) -> (listof <stuff>) ;; build-itemization : (listof entry) -> (listof <stuff>)
(define (build-itemization title entries) (define (build-itemization title entries)
(cond (cond
[(null? entries) '()] [(null? entries) '()]
[else [else
(list (let ([entries
(bold title) (sort
(apply itemize entries
(map (λ (x y) (string-ci<=? (entry->sort-key x) (entry->sort-key y))))])
(λ (entry) (list*
(apply item (bold title)
(make-link-element (apply itemize
"indexlink" (map
(entry-content entry) (λ (entry)
(entry-tag entry)) (apply item
(make-extra-content (make-link-element
(entry-desc entry)))) "indexlink"
(limit-length (entry-content entry)
500 (entry-tag entry))
(sort (make-extra-content
entries (entry-desc entry))))
(λ (x y) (string-ci<=? (entry->sort-key x) (entry->sort-key y))))))))])) (limit-length
limit
entries)))
(if (<= (length entries) limit)
'()
(list (italic (format "Search truncated after ~a hits." limit))))))]))
(define (limit-length n l) (define (limit-length n l)
(cond (cond
[(zero? n) '()]
[(null? l) '()] [(null? l) '()]
[(zero? n) '()]
[else (cons (car l) (limit-length (- n 1) (cdr l)))])) [else (cons (car l) (limit-length (- n 1) (cdr l)))]))
(define (entry->sort-key e) (define (entry->sort-key e)