Add support for resolving relative feed URLs
I think this is probably more like a bug in github.com/SlyMarbo/rss but at least this fixes it for now
This commit is contained in:
parent
adede4451d
commit
6d79d2e375
1 changed files with 16 additions and 2 deletions
18
openring.go
18
openring.go
|
@ -109,6 +109,14 @@ func main() {
|
||||||
if len(items) > *perSource {
|
if len(items) > *perSource {
|
||||||
items = items[:*perSource]
|
items = items[:*perSource]
|
||||||
}
|
}
|
||||||
|
base, err := url.Parse(feed.UpdateURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("failed parsing update URL of the feed")
|
||||||
|
}
|
||||||
|
feedLink, _ := url.Parse(feed.Link)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("failed parsing canonical feed URL of the feed")
|
||||||
|
}
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
raw_summary := item.Summary
|
raw_summary := item.Summary
|
||||||
if len(raw_summary) == 0 {
|
if len(raw_summary) == 0 {
|
||||||
|
@ -116,13 +124,19 @@ func main() {
|
||||||
}
|
}
|
||||||
summary := runewidth.Truncate(
|
summary := runewidth.Truncate(
|
||||||
policy.Sanitize(raw_summary), *summaryLen, "…")
|
policy.Sanitize(raw_summary), *summaryLen, "…")
|
||||||
|
|
||||||
|
itemLink, _ := url.Parse(item.Link)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("failed parsing article URL of the feed item")
|
||||||
|
}
|
||||||
|
|
||||||
articles = append(articles, &Article{
|
articles = append(articles, &Article{
|
||||||
Date: item.Date,
|
Date: item.Date,
|
||||||
SourceLink: feed.Link,
|
SourceLink: base.ResolveReference(feedLink).String(),
|
||||||
SourceTitle: feed.Title,
|
SourceTitle: feed.Title,
|
||||||
Summary: template.HTML(summary),
|
Summary: template.HTML(summary),
|
||||||
Title: item.Title,
|
Title: item.Title,
|
||||||
Link: item.Link,
|
Link: base.ResolveReference(itemLink).String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue