A self-hosted dashboard that puts all your feeds in one place
Go aggregatordashboarddockerfeed-readergohomelabhomepagemonitoringredditrssrss-readerself-hostedstartpageyoutube
Add Dashboard Icons prefix support
2Q2C0DEd0c4e9d8466a
diff --git a/internal/widget/bookmarks.go b/internal/widget/bookmarks.goindex 962d540..1ad3390 100644--- a/internal/widget/bookmarks.go+++ b/internal/widget/bookmarks.go@@ -13,12 +13,13 @@ type Bookmarks struct {Title string `yaml:"title"`Color *HSLColorField `yaml:"color"`Links []struct {- Title string `yaml:"title"`- URL string `yaml:"url"`- Icon string `yaml:"icon"`- IsSimpleIcon bool `yaml:"-"`- SameTab bool `yaml:"same-tab"`- HideArrow bool `yaml:"hide-arrow"`+ Title string `yaml:"title"`+ URL string `yaml:"url"`+ Icon string `yaml:"icon"`+ IsSimpleIcon bool `yaml:"-"`+ IconSource IconSource `yaml:"-"`+ SameTab bool `yaml:"same-tab"`+ HideArrow bool `yaml:"hide-arrow"`} `yaml:"links"`} `yaml:"groups"`}@@ -33,7 +34,8 @@ func (widget *Bookmarks) Initialize() error {}link := &widget.Groups[g].Links[l]- link.Icon, link.IsSimpleIcon = toSimpleIconIfPrefixed(link.Icon)+ link.Icon, link.IconSource = toRemoteResourceIconIfPrefixed(link.Icon)+ link.IsSimpleIcon = link.IconSource == SimpleIcon}}diff --git a/internal/widget/fields.go b/internal/widget/fields.goindex 9ae1eda..51f7d92 100644--- a/internal/widget/fields.go+++ b/internal/widget/fields.go@@ -27,6 +27,14 @@ type HSLColorField struct {Lightness uint8}+type IconSource uint8++const (+ LocalFile IconSource = iota+ SimpleIcon+ DashboardIcon+)+func (c *HSLColorField) String() string {return fmt.Sprintf("hsl(%d, %d%%, %d%%)", c.Hue, c.Saturation, c.Lightness)}@@ -156,13 +164,24 @@ func (f *OptionalEnvString) String() string {return string(*f)}-func toSimpleIconIfPrefixed(icon string) (string, bool) {- if !strings.HasPrefix(icon, "si:") {- return icon, false+func toRemoteResourceIconIfPrefixed(icon string) (string, IconSource) {+ var prefix, iconstr string++ prefix, iconstr, found := strings.Cut(icon, ":")++ if !found {+ return icon, LocalFile}- icon = strings.TrimPrefix(icon, "si:")- icon = "https://cdnjs.cloudflare.com/ajax/libs/simple-icons/11.14.0/" + icon + ".svg"+ if prefix == "si" {+ icon = "https://cdnjs.cloudflare.com/ajax/libs/simple-icons/11.14.0/" + iconstr + ".svg"+ return icon, SimpleIcon+ }++ if prefix == "di" {+ icon = "https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons@master/svg/" + iconstr + ".svg"+ return icon, DashboardIcon+ }- return icon, true+ return icon, LocalFile}diff --git a/internal/widget/monitor.go b/internal/widget/monitor.goindex 06d7303..5ad4e20 100644--- a/internal/widget/monitor.go+++ b/internal/widget/monitor.go@@ -49,6 +49,7 @@ type Monitor struct {Title string `yaml:"title"`IconUrl string `yaml:"icon"`IsSimpleIcon bool `yaml:"-"`+ IconSource IconSource `yaml:"-"`SameTab bool `yaml:"same-tab"`StatusText string `yaml:"-"`StatusStyle string `yaml:"-"`@@ -61,7 +62,8 @@ func (widget *Monitor) Initialize() error {widget.withTitle("Monitor").withCacheDuration(5 * time.Minute)for i := range widget.Sites {- widget.Sites[i].IconUrl, widget.Sites[i].IsSimpleIcon = toSimpleIconIfPrefixed(widget.Sites[i].IconUrl)+ widget.Sites[i].IconUrl, widget.Sites[i].IconSource = toRemoteResourceIconIfPrefixed(widget.Sites[i].IconUrl)+ widget.Sites[i].IsSimpleIcon = widget.Sites[i].IconSource == SimpleIcon}return nil