diff --git a/display/feeds.go b/display/feeds.go index 52a52c7..9d19389 100644 --- a/display/feeds.go +++ b/display/feeds.go @@ -3,6 +3,7 @@ package display import ( "fmt" "strings" + "time" "github.com/makeworld-the-better-one/amfora/feeds" "github.com/makeworld-the-better-one/amfora/renderer" @@ -12,6 +13,8 @@ import ( var feedPageRaw = "# Feeds & Pages\n\nUpdates" + strings.Repeat(" ", 80-25) + "[Newest -> Oldest]\n" + strings.Repeat("-", 80) + "\n\n" +var timeDay = 24 * time.Hour + // Feeds displays the feeds page on the current tab. func Feeds(t *tab) { // TODO; Decide about date in local time vs UTC @@ -19,12 +22,12 @@ func Feeds(t *tab) { pe := feeds.GetPageEntries() - curDay := time.Time.Round(time.Day) + curDay := time.Time{}.Round(timeDay) for _, entry := range pe.Entries { - if entry.Published.Round(time.Day).After(curDay) { + if entry.Published.Round(timeDay).After(curDay) { // This post is on a new day, add a day header - curDay := entry.Published.Round(time.Day) + curDay := entry.Published.Round(timeDay) feedPageRaw += fmt.Sprintf("\n## %s\n\n", curDay.Format("Jan 02, 2006")) } feedPageRaw += fmt.Sprintf("=>%s %s - %s\n", entry.URL, entry.Author, entry.Title) diff --git a/display/util.go b/display/util.go index e3e7124..37b6f1d 100644 --- a/display/util.go +++ b/display/util.go @@ -47,8 +47,8 @@ func textWidth() int { // queryEscape is the same as url.PathEscape, but it also replaces the +. // This is because Gemini requires percent-escaping for queries. -func queryEscape(path string) string { - return strings.ReplaceAll(url.PathEscape(path), "+", "%2B") +func queryEscape(query string) string { + return strings.ReplaceAll(url.PathEscape(query), "+", "%2B") } // resolveRelLink returns an absolute link for the given absolute link and relative one.