Esempio n. 1
0
File: wiki.go Progetto: gokyle/gowik
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)
}
Esempio n. 2
0
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)
	}
}
Esempio n. 3
0
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)
}