This commit is contained in:
parent
dc7493737a
commit
8a2dbfec7a
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user