aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-23 17:11:21 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-23 17:11:21 +0200
commit27f25ae1749f28d59edb925c3989efbeb83fcc41 (patch)
tree4565cee869c0f192b6d1fd485633ad625f6d810b
parentRepair tests. (diff)
downloadcalp-27f25ae1749f28d59edb925c3989efbeb83fcc41.tar.gz
calp-27f25ae1749f28d59edb925c3989efbeb83fcc41.tar.xz
Add rendering of standalone small-cal.
-rw-r--r--module/calp/entry-points/html.scm19
-rw-r--r--module/html/view/small-calendar.scm19
-rw-r--r--static/.gitignore2
-rw-r--r--static/Makefile2
-rw-r--r--static/_global.scss4
-rw-r--r--static/smallcal.scss2
-rw-r--r--static/style.scss3
7 files changed, 46 insertions, 5 deletions
diff --git a/module/calp/entry-points/html.scm b/module/calp/entry-points/html.scm
index 4f672109..abaa5f13 100644
--- a/module/calp/entry-points/html.scm
+++ b/module/calp/entry-points/html.scm
@@ -41,7 +41,7 @@
(description "Directory where html files should end up. Default to " (b "./html")))
(style (value #t) (predicate ,(lambda (v) (memv (string->symbol v)
- '(wide week table))))
+ '(small wide week table))))
(description "How the body of the HTML page should be layed out. "
(br) (b "week")
" gives a horizontally scrolling page with 7 elements, "
@@ -54,6 +54,11 @@
" is the same as week, but gives a full month.")
)
+ (standalone
+ (description "Creates a standalone document instead of an HTML fragment "
+ "for embedding in a larger page. Currently only applies to the "
+ (i "small") "style"))
+
(help (single-char #\h) (description "Print this help."))))
@@ -121,6 +126,8 @@
(define target-directory (option-ref opts 'target "./html"))
+ (define standalone (option-ref opts 'standalone #f))
+
(when (option-ref opts 'help #f)
(print-arg-help opt-spec)
(throw 'return)
@@ -130,6 +137,16 @@
;; while we save the documents as .xml.
(case style
+
+ [(small)
+ (let ((fname (path-append target-directory (date->string start "small-~1.xml"))))
+ (with-output-to-file fname
+ (lambda ()
+ (sxml->xml
+ (re-root-static
+ ((@ (html view small-calendar) render-small-calendar)
+ start standalone))))))]
+
[(wide)
(common target-directory count start (date month: 1) render-calendar-wide)]
diff --git a/module/html/view/small-calendar.scm b/module/html/view/small-calendar.scm
new file mode 100644
index 00000000..e6378176
--- /dev/null
+++ b/module/html/view/small-calendar.scm
@@ -0,0 +1,19 @@
+(define-module (html view small-calendar)
+ :use-module ((html components) :select (xhtml-doc include-css))
+ :use-module ((html caltable) :select (cal-table))
+ :use-module ((datetime) :select (month- month+ remove-day date->string))
+ )
+
+(define-public (render-small-calendar month standalone)
+ (define table (cal-table
+ start-date: month
+ end-date: (remove-day (month+ month))
+ next-start: month+
+ prev-start: month-
+ ))
+ (if standalone
+ (xhtml-doc
+ (head (title ,(date->string month "~1"))
+ ,(include-css "/static/smallcal.css"))
+ (body ,table))
+ table))
diff --git a/static/.gitignore b/static/.gitignore
index c90a6b1b..735b5dce 100644
--- a/static/.gitignore
+++ b/static/.gitignore
@@ -1,3 +1,3 @@
-style.css
+*.css
.*-cache
*.map
diff --git a/static/Makefile b/static/Makefile
index a5c42396..12df8c2a 100644
--- a/static/Makefile
+++ b/static/Makefile
@@ -1,6 +1,6 @@
.PHONY: all clean
-TARGETS := style.css
+TARGETS := style.css smallcal.css
all: $(TARGETS)
diff --git a/static/_global.scss b/static/_global.scss
new file mode 100644
index 00000000..bb8f4bf5
--- /dev/null
+++ b/static/_global.scss
@@ -0,0 +1,4 @@
+$gray: #757575;
+$btn-height: 0.5ex;
+
+
diff --git a/static/smallcal.scss b/static/smallcal.scss
new file mode 100644
index 00000000..c9a356c4
--- /dev/null
+++ b/static/smallcal.scss
@@ -0,0 +1,2 @@
+@import 'global';
+@import 'small-calendar';
diff --git a/static/style.scss b/static/style.scss
index 1d47691a..3f92f8fc 100644
--- a/static/style.scss
+++ b/static/style.scss
@@ -1,5 +1,4 @@
-$gray: #757575;
-$btn-height: 0.5ex;
+@import 'global';
html, body {
height: 100%;