feat: add PUBLIC_INSTANCE_TYPE env var
This commit is contained in:
9 files changed
+37
-68
No files matched your search
@@ -21,7 +21,6 @@ Jump to:
|
|||||||
<img width="3220" height="1800" alt="Photon dark theme compact" src="https://github.com/user-attachments/assets/76b5278b-e5f9-4c0c-81ec-0820d3261223" />
|
<img width="3220" height="1800" alt="Photon dark theme compact" src="https://github.com/user-attachments/assets/76b5278b-e5f9-4c0c-81ec-0820d3261223" />
|
||||||
<img width="3220" height="1800" alt="Photon light theme cozy" src="https://github.com/user-attachments/assets/41d205fe-7d32-4b83-bfef-6aa9dd63e074" />
|
<img width="3220" height="1800" alt="Photon light theme cozy" src="https://github.com/user-attachments/assets/41d205fe-7d32-4b83-bfef-6aa9dd63e074" />
|
||||||
|
|
||||||
|
|
||||||
## Self-hosting
|
## Self-hosting
|
||||||
|
|
||||||
You selfhost a Photon frontend server for your Lemmy instance, or independently for any instance.
|
You selfhost a Photon frontend server for your Lemmy instance, or independently for any instance.
|
||||||
@@ -39,6 +38,7 @@ To run an unconfigured Photon instance on port `8080`:
|
|||||||
```sh
|
```sh
|
||||||
docker run -p 8080:3000 ghcr.io/xyphyn/photon:latest
|
docker run -p 8080:3000 ghcr.io/xyphyn/photon:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running natively
|
### Running natively
|
||||||
|
|
||||||
Clone the repo:
|
Clone the repo:
|
||||||
@@ -80,8 +80,11 @@ Photon lets you configure the default client settings and more.
|
|||||||
If you're hosting Photon for a Lemmy instance, you' ll almost definitely want to set these:
|
If you're hosting Photon for a Lemmy instance, you' ll almost definitely want to set these:
|
||||||
|
|
||||||
- `PUBLIC_INSTANCE_URL` `string`: The domain which **the browser** will send API requests to.
|
- `PUBLIC_INSTANCE_URL` `string`: The domain which **the browser** will send API requests to.
|
||||||
|
|
||||||
- Example: `PUBLIC_INSTANCE_URL=fedi.phtn.app`
|
- Example: `PUBLIC_INSTANCE_URL=fedi.phtn.app`
|
||||||
|
|
||||||
|
- `PUBLIC_INSTANCE_TYPE` `lemmyv3 | piefedalpha` (default: `lemmyv3`): If your instance is running Piefed, you must set this option to `piefedalpha`. Otherwise, you don't need to do anything.
|
||||||
|
|
||||||
- `PUBLIC_SSR_ENABLED` `boolean`: When enabled, will **make page requests be rendered server side first**, which allows search engine indexing, and basic non-js usage.
|
- `PUBLIC_SSR_ENABLED` `boolean`: When enabled, will **make page requests be rendered server side first**, which allows search engine indexing, and basic non-js usage.
|
||||||
|
|
||||||
- `PUBLIC_INTERNAL_INSTANCE` `string`: Only relevant if `PUBLIC_SSR_ENABLED=true`. This is the domain that the **server will make API requests to.**
|
- `PUBLIC_INTERNAL_INSTANCE` `string`: Only relevant if `PUBLIC_SSR_ENABLED=true`. This is the domain that the **server will make API requests to.**
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@dicebear/core": "^8.0.1",
|
"@dicebear/core": "^8.0.1",
|
||||||
|
|||||||
+11
-4
@@ -1,13 +1,20 @@
|
|||||||
|
import { env } from '$env/dynamic/public'
|
||||||
import * as types from './types'
|
import * as types from './types'
|
||||||
|
|
||||||
export type ClientType =
|
export type ClientType =
|
||||||
| { name: 'lemmy'; baseUrl: '/api/v3' }
|
| { name: 'lemmy'; baseUrl: '/api/v3' }
|
||||||
| { name: 'piefed'; baseUrl: '/api/alpha' }
|
| { name: 'piefed'; baseUrl: '/api/alpha' }
|
||||||
|
|
||||||
export const DEFAULT_CLIENT_TYPE: ClientType = {
|
export const DEFAULT_CLIENT_TYPE: ClientType =
|
||||||
name: 'lemmy',
|
env.PUBLIC_INSTANCE_TYPE == 'piefedalpha'
|
||||||
baseUrl: '/api/v3',
|
? {
|
||||||
}
|
name: 'piefed',
|
||||||
|
baseUrl: '/api/alpha',
|
||||||
|
}
|
||||||
|
: {
|
||||||
|
name: 'lemmy',
|
||||||
|
baseUrl: '/api/v3',
|
||||||
|
}
|
||||||
|
|
||||||
export abstract class BaseClient {
|
export abstract class BaseClient {
|
||||||
abstract type: ClientType
|
abstract type: ClientType
|
||||||
|
|||||||
@@ -119,34 +119,3 @@ export async function validateInstance(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mayBeIncompatible(
|
|
||||||
minVersion: string,
|
|
||||||
availableVersion: string,
|
|
||||||
) {
|
|
||||||
if (minVersion.valueOf() === availableVersion.valueOf()) return false
|
|
||||||
|
|
||||||
const versionFormatter = /[\d.]/
|
|
||||||
if (
|
|
||||||
!minVersion.match(versionFormatter) ||
|
|
||||||
!availableVersion.match(availableVersion)
|
|
||||||
) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
const splitMinVersion = minVersion.split('.')
|
|
||||||
const splitAvailableVersion = availableVersion.split('.')
|
|
||||||
|
|
||||||
if (splitMinVersion.length !== splitAvailableVersion.length) return true
|
|
||||||
|
|
||||||
for (let i = 0; i < splitMinVersion.length; ++i) {
|
|
||||||
const minVersionDigit = parseInt(splitMinVersion[i])
|
|
||||||
const availableVersionDigit = parseInt(splitAvailableVersion[i])
|
|
||||||
|
|
||||||
if (availableVersionDigit === undefined) return true
|
|
||||||
if (minVersionDigit < availableVersionDigit) return false
|
|
||||||
if (availableVersionDigit < minVersionDigit) return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
@@ -62,7 +62,8 @@
|
|||||||
"moveUp": "Move up",
|
"moveUp": "Move up",
|
||||||
"moveDown": "Move down",
|
"moveDown": "Move down",
|
||||||
"guest": "Guest",
|
"guest": "Guest",
|
||||||
"versionGate": "This version of Photon supports instances running {{version}} or higher."
|
"versionGate": "This version of Photon supports instances running {{version}} or higher.",
|
||||||
|
"piefedGate": "Piefed support is experimental. Some features are not supported."
|
||||||
},
|
},
|
||||||
"filter": {
|
"filter": {
|
||||||
"location": {
|
"location": {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
import { site } from '$lib/client/lemmy.svelte'
|
||||||
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||||
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
||||||
@@ -10,7 +11,6 @@
|
|||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||||
import { t } from '$lib/i18n/translations.js'
|
import { t } from '$lib/i18n/translations.js'
|
||||||
import { site } from '$lib/client/lemmy.svelte'
|
|
||||||
import { postFeeds } from '$lib/lemmy/postfeed.svelte.js'
|
import { postFeeds } from '$lib/lemmy/postfeed.svelte.js'
|
||||||
import { settings, SSR_ENABLED } from '$lib/settings.svelte.js'
|
import { settings, SSR_ENABLED } from '$lib/settings.svelte.js'
|
||||||
import Button from 'mono-svelte/button/Button.svelte'
|
import Button from 'mono-svelte/button/Button.svelte'
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { preventDefault } from 'svelte/legacy'
|
|
||||||
|
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
import { profile } from '$lib/auth.svelte'
|
import { profile } from '$lib/auth.svelte'
|
||||||
import { client, mayBeIncompatible, site } from '$lib/client/lemmy.svelte'
|
import { DEFAULT_CLIENT_TYPE, type ClientType } from '$lib/client/base'
|
||||||
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import ErrorContainer, {
|
import ErrorContainer, {
|
||||||
clearErrorScope,
|
clearErrorScope,
|
||||||
pushError,
|
pushError,
|
||||||
@@ -17,7 +16,6 @@
|
|||||||
} from '$lib/instance.svelte.js'
|
} from '$lib/instance.svelte.js'
|
||||||
import { errorMessage } from '$lib/lemmy/error'
|
import { errorMessage } from '$lib/lemmy/error'
|
||||||
import { DOMAIN_REGEX_FORMS } from '$lib/util.svelte.js'
|
import { DOMAIN_REGEX_FORMS } from '$lib/util.svelte.js'
|
||||||
import { MINIMUM_VERSION } from '$lib/version.js'
|
|
||||||
import { Button, Note, Option, Select, TextInput, toast } from 'mono-svelte'
|
import { Button, Note, Option, Select, TextInput, toast } from 'mono-svelte'
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
@@ -25,7 +23,6 @@
|
|||||||
QuestionMarkCircle,
|
QuestionMarkCircle,
|
||||||
UserCircle,
|
UserCircle,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { DEFAULT_CLIENT_TYPE, type ClientType } from '$lib/client/base'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
ref?: string
|
ref?: string
|
||||||
@@ -110,19 +107,23 @@
|
|||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="max-w-xl w-full mx-auto h-max my-auto">
|
<div class="max-w-xl w-full mx-auto h-max my-auto">
|
||||||
<form onsubmit={preventDefault(logIn)} class="flex flex-col gap-5">
|
<form
|
||||||
|
onsubmit={e => {
|
||||||
|
e.preventDefault()
|
||||||
|
logIn()
|
||||||
|
}}
|
||||||
|
class="flex flex-col gap-5"
|
||||||
|
>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
<Header>{$t('account.login')}</Header>
|
<Header>{$t('account.login')}</Header>
|
||||||
{#if site.data && mayBeIncompatible(MINIMUM_VERSION, site.data.version.replace('v', ''))}
|
|
||||||
<Note>
|
|
||||||
{$t('account.versionGate', {
|
|
||||||
version: `v${MINIMUM_VERSION}`,
|
|
||||||
})}
|
|
||||||
</Note>
|
|
||||||
{/if}
|
|
||||||
<ErrorContainer class="pt-2" scope={page.route.id} />
|
<ErrorContainer class="pt-2" scope={page.route.id} />
|
||||||
</div>
|
</div>
|
||||||
|
{#if data.client.name == 'piefed'}
|
||||||
|
<Note>
|
||||||
|
{$t('account.piefedGate')}
|
||||||
|
</Note>
|
||||||
|
{/if}
|
||||||
<div class="flex flex-row w-full items-center gap-2">
|
<div class="flex flex-row w-full items-center gap-2">
|
||||||
<TextInput
|
<TextInput
|
||||||
id="username"
|
id="username"
|
||||||
|
|||||||
@@ -3,16 +3,14 @@
|
|||||||
|
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { page } from '$app/state'
|
import { page } from '$app/state'
|
||||||
|
import { profile } from '$lib/auth.svelte'
|
||||||
|
import { DEFAULT_CLIENT_TYPE, type ClientType } from '$lib/client/base'
|
||||||
|
import { validateInstance } from '$lib/client/lemmy.svelte'
|
||||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||||
import { t } from '$lib/i18n/translations'
|
import { t } from '$lib/i18n/translations'
|
||||||
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte'
|
||||||
import { mayBeIncompatible } from '$lib/client/lemmy.svelte'
|
|
||||||
import { site, validateInstance } from '$lib/client/lemmy.svelte'
|
|
||||||
import { DOMAIN_REGEX_FORMS } from '$lib/util.svelte'
|
import { DOMAIN_REGEX_FORMS } from '$lib/util.svelte'
|
||||||
import { MINIMUM_VERSION } from '$lib/version'
|
import { Button, Option, Select, TextInput, toast } from 'mono-svelte'
|
||||||
import { Button, Note, Option, Select, TextInput, toast } from 'mono-svelte'
|
|
||||||
import { profile } from '$lib/auth.svelte'
|
|
||||||
import { DEFAULT_CLIENT_TYPE, type ClientType } from '$lib/client/base'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
ref?: string
|
ref?: string
|
||||||
@@ -64,13 +62,6 @@
|
|||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
<Header>{$t('account.addGuest')}</Header>
|
<Header>{$t('account.addGuest')}</Header>
|
||||||
{#if site.data && mayBeIncompatible(MINIMUM_VERSION, site.data.version.replace('v', ''))}
|
|
||||||
<Note>
|
|
||||||
{$t('account.versionGate', {
|
|
||||||
version: `v${MINIMUM_VERSION}`,
|
|
||||||
})}
|
|
||||||
</Note>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="inline-flex items-center gap-2">
|
<div class="inline-flex items-center gap-2">
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|||||||
Reference in new issue
Block a user