funzone for the fun stuff

This commit is contained in:
Ted Unangst 2019-06-24 00:31:34 -04:00
parent 1181ee6acf
commit b242186b29
5 changed files with 53 additions and 3 deletions

View File

@ -1,5 +1,9 @@
changelog
-- v
+ Add the funzone.
-- 0.7.1
+ Fix bug preventing unfollow from working.

View File

@ -76,18 +76,18 @@ Custom CSS may be provided by creating a views/local.css file.
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
Link and inline a hoot from that other bird site.

29
honk.go
View File

@ -139,6 +139,33 @@ func homepage(w http.ResponseWriter, r *http.Request) {
}
}
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 @@ func serve() {
"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 @@ func serve() {
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)

16
views/funzone.html Normal file
View File

@ -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>

View File

@ -23,6 +23,7 @@
<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 }}