From 521d460867abff86c9cfb3bdacc7ad421caa363d Mon Sep 17 00:00:00 2001 From: Sorrel <52061229+sorrelbri@users.noreply.github.com> Date: Wed, 8 Nov 2023 23:10:28 -0500 Subject: [PATCH] clean up and styling, basic structure --- sorrel.dev.rkt | 68 ++++++++++++++++++++++---------------- source/feed.atom | 1 + source/header.txt | 12 +++---- source/index.txt | 4 +-- source/license.txt | 2 ++ source/post-footer.txt | 39 ++++++++++++++++++++++ source/settled/index.txt | 3 ++ source/tagged.txt | 3 ++ source/unsettled/index.txt | 3 ++ source/unsettleds/1.txt | 2 -- static/styles.css | 49 +++++++++++++++++++++++---- 11 files changed, 141 insertions(+), 45 deletions(-) create mode 100644 source/feed.atom create mode 100644 source/license.txt create mode 100644 source/post-footer.txt create mode 100644 source/settled/index.txt create mode 100644 source/tagged.txt create mode 100644 source/unsettled/index.txt delete mode 100644 source/unsettleds/1.txt diff --git a/sorrel.dev.rkt b/sorrel.dev.rkt index e124d2d..397e3cb 100644 --- a/sorrel.dev.rkt +++ b/sorrel.dev.rkt @@ -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 "" - (xexpr->string content)))))) + (string->bytes/utf-8 (file->string "source/feed.atom")))) ;;; 404 diff --git a/source/feed.atom b/source/feed.atom new file mode 100644 index 0000000..436156e --- /dev/null +++ b/source/feed.atom @@ -0,0 +1 @@ +λ.sorrel.dev2023-11-08T22:49:41sorrelhttps://sorrel.dev \ No newline at end of file diff --git a/source/header.txt b/source/header.txt index 1a3cf70..8acf6db 100644 --- a/source/header.txt +++ b/source/header.txt @@ -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)") diff --git a/source/index.txt b/source/index.txt index 0485224..9fb7b46 100644 --- a/source/index.txt +++ b/source/index.txt @@ -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")) diff --git a/source/license.txt b/source/license.txt new file mode 100644 index 0000000..53a30a9 --- /dev/null +++ b/source/license.txt @@ -0,0 +1,2 @@ +(article + (p "no licensing info yet. this is a real big question.")) \ No newline at end of file diff --git a/source/post-footer.txt b/source/post-footer.txt new file mode 100644 index 0000000..bae6fe4 --- /dev/null +++ b/source/post-footer.txt @@ -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")))))) \ No newline at end of file diff --git a/source/settled/index.txt b/source/settled/index.txt new file mode 100644 index 0000000..36750a1 --- /dev/null +++ b/source/settled/index.txt @@ -0,0 +1,3 @@ +(article + (p + "stubbed tagged page")) \ No newline at end of file diff --git a/source/tagged.txt b/source/tagged.txt new file mode 100644 index 0000000..36750a1 --- /dev/null +++ b/source/tagged.txt @@ -0,0 +1,3 @@ +(article + (p + "stubbed tagged page")) \ No newline at end of file diff --git a/source/unsettled/index.txt b/source/unsettled/index.txt new file mode 100644 index 0000000..36750a1 --- /dev/null +++ b/source/unsettled/index.txt @@ -0,0 +1,3 @@ +(article + (p + "stubbed tagged page")) \ No newline at end of file diff --git a/source/unsettleds/1.txt b/source/unsettleds/1.txt deleted file mode 100644 index 90b9526..0000000 --- a/source/unsettleds/1.txt +++ /dev/null @@ -1,2 +0,0 @@ -(body - "just a test") \ No newline at end of file diff --git a/static/styles.css b/static/styles.css index b7a1d0b..a9a5a84 100644 --- a/static/styles.css +++ b/static/styles.css @@ -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; +} +