clean up and styling, basic structure

This commit is contained in:
Sorrel 2023-11-08 23:10:28 -05:00
parent d02be1f2a4
commit 521d460867
11 changed files with 141 additions and 45 deletions

View file

@ -35,12 +35,31 @@
(lambda (type resource-processor) (lambda (type resource-processor)
(case-lambda (case-lambda
[(req) (let ([res-path (path-add-extension [(req) (let ([res-path (path-add-extension
(build-path "source" type) #".txt")]) (if (and (non-empty-string? type) (not (eq? type "root")))
(build-path "source" type "index")
(build-path "source" "index" ))
#".txt")])
(displayln res-path)
(if (file-exists? res-path) (if (file-exists? res-path)
(html-response (resource-processor res-path)) (html-response (resource-processor res-path))
(html-response (resource-processor "source/not-found.txt"))))] (html-response (resource-processor "source/not-found.txt"))))]
[(req id) (let ([res-path (path-add-extension [(req id) (let ([res-path
(build-path "source" type (~a id)) #".txt")]) (path-add-extension
(build-path
"source"
(if (eq? type "root")
(if (eq? id "")
;; if "root/" something weird has happened
"index"
;; allows for loading "/this" and other root resources
(~a id))
(if
;; if "type/" id will be an empty string
(or (not (string? id)) (non-empty-string? id))
(build-path type (~a id))
;; and should return index for that type
(build-path type "index"))))
#".txt")])
(if (file-exists? res-path) (if (file-exists? res-path)
(html-response (resource-processor res-path)) (html-response (resource-processor res-path))
(html-response (resource-processor "source/not-found.txt"))))]))) (html-response (resource-processor "source/not-found.txt"))))])))
@ -57,15 +76,14 @@
(define-values (httpx-app reverse-httpx-uri) (define-values (httpx-app reverse-httpx-uri)
(dispatch-rules (dispatch-rules
[("hx" "about") (respond-resource-with-processor "about" xexpr-file->xml)] [("hx" "home") (respond-resource-with-processor "root" xexpr-file->xml)]
[("hx" "home") (respond-resource-with-processor "index" xexpr-file->xml)] [("hx" "settled") (respond-resource-with-processor "settled" xexpr-file->xml)]
[("hx" "settleds" (integer-arg)) (respond-resource-with-processor "settleds" xexpr-file->xml)] [("hx" "settled" (integer-arg)) (respond-resource-with-processor "settled" xexpr-file->xml)]
[("hx" "settleds") (respond-resource-with-processor "settleds" xexpr-file->xml)] [("hx" "unsettled") (respond-resource-with-processor "unsettled" xexpr-file->xml)]
[("hx" "unsettleds" (integer-arg)) (respond-resource-with-processor "unsettleds" xexpr-file->xml)] [("hx" "unsettled" (integer-arg)) (respond-resource-with-processor "unsettled" xexpr-file->xml)]
[("hx" "unsettleds") (respond-resource-with-processor "unsettleds" xexpr-file->xml)]
[("hx" "tagged" (string-arg)) (respond-resource-with-processor "tagged" xexpr-file->xml)]
[("hx" "tagged") (respond-resource-with-processor "tagged" xexpr-file->xml)] [("hx" "tagged") (respond-resource-with-processor "tagged" xexpr-file->xml)]
[("hx" "this") (respond-resource-with-processor "this" xexpr-file->xml)] [("hx" "tagged" (string-arg)) (respond-resource-with-processor "tagged" xexpr-file->xml)]
[("hx" (string-arg)) (respond-resource-with-processor "root" xexpr-file->xml)]
[else 404-hx])) [else 404-hx]))
;;; page-app ;;; page-app
@ -77,19 +95,19 @@
,(read (open-input-file "source/head.txt")) ,(read (open-input-file "source/head.txt"))
(body (body
,(read (open-input-file "source/header.txt")) ,(read (open-input-file "source/header.txt"))
,(read (open-input-file resource))))))) (main ,(read (open-input-file resource))))))))
(define-values (page-app reverse-page-uri) (define-values (page-app reverse-page-uri)
(dispatch-rules (dispatch-rules
[("") (respond-resource-with-processor "index" make-page)] [("") (respond-resource-with-processor "" make-page)]
[("about") (respond-resource-with-processor "about" make-page)] [("home") (respond-resource-with-processor "" make-page)]
[("settleds" (integer-arg)) (respond-resource-with-processor "settleds" make-page)] [("settled") (respond-resource-with-processor "settled" make-page)]
[("settleds") (respond-resource-with-processor "settleds" make-page)] [("settled" (integer-arg)) (respond-resource-with-processor "settled" make-page)]
[("unsettleds" (integer-arg)) (respond-resource-with-processor "unsettleds" make-page)] [("unsettled") (respond-resource-with-processor "unsettled" make-page)]
[("unsettleds") (respond-resource-with-processor "unsettleds" make-page)] [("unsettled" (integer-arg)) (respond-resource-with-processor "unsettled" make-page)]
[("tagged" (string-arg)) (respond-resource-with-processor "tagged" make-page)]
[("tagged") (respond-resource-with-processor "tagged" make-page)] [("tagged") (respond-resource-with-processor "tagged" make-page)]
[("this") (respond-resource-with-processor "this" make-page)] [("tagged" (string-arg)) (respond-resource-with-processor "tagged" make-page)]
[((string-arg)) (respond-resource-with-processor "root" make-page)]
[else not-found])) [else not-found]))
@ -114,16 +132,8 @@
(define (rss-feed request) (define (rss-feed request)
(let ([feed-ref "https://sorrel.dev/feed.atom"]
[update-time (date->string (current-date) (date-display-format 'iso-8601))]
[homepage "https://sorrel.dev"])
;; hard coding for now because reader can't be escaped
(define content
((eval (read (open-input-file "source/atom.txt")) ns)
feed-ref update-time homepage))
(xml-response (xml-response
(string->bytes/utf-8 (string-append "<?xml version=\"1.0\" encoding=\"utf-8\"?>" (string->bytes/utf-8 (file->string "source/feed.atom"))))
(xexpr->string content))))))
;;; 404 ;;; 404

1
source/feed.atom Normal file
View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>λ.sorrel.dev</title><link rel="self" href="https://sorrel.dev/feed.atom"/><updated>2023-11-08T22:49:41</updated><author><name>sorrel</name></author><id>https://sorrel.dev</id>

View file

@ -3,12 +3,12 @@
((class "banner") ((class "banner")
(hx-get "/hx/home") (hx-get "/hx/home")
(hx-target "main") (hx-target "main")
(hx-swap "outerHTML")) (hx-swap "innerHTML"))
(p (p
((class "ascii")) ((class "ascii"))
"▒▓░ "(a "▒▓░ "(a
((href "/")) ((href "/"))
"home")" ░░▒ ▒▒▓█▒ ░▒ "home")" ░░▒ ▒▒▓█▒ ░▒
░▒▒░▓▓ ▒▒▒▒▒▒▓█ ▒▓ ░▒▒░▓▓ ▒▒▒▒▒▒▓█ ▒▓
▒▒▓▓░▒▓ ▓█▓▓ ░▓ ▒▒▓▓░▒▓ ▓█▓▓ ░▓
▓▒▒ ▒▒ ░ ▓▒▒ ▒▒ ░
@ -54,14 +54,14 @@
(hx-swap "innerHTML")) (hx-swap "innerHTML"))
"about sorrel (the bitch who made this)") "about sorrel (the bitch who made this)")
(a (a
((href "/unsettleds") ((href "/unsettled")
(hx-get "/hx/unsettleds") (hx-get "/hx/unsettled")
(hx-target "main") (hx-target "main")
(hx-swap "innerHTML")) (hx-swap "innerHTML"))
"unsettled thoughts (something like a blog)") "unsettled thoughts (something like a blog)")
(a (a
((href "/settleds") ((href "/settled")
(hx-get "/hx/settleds") (hx-get "/hx/settled")
(hx-target "main") (hx-target "main")
(hx-swap "innerHTML")) (hx-swap "innerHTML"))
"\"settled\" thoughts (projects built/in progress)") "\"settled\" thoughts (projects built/in progress)")

View file

@ -1,4 +1,4 @@
(main (article
(noscript (noscript
(span (span
((class "noscript")) ((class "noscript"))
@ -26,7 +26,7 @@
(a ((href "/this") (a ((href "/this")
(hx-get "/hx/this") (hx-get "/hx/this")
(hx-target "closest span") (hx-target "closest span")
(hx-swap "inner HTML")) (hx-swap "innerHTML"))
"(how i build this little page.)"))) "(how i build this little page.)")))
(p " i hope you have a nice time looking at things here.") (p " i hope you have a nice time looking at things here.")
(p ((class "ascii but-normal-size")) (p ((class "ascii but-normal-size"))

2
source/license.txt Normal file
View file

@ -0,0 +1,2 @@
(article
(p "no licensing info yet. this is a real big question."))

39
source/post-footer.txt Normal file
View file

@ -0,0 +1,39 @@
(lambda (tag-list history-list)
(let ([class-sec `(ul ((class "tag-list")))])
`(footer
(section
(h5 "tagged")
,(begin
(for-each
(lambda (tag)
(set! class-sec
(append class-sec
;; append unwraps one layer of list, hence (( ... ))
`((li
((class "tag-item"))
(span
((class "hx-target"))
(a ((href ,(string-append "/tagged/" tag))
(hx-get ,(string-append "/hx/tagged/" tag))
(hx-target "closest span.hx-target")
(hx-swap "innerHTML"))
,tag)))))))
tag-list)
class-sec))
(hr)
(p
((class "doc-history"))
(small
,(foldr
(lambda (history acc)
(if (non-empty-string? acc)
(string-append acc "modified: " (~a history) "\n")
(string-append acc "published: " (~a history))))
""
history-list)))
(p
((class "license-info"))
(small
(a
((href "/license"))
"license"))))))

3
source/settled/index.txt Normal file
View file

@ -0,0 +1,3 @@
(article
(p
"stubbed tagged page"))

3
source/tagged.txt Normal file
View file

@ -0,0 +1,3 @@
(article
(p
"stubbed tagged page"))

View file

@ -0,0 +1,3 @@
(article
(p
"stubbed tagged page"))

View file

@ -1,2 +0,0 @@
(body
"just a test")

View file

@ -1,15 +1,31 @@
:root { :root {
--foreground-color: lab(90 50 -80); color-scheme: light dark;
--background-color: lab(0 50 -30); }
--link-color: lab(80 40 100);
--visited-link-color: lab(70 10 15); @media screen and not (prefers-color-scheme: light) {
--banner-ascii-color: lab(90 -40 20 / 0.8); html {
background-color: var(--background-color); --foreground-color: lab(90 50 -80);
--background-color: lab(0 50 -30);
--link-color: lab(80 40 100);
--visited-link-color: lab(70 10 15);
--banner-ascii-color: lab(90 -40 20 / 0.8);
}
}
@media screen and (prefers-color-scheme: light) {
html {
--foreground-color: lab(10 50 -80);
--background-color: lab(90 50 -30);
--link-color: lab(20 40 100);
--visited-link-color: lab(20 10 15);
--banner-ascii-color: lab(10 -40 20 / 0.8);
}
} }
html { html {
padding: 20px; padding: 20px;
color: var(--foreground-color); color: var(--foreground-color);
background-color: var(--background-color);
} }
h1, h2, h3, h4, h5 { h1, h2, h3, h4, h5 {
@ -19,6 +35,10 @@ h1, h2, h3, h4, h5 {
padding: 2 10; padding: 2 10;
} }
h5 {
margin: 2 0;
}
span.noscript p { span.noscript p {
font-family: 'Courier New', Courier, monospace; font-family: 'Courier New', Courier, monospace;
font-size: small; font-size: small;
@ -92,3 +112,20 @@ nav a {
padding: 5px; padding: 5px;
} }
p {
margin: 12 0;
}
ul.tag-list {
display: flex;
flex-direction: row;
margin: 6 0;
padding: 0;
}
li.tag-item {
list-style-type: none;
flex-basis: fit-content;
margin: 0 6;
}