aboutsummaryrefslogtreecommitdiff
path: root/module/entry-points/server.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/entry-points/server.scm')
-rw-r--r--module/entry-points/server.scm28
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))