Add Dashboard Icons prefix support

- defined new type IconSource and constants, presently supporting:
  - LocalFile
  - SimpleIcon
  - DashboardIcon
- added new field to bookmarks and monitors to hold IconSource
- adjusted IsSimpleIcon to get truthiness from IconSource field
- generalised `toSimpleIconIfPrefixed` into `toRemoteResourceIconIfPrefixed`,
  adding support for `walkxcode`'s dashboard icons via CDN (svg)
This commit is contained in:
2Q2C0DE
2024-11-14 17:35:14 +11:00
committed by Doc Em
parent d90d39933a
commit d0c4e9d846
3 changed files with 37 additions and 14 deletions

View File

@@ -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
}
}