The Lambda Lab
/
projects
/
rags.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1d39d88
)
Fleshing out server.
author
Tim Vaughan
<plugd@thelambdalab.xyz>
Fri, 22 May 2020 20:17:43 +0000
(22:17 +0200)
committer
Tim Vaughan
<plugd@thelambdalab.xyz>
Fri, 22 May 2020 20:17:43 +0000
(22:17 +0200)
gratchy.scm
patch
|
blob
|
history
diff --git
a/gratchy.scm
b/gratchy.scm
index
4edb63d
..
3ddb540
100644
(file)
--- a/
gratchy.scm
+++ b/
gratchy.scm
@@
-7,6
+7,10
@@
(define SERVER-ROOT "public_gemini")
(define SERVER-HOST "thelambdalab.xyz")
(define SERVER-ROOT "public_gemini")
(define SERVER-HOST "thelambdalab.xyz")
+(define file-types
+ '(("gmi" "text/gemini; charset=utf8")
+ ("txt" "text/plain; charset=utf8")))
+
(define (process-request request-line)
(condition-case
(let ((uri (uri-normalize-path-segments (absolute-uri request-line))))
(define (process-request request-line)
(condition-case
(let ((uri (uri-normalize-path-segments (absolute-uri request-line))))
@@
-30,12
+34,19
@@
(print "50 " reason "\r"))
(define (document-available? uri)
(print "50 " reason "\r"))
(define (document-available? uri)
- (let ((path (apply make-pathname (cons SERVER-ROOT (cdr (uri-path uri))))))
- (file-exists? path)))
-
+ (print (document-path uri))
+ (file-exists? (document-path uri)))
+(define (document-path uri)
+ (let* ((crumbs (reverse (cons SERVER-ROOT (cdr (uri-path uri)))))
+ (path (make-pathname (reverse (cdr crumbs)) (car crumbs))))
+ (if (directory-exists? path)
+ (make-pathname path "index.gmi")
+ path)))
+
(define (serve-document uri)
(define (serve-document uri)
- (print "20 Surprise!\r"))
+ (let ((path (document-path uri)))
+ (print "20 Surprise!\r")))
-(process-request "gemini://thelambdalab.xyz/
../index
")
+(process-request "gemini://thelambdalab.xyz/
/
")