6f5c6b9858ba — Peter Sanchez 6 months ago
Add svg support for emus
1 files changed, 6 insertions(+), 2 deletions(-)

M fun.go
M fun.go +6 -2
@@ 471,7 471,7 @@ var re_emus = regexp.MustCompile(`:[[:al
 
 var emucache = gencache.New(gencache.Options[string, *Emu]{Fill: func(ename string) (*Emu, bool) {
 	fname := ename[1 : len(ename)-1]
-	exts := []string{".png", ".gif"}
+	exts := []string{".png", ".gif", ".svg"}
 	for _, ext := range exts {
 		_, err := os.Stat(dataDir + "/emus/" + fname + ext)
 		if err != nil {

          
@@ 481,7 481,11 @@ var emucache = gencache.New(gencache.Opt
 		if develMode {
 			url = fmt.Sprintf("/emu/%s%s", fname, ext)
 		}
-		return &Emu{ID: url, Name: ename, Type: "image/" + ext[1:]}, true
+		e := &Emu{ID: url, Name: ename, Type: "image/" + ext[1:]}
+		if ext == ".svg" {
+			e.Type = e.Type + "+xml" // image/svg+xml
+		}
+		return e, true
 	}
 	return nil, true
 }, Duration: 10 * time.Second})