Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add public-url parameter to rss widget feeds #322

Open
wants to merge 1 commit into
base: release/v0.7.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,16 @@ An array of RSS/atom feeds. The title can optionally be changed.
| Name | Type | Required | Default | Notes |
| ---- | ---- | -------- | ------- | ----- |
| url | string | yes | | |
| public-url | string | no | | |
| title | string | no | the title provided by the feed | |
| 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 | | |
| headers | key (string) & value (string) | no | | |

###### `public-url`
An alternate url used when the RSS feed source is displayed as a clickable link.

###### `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.

Expand Down
5 changes: 5 additions & 0 deletions internal/glance/widget-rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func shortenFeedDescriptionLen(description string, maxLen int) string {

type rssFeedRequest struct {
URL string `yaml:"url"`
PublicURL string `yaml:"public-url"`
Title string `yaml:"title"`
HideCategories bool `yaml:"hide-categories"`
HideDescription bool `yaml:"hide-description"`
Expand Down Expand Up @@ -199,6 +200,10 @@ func fetchItemsFromRSSFeedTask(request rssFeedRequest) ([]rssFeedItem, error) {
ChannelURL: feed.Link,
}

if request.PublicURL != "" {
rssItem.ChannelURL = request.PublicURL
}

if request.ItemLinkPrefix != "" {
rssItem.Link = request.ItemLinkPrefix + item.Link
} else if strings.HasPrefix(item.Link, "http://") || strings.HasPrefix(item.Link, "https://") {
Expand Down