aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-19 02:25:51 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-19 02:25:51 +0100
commit81b785cf2dd91326c36efa6c8a3d61d627cdbd53 (patch)
treedc4811f3f47675df1d2901eb62ae1752de73d6fa
parentUpdate html code to use with-streams. (diff)
downloadcalp-81b785cf2dd91326c36efa6c8a3d61d627cdbd53.tar.gz
calp-81b785cf2dd91326c36efa6c8a3d61d627cdbd53.tar.xz
Start implementing html table output.
-rw-r--r--module/output/html.scm32
-rw-r--r--static/style.css15
2 files changed, 47 insertions, 0 deletions
diff --git a/module/output/html.scm b/module/output/html.scm
index bb01b6cd..ed2baa44 100644
--- a/module/output/html.scm
+++ b/module/output/html.scm
@@ -285,6 +285,21 @@
(div (@ (class "days"))
,@(stream->list (stream-map lay-out-day event-groups)))))
+;; TODO this currently only popuplates the table with the number of events for
+;; each day. It should show all the actual events.
+;; (stream event-group) -> sxml
+(define (render-calendar-table event-groups)
+ `(table (@ (border 1))
+ (thead (tr ,@(map (lambda (d) `(th ,d))
+ '(Måndag Tisdag Onsdag Torsdag Fredag Lördag Söndag))))
+ (tbody
+ ,@(tablify (stream->list (stream-map
+ (match-lambda
+ [(day-date . events)
+ `(td ,(stream-length events))])
+ event-groups))
+ 7))))
+
;;; NOTE
;;; The side bar filters all earlier events for each day to not create repeats,
@@ -407,3 +422,20 @@
(map (cut date- <> (date day: 1)) ; last in month
(cdr ms))))))))
+
+(define-public (html-table-main count calendars events start-date)
+ ;; TODO same file creation as in html-chunked-main
+ (stream-for-each
+ (lambda (start-of-month)
+ (let ((fname (format #f "./html/~a.html" (date->string start-of-month "~1"))))
+ (format (current-error-port) "Writing to [~a]~%" fname)
+ (let* ((before current after (month-days start-of-month (week-start))))
+ (with-output-to-file fname
+ ;; TODO this produces incorrect next and prev links
+ ;; TODO It actually produces almost all date links wrong
+ (lambda () (html-generate calendars events
+ ;; Appends for case where before or after is empty
+ (car (append before current))
+ (last (append current after))
+ render-calendar-table))))))
+ (stream-take count (month-stream start-date))))
diff --git a/static/style.css b/static/style.css
index 2db25af2..11565ff7 100644
--- a/static/style.css
+++ b/static/style.css
@@ -114,6 +114,21 @@ body {
max-width: calc(100% - 20em);
display: flex;
flex-direction: column;
+ flex-grow: 1;
+}
+
+main table {
+ width: 100%;
+ height: 90%; /* TODO */
+ border-collapse: collapse;
+}
+
+main table thead {
+ height: 1em;
+}
+
+main table td {
+ width: calc(100%/7);
}
.calendar {