An experimental IndieWeb site built in Go.
at main 13 kB view raw
1// Code generated by templ - DO NOT EDIT. 2 3// templ: version: v0.2.747 4package pages 5 6//lint:file-ignore SA4006 This context is only used if a nested component is present. 7 8import "github.com/a-h/templ" 9import templruntime "github.com/a-h/templ/runtime" 10 11import ( 12 "go.hacdias.com/indielib/indieauth" 13 "strings" 14) 15 16func Auth(req *indieauth.AuthenticationRequest, app *indieauth.ApplicationMetadata, nonceId string, nonce string) templ.Component { 17 return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { 18 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context 19 templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) 20 if !templ_7745c5c3_IsBuffer { 21 defer func() { 22 templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) 23 if templ_7745c5c3_Err == nil { 24 templ_7745c5c3_Err = templ_7745c5c3_BufErr 25 } 26 }() 27 } 28 ctx = templ.InitializeContext(ctx) 29 templ_7745c5c3_Var1 := templ.GetChildren(ctx) 30 if templ_7745c5c3_Var1 == nil { 31 templ_7745c5c3_Var1 = templ.NopComponent 32 } 33 ctx = templ.ClearChildren(ctx) 34 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<main class=\"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 if templ_7745c5c3_Err != nil { 36 return templ_7745c5c3_Err 37 } 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 } 43 if len(app.Logo) > 0 { 44 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<img class=\"max-w-12\" src=\"") 45 if templ_7745c5c3_Err != nil { 46 return templ_7745c5c3_Err 47 } 48 var templ_7745c5c3_Var2 string 49 templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(app.Logo) 50 if templ_7745c5c3_Err != nil { 51 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 16, Col: 42} 52 } 53 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) 54 if templ_7745c5c3_Err != nil { 55 return templ_7745c5c3_Err 56 } 57 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">") 58 if templ_7745c5c3_Err != nil { 59 return templ_7745c5c3_Err 60 } 61 } 62 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div><h2 class=\"font-bold text-lg\">") 63 if templ_7745c5c3_Err != nil { 64 return templ_7745c5c3_Err 65 } 66 var templ_7745c5c3_Var3 string 67 templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(app.Name) 68 if templ_7745c5c3_Err != nil { 69 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 19, Col: 46} 70 } 71 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) 72 if templ_7745c5c3_Err != nil { 73 return templ_7745c5c3_Err 74 } 75 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</h2>") 76 if templ_7745c5c3_Err != nil { 77 return templ_7745c5c3_Err 78 } 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: 21, Col: 52} 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 } 97 } 98 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div>") 99 if templ_7745c5c3_Err != nil { 100 return templ_7745c5c3_Err 101 } 102 } else { 103 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<h2 class=\"px-6 font-bold text-subtle\">unidentified client</h2>") 104 if templ_7745c5c3_Err != nil { 105 return templ_7745c5c3_Err 106 } 107 } 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\">") 109 if templ_7745c5c3_Err != nil { 110 return templ_7745c5c3_Err 111 } 112 var templ_7745c5c3_Var5 string 113 templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(req.ClientID) 114 if templ_7745c5c3_Err != nil { 115 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 30, Col: 101} 116 } 117 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) 118 if templ_7745c5c3_Err != nil { 119 return templ_7745c5c3_Err 120 } 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\">") 122 if templ_7745c5c3_Err != nil { 123 return templ_7745c5c3_Err 124 } 125 var templ_7745c5c3_Var6 string 126 templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(req.RedirectURI) 127 if templ_7745c5c3_Err != nil { 128 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 32, Col: 93} 129 } 130 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) 131 if templ_7745c5c3_Err != nil { 132 return templ_7745c5c3_Err 133 } 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\">") 135 if templ_7745c5c3_Err != nil { 136 return templ_7745c5c3_Err 137 } 138 for _, scope := range req.Scopes { 139 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<li class=\"px-2 py-1 text-sm bg-pine rounded\">") 140 if templ_7745c5c3_Err != nil { 141 return templ_7745c5c3_Err 142 } 143 var templ_7745c5c3_Var7 string 144 templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(scope) 145 if templ_7745c5c3_Err != nil { 146 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 36, Col: 59} 147 } 148 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) 149 if templ_7745c5c3_Err != nil { 150 return templ_7745c5c3_Err 151 } 152 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</li>") 153 if templ_7745c5c3_Err != nil { 154 return templ_7745c5c3_Err 155 } 156 } 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=\"") 158 if templ_7745c5c3_Err != nil { 159 return templ_7745c5c3_Err 160 } 161 var templ_7745c5c3_Var8 string 162 templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(req.Scopes, " ")) 163 if templ_7745c5c3_Err != nil { 164 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 43, Col: 74} 165 } 166 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) 167 if templ_7745c5c3_Err != nil { 168 return templ_7745c5c3_Err 169 } 170 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> <input type=\"hidden\" name=\"redirect_uri\" value=\"") 171 if templ_7745c5c3_Err != nil { 172 return templ_7745c5c3_Err 173 } 174 var templ_7745c5c3_Var9 string 175 templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(req.RedirectURI) 176 if templ_7745c5c3_Err != nil { 177 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 44, Col: 67} 178 } 179 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) 180 if templ_7745c5c3_Err != nil { 181 return templ_7745c5c3_Err 182 } 183 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> <input type=\"hidden\" name=\"client_id\" value=\"") 184 if templ_7745c5c3_Err != nil { 185 return templ_7745c5c3_Err 186 } 187 var templ_7745c5c3_Var10 string 188 templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(req.ClientID) 189 if templ_7745c5c3_Err != nil { 190 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 45, Col: 61} 191 } 192 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) 193 if templ_7745c5c3_Err != nil { 194 return templ_7745c5c3_Err 195 } 196 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> <input type=\"hidden\" name=\"state\" value=\"") 197 if templ_7745c5c3_Err != nil { 198 return templ_7745c5c3_Err 199 } 200 var templ_7745c5c3_Var11 string 201 templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(req.State) 202 if templ_7745c5c3_Err != nil { 203 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 46, Col: 54} 204 } 205 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) 206 if templ_7745c5c3_Err != nil { 207 return templ_7745c5c3_Err 208 } 209 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> <input type=\"hidden\" name=\"code_challenge\" value=\"") 210 if templ_7745c5c3_Err != nil { 211 return templ_7745c5c3_Err 212 } 213 var templ_7745c5c3_Var12 string 214 templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(req.CodeChallenge) 215 if templ_7745c5c3_Err != nil { 216 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 47, Col: 71} 217 } 218 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) 219 if templ_7745c5c3_Err != nil { 220 return templ_7745c5c3_Err 221 } 222 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> <input type=\"hidden\" name=\"code_challenge_method\" value=\"") 223 if templ_7745c5c3_Err != nil { 224 return templ_7745c5c3_Err 225 } 226 var templ_7745c5c3_Var13 string 227 templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(req.CodeChallengeMethod) 228 if templ_7745c5c3_Err != nil { 229 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 48, Col: 84} 230 } 231 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) 232 if templ_7745c5c3_Err != nil { 233 return templ_7745c5c3_Err 234 } 235 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><input type=\"hidden\" name=\"nonce_id\" value=\"") 236 if templ_7745c5c3_Err != nil { 237 return templ_7745c5c3_Err 238 } 239 var templ_7745c5c3_Var14 string 240 templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(nonceId) 241 if templ_7745c5c3_Err != nil { 242 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 50, Col: 55} 243 } 244 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) 245 if templ_7745c5c3_Err != nil { 246 return templ_7745c5c3_Err 247 } 248 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"> <input type=\"hidden\" name=\"nonce\" value=\"") 249 if templ_7745c5c3_Err != nil { 250 return templ_7745c5c3_Err 251 } 252 var templ_7745c5c3_Var15 string 253 templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(nonce) 254 if templ_7745c5c3_Err != nil { 255 return templ.Error{Err: templ_7745c5c3_Err, FileName: `html/pages/auth.templ`, Line: 51, Col: 50} 256 } 257 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) 258 if templ_7745c5c3_Err != nil { 259 return templ_7745c5c3_Err 260 } 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></main>") 262 if templ_7745c5c3_Err != nil { 263 return templ_7745c5c3_Err 264 } 265 return templ_7745c5c3_Err 266 }) 267}