Merge branch 'only-week'
This commit is contained in:
commit
2e4e7c4d86
1
go.mod
1
go.mod
|
@ -3,6 +3,7 @@ module p83.nl/go/weekly
|
|||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/jinzhu/now v1.1.1
|
||||
github.com/pkg/errors v0.8.1 // indirect
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
|
||||
p83.nl/go/ekster v0.0.0-20191119211024-4511657daa0b
|
||||
|
|
2
go.sum
2
go.sum
|
@ -1,3 +1,5 @@
|
|||
github.com/jinzhu/now v1.1.1 h1:g39TucaRWyV3dwDO++eEc6qf8TVIQ/Da48WmqjZ3i7E=
|
||||
github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
|
|
19
main.go
19
main.go
|
@ -6,7 +6,10 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/now"
|
||||
"p83.nl/go/ekster/pkg/microsub"
|
||||
"willnorris.com/go/microformats"
|
||||
|
||||
"p83.nl/go/ekster/pkg/jf2"
|
||||
|
@ -31,6 +34,8 @@ func main() {
|
|||
md := microformats.Parse(resp.Body, u)
|
||||
items := jf2.SimplifyMicroformatDataItems(md)
|
||||
|
||||
items = filterEntriesAfter(items, now.With(time.Now()).Monday())
|
||||
|
||||
t, err := template.ParseFiles("templates/weekly.html")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -41,3 +46,17 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func filterEntriesAfter(items []microsub.Item, from time.Time) []microsub.Item {
|
||||
var result []microsub.Item
|
||||
for _, item := range items {
|
||||
published, err := time.Parse(time.RFC3339, item.Published)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if published.After(from) {
|
||||
result = append(result, item)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
<div class="p-content">{{ .Content.Text }}</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<time datetime="{{ .Published }}">{{ .Published }}</time>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user