quick add a list of all combos
Ted Unangst tedu@tedunangst.com
Tue, 30 Apr 2019 18:48:13 -0400
3 files changed,
34 insertions(+),
0 deletions(-)
M
honk.go
→
honk.go
@@ -975,6 +975,23 @@ log.Print(err)
} } +func showcombos(w http.ResponseWriter, r *http.Request) { + userinfo := login.GetUserInfo(r) + templinfo := getInfo(r) + honkers := gethonkers(userinfo.UserID) + var combos []string + for _, h := range honkers { + combos = append(combos, h.Combos...) + } + combos = oneofakind(combos) + sort.Strings(combos) + templinfo["Combos"] = combos + err := readviews.Execute(w, "combos.html", templinfo) + if err != nil { + log.Print(err) + } +} + var handfull = make(map[string]string) var handlock sync.Mutex@@ -1210,6 +1227,7 @@ readviews = templates.Load(debug,
"views/honkpage.html", "views/honkers.html", "views/zonkers.html", + "views/combos.html", "views/honkform.html", "views/honk.html", "views/login.html",@@ -1263,6 +1281,7 @@ loggedin.Handle("/saveuser", login.CSRFWrap("saveuser", http.HandlerFunc(saveuser)))
loggedin.HandleFunc("/honkers", showhonkers) loggedin.HandleFunc("/h/{name:[[:alnum:]]+}", showhonker) loggedin.HandleFunc("/c/{name:[[:alnum:]]+}", showcombo) + loggedin.HandleFunc("/c", showcombos) loggedin.Handle("/savehonker", login.CSRFWrap("savehonker", http.HandlerFunc(savehonker))) err = http.Serve(listener, mux)
A
views/combos.html
@@ -0,0 +1,14 @@
+{{ template "header.html" . }} +<main> +<div class="info"> +<p>combos +</div> +{{ range .Combos }} +<section class="honk"> +<header> +<p style="font-size: 1.8em">{{ . }} +</header> +<p>honks: <a href="/c/{{ . }}" rel=noreferrer>{{ . }}</a> +</section> +{{ end }} +</main>
M
views/header.html
→
views/header.html
@@ -16,6 +16,7 @@ {{ if .UserInfo }}
<span><a href="/atme">@me</a></span> <span><a href="/u/{{ .UserInfo.Username }}">{{ .UserInfo.Username }}</a></span> <span><a href="/honkers">honkers</a></span> +<span><a href="/c">combos</a></span> <span><a href="/killzone">killzone</a></span> <span><a href="/logout?CSRF={{ .LogoutCSRF }}">logout</a></span> {{ else }}