Add support for gif emus
Peter Sanchez pjs@petersanchez.com
Wed, 11 May 2022 14:15:40 -0600
3 files changed,
13 insertions(+),
8 deletions(-)
M
activity.go
→
activity.go
@@ -1166,7 +1166,7 @@ t["type"] = "Emoji"
t["name"] = e.Name i := junk.New() i["type"] = "Image" - i["mediaType"] = "image/png" + i["mediaType"] = e.Type i["url"] = e.ID t["icon"] = i tags = append(tags, t)@@ -1339,7 +1339,7 @@ t["type"] = "Emoji"
t["name"] = e.Name i := junk.New() i["type"] = "Image" - i["mediaType"] = "image/png" + i["mediaType"] = e.Type i["url"] = e.ID t["icon"] = i tags = append(tags, t)
M
docs/honk.8
→
docs/honk.8
@@ -102,7 +102,7 @@ Image and video files are supported.
Add custom emus (emoji) to the .Pa emus data directory. -PNG files are supported. +PNG and GIF files are supported. .Pp Site CSS may be overridden by creating a .Pa views/local.css
M
fun.go
→
fun.go
@@ -378,18 +378,23 @@
type Emu struct { ID string Name string + Type string } var re_emus = regexp.MustCompile(`:[[:alnum:]_-]+:`) var emucache = cache.New(cache.Options{Filler: func(ename string) (Emu, bool) { fname := ename[1 : len(ename)-1] - _, err := os.Stat(dataDir + "/emus/" + fname + ".png") - if err != nil { - return Emu{Name: ename, ID: ""}, true + exts := []string{".png", ".gif"} + for _, ext := range exts { + _, err := os.Stat(dataDir + "/emus/" + fname + ext) + if err != nil { + continue + } + url := fmt.Sprintf("https://%s/emu/%s%s", serverName, fname, ext) + return Emu{ID: url, Name: ename, Type: "image/" + ext[1:]}, true } - url := fmt.Sprintf("https://%s/emu/%s.png", serverName, fname) - return Emu{ID: url, Name: ename}, true + return Emu{Name: ename, ID: "", Type: "image/png"}, true }, Duration: 10 * time.Second}) func herdofemus(noise string) []Emu {