funzone for the fun stuff
Ted Unangst tedu@tedunangst.com
Mon, 24 Jun 2019 00:31:34 -0400
5 files changed,
53 insertions(+),
3 deletions(-)
M
docs/changelog.txt
→
docs/changelog.txt
@@ -1,5 +1,9 @@
changelog +-- v + ++ Add the funzone. + -- 0.7.1 + Fix bug preventing unfollow from working.
M
docs/manual.txt
→
docs/manual.txt
@@ -76,17 +76,17 @@
A custom server message may be set adding a ('servermsg', 'message') entry to the config table using sqlite3. --- emus +-- emus and memes Custom emus may be provided by creating and populating the emus directory. emus may be referenced when composing a honk via colon wrapping. How pleasant. This :example: will be replaced by emus/example.png. --- memes - To save disk space and avoid repeated uploads, the memes directory may be prepopulated with bandwidth wasting reactions and referenced by meme: filename. Example: "Woah. meme: woahface.mp4" + +A list of available emus and memes appears in the funzone. -- hoots
M
honk.go
→
honk.go
@@ -139,6 +139,33 @@ log.Print(err)
} } +func showfunzone(w http.ResponseWriter, r *http.Request) { + var emunames, memenames []string + dir, err := os.Open("emus") + if err == nil { + emunames, _ = dir.Readdirnames(0) + dir.Close() + } + for i, e := range emunames { + if len(e) > 4 { + emunames[i] = e[:len(e)-4] + } + } + dir, err = os.Open("memes") + if err == nil { + memenames, _ = dir.Readdirnames(0) + dir.Close() + } + templinfo := getInfo(r) + templinfo["Emus"] = emunames + templinfo["Memes"] = memenames + err = readviews.Execute(w, "funzone.html", templinfo) + if err != nil { + log.Print(err) + } + +} + func showrss(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"]@@ -1344,6 +1371,7 @@ "views/honkform.html",
"views/honk.html", "views/account.html", "views/about.html", + "views/funzone.html", "views/login.html", "views/xzone.html", "views/header.html",@@ -1390,6 +1418,7 @@
loggedin := mux.NewRoute().Subrouter() loggedin.Use(login.Required) loggedin.HandleFunc("/account", accountpage) + loggedin.HandleFunc("/funzone", showfunzone) loggedin.HandleFunc("/chpass", dochpass) loggedin.HandleFunc("/atme", homepage) loggedin.HandleFunc("/zonkzone", zonkzone)
A
views/funzone.html
@@ -0,0 +1,16 @@
+{{ template "header.html" . }} +<main> +<div class="info"> +<p>Welcome the fun zone! +<ul> +{{ range .Emus }} +<li><img class="emu" src="/emu/{{ . }}.png"> :{{ . }}: +{{ end }} +</ul> +<ul> +{{ range .Memes }} +<li><a href="/meme/{{ . }}">view</a> {{ . }} +{{ end }} +</ul> +</div> +</main>
M
views/header.html
→
views/header.html
@@ -23,6 +23,7 @@ <span><a href="/about">about</a></span>
<span><a href="/front">front</a></span> <span><a href="/xzone">xzone</a></span> <span><a href="/zonkzone">zonkzone</a></span> +<span><a href="/funzone">funzone</a></span> <span><a href="/account">account</a></span> </details> {{ else }}