From c983de83b074b714a29de09dee195dc8e9f63107 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Tue, 27 Jan 2026 10:16:08 +0000 Subject: [PATCH] appview/pages: templatize login, signup, complete-signup pages these pages were full html pages instead of blocks. as a result, their meta values were not in sync with the rest of the site. by introducing layouts/loginbase, we can now share the boilerplate. of note is that the signup page needs an extra line in the ``: the script to load a cloudflare turnstile. this is supplied using `extrameta` Signed-off-by: oppiliappan --- appview/pages/pages.go | 24 +- .../pages/templates/layouts/loginbase.html | 26 ++ .../pages/templates/user/completeSignup.html | 161 +++++------- appview/pages/templates/user/login.html | 243 ++++++++---------- appview/pages/templates/user/signup.html | 103 ++++---- 5 files changed, 263 insertions(+), 294 deletions(-) create mode 100644 appview/pages/templates/layouts/loginbase.html diff --git a/appview/pages/pages.go b/appview/pages/pages.go index d8c9f475..ce43444d 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -178,6 +178,15 @@ func (p *Pages) parseProfileBase(top string) (*template.Template, error) { return p.parse(stack...) } +func (p *Pages) parseLoginBase(top string) (*template.Template, error) { + stack := []string{ + "layouts/base", + "layouts/loginbase", + top, + } + return p.parse(stack...) +} + func (p *Pages) executePlain(name string, w io.Writer, params any) error { tpl, err := p.parse(name) if err != nil { @@ -187,6 +196,15 @@ func (p *Pages) executePlain(name string, w io.Writer, params any) error { return tpl.Execute(w, params) } +func (p *Pages) executeLogin(name string, w io.Writer, params any) error { + tpl, err := p.parseLoginBase(name) + if err != nil { + return err + } + + return tpl.ExecuteTemplate(w, "layouts/base", params) +} + func (p *Pages) execute(name string, w io.Writer, params any) error { tpl, err := p.parseBase(name) if err != nil { @@ -237,7 +255,7 @@ type LoginParams struct { } func (p *Pages) Login(w io.Writer, params LoginParams) error { - return p.executePlain("user/login", w, params) + return p.executeLogin("user/login", w, params) } type SignupParams struct { @@ -245,11 +263,11 @@ type SignupParams struct { } func (p *Pages) Signup(w io.Writer, params SignupParams) error { - return p.executePlain("user/signup", w, params) + return p.executeLogin("user/signup", w, params) } func (p *Pages) CompleteSignup(w io.Writer) error { - return p.executePlain("user/completeSignup", w, nil) + return p.executeLogin("user/completeSignup", w, nil) } type TermsOfServiceParams struct { diff --git a/appview/pages/templates/layouts/loginbase.html b/appview/pages/templates/layouts/loginbase.html new file mode 100644 index 00000000..fd5bb86a --- /dev/null +++ b/appview/pages/templates/layouts/loginbase.html @@ -0,0 +1,26 @@ +{{ define "mainLayout" }} +
+
+ {{ template "logo" }} + {{ block "content" . }}{{ end }} +
+
+{{ end }} + +{{ define "topbarLayout" }} + +{{ end }} + +{{ define "footerLayout" }} + +{{ end }} + +{{ define "logo" }} +

+ {{ template "fragments/logotype" }} +

+

+ tightly-knit social coding. +

+{{ end }} + diff --git a/appview/pages/templates/user/completeSignup.html b/appview/pages/templates/user/completeSignup.html index 1f0e9744..03cb6177 100644 --- a/appview/pages/templates/user/completeSignup.html +++ b/appview/pages/templates/user/completeSignup.html @@ -1,103 +1,66 @@ -{{ define "user/completeSignup" }} - - - - - - - - - - - - complete signup · tangled - - -
-

- {{ template "fragments/logotype" }} -

-

- tightly-knit social coding. -

-
-
- - - - Enter the code sent to your email. - -
+{{ define "title" }} complete signup {{ end }} -
- - - - Your complete handle will be of the form user.tngl.sh. - -
+{{ define "content" }} + +
+ + + + Enter the code sent to your email. + +
-
- - - - Choose a strong password for your account. - -
+
+ + + + Your complete handle will be of the form user.tngl.sh. + +
- -
-

-

-
- - +
+ + + + Choose a strong password for your account. + +
+ + + +

+

{{ end }} diff --git a/appview/pages/templates/user/login.html b/appview/pages/templates/user/login.html index 53f58975..4b045c7f 100644 --- a/appview/pages/templates/user/login.html +++ b/appview/pages/templates/user/login.html @@ -1,138 +1,117 @@ -{{ define "user/login" }} - - - - - - - - - - - - login · tangled - - -
-

- {{ template "fragments/logotype" }} -

-

- tightly-knit social coding. -

+{{ define "title" }} login {{ end }} - {{ if .AddAccount }} -
- {{ i "user-plus" "w-4 h-4" }} -
-
Add another account
-

Sign in with a different account to add it to your account list.

-
-
- {{ end }} +{{ define "content" }} + {{ if .AddAccount }} +
+ {{ i "user-plus" "w-4 h-4" }} +
+
Add another account
+

Sign in with a different account to add it to your account list.

+
+
+ {{ end }} - {{ if and .LoggedInUser .LoggedInUser.Accounts }} - {{ $accounts := .LoggedInUser.Accounts }} - {{ if $accounts }} -
-
- Saved accounts -
-
- {{ range $accounts }} -
- - -
- {{ end }} -
-
- {{ end }} - {{ end }} + {{ if and .LoggedInUser .LoggedInUser.Accounts }} + {{ $accounts := .LoggedInUser.Accounts }} + {{ if $accounts }} +
+
+ Saved accounts +
+
+ {{ range $accounts }} +
+ + +
+ {{ end }} +
+
+ {{ end }} + {{ end }} -
-
- - - - Use your AT Protocol - handle to log in. If you're unsure, this is likely - your Tangled (.tngl.sh) or Bluesky (.bsky.social) account. - -
- - + +
+ + + + Use your AT Protocol + handle to log in. If you're unsure, this is likely + your Tangled (.tngl.sh) or Bluesky (.bsky.social) account. + +
+ + - -
- {{ if .ErrorCode }} -
- {{ i "circle-alert" "w-4 h-4" }} -
-
Login error
-

- {{ if eq .ErrorCode "access_denied" }} - You have not authorized the app. - {{ else if eq .ErrorCode "session" }} - Server failed to create user session. - {{ else if eq .ErrorCode "max_accounts" }} - You have reached the maximum of 20 linked accounts. Please remove an account before adding a new one. - {{ else }} - Internal Server error. - {{ end }} - Please try again. -

-
-
- {{ end }} -

- Don't have an account? Create an account on Tangled now! -

+ + + {{ if .ErrorCode }} +
+ {{ i "circle-alert" "w-4 h-4" }} +
+
Login error
+

+ {{ if eq .ErrorCode "access_denied" }} + You have not authorized the app. + {{ else if eq .ErrorCode "session" }} + Server failed to create user session. + {{ else if eq .ErrorCode "max_accounts" }} + You have reached the maximum of 20 linked accounts. Please remove an account before adding a new one. + {{ else }} + Internal Server error. + {{ end }} + Please try again. +

+
+
+ {{ end }} +

+ Don't have an account? Create an account on Tangled now! +

-

-
- - +

{{ end }} + diff --git a/appview/pages/templates/user/signup.html b/appview/pages/templates/user/signup.html index 520fca86..4bf4370f 100644 --- a/appview/pages/templates/user/signup.html +++ b/appview/pages/templates/user/signup.html @@ -1,63 +1,46 @@ -{{ define "user/signup" }} - - - - - - - - - - - - sign up · tangled +{{ define "title" }} signup {{ end }} - - - -
-

- {{ template "fragments/logotype" }} -

-

tightly-knit social coding.

-
-
- - -
- - You will receive an email with an invite code. Enter your - invite code, desired username, and password in the next - page to complete your registration. - -
-
-
- -

- Already have an AT Protocol account? Login to Tangled. -

+{{ define "extrameta" }} + +{{ end }} + +{{ define "content" }} + +
+ + +
+ + You will receive an email with an invite code. Enter your + invite code, desired username, and password in the next + page to complete your registration. + +
+
+
+ +

+ Already have an AT Protocol account? Login to Tangled. +

-

-

- By signing up, you agree to our Terms of Service and Privacy Policy. -

-
-
- - +

+

+ By signing up, you agree to our Terms of Service and Privacy Policy. +

+ {{ end }} -- 2.51.2