diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-05-09 22:19:01 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-05-09 22:19:01 +0200 |
commit | f56daa40756cb4f356c283567de9cbc050bd86b1 (patch) | |
tree | 778a1bbada2a00acc854a85721f36618b6ce4f6b /module/output | |
parent | Clean up util header. (diff) | |
parent | Add short commentary on difference between parse and parse/component. (diff) | |
download | calp-f56daa40756cb4f356c283567de9cbc050bd86b1.tar.gz calp-f56daa40756cb4f356c283567de9cbc050bd86b1.tar.xz |
Replace iCalendar parser.
The old iCalendar parser was a direct port of my C parser, which
unfortunately clashed with guile's evaluation model, and was therefore
really slow.
This new one is much schemier [sic?], and therefore much faster. On my
laptop the parse time went from around 10s to 2.5s, so a 4x speedup!
Diffstat (limited to '')
-rw-r--r-- | module/output/html.scm | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/module/output/html.scm b/module/output/html.scm index 3b17d81b..da5c0659 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -145,12 +145,17 @@ ,(fmt-single-event ev)))) +(define (->string a) + (format #f "~a" a)) + (define (data-attributes event) (hash-map->list (match-lambda* + [(key (vlines ...)) (list (string->symbol (format #f "data-~a" key)) + (string-join (map (compose ->string value) vlines) ","))] [(key vline) (list (string->symbol (format #f "data-~a" key)) - (format #f "~a" (value vline)))] + (->string (value vline)))] [_ (error "What are you doing‽")]) (attributes event))) @@ -234,12 +239,12 @@ (make-block ev `((class - ,(when (date<? (as-date (get-datetime (attr ev 'DTSTART))) date) + ,(when (date<? (as-date (attr ev 'DTSTART)) date) " continued") ;; TODO all day events usually have the day after as DTEND. ;; So a whole day event the 6 june would have a DTEND of the ;; 7 june. - ,(when (date<? date (as-date (get-datetime (attr ev 'DTEND)))) + ,(when (date<? date (as-date (attr ev 'DTEND))) " continuing")) (style ,style)))) @@ -354,7 +359,7 @@ ,((compose (@ (vcomponent recurrence display) format-recurrence-rule) (@ (vcomponent recurrence parse) parse-recurrence-rule)) (attr ev 'RRULE)) - ,@(awhen (attr ev 'EXDATE) + ,@(awhen (attr* ev 'EXDATE) (list ", undantaget " (add-enumeration-punctuation @@ -371,7 +376,7 @@ '(HOURLY MINUTELY SECONDLY)) (datetime->string d "~e ~b ~k:~M") (datetime->string d "~e ~b")))) - it)))) + (map value it))))) ".")) (define (format-description ev str) @@ -783,6 +788,8 @@ (define calendars (getf 'calendars)) (define events (getf 'event-set)) + ((@ (util time) report-time!) "html start") + ;; TODO This still doesn't account for PWD, file existing but is of ;; wrong type, html directory existing but static symlink missing, ;; static being a different file type, and probably something else |