Cleanup following template
alex wennerberg alex@alexwennerberg.com
Wed, 27 Jan 2021 18:09:34 -0800
2 files changed,
12 insertions(+),
4 deletions(-)
M
feed.go
→
feed.go
@@ -68,19 +68,26 @@ // Aggregate and sort by date
type feedPlusItem struct { Feed *gofeed.Feed FeedItem *gofeed.Item + Date string } data := struct { + User string FeedItems []feedPlusItem }{} + data.User = user for _, feed := range feedData { for _, item := range feed.Items { - if item.PublishedParsed != nil { - data.FeedItems = append(data.FeedItems, feedPlusItem{feed, item}) + if item.UpdatedParsed == nil { + item.UpdatedParsed = item.PublishedParsed + } + if item.UpdatedParsed != nil { + date := item.UpdatedParsed.Format("2006-01-02") + data.FeedItems = append(data.FeedItems, feedPlusItem{feed, item, date}) } } } sort.Slice(data.FeedItems, func(i, j int) bool { - return data.FeedItems[i].FeedItem.PublishedParsed.After(*data.FeedItems[j].FeedItem.PublishedParsed) + return data.FeedItems[i].FeedItem.UpdatedParsed.After(*data.FeedItems[j].FeedItem.UpdatedParsed) }) outputf, err := os.OpenFile(path.Join(getUserDirectory(user), followingFile), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
M
templates/following.gmi
→
templates/following.gmi
@@ -1,3 +1,4 @@
+# {{.User}}'s Following {{ range .FeedItems }} -=> {{.FeedItem.Link}} {{.FeedItem.Published}} {{.Feed.Title}} -- {{.FeedItem.Title}}{{ end }} +=> {{.FeedItem.Link}} {{.Date}} {{.Feed.Title}} -- {{.FeedItem.Title}}{{ end }}