// POST page deletion request func PageDelete(c *gin.Context) { page, _ := models.GetPage(c.Param("id")) if err := page.Delete(); err != nil { c.HTML(http.StatusInternalServerError, "errors/500", nil) return } else { c.Redirect(http.StatusFound, "/admin/pages") } }
// GET /pages/:id route func PageGet(c *gin.Context) { page, err := models.GetPage(c.Param("id")) if err != nil || !page.Published { c.HTML(http.StatusNotFound, "errors/404", nil) return } h := helpers.DefaultH(c) h["Title"] = page.Name h["Description"] = template.HTML(string(blackfriday.MarkdownCommon([]byte(page.Description)))) h["Active"] = "pages" c.HTML(http.StatusOK, "pages/show", h) }
// GET page update form func PageEdit(c *gin.Context) { page, _ := models.GetPage(c.Param("id")) if page.Id == 0 { c.HTML(http.StatusNotFound, "errors/404", nil) return } h := helpers.DefaultH(c) h["Title"] = "Edit page" h["Active"] = "pages" h["Page"] = page session := sessions.Default(c) h["Flash"] = session.Flashes() session.Save() c.HTML(http.StatusOK, "admin/pages/form", h) }