Some theming, fix bugs and such, better templating

This commit is contained in:
Vivianne 2023-12-13 01:56:30 -05:00
parent 58388e63b3
commit e40fc82904
4 changed files with 71 additions and 13 deletions

View File

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

View File

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

View File

@ -0,0 +1,25 @@
;; todo: module
(lambda (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;
}