Beispiel #1
0
//PageDelete handles POST /admin/pages/:id/delete route
func PageDelete(c *gin.Context) {
	page, _ := models.GetPage(c.Param("id"))
	if err := page.Delete(); err != nil {
		c.HTML(http.StatusInternalServerError, "errors/500", nil)
		logrus.Error(err)
		return
	}
	c.Redirect(http.StatusFound, "/admin/pages")
}
Beispiel #2
0
//PageGet handles 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)
}
Beispiel #3
0
//PageEdit handles GET /admin/pages/:id/edit route
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, "pages/form", h)
}