Compare commits

...

4 Commits

5 changed files with 49 additions and 32 deletions

4
.dir-locals.el Normal file
View File

@ -0,0 +1,4 @@
;;; Directory Local Variables -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")
((scheme-mode . ((tab-width . 4))))

View File

@ -2,7 +2,8 @@
;; https://spritely.institute/files/docs/guile-hoot/0.2.0/Tutorial.html ;; https://spritely.institute/files/docs/guile-hoot/0.2.0/Tutorial.html
(use-modules (ice-9 binary-ports) (ice-9 format) (ice-9 match) (use-modules (ice-9 binary-ports) (ice-9 format) (ice-9 match)
(web server) (web request) (web response) (web uri)) (web server) (web request) (web response) (web uri)
(haunt html))
(define (extension file) (define (extension file)
(match (string-split file #\.) (match (string-split file #\.)
@ -12,13 +13,21 @@
(define (mime-type file-name) (define (mime-type file-name)
(or (assoc-ref '(("js" . application/javascript) (or (assoc-ref '(("js" . application/javascript)
("html" . text/html) ("html" . text/html)
("scm" . text/stml)
("wasm" . application/wasm)) ("wasm" . application/wasm))
(extension file-name)) (extension file-name))
'text/plain)) 'text/plain))
(define (render-stml file-name)
(values '((content-type . (text/html)))
(sxml->html-string (load file-name))))
(define (render-file file-name) (define (render-file file-name)
(values `((content-type . (,(mime-type file-name)))) (let ((type (mime-type file-name)))
(call-with-input-file file-name get-bytevector-all))) (if (eq? type 'text/stml)
(render-stml file-name)
(values `((content-type . (,type)))
(call-with-input-file file-name get-bytevector-all)))))
(define (not-found path) (define (not-found path)
(values (build-response #:code 404) (string-append "Not found: " path))) (values (build-response #:code 404) (string-append "Not found: " path)))
@ -34,7 +43,7 @@
(cond ((and (file-exists? f) (not (directory? f))) (cond ((and (file-exists? f) (not (directory? f)))
(render-file f)) (render-file f))
((equal? "/" path) ((equal? "/" path)
(render-file (prepend-prefix "index.html"))) (render-file (prepend-prefix "index.scm")))
(else not-found path)))) (else not-found path))))
(define (handle-request request body) (define (handle-request request body)

View File

@ -1,30 +1,38 @@
(use-modules (use-modules
(guix packages) (guix packages)
((guix licenses) #:prefix license:) ((guix licenses) #:prefix license:)
(guix download) (guix gexp)
(guix build-system gnu) (guix git-download)
(gnu packages) (guix utils)
(gnu packages autotools) (guix build-system copy)
(gnu packages guile) (gnu packages)
(gnu packages guile-xyz) (gnu packages autotools)
(gnu packages pkg-config) (gnu packages guile)
(gnu packages texinfo)) (gnu packages guile-xyz)
(gnu packages pkg-config)
(gnu packages texinfo))
(define vcs-file?
(or (git-predicate (current-source-directory))
(const #t)))
(package (package
(name "guile-guile-docs") (name "guile-guile-docs")
(version "0.1") (version "0.1")
(source "./guile-guile-docs-0.1.tar.gz") (source (local-file "." "guile-checkout"
(build-system gnu-build-system) #:recursive? #t
#:select? vcs-file?))
(build-system copy-build-system)
(arguments `()) (arguments `())
(native-inputs (native-inputs
`(("autoconf" ,autoconf) `(("autoconf" ,autoconf)
("automake" ,automake) ("automake" ,automake)
("pkg-config" ,pkg-config) ("pkg-config" ,pkg-config)
("texinfo" ,texinfo))) ("texinfo" ,texinfo)))
(inputs `(("guile" ,guile-3.0))) (inputs (list guile-3.0
haunt))
(propagated-inputs `()) (propagated-inputs `())
(synopsis "") (synopsis "")
(description "") (description "")
(home-page "") (home-page "")
(license license:gpl3+)) (license license:gpl3+))

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Guile Docs</title>
</head>
<body>
<h1>Welcome to Guile Docs</h1>
<p>This is Guile Docs.</p>
</body>
</html>

6
public/index.scm Normal file
View File

@ -0,0 +1,6 @@
'(html
(head
(title "Welcome to Guile Docs"))
(body
(h1 "Welcome to Guile Docs")
(p "This is Guile Docs.")))