f75cc73b8b7874d2125ce0b9ec2b650f9022a255 — Jeff Kaufman 4 months ago 4c35eaa
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.
1 files changed, 6 insertions(+), 1 deletions(-)

M openring.go
M openring.go => openring.go +6 -1
@@ 1,6 1,7 @@
 package main
 
 import (
+	"html"
 	"html/template"
 	"io/ioutil"
 	"log"


@@ 114,8 115,12 @@
 			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,