func handleSign(r *web.Request) { c := gae.Context(r) g := &Greeting{ Content: r.Param.Get("content"), Date: datastore.SecondsToTime(time.Seconds()), } if u := user.Current(c); u != nil { g.Author = u.String() } if _, err := datastore.Put(c, datastore.NewIncompleteKey("Greeting"), g); err != nil { r.Error(web.StatusInternalServerError, err) return } r.Redirect("/", false) }
func handleMainPage(r *web.Request) { c := gae.Context(r) q := datastore.NewQuery("Greeting").Order("-Date").Limit(10) var gg []*Greeting _, err := q.GetAll(c, &gg) if err != nil { r.Error(web.StatusInternalServerError, err) return } w := r.Respond(200, "Content-Type", "text/html") if err := mainPage.Execute(w, map[string]interface{}{ "xsrf": r.Param.Get("xsrf"), "gg": gg}); err != nil { c.Logf("%v", err) } }