v1.2.0
* added Podcast.AddPubDate() and Podcast.AddLastBuildDate() overrides. * added Item.AddImage() to mask some cumbersome addition of IImage. * added Item.AddPubDate to simply datetime setters. * added more examples (mostly around Item struct).
This commit is contained in:
parent
987dd40bb7
commit
cd785c6457
7
doc.go
7
doc.go
|
@ -37,6 +37,13 @@
|
||||||
//
|
//
|
||||||
// Release Notes
|
// Release Notes
|
||||||
//
|
//
|
||||||
|
// 1.2.0
|
||||||
|
// * added Podcast.AddPubDate() and Podcast.AddLastBuildDate() overrides.
|
||||||
|
// * added Item.AddImage() to mask some cumbersome addition of IImage.
|
||||||
|
// * added Item.AddPubDate to simply datetime setters.
|
||||||
|
// * added more examples (mostly around Item struct).
|
||||||
|
// * tweaked some documentation.
|
||||||
|
//
|
||||||
// 1.1.0
|
// 1.1.0
|
||||||
// * Enabling CDATA in ISummary fields for Podcast and Channel.
|
// * Enabling CDATA in ISummary fields for Podcast and Channel.
|
||||||
//
|
//
|
||||||
|
|
|
@ -40,6 +40,7 @@ func Example_httpHandlers() {
|
||||||
Description: "Description for Episode " + n,
|
Description: "Description for Episode " + n,
|
||||||
PubDate: &d,
|
PubDate: &d,
|
||||||
}
|
}
|
||||||
|
item.AddImage("http://example.com/episode-" + n + ".png")
|
||||||
item.AddSummary(`item <a href="http://example.com">example.com</a>`)
|
item.AddSummary(`item <a href="http://example.com">example.com</a>`)
|
||||||
// add a Download to the Item
|
// add a Download to the Item
|
||||||
item.AddEnclosure("http://e.com/"+n+".mp3", podcast.MP3, 55*(i+1))
|
item.AddEnclosure("http://e.com/"+n+".mp3", podcast.MP3, 55*(i+1))
|
||||||
|
@ -75,7 +76,7 @@ func Example_httpHandlers() {
|
||||||
// <title>eduncan911 Podcasts</title>
|
// <title>eduncan911 Podcasts</title>
|
||||||
// <link>http://eduncan911.com/</link>
|
// <link>http://eduncan911.com/</link>
|
||||||
// <description>An example Podcast</description>
|
// <description>An example Podcast</description>
|
||||||
// <generator>go podcast v1.1.0 (github.com/eduncan911/podcast)</generator>
|
// <generator>go podcast v1.2.0 (github.com/eduncan911/podcast)</generator>
|
||||||
// <language>en-us</language>
|
// <language>en-us</language>
|
||||||
// <lastBuildDate>Mon, 06 Feb 2017 08:21:52 +0000</lastBuildDate>
|
// <lastBuildDate>Mon, 06 Feb 2017 08:21:52 +0000</lastBuildDate>
|
||||||
// <managingEditor>me@janedoe.com (Jane Doe)</managingEditor>
|
// <managingEditor>me@janedoe.com (Jane Doe)</managingEditor>
|
||||||
|
@ -95,7 +96,7 @@ func Example_httpHandlers() {
|
||||||
// <enclosure url="http://e.com/1.mp3" length="110" type="audio/mpeg"></enclosure>
|
// <enclosure url="http://e.com/1.mp3" length="110" type="audio/mpeg"></enclosure>
|
||||||
// <itunes:author>me@janedoe.com (Jane Doe)</itunes:author>
|
// <itunes:author>me@janedoe.com (Jane Doe)</itunes:author>
|
||||||
// <itunes:summary><![CDATA[item <a href="http://example.com">example.com</a>]]></itunes:summary>
|
// <itunes:summary><![CDATA[item <a href="http://example.com">example.com</a>]]></itunes:summary>
|
||||||
// <itunes:image href="http://janedoe.com/i.jpg"></itunes:image>
|
// <itunes:image href="http://example.com/episode-1.png"></itunes:image>
|
||||||
// <itunes:duration>110</itunes:duration>
|
// <itunes:duration>110</itunes:duration>
|
||||||
// </item>
|
// </item>
|
||||||
// <item>
|
// <item>
|
||||||
|
@ -107,7 +108,7 @@ func Example_httpHandlers() {
|
||||||
// <enclosure url="http://e.com/2.mp3" length="165" type="audio/mpeg"></enclosure>
|
// <enclosure url="http://e.com/2.mp3" length="165" type="audio/mpeg"></enclosure>
|
||||||
// <itunes:author>me@janedoe.com (Jane Doe)</itunes:author>
|
// <itunes:author>me@janedoe.com (Jane Doe)</itunes:author>
|
||||||
// <itunes:summary><![CDATA[item <a href="http://example.com">example.com</a>]]></itunes:summary>
|
// <itunes:summary><![CDATA[item <a href="http://example.com">example.com</a>]]></itunes:summary>
|
||||||
// <itunes:image href="http://janedoe.com/i.jpg"></itunes:image>
|
// <itunes:image href="http://example.com/episode-2.png"></itunes:image>
|
||||||
// <itunes:duration>165</itunes:duration>
|
// <itunes:duration>165</itunes:duration>
|
||||||
// </item>
|
// </item>
|
||||||
// </channel>
|
// </channel>
|
||||||
|
@ -141,6 +142,7 @@ func Example_ioWriter() {
|
||||||
ISubtitle: "A simple episode " + n,
|
ISubtitle: "A simple episode " + n,
|
||||||
PubDate: &d,
|
PubDate: &d,
|
||||||
}
|
}
|
||||||
|
item.AddImage("http://example.com/episode-" + n + ".png")
|
||||||
item.AddSummary(`item k <a href="http://example.com">example.com</a>`)
|
item.AddSummary(`item k <a href="http://example.com">example.com</a>`)
|
||||||
// add a Download to the Item
|
// add a Download to the Item
|
||||||
item.AddEnclosure("http://example.com/"+n+".mp3", podcast.MP3, 55*(i+1))
|
item.AddEnclosure("http://example.com/"+n+".mp3", podcast.MP3, 55*(i+1))
|
||||||
|
@ -163,7 +165,7 @@ func Example_ioWriter() {
|
||||||
// <title>Sample Podcasts</title>
|
// <title>Sample Podcasts</title>
|
||||||
// <link>http://example.com/</link>
|
// <link>http://example.com/</link>
|
||||||
// <description>An example Podcast</description>
|
// <description>An example Podcast</description>
|
||||||
// <generator>go podcast v1.1.0 (github.com/eduncan911/podcast)</generator>
|
// <generator>go podcast v1.2.0 (github.com/eduncan911/podcast)</generator>
|
||||||
// <language>en-us</language>
|
// <language>en-us</language>
|
||||||
// <lastBuildDate>Mon, 06 Feb 2017 08:21:52 +0000</lastBuildDate>
|
// <lastBuildDate>Mon, 06 Feb 2017 08:21:52 +0000</lastBuildDate>
|
||||||
// <managingEditor>jane.doe@example.com (Jane Doe)</managingEditor>
|
// <managingEditor>jane.doe@example.com (Jane Doe)</managingEditor>
|
||||||
|
@ -185,7 +187,7 @@ func Example_ioWriter() {
|
||||||
// <itunes:author>jane.doe@example.com (Jane Doe)</itunes:author>
|
// <itunes:author>jane.doe@example.com (Jane Doe)</itunes:author>
|
||||||
// <itunes:subtitle>A simple episode 9</itunes:subtitle>
|
// <itunes:subtitle>A simple episode 9</itunes:subtitle>
|
||||||
// <itunes:summary><![CDATA[item k <a href="http://example.com">example.com</a>]]></itunes:summary>
|
// <itunes:summary><![CDATA[item k <a href="http://example.com">example.com</a>]]></itunes:summary>
|
||||||
// <itunes:image href="http://example.com/podcast.jpg"></itunes:image>
|
// <itunes:image href="http://example.com/episode-9.png"></itunes:image>
|
||||||
// <itunes:duration>550</itunes:duration>
|
// <itunes:duration>550</itunes:duration>
|
||||||
// </item>
|
// </item>
|
||||||
// <item>
|
// <item>
|
||||||
|
@ -198,7 +200,7 @@ func Example_ioWriter() {
|
||||||
// <itunes:author>jane.doe@example.com (Jane Doe)</itunes:author>
|
// <itunes:author>jane.doe@example.com (Jane Doe)</itunes:author>
|
||||||
// <itunes:subtitle>A simple episode 10</itunes:subtitle>
|
// <itunes:subtitle>A simple episode 10</itunes:subtitle>
|
||||||
// <itunes:summary><![CDATA[item k <a href="http://example.com">example.com</a>]]></itunes:summary>
|
// <itunes:summary><![CDATA[item k <a href="http://example.com">example.com</a>]]></itunes:summary>
|
||||||
// <itunes:image href="http://example.com/podcast.jpg"></itunes:image>
|
// <itunes:image href="http://example.com/episode-10.png"></itunes:image>
|
||||||
// <itunes:duration>605</itunes:duration>
|
// <itunes:duration>605</itunes:duration>
|
||||||
// </item>
|
// </item>
|
||||||
// </channel>
|
// </channel>
|
||||||
|
|
|
@ -103,10 +103,32 @@ func ExamplePodcast_AddItem() {
|
||||||
// http://example.com/1.mp3 Episode 1 http://example.com/1.mp3 Description for Episode 1 &{{ } me@test.com (the name)} 2017-04-22 08:21:52 +0000 UTC Sat, 22 Apr 2017 08:21:52 +0000 {{ } http://example.com/1.mp3 183 183 audio/mpeg audio/mpeg} me@test.com (the name) 183 A simple episode 1 &{{ } See more at <a href="http://example.com">Here</a>}
|
// http://example.com/1.mp3 Episode 1 http://example.com/1.mp3 Description for Episode 1 &{{ } me@test.com (the name)} 2017-04-22 08:21:52 +0000 UTC Sat, 22 Apr 2017 08:21:52 +0000 {{ } http://example.com/1.mp3 183 183 audio/mpeg audio/mpeg} me@test.com (the name) 183 A simple episode 1 &{{ } See more at <a href="http://example.com">Here</a>}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExamplePodcast_AddLastBuildDate() {
|
||||||
|
p := podcast.New("title", "link", "description", nil, nil)
|
||||||
|
d := pubDate.AddDate(0, 0, -7)
|
||||||
|
|
||||||
|
p.AddLastBuildDate(&d)
|
||||||
|
|
||||||
|
fmt.Println(p.LastBuildDate)
|
||||||
|
// Output:
|
||||||
|
// Sat, 28 Jan 2017 08:21:52 +0000
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExamplePodcast_AddPubDate() {
|
||||||
|
p := podcast.New("title", "link", "description", nil, nil)
|
||||||
|
d := pubDate.AddDate(0, 0, -5)
|
||||||
|
|
||||||
|
p.AddPubDate(&d)
|
||||||
|
|
||||||
|
fmt.Println(p.PubDate)
|
||||||
|
// Output:
|
||||||
|
// Mon, 30 Jan 2017 08:21:52 +0000
|
||||||
|
}
|
||||||
|
|
||||||
func ExamplePodcast_AddSummary() {
|
func ExamplePodcast_AddSummary() {
|
||||||
p := podcast.New("title", "link", "description", nil, nil)
|
p := podcast.New("title", "link", "description", nil, nil)
|
||||||
|
|
||||||
// add the Image
|
// add a summary
|
||||||
p.AddSummary(`A very cool podcast with a long summary!
|
p.AddSummary(`A very cool podcast with a long summary!
|
||||||
|
|
||||||
See more at our website: <a href="http://example.com">example.com</a>
|
See more at our website: <a href="http://example.com">example.com</a>
|
||||||
|
@ -161,7 +183,7 @@ See more at our website: <a href="http://example.com">example.com</a>
|
||||||
// <title>eduncan911 Podcasts</title>
|
// <title>eduncan911 Podcasts</title>
|
||||||
// <link>http://eduncan911.com/</link>
|
// <link>http://eduncan911.com/</link>
|
||||||
// <description>An example Podcast</description>
|
// <description>An example Podcast</description>
|
||||||
// <generator>go podcast v1.1.0 (github.com/eduncan911/podcast)</generator>
|
// <generator>go podcast v1.2.0 (github.com/eduncan911/podcast)</generator>
|
||||||
// <language>en-us</language>
|
// <language>en-us</language>
|
||||||
// <lastBuildDate>Mon, 06 Feb 2017 08:21:52 +0000</lastBuildDate>
|
// <lastBuildDate>Mon, 06 Feb 2017 08:21:52 +0000</lastBuildDate>
|
||||||
// <managingEditor>me@janedoe.com (Jane Doe)</managingEditor>
|
// <managingEditor>me@janedoe.com (Jane Doe)</managingEditor>
|
||||||
|
@ -196,3 +218,25 @@ See more at our website: <a href="http://example.com">example.com</a>
|
||||||
// </channel>
|
// </channel>
|
||||||
// </rss>
|
// </rss>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExampleItem_AddPubDate() {
|
||||||
|
p := podcast.New("title", "link", "description", nil, nil)
|
||||||
|
i := podcast.Item{
|
||||||
|
Title: "item title",
|
||||||
|
Description: "item desc",
|
||||||
|
Link: "item link",
|
||||||
|
}
|
||||||
|
d := pubDate.AddDate(0, 0, -11)
|
||||||
|
|
||||||
|
// add the pub date
|
||||||
|
i.AddPubDate(&d)
|
||||||
|
|
||||||
|
if i.PubDate != nil {
|
||||||
|
fmt.Println(i.PubDateFormatted, *i.PubDate)
|
||||||
|
}
|
||||||
|
p.AddItem(i) // this should not override with Podcast.PubDate
|
||||||
|
fmt.Println(i.PubDateFormatted, *i.PubDate)
|
||||||
|
// Output:
|
||||||
|
// Tue, 24 Jan 2017 08:21:52 +0000 2017-01-24 08:21:52 +0000 UTC
|
||||||
|
// Tue, 24 Jan 2017 08:21:52 +0000 2017-01-24 08:21:52 +0000 UTC
|
||||||
|
}
|
||||||
|
|
21
item.go
21
item.go
|
@ -58,6 +58,27 @@ func (i *Item) AddEnclosure(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddImage adds the image as an iTunes-only IImage. RSS 2.0 does not have
|
||||||
|
// the specification of Images at the Item level.
|
||||||
|
//
|
||||||
|
// Podcast feeds contain artwork that is a minimum size of
|
||||||
|
// 1400 x 1400 pixels and a maximum size of 3000 x 3000 pixels,
|
||||||
|
// 72 dpi, in JPEG or PNG format with appropriate file
|
||||||
|
// extensions (.jpg, .png), and in the RGB colorspace. To optimize
|
||||||
|
// images for mobile devices, Apple recommends compressing your
|
||||||
|
// image files.
|
||||||
|
func (i *Item) AddImage(url string) {
|
||||||
|
i.IImage = &IImage{HREF: url}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddPubDate adds the datetime as a parsed PubDate.
|
||||||
|
//
|
||||||
|
// UTC time is used by default.
|
||||||
|
func (i *Item) AddPubDate(datetime *time.Time) {
|
||||||
|
i.PubDate = datetime
|
||||||
|
i.PubDateFormatted = parseDateRFC1123Z(i.PubDate)
|
||||||
|
}
|
||||||
|
|
||||||
// AddSummary adds the iTunes summary.
|
// AddSummary adds the iTunes summary.
|
||||||
//
|
//
|
||||||
// Limit: 4000 characters
|
// Limit: 4000 characters
|
||||||
|
|
16
podcast.go
16
podcast.go
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
pVersion = "1.1.0"
|
pVersion = "1.2.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Podcast represents a podcast.
|
// Podcast represents a podcast.
|
||||||
|
@ -231,6 +231,20 @@ func (p *Podcast) AddItem(i Item) (int, error) {
|
||||||
return len(p.Items), nil
|
return len(p.Items), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddPubDate adds the datetime as a parsed PubDate.
|
||||||
|
//
|
||||||
|
// UTC time is used by default.
|
||||||
|
func (p *Podcast) AddPubDate(datetime *time.Time) {
|
||||||
|
p.PubDate = parseDateRFC1123Z(datetime)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddLastBuildDate adds the datetime as a parsed PubDate.
|
||||||
|
//
|
||||||
|
// UTC time is used by default.
|
||||||
|
func (p *Podcast) AddLastBuildDate(datetime *time.Time) {
|
||||||
|
p.LastBuildDate = parseDateRFC1123Z(datetime)
|
||||||
|
}
|
||||||
|
|
||||||
// AddSummary adds the iTunes summary.
|
// AddSummary adds the iTunes summary.
|
||||||
//
|
//
|
||||||
// Limit: 4000 characters
|
// Limit: 4000 characters
|
||||||
|
|
Loading…
Reference in New Issue