From f279ff3c0a93204a629e707fe54b0ee08921c579 Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Sun, 24 May 2020 00:12:51 +0200 Subject: [PATCH] Better name. --- gratchy.scm => rags.scm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) rename gratchy.scm => rags.scm (96%) diff --git a/gratchy.scm b/rags.scm similarity index 96% rename from gratchy.scm rename to rags.scm index 6237534..264f553 100644 --- a/gratchy.scm +++ b/rags.scm @@ -54,9 +54,12 @@ (mime-type (cadr mime))) (print "20 " (string-intersperse (cdr mime) ";") "\r") (cond - ((equal? mime-type "text/gemini") (serve-dynamic-gemini path)) - ((equal? mime-type "text/plain") (serve-text-plain path)) - (else (serve-binary))))) + ((and (equal? mime-type "text/gemini") + (file-executable? path)) + (serve-text-dynamic path)) + ((string-prefix? "text/" mime-type) + (serve-text-plain path)) + (else (serve-binary path))))) (define (serve-text-plain path) (with-input-from-file path @@ -66,7 +69,7 @@ (print* str) (loop (read-string))))))) -(define (serve-dynamic-gemini path) +(define (serve-text-dynamic path) (with-input-from-file path (lambda () (let loop ((c (peek-char))) @@ -113,7 +116,6 @@ (change-directory old-wd) (signal o))))) - (define (run-server config) (define listener (ssl-listen* hostname: (config-host config) port: (config-port config) @@ -182,5 +184,4 @@ (print "One or more invalid arguments.") (print-usage progname))))))))) - (main) -- 2.20.1