From 18224a5f05b7f3fc7f5e5bf216db59fc2dfa66bd Mon Sep 17 00:00:00 2001 From: Bagas Aulia Rezki Date: Thu, 13 Jun 2024 15:34:57 +0700 Subject: [PATCH 1/4] Remove unuse route --- routes/routes.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/routes/routes.go b/routes/routes.go index a5a3e98..51c46df 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -193,11 +193,6 @@ func SetupRoutes() *http.ServeMux { http.ServeFile(w, r, "public/favicon.ico") }) - //TODO add error message catching to the middleware so we can show the error message at the error page - handler.HandleFunc("/test", func(w http.ResponseWriter, r *http.Request) { - http.Error(w, "anjay", http.StatusInternalServerError) - }) - fileServer := http.FileServer(http.Dir("./public")) handler.Handle("/public/", http.StripPrefix("/public", fileServer)) From c5c697a84c87db79d60b8b0da2ed5867aa39a352 Mon Sep 17 00:00:00 2001 From: Bagas Aulia Rezki Date: Thu, 13 Jun 2024 15:39:13 +0700 Subject: [PATCH 2/4] Correct a typo --- view/upload/upload.templ | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/view/upload/upload.templ b/view/upload/upload.templ index 6f22ae8..995a3e1 100644 --- a/view/upload/upload.templ +++ b/view/upload/upload.templ @@ -18,14 +18,10 @@ templ content(title string) { stroke-width="2" d="M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2" /> -

Click to upload or drag and drop

-

SVG, PNG, JPG or GIF (MAX. - 800x400px)

+

Click to upload or drag and drop

-
Go back to homepage diff --git a/view/index/index.templ b/view/index/index.templ index 5de6c4b..ba6b13f 100644 --- a/view/index/index.templ +++ b/view/index/index.templ @@ -20,12 +20,12 @@ templ content(title string, user types.User) {
if user.Authenticated { + href="/user" hx-get="/user" hx-swap="outerHTML" hx-push-url="true" hx-target="#content"> Open Dashboard } else { + href="/signup" hx-get="/signup" hx-swap="outerHTML" hx-push-url="true" hx-target="#content"> Get started } diff --git a/view/layout/base.templ b/view/layout/base.templ index 6dabc6e..435614f 100644 --- a/view/layout/base.templ +++ b/view/layout/base.templ @@ -13,9 +13,12 @@ templ Base(title string){ { title } + - { children... } +
+ { children... } +
} @@ -70,10 +73,10 @@ templ Navbar(user types.User) {
} else { - + Sign up - + Sign in } diff --git a/view/signin/signin.templ b/view/signin/signin.templ index 6f6115b..53d0253 100644 --- a/view/signin/signin.templ +++ b/view/signin/signin.templ @@ -29,7 +29,7 @@ templ content(err types.Message, title string) {
@@ -52,7 +52,7 @@ templ content(err types.Message, title string) {
Don't have an account? - + Sign up
diff --git a/view/signup/signup.templ b/view/signup/signup.templ index 229ee84..c3d36a4 100644 --- a/view/signup/signup.templ +++ b/view/signup/signup.templ @@ -81,7 +81,7 @@ templ form(err types.Message, title string) {
Already have an account? - + Sign in
diff --git a/view/user/user.templ b/view/user/user.templ index c84b957..0825dda 100644 --- a/view/user/user.templ +++ b/view/user/user.templ @@ -221,12 +221,12 @@ templ content(title string, user types.User, ListSession []*session.SessionInfo)
+ type="button" href="/upload" hx-get="/upload" hx-swap="outerHTML" hx-push-url="true" hx-target="#content"> Upload + type="button" href="/download" hx-get="/download" hx-swap="outerHTML" hx-push-url="true" hx-target="#content"> Download From f82377e5f85eb0a0f1c27de4c6c812d6662c3069 Mon Sep 17 00:00:00 2001 From: Bagas Aulia Rezki Date: Thu, 13 Jun 2024 17:24:13 +0700 Subject: [PATCH 4/4] Remove newline from the HTTP request logger --- middleware/middleware.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleware/middleware.go b/middleware/middleware.go index d655d5b..c30578c 100644 --- a/middleware/middleware.go +++ b/middleware/middleware.go @@ -64,7 +64,7 @@ func Handler(next http.Handler) http.Handler { writer.Header().Set("Access-Control-Allow-Methods", fmt.Sprintf("%s, OPTIONS", utils.Getenv("CORS_METHODS"))) writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization") next.ServeHTTP(wrappedWriter, request) - log.Info(fmt.Sprintf("%s %s %s %v \n", utils.ClientIP(request), request.Method, request.RequestURI, wrappedWriter.statusCode)) + log.Info(fmt.Sprintf("%s %s %s %v", utils.ClientIP(request), request.Method, request.RequestURI, wrappedWriter.statusCode)) }) }