From f89ed305d92114eb9010d2973a0971f0b2320da2 Mon Sep 17 00:00:00 2001 From: Jason Moiron Date: Wed, 16 Jan 2013 21:03:48 -0500 Subject: [PATCH] add copyright info, add ToXML support for RssFeed & AtomFeed (provided you only want to create those), hide more empty members of atom feed --- atom.go | 10 ++++++++-- feed_test.go | 1 + rss.go | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/atom.go b/atom.go index b9bdc44..e3889e1 100644 --- a/atom.go +++ b/atom.go @@ -52,8 +52,8 @@ type AtomFeed struct { XMLName xml.Name `xml:"feed"` Xmlns string `xml:"xmlns,attr"` Category string `xml:"category,omitempty"` - Icon string `xml:"icon"` - Logo string `xml:"logo"` + Icon string `xml:"icon,omitempty"` + Logo string `xml:"logo,omitempty"` Rights string `xml:"rights,omitempty"` Title string `xml:"title"` Subtitle string `xml:"subtitle,omitempty"` @@ -113,9 +113,15 @@ func (a *Atom) FeedXml() interface{} { Subtitle: a.Description, Id: a.Link.Href, Updated: updated, + Rights: a.Copyright, } for _, e := range a.Items { feed.Entries = append(feed.Entries, newAtomEntry(e)) } return feed } + +// support the ToXML function for AtomFeeds directly +func (a *AtomFeed) FeedXml() interface{} { + return a +} diff --git a/feed_test.go b/feed_test.go index 7349369..3ce437a 100644 --- a/feed_test.go +++ b/feed_test.go @@ -14,6 +14,7 @@ func TestFeed(t *testing.T) { Description: "discussion about tech, footie, photos", Author: &Author{"Jason Moiron", "jmoiron@jmoiron.net"}, Created: now, + Copyright: "This work is copyright © Benjamin Button", } feed.Items = []*Item{ diff --git a/rss.go b/rss.go index b510851..2733402 100644 --- a/rss.go +++ b/rss.go @@ -92,6 +92,7 @@ func (r *Rss) FeedXml() interface{} { ManagingEditor: author, PubDate: pub, LastBuildDate: build, + Copyright: r.Copyright, }, } for _, i := range r.Items { @@ -100,3 +101,7 @@ func (r *Rss) FeedXml() interface{} { return feed } + +func (r *RssFeed) FeedXml() interface{} { + return &rssFeedXml{Version: "2.0", Channel: r} +}