diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-05-03 11:42:01 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-05-03 11:42:01 +0200 |
commit | 802f8a5d482e73785127dd7c560a68972c355c3f (patch) | |
tree | e6c9e2efaf138727bd54b53fa72aeae2103ed01d /module/entry-points | |
parent | Whitespace fixup. (diff) | |
download | calp-802f8a5d482e73785127dd7c560a68972c355c3f.tar.gz calp-802f8a5d482e73785127dd7c560a68972c355c3f.tar.xz |
[today] and [jump to] now works without JS.
Diffstat (limited to '')
-rw-r--r-- | module/entry-points/server.scm | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/module/entry-points/server.scm b/module/entry-points/server.scm index 78eac835..689b220b 100644 --- a/module/entry-points/server.scm +++ b/module/entry-points/server.scm @@ -18,6 +18,7 @@ :use-module (web request) :use-module (web response) :use-module (web uri) + :use-module (web http) :use-module (sxml simple) @@ -99,13 +100,32 @@ intervaltype: 'month )))))) + ;; Get specific page by query string instead of by path. + ;; Useful for <form>'s, since they always submit in this form, but also + ;; useful when javascript is disabled, since a link to "today" needs some + ;; form of evaluation when clicked. + (GET "/today" (view date) + (define location + (parse-header 'location + (format #f "/~a/~a.html" + (or view "month") + (date->string + (cond [date => parse-iso-date] + [else (current-date)]) + "~1"))) ) + + (return (build-response + code: 302 + headers: `((location . ,location))) + "")) + ;; TODO export all events in interval (GET "/calendar" (start end) (return '((content-type text/calendar)) (with-output-to-string (lambda () - (ical-main (parse-iso-date start) - (parse-iso-date end)))))) + (ical-main (parse-iso-date start) + (parse-iso-date end)))))) ;; TODO this fails if there's a period in the uid. (GET "/calendar/:uid{.*}.ics" (uid) @@ -139,9 +159,7 @@ ;; (sleep 1) (return '((content-type text/plain)) (string-append (number->string state) "\n") - (1+ state))) - - )) + (1+ state))))) (define options '((port (value #t) (single-char #\p)) |