Improve content appending in item

This commit is contained in:
Vabd
2018-03-20 10:20:20 +01:00
committed by Kamil Kisiel
parent 14ba03d14c
commit 087409c2e1
2 changed files with 8 additions and 14 deletions
+5 -7
View File
@@ -92,12 +92,6 @@ func newAtomEntry(i *Item) *AtomEntry {
// assume the description is html
s := &AtomSummary{Content: i.Description, Type: "html"}
// if there's a content, assume it's html
var c *AtomContent
if len(i.Content) > 0 {
c = &AtomContent{Content: i.Content, Type: "html"}
}
if len(id) == 0 {
// if there's no id set, try to create one, either from data or just a uuid
if len(i.Link.Href) > 0 && (!i.Created.IsZero() || !i.Updated.IsZero()) {
@@ -123,12 +117,16 @@ func newAtomEntry(i *Item) *AtomEntry {
x := &AtomEntry{
Title: i.Title,
Links: []AtomLink{{Href: i.Link.Href, Rel: link_rel, Type: i.Link.Type}},
Content: c,
Id: id,
Updated: anyTimeFormat(time.RFC3339, i.Updated, i.Created),
Summary: s,
}
// if there's a content, assume it's html
if len(i.Content) > 0 {
x.Content = &AtomContent{Content: i.Content, Type: "html"}
}
if i.Enclosure != nil && link_rel != "enclosure" {
x.Links = append(x.Links, AtomLink{Href: i.Enclosure.Url, Rel: "enclosure", Type: i.Enclosure.Type, Length: i.Enclosure.Length})
}
+3 -7
View File
@@ -92,19 +92,15 @@ type Rss struct {
// create a new RssItem with a generic Item struct's data
func newRssItem(i *Item) *RssItem {
// append an encoded content if one is provided
var c *RssContent
if len(i.Content) > 0 {
c = &RssContent{Content: i.Content}
}
item := &RssItem{
Title: i.Title,
Link: i.Link.Href,
Description: i.Description,
Guid: i.Id,
PubDate: anyTimeFormat(time.RFC1123Z, i.Created, i.Updated),
Content: c,
}
if len(i.Content) > 0 {
item.Content = &RssContent{Content: i.Content}
}
if i.Source != nil {
item.Source = i.Source.Href