aboutsummaryrefslogtreecommitdiff
path: root/module/output
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-09 15:44:44 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-09 16:27:31 +0200
commite2a602d16dfad5325960dec0a16ee2b88560a36f (patch)
treee076260a831ef3471f45b07d516410eb891299d7 /module/output
parentCan create events with åäö again. (diff)
downloadcalp-e2a602d16dfad5325960dec0a16ee2b88560a36f.tar.gz
calp-e2a602d16dfad5325960dec0a16ee2b88560a36f.tar.xz
Add basic (semi broken) paginator to HTML search.
Diffstat (limited to 'module/output')
-rw-r--r--module/output/html-search.scm39
-rw-r--r--module/output/html.scm16
2 files changed, 47 insertions, 8 deletions
diff --git a/module/output/html-search.scm b/module/output/html-search.scm
new file mode 100644
index 00000000..e8414d18
--- /dev/null
+++ b/module/output/html-search.scm
@@ -0,0 +1,39 @@
+;; TODO rename this module
+(define-module (output html-search)
+ :use-module (util)
+ :use-module (vcomponent)
+ :use-module (ice-9 format)
+ )
+
+(define-public (search-result-page search-term search-result mp 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")
+ (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)))
+ "»"))))
+ ))
+ ))))
diff --git a/module/output/html.scm b/module/output/html.scm
index e3668f08..6e6fcd30 100644
--- a/module/output/html.scm
+++ b/module/output/html.scm
@@ -125,6 +125,7 @@
`(div (@ (class "tab"))
(input (@ (type "radio") (id ,id) (name ,tabgroup)
,@(when (zero? i) '((checked)))))
+ ;; TODO title attribute for label
(label (@ (for ,id) (style "top: " ,(* 6 i) "ex")) ,key)
(div (@ (class "content")) ,body)))))
@@ -144,14 +145,13 @@
onclick: "remove_event(document.getElementById(this.closest('.popup-container').id.substr(5)))"))
,(tabset
- (append
- `(("📅" ,(fmt-single-event ev))
- ("⤓" (div (@ (style "font-family:sans"))
- (p "Ladda ner")
- (ul (li (a (@ (href "/calendar/" ,(prop ev 'UID) ".ics"))
- "som iCal"))
- (li (a (@ (href "/calendar/" ,(prop ev 'UID) ".xcs"))
- "som xCal")))))))))))
+ `(("📅" ,(fmt-single-event ev))
+ ("⤓" (div (@ (style "font-family:sans"))
+ (p "Ladda ner")
+ (ul (li (a (@ (href "/calendar/" ,(prop ev 'UID) ".ics"))
+ "som iCal"))
+ (li (a (@ (href "/calendar/" ,(prop ev 'UID) ".xcs"))
+ "som xCal"))))))))))