Skip to content

Commit

Permalink
Merge pull request #6 from CallumKerson/patch/adding-content-ns
Browse files Browse the repository at this point in the history
Adding content xmlns
  • Loading branch information
CallumKerson authored Mar 7, 2023
2 parents 781c028 + afca8fe commit eb8e66b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
16 changes: 9 additions & 7 deletions feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
)

const (
rssXmlns = "http://www.itunes.com/dtds/podcast-1.0.dtd"
rssVersion = "2.0"
rfc2822 = "Mon, 02 Jan 2006 15:04:05 -0700"
itunesXMLNS = "http://www.itunes.com/dtds/podcast-1.0.dtd"
contentXMLNS = "http://purl.org/rss/1.0/modules/content/"
rssVersion = "2.0"
rfc2822 = "Mon, 02 Jan 2006 15:04:05 -0700"
)

// NewPubDate returns a new PubDate.
Expand Down Expand Up @@ -157,10 +158,11 @@ type Channel struct {

// Feed wraps the given RSS channel.
type Feed struct {
XMLName xml.Name `xml:"rss"`
Xmlns string `xml:"xmlns:itunes,attr"`
Version string `xml:"version,attr"`
Channel *Channel
XMLName xml.Name `xml:"rss"`
ItunesXMLNS string `xml:"xmlns:itunes,attr"`
ContentXMLNS string `xml:"xmlns:content,attr"`
Version string `xml:"version,attr"`
Channel *Channel
}

// SetOptions sets options of given feed.
Expand Down
5 changes: 3 additions & 2 deletions podcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ func (p *Podcast) AddItem(item *Item) {
// Feed creates a new feed for current podcast.
func (p *Podcast) Feed(options ...func(f *Feed) error) (*Feed, error) {
f := &Feed{
Xmlns: rssXmlns,
Version: rssVersion,
ItunesXMLNS: itunesXMLNS,
ContentXMLNS: contentXMLNS,
Version: rssVersion,
Channel: &Channel{
Title: p.Title,
Description: p.Description,
Expand Down
2 changes: 1 addition & 1 deletion podcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestContainsRssElement(t *testing.T) {
if err != nil {
t.Errorf("unexpected error %v", err)
}
want := `<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">`
want := `<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">`
if !strings.Contains(data, want) {
t.Errorf("expected %v to contain %v", data, want)
}
Expand Down

0 comments on commit eb8e66b

Please sign in to comment.