diff options
author | Frédéric Guillot <fred@miniflux.net> | 2019-12-22 17:47:56 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2019-12-22 18:03:04 -0800 |
commit | cfb6ddfcea3e387a7141d4c65099d2f08bc1732b (patch) | |
tree | c7d0b01d660a5bc7f6683689bf87ca8d4cac1d26 /reader/atom/atom.go | |
parent | 8e1ed8bef3b65cb75c476ebafc1492fea97754d5 (diff) |
Add support for Atom 'replies' link relation
Show comments URL for Atom feeds as per RFC 4685.
See https://tools.ietf.org/html/rfc4685#section-4
Note that only the first link with type "text/html" is taken into consideration.
Diffstat (limited to 'reader/atom/atom.go')
-rw-r--r-- | reader/atom/atom.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/reader/atom/atom.go b/reader/atom/atom.go index 517b43d..677f69a 100644 --- a/reader/atom/atom.go +++ b/reader/atom/atom.go @@ -99,6 +99,7 @@ func (a *atomEntry) Transform() *model.Entry { entry.Content = getContent(a) entry.Title = getTitle(a) entry.Enclosures = getEnclosures(a) + entry.CommentsURL = getRelationURLWithType(a.Links, "replies", "text/html") return entry } @@ -126,6 +127,16 @@ func getRelationURL(links []atomLink, relation string) string { return "" } +func getRelationURLWithType(links []atomLink, relation, contentType string) string { + for _, link := range links { + if strings.ToLower(link.Rel) == relation && strings.ToLower(link.Type) == contentType { + return strings.TrimSpace(link.URL) + } + } + + return "" +} + func getDate(a *atomEntry) time.Time { // Note: The published date represents the original creation date for YouTube feeds. // Example: |