Don't hardcode emote size

Replaced the hardcoded height attribute in the emote img tags with a
class attribute.  This allows the emotes to be resized with the change
of a CSS value instead of recompiling the server.

Resolves #150
This commit is contained in:
Zorchenhimer 2021-01-16 15:36:44 -05:00
parent d06e2251a4
commit f76d184173
3 changed files with 24 additions and 20 deletions

View File

@ -48,7 +48,7 @@ func (em EmotesMap) Add(fullpath string) EmotesMap {
}
func EmoteToHtml(file, title string) string {
return fmt.Sprintf(`<img src="%s" height="28px" title="%s" />`, file, title)
return fmt.Sprintf(`<img src="%s" class="emote" title="%s" />`, file, title)
}
// Used with a regexp.ReplaceAllStringFunc() call. Needs to lookup the value as it
@ -56,7 +56,7 @@ func EmoteToHtml(file, title string) string {
func emoteToHmtl2(key string) string {
key = strings.Trim(key, ":[]")
if val, ok := Emotes[key]; ok {
return fmt.Sprintf(`<img src="%s" height="28px" title="%s" />`, val, key)
return fmt.Sprintf(`<img src="%s" class="emote" title="%s" />`, val, key)
}
return key
}

View File

@ -6,31 +6,31 @@ import (
)
var data_good = map[string]string{
"one": `<img src="/emotes/one.png" height="28px" title="one" />`,
"two": `<img src="/emotes/two.png" height="28px" title="two" />`,
"three": `<img src="/emotes/three.gif" height="28px" title="three" />`,
"one": `<img src="/emotes/one.png" class="emote" title="one" />`,
"two": `<img src="/emotes/two.png" class="emote" title="two" />`,
"three": `<img src="/emotes/three.gif" class="emote" title="three" />`,
":one:": `<img src="/emotes/one.png" height="28px" title="one" />`,
":two:": `<img src="/emotes/two.png" height="28px" title="two" />`,
":three:": `<img src="/emotes/three.gif" height="28px" title="three" />`,
":one:": `<img src="/emotes/one.png" class="emote" title="one" />`,
":two:": `<img src="/emotes/two.png" class="emote" title="two" />`,
":three:": `<img src="/emotes/three.gif" class="emote" title="three" />`,
":one::one:": `<img src="/emotes/one.png" height="28px" title="one" /><img src="/emotes/one.png" height="28px" title="one" />`,
":one:one:": `<img src="/emotes/one.png" height="28px" title="one" />one:`,
":one::one:": `<img src="/emotes/one.png" class="emote" title="one" /><img src="/emotes/one.png" class="emote" title="one" />`,
":one:one:": `<img src="/emotes/one.png" class="emote" title="one" />one:`,
"oneone": "oneone",
"one:one:": `one<img src="/emotes/one.png" height="28px" title="one" />`,
"one:one:": `one<img src="/emotes/one.png" class="emote" title="one" />`,
"[one]": `<img src="/emotes/one.png" height="28px" title="one" />`,
"[two]": `<img src="/emotes/two.png" height="28px" title="two" />`,
"[three]": `<img src="/emotes/three.gif" height="28px" title="three" />`,
"[one]": `<img src="/emotes/one.png" class="emote" title="one" />`,
"[two]": `<img src="/emotes/two.png" class="emote" title="two" />`,
"[three]": `<img src="/emotes/three.gif" class="emote" title="three" />`,
"[one][one]": `<img src="/emotes/one.png" height="28px" title="one" /><img src="/emotes/one.png" height="28px" title="one" />`,
"[one]one": `<img src="/emotes/one.png" height="28px" title="one" />one`,
"[one][one]": `<img src="/emotes/one.png" class="emote" title="one" /><img src="/emotes/one.png" class="emote" title="one" />`,
"[one]one": `<img src="/emotes/one.png" class="emote" title="one" />one`,
":one: two [three]": `<img src="/emotes/one.png" height="28px" title="one" /> <img src="/emotes/two.png" height="28px" title="two" /> <img src="/emotes/three.gif" height="28px" title="three" />`,
":one: two [three]": `<img src="/emotes/one.png" class="emote" title="one" /> <img src="/emotes/two.png" class="emote" title="two" /> <img src="/emotes/three.gif" class="emote" title="three" />`,
"nope one what": `nope <img src="/emotes/one.png" height="28px" title="one" /> what`,
"nope :two: what": `nope <img src="/emotes/two.png" height="28px" title="two" /> what`,
"nope [three] what": `nope <img src="/emotes/three.gif" height="28px" title="three" /> what`,
"nope one what": `nope <img src="/emotes/one.png" class="emote" title="one" /> what`,
"nope :two: what": `nope <img src="/emotes/two.png" class="emote" title="two" /> what`,
"nope [three] what": `nope <img src="/emotes/three.gif" class="emote" title="three" /> what`,
}
var data_wrapped = map[string]string{

View File

@ -124,6 +124,10 @@ input[type=text] {
width: 112px;
}
.emote {
height: 28px;
}
.notice {
color: #595959;
font-size: 75%;