From 79303728a28cdfc47114b9563761e10ebf17ddd7 Mon Sep 17 00:00:00 2001 From: Callum Kerson <12272439+CallumKerson@users.noreply.github.com> Date: Tue, 7 Mar 2023 13:15:39 +0000 Subject: [PATCH 1/2] Adding content xmlns --- feed.go | 14 ++++++++------ podcast.go | 7 ++++--- podcast_test.go | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/feed.go b/feed.go index 9442c5b..a62a418 100644 --- a/feed.go +++ b/feed.go @@ -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. @@ -157,9 +158,10 @@ 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"` + XMLName xml.Name `xml:"rss"` + ItunesXMLNS string `xml:"xmlns:itunes,attr"` + ContentXMLNS string `xml:"xmlns:content,attr"` + Version string `xml:"version,attr"` Channel *Channel } diff --git a/podcast.go b/podcast.go index 549d62a..a81b13b 100644 --- a/podcast.go +++ b/podcast.go @@ -18,9 +18,10 @@ 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, - Channel: &Channel{ + ItunesXMLNS: itunesXMLNS, + ContentXMLNS: contentXMLNS + Version: rssVersion, + Channel: &Channel{ Title: p.Title, Description: p.Description, Link: p.Link, diff --git a/podcast_test.go b/podcast_test.go index 384bdf3..8570551 100644 --- a/podcast_test.go +++ b/podcast_test.go @@ -74,7 +74,7 @@ func TestContainsRssElement(t *testing.T) { if err != nil { t.Errorf("unexpected error %v", err) } - want := `` + want := `` if !strings.Contains(data, want) { t.Errorf("expected %v to contain %v", data, want) } From afca8fe5c65e5416992a8bbd571ef68ca111351a Mon Sep 17 00:00:00 2001 From: Callum Kerson <12272439+CallumKerson@users.noreply.github.com> Date: Tue, 7 Mar 2023 13:26:43 +0000 Subject: [PATCH 2/2] Fixing formatting --- feed.go | 2 +- podcast.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/feed.go b/feed.go index a62a418..635f6af 100644 --- a/feed.go +++ b/feed.go @@ -162,7 +162,7 @@ type Feed struct { ItunesXMLNS string `xml:"xmlns:itunes,attr"` ContentXMLNS string `xml:"xmlns:content,attr"` Version string `xml:"version,attr"` - Channel *Channel + Channel *Channel } // SetOptions sets options of given feed. diff --git a/podcast.go b/podcast.go index a81b13b..8f91310 100644 --- a/podcast.go +++ b/podcast.go @@ -19,9 +19,9 @@ func (p *Podcast) AddItem(item *Item) { func (p *Podcast) Feed(options ...func(f *Feed) error) (*Feed, error) { f := &Feed{ ItunesXMLNS: itunesXMLNS, - ContentXMLNS: contentXMLNS + ContentXMLNS: contentXMLNS, Version: rssVersion, - Channel: &Channel{ + Channel: &Channel{ Title: p.Title, Description: p.Description, Link: p.Link,