Skip to content

Commit 4cfde43

Browse files
committed
use Content by default in atom instead of Summary (via Description), change content to a struct and set Type to html
1 parent 96da93e commit 4cfde43

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

atom.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ type AtomPerson struct {
1818
}
1919

2020
type AtomSummary struct {
21-
Content string `xml:",chardata"`
22-
Type string `xml:"type,attr"`
21+
XMLName xml.Name `xml:"summary"`
22+
Content string `xml:",chardata"`
23+
Type string `xml:"type,attr"`
24+
}
25+
26+
type AtomContent struct {
27+
XMLName xml.Name `xml:"content"`
28+
Content string `xml:",chardata"`
29+
Type string `xml:"type,attr"`
2330
}
2431

2532
type AtomAuthor struct {
@@ -38,10 +45,10 @@ type AtomEntry struct {
3845
Updated string `xml:"updated"` // required
3946
Id string `xml:"id"` // required
4047
Category string `xml:"category,omitempty"`
41-
Content string `xml:"content,omitempty"`
42-
Rights string `xml:"rights,omitempty"`
43-
Source string `xml:"source,omitempty"`
44-
Published string `xml:"published,omitempty"`
48+
Content *AtomContent
49+
Rights string `xml:"rights,omitempty"`
50+
Source string `xml:"source,omitempty"`
51+
Published string `xml:"published,omitempty"`
4552
Contributor *AtomContributor
4653
Link *AtomLink // required if no child 'content' elements
4754
Summary *AtomSummary // required if content has src or content is base64
@@ -78,7 +85,7 @@ type Atom struct {
7885
func newAtomEntry(i *Item) *AtomEntry {
7986
id := i.Id
8087
// assume the description is html
81-
s := &AtomSummary{i.Description, "html"}
88+
c := &AtomContent{Content: i.Description, Type: "html"}
8289

8390
if len(id) == 0 {
8491
// if there's no id set, try to create one, either from data or just a uuid
@@ -101,7 +108,7 @@ func newAtomEntry(i *Item) *AtomEntry {
101108
x := &AtomEntry{
102109
Title: i.Title,
103110
Link: &AtomLink{Href: i.Link.Href, Rel: i.Link.Rel},
104-
Summary: s,
111+
Content: c,
105112
Id: id,
106113
Updated: anyTimeFormat(time.RFC3339, i.Updated, i.Created),
107114
}

feed_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ var atomOutput = `<?xml version="1.0" encoding="UTF-8"?>
2121
<title>Limiting Concurrency in Go</title>
2222
<updated>2013-01-16T21:52:35-05:00</updated>
2323
<id>tag:jmoiron.net,2013-01-16:/blog/limiting-concurrency-in-go/</id>
24+
<content type="html">A discussion on controlled parallelism in golang</content>
2425
<link href="http://jmoiron.net/blog/limiting-concurrency-in-go/"></link>
25-
<Summary type="html">A discussion on controlled parallelism in golang</Summary>
2626
<author>
2727
<name>Jason Moiron</name>
2828
<email>[email protected]</email>
@@ -32,15 +32,15 @@ var atomOutput = `<?xml version="1.0" encoding="UTF-8"?>
3232
<title>Logic-less Template Redux</title>
3333
<updated>2013-01-16T21:52:35-05:00</updated>
3434
<id>tag:jmoiron.net,2013-01-16:/blog/logicless-template-redux/</id>
35+
<content type="html">More thoughts on logicless templates</content>
3536
<link href="http://jmoiron.net/blog/logicless-template-redux/"></link>
36-
<Summary type="html">More thoughts on logicless templates</Summary>
3737
</entry>
3838
<entry>
3939
<title>Idiomatic Code Reuse in Go</title>
4040
<updated>2013-01-16T21:52:35-05:00</updated>
4141
<id>tag:jmoiron.net,2013-01-16:/blog/idiomatic-code-reuse-in-go/</id>
42+
<content type="html">How to use interfaces &lt;em&gt;effectively&lt;/em&gt;</content>
4243
<link href="http://jmoiron.net/blog/idiomatic-code-reuse-in-go/"></link>
43-
<Summary type="html">How to use interfaces &lt;em&gt;effectively&lt;/em&gt;</Summary>
4444
</entry>
4545
</feed>`
4646

0 commit comments

Comments
 (0)