aboutsummaryrefslogtreecommitdiff
path: root/web/webserver.scm
diff options
context:
space:
mode:
authorPjotr Prins2023-09-12 10:02:34 -0500
committerPjotr Prins2023-09-12 10:02:34 -0500
commita3aa5b9ea09d71cb86884176bf5bb89270aef5a3 (patch)
tree713ac78ea4feee3f5ae64eb88cbe49fd1e43d9c4 /web/webserver.scm
parentacaea1fb7d6544a98867a16b283085592a042b9f (diff)
downloadgn-guile-a3aa5b9ea09d71cb86884176bf5bb89270aef5a3.tar.gz
pico.css works
Diffstat (limited to 'web/webserver.scm')
-rwxr-xr-xweb/webserver.scm32
1 files changed, 19 insertions, 13 deletions
diff --git a/web/webserver.scm b/web/webserver.scm
index fe4596b..05e842c 100755
--- a/web/webserver.scm
+++ b/web/webserver.scm
@@ -76,14 +76,15 @@ otherwise search for set/group data"
(define file-mime-types
- '(("css" . (text/css))
- ("js" . (text/javascript))
- ("svg" . (image/svg+xml))
- ("png" . (image/png))
- ("gif" . (image/gif))
- ("jpg" . (image/jpg))
+ '(("css" . (text/css))
+ ("js" . (text/javascript))
+ ("svg" . (image/svg+xml))
+ ("png" . (image/png))
+ ("gif" . (image/gif))
+ ("jpg" . (image/jpg))
("woff" . (application/font-woff))
("ttf" . (application/octet-stream))
+ ("map" . (text/json))
("html" . (text/html))))
(define (file-extension file-name)
@@ -98,11 +99,14 @@ otherwise search for set/group data"
(last-modified . ,(time-utc->date modified)))
(call-with-input-file file-name get-bytevector-all))))
-(define* (render-file path page #:optional rec #:key (extra-headers '()))
- (list (append extra-headers
- '((content-type . (text/html))))
- (lambda (port)
- (sxml->html (view-doc path page rec) port))))
+(define* (render-static-file path #:optional rec #:key (extra-headers '()))
+ (let* ((stat (stat path #f))
+ (modified (and stat
+ (make-time time-utc 0 (stat:mtime stat)))))
+ (list `((content-type . ,(assoc-ref file-mime-types
+ (file-extension path)))
+ (last-modified . ,(time-utc->date modified)))
+ (call-with-input-file path get-bytevector-all))))
(define* (render-doc path page #:optional rec #:key (extra-headers '()))
(list (append extra-headers
@@ -132,8 +136,10 @@ otherwise search for set/group data"
(render-json info))
(('GET "version")
(render-json get-version))
- (('GET "css" fn)
- (render-file fn))
+ (('GET "css" fn )
+ (render-static-file (string-append "css/" fn)))
+ (('GET "map" fn )
+ (render-static-file (string-append "css/" fn)))
(('GET "static" "images" fn)
(render-static-image (string-append "static/images/" fn)))
(('GET "home" path)