aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-04-22 18:33:12 +0200
committerHugo Hörnquist <hugo@hornquist.se>2019-04-22 18:33:12 +0200
commit79f7122a66ea7f02c5d0ba128363f0ea35983ba8 (patch)
tree20a247315ba6c42fe096c25a85c4fd36d7998caa
parentLimit HTML output to single week. (diff)
downloadcalp-79f7122a66ea7f02c5d0ba128363f0ea35983ba8.tar.gz
calp-79f7122a66ea7f02c5d0ba128363f0ea35983ba8.tar.xz
General cleanup.
-rw-r--r--module/html/html.scm2
-rwxr-xr-xmodule/main.scm36
-rw-r--r--module/srfi/srfi-19/util.scm7
-rw-r--r--static/style.css1
4 files changed, 25 insertions, 21 deletions
diff --git a/module/html/html.scm b/module/html/html.scm
index 93977106..d81faaaf 100644
--- a/module/html/html.scm
+++ b/module/html/html.scm
@@ -38,7 +38,7 @@
#f
(let* ((pred? (lambda (next)
(time<? (attr next 'DTSTART)
- (attr (car ev-list) 'DTEND))))
+ (attr (car ev-list) 'DTEND))))
(overlapping (take-while pred? ev-list))
(rest (drop-while pred? ev-list)))
(for-each (lambda (o x) (set! (x-pos o) x)) overlapping (iota (length overlapping)))
diff --git a/module/main.scm b/module/main.scm
index a83f651f..1b38e6e2 100755
--- a/module/main.scm
+++ b/module/main.scm
@@ -51,6 +51,22 @@
(define (displayln a)
(display a) (newline))
+(define (display-event-table events)
+ (for-each
+ (lambda (ev i)
+ (format #t "~a │ ~a~a~a~a │ ~a~a~%"
+ (time->string (attr ev 'DTSTART) "~1 ~3") ; TODO show truncated string
+ (if (= i cur-event) "\x1b[7m" "")
+ (color-escape (attr (parent ev) 'COLOR))
+ ;; Summary filter is a hook for the user
+ (trim-to-width (summary-filter ev (attr ev 'SUMMARY)) 30)
+ STR-RESET
+ (trim-to-width
+ (or (attr ev 'LOCATION) "\x1b[1;30mINGEN LOKAL") 20)
+ STR-RESET))
+ events
+ (iota (length events))))
+
(define (summary-filter _ str) str)
(define (main-loop event-stream)
@@ -65,24 +81,9 @@
(cls)
(display-calendar-header! (time-utc->date time))
- ;; (line)
- (displayln (box-top #\┬ #\─ 20 32 10))
-
- (for-each
- (lambda (ev i)
- (format #t "~a │ ~a~a~a~a │ ~a~a~%"
- (time->string (attr ev 'DTSTART) "~1 ~3") ; TODO show truncated string
- (if (= i cur-event) "\x1b[7m" "")
- (color-escape (attr (parent ev) 'COLOR))
- ;; Summary filter is a hook for the user
- (trim-to-width (summary-filter ev (attr ev 'SUMMARY)) 30)
- STR-RESET
- (trim-to-width
- (or (attr ev 'LOCATION) "\x1b[1;30mINGEN LOKAL") 20)
- STR-RESET))
- events
- (iota (length events)))
+ (displayln (box-top #\┬ #\─ 20 32 10))
+ (display-event-table events)
(displayln (box-top #\┴ #\─ 20 32 10))
(unless (null? events)
@@ -160,4 +161,5 @@
;; (with-vulgar
;; (lambda () (main-loop events)))))
((@ (sxml simple) sxml->xml) (init html-main))
+ (newline)
)
diff --git a/module/srfi/srfi-19/util.scm b/module/srfi/srfi-19/util.scm
index f9453820..551f5a12 100644
--- a/module/srfi/srfi-19/util.scm
+++ b/module/srfi/srfi-19/util.scm
@@ -54,6 +54,8 @@ attribute set to 0. Can also be seen as \"Start of day\""
(define* (time->string time #:optional (format "~1 ~3"))
(date->string (time-utc->date time) format))
+;; TODO these ({add,remove}-day} might have problem moving between timezones.
+
(define (add-day time)
(add-duration time (make-duration (* 60 60 24))))
@@ -99,14 +101,13 @@ attribute set to 0. Can also be seen as \"Start of day\""
(lambda (d)
(set! (day d) (1+ (day d)))
(normalize-date d))
- start-day))
+ (#; drop-time identity start-day
+ )))
(define-public (in-date-range? start-date end-date)
(format (current-error-port) "Start: ~a~%End: ~a~%"
(date->string start-date) (date->string end-date))
(lambda (date)
- (format (current-error-port) "Date: ~a~%"
- (date->string date "~1"))
(let ((time (date->time-utc date)))
(timespan-overlaps?
(date->time-utc start-date) (date->time-utc end-date)
diff --git a/static/style.css b/static/style.css
index 728423a3..1a98358b 100644
--- a/static/style.css
+++ b/static/style.css
@@ -73,6 +73,7 @@ body {
border-style: solid;
border-width: 2px;
+ font-size: 8pt;
overflow: hidden;