RSVP 0.13.0 and fix templates
This commit is contained in:
parent
dfa2525714
commit
c763ff40d4
|
|
@ -5,7 +5,7 @@ go 1.23.3
|
||||||
toolchain go1.24.5
|
toolchain go1.24.5
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Teajey/rsvp v0.11.0
|
github.com/Teajey/rsvp v0.13.0
|
||||||
github.com/Teajey/sqlstore v0.0.6
|
github.com/Teajey/sqlstore v0.0.6
|
||||||
github.com/gorilla/sessions v1.4.0
|
github.com/gorilla/sessions v1.4.0
|
||||||
golang.org/x/crypto v0.22.0
|
golang.org/x/crypto v0.22.0
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
github.com/Teajey/rsvp v0.11.0 h1:ePx7Oj0nDYRCmFB6fQvSQbYUcWhgqTh9fh8PaHlOnwk=
|
github.com/Teajey/rsvp v0.13.0 h1:EeuHMHtU2/eLuSbCIlzKqy5FI9f6Qq+yUJnrVPBJvKk=
|
||||||
github.com/Teajey/rsvp v0.11.0/go.mod h1:WCWos0l+K/9heUuvbIUXkKAHAtxoLpkJ43C/fszD4RY=
|
github.com/Teajey/rsvp v0.13.0/go.mod h1:WCWos0l+K/9heUuvbIUXkKAHAtxoLpkJ43C/fszD4RY=
|
||||||
github.com/Teajey/sqlstore v0.0.6 h1:kUEpA+3BKFHZl128MuMeYY6zVcmq1QmOlNyofcFEJOA=
|
github.com/Teajey/sqlstore v0.0.6 h1:kUEpA+3BKFHZl128MuMeYY6zVcmq1QmOlNyofcFEJOA=
|
||||||
github.com/Teajey/sqlstore v0.0.6/go.mod h1:hjk0S593/2Q4QxkEXCgpThj9w5KWGTQi9JtgfziHXXk=
|
github.com/Teajey/sqlstore v0.0.6/go.mod h1:hjk0S593/2Q4QxkEXCgpThj9w5KWGTQi9JtgfziHXXk=
|
||||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package response
|
package response
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"lishwist/http/templates"
|
"lishwist/http/templates"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -17,7 +16,7 @@ type ServeMux struct {
|
||||||
|
|
||||||
func NewServeMux(store *sqlstore.Store) *ServeMux {
|
func NewServeMux(store *sqlstore.Store) *ServeMux {
|
||||||
mux := rsvp.NewServeMux()
|
mux := rsvp.NewServeMux()
|
||||||
mux.Config.HtmlTemplate = templates.Templates["login.gotmpl"]
|
mux.Config.HtmlTemplate = templates.Template
|
||||||
return &ServeMux{
|
return &ServeMux{
|
||||||
inner: mux,
|
inner: mux,
|
||||||
store: store,
|
store: store,
|
||||||
|
|
@ -35,7 +34,7 @@ type Handler interface {
|
||||||
type HandlerFunc func(*Session, http.Header, *http.Request) rsvp.Response
|
type HandlerFunc func(*Session, http.Header, *http.Request) rsvp.Response
|
||||||
|
|
||||||
func (m *ServeMux) HandleFunc(pattern string, handler HandlerFunc) {
|
func (m *ServeMux) HandleFunc(pattern string, handler HandlerFunc) {
|
||||||
m.inner.Std.HandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) {
|
m.inner.MiddleHandleFunc(pattern, func(w http.ResponseWriter, r *http.Request) rsvp.Response {
|
||||||
session := m.GetSession(r)
|
session := m.GetSession(r)
|
||||||
|
|
||||||
response := handler(session, w.Header(), r)
|
response := handler(session, w.Header(), r)
|
||||||
|
|
@ -47,10 +46,7 @@ func (m *ServeMux) HandleFunc(pattern string, handler HandlerFunc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := response.Write(w, r, m.inner.Config)
|
return response
|
||||||
if err != nil {
|
|
||||||
panic(fmt.Sprintf("Failed to write rsvp.Response: %s", err))
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,10 @@ type Session struct {
|
||||||
|
|
||||||
func (s *Session) FlashGet() any {
|
func (s *Session) FlashGet() any {
|
||||||
list := s.inner.Flashes()
|
list := s.inner.Flashes()
|
||||||
s.written = true
|
|
||||||
if len(list) < 1 {
|
if len(list) < 1 {
|
||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
|
s.written = true
|
||||||
return list[0]
|
return list[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ type foreignWishlistProps struct {
|
||||||
func ForeignWishlist(app *lishwist.Session, h http.Header, r *http.Request) rsvp.Response {
|
func ForeignWishlist(app *lishwist.Session, h http.Header, r *http.Request) rsvp.Response {
|
||||||
userReference := r.PathValue("userReference")
|
userReference := r.PathValue("userReference")
|
||||||
if app.User.Reference == userReference {
|
if app.User.Reference == userReference {
|
||||||
return rsvp.SeeOther("/")
|
return rsvp.Found("/", "You're not allowed to view your own wishlist!")
|
||||||
}
|
}
|
||||||
otherUser, err := lishwist.GetUserByReference(userReference)
|
otherUser, err := lishwist.GetUserByReference(userReference)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -44,12 +44,14 @@ func LoginPost(session *response.Session, h http.Header, r *http.Request) rsvp.R
|
||||||
|
|
||||||
props := api.NewLoginProps(username, password)
|
props := api.NewLoginProps(username, password)
|
||||||
|
|
||||||
|
resp := rsvp.SeeOther(r.URL.Path, props)
|
||||||
|
|
||||||
valid := props.Validate()
|
valid := props.Validate()
|
||||||
props.Password.Value = ""
|
props.Password.Value = ""
|
||||||
if !valid {
|
if !valid {
|
||||||
session.FlashSet(&props)
|
session.FlashSet(&props)
|
||||||
log.Printf("Invalid props: %#v\n", props)
|
log.Printf("Invalid props: %#v\n", props)
|
||||||
return rsvp.SeeOther("/")
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
app, err := lishwist.Login(username, password)
|
app, err := lishwist.Login(username, password)
|
||||||
|
|
@ -59,12 +61,12 @@ func LoginPost(session *response.Session, h http.Header, r *http.Request) rsvp.R
|
||||||
props.GeneralError = "Username or password invalid"
|
props.GeneralError = "Username or password invalid"
|
||||||
session.FlashSet(&props)
|
session.FlashSet(&props)
|
||||||
log.Printf("Invalid credentials: %s: %#v\n", err, props)
|
log.Printf("Invalid credentials: %s: %#v\n", err, props)
|
||||||
return rsvp.SeeOther("/")
|
return resp
|
||||||
default:
|
default:
|
||||||
props.GeneralError = "Something went wrong."
|
props.GeneralError = "Something went wrong."
|
||||||
session.FlashSet(&props)
|
session.FlashSet(&props)
|
||||||
log.Printf("Login error: %s\n", err)
|
log.Printf("Login error: %s\n", err)
|
||||||
return rsvp.SeeOther("/")
|
return resp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,5 +74,5 @@ func LoginPost(session *response.Session, h http.Header, r *http.Request) rsvp.R
|
||||||
session.SetValue("authorized", true)
|
session.SetValue("authorized", true)
|
||||||
session.SetValue("username", app.User.Name)
|
session.SetValue("username", app.User.Name)
|
||||||
|
|
||||||
return rsvp.SeeOther(r.URL.Path)
|
return rsvp.SeeOther(r.URL.Path, "Login successful!")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,5 @@ func LogoutPost(session *response.Session, h http.Header, r *http.Request) rsvp.
|
||||||
session.Options().MaxAge = 0
|
session.Options().MaxAge = 0
|
||||||
session.ClearValues()
|
session.ClearValues()
|
||||||
|
|
||||||
return rsvp.SeeOther("/")
|
return rsvp.SeeOther("/", "Logout successful")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,8 @@ func RegisterPost(s *response.Session, h http.Header, r *http.Request) rsvp.Resp
|
||||||
props.ConfirmPassword.Value = ""
|
props.ConfirmPassword.Value = ""
|
||||||
if !valid {
|
if !valid {
|
||||||
s.FlashSet(&props)
|
s.FlashSet(&props)
|
||||||
log.Printf("Invalid props: %#v\n", props)
|
log.Printf("Invalid register props: %#v\n", props)
|
||||||
return rsvp.SeeOther("/")
|
return rsvp.SeeOther(r.URL.Path, props)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = lishwist.Register(username, newPassword)
|
_, err = lishwist.Register(username, newPassword)
|
||||||
|
|
@ -58,9 +58,9 @@ func RegisterPost(s *response.Session, h http.Header, r *http.Request) rsvp.Resp
|
||||||
}
|
}
|
||||||
s.FlashSet(&props)
|
s.FlashSet(&props)
|
||||||
log.Printf("Registration failed: %s\n", err)
|
log.Printf("Registration failed: %s\n", err)
|
||||||
return rsvp.SeeOther("/register")
|
return rsvp.SeeOther(r.URL.Path, props)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.FlashSet(true)
|
s.FlashSet(true)
|
||||||
return rsvp.SeeOther("/")
|
return rsvp.SeeOther("/", "Registration successful!")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,5 +34,5 @@ func TodoUpdate(app *lishwist.Session, h http.Header, r *http.Request) rsvp.Resp
|
||||||
default:
|
default:
|
||||||
return response.Error(http.StatusBadRequest, "Invalid intent")
|
return response.Error(http.StatusBadRequest, "Invalid intent")
|
||||||
}
|
}
|
||||||
return rsvp.SeeOther("/")
|
return rsvp.SeeOther("/", "Update successful")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ func WishlistAdd(app *lishwist.Session, h http.Header, r *http.Request) rsvp.Res
|
||||||
log.Printf("%s\n", err)
|
log.Printf("%s\n", err)
|
||||||
return response.Error(http.StatusInternalServerError, "Failed to add gift.")
|
return response.Error(http.StatusInternalServerError, "Failed to add gift.")
|
||||||
}
|
}
|
||||||
return rsvp.SeeOther("/")
|
return rsvp.SeeOther("/", "Wish added!")
|
||||||
}
|
}
|
||||||
|
|
||||||
func WishlistDelete(app *lishwist.Session, h http.Header, r *http.Request) rsvp.Response {
|
func WishlistDelete(app *lishwist.Session, h http.Header, r *http.Request) rsvp.Response {
|
||||||
|
|
@ -37,7 +37,7 @@ func WishlistDelete(app *lishwist.Session, h http.Header, r *http.Request) rsvp.
|
||||||
log.Printf("%s\n", err)
|
log.Printf("%s\n", err)
|
||||||
return response.Error(http.StatusInternalServerError, "Failed to remove gifts.")
|
return response.Error(http.StatusInternalServerError, "Failed to remove gifts.")
|
||||||
}
|
}
|
||||||
return rsvp.SeeOther("/")
|
return rsvp.SeeOther("/", "Wish deleted")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ForeignWishlistPost(app *lishwist.Session, h http.Header, r *http.Request) rsvp.Response {
|
func ForeignWishlistPost(app *lishwist.Session, h http.Header, r *http.Request) rsvp.Response {
|
||||||
|
|
@ -47,6 +47,7 @@ func ForeignWishlistPost(app *lishwist.Session, h http.Header, r *http.Request)
|
||||||
}
|
}
|
||||||
|
|
||||||
userReference := r.PathValue("userReference")
|
userReference := r.PathValue("userReference")
|
||||||
|
resp := rsvp.SeeOther("/list/"+userReference, "Update successful")
|
||||||
intent := r.Form.Get("intent")
|
intent := r.Form.Get("intent")
|
||||||
switch intent {
|
switch intent {
|
||||||
case "claim":
|
case "claim":
|
||||||
|
|
@ -57,6 +58,7 @@ func ForeignWishlistPost(app *lishwist.Session, h http.Header, r *http.Request)
|
||||||
log.Printf("%s\n", err)
|
log.Printf("%s\n", err)
|
||||||
return response.Error(http.StatusInternalServerError, "Failed to update claim...")
|
return response.Error(http.StatusInternalServerError, "Failed to update claim...")
|
||||||
}
|
}
|
||||||
|
resp.Body = "Successfully claimed wishes"
|
||||||
case "complete":
|
case "complete":
|
||||||
claims := r.Form["claimed"]
|
claims := r.Form["claimed"]
|
||||||
err := app.CompleteWishes(claims)
|
err := app.CompleteWishes(claims)
|
||||||
|
|
@ -64,6 +66,7 @@ func ForeignWishlistPost(app *lishwist.Session, h http.Header, r *http.Request)
|
||||||
log.Printf("%s\n", err)
|
log.Printf("%s\n", err)
|
||||||
return response.Error(http.StatusInternalServerError, "Failed to complete gifts...")
|
return response.Error(http.StatusInternalServerError, "Failed to complete gifts...")
|
||||||
}
|
}
|
||||||
|
resp.Body = "Successfully completed wishes"
|
||||||
case "add":
|
case "add":
|
||||||
wishName := r.Form.Get("gift_name")
|
wishName := r.Form.Get("gift_name")
|
||||||
if wishName == "" {
|
if wishName == "" {
|
||||||
|
|
@ -74,6 +77,7 @@ func ForeignWishlistPost(app *lishwist.Session, h http.Header, r *http.Request)
|
||||||
log.Printf("%s\n", err)
|
log.Printf("%s\n", err)
|
||||||
return response.Error(http.StatusInternalServerError, "Failed to add gift idea to other user...")
|
return response.Error(http.StatusInternalServerError, "Failed to add gift idea to other user...")
|
||||||
}
|
}
|
||||||
|
resp.Body = "Successfully added wishes"
|
||||||
case "delete":
|
case "delete":
|
||||||
claims := r.Form["unclaimed"]
|
claims := r.Form["unclaimed"]
|
||||||
unclaims := r.Form["claimed"]
|
unclaims := r.Form["claimed"]
|
||||||
|
|
@ -83,8 +87,9 @@ func ForeignWishlistPost(app *lishwist.Session, h http.Header, r *http.Request)
|
||||||
log.Printf("%s\n", err)
|
log.Printf("%s\n", err)
|
||||||
return response.Error(http.StatusInternalServerError, "Failed to remove gift idea for other user...")
|
return response.Error(http.StatusInternalServerError, "Failed to remove gift idea for other user...")
|
||||||
}
|
}
|
||||||
|
resp.Body = "Successfully removed wishes"
|
||||||
default:
|
default:
|
||||||
return response.Error(http.StatusBadRequest, "Invalid intent %q", intent)
|
return response.Error(http.StatusBadRequest, "Invalid intent %q", intent)
|
||||||
}
|
}
|
||||||
return rsvp.SeeOther("/list/" + userReference)
|
return resp
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
{{define "head"}}
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>Lishwist</title>
|
<title>Lishwist</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
|
|
@ -42,6 +39,11 @@
|
||||||
submitter.disabled = !accepted;
|
submitter.disabled = !accepted;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "boilerplate"}}
|
||||||
|
<head>
|
||||||
|
{{template "head" .}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
@ -61,5 +63,8 @@
|
||||||
{{template "body" .}}
|
{{template "body" .}}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
</html>
|
{{define "login_prompt"}}
|
||||||
|
<a href="/">Login</a> or <a href="/register">register</a>
|
||||||
|
{{end}}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,34 @@
|
||||||
{{define "navbar"}}
|
<!doctype html>
|
||||||
<nav>
|
<html>
|
||||||
|
<head>
|
||||||
|
{{template "head" .}}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="height: 100svh;" class="d-flex flex-column">
|
||||||
|
<div class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-brand">Lishwist</div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle"
|
||||||
|
aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||||
|
<nav>
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/">Home</a>
|
<a class="nav-link" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{{end}}
|
</div>
|
||||||
|
</div>
|
||||||
{{define "body"}}
|
</div>
|
||||||
<div class="container d-flex flex-grow-1 justify-content-center align-items-center flex-column">
|
<div class="container d-flex flex-grow-1 justify-content-center align-items-center flex-column">
|
||||||
<div class="alert alert-danger" role="alert">
|
<div class="alert alert-danger" role="alert">
|
||||||
<p class="mb-0">{{.Message}}</p>
|
<p class="mb-0">{{.Message}}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,28 @@
|
||||||
{{define "navbar"}}
|
<!doctype html>
|
||||||
<nav>
|
<html>
|
||||||
|
<head>
|
||||||
|
{{template "head" .}}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="height: 100svh;" class="d-flex flex-column">
|
||||||
|
<div class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-brand">Lishwist</div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle"
|
||||||
|
aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||||
|
<nav>
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/">Home</a>
|
<a class="nav-link" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="flex-grow-1"></div>
|
<div class="flex-grow-1"></div>
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
|
@ -22,11 +37,11 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{end}}
|
</div>
|
||||||
|
</div>
|
||||||
{{define "body"}}
|
</div>
|
||||||
<div class="overflow-y-scroll flex-grow-1">
|
<div class="overflow-y-scroll flex-grow-1">
|
||||||
<div class="container py-5">
|
<div class="container py-5">
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
@ -94,5 +109,7 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,28 @@
|
||||||
{{define "navbar"}}
|
<!doctype html>
|
||||||
<nav>
|
<html>
|
||||||
|
<head>
|
||||||
|
{{template "head" .}}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="height: 100svh;" class="d-flex flex-column">
|
||||||
|
<div class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-brand">Lishwist</div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle"
|
||||||
|
aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||||
|
<nav>
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/">Home</a>
|
<a class="nav-link" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="flex-grow-1"></div>
|
<div class="flex-grow-1"></div>
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
<button class="nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
|
||||||
|
|
@ -22,11 +37,11 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{end}}
|
</div>
|
||||||
|
</div>
|
||||||
{{define "body"}}
|
</div>
|
||||||
<div class="overflow-y-scroll flex-grow-1">
|
<div class="overflow-y-scroll flex-grow-1">
|
||||||
<div class="container py-5">
|
<div class="container py-5">
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
@ -45,6 +60,7 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,21 @@
|
||||||
{{define "navbar"}}
|
<!doctype html>
|
||||||
<div class="flex-grow-1"></div>
|
<html>
|
||||||
<ul class="navbar-nav">
|
<head>
|
||||||
|
{{template "head" .}}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="height: 100svh;" class="d-flex flex-column">
|
||||||
|
<div class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-brand">Lishwist</div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle"
|
||||||
|
aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||||
|
<div class="flex-grow-1"></div>
|
||||||
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item"><button class="btn btn-success"
|
<li class="nav-item"><button class="btn btn-success"
|
||||||
onclick="navigator.clipboard.writeText('{{.HostUrl}}/list/{{.Reference}}'); alert('The share link to your wishlist has been copied to your clipboard. Anyone with the link will be able to claim gifts for you. Share it with someone!');">Copy
|
onclick="navigator.clipboard.writeText('{{.HostUrl}}/list/{{.Reference}}'); alert('The share link to your wishlist has been copied to your clipboard. Anyone with the link will be able to claim gifts for you. Share it with someone!');">Copy
|
||||||
share link</button></li>
|
share link</button></li>
|
||||||
|
|
@ -18,11 +33,11 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{{end}}
|
</div>
|
||||||
|
</div>
|
||||||
{{define "body"}}
|
</div>
|
||||||
<div class="overflow-y-scroll flex-grow-1">
|
<div class="overflow-y-scroll flex-grow-1">
|
||||||
<div class="container py-5">
|
<div class="container py-5">
|
||||||
<section class="card mb-4">
|
<section class="card mb-4">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
@ -109,5 +124,7 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,23 @@
|
||||||
{{define "navbar"}}
|
<!doctype html>
|
||||||
{{end}}
|
<html>
|
||||||
|
<head>
|
||||||
|
{{template "head" .}}
|
||||||
|
</head>
|
||||||
|
|
||||||
{{define "body"}}
|
<body>
|
||||||
<div class="container d-flex flex-grow-1 justify-content-center align-items-center flex-column">
|
<div style="height: 100svh;" class="d-flex flex-column">
|
||||||
|
<div class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-brand">Lishwist</div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle"
|
||||||
|
aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container d-flex flex-grow-1 justify-content-center align-items-center flex-column">
|
||||||
{{if .SuccessfulRegistration}}
|
{{if .SuccessfulRegistration}}
|
||||||
<div class="alert alert-success" role="alert">
|
<div class="alert alert-success" role="alert">
|
||||||
<p class="mb-0">Registration successful. Now you can login.</p>
|
<p class="mb-0">Registration successful. Now you can login.</p>
|
||||||
|
|
@ -29,5 +44,7 @@
|
||||||
<input class="btn btn-primary" type="submit" value="Login">
|
<input class="btn btn-primary" type="submit" value="Login">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,30 @@
|
||||||
{{define "navbar"}}
|
<!doctype html>
|
||||||
<nav>
|
<html>
|
||||||
|
<head>
|
||||||
|
{{template "head" .}}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="height: 100svh;" class="d-flex flex-column">
|
||||||
|
<div class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-brand">Lishwist</div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle"
|
||||||
|
aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||||
|
<nav>
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/">Home</a>
|
<a class="nav-link" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{{end}}
|
</div>
|
||||||
|
</div>
|
||||||
{{define "login_prompt"}}
|
</div>
|
||||||
<a href="/">Login</a> or <a href="/register">register</a>
|
<div class="overflow-y-scroll flex-grow-1">
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{define "body"}}
|
|
||||||
<div class="overflow-y-scroll flex-grow-1">
|
|
||||||
<div class="container py-5">
|
<div class="container py-5">
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
@ -33,5 +44,7 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,30 @@
|
||||||
{{define "navbar"}}
|
<!doctype html>
|
||||||
<nav>
|
<html>
|
||||||
|
<head>
|
||||||
|
{{template "head" .}}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="height: 100svh;" class="d-flex flex-column">
|
||||||
|
<div class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-brand">Lishwist</div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle"
|
||||||
|
aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||||
|
<nav>
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/">Home</a>
|
<a class="nav-link" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{{end}}
|
</div>
|
||||||
|
</div>
|
||||||
{{define "login_prompt"}}
|
</div>
|
||||||
<a href="/">Login</a> or <a href="/register">register</a>
|
<div class="overflow-y-scroll flex-grow-1">
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{define "body"}}
|
|
||||||
<div class="overflow-y-scroll flex-grow-1">
|
|
||||||
<div class="container py-5">
|
<div class="container py-5">
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
@ -33,5 +44,7 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,30 @@
|
||||||
{{define "navbar"}}
|
<!doctype html>
|
||||||
<nav>
|
<html>
|
||||||
|
<head>
|
||||||
|
{{template "head" .}}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div style="height: 100svh;" class="d-flex flex-column">
|
||||||
|
<div class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-brand">Lishwist</div>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarToggle"
|
||||||
|
aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||||
|
<nav>
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/">Home</a>
|
<a class="nav-link" href="/">Home</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
{{end}}
|
</div>
|
||||||
|
</div>
|
||||||
{{define "body"}}
|
</div>
|
||||||
<div class="container d-flex flex-grow-1 justify-content-center align-items-center flex-column">
|
<div class="container d-flex flex-grow-1 justify-content-center align-items-center flex-column">
|
||||||
<div class="alert alert-warning" role="alert">
|
<div class="alert alert-warning" role="alert">
|
||||||
<p>Your password will be stored in a safe, responsible manner; but don't trust my programming skills!</p>
|
<p>Your password will be stored in a safe, responsible manner; but don't trust my programming skills!</p>
|
||||||
<p class="mb-0">Maybe use a password here that you don't use for important things...</p>
|
<p class="mb-0">Maybe use a password here that you don't use for important things...</p>
|
||||||
|
|
@ -36,5 +51,7 @@
|
||||||
<input class="btn btn-primary" type="submit" value="Register">
|
<input class="btn btn-primary" type="submit" value="Register">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -29,29 +29,13 @@ func (p *InputProps) Validate() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
var Templates map[string]*template.Template
|
var Template *template.Template
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Templates = load()
|
Template = load()
|
||||||
}
|
}
|
||||||
|
|
||||||
func load() map[string]*template.Template {
|
func load() *template.Template {
|
||||||
homeTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/home.gotmpl"))
|
t := template.Must(template.ParseGlob("templates/*.gotmpl"))
|
||||||
loginTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/login.gotmpl"))
|
return t
|
||||||
registerTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/register.gotmpl"))
|
|
||||||
foreignTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/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"))
|
|
||||||
groupTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/group_page.gotmpl"))
|
|
||||||
publicGroupTmpl := template.Must(template.ParseFiles("templates/base.gotmpl", "templates/public_group_page.gotmpl"))
|
|
||||||
return map[string]*template.Template{
|
|
||||||
"home.gotmpl": homeTmpl,
|
|
||||||
"login.gotmpl": loginTmpl,
|
|
||||||
"register.gotmpl": registerTmpl,
|
|
||||||
"foreign_wishlist.gotmpl": foreignTmpl,
|
|
||||||
"public_foreign_wishlist.gotmpl": publicWishlistTmpl,
|
|
||||||
"error_page.gotmpl": errorTmpl,
|
|
||||||
"group_page.gotmpl": groupTmpl,
|
|
||||||
"public_group_page.gotmpl": publicGroupTmpl,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue