aboutsummaryrefslogtreecommitdiff
path: root/module/calp/html/view/search.scm
blob: faefe6dcadfd913714292a1afccbc6a3cb73dcb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(define-module (calp html view search)
  :use-module (util)
  :use-module (vcomponent)
  :use-module (vcomponent search)
  :use-module ((ice-9 pretty-print) :select (pretty-print))
  :use-module ((calp html components)
               :select (xhtml-doc include-css))
  :use-module ((calp html vcomponent)
               :select (compact-event-list))
  )

(define-public (search-result-page
                has-query? search-term search-result page paginator q=)
  (xhtml-doc
   (@ (lang sv))
   (head (title "Search results")
         ,(include-css "/static/style.css"))
   (body
    (h2 "Search term")
    (form
     (pre (textarea (@ (name "q") (rows 5) (spellcheck false)
                       (style "width:100%"))
                    ,(when has-query?
                       (with-output-to-string
                         (lambda () (pretty-print search-term))))))
     (input (@ (type submit))))
    (h2 "Result (page " ,page ")")
    (ul
     ,@(compact-event-list search-result))
    (div (@ (class "paginator"))
         ,@(paginator->list
            paginator
            (lambda (p) (if (= p page)
                       `(span ,p)
                       `(a (@ (href "?" ,q= "&p=" ,p)) ,p)))
            (lambda (p) `(a (@ (href "?" ,q= "&p=" ,p)) "»"))))
    )))