func AdminArticle(context *GoInk.Context) { articles, pager := model.GetArticleList(context.Int("page"), 10) context.Layout("admin") context.Render("admin/articles", map[string]interface{}{ "Title": "文章", "Articles": articles, "Pager": pager, }) }
func AdminPage(context *GoInk.Context) { pages, pager := model.GetPageList(context.Int("page"), 10) context.Layout("admin") context.Render("admin/pages", map[string]interface{}{ "Title": "页面", "Pages": pages, "Pager": pager, }) }
func AdminFiles(context *GoInk.Context) { if context.Method == "DELETE" { id := context.Int("id") model.RemoveFile(id) Json(context, true).End() return } files, pager := model.GetFileList(context.Int("page"), 10) context.Layout("admin") context.Render("admin/files", map[string]interface{}{ "Title": "媒体文件", "Files": files, "Pager": pager, }) }
func AdminComments(context *GoInk.Context) { if context.Method == "DELETE" { id := context.Int("id") cmt := model.GetCommentById(id) model.RemoveComment(cmt.Cid, id) Json(context, true).End() return } if context.Method == "PUT" { id := context.Int("id") cmt2 := model.GetCommentById(id) cmt2.Status = "approved" cmt2.GetReader().Active = true model.SaveComment(cmt2) Json(context, true).End() return } if context.Method == "POST" { // get required data pid := context.Int("pid") cid := model.GetCommentById(pid).Cid uid, _ := strconv.Atoi(context.Cookie("token-user")) user := model.GetUserById(uid) co := new(model.Comment) co.Author = user.Nick co.Email = user.Email co.Url = user.Url co.Content = strings.Replace(utils.Html2str(context.String("content")), "\n", "<br/>", -1) co.Avatar = utils.Gravatar(co.Email, "50") co.Pid = pid co.Ip = context.Ip co.UserAgent = context.UserAgent co.IsAdmin = true model.CreateComment(cid, co) Json(context, true).Set("comment", co.ToJson()).End() return } page := context.IntOr("page", 1) comments, pager := model.GetCommentList(page, 6) context.Layout("admin") context.Render("admin/comments", map[string]interface{}{ "Title": "评论", "Comments": comments, "Pager": pager, }) }