aboutsummaryrefslogtreecommitdiff
path: root/module/calp/server/routes.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-04-07 22:12:29 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-04-07 22:12:29 +0200
commite377df7b305514d721510fe1f15921647ebc7552 (patch)
tree35dd17aaf5e29c44c0f13401b6cb86e4d7df5acd /module/calp/server/routes.scm
parentRename filename-extension{ => ?}. (diff)
parentFix translation for (vcomponent datetime output). (diff)
downloadcalp-e377df7b305514d721510fe1f15921647ebc7552.tar.gz
calp-e377df7b305514d721510fe1f15921647ebc7552.tar.xz
Merge branch 'translation'
Diffstat (limited to 'module/calp/server/routes.scm')
-rw-r--r--module/calp/server/routes.scm40
1 files changed, 26 insertions, 14 deletions
diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm
index 88f641fb..d05451eb 100644
--- a/module/calp/server/routes.scm
+++ b/module/calp/server/routes.scm
@@ -33,7 +33,11 @@
:use-module (calp util config)
:use-module (calp html view calendar)
- :use-module ((calp html view search) :select (search-result-page)))
+ :use-module ((calp html view search) :select (search-result-page))
+
+ :use-module (calp translation)
+
+ )
@@ -49,8 +53,13 @@
;; start with /static.
(define (directory-table prefix dir)
`(table (@ (class "directory-table"))
- (thead
- (tr (th "") (th "Name") (th "Perm") (th "Size")))
+ (thead
+ (tr (th "")
+ (th ,(_ "Name"))
+ ;; File permissions, should be about as long as three digits
+ (th ,(_ "Perm"))
+ ;; File size
+ (th ,(_ "Size"))))
(tbody
(tr (td "↩️") (td (@ (colspan 3))
(a (@ (href ,(-> (path-split dir)
@@ -80,7 +89,7 @@
(scm-error
'misc-error
"directory-table"
- "Scandir argument invalid or not directory: ~s"
+ (_ "Scandir argument invalid or not directory: ~s")
(list dir) '())))))))
@@ -122,7 +131,7 @@
(GET "/" ()
(return '((content-type text/html))
(sxml->html-string
- '(body (a (@ (href "/today")) "Gå till idag")
+ '(body (a (@ (href "/today")) ,(_ "Go to Today"))
(script "window.onload = function() {
document.getElementsByTagName('a')[0].click();}")))))
@@ -175,7 +184,7 @@
(POST "/remove" (uid)
(unless uid
(return (build-response code: 400)
- "uid required"))
+ (_ "uid required")))
(aif (get-event-by-uid global-event-object uid)
(begin
@@ -187,10 +196,10 @@
(set! (param (prop* it 'X-HNH-REMOVED) 'VALUE) "BOOLEAN")
(unless ((@ (vcomponent formats vdir save-delete) save-event) it)
(return (build-response code: 500)
- "Saving event to disk failed."))
+ (_ "Saving event to disk failed.")))
(return (build-response code: 204)))
(return (build-response code: 400)
- (format #f "No event with UID '~a'" uid))))
+ (format #f (_ "No event with UID '~a'") uid))))
;; TODO this fails when dtstart is <date>.
;; @var{cal} should be the name of the calendar encoded in base64.
@@ -198,7 +207,7 @@
(unless (and cal data)
(return (build-response code: 400)
- "Both 'cal' and 'data' required\r\n"))
+ (string-append (_ "Both 'cal' and 'data' required") "\r\n")))
;; NOTE that this leaks which calendar exists,
@@ -211,7 +220,8 @@
(unless calendar
(return (build-response code: 400)
- (format #f "No calendar with name [~a]\r\n" calendar-name)))
+ (format #f "~@?\r\n" (_ "No calendar with name [~a]")
+ calendar-name)))
;; Expected form of data (but in XML) is:
;; @example
@@ -240,11 +250,13 @@
#f))
(lambda (err port . args)
(return (build-response code: 400)
- (format #f "XML parse error ~{~a~}\r\n" args)))))))
+ (format #f "~a ~{~a~}\r\n"
+ (_ "XML parse error")
+ args)))))))
(unless (eq? 'VEVENT (type event))
(return (build-response code: 400)
- "Object not a VEVENT\r\n"))
+ (string-append (_ "Object not a VEVENT") "\r\n")))
;; NOTE add-event uses the given UID if one is given,
;; but generates its own if not. It might be a good idea
@@ -320,7 +332,7 @@
;; and "program parent" into different fields.
(lambda () (sxml->xml ((@ (vcomponent formats xcal output) vcomponent->sxcal) it)))))
(return (build-response code: 404)
- (format #f "No component with UID=~a found." uid))))
+ (format #f (_ "No component with UID=~a found.") uid))))
(GET "/calendar/:uid{.*}.ics" (uid)
(aif (get-event-by-uid global-event-object uid)
@@ -329,7 +341,7 @@
(lambda () (print-components-with-fake-parent
(list it)))))
(return (build-response code: 404)
- (format #f "No component with UID=~a found." uid))))
+ (format #f (_ "No component with UID=~a found.") uid))))
(GET "/search/text" (q)
(return (build-response