func (c *NoteController) New() { uname := c.Ctx.GetCookie("uname") if uname == "" { c.Ctx.SetCookie("uname", models.GenerateUUID()) } c.TplNames = "note/new.tpl" }
func (c *NoteController) Submit() { uname := c.Ctx.GetCookie("uname") if uname == "" { uname = models.GenerateUUID() c.Ctx.SetCookie("uname", uname) } noteContent := html.EscapeString(c.Input().Get("noteContent")) if noteEntry, err := models.NewNoteEntry(uname, noteContent); err != nil { c.Data["json"] = makeAjaxResponse(false, "", "something wrong with server") } else { beego.Debug(noteEntry.GetUrl()) c.Data["json"] = makeAjaxResponse(true, noteEntry.GetUrl(), "succ") } c.ServeJson() }