mirror of
https://github.com/Xevion/glance.git
synced 2025-12-09 10:07:24 -06:00
Allow setting widget title URL
This commit is contained in:
@@ -21,7 +21,10 @@ type HackerNews struct {
|
||||
}
|
||||
|
||||
func (widget *HackerNews) Initialize() error {
|
||||
widget.withTitle("Hacker News").withCacheDuration(30 * time.Minute)
|
||||
widget.
|
||||
withTitle("Hacker News").
|
||||
withTitleURL("https://news.ycombinator.com/").
|
||||
withCacheDuration(30 * time.Minute)
|
||||
|
||||
if widget.Limit <= 0 {
|
||||
widget.Limit = 15
|
||||
|
||||
@@ -24,6 +24,12 @@ type Lobsters struct {
|
||||
func (widget *Lobsters) Initialize() error {
|
||||
widget.withTitle("Lobsters").withCacheDuration(time.Hour)
|
||||
|
||||
if widget.InstanceURL == "" {
|
||||
widget.withTitleURL("https://lobste.rs")
|
||||
} else {
|
||||
widget.withTitleURL(widget.InstanceURL)
|
||||
}
|
||||
|
||||
if widget.SortBy == "" || (widget.SortBy != "hot" && widget.SortBy != "new") {
|
||||
widget.SortBy = "hot"
|
||||
}
|
||||
|
||||
@@ -54,7 +54,10 @@ func (widget *Reddit) Initialize() error {
|
||||
}
|
||||
}
|
||||
|
||||
widget.withTitle("/r/" + widget.Subreddit).withCacheDuration(30 * time.Minute)
|
||||
widget.
|
||||
withTitle("/r/" + widget.Subreddit).
|
||||
withTitleURL("https://www.reddit.com/r/" + widget.Subreddit + "/").
|
||||
withCacheDuration(30 * time.Minute)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ type TwitchChannels struct {
|
||||
}
|
||||
|
||||
func (widget *TwitchChannels) Initialize() error {
|
||||
widget.withTitle("Twitch Channels").withCacheDuration(time.Minute * 10)
|
||||
widget.
|
||||
withTitle("Twitch Channels").
|
||||
withTitleURL("https://www.twitch.tv/directory/following").
|
||||
withCacheDuration(time.Minute * 10)
|
||||
|
||||
if widget.CollapseAfter == 0 || widget.CollapseAfter < -1 {
|
||||
widget.CollapseAfter = 5
|
||||
|
||||
@@ -18,7 +18,10 @@ type TwitchGames struct {
|
||||
}
|
||||
|
||||
func (widget *TwitchGames) Initialize() error {
|
||||
widget.withTitle("Top games on Twitch").withCacheDuration(time.Minute * 10)
|
||||
widget.
|
||||
withTitle("Top games on Twitch").
|
||||
withTitleURL("https://www.twitch.tv/directory?sort=VIEWER_COUNT").
|
||||
withCacheDuration(time.Minute * 10)
|
||||
|
||||
if widget.Limit <= 0 {
|
||||
widget.Limit = 10
|
||||
|
||||
@@ -119,6 +119,7 @@ const (
|
||||
type widgetBase struct {
|
||||
Type string `yaml:"type"`
|
||||
Title string `yaml:"title"`
|
||||
TitleURL string `yaml:"title-url"`
|
||||
CSSClass string `yaml:"css-class"`
|
||||
CustomCacheDuration DurationField `yaml:"cache"`
|
||||
ContentAvailable bool `yaml:"-"`
|
||||
@@ -186,6 +187,14 @@ func (w *widgetBase) withTitle(title string) *widgetBase {
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *widgetBase) withTitleURL(titleURL string) *widgetBase {
|
||||
if w.TitleURL == "" {
|
||||
w.TitleURL = titleURL
|
||||
}
|
||||
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *widgetBase) withCacheDuration(duration time.Duration) *widgetBase {
|
||||
w.cacheType = cacheTypeDuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user