mirror of
https://github.com/Xevion/glance.git
synced 2025-12-10 16:07:22 -06:00
Additions to monitor and bookmarks widgets
This commit is contained in:
@@ -2,6 +2,7 @@ package widget
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"strings"
|
||||
|
||||
"github.com/glanceapp/glance/internal/assets"
|
||||
)
|
||||
@@ -13,14 +14,33 @@ type Bookmarks struct {
|
||||
Title string `yaml:"title"`
|
||||
Color *HSLColorField `yaml:"color"`
|
||||
Links []struct {
|
||||
Title string `yaml:"title"`
|
||||
URL string `yaml:"url"`
|
||||
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"`
|
||||
} `yaml:"links"`
|
||||
} `yaml:"groups"`
|
||||
}
|
||||
|
||||
func (widget *Bookmarks) Initialize() error {
|
||||
widget.withTitle("Bookmarks").withError(nil)
|
||||
|
||||
for g := range widget.Groups {
|
||||
for l := range widget.Groups[g].Links {
|
||||
if widget.Groups[g].Links[l].Icon == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.HasPrefix(widget.Groups[g].Links[l].Icon, "si:") {
|
||||
icon := strings.TrimPrefix(widget.Groups[g].Links[l].Icon, "si:")
|
||||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
widget.cachedHTML = widget.render(widget, assets.BookmarksTemplate)
|
||||
|
||||
return nil
|
||||
|
||||
@@ -49,6 +49,7 @@ type Monitor struct {
|
||||
Title string `yaml:"title"`
|
||||
Url string `yaml:"url"`
|
||||
IconUrl string `yaml:"icon"`
|
||||
SameTab bool `yaml:"same-tab"`
|
||||
Status *feed.SiteStatus `yaml:"-"`
|
||||
StatusText string `yaml:"-"`
|
||||
StatusStyle string `yaml:"-"`
|
||||
|
||||
Reference in New Issue
Block a user