64 lines
1.4 KiB
Plaintext
64 lines
1.4 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/twitter/oauth"),
|
|
)
|
|
|
|
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>
|
|
<form
|
|
autocomplete="on"
|
|
method="post"
|
|
action="/api/mastodon/apps"
|
|
enctype="application/x-www-form-urlencoded"
|
|
>
|
|
<fieldset role="group">
|
|
<input
|
|
type="url"
|
|
name="instance-url"
|
|
placeholder="https://mastodon.social"
|
|
aria-label="Instance Url"
|
|
list="instance-suggestions"
|
|
required
|
|
/>
|
|
<datalist id="instance-suggestions">
|
|
@InstancesOptions(20)
|
|
</datalist>
|
|
<button>Login</button>
|
|
</fieldset>
|
|
</form>
|
|
</article>
|
|
</dialog>
|
|
</div>
|
|
}
|