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/atom.go | |
| parent | 3b4b6cede9bc30008b0f40989a1564b26e64fd05 (diff) | |
| download | xesite-3a21ef192628f6952eaa981bcdf718a35a4b43c7.tar.xz xesite-3a21ef192628f6952eaa981bcdf718a35a4b43c7.zip | |
convert to go buildpack
Diffstat (limited to 'vendor/github.com/gorilla/feeds/atom.go')
| -rw-r--r-- | vendor/github.com/gorilla/feeds/atom.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/vendor/github.com/gorilla/feeds/atom.go b/vendor/github.com/gorilla/feeds/atom.go index 512976b..6b0ddcb 100644 --- a/vendor/github.com/gorilla/feeds/atom.go +++ b/vendor/github.com/gorilla/feeds/atom.go @@ -4,7 +4,6 @@ import ( "encoding/xml" "fmt" "net/url" - "strconv" "time" ) @@ -52,11 +51,12 @@ type AtomEntry struct { Source string `xml:"source,omitempty"` Published string `xml:"published,omitempty"` Contributor *AtomContributor - Link *AtomLink // required if no child 'content' elements + Links []AtomLink // required if no child 'content' elements Summary *AtomSummary // required if content has src or content is base64 Author *AtomAuthor // required if feed lacks an author } +// Multiple links with different rel can coexist type AtomLink struct { //Atom 1.0 <link rel="enclosure" type="audio/mpeg" title="MP3" href="http://www.example.org/myaudiofile.mp3" length="1234" /> XMLName xml.Name `xml:"link"` @@ -110,19 +110,20 @@ func newAtomEntry(i *Item) *AtomEntry { name, email = i.Author.Name, i.Author.Email } + link_rel := i.Link.Rel + if link_rel == "" { + link_rel = "alternate" + } x := &AtomEntry{ Title: i.Title, - Link: &AtomLink{Href: i.Link.Href, Rel: i.Link.Rel, Type: i.Link.Type}, + Links: []AtomLink{{Href: i.Link.Href, Rel: link_rel, Type: i.Link.Type}}, Content: c, Id: id, Updated: anyTimeFormat(time.RFC3339, i.Updated, i.Created), } - intLength, err := strconv.ParseInt(i.Link.Length, 10, 64) - - if err == nil && (intLength > 0 || i.Link.Type != "") { - i.Link.Rel = "enclosure" - x.Link = &AtomLink{Href: i.Link.Href, Rel: i.Link.Rel, Type: i.Link.Type, Length: i.Link.Length} + if i.Enclosure != nil && link_rel != "enclosure" { + x.Links = append(x.Links, AtomLink{Href: i.Enclosure.Url, Rel: "enclosure", Type: i.Enclosure.Type, Length: i.Enclosure.Length}) } if len(name) > 0 || len(email) > 0 { |
