10
XMLName xml.Name `xml:"rss"`
11
Channel RssChannel `xml:"channel"`
12
Version string `xml:"version,attr"`
15
type RssChannel struct {
16
XMLName xml.Name `xml:"channel"`
17
Title string `xml:"title"`
18
Description string `xml:"description"`
19
Link string `xml:"link"`
20
Updated RssTime `xml:"pubDate"`
21
Language string `xml:"language"`
22
Author string `xml:"managingEditor"`
23
Generator string `xml:"generator"`
24
Docs string `xml:"docs"`
25
Entry []RssEntry `xml:"item"`
30
Title string `xml:"title"`
31
URL string `xml:"link"`
32
Updated RssTime `xml:"pubDate"`
33
Description RssDescription `xml:"description"`
34
Enclosure *RssEnclosure `xml:"enclosure,omitempty"`
38
XMLName xml.Name `xml:"guid"`
39
PermaLink string `xml:"isPermaLink,attr"`
40
ID string `xml:",innerxml"`
43
type RssDescription struct {
44
XMLName xml.Name `xml:"description"`
45
Text string `xml:",cdata"`
48
type RssEnclosure struct {
49
XMLName xml.Name `xml:"enclosure"`
50
Url string `xml:"url,attr"`
51
Length int `xml:"length,attr"`
52
MimeType string `xml:"type,attr"`
55
func (a *Rss) setChannelData(data FeedChannelData) {
57
a.Channel = RssChannel{
59
Description: data.Description,
61
Language: data.Language,
62
Author: fmt.Sprintf("%s (%s)", data.Email, data.Author),
63
Generator: data.Generator,
64
Docs: "http://www.rssboard.org/rss-specification",
67
for _, entry := range data.FeedItems {
72
func (a *Rss) ContentType() string {
73
return "application/rss+xml; charset=utf-8"
76
func (a *Rss) addFeedItem(entry *FeedItem) {
77
a.Channel.Entry = append(a.Channel.Entry, RssEntry{
84
Updated: RssTime(entry.CreatedAt),
85
Description: RssDescription{Text: entry.Text},
86
Enclosure: entry.GetRssEnclosure(),
89
if entry.CreatedAt.After(time.Time(a.Channel.Updated)) {
90
a.Channel.Updated = RssTime(entry.CreatedAt)