all repos — www @ 21c0adb90a362f03a033ed4efe841261a6378f2d

deserthorns.net content + generator

do, more tweaks
sageclove
Sun, 05 Jan 2025 13:22:43 -0700
commit

21c0adb90a362f03a033ed4efe841261a6378f2d

parent

d62e4b4fc52d42dd20787ba4f778776d007855f1

5 files changed, 218 insertions(+), 36 deletions(-)

jump to
A assets/css/zenburn.css

@@ -0,0 +1,11 @@

+:root { + --background: #464646; + --f_high: #DCDCCC; + --f_med: #DCA3A3; + --f_low: #7F9F7F; + --f_inv: #000D18; + --b_high: #262626; + --b_med: #333333; + --b_low: #3F3F3F; + --b_inv: #8FAF9F; +}
M build/build.gobuild/build.go

@@ -58,49 +58,63 @@ fmt.Println("Starting build...")

os.RemoveAll(filepath.Join("out")) os.Mkdir(filepath.Join("out"), 0777) - fmt.Println("Building wiki pages...") + fmt.Print("Building wiki pages...") buildWiki(buildWikiLinkedList()) - fmt.Println("\tDone") + fmt.Println("Done") - fmt.Println("Copying and renaming wiki CSS...") - wikiCssFS := os.DirFS(filepath.Join(rootPath, "wiki", "css")) + fmt.Print("Copying and renaming wiki CSS...") wikiCssOutPath := filepath.Join("out", "wiki", "css") - os.CopyFS(wikiCssOutPath, wikiCssFS) + copyDir( + filepath.Join(rootPath, "wiki", "css"), + wikiCssOutPath, + ) os.Rename( filepath.Join(wikiCssOutPath, "style.css"), filepath.Join(wikiCssOutPath, "style."+strconv.FormatInt(now.Unix(), 10)+".css"), ) - fmt.Println("\tDone") + fmt.Println("Done") - fmt.Println("Copying assets...") - assetsFS := os.DirFS(filepath.Join(rootPath, "assets")) - os.CopyFS(filepath.Join("out", "assets"), assetsFS) - fmt.Println("\tDone") + fmt.Print("Copying assets/...") + copyDir( + filepath.Join(rootPath, "assets"), + filepath.Join("out", "assets"), + ) + fmt.Println("Done") - fmt.Println("Copying root index...") + fmt.Print("Copying index.html...") copyFile( filepath.Join(rootPath, "index.html"), filepath.Join("out", "index.html"), ) - fmt.Println("\tDone") + fmt.Println("Done") + + fmt.Print("copying etc/...") + copyDir( + filepath.Join(rootPath, "etc"), + filepath.Join("out", "etc"), + ) + fmt.Println("Done") fmt.Println("Build complete.") if serve { http.Handle("/", http.StripPrefix("/", http.FileServer(http.Dir("out")))) - http.HandleFunc("GET /wiki/{page}", wikiHandler) + http.HandleFunc("GET /wiki/{page}", pageHandler(filepath.Join("out", "wiki"))) + http.HandleFunc("GET /etc/{page}", pageHandler(filepath.Join("out", "etc"))) fmt.Println("Serving on http://localhost:8000") log.Fatal(http.ListenAndServe(":8000", nil)) } } -func wikiHandler(responseWriter http.ResponseWriter, request *http.Request) { - pageName := request.PathValue("page") - pageFile, err := os.ReadFile(filepath.Join("out", "wiki", pageName+".html")) - if err == nil { - responseWriter.Write(pageFile) - return +func pageHandler(rootPath string) func(http.ResponseWriter, *http.Request) { + return func(responseWriter http.ResponseWriter, request *http.Request) { + pageName := request.PathValue("page") + pageFile, err := os.ReadFile(filepath.Join(rootPath, pageName+".html")) + if err == nil { + responseWriter.Write(pageFile) + return + } + http.NotFound(responseWriter, request) } - http.NotFound(responseWriter, request) } func buildWikiLinkedList() *Page {

@@ -245,6 +259,11 @@ dst, _ := os.Create(dstPath)

src, _ := os.Open(srcPath) io.Copy(dst, src) dst.Sync() +} + +func copyDir(srcPath string, dstPath string) { + srcFS := os.DirFS(srcPath) + os.CopyFS(dstPath, srcFS) } func __(foo any) {}
A etc/do.html

@@ -0,0 +1,129 @@

+<!DOCTYPE html> +<html> + +<head> + <meta charset="UTF-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width,initial-scale=1.0"> + <link rel="stylesheet" href="/assets/css/zenburn.css"> + <title>do</title> + <style> + html { + background: var(--background); + color: var(--f_high); + } + + body { + -webkit-text-size-adjust: 100%; + } + + p { + max-width: 30rem; + margin: 0 auto; + text-align: center; + } + + hr { + border: 1px solid var(--b_med); + } + + a { + color: var(--f_med); + } + + h1, + h2 { + letter-spacing: 0.5rem; + font-family: monospace; + text-align: center; + color: var(--f_low); + } + + .logo { + display: block; + margin: 2rem auto; + width: 4rem; + height: 4rem; + } + + .rotation { + max-width: 20rem; + margin: 0 auto; + margin-bottom: 3rem; + } + + .rotation > div { + padding: 1rem; + margin: 0.25rem; + text-align: center; + color: var(--f_high); + font-family: monospace; + font-size: 1rem; + } + + .rotation > div > span { + display: block; + } + + #today { + background: var(--b_high); + color: var(--f_med); + font-weight: bold; + } + + #plus-1 { + background: var(--b_med); + } + + #plus-2 { + background: var(--b_low); + } + </style> +</head> + +<body> + <a href="/"> + <img class="logo" src="/assets/svg/logo-block-mono.svg"> + </a> + <hr> + <h1>do</h1> + <div class="rotation"> + <div id="today"> + <span>Today,</span> + <span id="action"></span> + </div> + <div id="plus-1"> + <span>Tommorrow,</span> + <span id="action"></span> + </div> + <div id="plus-2"> + <span>Then,</span> + <span id="action"></span> + </div> + </div> + <h2>about</h2> + <p> + Based on the concept of "The Discipline" discussed <a href="https://anatomy.1651.org/#the-discipline">here</a>. + </p> +</body> +<script> + const rotation = [ + "connect", + "read", + "study", + "play", + "create", + "read", + "create", + "play", + "study", + "read" + ]; + const now = Date.now(); + const index = Math.floor((now / 1000 / 60 / 60 / 24) % 10); + document.querySelector("#today > #action").innerText = rotation[index]; + document.querySelector("#plus-1 > #action").innerText = rotation[(index + 1) % 10]; + document.querySelector("#plus-2 > #action").innerText = rotation[(index + 2) % 10]; +</script> + +</html>
M index.htmlindex.html

@@ -6,28 +6,15 @@ <meta charset="UTF-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>deserthorns</title> + <link rel="stylesheet" href="/assets/css/zenburn.css"> <style> - :root { - --background: #464646; - --f_high: #DCDCCC; - --f_med: #DCA3A3; - --f_low: #7F9F7F; - --f_inv: #000D18; - --b_high: #262626; - --b_med: #333333; - --b_low: #3F3F3F; - --b_inv: #8FAF9F; - } - html { background: var(--background); color: var(--f_high); } - .logo { - display: block; - margin: 5rem auto; - max-width: 15rem; + body { + -webkit-text-size-adjust: 100%; } h1 {

@@ -36,11 +23,46 @@ font-family: monospace;

text-align: center; color: var(--f_low); } + + a { + color: var(--f_med); + } + + ul { + list-style: none; + text-align: center; + font-size: 1.25rem; + padding: 0; + } + + li { + padding-bottom: 1rem; + } + + hr { + border: 1px solid var(--b_med); + } + + .logo { + display: block; + margin: 5rem auto; + max-width: 15rem; + } </style> </head> + <body> <img class="logo" src="/assets/svg/logo-block-mono.svg"> <h1>deserthorns</h1> + <hr> + <ul> + <li> + <a href="/wiki">wiki</a> + </li> + <li> + <a href="/etc/do">do</a> + </li> + </ul> </body> </html>
M wiki/css/style.csswiki/css/style.css

@@ -18,6 +18,7 @@

body { margin: 1rem; max-width: 60rem; + -webkit-text-size-adjust: 100%; } h1,