mirror of
https://github.com/JustKato/FreePad.git
synced 2026-02-23 15:50:46 +02:00
+ Deletion implemented
This commit is contained in:
@@ -64,7 +64,18 @@ func AdminRoutes(router *gin.RouterGroup) {
|
||||
})
|
||||
|
||||
router.GET("/delete/:padname", func(ctx *gin.Context) {
|
||||
// Get the pad name that we bout' to delete
|
||||
padName := ctx.Param("padname")
|
||||
|
||||
// Try and get the pad, check if valid
|
||||
pad := objects.GetPost(padName, false)
|
||||
|
||||
// Delete the pad
|
||||
err := pad.Delete()
|
||||
fmt.Println(err)
|
||||
|
||||
// Redirect the user to the admin page
|
||||
ctx.Redirect(http.StatusFound, "/admin/view")
|
||||
})
|
||||
|
||||
// Admin view route
|
||||
@@ -73,8 +84,6 @@ func AdminRoutes(router *gin.RouterGroup) {
|
||||
// Get all of the pads as a listing
|
||||
padList := objects.GetAllPosts()
|
||||
|
||||
fmt.Println(padList)
|
||||
|
||||
ctx.HTML(200, "admin_view.html", gin.H{
|
||||
"title": "Admin",
|
||||
"padList": padList,
|
||||
|
||||
@@ -41,7 +41,7 @@ func HomeRoutes(router *gin.Engine) {
|
||||
}
|
||||
postName = sanitize.XSS(sanitize.SingleLine(postName))
|
||||
|
||||
post := objects.GetPost(postName)
|
||||
post := objects.GetPost(postName, true)
|
||||
|
||||
c.HTML(200, "page.html", gin.H{
|
||||
"title": postName,
|
||||
|
||||
Reference in New Issue
Block a user