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) }
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) }
func Home(w http.ResponseWriter, r *http.Request) { data := make(middleware.Data) middleware.RenderView(w, "home.html", data) }