From ebf8a24b364cc851b79319bfbdb755ed6d057c71 Mon Sep 17 00:00:00 2001 From: m15o Date: Sat, 9 Jul 2022 10:49:39 +0200 Subject: [PATCH] Update deps --- go.mod | 2 +- main.go | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index db23cf7..0c2c599 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module git.sr.ht/~m15o/kiosk go 1.18 -require git.sr.ht/~m15o/htmlj v0.0.0-20220708133931-8dda81d963cc +require git.sr.ht/~m15o/htmlj v0.0.0-20220709084050-c36dda5901f7 require golang.org/x/net v0.0.0-20220607020251-c690dde0001d // indirect diff --git a/main.go b/main.go index e5d37f0..8747469 100644 --- a/main.go +++ b/main.go @@ -22,7 +22,7 @@ var tpl string type Entry struct { URL string Author string - Published string + Published time.Time Title string Body template.HTML } @@ -95,13 +95,13 @@ func processContent(u, content string) (string, error) { func build(urls []string, dst string) { var journals []Journal for _, u := range urls { - fmt.Println("fetching", u) + fmt.Print("Fetching: ", u) j, err := fetchJournal(u) if err != nil { log.Println("Error fetching journal:", err) continue } - fmt.Println(len(j.Entries), "found") + fmt.Printf(" - %d entries found\n", len(j.Entries)) journals = append(journals, Journal{ URL: u, J: j, @@ -110,8 +110,13 @@ func build(urls []string, dst string) { var entries []Entry + lastMonth := time.Now().AddDate(0, -1, 0) + for _, j := range journals { for _, e := range j.J.Entries { + if !e.Published.After(lastMonth) { + continue + } c, err := processContent(j.URL, e.Content) if err != nil { continue @@ -123,12 +128,11 @@ func build(urls []string, dst string) { Title: e.Title, Body: template.HTML(c), }) - break } } sort.Slice(entries, func(i, j int) bool { - return entries[i].Published > entries[j].Published + return entries[i].Published.After(entries[j].Published) }) t := template.Must(template.New("").Parse(tpl)) -- 2.45.2