2024-06-17 21:17:27 +01:00
|
|
|
<script>
|
|
|
|
import Feed from './Feed.svelte';
|
2024-06-19 22:13:16 +01:00
|
|
|
import { Client, server_types } from './client/client.js';
|
|
|
|
|
|
|
|
let ready = Client.get().app && Client.get().app.token;
|
|
|
|
|
|
|
|
let auth_code = new URLSearchParams(location.search).get("code");
|
|
|
|
if (auth_code) {
|
|
|
|
let client = Client.get();
|
|
|
|
client.getToken(auth_code).then(() => {
|
|
|
|
client.save();
|
|
|
|
location = location.origin;
|
2024-06-17 21:17:27 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function log_in(event) {
|
2024-06-19 22:13:16 +01:00
|
|
|
let client = Client.get();
|
2024-06-17 21:17:27 +01:00
|
|
|
event.preventDefault();
|
2024-06-19 22:13:16 +01:00
|
|
|
const host = event.target.host.value;
|
|
|
|
|
|
|
|
client.init(host).then(() => {
|
|
|
|
if (client.instance.type === server_types.INCOMPATIBLE) {
|
|
|
|
console.error("Server " + client.instance.host + " is not supported - " + client.instance.version);
|
|
|
|
alert("Sorry, this app is not compatible with " + client.instance.host + "!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
console.log("Server is \"" + client.instance.type + "\" (or compatible).");
|
|
|
|
client.save();
|
|
|
|
let oauth_url = client.getOAuthUrl();
|
|
|
|
location = oauth_url;
|
|
|
|
});
|
2024-06-17 21:17:27 +01:00
|
|
|
}
|
|
|
|
|
2024-06-19 22:13:16 +01:00
|
|
|
|
2024-06-17 21:17:27 +01:00
|
|
|
function log_out() {
|
2024-06-19 22:13:16 +01:00
|
|
|
Client.get().logout().then(() => {
|
|
|
|
ready = false;
|
|
|
|
});
|
2024-06-17 21:17:27 +01:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<header>
|
|
|
|
<h1>space social</h1>
|
|
|
|
<p>social media for the galaxy-wide-web! 🌌</p>
|
2024-06-19 22:13:16 +01:00
|
|
|
<button id="logout" on:click={log_out}>log out</button>
|
2024-06-17 21:17:27 +01:00
|
|
|
</header>
|
|
|
|
|
|
|
|
<main>
|
|
|
|
{#if ready}
|
|
|
|
<Feed />
|
2024-06-19 22:13:16 +01:00
|
|
|
{:else}
|
|
|
|
<div class="pane">
|
|
|
|
<form on:submit={log_in} id="login">
|
|
|
|
<h1>welcome!</h1>
|
|
|
|
<p>please enter your instance domain to log in.</p>
|
|
|
|
<input type="text" id="host" aria-label="instance domain">
|
|
|
|
<button type="submit" id="login">log in</button>
|
2024-06-17 21:17:27 +01:00
|
|
|
</form>
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
|
|
|
|
<p><small>
|
2024-06-19 22:13:16 +01:00
|
|
|
please note this is <strong><em>extremely experimental software</em></strong>;
|
2024-06-17 21:17:27 +01:00
|
|
|
even if you use the exact same instance as me, you may encounter problems.
|
|
|
|
if that's all cool with you, welcome aboard!
|
|
|
|
</small></p>
|
|
|
|
|
|
|
|
<p>made with ❤️ by <a href="https://arimelody.me">ari melody</a>, 2024</p>
|
2024-06-19 22:13:16 +01:00
|
|
|
</div>
|
2024-06-17 21:17:27 +01:00
|
|
|
{/if}
|
|
|
|
</main>
|
|
|
|
|
|
|
|
<footer>
|
|
|
|
</footer>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
header {
|
|
|
|
width: min(768px, calc(100vw - 32px));
|
|
|
|
margin: 16px auto;
|
|
|
|
padding: 0 16px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
|
2024-06-19 22:13:16 +01:00
|
|
|
header h1 {
|
|
|
|
margin: 0 16px 0 0;
|
|
|
|
}
|
|
|
|
|
2024-06-17 21:17:27 +01:00
|
|
|
h1 {
|
|
|
|
color: var(--accent);
|
|
|
|
}
|
|
|
|
|
|
|
|
main {
|
|
|
|
width: min(800px, calc(100vw - 16px));
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
|
|
|
|
2024-06-19 22:13:16 +01:00
|
|
|
div.pane {
|
|
|
|
margin-top: 16px;
|
|
|
|
padding: 20px 32px;
|
|
|
|
border: 1px solid #8884;
|
|
|
|
border-radius: 16px;
|
|
|
|
background-color: var(--bg1);
|
|
|
|
}
|
|
|
|
|
|
|
|
form#login {
|
|
|
|
margin: 64px 0;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
2024-06-17 21:17:27 +01:00
|
|
|
a {
|
|
|
|
color: var(--accent);
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
a:hover {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
|
2024-06-19 22:15:03 +01:00
|
|
|
input[type="text"] {
|
2024-06-19 22:13:16 +01:00
|
|
|
margin: 8px 0;
|
2024-06-17 21:17:27 +01:00
|
|
|
padding: 4px 6px;
|
|
|
|
font-family: inherit;
|
|
|
|
border: none;
|
|
|
|
border-radius: 8px;
|
|
|
|
}
|
|
|
|
|
2024-06-19 22:13:16 +01:00
|
|
|
button#login, button#logout {
|
2024-06-17 21:17:27 +01:00
|
|
|
margin-left: auto;
|
|
|
|
padding: 8px 12px;
|
|
|
|
font-size: 1em;
|
|
|
|
background-color: var(--bg2);
|
|
|
|
color: inherit;
|
|
|
|
border: none;
|
|
|
|
border-radius: 16px;
|
|
|
|
cursor: pointer;
|
|
|
|
transition: color .1s, background-color .1s;
|
|
|
|
}
|
|
|
|
|
2024-06-19 22:13:16 +01:00
|
|
|
button#login:hover, button#logout:hover {
|
2024-06-17 21:17:27 +01:00
|
|
|
color: var(--bg0);
|
|
|
|
background: var(--fg0);
|
|
|
|
}
|
|
|
|
|
2024-06-19 22:13:16 +01:00
|
|
|
button#login:active, button#logout:active {
|
2024-06-17 21:17:27 +01:00
|
|
|
background: #0001;
|
|
|
|
}
|
|
|
|
</style>
|