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") {
|
if strings.HasPrefix(contentType, "text/html") {
|
||||||
data := microformats.Parse(body, u)
|
data := microformats.Parse(body, u)
|
||||||
results := jf2.SimplifyMicroformatData(data)
|
results := jf2.SimplifyMicroformatData(data)
|
||||||
|
|
||||||
found := -1
|
found := -1
|
||||||
for {
|
for {
|
||||||
for i, r := range results {
|
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:]...)
|
results = append(results[:found], results[found+1:]...)
|
||||||
for i := range results {
|
for i := range results {
|
||||||
if results[i]["type"] == "entry" && results[i]["author"] == card["url"] {
|
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
|
found = -1
|
||||||
|
|
|
@ -170,15 +170,13 @@ func SimplifyMicroformatData(md *microformats.Data) []map[string]interface{} {
|
||||||
return items
|
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 value, e := values[key]; e {
|
||||||
if stringValue, ok:= value.(string); ok {
|
return value
|
||||||
return stringValue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
func MapToAuthor(result map[string]interface{}) *microsub.Card {
|
func MapToAuthor(result map[string]string) *microsub.Card {
|
||||||
item := µsub.Card{}
|
item := µsub.Card{}
|
||||||
item.Type = "card"
|
item.Type = "card"
|
||||||
item.Name = fetchValue("name", result);
|
item.Name = fetchValue("name", result);
|
||||||
|
@ -213,13 +211,13 @@ func MapToItem(result map[string]interface{}) microsub.Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
if authorValue, e := result["author"]; e {
|
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)
|
item.Author = MapToAuthor(author)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if checkinValue, e := result["checkin"]; e {
|
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)
|
item.Checkin = MapToAuthor(checkin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user