Skip to content
Open
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
4 changes: 2 additions & 2 deletions atom.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type AtomEntry struct {
Title string `xml:"title"` // required
Updated string `xml:"updated"` // required
Id string `xml:"id"` // required
Category string `xml:"category,omitempty"`
Categories []string `xml:"category,omitempty"`
Content *AtomContent
Rights string `xml:"rights,omitempty"`
Source string `xml:"source,omitempty"`
Expand All @@ -72,7 +72,7 @@ type AtomFeed struct {
Title string `xml:"title"` // required
Id string `xml:"id"` // required
Updated string `xml:"updated"` // required
Category string `xml:"category,omitempty"`
Categories []string `xml:"category,omitempty"`
Icon string `xml:"icon,omitempty"`
Logo string `xml:"logo,omitempty"`
Rights string `xml:"rights,omitempty"` // copyright used
Expand Down
75 changes: 39 additions & 36 deletions consume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var testRssFeedXML = RssFeedXml{
WebMaster: "",
PubDate: "Tue, 30 Oct 2018 23:22:00 GMT",
LastBuildDate: "Tue, 30 Oct 2018 23:22:37 GMT",
Category: "",
Categories: []string{"you say goodbye", "i say hello"},
Generator: "RSS for Node",
Docs: "",
Cloud: "",
Expand All @@ -43,7 +43,7 @@ var testRssFeedXML = RssFeedXml{
Description: "Exercitation ut Lorem sint proident.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Categories: nil,
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941720", IsPermaLink: "true"},
Expand All @@ -57,12 +57,15 @@ var testRssFeedXML = RssFeedXml{
Description: "Ea est do quis fugiat exercitation.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941660", IsPermaLink: "true"},
PubDate: "Tue, 30 Oct 2018 23:21:00 GMT",
Source: "",
Categories: []string{
"i don't know why you say goodbye",
"i say hello, hello, hello-o-o",
},
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941660", IsPermaLink: "true"},
PubDate: "Tue, 30 Oct 2018 23:21:00 GMT",
Source: "",
},
{
XMLName: xml.Name{Space: "", Local: "item"},
Expand All @@ -71,7 +74,7 @@ var testRssFeedXML = RssFeedXml{
Description: "Ipsum velit cillum ad laborum sit nulla exercitation consequat sint veniam culpa veniam voluptate incididunt.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Categories: nil,
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941600", IsPermaLink: "true"},
Expand All @@ -85,7 +88,7 @@ var testRssFeedXML = RssFeedXml{
Description: "Ullamco pariatur aliqua consequat ea veniam id qui incididunt laborum.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Categories: nil,
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941540", IsPermaLink: "true"},
Expand All @@ -99,7 +102,7 @@ var testRssFeedXML = RssFeedXml{
Description: "Velit proident aliquip aliquip anim mollit voluptate laboris voluptate et occaecat occaecat laboris ea nulla.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Categories: nil,
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941480", IsPermaLink: "true"},
Expand All @@ -113,7 +116,7 @@ var testRssFeedXML = RssFeedXml{
Description: "Do in quis mollit consequat id in minim laborum sint exercitation laborum elit officia.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Categories: nil,
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941420", IsPermaLink: "true"},
Expand All @@ -127,7 +130,7 @@ var testRssFeedXML = RssFeedXml{
Description: "Irure id sint ullamco Lorem magna consectetur officia adipisicing duis incididunt.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Categories: nil,
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941360", IsPermaLink: "true"},
Expand All @@ -141,7 +144,7 @@ var testRssFeedXML = RssFeedXml{
Description: "Sunt anim excepteur esse nisi commodo culpa laborum exercitation ad anim ex elit.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Categories: nil,
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941300", IsPermaLink: "true"},
Expand All @@ -155,7 +158,7 @@ var testRssFeedXML = RssFeedXml{
Description: "Excepteur aliquip fugiat ex labore nisi.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Categories: nil,
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941240", IsPermaLink: "true"},
Expand All @@ -169,7 +172,7 @@ var testRssFeedXML = RssFeedXml{
Description: "Id proident adipisicing proident pariatur aute pariatur pariatur dolor dolor in voluptate dolor.",
Content: (*RssContent)(nil),
Author: "",
Category: "",
Categories: nil,
Comments: "",
Enclosure: (*RssEnclosure)(nil),
Guid: &RssGuid{XMLName: xml.Name{Local: "guid"}, Id: "http://example.com/test/1540941180", IsPermaLink: "true"},
Expand All @@ -181,16 +184,16 @@ var testRssFeedXML = RssFeedXml{
}

var testAtomFeedXML = AtomFeed{
XMLName: xml.Name{Space: "", Local: "feed"},
Xmlns: "",
Title: "Lorem ipsum feed for an interval of 1 minutes",
Id: "",
Updated: "",
Category: "",
Icon: "",
Logo: "",
Rights: "",
Subtitle: "",
XMLName: xml.Name{Space: "", Local: "feed"},
Xmlns: "",
Title: "Lorem ipsum feed for an interval of 1 minutes",
Id: "",
Updated: "",
Categories: nil,
Icon: "",
Logo: "",
Rights: "",
Subtitle: "",
Link: &AtomLink{
XMLName: xml.Name{Space: "", Local: "link"},
Href: "",
Expand All @@ -210,7 +213,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:22:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand All @@ -226,7 +229,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:21:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand All @@ -242,7 +245,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:20:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand All @@ -258,7 +261,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:19:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand All @@ -274,7 +277,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:18:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand All @@ -290,7 +293,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:17:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand All @@ -306,7 +309,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:16:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand All @@ -322,7 +325,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:15:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand All @@ -338,7 +341,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:14:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand All @@ -354,7 +357,7 @@ var testAtomFeedXML = AtomFeed{
Title: "Lorem ipsum 2018-10-30T23:13:00+00:00",
Updated: "",
Id: "",
Category: "",
Categories: nil,
Content: (*AtomContent)(nil),
Rights: "",
Source: "",
Expand Down
2 changes: 2 additions & 0 deletions feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Item struct {
Description string // used as description in rss, summary in atom
Id string // used as guid in rss, id in atom
IsPermaLink string // an optional parameter for guid in rss
Categories []string
Updated time.Time
Created time.Time
Enclosure *Enclosure
Expand All @@ -51,6 +52,7 @@ type Feed struct {
Items []*Item
Copyright string
Image *Image
Categories []string
}

// add a new Item to a Feed
Expand Down
10 changes: 6 additions & 4 deletions rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type RssFeed struct {
WebMaster string `xml:"webMaster,omitempty"`
PubDate string `xml:"pubDate,omitempty"` // created or updated
LastBuildDate string `xml:"lastBuildDate,omitempty"` // updated used
Category string `xml:"category,omitempty"`
Categories []string `xml:"category,omitempty"`
Generator string `xml:"generator,omitempty"`
Docs string `xml:"docs,omitempty"`
Cloud string `xml:"cloud,omitempty"`
Expand All @@ -70,9 +70,9 @@ type RssItem struct {
Link string `xml:"link"` // required
Description string `xml:"description"` // required
Content *RssContent
Author string `xml:"author,omitempty"`
Category string `xml:"category,omitempty"`
Comments string `xml:"comments,omitempty"`
Author string `xml:"author,omitempty"`
Categories []string `xml:"category,omitempty"`
Comments string `xml:"comments,omitempty"`
Enclosure *RssEnclosure
Guid *RssGuid // Id used
PubDate string `xml:"pubDate,omitempty"` // created or updated
Expand Down Expand Up @@ -104,6 +104,7 @@ func newRssItem(i *Item) *RssItem {
Title: i.Title,
Description: i.Description,
PubDate: anyTimeFormat(time.RFC1123Z, i.Created, i.Updated),
Categories: i.Categories,
}
if i.Id != "" {
item.Guid = &RssGuid{Id: i.Id, IsPermaLink: i.IsPermaLink}
Expand Down Expand Up @@ -159,6 +160,7 @@ func (r *Rss) RssFeed() *RssFeed {
LastBuildDate: build,
Copyright: r.Copyright,
Image: image,
Categories: r.Categories,
}
for _, i := range r.Items {
channel.Items = append(channel.Items, newRssItem(i))
Expand Down
4 changes: 4 additions & 0 deletions test.rss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<pubDate>Tue, 30 Oct 2018 23:22:00 GMT</pubDate>
<copyright><![CDATA[Michael Bertolacci, licensed under a Creative Commons Attribution 3.0 Unported License.]]></copyright>
<ttl>60</ttl>
<category>you say goodbye</category>
<category>i say hello</category>
<item>
<title><![CDATA[Lorem ipsum 2018-10-30T23:22:00+00:00]]></title>
<description><![CDATA[Exercitation ut Lorem sint proident.]]></description>
Expand All @@ -27,6 +29,8 @@
<guid isPermaLink="true">http://example.com/test/1540941660</guid>
<dc:creator><![CDATA[John Smith]]></dc:creator>
<pubDate>Tue, 30 Oct 2018 23:21:00 GMT</pubDate>
<category>i don't know why you say goodbye</category>
<category>i say hello, hello, hello-o-o</category>
</item>
<item>
<title><![CDATA[Lorem ipsum 2018-10-30T23:20:00+00:00]]></title>
Expand Down
Loading