Files
extrovert/components/logins.templ
2024-07-08 20:17:50 -03:00

53 lines
1.1 KiB
Plaintext

package components
import (
"fmt"
"os"
"net/url"
)
var loginUrl = fmt.Sprintf("https://x.com/i/oauth2/authorize"+
"?response_type=code"+
"&client_id=%s"+
"&redirect_uri=%s"+
"&scope=tweet.write tweet.read users.read"+
"&state=state"+
"&code_challenge=challenge"+
"&code_challenge_method=plain",
os.Getenv("TWITTER_CLIENT_ID"),
url.PathEscape("http://localhost:7331/api/oauth/twitter"),
)
templ LoginTwitter() {
<a href={ templ.SafeURL(loginUrl) } rel="">Login on Twitter</a>
}
templ LoginMastodon() {
<button popovertargetaction="show" popovertarget="mastodon-login">Login on Mastodon</button>
<div id="mastodon-login" popover>
<dialog open>
<article>
<header>
<button
popovertargetaction="hide"
popovertarget="mastodon-login"
aria-label="Close"
rel="prev"
></button>
<label for="instance-url">Choose a instance</label>
</header>
<input
type="url"
name="instance-url"
placeholder="Instance Url"
aria-label="Instance Url"
list="instance-suggestions"
/>
<datalist id="instance-suggestions">
@InstancesOptions(20)
</datalist>
</article>
</dialog>
</div>
}