aboutsummaryrefslogtreecommitdiff
path: root/module/output/html-search.scm
blob: a6a80cd471363c1535263e431138340b69683984 (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
;; TODO rename this module
(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 page paginator q=)
  `(*TOP*
    (*PI* xml "version=\"1.0\" encoding=\"utf-8\"")
    (html (@ (xmlns "http://www.w3.org/1999/xhtml") (lang sv))
          (head (title "Search results")
                ;; TODO (@ (output html) include-css)
                (link (@ (type "text/css")
                         (rel "stylesheet")
                         (href "/static/style.css"))))
          (body
           (h2 "Search term")
           (form
            (pre (textarea (@ (name "q") (rows 5) (spellcheck false)
                              (style "width:100%"))
                           ,(format #f "~y" search-term)))
            (input (@ (type submit))))
           (h2 "Result (page " ,page ")")
           (ul
            ,@(for event in search-result
                   `(li (@ (class "event"))
                        ,(prop event 'SUMMARY))))
           (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)) "»"))))
           ))))