func ServePage(t *template.Template, page *Page, w http.ResponseWriter) { out, err := webshell.BuildTemplate(t, page) if err != nil { panic("template error: " + err.Error()) } w.Write(out) }
func showPage(page Page, w http.ResponseWriter, r *http.Request) { out, err := webshell.BuildTemplate(home_template, page) if err != nil { webshell.Error500(err.Error(), "text/plain", w, r) } else { w.Write(out) } }
func servePage(w http.ResponseWriter, r *http.Request) { md_file := getMdFilename(r.URL.Path[1:]) title := getPageTitle(md_file) out, err := loadMarkdown(md_file) if err != nil { webshell.Error404("Page not found.", "text/plain", w, r) return } page := Page{false, false, title, template.HTML(string(out))} active := extRegex.ReplaceAllString(filepath.Base(md_file), "$1") if active == "index" { page.HomeActive = true } else if active == "about" { page.AboutActive = true } body, err := webshell.BuildTemplate(page_tpl, page) if err != nil { webshell.Error500(err.Error(), "text/plain", w, r) return } w.Write(body) }