From 715e36ab81389ebf53ea158027d0a83f144eee0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 30 Jun 2020 01:58:19 +0200 Subject: Finished renamining attribute to property. --- module/output/html.scm | 90 +++++++++++++++++++++++----------------------- module/output/ical.scm | 16 ++++----- module/output/terminal.scm | 32 ++++++++--------- 3 files changed, 69 insertions(+), 69 deletions(-) (limited to 'module/output') diff --git a/module/output/html.scm b/module/output/html.scm index 5c963482..f462db56 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -76,8 +76,8 @@ ;; TODO currently not guaranteed to be unique (define (UID ev) (string-append - (datetime->string (as-datetime (attr ev 'DTSTART)) "~Y~m~d~H~M~S") - (html-attr (attr ev 'UID)))) + (datetime->string (as-datetime (prop ev 'DTSTART)) "~Y~m~d~H~M~S") + (html-attr (prop ev 'UID)))) ;; Retuns an HTML-safe version of @var{str}. (define (html-attr str) @@ -87,9 +87,9 @@ ;; Takes an event, and returns a pretty string for the time interval ;; the event occupies. (define (fmt-time-span ev) - (cond [(attr ev 'DTSTART) date? + (cond [(prop ev 'DTSTART) date? => (lambda (s) - (cond [(attr ev 'DTEND) + (cond [(prop ev 'DTEND) => (lambda (e) (if (date= e (date+ s (date day: 1))) (date->string s) ; start = end, only return one value @@ -98,8 +98,8 @@ ;; no end value, just return start [else (date->string s)]))] [else ; guaranteed datetime - (let ((s (attr ev 'DTSTART)) - (e (attr ev 'DTEND))) + (let ((s (prop ev 'DTSTART)) + (e (prop ev 'DTEND))) (if e (let ((fmt-str (if (date= (get-date s) (get-date e)) "~H:~M" "~Y-~m-~d ~H:~M"))) @@ -138,7 +138,7 @@ (define (popup ev id) `(div (@ (class "popup-container") (id ,id)) (div (@ (class "popup")) - (nav (@ (class "popup-control CAL_" ,(html-attr (or (attr (parent ev) 'NAME) + (nav (@ (class "popup-control CAL_" ,(html-attr (or (prop (parent ev) 'NAME) "unknown")))) ,(btn "×" title: "Stäng" @@ -147,7 +147,7 @@ ) ,(btn "📅" title: "Ladda ner" - href: (string-append "/calendar/" (attr ev 'UID) ".ics"))) + href: (string-append "/calendar/" (prop ev 'UID) ".ics"))) ,(fmt-single-event ev)))) @@ -189,22 +189,22 @@ (class "hidelink")) (div (@ ,@(assq-merge extra-attributes - `((class "event CAL_" ,(html-attr (or (attr (parent ev) 'NAME) + `((class "event CAL_" ,(html-attr (or (prop (parent ev) 'NAME) "unknown")) - ,(when (and (attr ev 'PARTSTAT) - (eq? 'TENTATIVE (attr ev 'PARTSTAT))) + ,(when (and (prop ev 'PARTSTAT) + (eq? 'TENTATIVE (prop ev 'PARTSTAT))) " tentative")) (data-tipped-options ,(format #f "inline: '~a'" popup-id))))) ,(when (debug) `(script (@ (type "application/calendar+xml")) ,((@ (output xcal) vcomponent->sxcal) ev))) - ,(when (attr ev 'RRULE) + ,(when (prop ev 'RRULE) `(span (@ (class "repeating")) "↺")) - ,((get-config 'summary-filter) ev (attr ev 'SUMMARY)) - ,(when (attr ev 'LOCATION) + ,((get-config 'summary-filter) ev (prop ev 'SUMMARY)) + ,(when (prop ev 'LOCATION) `(span (@ (class "location")) ,(string-map (lambda (c) (if (char=? c #\,) #\newline c)) - (attr ev 'LOCATION)))))) + (prop ev 'LOCATION)))))) ,(popup ev popup-id))) ;; Format single event for graphical display @@ -221,10 +221,10 @@ (* 100 (width ev)) ; width ;; top - (if (date= date (as-date (attr ev 'DTSTART))) + (if (date= date (as-date (prop ev 'DTSTART))) (* 100/24 (time->decimal-hour - (as-time (attr ev 'DTSTART)))) + (as-time (prop ev 'DTSTART)))) 0) ;; height @@ -232,9 +232,9 @@ (make-block ev `((class - ,(when (datedecimal-hour diff start-date) total-length))) @@ -273,10 +273,10 @@ (make-block ev `((class - ,(when (date/-time< (attr ev 'DTSTART) start-date) + ,(when (date/-time< (prop ev 'DTSTART) start-date) " continued") - ,(when (and (attr ev 'DTEND) - (date/-time< (date+ end-date (date day: 1)) (attr ev 'DTEND))) + ,(when (and (prop ev 'DTEND) + (date/-time< (date+ end-date (date day: 1)) (prop ev 'DTEND))) " continuing")) (style ,style)))) @@ -351,8 +351,8 @@ `(span (@ (class "rrule")) "Upprepas " ,((@ (vcomponent recurrence display) format-recurrence-rule) - (attr ev 'RRULE)) - ,@(awhen (attr* ev 'EXDATE) + (prop ev 'RRULE)) + ,@(awhen (prop* ev 'EXDATE) (list ", undantaget " (add-enumeration-punctuation @@ -363,7 +363,7 @@ ;; NOTE only show time when it's different than the start time? ;; or possibly only when FREQ is hourly or lower. (if (memv ((@ (vcomponent recurrence internal) freq) - (attr ev 'RRULE)) + (prop ev 'RRULE)) '(HOURLY MINUTELY SECONDLY)) (datetime->string d "~e ~b ~k:~M") (datetime->string d "~e ~b")))) @@ -381,34 +381,34 @@ (define* (fmt-single-event ev optional: (attributes '()) key: (fmt-header list)) - ;; (format (current-error-port) "fmt-single-event: ~a~%" (attr ev 'X-HNH-FILENAME)) + ;; (format (current-error-port) "fmt-single-event: ~a~%" (prop ev 'X-HNH-FILENAME)) `(article (@ ,@(assq-merge attributes `((class "eventtext CAL_bg_" - ,(html-attr (or (attr (parent ev) 'NAME) "unknown")) - ,(when (and (attr ev 'PARTSTAT) - (eq? 'TENTATIVE (attr ev 'PARTSTAT))) + ,(html-attr (or (prop (parent ev) 'NAME) "unknown")) + ,(when (and (prop ev 'PARTSTAT) + (eq? 'TENTATIVE (prop ev 'PARTSTAT))) " tentative"))))) (h3 ,(fmt-header - (when (attr ev 'RRULE) + (when (prop ev 'RRULE) `(span (@ (class "repeating")) "↺")) - (attr ev 'SUMMARY))) + (prop ev 'SUMMARY))) (div ,(call-with-values (lambda () (fmt-time-span ev)) (case-lambda [(start) `(div ,start)] [(start end) `(div ,start " — " ,end)])) - ,(when (and=> (attr ev 'LOCATION) (negate string-null?)) + ,(when (and=> (prop ev 'LOCATION) (negate string-null?)) `(div (b "Plats: ") (div (@ (class "location")) ,(string-map (lambda (c) (if (char=? c #\,) #\newline c)) - (attr ev 'LOCATION))))) - ,(and=> (attr ev 'DESCRIPTION) + (prop ev 'LOCATION))))) + ,(and=> (prop ev 'DESCRIPTION) (lambda (str) (format-description ev str))) - ,(awhen (attr ev 'RRULE) + ,(awhen (prop ev 'RRULE) (format-recurrence-rule ev)) - ,(when (attr ev 'LAST-MODIFIED) + ,(when (prop ev 'LAST-MODIFIED) `(span (@ (class "last-modified")) "Senast ändrad " - ,(datetime->string (attr ev 'LAST-MODIFIED) "~1 ~H:~M"))) + ,(datetime->string (prop ev 'LAST-MODIFIED) "~1 ~H:~M"))) ))) @@ -425,7 +425,7 @@ ev `((id ,(UID ev))) fmt-header: (lambda body - `(a (@ (href "#" ,(date-link (as-date (attr ev 'DTSTART)))) + `(a (@ (href "#" ,(date-link (as-date (prop ev 'DTSTART)))) (class "hidelink")) ,@body)))) (stream-filter @@ -434,7 +434,7 @@ ;; This removes all descriptions from ;; events for previous days, ;; solving duplicates. - (date/-time<=? date (attr ev 'DTSTART))) + (date/-time<=? date (prop ev 'DTSTART))) events)))))) @@ -625,9 +625,9 @@ (script (@ (src "/static/script.js")) "") (style ,(format #f "~:{.CAL_~a { background-color: ~a; color: ~a }~%.CAL_bg_~a { border-color: ~a }~%~}" (map (lambda (c) - (let* ((name (html-attr (attr c 'NAME))) - (bg-color (attr c 'COLOR)) - (fg-color (and=> (attr c 'COLOR) + (let* ((name (html-attr (prop c 'NAME))) + (bg-color (prop c 'COLOR)) + (fg-color (and=> (prop c 'COLOR) calculate-fg-color))) (list name (or bg-color 'white) (or fg-color 'black) name (or bg-color 'black)))) @@ -740,8 +740,8 @@ (ul ,@(map (lambda (calendar) `(li (@ (class "CAL_bg_" - ,(html-attr (attr calendar 'NAME)))) - ,(attr calendar 'NAME))) + ,(html-attr (prop calendar 'NAME)))) + ,(prop calendar 'NAME))) calendars)))) ;; List of events diff --git a/module/output/ical.scm b/module/output/ical.scm index de6a351d..7e514c99 100644 --- a/module/output/ical.scm +++ b/module/output/ical.scm @@ -155,7 +155,7 @@ (format #t "END:~a\r\n" (type component)) ;; If we have alternatives, splice them in here. - (cond [(attr component 'X-HNH-ALTERNATIVES) + (cond [(prop component 'X-HNH-ALTERNATIVES) => (lambda (alts) (hash-map->list (lambda (_ comp) (component->ical-string comp)) alts))])) @@ -164,23 +164,23 @@ (define (write-event-to-file event calendar-path) (define cal (make-vcomponent 'VCALENDAR)) - (set! (attr cal 'PRODID) (@ (global) *prodid*) - (attr cal 'VERSION) "2.0" - (attr cal 'CALSCALE) "GREGORIAN") + (set! (prop cal 'PRODID) (@ (global) *prodid*) + (prop cal 'VERSION) "2.0" + (prop cal 'CALSCALE) "GREGORIAN") (add-child! cal event) - (awhen (param (attr* event 'DTSTART) 'TZID) + (awhen (param (prop* event 'DTSTART) 'TZID) ;; TODO this is broken (add-child! cal (zoneinfo->vtimezone (getf 'zoneinfo) it))) - (unless (attr event 'UID) - (set! (attr event 'UID) + (unless (prop event 'UID) + (set! (prop event 'UID) (generate-uuid))) (with-output-to-file (glob (format #f "~a/~a.ics" calendar-path - (attr event 'UID))) + (prop event 'UID))) (lambda () (component->ical-string cal)))) diff --git a/module/output/terminal.scm b/module/output/terminal.scm index 92afe7a6..14777437 100644 --- a/module/output/terminal.scm +++ b/module/output/terminal.scm @@ -41,26 +41,26 @@ (lambda (ev i) (display (string-append - (if (datetime? (attr ev 'DTSTART)) - (datetime->string (attr ev 'DTSTART) "~Y-~m-~d ~H:~M:~S") + (if (datetime? (prop ev 'DTSTART)) + (datetime->string (prop ev 'DTSTART) "~Y-~m-~d ~H:~M:~S") ((@ (texinfo string-utils) center-string) - (date->string (attr ev 'DTSTART)) + (date->string (prop ev 'DTSTART)) 19)) " │ " (if (= i cur-event) "\x1b[7m" "") - (color-escape (attr (parent ev) 'COLOR)) + (color-escape (prop (parent ev) 'COLOR)) ;; Summary filter is a hook for the user - (let ((dirty (attr ev 'X-HNH-DIRTY))) + (let ((dirty (prop ev 'X-HNH-DIRTY))) (string-append (if dirty "* " "") ;; TODO reintroduce summary-filter - (trim-to-width (attr ev 'SUMMARY) (- summary-width + (trim-to-width (prop ev 'SUMMARY) (- summary-width (if dirty 2 0))))) STR-RESET " │ " - (if (attr ev 'LOCATION) "" "\x1b[1;30m") + (if (prop ev 'LOCATION) "" "\x1b[1;30m") (trim-to-width - (or (attr ev 'LOCATION) "INGEN LOKAL") location-width) + (or (prop ev 'LOCATION) "INGEN LOKAL") location-width) STR-RESET "\n"))) events @@ -108,22 +108,22 @@ (unless (null? events) (let ((ev (list-ref events cur-event))) (format #t "~a~%~% ~a~%~%~a\x1b[1mStart:\x1b[m ~a \x1b[1mSlut:\x1b[m ~a~%~%~a~%" - (attr ev 'X-HNH-FILENAME) - (attr ev 'SUMMARY) - (or (and=> (attr ev 'LOCATION) + (prop ev 'X-HNH-FILENAME) + (prop ev 'SUMMARY) + (or (and=> (prop ev 'LOCATION) (cut string-append "\x1b[1mPlats:\x1b[m " <> "\n")) "") ;; NOTE RFC 5545 says that DTSTART and DTEND MUST ;; have the same type. However we believe that is ;; another story. - (let ((start (attr ev 'DTSTART))) + (let ((start (prop ev 'DTSTART))) (if (datetime? start) - (datetime->string (attr ev 'DTSTART) "~Y-~m-~d ~H:~M:~S") + (datetime->string (prop ev 'DTSTART) "~Y-~m-~d ~H:~M:~S") (date->string start))) - (let ((end (attr ev 'DTEND))) + (let ((end (prop ev 'DTEND))) (if (datetime? end) - (datetime->string (attr ev 'DTEND) "~Y-~m-~d ~H:~M:~S") + (datetime->string (prop ev 'DTEND) "~Y-~m-~d ~H:~M:~S") (date->string end))) - (unlines (take-to (flow-text (or (attr ev 'DESCRIPTION) "") + (unlines (take-to (flow-text (or (prop ev 'DESCRIPTION) "") #:width (min 70 width)) (- height 8 5 (length events) 5)))))) -- cgit v1.2.3