From 1957dec764dcaf45cc927bd33d555c2479490379 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Sun, 30 Jan 2022 11:55:30 +0200 Subject: [PATCH] feat: rename all html files --- controllers/captcha_controller.go | 2 +- controllers/threads_controller.go | 80 +++++++++---------- .../{captcha.html => component_captcha.html} | 0 .../{footer.html => component_footer.html} | 0 .../{header.html => component_header.html} | 0 ...ost-form.html => component_post-form.html} | 0 ...namic.html => head_meta-tags-dynamic.html} | 0 ...static.html => head_meta-tags-static.html} | 0 templates/{static.html => head_static.html} | 0 templates/{400.html => page_400.html} | 0 templates/{404.html => page_404.html} | 0 templates/{500.html => page_500.html} | 0 templates/{index.html => page_index.html} | 0 templates/{thread.html => page_thread.html} | 0 14 files changed, 41 insertions(+), 41 deletions(-) rename templates/{captcha.html => component_captcha.html} (100%) rename templates/{footer.html => component_footer.html} (100%) rename templates/{header.html => component_header.html} (100%) rename templates/{post-form.html => component_post-form.html} (100%) rename templates/{meta-tags-dynamic.html => head_meta-tags-dynamic.html} (100%) rename templates/{meta-tags-static.html => head_meta-tags-static.html} (100%) rename templates/{static.html => head_static.html} (100%) rename templates/{400.html => page_400.html} (100%) rename templates/{404.html => page_404.html} (100%) rename templates/{500.html => page_500.html} (100%) rename templates/{index.html => page_index.html} (100%) rename templates/{thread.html => page_thread.html} (100%) diff --git a/controllers/captcha_controller.go b/controllers/captcha_controller.go index fbc27ad..421ec63 100644 --- a/controllers/captcha_controller.go +++ b/controllers/captcha_controller.go @@ -15,7 +15,7 @@ func GetCaptcha(c *gin.Context) { err := captcha.WriteImage(&content, ID, captcha.StdWidth, captcha.StdHeight) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } diff --git a/controllers/threads_controller.go b/controllers/threads_controller.go index a357da3..68590d8 100644 --- a/controllers/threads_controller.go +++ b/controllers/threads_controller.go @@ -22,12 +22,12 @@ func GetThreads(c *gin.Context) { pageString := c.DefaultQuery("page", "1") page, err := strconv.Atoi(pageString) if err != nil { - c.HTML(http.StatusNotFound, "404.html", nil) + c.HTML(http.StatusNotFound, "page_404.html", nil) return } if page <= 0 { - c.HTML(http.StatusNotFound, "404.html", nil) + c.HTML(http.StatusNotFound, "page_404.html", nil) return } @@ -36,19 +36,19 @@ func GetThreads(c *gin.Context) { threads, err := Repositories.Posts.Get(limit, offset) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } count, err := Repositories.Posts.GetCount() if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } pagesCount := int(math.Ceil(float64(count) / 10)) if page > pagesCount && count != 0 { - c.HTML(http.StatusNotFound, "404.html", nil) + c.HTML(http.StatusNotFound, "page_404.html", nil) return } @@ -62,24 +62,24 @@ func GetThreads(c *gin.Context) { IsCaptchaActive: Config.App.IsCaptchaActive, }, } - c.HTML(http.StatusOK, "index.html", htmlData) + c.HTML(http.StatusOK, "page_index.html", htmlData) } func GetThread(c *gin.Context) { threadIDString := c.Param("threadID") threadID, err := strconv.Atoi(threadIDString) if err != nil { - c.HTML(http.StatusNotFound, "404.html", nil) + c.HTML(http.StatusNotFound, "page_404.html", nil) return } thread, err := Repositories.Posts.GetThreadByPostID(threadID) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } if thread == nil { - c.HTML(http.StatusNotFound, "404.html", nil) + c.HTML(http.StatusNotFound, "page_404.html", nil) return } @@ -93,14 +93,14 @@ func GetThread(c *gin.Context) { IsCaptchaActive: Config.App.IsCaptchaActive, }, } - c.HTML(http.StatusOK, "thread.html", htmlData) + c.HTML(http.StatusOK, "page_thread.html", htmlData) } func CreateThread(c *gin.Context) { form, err := c.MultipartForm() if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } @@ -113,7 +113,7 @@ func CreateThread(c *gin.Context) { errorHtmlData := Repositories.BadRequestHtmlData{ Message: validationErrorMessage, } - c.HTML(http.StatusBadRequest, "400.html", errorHtmlData) + c.HTML(http.StatusBadRequest, "page_400.html", errorHtmlData) return } @@ -124,14 +124,14 @@ func CreateThread(c *gin.Context) { errorHtmlData := Repositories.BadRequestHtmlData{ Message: Repositories.InvalidCaptchaErrorMessage, } - c.HTML(http.StatusBadRequest, "400.html", errorHtmlData) + c.HTML(http.StatusBadRequest, "page_400.html", errorHtmlData) return } conn, err := Db.Pool.Acquire(context.TODO()) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } defer conn.Release() @@ -139,7 +139,7 @@ func CreateThread(c *gin.Context) { threadsCount, err := Repositories.Posts.GetCount() if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } @@ -147,13 +147,13 @@ func CreateThread(c *gin.Context) { oldestThreadUpdatedAt, err := Repositories.Posts.GetOldestThreadUpdatedAt() if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } err = Repositories.Posts.ArchiveThreadsFrom(oldestThreadUpdatedAt) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } } @@ -161,7 +161,7 @@ func CreateThread(c *gin.Context) { tx, err := conn.Begin(context.TODO()) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } defer tx.Rollback(context.TODO()) @@ -175,14 +175,14 @@ func CreateThread(c *gin.Context) { threadID, err := Repositories.Posts.CreateInTx(tx, post) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } err = Utils.CreateThreadFolder(threadID) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } @@ -198,7 +198,7 @@ func CreateThread(c *gin.Context) { fileID, err := Repositories.Files.CreateInTx(tx, file) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } @@ -211,21 +211,21 @@ func CreateThread(c *gin.Context) { err = c.SaveUploadedFile(fileInRequest, path) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } // creating thumbnail thumbImg, err := Utils.MakeImageThumbnail(path, file.Ext, threadID, fileID) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } // saving thumbnail err = Utils.SaveImageThumbnail(thumbImg, threadID, fileID, file.Ext) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } } @@ -240,7 +240,7 @@ func UpdateThread(c *gin.Context) { threadIDString := c.Param("threadID") threadID, err := strconv.Atoi(threadIDString) if err != nil { - c.HTML(http.StatusNotFound, "500.html", nil) + c.HTML(http.StatusNotFound, "page_500.html", nil) return } @@ -249,19 +249,19 @@ func UpdateThread(c *gin.Context) { errorHtmlData := Repositories.BadRequestHtmlData{ Message: Repositories.ThreadIsArchivedErrorMessage, } - c.HTML(http.StatusBadRequest, "400.html", errorHtmlData) + c.HTML(http.StatusBadRequest, "page_400.html", errorHtmlData) return } if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } form, err := c.MultipartForm() if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } @@ -273,7 +273,7 @@ func UpdateThread(c *gin.Context) { errorHtmlData := Repositories.BadRequestHtmlData{ Message: validationErrorMessage, } - c.HTML(http.StatusBadRequest, "400.html", errorHtmlData) + c.HTML(http.StatusBadRequest, "page_400.html", errorHtmlData) return } @@ -284,7 +284,7 @@ func UpdateThread(c *gin.Context) { errorHtmlData := Repositories.BadRequestHtmlData{ Message: Repositories.InvalidCaptchaErrorMessage, } - c.HTML(http.StatusBadRequest, "400.html", errorHtmlData) + c.HTML(http.StatusBadRequest, "page_400.html", errorHtmlData) return } @@ -298,7 +298,7 @@ func UpdateThread(c *gin.Context) { conn, err := Db.Pool.Acquire(context.TODO()) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } defer conn.Release() @@ -306,14 +306,14 @@ func UpdateThread(c *gin.Context) { tx, err := conn.Begin(context.TODO()) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } defer tx.Rollback(context.TODO()) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } post := Repositories.Post{ @@ -326,14 +326,14 @@ func UpdateThread(c *gin.Context) { postID, err := Repositories.Posts.CreateInTx(tx, post) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } postsCountInThread, err := Repositories.Posts.GetThreadPostsCount(threadID) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } isBumpLimit := postsCountInThread >= Config.App.ThreadBumpLimit @@ -342,7 +342,7 @@ func UpdateThread(c *gin.Context) { err = Repositories.Posts.BumpThreadInTx(tx, threadID) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } } @@ -359,7 +359,7 @@ func UpdateThread(c *gin.Context) { fileID, err := Repositories.Files.CreateInTx(tx, file) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } @@ -372,21 +372,21 @@ func UpdateThread(c *gin.Context) { err = c.SaveUploadedFile(fileInRequest, path) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } // creating thumbnail thumbImg, err := Utils.MakeImageThumbnail(path, file.Ext, threadID, fileID) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } // saving thumbnail err = Utils.SaveImageThumbnail(thumbImg, threadID, fileID, file.Ext) if err != nil { log.Println("error:", err) - c.HTML(http.StatusInternalServerError, "500.html", nil) + c.HTML(http.StatusInternalServerError, "page_500.html", nil) return } } diff --git a/templates/captcha.html b/templates/component_captcha.html similarity index 100% rename from templates/captcha.html rename to templates/component_captcha.html diff --git a/templates/footer.html b/templates/component_footer.html similarity index 100% rename from templates/footer.html rename to templates/component_footer.html diff --git a/templates/header.html b/templates/component_header.html similarity index 100% rename from templates/header.html rename to templates/component_header.html diff --git a/templates/post-form.html b/templates/component_post-form.html similarity index 100% rename from templates/post-form.html rename to templates/component_post-form.html diff --git a/templates/meta-tags-dynamic.html b/templates/head_meta-tags-dynamic.html similarity index 100% rename from templates/meta-tags-dynamic.html rename to templates/head_meta-tags-dynamic.html diff --git a/templates/meta-tags-static.html b/templates/head_meta-tags-static.html similarity index 100% rename from templates/meta-tags-static.html rename to templates/head_meta-tags-static.html diff --git a/templates/static.html b/templates/head_static.html similarity index 100% rename from templates/static.html rename to templates/head_static.html diff --git a/templates/400.html b/templates/page_400.html similarity index 100% rename from templates/400.html rename to templates/page_400.html diff --git a/templates/404.html b/templates/page_404.html similarity index 100% rename from templates/404.html rename to templates/page_404.html diff --git a/templates/500.html b/templates/page_500.html similarity index 100% rename from templates/500.html rename to templates/page_500.html diff --git a/templates/index.html b/templates/page_index.html similarity index 100% rename from templates/index.html rename to templates/page_index.html diff --git a/templates/thread.html b/templates/page_thread.html similarity index 100% rename from templates/thread.html rename to templates/page_thread.html