From d2760f1f39422b2cd2432bab0df87a152aed94fa Mon Sep 17 00:00:00 2001 From: kingjulienboss <147748708+kingjulienboss@users.noreply.github.com> Date: Tue, 9 Apr 2024 14:41:33 +0200 Subject: [PATCH 1/6] make docs more clear --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e601f30..2f4bf9d 100755 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ This project is a cms for hosting your videos. +## Documentation + Follow the documentation to setup VideoCMS: [https://videocms-docs.vercel.app/](https://videocms-docs.vercel.app/) ## Screenshots From febc89c2801a512fe6e75b78ddca55c2e1cccd0b Mon Sep 17 00:00:00 2001 From: kingjulienboss <147748708+kingjulienboss@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:15:22 +0200 Subject: [PATCH 2/6] rename fileId to LinkId --- controllers/CreateTagController.go | 2 +- controllers/DeleteTagController.go | 2 +- models/Tag.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/controllers/CreateTagController.go b/controllers/CreateTagController.go index 3c6648a..992df5c 100755 --- a/controllers/CreateTagController.go +++ b/controllers/CreateTagController.go @@ -15,7 +15,7 @@ func CreateTagController(c echo.Context) error { return c.String(status, err.Error()) } - status, dbTag, err := logic.CreateTag(validator.Name, validator.FileID, c.Get("UserID").(uint)) + status, dbTag, err := logic.CreateTag(validator.Name, validator.LinkId, c.Get("UserID").(uint)) if err != nil { return c.String(status, err.Error()) diff --git a/controllers/DeleteTagController.go b/controllers/DeleteTagController.go index c0cf333..a0c28c1 100755 --- a/controllers/DeleteTagController.go +++ b/controllers/DeleteTagController.go @@ -15,7 +15,7 @@ func DeleteTagController(c echo.Context) error { return c.String(status, err.Error()) } - status, err := logic.DeleteTag(validator.TagID, validator.FileID, c.Get("UserID").(uint)) + status, err := logic.DeleteTag(validator.TagID, validator.LinkId, c.Get("UserID").(uint)) if err != nil { return c.String(status, err.Error()) diff --git a/models/Tag.go b/models/Tag.go index b16eaf7..9872815 100644 --- a/models/Tag.go +++ b/models/Tag.go @@ -23,10 +23,10 @@ type TagLinks struct { type TagCreateValidation struct { Name string `validate:"required,min=1,max=120" json:"Name" form:"Name"` - FileID uint `validate:"required,number" json:"FileID" form:"FileID"` + LinkId uint `validate:"required,number" json:"LinkId" form:"LinkId"` } type TagDeleteValidation struct { TagID uint `validate:"required,number" json:"TagID" form:"TagID"` - FileID uint `validate:"required,number" json:"FileID" form:"FileID"` + LinkId uint `validate:"required,number" json:"LinkId" form:"LinkId"` } From c6943c14fb4f4c82a3754ac6fa59fd22234b4309 Mon Sep 17 00:00:00 2001 From: kingjulienboss <147748708+kingjulienboss@users.noreply.github.com> Date: Tue, 9 Apr 2024 15:29:58 +0200 Subject: [PATCH 3/6] rename TagID to TagId --- controllers/DeleteTagController.go | 2 +- models/Tag.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/DeleteTagController.go b/controllers/DeleteTagController.go index a0c28c1..6097918 100755 --- a/controllers/DeleteTagController.go +++ b/controllers/DeleteTagController.go @@ -15,7 +15,7 @@ func DeleteTagController(c echo.Context) error { return c.String(status, err.Error()) } - status, err := logic.DeleteTag(validator.TagID, validator.LinkId, c.Get("UserID").(uint)) + status, err := logic.DeleteTag(validator.TagId, validator.LinkId, c.Get("UserID").(uint)) if err != nil { return c.String(status, err.Error()) diff --git a/models/Tag.go b/models/Tag.go index 9872815..114dae4 100644 --- a/models/Tag.go +++ b/models/Tag.go @@ -27,6 +27,6 @@ type TagCreateValidation struct { } type TagDeleteValidation struct { - TagID uint `validate:"required,number" json:"TagID" form:"TagID"` + TagId uint `validate:"required,number" json:"TagId" form:"TagId"` LinkId uint `validate:"required,number" json:"LinkId" form:"LinkId"` } From 2758a9394515eccb749a22a3e89e0f4f1ca224f0 Mon Sep 17 00:00:00 2001 From: kirari04 Date: Tue, 9 Apr 2024 17:21:36 +0200 Subject: [PATCH 4/6] fix method on create web page --- routes/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api.go b/routes/api.go index 46591ef..9479fab 100755 --- a/routes/api.go +++ b/routes/api.go @@ -64,7 +64,7 @@ func Api() { protectedApi.GET("/servers", controllers.ListServers, middlewares.IsAdmin()) protectedApi.GET("/pages", controllers.ListWebPage, middlewares.IsAdmin()) - protectedApi.GET("/page", controllers.CreateWebPage, middlewares.IsAdmin()) + protectedApi.POST("/page", controllers.CreateWebPage, middlewares.IsAdmin()) protectedApi.PUT("/page", controllers.UpdateWebPage, middlewares.IsAdmin()) protectedApi.DELETE("/page", controllers.DeleteWebPage, middlewares.IsAdmin()) From d86e1a921ae464e93fef514e49d3397884df597f Mon Sep 17 00:00:00 2001 From: kirari04 Date: Tue, 9 Apr 2024 17:24:45 +0200 Subject: [PATCH 5/6] removed dirpath validation --- models/WebPage.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/WebPage.go b/models/WebPage.go index d781e48..69ba6bc 100644 --- a/models/WebPage.go +++ b/models/WebPage.go @@ -9,7 +9,7 @@ type WebPage struct { } type WebPageCreateValidation struct { - Path string `validate:"required,dirpath,min=2,max=50"` + Path string `validate:"required,min=2,max=50"` Title string `validate:"required,min=2,max=128"` Html string `validate:"required,min=0,max=50000"` ListInFooter *bool `validate:"required,boolean"` @@ -17,7 +17,7 @@ type WebPageCreateValidation struct { type WebPageUpdateValidation struct { WebPageID uint `validate:"required,number"` - Path string `validate:"required,dirpath,min=2,max=50"` + Path string `validate:"required,min=2,max=50"` Title string `validate:"required,min=2,max=128"` Html string `validate:"required,min=0,max=50000"` ListInFooter *bool `validate:"required,boolean"` @@ -28,5 +28,5 @@ type WebPageDeleteValidation struct { } type WebPageGetValidation struct { - Path string `validate:"required,dirpath,min=2,max=50" query:"Path"` + Path string `validate:"required,min=2,max=50" query:"Path"` } From 8052e96afcf9dccb3e5c74f2cb1627e2085620f3 Mon Sep 17 00:00:00 2001 From: kirari04 Date: Tue, 9 Apr 2024 17:31:25 +0200 Subject: [PATCH 6/6] add trailing slash --- controllers/CreateWebPageController.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controllers/CreateWebPageController.go b/controllers/CreateWebPageController.go index 41da4da..20b15a4 100755 --- a/controllers/CreateWebPageController.go +++ b/controllers/CreateWebPageController.go @@ -4,6 +4,7 @@ import ( "ch/kirari04/videocms/helpers" "ch/kirari04/videocms/inits" "ch/kirari04/videocms/models" + "fmt" "log" "net/http" @@ -28,6 +29,10 @@ func CreateWebPage(c echo.Context) error { return c.String(http.StatusBadRequest, "Path already used") } + if validatus.Path[len(validatus.Path)-1] != '/' { + validatus.Path = fmt.Sprintf("%s/", validatus.Path) + } + webPage := models.WebPage{ Path: validatus.Path, Title: validatus.Title,