aboutsummaryrefslogtreecommitdiff
path: root/module/html/util.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/html/util.scm')
-rw-r--r--module/html/util.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/module/html/util.scm b/module/html/util.scm
new file mode 100644
index 00000000..36b1d929
--- /dev/null
+++ b/module/html/util.scm
@@ -0,0 +1,20 @@
+(define-module (html util)
+ :use-module (util))
+
+;; Retuns an HTML-safe version of @var{str}.
+(define-public (html-attr str)
+ (define cs (char-set-adjoin char-set:letter+digit #\- #\_))
+ (string-filter (lambda (c) (char-set-contains? cs c)) str))
+
+(define-public (date-link date)
+ ((@ (datetime) date->string) date "~Y-~m-~d"))
+
+
+
+;; Generate an html id for an event.
+;; TODO? same event placed multiple times, when spanning multiple cells
+(define-public html-id
+ (let ((id (make-object-property)))
+ (lambda (ev)
+ (or (id ev)
+ (set/r! (id ev) (symbol->string (gensym "__html_id_")))))))