fix ten billion things
Jes Olson j3s@c3f.net
Sun, 06 Nov 2022 19:20:40 -0800
9 files changed,
155 insertions(+),
89 deletions(-)
M
feed/feed.go
→
feed/feed.go
@@ -42,7 +42,6 @@ "https://www.namecoin.org/feed.rss",
"https://www.ryanprior.com/posts/index.xml", } -// todo: async (nevermind, not really needed now tbh with new update method) func GetAllFeeds() []rss.Feed { var feeds []rss.Feed for _, f := range lovelyFeedList {
M
main.go
→
main.go
@@ -29,8 +29,7 @@ // data for use in templates. it's useful for it to be
// global since it may need to be available in arbitrary // contexts. maybe that sucks. but idfk! type templateData struct { - Feeds []rss.Feed - TitleWord string + Feeds []rss.Feed } var data templateData@@ -52,19 +51,30 @@ }
} } +func redirHandler(url string) func(w http.ResponseWriter, r *http.Request) { + return func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, url, 302) + } +} + func main() { go data.populate() fs := http.FileServer(http.Dir("./static")) http.Handle("/static/", http.StripPrefix("/static/", fs)) + // redirs up front - some of these are here for + // historic reasons, others for utility + http.HandleFunc("/tools.html", redirHandler("/creations.html")) + http.HandleFunc("/projects.html", redirHandler("/creations.html")) + http.HandleFunc("/feeds", feedHandler) http.HandleFunc("/feed.atom", atom.Handler) - http.HandleFunc("/age.html", serveAge) + http.HandleFunc("/age.html", ageHandler) http.HandleFunc("/ip", ipHandler) - http.HandleFunc("/review/", babyHandler) - http.HandleFunc("/thought/", babyHandler) - http.HandleFunc("/", serveTemplate) + http.HandleFunc("/review/", postHandler) + http.HandleFunc("/thought/", postHandler) + http.HandleFunc("/", serveRoot) log.Println("listening on :4666 tbh") err := http.ListenAndServe(":4666", nil)@@ -73,38 +83,46 @@ log.Fatal(err)
} } -func serveTemplate(w http.ResponseWriter, r *http.Request) { - lp := filepath.Join("templates", "layout.html") - if r.URL.Path == "/" { - r.URL.Path = "index.html" - } - fp := filepath.Join("templates", filepath.Clean(r.URL.Path)) +// templatesCombobulator takes a template & lays it on top +// of the layout template, then passes it back to the user +// this thing also sprinkles on some x-tra necessary funcs - info, err := os.Stat(fp) +func templateCombobulator(requestedPath string) (template.Template, error) { + layoutPath := filepath.Join("templates", "layout.html") + + info, err := os.Stat(requestedPath) if err != nil { - if os.IsNotExist(err) { - http.NotFound(w, r) - return - } + return template.Template{}, err } if info.IsDir() { - http.NotFound(w, r) - return + return template.Template{}, err } - tmpl, err := template.ParseFiles(lp, fp) + funcMap := template.FuncMap{ + "randomheaderphrase": randomJesPhrase, + } + + tmpl, err := template.New("unimportant").Funcs(funcMap).ParseFiles(layoutPath, requestedPath) + if err != nil { + return *tmpl, err + } + return *tmpl, nil +} + +func serveRoot(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/" { + r.URL.Path = "index.html" + } + requestedPath := filepath.Join("templates", filepath.Clean(r.URL.Path)) + + tmpl, err := templateCombobulator(requestedPath) if err != nil { log.Println(err.Error()) http.Error(w, http.StatusText(500), 500) return } - var wordList []string - wordList = append(wordList, "existential optimist", "shit hell", "loves shell", "is manic", "hugs you", "*fucking dies*", "logs off", "closes the world", "jes jes jes jes jes", "is a mess", "stands awkwardly", "walks to waterfall", "eats rice pudding", "olson", "plays dota2", "inspires ideas", "hates jump king", "<3", "pets every cat", "is a 0.5 on the binary", "winks at your miata", "has social anxiety", "tilts under pressure", "den", "is a skeletor") - wordIndex := rand.Intn(len(wordList)) - data.TitleWord = wordList[wordIndex] - err = tmpl.ExecuteTemplate(w, "layout", data) if err != nil { log.Println(err.Error())@@ -112,7 +130,7 @@ http.Error(w, http.StatusText(500), 500)
} } -func babyHandler(w http.ResponseWriter, r *http.Request) { +func postHandler(w http.ResponseWriter, r *http.Request) { lp := filepath.Join("templates", "simple-layout.html") fp := filepath.Join(strings.TrimPrefix(filepath.Clean(r.URL.Path), "/"))@@ -156,11 +174,8 @@ PublicKey string
Message string } -func serveAge(w http.ResponseWriter, r *http.Request) { - lp := filepath.Join("templates", "layout.html") - fp := filepath.Join("templates", "age.html") - - tmpl, err := template.ParseFiles(lp, fp) +func ageHandler(w http.ResponseWriter, r *http.Request) { + tmpl, err := templateCombobulator(filepath.Join("templates", "age.html")) if err != nil { log.Println(err.Error()) http.Error(w, http.StatusText(500), 500)@@ -207,9 +222,11 @@ if err := armorWriter.Close(); err != nil {
log.Fatalf("Failed to close armor: %v", err) } - log.Printf("%+v", buf) - - tmpl.ExecuteTemplate(w, "layout", buf.String()) + err = tmpl.ExecuteTemplate(w, "layout", buf.String()) + if err != nil { + log.Println(err.Error()) + http.Error(w, http.StatusText(500), 500) + } } func ipHandler(w http.ResponseWriter, r *http.Request) {@@ -236,7 +253,6 @@ <body>
<table> <tbody>`) - // printf the shit posts := feed.SortItems(data.Feeds) for _, p := range posts { fmt.Fprintf(w, "<tr><td>")@@ -244,3 +260,36 @@ fmt.Fprintf(w, `<a href="%s">%s</a>`, p.Link, p.Title)
fmt.Fprintf(w, "</tr></td>") } } + +func randomJesPhrase() string { + wordList := []string{ + "existential optimist", + "shit hell", + "loves shell", + "is manic", + "hugs you", + "*fucking dies*", + "logs off", + "closes the world", + "jes jes jes jes jes", + "is a mess", + "stands awkwardly", + "walks to waterfall", + "eats rice pudding", + "olson", + "plays dota2", + "inspires ideas", + "hates jump king", + "<3", + "pets every cat", + "is a 0.5 on the binary", + "winks at your miata", + "has social anxiety", + "tilts under pressure", + "den", + "is a skeletor", + "listens thoughtfully", + } + wordIndex := rand.Intn(len(wordList)) + return wordList[wordIndex] +}
M
templates/about.html
→
templates/about.html
@@ -1,18 +1,27 @@
-{{define "title"}}me{{end}} +{{define "title"}}about{{end}} {{define "body"}} -<h3>Jes Olson</h3> -<a href="/"><img src="/static/scrombles.png" width="140" alt="pic of a one eyed cat named scrombles"></a> -<p><i>patient anxious mentor, teacher</p></i> -<p><i>loves simplicity and minimalism</p></i> -<p><i>statically compiled binary FREAK</p></i> -<p><i>dota2 + beat saber expert, osu! liker</p></i> -<p><i>existential crisis actor</p></i> -<p><i>loves walking, cats, sushi, crepes, & friends</p></i> +<h3>about</h3> +<img src="/static/scrombles.png" width="140" alt="pic of a one eyed cat named scrombles"> +<pre> +Jes Olson + +existential, kind, anxious, mentor +asexual, tea drinker, sweet tooth +empathic creature living in a van +reductionist +former drug abuser & self harmer +loves poetry and horror films +loves walking, cats, sushi, crepes, & friends +loves smiling & listening & warm sunny walks +</pre> <h3>contact</h3> -<p>email: <a href="mailto:j3s@c3f.net">j3s@c3f.net</a></p> -<p>matrix: <a href="https://matrix.to/#/@j3s:cyberia.club">@j3s:cyberia.club</a></p> -<p>mastodon: <a href="https://merveilles.town/@j3s">@j3s@merveilles.town</a></p> -<p>age pubkey: <a href="/age.html">/age.html</a></p> +<pre> +i'm j3s pretty much everywhere + +email: <code>j3</code><code>s@c</code><code>3</code><code>f.n</code><code>et</code> +matrix: @j3s:cyberia.club</a> +mastodon: j3s@merveilles.town +</pre> <h3>values</h3> <p>i have some values that i try my best to live by.</p> <h4>simplicity</h4>@@ -32,7 +41,7 @@ <li>move fast & break things,</li>
<li>nothing is permanent</li> <li>things should feel fast</li> <h4>reliability</h4> -<li>tools so simple and focused</li> +<li>things so simple and focused</li> <li>they can't help but work correctly</li> <li>and obviously</li> <li>every single time</li>
M
templates/age.html
→
templates/age.html
@@ -1,12 +1,6 @@
-{{define "title"}}jes age tool{{end}} +{{define "title"}}tools/age{{end}} {{ define "body" }} -{{ if . }} -<p>encrypted data:</p> -<pre> -{{ . }} -</pre> -{{ else }} -<h1>age form</h1> +<h3>tools/age</h3> <p>use this form to encrypt age data for people, if you want. my public key is <pre>age12amwzaps3lfy5y7kup5h730d2alfcpxlrnahgxv7u4a877hl9c8s6h2wuf</pre></p> <form method="POST"> <label>age public key</label><br />@@ -15,5 +9,10 @@ <label>text to encrypt</label><br />
<textarea name="message" rows="10" cols="60" required></textarea><br /> <input type="submit"> </form> +{{ if . }} +<h3>result</h3> +<pre> +{{ . }} +</pre> {{ end }} {{ end }}
A
templates/creations.html
@@ -0,0 +1,31 @@
+{{define "title"}}creations{{end}} +{{define "body"}} +<h3>creations</h3> +this page is a showcase for my many creations :3 + +<h4>handy j3s.sh links</h4> +<ul><a href="/ip">/ip - get ur public ip</a></ul> +<ul><a href="/feeds">/feeds - my personal rss reader</a></ul> +<ul><a href="/age.html">/age.html - age encryption tool</a></ul> +<ul><a href="/travel.html">/travel.html - my travel checklist</a></ul> + +<h4>tools</h4> +<ul><a href="https://github.com/biox/shmoji">shmoji | a little shell-based emoji picker</a></ul> +<ul><a href="https://github.com/biox/pa">pa | a simple shell-based password manager that uses age</a></ul> +<ul><a href="https://git.cyberia.club/cyberia/nekobot">nekobot | 🐱 a little kitty robot for matrix</a></ul> +<ul><a href="https://git.j3s.sh/neoarkbot">neoarkbot | a very funny mumble bot</a></ul> +<ul><a href="https://git.j3s.sh/shitchat">shitchat | the worst chat app on planet earth</a></ul> +<ul><a href="https://git.j3s.sh/jrss">jrss | my personal rss feed reader lmao</a></ul> + +<h4>websites</h4> +<ul><a href="https://git.j3s.sh/j3s.sh">j3s.sh | this website</a></ul> +<ul><a href="https://capsul.org">capsul | cyberia.club's VM service</a></ul> +<ul><a href="https://existentialcrisis.sh">existentialcrisis.sh | existential crisis api</a></ul> +<ul><a href="https://poop.is">poop.is | poop-themed link shortener</a> (defunct atm due to domain dispute)</ul> + +<h4>misc</h4> +<ul><a href="https://git.j3s.sh/dotfiles">my dotfiles | neurotically curated</a></ul> + +<p><i>someone on hacker news said that my projects have a "consistent scatalogical theme" and i will never forgive them for making me aware of this</i></p> + +{{end}}
M
templates/index.html
→
templates/index.html
@@ -5,10 +5,6 @@ <marquee><pre>
*whispers* hello friend HACK THE PLANET 🌎 🐡 it's a unix system. i know this. we're all pilgrims and strangers, and nobody knows what the fuck they're doing. never feel certain. sureness is sin. feel good. pride. confidence. effortless. present. feel bad. doubt. anxiety. potential. past. it's you. it's us. we'll make it. of course. we all must make it. because someday it'll be over. like a great big dream. i hope we can wake up together. and laugh at our efforts completely gone. and gaze into each others eyes for eternity. i want so badly to see you again. 💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀💀 </pre></marquee> -<h4>email me pls 🥺</h4> -<p>i love getting email. from anyone. it's my favorite way to talk. email me anything, seriously! it always brightens my day.</p> -<p>i may not respond to everything, but i read everything. i'm going through a lot of life changes rn and don't have much energy. i love you all.</p> -<p>email me at <code>j3</code><code>s@c</code><code>3</code><code>f.n</code><code>et</code></p> <h4>important quotes</h4> <details> <summary>0</summary>@@ -70,8 +66,15 @@ <pre>life is but a dream for the dead
swim in illusion or sink in dread</pre> </details> +<details> + <summary>7</summary> + <pre>wheresoever you go, go with all your heart.</pre> +</details> +<details> + <summary>8</summary> + <pre>despite everything, it's still you.</pre> +</details> <h4>posts from my friends</h4> -<p>note: this list is too big rn, it'll be trimmed to just my friends soon</p> {{- range $feed := .Feeds }} <li> <a href="{{ (index .Items 0).Link }}">{{ (index .Items 0).Title }}</a>
M
templates/layout.html
→
templates/layout.html
@@ -40,14 +40,13 @@
<body class="grayscale"> <div id="header"> <a href="/"><img src="/static/unnamed-puffy.png" height="111" width="140" alt="pic of an unnamed pufferfish, drawn by rekka bellum of kokorobot.ca and hundred rabbits :3"></a> - <h1>jes {{ .TitleWord }}</h1> + <h1>jes {{ randomheaderphrase }}</h1> <p> <a href="/now.html">now</a> <a href="/about.html">about</a> <a href="/reviews.html">reviews</a> <a href="/thoughts.html">thoughts</a> - <a href="/tools.html">tools</a> - <a href="/projects.html">projects</a> + <a href="/creations.html">creations</a> | <a href="https://git.j3s.sh">git -></a> <a href="https://snap.as/j3s">pics -></a>
D
templates/projects.html
@@ -1,15 +0,0 @@
-{{define "title"}}projects i am proud of{{end}} -{{define "body"}} -<h4>projects</h4> -<p><a href="https://git.j3s.sh/j3s.sh">j3s.sh | this website</a></p> -<p><a href="https://github.com/biox/pa">pa | a simple shell-only password manager that uses age</a></p> -<p><a href="https://existentialcrisis.sh">existentialcrisis.sh | existential crisis api</a></p> -<p><a href="https://poop.is">poop.is | poop-themed link shortener</a></p> -<p><a href="https://capsul.org">capsul | cyberia.club's VM service</a></p> -<p><a href="https://git.cyberia.club/cyberia/nekobot">nekobot | 🐱 a small & simple & easy to hack on kitty robot for matrix </a></p> -<p><a href="https://git.j3s.sh/neoarkbot">neoarkbot | a very funny mumble bot</a></p> -<p><a href="https://git.j3s.sh/shitchat">shitchat | the worst chat app on planet earth</a></p> -<p><a href="https://git.j3s.sh/dotfiles">my dotfiles | neurotically curated</a></p> -<p><a href="https://git.j3s.sh/jrss">jrss | my personal rss feed reader lmao</a></p> -<p><i>someone on hacker news said that my projects have a "consistent scatalogical theme" and i will never forgive them for making me aware of this</i></p> -{{end}}
D
templates/tools.html
@@ -1,8 +0,0 @@
-{{define "title"}}little silly tools{{end}} -{{define "body"}} -<p>heres some of my toolz</p> -<p><a href="/ip">/ip - get ur public ip</a></p> -<p><a href="/feeds">my personal rss feed</a></p> -<p><a href="/age.html">age encryptor</a></p> -<p><a href="/travel.html">my travel checklist</a></p> -{{end}}