diff --git a/pkg/fetch/fetch.go b/pkg/fetch/fetch.go index ac39ee3..b6fb9b8 100644 --- a/pkg/fetch/fetch.go +++ b/pkg/fetch/fetch.go @@ -161,6 +161,7 @@ func FeedItems(fetcher Fetcher, fetchURL, contentType string, body io.Reader) ([ if strings.HasPrefix(contentType, "text/html") { data := microformats.Parse(body, u) results := jf2.SimplifyMicroformatData(data) + found := -1 for { for i, r := range results { @@ -174,7 +175,14 @@ func FeedItems(fetcher Fetcher, fetchURL, contentType string, body io.Reader) ([ results = append(results[:found], results[found+1:]...) for i := range results { if results[i]["type"] == "entry" && results[i]["author"] == card["url"] { - results[i]["author"] = card + author := make(map[string]string) + author["type"] = "card" + for k, v := range card { + if val, ok := v.(string); ok { + author[k] = val + } + } + results[i]["author"] = author } } found = -1 diff --git a/pkg/jf2/simplify.go b/pkg/jf2/simplify.go index 7e6723a..d790d88 100644 --- a/pkg/jf2/simplify.go +++ b/pkg/jf2/simplify.go @@ -170,15 +170,13 @@ func SimplifyMicroformatData(md *microformats.Data) []map[string]interface{} { return items } -func fetchValue(key string, values map[string]interface{}) string { +func fetchValue(key string, values map[string]string) string { if value, e := values[key]; e { - if stringValue, ok:= value.(string); ok { - return stringValue - } + return value } return "" } -func MapToAuthor(result map[string]interface{}) *microsub.Card { +func MapToAuthor(result map[string]string) *microsub.Card { item := µsub.Card{} item.Type = "card" item.Name = fetchValue("name", result); @@ -213,13 +211,13 @@ func MapToItem(result map[string]interface{}) microsub.Item { } if authorValue, e := result["author"]; e { - if author, ok := authorValue.(map[string]interface{}); ok { + if author, ok := authorValue.(map[string]string); ok { item.Author = MapToAuthor(author) } } if checkinValue, e := result["checkin"]; e { - if checkin, ok := checkinValue.(map[string]interface{}); ok { + if checkin, ok := checkinValue.(map[string]string); ok { item.Checkin = MapToAuthor(checkin) } }