Ejemplo n.º 1
0
func List(w http.ResponseWriter, r *http.Request) {
	data := make(middleware.Data)
	articles, err := article.List()
	if err != nil {
		middleware.Fatal(w)
		return
	}
	data["Title"] = "Recent articles"
	data["Articles"] = articles
	middleware.RenderView(w, "list.html", data)
}
Ejemplo n.º 2
0
func Article(c web.C, w http.ResponseWriter, r *http.Request) {
	data := make(middleware.Data)
	id := c.URLParams["id"]
	article, err := article.Get(id)
	if err != nil {
		if err == model.ErrNotFound {
			middleware.NotFound(w)
		} else {
			middleware.Fatal(w)
		}
		return
	}
	err = article.Merge()
	if err != nil {
		middleware.Fatal(w)
		return
	}
	data["Title"] = article.Title
	data["Article"] = article
	middleware.RenderView(w, "article.html", data)
}
Ejemplo n.º 3
0
func Home(w http.ResponseWriter, r *http.Request) {
	data := make(middleware.Data)
	middleware.RenderView(w, "home.html", data)
}