Skip to content

Commit

Permalink
add copyright info, add ToXML support for RssFeed & AtomFeed (provide…
Browse files Browse the repository at this point in the history
…d you only want to create those), hide more empty members of atom feed
  • Loading branch information
jmoiron committed Jan 17, 2013
1 parent 09ecc7c commit f89ed30
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions atom.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
5 changes: 5 additions & 0 deletions rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (r *Rss) FeedXml() interface{} {
ManagingEditor: author,
PubDate: pub,
LastBuildDate: build,
Copyright: r.Copyright,
},
}
for _, i := range r.Items {
Expand All @@ -100,3 +101,7 @@ func (r *Rss) FeedXml() interface{} {
return feed

}

func (r *RssFeed) FeedXml() interface{} {
return &rssFeedXml{Version: "2.0", Channel: r}
}

0 comments on commit f89ed30

Please sign in to comment.