From 1aa325de27919f469adc5ee937ef618ee7372500 Mon Sep 17 00:00:00 2001 From: ralphocdol Date: Thu, 12 Sep 2024 06:43:27 +0800 Subject: [PATCH] feat: hide-title and show-domain-source for rss --- docs/configuration.md | 5 +++++ internal/assets/static/main.css | 5 +++++ .../assets/templates/rss-detailed-list.html | 11 +++++++++-- .../templates/rss-horizontal-cards-2.html | 5 +++++ .../assets/templates/rss-horizontal-cards.html | 5 +++++ internal/assets/templates/rss-list.html | 11 +++++++++-- internal/feed/rss.go | 17 ++++++++++++++++- 7 files changed, 54 insertions(+), 5 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index d39c8b5d..7bdd15fa 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -518,10 +518,15 @@ An array of RSS/atom feeds. The title can optionally be changed. | hide-categories | boolean | no | false | Only applicable for `detailed-list` style | | hide-description | boolean | no | false | Only applicable for `detailed-list` style | | item-link-prefix | string | no | | | +| hide-title | boolean | no | false | | +| show-domain-source | boolean | no | false | | ###### `item-link-prefix` If an RSS feed isn't returning item links with a base domain and Glance has failed to automatically detect the correct domain you can manually add a prefix to each link with this property. +###### `show-domain-source` +Useful when using FreshRSS' user queries since it shows the query name instead of the actual source + ##### `limit` The maximum number of articles to show. diff --git a/internal/assets/static/main.css b/internal/assets/static/main.css index c2a4acd4..56156847 100644 --- a/internal/assets/static/main.css +++ b/internal/assets/static/main.css @@ -795,6 +795,11 @@ details[open] .summary::after { top: 0.1rem; } +.list-horizontal-text > .rss-li { + display: inline-flex; + align-items: center; +} + .header-container { margin-top: calc(var(--widget-gap) / 2); --header-height: 45px; diff --git a/internal/assets/templates/rss-detailed-list.html b/internal/assets/templates/rss-detailed-list.html index 311923da..2902eff4 100644 --- a/internal/assets/templates/rss-detailed-list.html +++ b/internal/assets/templates/rss-detailed-list.html @@ -16,10 +16,17 @@
{{ .Title }} {{ if ne "" .Description }}

{{ .Description }}

diff --git a/internal/assets/templates/rss-horizontal-cards-2.html b/internal/assets/templates/rss-horizontal-cards-2.html index 0404fce1..7e0ed358 100644 --- a/internal/assets/templates/rss-horizontal-cards-2.html +++ b/internal/assets/templates/rss-horizontal-cards-2.html @@ -19,7 +19,12 @@ {{ .Title }}
diff --git a/internal/assets/templates/rss-horizontal-cards.html b/internal/assets/templates/rss-horizontal-cards.html index 0f79b567..7de006e7 100644 --- a/internal/assets/templates/rss-horizontal-cards.html +++ b/internal/assets/templates/rss-horizontal-cards.html @@ -19,7 +19,12 @@ {{ .Title }} diff --git a/internal/assets/templates/rss-list.html b/internal/assets/templates/rss-list.html index 0b6222a6..1569bf64 100644 --- a/internal/assets/templates/rss-list.html +++ b/internal/assets/templates/rss-list.html @@ -6,10 +6,17 @@
  • {{ .Title }}
  • {{ else }} diff --git a/internal/feed/rss.go b/internal/feed/rss.go index ec6ab2ed..f4b71aa0 100644 --- a/internal/feed/rss.go +++ b/internal/feed/rss.go @@ -24,6 +24,8 @@ type RSSFeedItem struct { Categories []string Description string PublishedAt time.Time + SourceName string + SourceURL string } // doesn't cover all cases but works the vast majority of the time @@ -63,6 +65,8 @@ type RSSFeedRequest struct { HideDescription bool `yaml:"hide-description"` ItemLinkPrefix string `yaml:"item-link-prefix"` IsDetailed bool `yaml:"-"` + HideTitle bool `yaml:"hide-title"` + ShowSource bool `yaml:"show-domain-source"` } type RSSFeedItems []RSSFeedItem @@ -150,7 +154,18 @@ func getItemsFromRSSFeedTask(request RSSFeedRequest) ([]RSSFeedItem, error) { } } - if request.Title != "" { + if request.ShowSource { + parsedUrl, err := url.Parse(rssItem.Link) + if err != nil { + return nil, err + } + rssItem.SourceName = parsedUrl.Host + rssItem.SourceURL = parsedUrl.Scheme + "://" + parsedUrl.Host + } + + if request.HideTitle { + rssItem.ChannelName = "" + } else if request.Title != "" { rssItem.ChannelName = request.Title } else { rssItem.ChannelName = feed.Title