Sfoglia il codice sorgente

feature: Easier loading of custom-webui icons with simplified paths (#567)

James Read 1 anno fa
parent
commit
765c698a9b
2 ha cambiato i file con 19 aggiunte e 0 eliminazioni
  1. 15 0
      service/internal/config/emoji.go
  2. 4 0
      webui.dev/style.css

+ 15 - 0
service/internal/config/emoji.go

@@ -1,5 +1,10 @@
 package config
 
+import (
+	"fmt"
+	"strings"
+)
+
 var emojis = map[string]string{
 	"poop":        "💩",
 	"smile":       "😀",
@@ -27,5 +32,15 @@ func lookupHTMLIcon(keyToLookup string, defaultIcon string) string {
 		return emoji
 	}
 
+	keyToLookup = expandShortPathToFullPath(keyToLookup)
+
+	return keyToLookup
+}
+
+func expandShortPathToFullPath(keyToLookup string) string {
+	if strings.Contains(keyToLookup, "/") && !strings.HasPrefix(keyToLookup, "<") {
+		return fmt.Sprintf("<img src = \"/custom-webui/%s\" />", keyToLookup)
+	}
+
 	return keyToLookup
 }

+ 4 - 0
webui.dev/style.css

@@ -219,6 +219,10 @@ span.icon {
   font-size: 3em;
 }
 
+span.icon img {
+  width: 1em;
+}
+
 .action-header {
   display: flex;
   align-items: center;