From f1532b4eca797f5aab4ec1a693a767a7a3e603c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 9 Apr 2022 21:58:52 +0200 Subject: 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'). --- module/calp/html/config.scm | 9 ++------- module/calp/html/filter.scm | 9 +++++++++ module/calp/html/vcomponent.scm | 13 ++++--------- module/calp/html/view/calendar.scm | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) create mode 100644 module/calp/html/filter.scm (limited to 'module/calp/html') 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 { -- cgit v1.2.3