mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-22 10:51:24 +02:00
Add target property on bookmarks widget
This commit is contained in:
parent
94ec286de6
commit
491bc65a38
@ -1520,10 +1520,11 @@ An array of groups which can optionally have a title and a custom color.
|
|||||||
| links | array | yes | |
|
| links | array | yes | |
|
||||||
| same-tab | boolean | no | false |
|
| same-tab | boolean | no | false |
|
||||||
| hide-arrow | boolean | no | false |
|
| hide-arrow | boolean | no | false |
|
||||||
|
| target | string | no | |
|
||||||
|
|
||||||
> [!TIP]
|
> [!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.
|
> You can set `same-tab`, `hide-arrow` and `target` 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 |
|
||||||
@ -1533,6 +1534,7 @@ An array of groups which can optionally have a title and a custom color.
|
|||||||
| icon | string | no | |
|
| icon | string | no | |
|
||||||
| same-tab | boolean | no | false |
|
| same-tab | boolean | no | false |
|
||||||
| hide-arrow | boolean | no | false |
|
| hide-arrow | boolean | no | false |
|
||||||
|
| target | string | no | |
|
||||||
|
|
||||||
`icon`
|
`icon`
|
||||||
|
|
||||||
@ -1556,6 +1558,10 @@ Whether to open the link in the same tab or a new one.
|
|||||||
|
|
||||||
Whether to hide the colored arrow on each link.
|
Whether to hide the colored arrow on each link.
|
||||||
|
|
||||||
|
`target`
|
||||||
|
|
||||||
|
Set a custom value for the link's `target` attribute. Possible values are `_blank`, `_self`, `_parent` and `_top`, you can read more about what they do [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target). This property has precedence over `same-tab`.
|
||||||
|
|
||||||
### ChangeDetection.io
|
### ChangeDetection.io
|
||||||
Display a list watches from changedetection.io.
|
Display a list watches from changedetection.io.
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<img class="bookmarks-icon{{ if .Icon.IsFlatIcon }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy">
|
<img class="bookmarks-icon{{ if .Icon.IsFlatIcon }} flat-icon{{ end }}" src="{{ .Icon.URL }}" alt="" loading="lazy">
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<a href="{{ .URL | safeURL }}" class="bookmarks-link {{ if .HideArrow }}bookmarks-link-no-arrow {{ end }}color-highlight size-h4" {{ if not .SameTab }}target="_blank"{{ end }} rel="noreferrer">{{ .Title }}</a>
|
<a href="{{ .URL | safeURL }}" class="bookmarks-link {{ if .HideArrow }}bookmarks-link-no-arrow {{ end }}color-highlight size-h4" {{ if .Target }}target="{{ .Target }}"{{ end }} rel="noreferrer">{{ .Title }}</a>
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -14,6 +14,7 @@ type bookmarksWidget struct {
|
|||||||
Color *hslColorField `yaml:"color"`
|
Color *hslColorField `yaml:"color"`
|
||||||
SameTab bool `yaml:"same-tab"`
|
SameTab bool `yaml:"same-tab"`
|
||||||
HideArrow bool `yaml:"hide-arrow"`
|
HideArrow bool `yaml:"hide-arrow"`
|
||||||
|
Target string `yaml:"target"`
|
||||||
Links []struct {
|
Links []struct {
|
||||||
Title string `yaml:"title"`
|
Title string `yaml:"title"`
|
||||||
URL string `yaml:"url"`
|
URL string `yaml:"url"`
|
||||||
@ -23,10 +24,11 @@ type bookmarksWidget struct {
|
|||||||
// {{ if not .SameTab }} would return true for any non-nil pointer
|
// {{ 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
|
// which leaves us with no way of checking if the value is true or
|
||||||
// false, hence the duplicated fields below
|
// false, hence the duplicated fields below
|
||||||
SameTabRaw *bool `yaml:"same-tab"`
|
SameTabRaw *bool `yaml:"same-tab"`
|
||||||
SameTab bool `yaml:"-"`
|
SameTab bool `yaml:"-"`
|
||||||
HideArrowRaw *bool `yaml:"hide-arrow"`
|
HideArrowRaw *bool `yaml:"hide-arrow"`
|
||||||
HideArrow bool `yaml:"-"`
|
HideArrow bool `yaml:"-"`
|
||||||
|
Target string `yaml:"target"`
|
||||||
} `yaml:"links"`
|
} `yaml:"links"`
|
||||||
} `yaml:"groups"`
|
} `yaml:"groups"`
|
||||||
}
|
}
|
||||||
@ -49,6 +51,18 @@ func (widget *bookmarksWidget) initialize() error {
|
|||||||
} else {
|
} else {
|
||||||
link.HideArrow = *link.HideArrowRaw
|
link.HideArrow = *link.HideArrowRaw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if link.Target == "" {
|
||||||
|
if group.Target != "" {
|
||||||
|
link.Target = group.Target
|
||||||
|
} else {
|
||||||
|
if link.SameTab {
|
||||||
|
link.Target = ""
|
||||||
|
} else {
|
||||||
|
link.Target = "_blank"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user