aboutsummaryrefslogtreecommitdiff
path: root/module/calp/html
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-04-09 21:58:52 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-04-11 19:08:40 +0200
commitf1532b4eca797f5aab4ec1a693a767a7a3e603c9 (patch)
treecd6f0fab78e36a67451aceac5e042e45d061e5f1 /module/calp/html
parentFix loop in import entry-point. (diff)
downloadcalp-f1532b4eca797f5aab4ec1a693a767a7a3e603c9.tar.gz
calp-f1532b4eca797f5aab4ec1a693a767a7a3e603c9.tar.xz
Replace config system with paramater based system.
This new setup stores all configurations are parameters. This forces everything into modules, and ensures that we can't have a module use an unloaded config. It (unfortunatelly) also causes users to have to specify namespaces when defining values, but ini-files (and the like) already does that. Also, there is nothing stopping a new `set-config!' from being defined which allows un-namespaced operation. The commit also removes the introspection procedures. They where a bit weird to begin with, since they only showed loaded fields. And since the program had no way of properly serializing or deserializing them we remove them for the time being. They would however be good to reintroduce together with a proper menu for editing simple configuration (see Emacs' `custom-set-variables').
Diffstat (limited to 'module/calp/html')
-rw-r--r--module/calp/html/config.scm9
-rw-r--r--module/calp/html/filter.scm9
-rw-r--r--module/calp/html/vcomponent.scm13
-rw-r--r--module/calp/html/view/calendar.scm2
4 files changed, 16 insertions, 17 deletions
diff --git a/module/calp/html/config.scm b/module/calp/html/config.scm
index 08a4b2e8..c5a4e4c0 100644
--- a/module/calp/html/config.scm
+++ b/module/calp/html/config.scm
@@ -4,16 +4,11 @@
:use-module (calp translation)
)
-(define-public debug (make-parameter #f))
(define-config debug #f
- description: (_ "Places the generated thingy in debug mode")
- post: debug)
+ description: (_ "Places the generated thingy in debug mode"))
;;; NOTE edit mode should preferably depend on login-status of the user
;;; but this works for the time being.
-(define-public edit-mode (make-parameter #t))
(define-config edit-mode #t
- description: (_ "Makes the document editable")
- post: edit-mode)
-
+ description: (_ "Makes the document editable"))
diff --git a/module/calp/html/filter.scm b/module/calp/html/filter.scm
new file mode 100644
index 00000000..a3ef6209
--- /dev/null
+++ b/module/calp/html/filter.scm
@@ -0,0 +1,9 @@
+(define-module (calp html filter)
+ :use-module (calp util config)
+ )
+
+(define-config summary-filter (lambda (_ a) a)
+ pre: (ensure procedure?))
+
+(define-config description-filter (lambda (_ a) a)
+ pre: (ensure procedure?))
diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm
index 16189dff..91db44e6 100644
--- a/module/calp/html/vcomponent.scm
+++ b/module/calp/html/vcomponent.scm
@@ -25,22 +25,17 @@
:use-module ((base64) :select (base64encode))
:use-module (ice-9 format)
:use-module (calp translation)
+ :use-module (calp html filter)
)
-(define-config summary-filter (lambda (_ a) a)
- pre: (ensure procedure?))
-
-(define-config description-filter (lambda (_ a) a)
- pre: (ensure procedure?))
-
(define-public (format-summary ev str)
- ((get-config 'summary-filter) ev str))
+ ((summary-filter) ev str))
;; NOTE this should have information about context (html/term/...)
;; And then be moved somewhere else.
(define-public (format-description ev str)
- (catch* (lambda () ((get-config 'description-filter) ev str))
+ (catch* (lambda () ((description-filter) ev str))
(configuration-error
(lambda (key subr msg args data)
(format (current-error-port)
@@ -396,7 +391,7 @@
(select (@ (class "calendar-selection"))
;; NOTE flytta "muffarna" utanför
(option ,(_ "- Choose a Calendar -"))
- ,@(let ((dflt (get-config 'default-calendar)))
+ ,@(let ((dflt ((@ (vcomponent) default-calendar))))
(map (lambda (calendar)
(define name (prop calendar 'NAME))
`(option (@ (value ,(base64encode name))
diff --git a/module/calp/html/view/calendar.scm b/module/calp/html/view/calendar.scm
index d4ad2977..aef33f36 100644
--- a/module/calp/html/view/calendar.scm
+++ b/module/calp/html/view/calendar.scm
@@ -107,7 +107,7 @@
EDIT_MODE=~:[false~;true~];
window.default_calendar='~a';"
(edit-mode)
- (base64encode (get-config 'default-calendar))))
+ (base64encode ((@ (vcomponent) default-calendar)))))
(style ,(format #f "html {