diff --git a/atom.go b/atom.go index 7196f47..93cf15f 100644 --- a/atom.go +++ b/atom.go @@ -89,8 +89,6 @@ type Atom struct { func newAtomEntry(i *Item) *AtomEntry { id := i.Id - // assume the description is html - s := &AtomSummary{Content: i.Description, Type: "html"} if len(id) == 0 { // if there's no id set, try to create one, either from data or just a uuid @@ -119,7 +117,11 @@ func newAtomEntry(i *Item) *AtomEntry { Links: []AtomLink{{Href: i.Link.Href, Rel: link_rel, Type: i.Link.Type}}, Id: id, Updated: anyTimeFormat(time.RFC3339, i.Updated, i.Created), - Summary: s, + } + + // if there's a description, assume it's html + if len(i.Description) > 0 { + x.Summary = &AtomSummary{Content: i.Description, Type: "html"} } // if there's a content, assume it's html diff --git a/feed_test.go b/feed_test.go index 7493bf1..1c178d8 100644 --- a/feed_test.go +++ b/feed_test.go @@ -59,6 +59,13 @@ var atomOutput = ` How to use things like %s, %v, %d, etc. + + Go Proverb #1 + 2013-01-16T21:52:35-05:00 + tag:go-proverbs.github.io,2013-01-16:/ + Don't communicate by sharing memory, share memory by communicating. + + ` var rssOutput = ` @@ -103,6 +110,13 @@ var rssOutput = `How to use things like %s, %v, %d, etc. Wed, 16 Jan 2013 21:52:35 -0500 + + Go Proverb #1 + https://go-proverbs.github.io/ + + + Wed, 16 Jan 2013 21:52:35 -0500 + ` @@ -154,6 +168,13 @@ var jsonOutput = `{ "title": "String formatting in Go", "summary": "How to use things like %s, %v, %d, etc.", "date_published": "2013-01-16T21:52:35-05:00" + }, + { + "id": "", + "url": "https://go-proverbs.github.io/", + "title": "Go Proverb #1", + "content_html": "Don't communicate by sharing memory, share memory by communicating.", + "date_published": "2013-01-16T21:52:35-05:00" } ] }` @@ -209,6 +230,12 @@ func TestFeed(t *testing.T) { Link: &Link{Href: "http://example.com/strings"}, Description: "How to use things like %s, %v, %d, etc.", Created: now, + }, + { + Title: "Go Proverb #1", + Link: &Link{Href: "https://go-proverbs.github.io/"}, + Content: "Don't communicate by sharing memory, share memory by communicating.", + Created: now, }} atom, err := feed.ToAtom() @@ -273,35 +300,30 @@ var atomOutputSorted = ` - Logic-less Template Redux 2013-01-17T21:52:35-05:00 tag:jmoiron.net,2013-01-17:/blog/logicless-template-redux/ - Idiomatic Code Reuse in Go 2013-01-17T09:52:35-05:00 tag:jmoiron.net,2013-01-17:/blog/idiomatic-code-reuse-in-go/ - Never Gonna Give You Up Mp3 2013-01-17T07:52:35-05:00 tag:example.com,2013-01-17:/RickRoll.mp3 - String formatting in Go 2013-01-16T21:52:35-05:00 tag:example.com,2013-01-16:/strings - `