feat: better public wishlist text
This commit is contained in:
parent
0cc6abe03b
commit
04dc7e9376
|
|
@ -39,12 +39,12 @@ func (ctx *Context) ForeignWishlist(w http.ResponseWriter, r *http.Request) {
|
||||||
templates.Execute(w, "foreign_wishlist.gotmpl", p)
|
templates.Execute(w, "foreign_wishlist.gotmpl", p)
|
||||||
}
|
}
|
||||||
|
|
||||||
type publicForeignWishlistProps struct {
|
type publicWishlistProps struct {
|
||||||
Username string
|
Username string
|
||||||
GiftCount int
|
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")
|
userReference := r.PathValue("userReference")
|
||||||
otherUser, err := db.GetUserByReference(userReference)
|
otherUser, err := db.GetUserByReference(userReference)
|
||||||
if err != nil {
|
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)
|
error.Page(w, "An error occurred while fetching data about this user :(", http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p := publicForeignWishlistProps{Username: otherUser.Name, GiftCount: giftCount}
|
p := publicWishlistProps{Username: otherUser.Name, GiftCount: giftCount}
|
||||||
templates.Execute(w, "public_foreign_wishlist.gotmpl", p)
|
templates.Execute(w, "public_foreign_wishlist.gotmpl", p)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
main.go
2
main.go
|
|
@ -33,7 +33,7 @@ func main() {
|
||||||
publicMux.HandleFunc("POST /register", authMiddleware.RegisterPost)
|
publicMux.HandleFunc("POST /register", authMiddleware.RegisterPost)
|
||||||
publicMux.HandleFunc("GET /", authMiddleware.Login)
|
publicMux.HandleFunc("GET /", authMiddleware.Login)
|
||||||
publicMux.HandleFunc("POST /", authMiddleware.LoginPost)
|
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("GET /{$}", ctx.Home)
|
||||||
protectedMux.HandleFunc("POST /{$}", ctx.HomePost)
|
protectedMux.HandleFunc("POST /{$}", ctx.HomePost)
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,14 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h2>{{.Username}}'s list</h2>
|
<h2>{{.Username}}'s list</h2>
|
||||||
{{if eq .GiftCount 0}}
|
{{if eq .GiftCount 0}}
|
||||||
<p>{{.Username}} doesn't have any gift ideas!</p>
|
<p>{{.Username}} hasn't written any gift ideas!</p>
|
||||||
<p>{{template "login_prompt"}} to add some! :^)</p>
|
<p>{{template "login_prompt"}} to add some! :^)</p>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{if eq .GiftCount 1}}
|
{{if eq .GiftCount 1}}
|
||||||
<p>{{.Username}} only has one gift idea.</p>
|
<p>{{.Username}} has only written one gift idea.</p>
|
||||||
<p>{{template "login_prompt"}} to claim it, or add more! :^)</p>
|
<p>{{template "login_prompt"}} to claim it, or add more! :^)</p>
|
||||||
{{else}}
|
{{else}}
|
||||||
<p>{{.Username}} has {{.GiftCount}} gift ideas.</p>
|
<p>{{.Username}} has written {{.GiftCount}} gift ideas.</p>
|
||||||
<p>{{template "login_prompt"}} to claim an idea, or add more! :^)</p>
|
<p>{{template "login_prompt"}} to claim an idea, or add more! :^)</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
||||||
|
|
@ -30,14 +30,14 @@ func loadTemplates() map[string]*template.Template {
|
||||||
loginTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/login.gotmpl"))
|
loginTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/login.gotmpl"))
|
||||||
registerTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/register.gotmpl"))
|
registerTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/register.gotmpl"))
|
||||||
foreignTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/foreign_wishlist.gotmpl"))
|
foreignTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/foreign_wishlist.gotmpl"))
|
||||||
publicForeignTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/public_foreign_wishlist.gotmpl"))
|
publicWishlistTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/public_foreign_wishlist.gotmpl"))
|
||||||
errorTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/error_page.gotmpl"))
|
errorTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/error_page.gotmpl"))
|
||||||
return map[string]*template.Template{
|
return map[string]*template.Template{
|
||||||
"home.gotmpl": homeTmpl,
|
"home.gotmpl": homeTmpl,
|
||||||
"login.gotmpl": loginTmpl,
|
"login.gotmpl": loginTmpl,
|
||||||
"register.gotmpl": registerTmpl,
|
"register.gotmpl": registerTmpl,
|
||||||
"foreign_wishlist.gotmpl": foreignTmpl,
|
"foreign_wishlist.gotmpl": foreignTmpl,
|
||||||
"public_foreign_wishlist.gotmpl": publicForeignTmpl,
|
"public_foreign_wishlist.gotmpl": publicWishlistTmpl,
|
||||||
"error_page.gotmpl": errorTmpl,
|
"error_page.gotmpl": errorTmpl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue