aboutsummaryrefslogtreecommitdiff
path: root/module/html/vcomponent.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-10 17:23:34 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-10 17:23:34 +0200
commite028543baa552aa091fe3485b03da48d25ab8179 (patch)
tree89d481c7509d3634bce76e9319cb192c2b25a328 /module/html/vcomponent.scm
parentHTML work. (diff)
downloadcalp-e028543baa552aa091fe3485b03da48d25ab8179.tar.gz
calp-e028543baa552aa091fe3485b03da48d25ab8179.tar.xz
Really start breaking apart HTML.
Diffstat (limited to 'module/html/vcomponent.scm')
-rw-r--r--module/html/vcomponent.scm62
1 files changed, 62 insertions, 0 deletions
diff --git a/module/html/vcomponent.scm b/module/html/vcomponent.scm
index 5e17932c..f9c24ecd 100644
--- a/module/html/vcomponent.scm
+++ b/module/html/vcomponent.scm
@@ -5,10 +5,12 @@
:use-module (srfi srfi-41)
:use-module (datetime)
:use-module (html util)
+ :use-module ((html components) :select (btn tabset))
:use-module ((output general) :select (calculate-fg-color))
:use-module ((vcomponent datetime output)
:select (fmt-time-span
format-description
+ format-summary
format-recurrence-rule
))
)
@@ -126,3 +128,63 @@
(list name (or bg-color 'white) (or fg-color 'black)
name (or bg-color 'black))))
calendars))))
+
+;; "Physical" block in calendar view
+(define*-public (make-block ev optional: (extra-attributes '()))
+
+ `((a (@ (href "#" ,(html-id ev))
+ (class "hidelink"))
+ (div (@ ,@(assq-merge
+ extra-attributes
+ `((id ,(html-id ev))
+ (class "event CAL_" ,(html-attr (or (prop (parent ev) 'NAME)
+ "unknown"))
+ ,(when (and (prop ev 'PARTSTAT)
+ (eq? 'TENTATIVE (prop ev 'PARTSTAT)))
+ " tentative"))
+ (onclick "toggle_popup('popup' + this.id)")
+ )))
+ ;; Inner div to prevent overflow. Previously "overflow: none"
+ ;; was set on the surounding div, but the popup /needs/ to
+ ;; overflow (for the tabs?).
+ (div (@ (class "event-body"))
+ ,(when (prop ev 'RRULE)
+ `(span (@ (class "repeating")) "↺"))
+ (span (@ (class "summary"))
+ ,(format-summary ev (prop ev 'SUMMARY)))
+ ,(when (prop ev 'LOCATION)
+ `(span (@ (class "location"))
+ ,(string-map (lambda (c) (if (char=? c #\,) #\newline c))
+ (prop ev 'LOCATION)))))
+ (div (@ (style "display:none !important;"))
+ ,((@ (output xcal) ns-wrap)
+ ((@ (output xcal) vcomponent->sxcal)
+ ev)))))))
+
+
+
+(define-public (popup ev id)
+ `(div (@ (class "popup-container") (id ,id)
+ (onclick "event.stopPropagation()"))
+ (div (@ (class "popup"))
+ (nav (@ (class "popup-control CAL_"
+ ,(html-attr (or (prop (parent ev) 'NAME)
+ "unknown"))))
+ ,(btn "×"
+ title: "Stäng"
+ onclick: "close_popup(document.getElementById(this.closest('.popup-container').id))"
+ class: '("close-tooltip"))
+ ,(btn "🗑"
+ title: "Ta bort"
+ onclick: "remove_event(document.getElementById(this.closest('.popup-container').id.substr(5)))"))
+
+ ,(tabset
+ `(("📅" title: "Översikt"
+ ,(fmt-single-event ev))
+ ("⤓" title: "Nedladdning"
+ (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"))))))))))