improve handling of feeds with no summary

When testing Openring with Atom feeds like http://blog.davidchudzicki.com/feeds/posts/default and http://www.givinggladly.com/feeds/posts/default I noticed it wasn't able to pull out a text snippet.  Falling back to Content if Summary is null fixes this.  Content is html encoded, however, which means that we also need an UnescapeString or else Sanitize won't remove the HTML tags.
This commit is contained in:
Jeff Kaufman 2019-06-18 22:29:31 -04:00 committed by Drew DeVault
parent 4c35eaad3b
commit f75cc73b8b

View file

@ -1,6 +1,7 @@
package main
import (
"html"
"html/template"
"io/ioutil"
"log"
@ -114,8 +115,12 @@ func main() {
items = items[:perSource]
}
for _, item := range items {
raw_summary := item.Summary
if len(raw_summary) == 0 {
raw_summary = html.UnescapeString(item.Content)
}
summary := runewidth.Truncate(
policy.Sanitize(item.Summary), summaryLen, "…")
policy.Sanitize(raw_summary), summaryLen, "…")
articles = append(articles, &Article{
Date: item.Date,
SourceLink: feed.Link,