From b242186b2983fbd3256b124a59b25e3c34bc7ed1 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 24 Jun 2019 00:31:34 -0400 Subject: [PATCH] funzone for the fun stuff --- docs/changelog.txt | 4 ++++ docs/manual.txt | 6 +++--- honk.go | 29 +++++++++++++++++++++++++++++ views/funzone.html | 16 ++++++++++++++++ views/header.html | 1 + 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 views/funzone.html diff --git a/docs/changelog.txt b/docs/changelog.txt index fcc78c0..15b39b8 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -1,5 +1,9 @@ changelog +-- v + ++ Add the funzone. + -- 0.7.1 + Fix bug preventing unfollow from working. diff --git a/docs/manual.txt b/docs/manual.txt index 0361239..c6ca626 100644 --- a/docs/manual.txt +++ b/docs/manual.txt @@ -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. diff --git a/honk.go b/honk.go index 46f5f4d..e43e8a0 100644 --- a/honk.go +++ b/honk.go @@ -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) diff --git a/views/funzone.html b/views/funzone.html new file mode 100644 index 0000000..cd560ff --- /dev/null +++ b/views/funzone.html @@ -0,0 +1,16 @@ +{{ template "header.html" . }} +
+
+

Welcome the fun zone! +

    +{{ range .Emus }} +
  • :{{ . }}: +{{ end }} +
+
    +{{ range .Memes }} +
  • view {{ . }} +{{ end }} +
+
+
diff --git a/views/header.html b/views/header.html index 0f3974d..67b69e5 100644 --- a/views/header.html +++ b/views/header.html @@ -23,6 +23,7 @@ front xzone zonkzone +funzone account {{ else }}