44 lines
674 B
Go
44 lines
674 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"html/template"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
"net/url"
|
||
|
"os"
|
||
|
|
||
|
"willnorris.com/go/microformats"
|
||
|
|
||
|
"p83.nl/go/ekster/pkg/jf2"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
u, err := url.Parse(os.Args[1])
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
resp, err := http.Get(u.String())
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
defer resp.Body.Close()
|
||
|
|
||
|
if resp.StatusCode != 200 {
|
||
|
log.Fatalf("Status is not 200, but %d", resp.StatusCode)
|
||
|
}
|
||
|
|
||
|
md := microformats.Parse(resp.Body, u)
|
||
|
items := jf2.SimplifyMicroformatDataItems(md)
|
||
|
|
||
|
t, err := template.ParseFiles("templates/weekly.html")
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
|
||
|
err = t.Execute(os.Stdout, items)
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
}
|