From 04dc7e9376d4574235d575b784ff6343d472ed6b Mon Sep 17 00:00:00 2001 From: Teajey <21069848+Teajey@users.noreply.github.com> Date: Sat, 26 Oct 2024 12:39:41 +0900 Subject: [PATCH] feat: better public wishlist text --- context/foreign_wishlist.go | 6 +++--- main.go | 2 +- templates/public_foreign_wishlist.gotmpl | 8 ++++---- templates/templates.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/context/foreign_wishlist.go b/context/foreign_wishlist.go index d27f4a5..ce8165c 100644 --- a/context/foreign_wishlist.go +++ b/context/foreign_wishlist.go @@ -39,12 +39,12 @@ func (ctx *Context) ForeignWishlist(w http.ResponseWriter, r *http.Request) { templates.Execute(w, "foreign_wishlist.gotmpl", p) } -type publicForeignWishlistProps struct { +type publicWishlistProps struct { Username string GiftCount int } -func (ctx *Context) PublicForeignWishlist(w http.ResponseWriter, r *http.Request) { +func (ctx *Context) PublicWishlist(w http.ResponseWriter, r *http.Request) { userReference := r.PathValue("userReference") otherUser, err := db.GetUserByReference(userReference) if err != nil { @@ -60,6 +60,6 @@ func (ctx *Context) PublicForeignWishlist(w http.ResponseWriter, r *http.Request error.Page(w, "An error occurred while fetching data about this user :(", http.StatusInternalServerError, err) return } - p := publicForeignWishlistProps{Username: otherUser.Name, GiftCount: giftCount} + p := publicWishlistProps{Username: otherUser.Name, GiftCount: giftCount} templates.Execute(w, "public_foreign_wishlist.gotmpl", p) } diff --git a/main.go b/main.go index d58fa5c..5ceca5e 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,7 @@ func main() { publicMux.HandleFunc("POST /register", authMiddleware.RegisterPost) publicMux.HandleFunc("GET /", authMiddleware.Login) publicMux.HandleFunc("POST /", authMiddleware.LoginPost) - publicMux.HandleFunc("GET /list/{userReference}", ctx.PublicForeignWishlist) + publicMux.HandleFunc("GET /list/{userReference}", ctx.PublicWishlist) protectedMux.HandleFunc("GET /{$}", ctx.Home) protectedMux.HandleFunc("POST /{$}", ctx.HomePost) diff --git a/templates/public_foreign_wishlist.gotmpl b/templates/public_foreign_wishlist.gotmpl index 5e85b6b..3cd4206 100644 --- a/templates/public_foreign_wishlist.gotmpl +++ b/templates/public_foreign_wishlist.gotmpl @@ -19,14 +19,14 @@
{{.Username}} doesn't have any gift ideas!
+{{.Username}} hasn't written any gift ideas!
{{template "login_prompt"}} to add some! :^)
{{else}} {{if eq .GiftCount 1}} -{{.Username}} only has one gift idea.
+{{.Username}} has only written one gift idea.
{{template "login_prompt"}} to claim it, or add more! :^)
{{else}} -{{.Username}} has {{.GiftCount}} gift ideas.
+{{.Username}} has written {{.GiftCount}} gift ideas.
{{template "login_prompt"}} to claim an idea, or add more! :^)
{{end}} {{end}} @@ -34,4 +34,4 @@