// parse the requests cookies and display that day's reading to the user func HandleAll() http.HandlerFunc { return func(w http.ResponseWriter, req *http.Request) { t, err := template.ParseFiles("views/reading.html") if err != nil { logger.Fatal(err) } cookie, _ := getBookmark(req) m, d := normalizeBookmark(cookie) page := page{ esvapi.Query(reading.Plan[m][d].Gospel), esvapi.Query(reading.Plan[m][d].Nt), esvapi.Query(reading.Plan[m][d].Ot), esvapi.Query(reading.Plan[m][d].Wisdom), esvapi.Query(fv.Current(fv.Base)), } t.Execute(w, htmlPage{ template.HTML(page.Gospel.String()), template.HTML(page.Nt.String()), template.HTML(page.Ot.String()), template.HTML(page.Wisdom.String()), template.HTML(page.Memory.String()), }) } }
// renders the given genre's reading for the given month/day func Render(g, m, d int) { t, _ := template.New("all").Parse("\n\n{{.}}\n\n") m -= 1 // zero index d -= 1 // zero index var p bytes.Buffer switch { case g == Gospel: p = esvapi.Query(Plan[m][d].Gospel) case g == Wisdom: p = esvapi.Query(Plan[m][d].Wisdom) case g == Ot: p = esvapi.Query(Plan[m][d].Ot) case g == Nt: p = esvapi.Query(Plan[m][d].Nt) } err := t.Execute(os.Stdout, (&p).String()) if err != nil { log.Fatal(err) } }
// output the verse to STDOUT func Render(set, vn int) { t, _ := template.New("all").Parse("\n\n{{.}}\n\n") // vn -= 1 // zero index for vn > 259 { vn -= 260 // start the cycle over } v := esvapi.Query(sets[set][vn].Ref) err := t.Execute(os.Stdout, (&v).String()) if err != nil { log.Fatal(err) } }