diff --git a/src/lib/api/base.ts b/src/lib/api/base.ts index aec3ad66..a962affa 100644 --- a/src/lib/api/base.ts +++ b/src/lib/api/base.ts @@ -26,6 +26,40 @@ export abstract class BaseClient { } } + static async fetchInfo( + base: string, + ): Promise<{ type: ClientType; version: string } | null> { + try { + const res = await fetch(new URL('/nodeinfo/2.1', base)) + + if (!res.ok) return null + + const software: { name: string; version: string } = (await res.json()) + .software + + // should probably extract this into not a static function but its ok + switch (software.name) { + case 'lemmy': { + return { + type: { baseUrl: '/api/v3', name: 'lemmy' }, + version: software.version, + } + } + case 'piefed': { + return { + type: { baseUrl: '/api/alpha', name: 'piefed' }, + version: software.version, + } + } + default: + return null + } + } catch (err) { + console.error(err) + return null + } + } + abstract getSite(): Promise abstract editSite(form: types.EditSite): Promise abstract generateTotpSecret(): Promise diff --git a/src/lib/app/i18n/en.json b/src/lib/app/i18n/en.json index a17ff56a..08e7bcb7 100644 --- a/src/lib/app/i18n/en.json +++ b/src/lib/app/i18n/en.json @@ -953,7 +953,8 @@ "not_an_admin": "You are not an admin of this server.", "rate_limit_error": "You are performing that action too fast.", "unimplemented": "That function of your account's server software is not yet supported by Photon.", - "unsupported": "That function is not supported by your account's server software." + "unsupported": "That function is not supported by your account's server software.", + "not_live_supported": "That server is not running supported software, or is offline." }, "aria": { "pagination": { diff --git a/src/lib/ui/shared/forms/TextInput.svelte b/src/lib/ui/shared/forms/TextInput.svelte index 81c33c21..b0c64598 100644 --- a/src/lib/ui/shared/forms/TextInput.svelte +++ b/src/lib/ui/shared/forms/TextInput.svelte @@ -65,9 +65,10 @@ diff --git a/src/lib/ui/shared/note/Note.svelte b/src/lib/ui/shared/note/Note.svelte index 3fde440a..f5efd6bc 100644 --- a/src/lib/ui/shared/note/Note.svelte +++ b/src/lib/ui/shared/note/Note.svelte @@ -27,7 +27,7 @@ {#if children} {@render children?.()} {:else if content} -

+

{content}

{/if} diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index e7f7ca96..bceb913a 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -1,7 +1,11 @@ @@ -122,7 +155,7 @@
{$t('account.login')}
- {#if data.client.name == 'piefed'} + {#if form.client.name == 'piefed'} {$t('account.piefedGate')} @@ -130,7 +163,7 @@
- {#snippet suffix()} - + {#snippet customLabel()} + {$t('form.instance')} + + {#if detectedClient} + + {detectedClient} + + {:else if detectedClient === null} + + {/if} + {/snippet} {/if} @@ -176,13 +201,13 @@