aboutsummaryrefslogtreecommitdiff
path: root/module/calp
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-06-23 03:23:44 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-06-23 03:48:22 +0200
commit1976980d4a272fb7fc3694c734bfc6825edfc721 (patch)
tree8460db1176c64895e9968447588953fac85fe7d6 /module/calp
parentRemove all inline use-modules. (diff)
downloadcalp-1976980d4a272fb7fc3694c734bfc6825edfc721.tar.gz
calp-1976980d4a272fb7fc3694c734bfc6825edfc721.tar.xz
Centralize (almost) all exports to :export in define-module.
Diffstat (limited to 'module/calp')
-rw-r--r--module/calp/benchmark/parse.scm4
-rw-r--r--module/calp/entry-points/server.scm2
-rw-r--r--module/calp/html/caltable.scm4
-rw-r--r--module/calp/html/components.scm32
-rw-r--r--module/calp/html/util.scm9
-rw-r--r--module/calp/html/vcomponent.scm42
-rw-r--r--module/calp/html/view/calendar.scm32
-rw-r--r--module/calp/html/view/calendar/month.scm3
-rw-r--r--module/calp/html/view/calendar/shared.scm12
-rw-r--r--module/calp/html/view/calendar/week.scm3
-rw-r--r--module/calp/html/view/search.scm5
-rw-r--r--module/calp/html/view/small-calendar.scm3
-rw-r--r--module/calp/main.scm3
-rw-r--r--module/calp/repl.scm3
-rw-r--r--module/calp/server/routes.scm3
-rw-r--r--module/calp/server/server.scm7
-rw-r--r--module/calp/terminal.scm2
17 files changed, 103 insertions, 66 deletions
diff --git a/module/calp/benchmark/parse.scm b/module/calp/benchmark/parse.scm
index 1391d18a..2ba8a7de 100644
--- a/module/calp/benchmark/parse.scm
+++ b/module/calp/benchmark/parse.scm
@@ -3,13 +3,15 @@
:use-module ((hnh util path) :select (path-append))
:use-module (glob)
:use-module (statprof)
+ :use-module (datetime)
:use-module ((srfi srfi-1) :select (concatenate))
:use-module ((ice-9 ftw) :select (scandir))
+ :export (run-benchmark)
)
-(define-public (run-benchmark)
+(define (run-benchmark)
(define all-calendar-files
(statprof
(lambda ()
diff --git a/module/calp/entry-points/server.scm b/module/calp/entry-points/server.scm
index 26c2bee7..d357015d 100644
--- a/module/calp/entry-points/server.scm
+++ b/module/calp/entry-points/server.scm
@@ -34,7 +34,7 @@ and <i>[::]</i> for IPv6</group>"))))
(define-config port 8080
description: (_ "Port to which the web server should bind."))
-(define-public (main args)
+(define (main args)
(define opts (getopt-long args (getopt-opt options)))
(define addr (option-ref opts 'addr #f))
diff --git a/module/calp/html/caltable.scm b/module/calp/html/caltable.scm
index c8a225a1..efaf8871 100644
--- a/module/calp/html/caltable.scm
+++ b/module/calp/html/caltable.scm
@@ -6,6 +6,8 @@
:use-module (srfi srfi-41)
:use-module (calp translation)
+
+ :export (cal-table)
)
;; Small calendar similar to the one below.
@@ -30,7 +32,7 @@
;; prev-start and next-start will generate links for the next interval,
;; they can't be infered from start and end date, mostly due to months having
;; different lengths
-(define*-public (cal-table key: start-date end-date next-start prev-start)
+(define* (cal-table key: start-date end-date next-start prev-start)
(define (->link date)
(date->string date "~Y-~m-~d.html"))
diff --git a/module/calp/html/components.scm b/module/calp/html/components.scm
index a36dbef9..2b7f58bd 100644
--- a/module/calp/html/components.scm
+++ b/module/calp/html/components.scm
@@ -3,8 +3,14 @@
:use-module (ice-9 curried-definitions)
:use-module (ice-9 match)
:use-module (calp translation)
- :export (xhtml-doc)
- )
+ :export (xhtml-doc
+ slider-input
+ btn
+ tabset
+ include-css
+ include-alt-css
+ input-plus-minus
+ ))
;; Wraps a number of sxml forms into a valid sxhtml-tree.
(define-syntax xhtml-doc
@@ -20,12 +26,12 @@
;; Add a slider with an associated number input. Keeps the two in sync.
-(define*-public (slider-input key: variable
- (min 0)
- (max 10)
- (step 1)
- (value 1)
- (unit ""))
+(define* (slider-input key: variable
+ (min 0)
+ (max 10)
+ (step 1)
+ (value 1)
+ (unit ""))
`(slider-input
(@ (min ,min)
@@ -37,7 +43,7 @@
variable unit)))))
;; Generates a button or button-like link.
-(define*-public (btn key: onclick href (class '())
+(define* (btn key: onclick href (class '())
allow-other-keys:
rest: args)
(when (and onclick href)
@@ -80,7 +86,7 @@
;; @end example
;; Creates a tab with an calendar emoji as icon, "Översikt" is sent as the
;; extra argument #:title, and the body is the return from fmt-single-event.
-(define-public (tabset elements)
+(define (tabset elements)
(define tabgroup (symbol->string (gensym "tabgroup")))
`(div (@ (class "tabgroup"))
@@ -110,21 +116,21 @@
,@inner-body)]))
-(define-public (include-css path . extra-attributes)
+(define (include-css path . extra-attributes)
`(link (@ (type "text/css")
(rel "stylesheet")
(href ,path)
,@extra-attributes)))
-(define-public (include-alt-css path . extra-attributes)
+(define (include-alt-css path . extra-attributes)
`(link (@ (type "text/css")
(rel "alternate stylesheet")
(href ,path)
,@extra-attributes)))
-(define-public (input-plus-minus positive?)
+(define (input-plus-minus positive?)
(define id (gensym "id"))
`(span (@ (class "input-timespan"))
(input (@ (type "checkbox")
diff --git a/module/calp/html/util.scm b/module/calp/html/util.scm
index affaf5d2..948cadb7 100644
--- a/module/calp/html/util.scm
+++ b/module/calp/html/util.scm
@@ -1,15 +1,16 @@
(define-module (calp html util)
:use-module (hnh util)
- :use-module (calp translation))
+ :use-module (calp translation)
+ :export (date-link html-id calculate-fg-color))
-(define-public (date-link date)
+(define (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
+(define html-id
(let ((id (make-object-property)))
(lambda (ev)
(or (id ev)
@@ -17,7 +18,7 @@
;; Returns a color with good contrast to the given background color.
;; https://stackoverflow.com/questions/1855884/determine-font-color-based-on-background-color/1855903#1855903
-(define-public (calculate-fg-color c)
+(define (calculate-fg-color c)
;; TODO what errors can actually appear here?
(catch #t
(lambda ()
diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm
index 1cee47a5..287c62e1 100644
--- a/module/calp/html/vcomponent.scm
+++ b/module/calp/html/vcomponent.scm
@@ -25,7 +25,19 @@
:use-module (ice-9 format)
:use-module (calp translation)
:use-module (calp html filter)
- )
+ :export (format-summary
+ format-description
+ compact-event-list
+ fmt-single-event
+ fmt-day
+ calendar-styles
+ make-block
+ output-uid
+ edit-template
+ description-template
+ vevent-edit-rrule-template
+ popup-template
+ ))
(define (xml-entities s)
@@ -34,12 +46,12 @@
(map (lambda (c) (format #f "&#x~x;" (char->integer c)))
(string->list s)))))
-(define-public (format-summary ev str)
+(define (format-summary 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)
+(define (format-description ev str)
(catch* (lambda () ((description-filter) ev str))
(configuration-error
(lambda (key subr msg args data)
@@ -61,7 +73,7 @@
))
;; used by search view
-(define-public (compact-event-list list)
+(define (compact-event-list list)
(define calendars
(delete-duplicates!
@@ -101,9 +113,9 @@
;; Note that the <vevent-description/> tag is bound as a JS custem element, which
;; will re-render all this, through description-template. This also means that
;; the procedures output is intended to be static, and to NOT be changed by JavaScript.
-(define*-public (fmt-single-event ev
- optional: (attributes '())
- key: (fmt-header list))
+(define* (fmt-single-event ev
+ optional: (attributes '())
+ key: (fmt-header list))
;; (format (current-error-port) "fmt-single-event: ~a~%" (prop ev 'X-HNH-FILENAME))
`(vevent-description
(@ ,@(assq-merge
@@ -242,7 +254,7 @@
;; Single event in side bar (text objects)
-(define-public (fmt-day day)
+(define (fmt-day day)
(let ((date (car day))
(events (cdr day)))
`(section (@ (class "text-day"))
@@ -272,7 +284,7 @@
;; Specific styles for each calendar.
-(define*-public (calendar-styles calendars optional: (port #f))
+(define* (calendar-styles calendars optional: (port #f))
(format port "~:{ [data-calendar=\"~a\"] { --color: ~a; --complement: ~a }~%~}"
(map (lambda (c)
(let ((name (base64encode (prop c 'NAME)))
@@ -283,7 +295,7 @@
calendars)))
;; "Physical" block in calendar view
-(define*-public (make-block ev optional: (extra-attributes '()))
+(define* (make-block ev optional: (extra-attributes '()))
;; surrounding <a /> element which allows something to happen when an element
;; is clicked with JS turned off. Our JS disables this, and handles clicks itself.
@@ -355,7 +367,7 @@
;; Return a unique identifier for a specific instance of an event.
;; Allows us to reference each instance of a repeating event separately
;; from any other
-(define-public (output-uid event)
+(define (output-uid event)
(string-concatenate
(cons
(prop event 'UID)
@@ -393,7 +405,7 @@
;; edit tab of popup
-(define-public (edit-template calendars)
+(define (edit-template calendars)
`(template
(@ (id "vevent-edit"))
(div (@ (class " eventtext edit-tab "))
@@ -481,7 +493,7 @@
;; description in sidebar / tab of popup
;; Template data for <vevent-description />
-(define-public (description-template)
+(define (description-template)
`(template
(@ (id "vevent-description"))
(div (@ (class " vevent eventtext summary-tab " ()))
@@ -532,7 +544,7 @@
; "2021-09-29 19:56"
))))))
-(define-public (vevent-edit-rrule-template)
+(define (vevent-edit-rrule-template)
`(template
(@ (id "vevent-edit-rrule"))
(div (@ (class "eventtext"))
@@ -588,7 +600,7 @@
;; Based on popup:s output
-(define-public (popup-template)
+(define (popup-template)
`(template
(@ (id "popup-template"))
;; becomes the direct child of <popup-element/>
diff --git a/module/calp/html/view/calendar.scm b/module/calp/html/view/calendar.scm
index 8b7d8075..9378737f 100644
--- a/module/calp/html/view/calendar.scm
+++ b/module/calp/html/view/calendar.scm
@@ -31,6 +31,8 @@
:use-module (ice-9 format)
:use-module (calp translation)
+
+ :export (html-generate)
)
@@ -49,21 +51,21 @@
;; TODO document what @var{render-calendar} is supposed to take and return.
;; Can at least note that @var{render-calendar} is strongly encouraged to include
;; (script "const VIEW='??';"), where ?? is replaced by the name of the view.
-(define*-public (html-generate
- key:
- (intervaltype 'all) ; 'week | 'month | 'all
- calendars ; All calendars to work on, probably (get-calendars global-event-object)
- events ; All events which can be worked on, probably (get-event-set global-event-object)
- start-date ; First date in interval to show
- end-date ; Last date in interval to show
- render-calendar ; (bunch of kv args) → (list sxml)
- next-start ; date → date
- prev-start ; date → date
- ;; The pre and post dates are if we want to show some dates just
- ;; outside our actuall interval. Primarily for whole month views,
- ;; which needs a bit on each side.
- (pre-start start-date)
- (post-end end-date))
+(define* (html-generate
+ key:
+ (intervaltype 'all) ; 'week | 'month | 'all
+ calendars ; All calendars to work on, probably (get-calendars global-event-object)
+ events ; All events which can be worked on, probably (get-event-set global-event-object)
+ start-date ; First date in interval to show
+ end-date ; Last date in interval to show
+ render-calendar ; (bunch of kv args) → (list sxml)
+ next-start ; date → date
+ prev-start ; date → date
+ ;; The pre and post dates are if we want to show some dates just
+ ;; outside our actuall interval. Primarily for whole month views,
+ ;; which needs a bit on each side.
+ (pre-start start-date)
+ (post-end end-date))
;; NOTE maybe don't do this again for every month
(define evs (get-groups-between (group-stream events)
diff --git a/module/calp/html/view/calendar/month.scm b/module/calp/html/view/calendar/month.scm
index 1c162aaa..a19fcdb5 100644
--- a/module/calp/html/view/calendar/month.scm
+++ b/module/calp/html/view/calendar/month.scm
@@ -15,10 +15,11 @@
:select (make-block output-uid))
:use-module ((vcomponent util group)
:select (group-stream get-groups-between))
+ :export (render-calendar-table)
)
;; (stream event-group) -> sxml
-(define*-public (render-calendar-table key: events start-date end-date pre-start post-end #:allow-other-keys)
+(define* (render-calendar-table key: events start-date end-date pre-start post-end #:allow-other-keys)
(define-values (long-events short-events)
;; TODO should be really-long-event? or event-spanning-midnight
diff --git a/module/calp/html/view/calendar/shared.scm b/module/calp/html/view/calendar/shared.scm
index 108f3b9a..41d96171 100644
--- a/module/calp/html/view/calendar/shared.scm
+++ b/module/calp/html/view/calendar/shared.scm
@@ -15,7 +15,11 @@
:select (make-block format-summary))
:use-module (ice-9 format)
:use-module (calp translation)
- )
+
+ :export (fix-event-widths!
+ lay-out-long-events
+ create-top-block
+ ))
@@ -25,7 +29,7 @@
;; Takes a list of vcomponents, sets their widths and x-positions to optimally
;; fill out the space, without any overlaps.
-(define*-public (fix-event-widths! lst key: event-length-key (event-length-comperator date/-time>?))
+(define* (fix-event-widths! lst key: event-length-key (event-length-comperator date/-time>?))
;; The tree construction is greedy. This means
;; that if a smaller event preceeds a longer
;; event it would capture the longer event to
@@ -51,7 +55,7 @@
(inner x (right-subtree tree))))))
-(define-public (lay-out-long-events start end events)
+(define (lay-out-long-events start end events)
(fix-event-widths! events event-length-key: event-length
event-length-comperator: date/-time>)
(map (lambda (e) (create-top-block start end e))
@@ -61,7 +65,7 @@
;; get hours. This means that a day is always assumed to be 24h, even when that's
;; wrong. This might lead to some weirdness when the timezon switches (DST), but it
;; makes everything else behave MUCH better.
-(define-public (create-top-block start-date end-date ev)
+(define (create-top-block start-date end-date ev)
(define total-length
(* 24 (days-in-interval start-date end-date)))
diff --git a/module/calp/html/view/calendar/week.scm b/module/calp/html/view/calendar/week.scm
index 78abcfbf..828dce41 100644
--- a/module/calp/html/view/calendar/week.scm
+++ b/module/calp/html/view/calendar/week.scm
@@ -22,10 +22,11 @@
:use-module ((vcomponent util group)
:select (group-stream get-groups-between))
:use-module (ice-9 format)
+ :export (render-calendar)
)
-(define*-public (render-calendar key: calendars events start-date end-date #:allow-other-keys)
+(define* (render-calendar key: calendars events start-date end-date #:allow-other-keys)
(let* ((long-events short-events (partition long-event? (stream->list (events-between start-date end-date events))))
(range (date-range start-date end-date)))
`((script ,(lambda () (format #t "window.VIEW='week';")))
diff --git a/module/calp/html/view/search.scm b/module/calp/html/view/search.scm
index 08436bc5..114541ed 100644
--- a/module/calp/html/view/search.scm
+++ b/module/calp/html/view/search.scm
@@ -9,6 +9,7 @@
:use-module ((calp html vcomponent)
:select (compact-event-list))
:use-module (calp translation)
+ :export (search-result-page)
)
;; Display the result of a search term, but doesn't do any searching
@@ -21,8 +22,8 @@
;; @var{search-result} : The list of matched events
;; @var{page} : Which page we are on
;; @var{paginator} : A paginator object
-(define-public (search-result-page
- errors has-query? search-term search-result page paginator)
+(define (search-result-page
+ errors has-query? search-term search-result page paginator)
(xhtml-doc
(@ (lang sv))
(head (title ,(_ "Search results"))
diff --git a/module/calp/html/view/small-calendar.scm b/module/calp/html/view/small-calendar.scm
index 80cbbaf2..4d40c57c 100644
--- a/module/calp/html/view/small-calendar.scm
+++ b/module/calp/html/view/small-calendar.scm
@@ -2,9 +2,10 @@
:use-module ((calp html components) :select (xhtml-doc include-css))
:use-module ((calp html caltable) :select (cal-table))
:use-module ((datetime) :select (month- month+ remove-day date->string))
+ :export (render-small-calendar)
)
-(define-public (render-small-calendar month standalone)
+(define (render-small-calendar month standalone)
(define table (cal-table
start-date: month
end-date: (remove-day (month+ month))
diff --git a/module/calp/main.scm b/module/calp/main.scm
index 7f2a4679..d97d3d76 100644
--- a/module/calp/main.scm
+++ b/module/calp/main.scm
@@ -29,6 +29,7 @@
:use-module (calp translation)
+ :export (main)
)
@@ -207,7 +208,7 @@ zoneinfo database, but is currently broken.</p>")
-(define-public (main args)
+(define (main args)
((@ (calp util time) report-time!) (_ "Program start"))
(with-throw-handler #t
(lambda ()
diff --git a/module/calp/repl.scm b/module/calp/repl.scm
index 6f2c7c0a..7beee560 100644
--- a/module/calp/repl.scm
+++ b/module/calp/repl.scm
@@ -8,9 +8,10 @@
:use-module ((calp util hooks) :select (shutdown-hook))
:use-module ((hnh util exceptions) :select (warning))
:use-module (calp translation)
+ :export (repl-start)
)
-(define-public (repl-start address)
+(define (repl-start address)
(define lst (string->list address))
(format (current-error-port)
(_ "Starting REPL server at ~a~%") address)
diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm
index 3d90cc04..74836a42 100644
--- a/module/calp/server/routes.scm
+++ b/module/calp/server/routes.scm
@@ -40,6 +40,7 @@
:use-module ((calp html components) :select (xhtml-doc include-css))
+ :export (make-make-routes)
)
@@ -128,7 +129,7 @@
;; TODO ensure encoding on all fields which take user provided data.
;; Possibly a fallback which strips everything unknown, and treats
;; the bytevector as ascii.
-(define-public (make-make-routes)
+(define (make-make-routes)
(make-routes
;; Manual redirect to not reserve root.
diff --git a/module/calp/server/server.scm b/module/calp/server/server.scm
index b9d5c6d3..814aaed7 100644
--- a/module/calp/server/server.scm
+++ b/module/calp/server/server.scm
@@ -1,9 +1,10 @@
(define-module (calp server server)
-
:use-module (hnh util)
:use-module (web server)
:use-module ((calp server routes) :select (make-make-routes))
- :use-module (ice-9 threads))
+ :use-module (ice-9 threads)
+
+ :export (start-server))
;; NOTE The default make-default-socket is broken for IPv6.
;; A patch has been submitted to the mailing list. 2020-03-31
@@ -22,7 +23,7 @@
;; (define server (open-server impl open-params))
-(define-public (start-server open-params)
+(define (start-server open-params)
(run-server handler 'http open-params 1)
;; NOTE at first this seems to work, but it quickly deteriorates.
;; (for i in (iota 16)
diff --git a/module/calp/terminal.scm b/module/calp/terminal.scm
index 7cf354d8..e74c5fb8 100644
--- a/module/calp/terminal.scm
+++ b/module/calp/terminal.scm
@@ -322,7 +322,7 @@
(current-page this))))
(else (next-method))))
-(define-public (main-loop date)
+(define (main-loop date)
(define state (list (day-view (get-event-set global-event-object) date)))
(while #t