diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-07-19 19:50:54 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-07-19 19:50:54 +0200 |
commit | 1d9d5f40fe4092657f529bdba18f6f52511eea00 (patch) | |
tree | 718b5af2c43f64bbe16de927ffa7f0cb8ed5fc72 | |
parent | 3e435fc0d032a6cac0bdd15cdb138905ecdb7267 (diff) | |
download | lens-1d9d5f40fe4092657f529bdba18f6f52511eea00.tar.gz lens-1d9d5f40fe4092657f529bdba18f6f52511eea00.tar.bz2 lens-1d9d5f40fe4092657f529bdba18f6f52511eea00.zip |
feat: Move login from `html/template` to qtpl
-rw-r--r-- | pkg/view/auth.go | 4 | ||||
-rw-r--r-- | templates/login.qtpl (renamed from templates/login.html) | 17 |
2 files changed, 16 insertions, 5 deletions
diff --git a/pkg/view/auth.go b/pkg/view/auth.go index 6b096d9..5d73b22 100644 --- a/pkg/view/auth.go +++ b/pkg/view/auth.go @@ -8,6 +8,7 @@ import ( "git.sr.ht/~gabrielgio/img" "git.sr.ht/~gabrielgio/img/pkg/ext" "git.sr.ht/~gabrielgio/img/pkg/service" + "git.sr.ht/~gabrielgio/img/templates" ) type AuthView struct { @@ -21,7 +22,8 @@ func NewAuthView(userController *service.AuthController) *AuthView { } func (v *AuthView) LoginView(ctx *fasthttp.RequestCtx) error { - return img.Render[interface{}](ctx, "login.html", nil) + templates.WritePageTemplate(ctx, &templates.LoginPage{}) + return nil } func (v *AuthView) Logout(ctx *fasthttp.RequestCtx) error { diff --git a/templates/login.html b/templates/login.qtpl index 607faa1..b8aa98c 100644 --- a/templates/login.html +++ b/templates/login.qtpl @@ -1,6 +1,12 @@ -{{template "layout.html" .}} -{{define "title"}} Login {{end}} -{{define "content"}} +{% code +type LoginPage struct {} +%} + +{% func (p *LoginPage) Title() %} +Login +{% endfunc %} + +{% func (p *LoginPage) Content() %} <form action="/login" method="post"> <div class="field"> <label class="label">Username</label> @@ -21,4 +27,7 @@ <input class="button is-pulled-right" value="login" type="submit"> </div> </form> -{{end}} +{% endfunc %} + +{% func (p *LoginPage) Script() %} +{% endfunc %} |