diff --git a/features/auth/handlers.go b/features/auth/handlers.go index 4488bae..7e11665 100644 --- a/features/auth/handlers.go +++ b/features/auth/handlers.go @@ -84,7 +84,7 @@ func (h *Handlers) HandleSearch(w http.ResponseWriter, r *http.Request) { // Signin renders the chooser page: sign in vs create new Atmosphere account. func (h *Handlers) Signin(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/html; charset=utf-8") - if err := pages.Signin().Render(r.Context(), w); err != nil { + if err := pages.Signin(r.URL.Query().Get("next")).Render(r.Context(), w); err != nil { slog.Error("render signin", "err", err) } } @@ -305,9 +305,14 @@ func sanitizeASCode(code string) string { // On subsequent visits (after sign-out), auto-recovers the previous local account // via the known-accounts cookie. func (h *Handlers) ContinueWithoutAccount(w http.ResponseWriter, r *http.Request) { + nextDest := r.URL.Query().Get("next") + if nextDest == "" { + nextDest = "/profile" + } + // Check if already authenticated (ATProto or local) if _, _, err := h.ResumeSession(r); err == nil { - http.Redirect(w, r, "/profile", http.StatusFound) + http.Redirect(w, r, nextDest, http.StatusFound) return } @@ -319,7 +324,7 @@ func (h *Handlers) ContinueWithoutAccount(w http.ResponseWriter, r *http.Request SELECT did FROM users WHERE did = ? `, existingLocalID).Scan(&exists) if err == nil { - http.Redirect(w, r, "/profile", http.StatusFound) + http.Redirect(w, r, nextDest, http.StatusFound) return } } @@ -342,7 +347,7 @@ func (h *Handlers) ContinueWithoutAccount(w http.ResponseWriter, r *http.Request http.Error(w, "failed to set cookie", http.StatusInternalServerError) return } - http.Redirect(w, r, "/profile", http.StatusFound) + http.Redirect(w, r, nextDest, http.StatusFound) return } } @@ -374,7 +379,7 @@ func (h *Handlers) ContinueWithoutAccount(w http.ResponseWriter, r *http.Request } h.Sessions.RememberLocal(w, localID) - http.Redirect(w, r, "/profile", http.StatusFound) + http.Redirect(w, r, nextDest, http.StatusFound) } // LocalLogout clears the local session cookie and redirects home. diff --git a/features/auth/pages/signin.templ b/features/auth/pages/signin.templ index 38f0cad..5c5be5c 100644 --- a/features/auth/pages/signin.templ +++ b/features/auth/pages/signin.templ @@ -1,10 +1,14 @@ package pages -import "atmoquest/features/common/layouts" +import ( + "net/url" + + "atmoquest/features/common/layouts" +) // Signin renders the chooser: existing Atmosphere account vs create a new one. -// The create path is a stub for now — we'll wire it later. -templ Signin() { +// next is an optional path to redirect to after sign-in. +templ Signin(next string) { @layouts.Base("sign in", "Sign in with your ATProto account.") {
did:plc:… ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " also accepts did:plc:… or a PDS URL like https://pds.example.com ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/features/auth/pages/signin_templ.go b/features/auth/pages/signin_templ.go
index bcf2501..10c41d8 100644
--- a/features/auth/pages/signin_templ.go
+++ b/features/auth/pages/signin_templ.go
@@ -8,11 +8,15 @@ package pages
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
-import "atmoquest/features/common/layouts"
+import (
+ "net/url"
+
+ "atmoquest/features/common/layouts"
+)
// Signin renders the chooser: existing Atmosphere account vs create a new one.
-// The create path is a stub for now — we'll wire it later.
-func Signin() templ.Component {
+// next is an optional path to redirect to after sign-in.
+func Signin(next string) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
@@ -52,13 +56,26 @@ func Signin() templ.Component {
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs("@")
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/auth/pages/signin.templ`, Line: 18, Col: 56}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/auth/pages/signin.templ`, Line: 22, Col: 56}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "atmo.quest:~$ auth --pickatmo.quest is built on ATProto. Your records live in your repo, not ours. You'll sign in with the same identity you use anywhere on the open social web.
you.bsky.social or any ATProto PDS? Go this way.atmo.quest is built on ATProto. Your records live in your repo, not ours. You'll sign in with the same identity you use anywhere on the open social web.
you.bsky.social or any ATProto PDS? Go this way.{ v.TargetDID }
{ v.TargetBio }
+@nl2br(v.TargetBio)
} if v.SelfConnect { @@ -149,3 +154,8 @@ func avatarAlt(displayName string) string { } return displayName + "'s profile picture" } + +func nl2br(s string) templ.Component { + s = strings.ReplaceAll(s, "\r\n", "\n") + return templ.Raw(strings.ReplaceAll(html.EscapeString(s), "\n", "{ v.TargetLocalID }
{ v.TargetBio }
+@nl2br(v.TargetBio)
} if v.SelfConnect { diff --git a/features/connect/pages/connect_local_templ.go b/features/connect/pages/connect_local_templ.go index 8c653aa..fcb9c3a 100644 --- a/features/connect/pages/connect_local_templ.go +++ b/features/connect/pages/connect_local_templ.go @@ -178,12 +178,7 @@ func ConnectLocal(v ConnectLocalView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var9 string - templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(v.TargetBio) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect_local.templ`, Line: 46, Col: 42} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) + templ_7745c5c3_Err = nl2br(v.TargetBio).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -202,12 +197,12 @@ func ConnectLocal(v ConnectLocalView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var10 templ.SafeURL - templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinURLErrs(templ.SafeURL("/c/l/" + v.TargetLocalID + "/confirm")) + var templ_7745c5c3_Var9 templ.SafeURL + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinURLErrs(templ.SafeURL("/c/l/" + v.TargetLocalID + "/confirm")) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect_local.templ`, Line: 58, Col: 88} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -230,12 +225,12 @@ func ConnectLocal(v ConnectLocalView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var11 string - templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.ResolveAttributeValue(v.TargetLocalID) + var templ_7745c5c3_Var10 string + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.ResolveAttributeValue(v.TargetLocalID) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect_local.templ`, Line: 85, Col: 45} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var10) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/features/connect/pages/connect_templ.go b/features/connect/pages/connect_templ.go index c344501..e850645 100644 --- a/features/connect/pages/connect_templ.go +++ b/features/connect/pages/connect_templ.go @@ -8,7 +8,12 @@ package pages import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import "atmoquest/features/common/layouts" +import ( + "html" + "strings" + + "atmoquest/features/common/layouts" +) // ConnectView is the data the Connect handler renders. type ConnectView struct { @@ -85,7 +90,7 @@ func Connect(v ConnectView) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs("@") if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 44, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 49, Col: 56} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -98,7 +103,7 @@ func Connect(v ConnectView) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(shortDID(v.TargetDID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 45, Col: 61} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 50, Col: 61} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -116,7 +121,7 @@ func Connect(v ConnectView) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.ResolveAttributeValue(v.TargetAvatarURL) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 51, Col: 58} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 56, Col: 58} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5) if templ_7745c5c3_Err != nil { @@ -129,7 +134,7 @@ func Connect(v ConnectView) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.ResolveAttributeValue(avatarAlt(v.TargetDisplayName)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 51, Col: 97} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 56, Col: 97} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6) if templ_7745c5c3_Err != nil { @@ -157,7 +162,7 @@ func Connect(v ConnectView) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(v.TargetDisplayName) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 57, Col: 52} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 62, Col: 52} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -180,7 +185,7 @@ func Connect(v ConnectView) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(v.TargetDID) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 61, Col: 67} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 66, Col: 67} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -195,12 +200,7 @@ func Connect(v ConnectView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var9 string - templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(v.TargetBio) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 63, Col: 42} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) + templ_7745c5c3_Err = nl2br(v.TargetBio).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -219,12 +219,12 @@ func Connect(v ConnectView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var10 templ.SafeURL - templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinURLErrs(templ.SafeURL("/c/" + v.TargetDID + "/confirm")) + var templ_7745c5c3_Var9 templ.SafeURL + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinURLErrs(templ.SafeURL("/c/" + v.TargetDID + "/confirm")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 75, Col: 82} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 80, Col: 82} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -237,12 +237,12 @@ func Connect(v ConnectView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var11 string - templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(v.TargetCurrentEvent.Name) + var templ_7745c5c3_Var10 string + templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(v.TargetCurrentEvent.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 86, Col: 65} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 91, Col: 65} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -255,12 +255,12 @@ func Connect(v ConnectView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var12 string - templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(v.TargetCurrentEvent.Location) + var templ_7745c5c3_Var11 string + templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(v.TargetCurrentEvent.Location) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 88, Col: 66} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 93, Col: 66} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -273,12 +273,12 @@ func Connect(v ConnectView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var13 string - templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.ResolveAttributeValue(v.TargetCurrentEvent.EventURI) + var templ_7745c5c3_Var12 string + templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.ResolveAttributeValue(v.TargetCurrentEvent.EventURI) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 96, Col: 83} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 101, Col: 83} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -306,12 +306,12 @@ func Connect(v ConnectView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var14 string - templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.ResolveAttributeValue(v.TargetDID) + var templ_7745c5c3_Var13 string + templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.ResolveAttributeValue(v.TargetDID) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 129, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `features/connect/pages/connect.templ`, Line: 134, Col: 36} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -355,4 +355,9 @@ func avatarAlt(displayName string) string { return displayName + "'s profile picture" } +func nl2br(s string) templ.Component { + s = strings.ReplaceAll(s, "\r\n", "\n") + return templ.Raw(strings.ReplaceAll(html.EscapeString(s), "\n", "{ v.Bio }
+@nl2br(v.Bio)
}