Get more information from feeds
This commit is contained in:
parent
f5ed8dbc45
commit
0155a36a90
|
@ -372,17 +372,26 @@ func (b *memoryBackend) TimelineGet(after, before, channel string) microsub.Time
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
feeds := make(map[int64]feedbin.Feed)
|
||||
|
||||
var items []microsub.Item
|
||||
|
||||
for _, e := range entries {
|
||||
for _, entry := range entries {
|
||||
var item microsub.Item
|
||||
|
||||
var feed feedbin.Feed
|
||||
e := false
|
||||
if feed, e = feeds[entry.FeedID]; !e {
|
||||
feeds[entry.FeedID], _ = fb.Feed(entry.FeedID)
|
||||
feed = feeds[entry.FeedID]
|
||||
}
|
||||
|
||||
item.Type = "entry"
|
||||
item.Name = e.Title
|
||||
item.Content = µsub.Content{HTML: e.Content}
|
||||
item.URL = e.URL
|
||||
item.Published = e.Published.Format(time.RFC3339)
|
||||
item.Author = µsub.Card{Type: "card", Name: e.Author}
|
||||
item.Name = entry.Title
|
||||
item.Content = µsub.Content{HTML: entry.Content}
|
||||
item.URL = entry.URL
|
||||
item.Published = entry.Published.Format(time.RFC3339)
|
||||
item.Author = µsub.Card{Type: "card", Name: feed.Title, URL: feed.SiteURL}
|
||||
|
||||
items = append(items, item)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package feedbin
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Feedbin struct {
|
||||
|
@ -31,8 +32,24 @@ func (fb *Feedbin) Taggings() ([]Tagging, error) {
|
|||
return taggings, nil
|
||||
}
|
||||
|
||||
func (fb *Feedbin) Feed(id int64) (Feed, error) {
|
||||
resp, err := fb.get(fmt.Sprintf("/v2/feeds/%d.json", id))
|
||||
if err != nil {
|
||||
return Feed{}, err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
var feed Feed
|
||||
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
dec.Decode(&feed)
|
||||
|
||||
return feed, nil
|
||||
}
|
||||
|
||||
func (fb *Feedbin) Entries() ([]Entry, error) {
|
||||
resp, err := fb.get("/v2/entries.json")
|
||||
resp, err := fb.get("/v2/entries.json?mode=extended")
|
||||
if err != nil {
|
||||
return []Entry{}, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user