diff options
| author | Christine Dodrill <me@christine.website> | 2017-12-13 10:43:58 -0800 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2017-12-13 11:42:37 -0800 |
| commit | 3a21ef192628f6952eaa981bcdf718a35a4b43c7 (patch) | |
| tree | 9c88a3ddc57ab5014f436ec2c08c96280872632e /vendor/github.com/gorilla/feeds/rss.go | |
| parent | 3b4b6cede9bc30008b0f40989a1564b26e64fd05 (diff) | |
| download | xesite-3a21ef192628f6952eaa981bcdf718a35a4b43c7.tar.xz xesite-3a21ef192628f6952eaa981bcdf718a35a4b43c7.zip | |
convert to go buildpack
Diffstat (limited to 'vendor/github.com/gorilla/feeds/rss.go')
| -rw-r--r-- | vendor/github.com/gorilla/feeds/rss.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/vendor/github.com/gorilla/feeds/rss.go b/vendor/github.com/gorilla/feeds/rss.go index 3381f74..fec5915 100644 --- a/vendor/github.com/gorilla/feeds/rss.go +++ b/vendor/github.com/gorilla/feeds/rss.go @@ -7,7 +7,6 @@ package feeds import ( "encoding/xml" "fmt" - "strconv" "time" ) @@ -94,12 +93,15 @@ func newRssItem(i *Item) *RssItem { Guid: i.Id, PubDate: anyTimeFormat(time.RFC1123Z, i.Created, i.Updated), } + if i.Source != nil { + item.Source = i.Source.Href + } - intLength, err := strconv.ParseInt(i.Link.Length, 10, 64) - - if err == nil && (intLength > 0 || i.Link.Type != "") { - item.Enclosure = &RssEnclosure{Url: i.Link.Href, Type: i.Link.Type, Length: i.Link.Length} + // Define a closure + if i.Enclosure != nil && i.Enclosure.Type != "" && i.Enclosure.Length != "" { + item.Enclosure = &RssEnclosure{Url: i.Enclosure.Url, Type: i.Enclosure.Type, Length: i.Enclosure.Length} } + if i.Author != nil { item.Author = i.Author.Name } @@ -118,6 +120,11 @@ func (r *Rss) RssFeed() *RssFeed { } } + var image *RssImage + if r.Image != nil { + image = &RssImage{Url: r.Image.Url, Title: r.Image.Title, Link: r.Image.Link, Width: r.Image.Width, Height: r.Image.Height} + } + channel := &RssFeed{ Title: r.Title, Link: r.Link.Href, @@ -126,6 +133,7 @@ func (r *Rss) RssFeed() *RssFeed { PubDate: pub, LastBuildDate: build, Copyright: r.Copyright, + Image: image, } for _, i := range r.Items { channel.Items = append(channel.Items, newRssItem(i)) |
