diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-08-09 23:35:20 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-08-15 19:44:59 +0200 |
commit | ce42ed14891014e8be344fde7e3e25a2b26c150a (patch) | |
tree | 51a664c0d9644c34d0dfa21b9796edd8a8a5b4da /module/calp/server/routes.scm | |
parent | Fix paginator buttons forgetting future clause. (diff) | |
download | calp-ce42ed14891014e8be344fde7e3e25a2b26c150a.tar.gz calp-ce42ed14891014e8be344fde7e3e25a2b26c150a.tar.xz |
Render attachements to HTML frontend.
Diffstat (limited to 'module/calp/server/routes.scm')
-rw-r--r-- | module/calp/server/routes.scm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm index 95488fc9..b024ed4f 100644 --- a/module/calp/server/routes.scm +++ b/module/calp/server/routes.scm @@ -17,6 +17,8 @@ :use-module (sxml xpath) :use-module (sxml namespace) + :use-module ((rnrs io ports) :select (get-bytevector-all)) + :use-module ((xdg basedir) :prefix xdg-) :use-module ((calp html util) :select (html-unattr)) @@ -436,6 +438,25 @@ (sxml->html-string (directory-table (path-append "static" *))))) + ;; This is almost the same as /static/, but with the difference that + ;; we produce these images during runtime + (GET "/tmpfiles/:*{.*}.:ext" (* ext) + ;; Actually parsing /etc/mime.types would be better. + (define mime + (case (string->symbol (string-downcase ext)) + [(png) "png"] + [(jpg jpeg) "jpeg"] + [(gif) "gif"] + [else ext])) + + (return + `((content-type ,(string->symbol (string-append "image/" mime)))) + ;; TODO handle tmp directory globaly + (call-with-input-file (path-append (xdg-runtime-dir) + "calp-data" "images" + (string-append * "." ext)) + get-bytevector-all))) + (GET "/count" () ;; (sleep 1) |