Can't forget the funzone emus

This commit is contained in:
Peter Sanchez 2022-05-12 13:53:16 -06:00
parent cbeb18b3e7
commit c9fe106c48
2 changed files with 5 additions and 1 deletions

View File

@ -3,8 +3,9 @@
<div class="info"> <div class="info">
<p>Welcome the fun zone! <p>Welcome the fun zone!
<ul> <ul>
{{ $m := .Emuext }}
{{ range .Emus }} {{ range .Emus }}
<li><img class="emu" src="/emu/{{ . }}.png"> :{{ . }}: <li><img class="emu" src="/emu/{{ . }}{{ index $m . }}"> :{{ . }}:
{{ end }} {{ end }}
</ul> </ul>
<ul> <ul>

3
web.go
View File

@ -148,6 +148,7 @@ func homepage(w http.ResponseWriter, r *http.Request) {
func showfunzone(w http.ResponseWriter, r *http.Request) { func showfunzone(w http.ResponseWriter, r *http.Request) {
var emunames, memenames []string var emunames, memenames []string
emuext := make(map[string]string)
dir, err := os.Open(dataDir + "/emus") dir, err := os.Open(dataDir + "/emus")
if err == nil { if err == nil {
emunames, _ = dir.Readdirnames(0) emunames, _ = dir.Readdirnames(0)
@ -156,6 +157,7 @@ func showfunzone(w http.ResponseWriter, r *http.Request) {
for i, e := range emunames { for i, e := range emunames {
if len(e) > 4 { if len(e) > 4 {
emunames[i] = e[:len(e)-4] emunames[i] = e[:len(e)-4]
emuext[emunames[i]] = e[len(e)-4:]
} }
} }
dir, err = os.Open(dataDir + "/memes") dir, err = os.Open(dataDir + "/memes")
@ -167,6 +169,7 @@ func showfunzone(w http.ResponseWriter, r *http.Request) {
sort.Strings(memenames) sort.Strings(memenames)
templinfo := getInfo(r) templinfo := getInfo(r)
templinfo["Emus"] = emunames templinfo["Emus"] = emunames
templinfo["Emuext"] = emuext
templinfo["Memes"] = memenames templinfo["Memes"] = memenames
err = readviews.Execute(w, "funzone.html", templinfo) err = readviews.Execute(w, "funzone.html", templinfo)
if err != nil { if err != nil {