예제 #1
0
func servePage(page *Page, w http.ResponseWriter, r *http.Request) {
	page.getPageCount()
	page.getAllViews()
	out, err := webshell.BuildTemplateFile(page.File, page)
	if err != nil {
		webshell.Error404(err.Error(), "text/plain", w, r)
	} else {
		w.Write(out)
	}
	LogRequest(page, r)
}
예제 #2
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)
}