mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
Login page using templ
This commit is contained in:
parent
0924417a81
commit
37c5c9428e
5 changed files with 14 additions and 29 deletions
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/markbates/goth/gothic"
|
"github.com/markbates/goth/gothic"
|
||||||
|
|
||||||
"github.com/rjNemo/rentease/internal/auth"
|
"github.com/rjNemo/rentease/internal/auth"
|
||||||
|
"github.com/rjNemo/rentease/internal/view"
|
||||||
)
|
)
|
||||||
|
|
||||||
var indexTemplate = `{{range $key,$value:=.Providers}}
|
var indexTemplate = `{{range $key,$value:=.Providers}}
|
||||||
|
|
@ -71,8 +72,6 @@ func handleProvider() echo.HandlerFunc {
|
||||||
|
|
||||||
func handleLoginPage(as *auth.Service) echo.HandlerFunc {
|
func handleLoginPage(as *auth.Service) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
t, _ := template.New("foo").Parse(indexTemplate)
|
return renderTempl(c, http.StatusOK, view.Login(as.GetProviderIndex()))
|
||||||
return t.Execute(c.Response(), as.GetProviderIndex())
|
|
||||||
//return renderTempl(c, http.StatusOK, view.Login(as.GetProviderIndex()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ templ PublicLayout() {
|
||||||
<link rel="stylesheet" href="/static/css/pico.min.css"/>
|
<link rel="stylesheet" href="/static/css/pico.min.css"/>
|
||||||
<script src="/static/js/htmx.js" defer></script>
|
<script src="/static/js/htmx.js" defer></script>
|
||||||
</head>
|
</head>
|
||||||
<body hx-boost="true">
|
<body hx-boost="false">
|
||||||
<nav class="container-fluid">
|
<nav class="container-fluid">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ func PublicLayout() templ.Component {
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" | Locations de vacances au Gosier en Guadeloupe</title><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><meta name=\"description\" content=\"Locations de vacances au Gosier en Guadeloupe\"><link rel=\"icon\" href=\"/static/icons/favicon.png\"><link rel=\"stylesheet\" href=\"/static/css/pico.min.css\"><script src=\"/static/js/htmx.js\" defer></script></head><body hx-boost=\"true\"><nav class=\"container-fluid\"><ul><li><a href=\"/\"><img src=\"/static/img/logo.png\" alt=\"logo de villafleurie\" width=\"50px\"></a></li></ul><ul><li><details class=\"dropdown\"><summary>Logements</summary><ul dir=\"rtl\">")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" | Locations de vacances au Gosier en Guadeloupe</title><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><meta name=\"description\" content=\"Locations de vacances au Gosier en Guadeloupe\"><link rel=\"icon\" href=\"/static/icons/favicon.png\"><link rel=\"stylesheet\" href=\"/static/css/pico.min.css\"><script src=\"/static/js/htmx.js\" defer></script></head><body hx-boost=\"false\"><nav class=\"container-fluid\"><ul><li><a href=\"/\"><img src=\"/static/img/logo.png\" alt=\"logo de villafleurie\" width=\"50px\"></a></li></ul><ul><li><details class=\"dropdown\"><summary>Logements</summary><ul dir=\"rtl\">")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +1,17 @@
|
||||||
package view
|
package view
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/rjNemo/rentease/internal/auth"
|
||||||
"github.com/rjNemo/rentease/internal/view/layout"
|
"github.com/rjNemo/rentease/internal/view/layout"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ Login() {
|
// inject the providers into the template even if we don't use it
|
||||||
@layout.BaseLayout() {
|
templ Login(providers *auth.ProviderIndex) {
|
||||||
|
@layout.PublicLayout() {
|
||||||
<main class="container">
|
<main class="container">
|
||||||
<section>
|
<section>
|
||||||
<h1>Login</h1>
|
<h1>Login</h1>
|
||||||
<form method="POST">
|
<a href="/auth?provider=google">Log in with Google</a>
|
||||||
<input
|
|
||||||
type="email"
|
|
||||||
name="email"
|
|
||||||
placeholder="john@email.com"
|
|
||||||
aria-label="email"
|
|
||||||
autocomplete="email"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
name="password"
|
|
||||||
placeholder="p4Ssw0rD"
|
|
||||||
aria-label="password"
|
|
||||||
autocomplete="password"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<button type="submit">Log in</button>
|
|
||||||
</form>
|
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,12 @@ import "io"
|
||||||
import "bytes"
|
import "bytes"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/rjNemo/rentease/internal/auth"
|
||||||
"github.com/rjNemo/rentease/internal/view/layout"
|
"github.com/rjNemo/rentease/internal/view/layout"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Login() templ.Component {
|
// inject the providers into the template even if we don't use it
|
||||||
|
func Login(providers *auth.ProviderIndex) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
|
@ -33,7 +35,7 @@ func Login() templ.Component {
|
||||||
templ_7745c5c3_Buffer = templ.GetBuffer()
|
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<main class=\"container\"><section><h1>Login</h1><form method=\"POST\"><input type=\"email\" name=\"email\" placeholder=\"john@email.com\" aria-label=\"email\" autocomplete=\"email\" required> <input type=\"password\" name=\"password\" placeholder=\"p4Ssw0rD\" aria-label=\"password\" autocomplete=\"password\" required> <button type=\"submit\">Log in</button></form></section></main>")
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<main class=\"container\"><section><h1>Login</h1><a href=\"/auth?provider=google\">Log in with Google</a></section></main>")
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +44,7 @@ func Login() templ.Component {
|
||||||
}
|
}
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
})
|
})
|
||||||
templ_7745c5c3_Err = layout.BaseLayout().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = layout.PublicLayout().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue