Adapt feed comments
This commit is contained in:
parent
16d8b577e3
commit
a021de6e66
21
feed.go
21
feed.go
@ -16,7 +16,7 @@ type Feed struct {
|
||||
Generator *Generator `xml:"generator,omitempty"`
|
||||
Icon *Icon `xml:"icon,omitempty"`
|
||||
ID *ID `xml:"id"`
|
||||
Links []*Link `xml:"link,omitempty"` // There should be one link with rel "self"
|
||||
Links []*Link `xml:"link,omitempty"`
|
||||
Logo *Logo `xml:"logo,omitempty"`
|
||||
Rights Text `xml:"rights,omitempty"`
|
||||
Subtitle Text `xml:"subtitle,omitempty"`
|
||||
@ -26,7 +26,7 @@ type Feed struct {
|
||||
Entries []*Entry `xml:"entry,omitempty"`
|
||||
}
|
||||
|
||||
// NewFeed creates a new feed
|
||||
// NewFeed creates a new feed.
|
||||
func NewFeed(title string, updated time.Time) (*Feed, error) {
|
||||
text, err := NewText("text", title)
|
||||
if err != nil {
|
||||
@ -40,7 +40,7 @@ func NewFeed(title string, updated time.Time) (*Feed, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AddAuthor adds the person as an author to the feed
|
||||
// AddAuthor adds the person as an author to the feed.
|
||||
func (f *Feed) AddAuthor(p *Person) {
|
||||
if f.Authors == nil {
|
||||
f.Authors = make([]*Person, 1)
|
||||
@ -50,7 +50,7 @@ func (f *Feed) AddAuthor(p *Person) {
|
||||
}
|
||||
}
|
||||
|
||||
// AddCategory adds the category to the feed
|
||||
// AddCategory adds the category to the feed.
|
||||
func (f *Feed) AddCategory(c *Category) {
|
||||
if f.Categories == nil {
|
||||
f.Categories = make([]*Category, 1)
|
||||
@ -60,7 +60,7 @@ func (f *Feed) AddCategory(c *Category) {
|
||||
}
|
||||
}
|
||||
|
||||
// AddContributor adds the contributor to the feed
|
||||
// AddContributor adds the contributor to the feed.
|
||||
func (f *Feed) AddContributor(c *Person) {
|
||||
if f.Contributors == nil {
|
||||
f.Contributors = make([]*Person, 1)
|
||||
@ -70,7 +70,8 @@ func (f *Feed) AddContributor(c *Person) {
|
||||
}
|
||||
}
|
||||
|
||||
// AddLink adds the link to the feed
|
||||
// AddLink adds the link to the feed.
|
||||
// There should be one link with rel "self".
|
||||
func (f *Feed) AddLink(l *Link) {
|
||||
if f.Links == nil {
|
||||
f.Links = make([]*Link, 1)
|
||||
@ -80,7 +81,7 @@ func (f *Feed) AddLink(l *Link) {
|
||||
}
|
||||
}
|
||||
|
||||
// AddExtension adds the extension to the feed
|
||||
// AddExtension adds the extension to the feed.
|
||||
func (f *Feed) AddExtension(e *ExtensionElement) {
|
||||
if f.Extensions == nil {
|
||||
f.Extensions = make([]*ExtensionElement, 1)
|
||||
@ -90,7 +91,7 @@ func (f *Feed) AddExtension(e *ExtensionElement) {
|
||||
}
|
||||
}
|
||||
|
||||
// AddEntry adds the entry to the feed
|
||||
// AddEntry adds the entry to the feed.
|
||||
func (f *Feed) AddEntry(e *Entry) {
|
||||
if f.Entries == nil {
|
||||
f.Entries = make([]*Entry, 1)
|
||||
@ -100,7 +101,7 @@ func (f *Feed) AddEntry(e *Entry) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check checks the feed for incompatibilities with the Atom standard
|
||||
// Check checks the feed for incompatibilities with the Atom standard.
|
||||
func (f *Feed) Check() error {
|
||||
if f.ID == nil {
|
||||
return errors.New("no id element of feed")
|
||||
@ -232,7 +233,7 @@ func (f *Feed) Standardize() {
|
||||
}
|
||||
}
|
||||
|
||||
// ToXML converts the feed to XML
|
||||
// ToXML converts the feed to XML.
|
||||
func (f *Feed) ToXML(encoding string) (string, error) {
|
||||
xml, err := xml.MarshalIndent(f, "", " ")
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user