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)
(case-lambda
[(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)
(html-response (resource-processor res-path))
(html-response (resource-processor "source/not-found.txt"))))]
[(req id) (let ([res-path (path-add-extension
(build-path "source" type (~a id)) #".txt")])
[(req id) (let ([res-path
(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)
(html-response (resource-processor res-path))
(html-response (resource-processor "source/not-found.txt"))))])))
@ -57,15 +76,14 @@
(define-values (httpx-app reverse-httpx-uri)
(dispatch-rules
[("hx" "about") (respond-resource-with-processor "about" xexpr-file->xml)]
[("hx" "home") (respond-resource-with-processor "index" xexpr-file->xml)]
[("hx" "settleds" (integer-arg)) (respond-resource-with-processor "settleds" xexpr-file->xml)]
[("hx" "settleds") (respond-resource-with-processor "settleds" xexpr-file->xml)]
[("hx" "unsettleds" (integer-arg)) (respond-resource-with-processor "unsettleds" 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" "home") (respond-resource-with-processor "root" xexpr-file->xml)]
[("hx" "settled") (respond-resource-with-processor "settled" xexpr-file->xml)]
[("hx" "settled" (integer-arg)) (respond-resource-with-processor "settled" xexpr-file->xml)]
[("hx" "unsettled") (respond-resource-with-processor "unsettled" xexpr-file->xml)]
[("hx" "unsettled" (integer-arg)) (respond-resource-with-processor "unsettled" 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]))
;;; page-app
@ -77,19 +95,19 @@
,(read (open-input-file "source/head.txt"))
(body
,(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)
(dispatch-rules
[("") (respond-resource-with-processor "index" make-page)]
[("about") (respond-resource-with-processor "about" make-page)]
[("settleds" (integer-arg)) (respond-resource-with-processor "settleds" make-page)]
[("settleds") (respond-resource-with-processor "settleds" make-page)]
[("unsettleds" (integer-arg)) (respond-resource-with-processor "unsettleds" make-page)]
[("unsettleds") (respond-resource-with-processor "unsettleds" make-page)]
[("tagged" (string-arg)) (respond-resource-with-processor "tagged" make-page)]
[("") (respond-resource-with-processor "" make-page)]
[("home") (respond-resource-with-processor "" make-page)]
[("settled") (respond-resource-with-processor "settled" make-page)]
[("settled" (integer-arg)) (respond-resource-with-processor "settled" make-page)]
[("unsettled") (respond-resource-with-processor "unsettled" make-page)]
[("unsettled" (integer-arg)) (respond-resource-with-processor "unsettled" 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]))
@ -114,16 +132,8 @@
(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
(string->bytes/utf-8 (string-append "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
(xexpr->string content))))))
(string->bytes/utf-8 (file->string "source/feed.atom"))))
;;; 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")
(hx-get "/hx/home")
(hx-target "main")
(hx-swap "outerHTML"))
(hx-swap "innerHTML"))
(p
((class "ascii"))
"▒▓░ "(a
((href "/"))
"home")" ░░▒ ▒▒▓█▒ ░▒
"home")" ░░▒ ▒▒▓█▒ ░▒
░▒▒░▓▓ ▒▒▒▒▒▒▓█ ▒▓
▒▒▓▓░▒▓ ▓█▓▓ ░▓
▓▒▒ ▒▒ ░
@ -54,14 +54,14 @@
(hx-swap "innerHTML"))
"about sorrel (the bitch who made this)")
(a
((href "/unsettleds")
(hx-get "/hx/unsettleds")
((href "/unsettled")
(hx-get "/hx/unsettled")
(hx-target "main")
(hx-swap "innerHTML"))
"unsettled thoughts (something like a blog)")
(a
((href "/settleds")
(hx-get "/hx/settleds")
((href "/settled")
(hx-get "/hx/settled")
(hx-target "main")
(hx-swap "innerHTML"))
"\"settled\" thoughts (projects built/in progress)")

View file

@ -1,4 +1,4 @@
(main
(article
(noscript
(span
((class "noscript"))
@ -26,7 +26,7 @@
(a ((href "/this")
(hx-get "/hx/this")
(hx-target "closest span")
(hx-swap "inner HTML"))
(hx-swap "innerHTML"))
"(how i build this little page.)")))
(p " i hope you have a nice time looking at things here.")
(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 {
--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);
background-color: var(--background-color);
color-scheme: light dark;
}
@media screen and not (prefers-color-scheme: light) {
html {
--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 {
padding: 20px;
color: var(--foreground-color);
background-color: var(--background-color);
}
h1, h2, h3, h4, h5 {
@ -19,6 +35,10 @@ h1, h2, h3, h4, h5 {
padding: 2 10;
}
h5 {
margin: 2 0;
}
span.noscript p {
font-family: 'Courier New', Courier, monospace;
font-size: small;
@ -92,3 +112,20 @@ nav a {
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;
}