mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 18:31:24 +02:00
Allow setting same-tab and hide-arrow on bookmark groups
This commit is contained in:
parent
f89fc2ee1d
commit
eb86c3fb79
@ -1481,6 +1481,12 @@ An array of groups which can optionally have a title and a custom color.
|
|||||||
| title | string | no | |
|
| title | string | no | |
|
||||||
| color | HSL | no | the primary color of the theme |
|
| color | HSL | no | the primary color of the theme |
|
||||||
| links | array | yes | |
|
| links | array | yes | |
|
||||||
|
| same-tab | boolean | no | false |
|
||||||
|
| hide-arrow | boolean | no | false |
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
>
|
||||||
|
> You can set `same-tab` and `hide-arrow` either on the group which will apply them to all links in that group, or on each individual link which will override the value set on the group.
|
||||||
|
|
||||||
###### Properties for each link
|
###### Properties for each link
|
||||||
| Name | Type | Required | Default |
|
| Name | Type | Required | Default |
|
||||||
|
@ -10,20 +10,48 @@ type bookmarksWidget struct {
|
|||||||
widgetBase `yaml:",inline"`
|
widgetBase `yaml:",inline"`
|
||||||
cachedHTML template.HTML `yaml:"-"`
|
cachedHTML template.HTML `yaml:"-"`
|
||||||
Groups []struct {
|
Groups []struct {
|
||||||
Title string `yaml:"title"`
|
Title string `yaml:"title"`
|
||||||
Color *hslColorField `yaml:"color"`
|
Color *hslColorField `yaml:"color"`
|
||||||
Links []struct {
|
SameTab bool `yaml:"same-tab"`
|
||||||
Title string `yaml:"title"`
|
HideArrow bool `yaml:"hide-arrow"`
|
||||||
URL string `yaml:"url"`
|
Links []struct {
|
||||||
Icon customIconField `yaml:"icon"`
|
Title string `yaml:"title"`
|
||||||
SameTab bool `yaml:"same-tab"`
|
URL string `yaml:"url"`
|
||||||
HideArrow bool `yaml:"hide-arrow"`
|
Icon customIconField `yaml:"icon"`
|
||||||
|
// we need a pointer to bool to know whether a value was provided,
|
||||||
|
// however there's no way to dereference a pointer in a template so
|
||||||
|
// {{ if not .SameTab }} would return true for any non-nil pointer
|
||||||
|
// which leaves us with no way of checking if the value is true or
|
||||||
|
// false, hence the duplicated fields below
|
||||||
|
SameTabRaw *bool `yaml:"same-tab"`
|
||||||
|
SameTab bool `yaml:"-"`
|
||||||
|
HideArrowRaw *bool `yaml:"hide-arrow"`
|
||||||
|
HideArrow bool `yaml:"-"`
|
||||||
} `yaml:"links"`
|
} `yaml:"links"`
|
||||||
} `yaml:"groups"`
|
} `yaml:"groups"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *bookmarksWidget) initialize() error {
|
func (widget *bookmarksWidget) initialize() error {
|
||||||
widget.withTitle("Bookmarks").withError(nil)
|
widget.withTitle("Bookmarks").withError(nil)
|
||||||
|
|
||||||
|
for g := range widget.Groups {
|
||||||
|
group := &widget.Groups[g]
|
||||||
|
for l := range group.Links {
|
||||||
|
link := &group.Links[l]
|
||||||
|
if link.SameTabRaw == nil {
|
||||||
|
link.SameTab = group.SameTab
|
||||||
|
} else {
|
||||||
|
link.SameTab = *link.SameTabRaw
|
||||||
|
}
|
||||||
|
|
||||||
|
if link.HideArrowRaw == nil {
|
||||||
|
link.HideArrow = group.HideArrow
|
||||||
|
} else {
|
||||||
|
link.HideArrow = *link.HideArrowRaw
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
widget.cachedHTML = widget.renderTemplate(widget, bookmarksWidgetTemplate)
|
widget.cachedHTML = widget.renderTemplate(widget, bookmarksWidgetTemplate)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user