quick add a list of all combos

This commit is contained in:
Ted Unangst 2019-04-30 18:48:13 -04:00
parent 0f329cfea1
commit 36b3f6e1e1
3 changed files with 34 additions and 0 deletions

19
honk.go
View File

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

14
views/combos.html Normal file
View File

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

View File

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