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
(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)
(match (string-split file #\.)
@ -12,13 +13,21 @@
(define (mime-type file-name)
(or (assoc-ref '(("js" . application/javascript)
("html" . text/html)
("scm" . text/stml)
("wasm" . application/wasm))
(extension file-name))
'text/plain))
(define (render-stml file-name)
(values '((content-type . (text/html)))
(sxml->html-string (load file-name))))
(define (render-file file-name)
(values `((content-type . (,(mime-type file-name))))
(call-with-input-file file-name get-bytevector-all)))
(let ((type (mime-type file-name)))
(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)
(values (build-response #:code 404) (string-append "Not found: " path)))
@ -34,7 +43,7 @@
(cond ((and (file-exists? f) (not (directory? f)))
(render-file f))
((equal? "/" path)
(render-file (prepend-prefix "index.html")))
(render-file (prepend-prefix "index.scm")))
(else not-found path))))
(define (handle-request request body)

View File

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