8
"xelbot.com/reprogl/container"
12
XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"`
14
Title string `xml:"title"`
15
Description string `xml:"subtitle"`
16
Links []AtomLink `xml:"link"`
17
Updated SitemapTime `xml:"updated"`
18
Author AtomPerson `xml:"author"`
19
Generator string `xml:"generator"`
20
Entry []AtomEntry `xml:"entry"`
24
Rel string `xml:"rel,attr,omitempty"`
25
Language string `xml:"hreflang,attr,omitempty"`
26
Href string `xml:"href,attr"`
27
Length int `xml:"length,attr,omitempty"`
28
MimeType string `xml:"type,attr,omitempty"`
31
type AtomPerson struct {
32
Name string `xml:"name"`
33
Email string `xml:"email"`
36
type AtomEntry struct {
38
Title string `xml:"title"`
39
URLs []AtomLink `xml:"link"`
40
Updated SitemapTime `xml:"updated"`
41
Created SitemapTime `xml:"published"`
42
Content AtomContent `xml:"content"`
45
type AtomContent struct {
46
XMLName xml.Name `xml:"content"`
47
Text string `xml:",innerxml"`
48
Type string `xml:"type,attr"`
51
func (a *Atom) setChannelData(data FeedChannelData) {
52
a.ID = "urn:uuid:" + data.GIUD()
54
a.Description = data.Description
55
a.Generator = data.Generator
57
{Rel: "alternate", Href: data.Link, Language: data.Language},
58
{Rel: "self", Href: container.GenerateAbsoluteURL("feed-atom")},
60
a.Author = AtomPerson{Name: data.Author, Email: data.Email}
62
for _, entry := range data.FeedItems {
67
func (a *Atom) ContentType() string {
68
return "application/atom+xml; charset=utf-8"
71
func (a *Atom) addFeedItem(entry *FeedItem) {
72
links := make([]AtomLink, 0, 2)
73
links = append(links, AtomLink{Rel: "alternate", Href: entry.URL})
74
if enclosure := entry.GetRssEnclosure(); enclosure != nil {
75
links = append(links, AtomLink{
78
Length: enclosure.Length,
79
MimeType: enclosure.MimeType,
83
a.Entry = append(a.Entry, AtomEntry{
84
ID: "urn:uuid:" + entry.GIUD(),
87
Updated: SitemapTime(entry.UpdatedAt),
88
Created: SitemapTime(entry.CreatedAt),
89
Content: AtomContent{Text: html.EscapeString(entry.Text), Type: "html"},
92
if entry.CreatedAt.After(time.Time(a.Updated)) {
93
a.Updated = SitemapTime(entry.CreatedAt)