Exemple #1
0
func (ps *PageServer) Display(c http.ResponseWriter, r *http.Request) {
	page, err := ps.Manager.Load(r.URL.Path[len(ps.Prefix):])
	if err != nil {
		template.Error404(c, r, err)
		return
	}
	template.Render(c, r, page.Title, "page", page)
}
Exemple #2
0
func (ps *PageServer) Edit(c http.ResponseWriter, r *http.Request) {
	if len(r.URL.Path) < len(ps.Prefix)+len("/edit") {
		template.Error404(c, r, nil)
		return
	}

	name := r.URL.Path[len(ps.Prefix) : len(r.URL.Path)-len("/edit")]

	page, err := ps.Manager.Load(name)
	if err != nil {
		template.Error500(c, r, err)
		return
	}

	template.Render(c, r, "Editing "+page.Title, "edit", page)
}