An experimental IndieWeb site built in Go.

add auth page styles

+89 -56
+41 -22
html/pages/auth.templ
··· 6 6 ) 7 7 8 8 templ Auth( req *indieauth.AuthenticationRequest, app *indieauth.ApplicationMetadata, nonceId string, nonce string ) { 9 - <h1>IndieAuth Server Demo: Authorization</h1> 10 - 11 - <p> 12 - You received an authorization request from 9 + <div class="px-4 py-12 md:py-20 mx-auto max-w-screen-sm"> 10 + <p class="text-sm font-thin italic">authorize access to</p> 11 + <h1 class="mb-8 text-3xl font-extrabold">puregarlic dot space</h1> 13 12 13 + <div class="pt-6 border border-highlightMed rounded bg-surface"> 14 14 if app != nil { 15 - if len(app.Logo) > 0 { 16 - <img style="width: 1em; vertical-align: middle" src={ app.Logo } /> 17 - } 15 + <div class="px-6 flex gap-6 items-center"> 16 + if len(app.Logo) > 0 { 17 + <img class="max-w-12" src={ app.Logo } /> 18 + } 18 19 19 - <strong>{ app.Name }</strong> by { app.Author }: 20 + <div> 21 + <h2 class="font-bold text-lg">{ app.Name }</h2> 22 + 23 + if len(app.Author) > 0 { 24 + <p class="text-sm font-light">by {app.Author}</p> 25 + } 26 + </div> 27 + </div> 20 28 } else { 21 - the following client: 29 + <h2 class="px-6 font-bold text-subtle">unidentified client</h2> 22 30 } 23 - </p> 24 31 25 - <ul> 26 - <li><strong>Redirect:</strong> <code>{ req.ClientID }</code></li> 27 - <li><strong>Client:</strong> <code>{ req.RedirectURI }</code></li> 28 - </ul> 32 + <div class="mt-6 grid md:grid-cols-[max-content_1fr] *:border-highlightMed"> 33 + <h3 class="px-6 pt-4 pb-2 md:py-4 border-t bg-overlay md:border-r text-subtle font-bold">Client ID</h3> 34 + <p class="px-6 pb-4 pt-1 md:py-4 md:border-t bg-overlay min-w-0 overflow-x-scroll">{ req.ClientID }</p> 35 + 36 + <h3 class="px-6 pt-4 pb-2 md:py-4 border-t md:border-b md:border-r text-subtle font-bold">Redirect URL</h3> 37 + <p class="px-6 pb-4 pt-1 md:py-4 md:border-y min-w-0 overflow-x-scroll">{ req.RedirectURI}</p> 29 38 30 - <p>For the following scopes: 31 - for _, scope := range req.Scopes { 32 - <code>{ scope }</code> 33 - } 34 - .</p> 39 + <h3 class="px-6 pt-4 pb-2 md:py-4 border-t bg-overlay md:border-r text-subtle font-bold">Scopes</h3> 40 + <ul class="px-6 pb-4 pt-1 md:py-4 bg-overlay flex flex-wrap gap-3"> 41 + for _, scope := range req.Scopes { 42 + <li class="px-2 py-1 text-sm bg-pine rounded">{ scope }</li> 43 + } 44 + </ul> 45 + </div> 46 + </div> 35 47 36 48 <form method='post' action='/authorization/accept'> 37 49 <input type="hidden" name="response_type" value="code"/> ··· 46 58 <input type="hidden" name="nonce_id" value={ nonceId }/> 47 59 <input type="hidden" name="nonce" value={ nonce }/> 48 60 49 - <p>In a production server, this page could be behind some sort of authentication mechanism, such as username and password, PassKey, etc.</p> 50 - 51 - <button id="submit">Authorize</button> 61 + <button 62 + class="mt-8 px-3 py-2 flex items-center justify-center gap-2 bg-surface border border-highlightMed text-sm font-bold transition rounded hover:bg-foam hover:text-surface" 63 + id="submit" 64 + > 65 + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4"> 66 + <path fill-rule="evenodd" d="M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14Zm3.844-8.791a.75.75 0 0 0-1.188-.918l-3.7 4.79-1.649-1.833a.75.75 0 1 0-1.114 1.004l2.25 2.5a.75.75 0 0 0 1.15-.043l4.25-5.5Z" clip-rule="evenodd" /> 67 + </svg> 68 + Authorize 69 + </button> 52 70 </form> 71 + </div> 53 72 }
+48 -34
html/pages/auth_templ.go
··· 31 31 templ_7745c5c3_Var1 = templ.NopComponent 32 32 } 33 33 ctx = templ.ClearChildren(ctx) 34 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h1>IndieAuth Server Demo: Authorization</h1><p>You received an authorization request from ") 34 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"px-4 py-12 md:py-20 mx-auto max-w-screen-sm\"><p class=\"text-sm font-thin italic\">authorize access to</p><h1 class=\"mb-8 text-3xl font-extrabold\">puregarlic dot space</h1><div class=\"pt-6 border border-highlightMed rounded bg-surface\">") 35 35 if templ_7745c5c3_Err != nil { 36 36 return templ_7745c5c3_Err 37 37 } 38 38 if app != nil { 39 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"px-6 flex gap-6 items-center\">") 40 + if templ_7745c5c3_Err != nil { 41 + return templ_7745c5c3_Err 42 + } 39 43 if len(app.Logo) > 0 { 40 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<img style=\"width: 1em; vertical-align: middle\" src=\"") 44 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<img class=\"max-w-12\" src=\"") 41 45 if templ_7745c5c3_Err != nil { 42 46 return templ_7745c5c3_Err 43 47 } 44 48 var templ_7745c5c3_Var2 string 45 49 templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(app.Logo) 46 50 if templ_7745c5c3_Err != nil { 47 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 16, Col: 70} 51 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 17, Col: 46} 48 52 } 49 53 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) 50 54 if templ_7745c5c3_Err != nil { ··· 55 59 return templ_7745c5c3_Err 56 60 } 57 61 } 58 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" <strong>") 62 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div><h2 class=\"font-bold text-lg\">") 59 63 if templ_7745c5c3_Err != nil { 60 64 return templ_7745c5c3_Err 61 65 } 62 66 var templ_7745c5c3_Var3 string 63 67 templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(app.Name) 64 68 if templ_7745c5c3_Err != nil { 65 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 19, Col: 24} 69 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 21, Col: 49} 66 70 } 67 71 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) 68 72 if templ_7745c5c3_Err != nil { 69 73 return templ_7745c5c3_Err 70 74 } 71 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</strong> by ") 75 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h2>") 72 76 if templ_7745c5c3_Err != nil { 73 77 return templ_7745c5c3_Err 74 78 } 75 - var templ_7745c5c3_Var4 string 76 - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(app.Author) 77 - if templ_7745c5c3_Err != nil { 78 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 19, Col: 51} 79 - } 80 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) 81 - if templ_7745c5c3_Err != nil { 82 - return templ_7745c5c3_Err 79 + if len(app.Author) > 0 { 80 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<p class=\"text-sm font-light\">by ") 81 + if templ_7745c5c3_Err != nil { 82 + return templ_7745c5c3_Err 83 + } 84 + var templ_7745c5c3_Var4 string 85 + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(app.Author) 86 + if templ_7745c5c3_Err != nil { 87 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 24, Col: 56} 88 + } 89 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) 90 + if templ_7745c5c3_Err != nil { 91 + return templ_7745c5c3_Err 92 + } 93 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p>") 94 + if templ_7745c5c3_Err != nil { 95 + return templ_7745c5c3_Err 96 + } 83 97 } 84 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(":") 98 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div>") 85 99 if templ_7745c5c3_Err != nil { 86 100 return templ_7745c5c3_Err 87 101 } 88 102 } else { 89 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("the following client:") 103 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2 class=\"px-6 font-bold text-subtle\">unidentified client</h2>") 90 104 if templ_7745c5c3_Err != nil { 91 105 return templ_7745c5c3_Err 92 106 } 93 107 } 94 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><ul><li><strong>Redirect:</strong> <code>") 108 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"mt-6 grid md:grid-cols-[max-content_1fr] *:border-highlightMed\"><h3 class=\"px-6 pt-4 pb-2 md:py-4 border-t bg-overlay md:border-r text-subtle font-bold\">Client ID</h3><p class=\"px-6 pb-4 pt-1 md:py-4 md:border-t bg-overlay min-w-0 overflow-x-scroll\">") 95 109 if templ_7745c5c3_Err != nil { 96 110 return templ_7745c5c3_Err 97 111 } 98 112 var templ_7745c5c3_Var5 string 99 113 templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(req.ClientID) 100 114 if templ_7745c5c3_Err != nil { 101 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 26, Col: 55} 115 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 34, Col: 103} 102 116 } 103 117 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) 104 118 if templ_7745c5c3_Err != nil { 105 119 return templ_7745c5c3_Err 106 120 } 107 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</code></li><li><strong>Client:</strong> <code>") 121 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><h3 class=\"px-6 pt-4 pb-2 md:py-4 border-t md:border-b md:border-r text-subtle font-bold\">Redirect URL</h3><p class=\"px-6 pb-4 pt-1 md:py-4 md:border-y min-w-0 overflow-x-scroll\">") 108 122 if templ_7745c5c3_Err != nil { 109 123 return templ_7745c5c3_Err 110 124 } 111 125 var templ_7745c5c3_Var6 string 112 126 templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(req.RedirectURI) 113 127 if templ_7745c5c3_Err != nil { 114 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 27, Col: 56} 128 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 37, Col: 95} 115 129 } 116 130 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) 117 131 if templ_7745c5c3_Err != nil { 118 132 return templ_7745c5c3_Err 119 133 } 120 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</code></li></ul><p>For the following scopes: ") 134 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</p><h3 class=\"px-6 pt-4 pb-2 md:py-4 border-t bg-overlay md:border-r text-subtle font-bold\">Scopes</h3><ul class=\"px-6 pb-4 pt-1 md:py-4 bg-overlay flex flex-wrap gap-3\">") 121 135 if templ_7745c5c3_Err != nil { 122 136 return templ_7745c5c3_Err 123 137 } 124 138 for _, scope := range req.Scopes { 125 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<code>") 139 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<li class=\"px-2 py-1 text-sm bg-pine rounded\">") 126 140 if templ_7745c5c3_Err != nil { 127 141 return templ_7745c5c3_Err 128 142 } 129 143 var templ_7745c5c3_Var7 string 130 144 templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(scope) 131 145 if templ_7745c5c3_Err != nil { 132 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 32, Col: 19} 146 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 42, Col: 63} 133 147 } 134 148 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) 135 149 if templ_7745c5c3_Err != nil { 136 150 return templ_7745c5c3_Err 137 151 } 138 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</code> ") 152 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</li>") 139 153 if templ_7745c5c3_Err != nil { 140 154 return templ_7745c5c3_Err 141 155 } 142 156 } 143 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(".</p><form method=\"post\" action=\"/authorization/accept\"><input type=\"hidden\" name=\"response_type\" value=\"code\"> <input type=\"hidden\" name=\"scope\" value=\"") 157 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</ul></div></div><form method=\"post\" action=\"/authorization/accept\"><input type=\"hidden\" name=\"response_type\" value=\"code\"> <input type=\"hidden\" name=\"scope\" value=\"") 144 158 if templ_7745c5c3_Err != nil { 145 159 return templ_7745c5c3_Err 146 160 } 147 161 var templ_7745c5c3_Var8 string 148 162 templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(req.Scopes, " ")) 149 163 if templ_7745c5c3_Err != nil { 150 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 38, Col: 75} 164 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 50, Col: 75} 151 165 } 152 166 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) 153 167 if templ_7745c5c3_Err != nil { ··· 160 174 var templ_7745c5c3_Var9 string 161 175 templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(req.RedirectURI) 162 176 if templ_7745c5c3_Err != nil { 163 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 39, Col: 68} 177 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 51, Col: 68} 164 178 } 165 179 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) 166 180 if templ_7745c5c3_Err != nil { ··· 173 187 var templ_7745c5c3_Var10 string 174 188 templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(req.ClientID) 175 189 if templ_7745c5c3_Err != nil { 176 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 40, Col: 62} 190 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 52, Col: 62} 177 191 } 178 192 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) 179 193 if templ_7745c5c3_Err != nil { ··· 186 200 var templ_7745c5c3_Var11 string 187 201 templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(req.State) 188 202 if templ_7745c5c3_Err != nil { 189 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 41, Col: 55} 203 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 53, Col: 55} 190 204 } 191 205 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) 192 206 if templ_7745c5c3_Err != nil { ··· 199 213 var templ_7745c5c3_Var12 string 200 214 templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(req.CodeChallenge) 201 215 if templ_7745c5c3_Err != nil { 202 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 42, Col: 72} 216 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 54, Col: 72} 203 217 } 204 218 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) 205 219 if templ_7745c5c3_Err != nil { ··· 212 226 var templ_7745c5c3_Var13 string 213 227 templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(req.CodeChallengeMethod) 214 228 if templ_7745c5c3_Err != nil { 215 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 43, Col: 85} 229 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 55, Col: 85} 216 230 } 217 231 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) 218 232 if templ_7745c5c3_Err != nil { ··· 225 239 var templ_7745c5c3_Var14 string 226 240 templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(nonceId) 227 241 if templ_7745c5c3_Err != nil { 228 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 46, Col: 56} 242 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 58, Col: 56} 229 243 } 230 244 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) 231 245 if templ_7745c5c3_Err != nil { ··· 238 252 var templ_7745c5c3_Var15 string 239 253 templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(nonce) 240 254 if templ_7745c5c3_Err != nil { 241 - return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 47, Col: 51} 255 + return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 59, Col: 51} 242 256 } 243 257 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) 244 258 if templ_7745c5c3_Err != nil { 245 259 return templ_7745c5c3_Err 246 260 } 247 - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><p>In a production server, this page could be behind some sort of authentication mechanism, such as username and password, PassKey, etc.</p><button id=\"submit\">Authorize</button></form>") 261 + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> <button class=\"mt-8 px-3 py-2 flex items-center justify-center gap-2 bg-surface border border-highlightMed text-sm font-bold transition rounded hover:bg-foam hover:text-surface\" id=\"submit\"><svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"currentColor\" class=\"size-4\"><path fill-rule=\"evenodd\" d=\"M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14Zm3.844-8.791a.75.75 0 0 0-1.188-.918l-3.7 4.79-1.649-1.833a.75.75 0 1 0-1.114 1.004l2.25 2.5a.75.75 0 0 0 1.15-.043l4.25-5.5Z\" clip-rule=\"evenodd\"></path></svg> Authorize</button></form></div>") 248 262 if templ_7745c5c3_Err != nil { 249 263 return templ_7745c5c3_Err 250 264 }