diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-09 22:15:34 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-08-09 22:15:34 +0200 |
commit | 929640aa3fbb496c404b584d95c4d8001f667a19 (patch) | |
tree | 260c63955c929cd29fcb499f62bfd745551f89c0 /module/output/html-search.scm | |
parent | Add basic (semi broken) paginator to HTML search. (diff) | |
download | calp-929640aa3fbb496c404b584d95c4d8001f667a19.tar.gz calp-929640aa3fbb496c404b584d95c4d8001f667a19.tar.xz |
Add paginator, use in in html and term.
Diffstat (limited to 'module/output/html-search.scm')
-rw-r--r-- | module/output/html-search.scm | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/module/output/html-search.scm b/module/output/html-search.scm index e8414d18..a6a80cd4 100644 --- a/module/output/html-search.scm +++ b/module/output/html-search.scm @@ -2,10 +2,11 @@ (define-module (output html-search) :use-module (util) :use-module (vcomponent) + :use-module (vcomponent search) :use-module (ice-9 format) ) -(define-public (search-result-page search-term search-result mp q=) +(define-public (search-result-page search-term search-result page paginator q=) `(*TOP* (*PI* xml "version=\"1.0\" encoding=\"utf-8\"") (html (@ (xmlns "http://www.w3.org/1999/xhtml") (lang sv)) @@ -21,19 +22,17 @@ (style "width:100%")) ,(format #f "~y" search-term))) (input (@ (type submit)))) - (h2 "Result") + (h2 "Result (page " ,page ")") (ul ,@(for event in search-result `(li (@ (class "event")) ,(prop event 'SUMMARY)))) (div (@ (class "paginator")) - ,@(let () - (define (make-link n) `(a (@ (href "?" ,q= "&p=" ,n)) - ,n)) - (if (car mp) ; true max page - (map make-link (iota (cdr mp))) - (append (map make-link (iota (cdr mp))) - `((a (@ (href "?" ,q= "&p=" ,(cdr mp))) - "»")))) - )) + ,@(paginator->list + paginator + (lambda (p) (if (= p page) + `(span ,p) + `(a (@ (href "?" ,q= "&p=" ,p)) ,p))) + (lambda (p) `(a (@ (href "?" ,q= "&p=" ,p)) "»")))) )))) + |