From: Tim Vaughan Date: Sat, 23 May 2020 22:12:51 +0000 (+0200) Subject: Better name. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=f279ff3c0a93204a629e707fe54b0ee08921c579;p=rags.git Better name. --- 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)