mirror of
https://codeberg.org/librarian/feeds
synced 2024-12-06 19:16:24 +01:00
Improve content appending in item
This commit is contained in:
@@ -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})
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user