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: hide-title and show-domain-source for rss mainly for FreshRSS #215

Closed
Closed
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
5 changes: 5 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 5 additions & 0 deletions internal/assets/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 9 additions & 2 deletions internal/assets/templates/rss-detailed-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@
<div class="grow min-width-0">
<a class="size-h3 color-primary-if-not-visited" href="{{ .Link }}" target="_blank" rel="noreferrer">{{ .Title }}</a>
<ul class="list-horizontal-text flex-nowrap">
<li {{ dynamicRelativeTimeAttrs .PublishedAt }}></li>
<li class="min-width-0">
<li class="rss-li" {{ dynamicRelativeTimeAttrs .PublishedAt }}></li>
{{ if .ChannelName }}
<li class="rss-li min-width-0">
<a class="block text-truncate" href="{{ .ChannelURL }}" target="_blank" rel="noreferrer">{{ .ChannelName }}</a>
</li>
{{ end }}
{{ if .SourceName }}
<li class="rss-li min-width-0">
<a class="block text-truncate" href="{{ .SourceURL }}" target="_blank" rel="noreferrer">{{ .SourceName }}</a>
</li>
{{ end }}
</ul>
{{ if ne "" .Description }}
<p class="rss-detailed-description text-truncate-2-lines margin-top-10">{{ .Description }}</p>
Expand Down
5 changes: 5 additions & 0 deletions internal/assets/templates/rss-horizontal-cards-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
<a href="{{ .Link }}" title="{{ .Title }}" class="block text-truncate color-primary-if-not-visited" target="_blank" rel="noreferrer">{{ .Title }}</a>
<ul class="list-horizontal-text flex-nowrap margin-top-5">
<li class="shrink-0" {{ dynamicRelativeTimeAttrs .PublishedAt }}></li>
{{ if .ChannelName }}
<li class="min-width-0 text-truncate">{{ .ChannelName }}</li>
{{ end }}
{{ if .SourceName }}
<li class="min-width-0 text-truncate">{{ .SourceName }}</li>
{{ end }}
</ul>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions internal/assets/templates/rss-horizontal-cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
<a href="{{ .Link }}" title="{{ .Title }}" class="text-truncate-3-lines color-primary-if-not-visited margin-top-10 margin-bottom-auto" target="_blank" rel="noreferrer">{{ .Title }}</a>
<ul class="list-horizontal-text flex-nowrap margin-top-7">
<li class="shrink-0" {{ dynamicRelativeTimeAttrs .PublishedAt }}></li>
{{ if .ChannelName }}
<li class="min-width-0 text-truncate">{{ .ChannelName }}</li>
{{ end }}
{{ if .SourceName }}
<li class="min-width-0 text-truncate">{{ .SourceName }}</li>
{{ end }}
</ul>
</div>
</div>
Expand Down
11 changes: 9 additions & 2 deletions internal/assets/templates/rss-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@
<li>
<a class="title size-title-dynamic color-primary-if-not-visited" href="{{ .Link }}" target="_blank" rel="noreferrer" title="{{ .Title }}">{{ .Title }}</a>
<ul class="list-horizontal-text flex-nowrap">
<li {{ dynamicRelativeTimeAttrs .PublishedAt }}></li>
<li class="min-width-0">
<li class="rss-li" {{ dynamicRelativeTimeAttrs .PublishedAt }}></li>
{{ if .ChannelName }}
<li class="rss-li min-width-0">
<a class="block text-truncate" href="{{ .ChannelURL }}" target="_blank" rel="noreferrer">{{ .ChannelName }}</a>
</li>
{{ end }}
{{ if .SourceName }}
<li class="rss-li min-width-0">
<a class="block text-truncate" href="{{ .SourceURL }}" target="_blank" rel="noreferrer">{{ .SourceName }}</a>
</li>
{{ end }}
</ul>
</li>
{{ else }}
Expand Down
17 changes: 16 additions & 1 deletion internal/feed/rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down