From 47402afbd9d6d841703f52913cbd41230ca1175e Mon Sep 17 00:00:00 2001 From: Graham Barber Date: Sun, 18 Aug 2024 18:59:08 -0700 Subject: [PATCH] add auth page styles --- html/pages/auth.templ | 63 +++++++++++++++++++----------- html/pages/auth_templ.go | 82 +++++++++++++++++++++++----------------- 2 files changed, 89 insertions(+), 56 deletions(-) diff --git a/html/pages/auth.templ b/html/pages/auth.templ index 14ed850..439406e 100644 --- a/html/pages/auth.templ +++ b/html/pages/auth.templ @@ -6,32 +6,44 @@ import ( ) templ Auth( req *indieauth.AuthenticationRequest, app *indieauth.ApplicationMetadata, nonceId string, nonce string ) { -

IndieAuth Server Demo: Authorization

- -

- You received an authorization request from +

+

authorize access to

+

puregarlic dot space

+
if app != nil { - if len(app.Logo) > 0 { - - } +
+ if len(app.Logo) > 0 { + + } + +
+

{ app.Name }

- { app.Name } by { app.Author }: + if len(app.Author) > 0 { +

by {app.Author}

+ } +
+
} else { - the following client: +

unidentified client

} -

-
    -
  • Redirect: { req.ClientID }
  • -
  • Client: { req.RedirectURI }
  • -
+
+

Client ID

+

{ req.ClientID }

-

For the following scopes: - for _, scope := range req.Scopes { - { scope } - } - .

+

Redirect URL

+

{ req.RedirectURI}

+ +

Scopes

+
    + for _, scope := range req.Scopes { +
  • { scope }
  • + } +
+
+
@@ -46,8 +58,15 @@ templ Auth( req *indieauth.AuthenticationRequest, app *indieauth.ApplicationMeta -

In a production server, this page could be behind some sort of authentication mechanism, such as username and password, PassKey, etc.

- - +
+
} diff --git a/html/pages/auth_templ.go b/html/pages/auth_templ.go index 88b2649..3acff6b 100644 --- a/html/pages/auth_templ.go +++ b/html/pages/auth_templ.go @@ -31,20 +31,24 @@ func Auth(req *indieauth.AuthenticationRequest, app *indieauth.ApplicationMetada templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

IndieAuth Server Demo: Authorization

You received an authorization request from ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

authorize access to

puregarlic dot space

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if app != nil { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } if len(app.Logo) > 0 { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(app.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 19, Col: 24} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 21, Col: 49} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" by ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(app.Author) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 19, Col: 51} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err + if len(app.Author) > 0 { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

by ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(app.Author) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 24, Col: 56} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(":") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("the following client:") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

unidentified client

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

  • Redirect: ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Client ID

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(req.ClientID) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 26, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 34, Col: 103} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

  • Client: ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

    Redirect URL

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(req.RedirectURI) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 27, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 37, Col: 95} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

For the following scopes: ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Scopes

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, scope := range req.Scopes { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
  • ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(scope) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 32, Col: 19} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 42, Col: 63} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
  • ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(".

In a production server, this page could be behind some sort of authentication mechanism, such as username and password, PassKey, etc.

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } -- 2.51.2