mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-22 19:01:25 +02:00
Make converting string to simple icon url reusable
This commit is contained in:
parent
9c69509a19
commit
b63b5eb262
@ -2,7 +2,6 @@ package widget
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/glanceapp/glance/internal/assets"
|
"github.com/glanceapp/glance/internal/assets"
|
||||||
)
|
)
|
||||||
@ -34,11 +33,8 @@ func (widget *Bookmarks) Initialize() error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(widget.Groups[g].Links[l].Icon, "si:") {
|
link := &widget.Groups[g].Links[l]
|
||||||
icon := strings.TrimPrefix(widget.Groups[g].Links[l].Icon, "si:")
|
link.Icon, link.IsSimpleIcon = toSimpleIconIfPrefixed(link.Icon)
|
||||||
widget.Groups[g].Links[l].IsSimpleIcon = true
|
|
||||||
widget.Groups[g].Links[l].Icon = "https://cdnjs.cloudflare.com/ajax/libs/simple-icons/11.14.0/" + icon + ".svg"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
@ -150,3 +151,14 @@ func (f *OptionalEnvString) UnmarshalYAML(node *yaml.Node) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func toSimpleIconIfPrefixed(icon string) (string, bool) {
|
||||||
|
if !strings.HasPrefix(icon, "si:") {
|
||||||
|
return icon, false
|
||||||
|
}
|
||||||
|
|
||||||
|
icon = strings.TrimPrefix(icon, "si:")
|
||||||
|
icon = "https://cdnjs.cloudflare.com/ajax/libs/simple-icons/11.14.0/" + icon + ".svg"
|
||||||
|
|
||||||
|
return icon, true
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user