all repos — flounder @ b9a75b3d67ea9cbe20369a70a9880c634c2b7308

A small site builder for the Gemini protocol

Cleanup following template
alex wennerberg alex@alexwennerberg.com
Wed, 27 Jan 2021 18:09:34 -0800
commit

b9a75b3d67ea9cbe20369a70a9880c634c2b7308

parent

bae10cb7517fdbe207275c9c03e5a4245ee588de

2 files changed, 12 insertions(+), 4 deletions(-)

jump to
M feed.gofeed.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.gmitemplates/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 }}