flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit b9a75b3d67ea9cbe20369a70a9880c634c2b7308
parent bae10cb7517fdbe207275c9c03e5a4245ee588de
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Wed, 27 Jan 2021 18:09:34 -0800

Cleanup following template

Diffstat:
Mfeed.go | 13++++++++++---
Mtemplates/following.gmi | 3++-
2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/feed.go b/feed.go @@ -68,19 +68,26 @@ func writeAllFeeds(user string) error { 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) diff --git a/templates/following.gmi b/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 }}