Compare commits

...

7 Commits

6 changed files with 88 additions and 16 deletions

View File

@ -12,20 +12,18 @@
(define (mime-type file-name)
(or (assoc-ref '(("js" . application/javascript)
("css" . text/css)
("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)
(let ((type (mime-type file-name)))
(if (eq? type 'text/stml)
(render-stml file-name)
(values '((content-type . (text/html)))
(sxml->html-string (load file-name)))
(values `((content-type . (,type)))
(call-with-input-file file-name get-bytevector-all)))))
@ -39,12 +37,12 @@
(define %prefix `(,(getcwd) "public"))
(define (prepend-prefix path) (string-join (append %prefix `(,path)) file-name-separator-string))
(let* ((f (prepend-prefix (uri-decode path))))
(let ((f (prepend-prefix (uri-decode path))))
(cond ((and (file-exists? f) (not (directory? f)))
(render-file f))
((equal? "/" path)
(render-file (prepend-prefix "index.scm")))
(else not-found path))))
(else (not-found path)))))
(define (handle-request request body)
(let ((method (request-method request))

View File

@ -1,6 +1,4 @@
(define-module (guile-docs docs)
#:use-module (srfi srfi-9)
#:export (docs-in-module))
(use-modules (srfi srfi-9))
(define-record-type <doc>
(make-doc module symbol documentation)

View File

@ -1,6 +1,7 @@
'(html
(head
(title "Welcome to Guile Docs"))
(body
(h1 "Welcome to Guile Docs")
(p "This is Guile Docs.")))
;; TODO: move to modules - need to set up pre-inst-env or w/e
(load "overall-wrapper.scm")
(overall-wrapper
'(main
(h1 "Welcome")
(p "This is GuileDocs.")))

18
public/module.scm Normal file
View File

@ -0,0 +1,18 @@
(load "overall-wrapper.scm")
(load "../guile-docs/docs.scm")
(define (render-module module)
(let ((docs (docs-in-module module)))
(overall-wrapper
`(main ,(map render-doc docs)))))
(define (render-doc doc)
`((hgroup
(h1 ,(doc-symbol doc))
(p "In " ,(doc-module doc)))
(p ,(or (doc-documentation doc) ""))))
(render-module (resolve-interface '(srfi srfi-19)))

View File

@ -0,0 +1,23 @@
;; todo: module
(define (overall-wrapper content)
`(html
(link (@ (rel "stylesheet")
(type "text/css")
(href "style.css")))
(head (title "Welcome to GuileDocs"))
(body
(div (@ (id "overall-wrapper"))
(header (h3 "🚀GuileDocs")
(input (@ (type "text")
(placeholder "Search (ctrl-s)")))
(menu (li "Core Library")
(li "Quick Ref")))
(nav (section (h4 "Navigation")
(menu (li "Top")
(li "Examples")
(li "See Also")))
(section (h4 "Namespace")
(menu (li "guile")
(li "srfi"))))
,content
(footer (p (i "powered by solarpunks.")))))))

34
public/style.css Normal file
View File

@ -0,0 +1,34 @@
body {
background-color: #cdfcab;
}
#overall-wrapper {
max-width: 1000px;
margin: 0 auto;
}
header menu {
display: inline-block;
}
header menu li {
display: inline-block;
padding: 2px;
margin: 0 2px;
}
nav {
float: left;
padding: 0 50px 0 0;
}
main {
padding: 0 50px;
}
footer {
clear: both;
}
footer p {
text-align: center;
}