Fixing emu loader to work with gifs
2 files changed, 16 insertions(+), 7 deletions(-)

M views/emus.html
M web.go
M views/emus.html +1 -1
@@ 1,1 1,1 @@ 
-{{ range .Emus }}<img class="emu" alt=":{{.}}:" onclick="addemu(':{{.}}:');" src="/emu/{{ . }}.png">{{ end }}
+{{ range .Emus }}<img class="emu" alt=":{{.Name}}:" onclick="addemu(':{{.Name}}:');" src="{{ .ID }}">{{ end }}

          
M web.go +15 -6
@@ 50,7 50,7 @@ var honkSep = "h"
 
 var develMode = false
 
-var emunames []string
+var allemus []Emu
 
 func getuserstyle(u *login.UserInfo) template.CSS {
 	if u == nil {

          
@@ 151,7 151,7 @@ func homepage(w http.ResponseWriter, r *
 
 func showemus(w http.ResponseWriter, r *http.Request) {
 	templinfo := getInfo(r)
-	templinfo["Emus"] = emunames
+	templinfo["Emus"] = allemus
 	err := readviews.Execute(w, "emus.html", templinfo)
 	if err != nil {
 		elog.Print(err)

          
@@ 2431,18 2431,27 @@ func bgmonitor() {
 }
 
 func emuinit() {
+	var emunames []string
 	dir, err := os.Open(dataDir + "/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]
+		if len(e) <= 4 {
+			continue
 		}
+		ext := e[len(e)-4:]
+		emu := Emu{
+			ID:   fmt.Sprintf("/emu/%s", e),
+			Name: e[:len(e)-4],
+			Type: "image/" + ext[1:],
+		}
+		allemus = append(allemus, emu)
+		emunames[i] = e[:len(e)-4]
 	}
-	sort.Slice(emunames, func(i, j int) bool {
-		return emunames[i] < emunames[j]
+	sort.Slice(allemus, func(i, j int) bool {
+		return allemus[i].Name < allemus[j].Name
 	})
 }