summaryrefslogtreecommitdiff
path: root/tissue/web
diff options
context:
space:
mode:
authorArun Isaac2023-01-29 16:56:43 +0000
committerArun Isaac2023-01-29 22:35:53 +0000
commitfb26896560dbdfa80eb517d157e9afd2562e1f8e (patch)
tree446a52aa79e9d5bbdd0a81ebd3ee60b8e40daee3 /tissue/web
parent8516e5d0f5b64c681d31efa2944bb9a9de32dbbc (diff)
downloadtissue-fb26896560dbdfa80eb517d157e9afd2562e1f8e.tar.gz
tissue-fb26896560dbdfa80eb517d157e9afd2562e1f8e.tar.lz
tissue-fb26896560dbdfa80eb517d157e9afd2562e1f8e.zip
web: Do not temporarily checkout repository when serving it.
Now that snippet source texts are interred into the xapian index, the web server does not need a repository checkout. * bin/tissue (tissue-web): Do not temporarily checkout repositories being served. * tissue/web/server.scm (handler): Do not change into repository directory. * tissue/git.scm (call-with-temporary-checkouts): Delete function. * .dir-locals.el (scheme-mode): Unregister it.
Diffstat (limited to 'tissue/web')
-rw-r--r--tissue/web/server.scm56
1 files changed, 27 insertions, 29 deletions
diff --git a/tissue/web/server.scm b/tissue/web/server.scm
index 43093f8..db89bae 100644
--- a/tissue/web/server.scm
+++ b/tissue/web/server.scm
@@ -157,35 +157,33 @@ See `start-web-server' for documentation of HOSTS."
(log-request request)
(parameterize ((%current-git-repository
(repository-open repository-directory)))
- (call-with-current-directory repository-directory
- (lambda ()
- (cond
- ;; Static files
- ((let ((file-path
- (find file-exists?
- (map (cut string-append (assq-ref host-parameters 'website-directory) <>)
- (try-paths path)))))
- (and file-path
- ;; Check that the file really is within the document
- ;; root.
- (string-prefix? (string-append (assq-ref host-parameters 'website-directory) "/")
- (canonicalize-path file-path))
- (canonicalize-path file-path)))
- => (lambda (file-path)
- (values `((content-type . ,(mime-type-for-extension
- (file-name-extension file-path))))
- (call-with-input-file file-path
- get-bytevector-all))))
- ;; Search page. We look for the search page only after files
- ;; because we want to let files shadow the search page if
- ;; necessary.
- ((member path (list "/" "/search"))
- (search-handler request body
- (assq-ref host-parameters 'xapian-directory)
- (assq-ref host-parameters 'project)))
- ;; Not found
- (else
- (404-response request))))))))
+ (cond
+ ;; Static files
+ ((let ((file-path
+ (find file-exists?
+ (map (cut string-append (assq-ref host-parameters 'website-directory) <>)
+ (try-paths path)))))
+ (and file-path
+ ;; Check that the file really is within the document
+ ;; root.
+ (string-prefix? (string-append (assq-ref host-parameters 'website-directory) "/")
+ (canonicalize-path file-path))
+ (canonicalize-path file-path)))
+ => (lambda (file-path)
+ (values `((content-type . ,(mime-type-for-extension
+ (file-name-extension file-path))))
+ (call-with-input-file file-path
+ get-bytevector-all))))
+ ;; Search page. We look for the search page only after files
+ ;; because we want to let files shadow the search page if
+ ;; necessary.
+ ((member path (list "/" "/search"))
+ (search-handler request body
+ (assq-ref host-parameters 'xapian-directory)
+ (assq-ref host-parameters 'project)))
+ ;; Not found
+ (else
+ (404-response request))))))
(define (start-web-server socket-address hosts)
"Start web server listening on SOCKET-ADDRESS.