summaryrefslogtreecommitdiff
path: root/tissue
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
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')
-rw-r--r--tissue/git.scm14
-rw-r--r--tissue/web/server.scm56
2 files changed, 28 insertions, 42 deletions
diff --git a/tissue/git.scm b/tissue/git.scm
index b67d65c..4289d65 100644
--- a/tissue/git.scm
+++ b/tissue/git.scm
@@ -48,8 +48,7 @@
call-with-file-in-git
file-modification-table
clone-options
- call-with-temporary-checkout
- call-with-temporary-checkouts))
+ call-with-temporary-checkout))
;; We bind additional functions from libgit2 that are not already
;; bound in guile-git. TODO: Contribute them to guile-git.
@@ -223,14 +222,3 @@ checkout when PROC returns or exits non-locally."
(proc temporary-checkout))
;; The system-dependent temporary directory
(dirname (tmpnam))))
-
-(define (call-with-temporary-checkouts repositories proc)
- "Call PROC with temporary checkouts of REPOSITORIES, and delete the
-checkouts when PROC returns or exits non-locally."
- (match repositories
- ((repository other-repositories ...)
- (call-with-temporary-checkout repository
- (lambda (checkout)
- (call-with-temporary-checkouts other-repositories
- (cut proc checkout <...>)))))
- (() (proc))))
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.