From f219ac0dcadb467c9adf660f6c285c402b88b748 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Mon, 19 Sep 2022 23:41:35 +0300 Subject: [PATCH] Manual selecting emojis on page by codes contain --- renderer/renderer.go | 11 +++++++++++ templates/emoji.tmpl | 2 ++ 2 files changed, 13 insertions(+) diff --git a/renderer/renderer.go b/renderer/renderer.go index 7afeb14..cef03bb 100644 --- a/renderer/renderer.go +++ b/renderer/renderer.go @@ -40,6 +40,16 @@ type TemplateData struct { Ctx *Context } + +func allowed_emoji_page(emoj string, codes ...string) bool { + for _, code := range codes { + if strings.Contains(emoj, code) { + return true + } + } + return false +} + func emojiHTML(e mastodon.Emoji, height string) string { return `:` + e.ShortCode + `:` } @@ -142,6 +152,7 @@ func NewRenderer(templateGlobPattern string) (r *renderer, err error) { t := template.New("default") t, err = t.Funcs(template.FuncMap{ "EmojiFilter": emojiFilter, + "Allowed_emoji_page": allowed_emoji_page, "StatusContentFilter": statusContentFilter, "DisplayInteractionCount": displayInteractionCount, "TimeSince": timeSince, diff --git a/templates/emoji.tmpl b/templates/emoji.tmpl index 4b07e81..e3ba8a0 100644 --- a/templates/emoji.tmpl +++ b/templates/emoji.tmpl @@ -4,6 +4,7 @@
{{range .Emojis}} + {{if Allowed_emoji_page .ShortCode "blobfox" "senko" "shiro"}}
{{.ShortCode}} @@ -11,6 +12,7 @@
{{end}} + {{end}}
{{template "footer.tmpl"}}