Exemple #1
0
//TagDelete handles POST /admin/tags/:name/delete route
func TagDelete(c *gin.Context) {
	tag, _ := models.GetTag(c.Param("name"))
	if err := tag.Delete(); err != nil {
		c.HTML(http.StatusInternalServerError, "errors/500", nil)
		logrus.Error(err)
		return
	}
	c.Redirect(http.StatusFound, "/admin/tags")
}
Exemple #2
0
//TagGet handles GET /tags/:name route
func TagGet(c *gin.Context) {
	tag, err := models.GetTag(c.Param("name"))
	if err != nil {
		c.HTML(http.StatusNotFound, "errors/404", nil)
		return
	}
	list, err := models.GetPostsByTag(tag.Name)
	if err != nil {
		c.HTML(http.StatusNotFound, "errors/404", nil)
		return
	}

	h := helpers.DefaultH(c)
	h["Title"] = tag.Name
	h["Active"] = "tags"
	h["List"] = list
	c.HTML(http.StatusOK, "tags/show", h)
}