From 258bad533cc0539f5edb7b8f568cccbbafadb069 Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Thu, 24 Aug 2023 17:27:56 -0700 Subject: [PATCH] feat: add LOCK_TO_INSTANCE env var --- README.md | 45 +++++++++++++++++++++++---------------------- package.json | 2 +- src/lib/instance.ts | 5 ++++- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index f0141272..2d9e32bd 100644 --- a/README.md +++ b/README.md @@ -47,28 +47,29 @@ There you go, you now have an instance of Photon running. The following environment variables can be set to override the default settings: -| Variable | Values | Default Value | -| ------------------------------- | ------------------- | ------------- | -| PUBLIC_INSTANCE_URL | URL | `lemmy.ml` | -| PUBLIC_THEME | system\|dark\|light | system | -| PUBLIC_EXPANDABLE_IMAGES | `bool` | true | -| PUBLIC_MARK_READ_POSTS | `bool` | true | -| PUBLIC_REVERT_VOTE_COLORS | `bool` | false | -| PUBLIC_SHOW_INSTANCES_USER | `bool` | false | -| PUBLIC_SHOW_INSTANCES_COMMUNITY | `bool` | true | -| PUBLIC_SHOW_INSTANCES_COMMENTS | `bool` | false | -| PUBLIC_SHOW_COMPACT_POSTS | `bool` | false | -| PUBLIC_DEFAULT_FEED_SORT | `SortType` | Active | -| PUBLIC_DEFAULT_FEED | `ListingType` | Local | -| PUBLIC_DEFAULT_COMMENT_SORT | `CommentSortType` | Hot | -| PUBLIC_HIDE_DELETED | `bool` | true | -| PUBLIC_HIDE_REMOVED | `bool` | false | -| PUBLIC_FULL_WIDTH_LAYOUT | `bool` | false | -| PUBLIC_EXPAND_SIDEBAR | `bool` | true | -| PUBLIC_DISPLAY_NAMES | `bool` | true | -| PUBLIC_NSFW_BLUR | `bool` | true | -| PUBLIC_NEW_VOTE_BUTTONS | `bool` | false | -| PUBLIC_RANDOM_PLACEHOLDERS | `bool` | true | +| Variable | Values | Default Value | +| ------------------------------- | ------------------- | -------------------------------------- | +| PUBLIC_INSTANCE_URL | URL | `lemmy.ml` | +| PUBLIC_LOCK_TO_INSTANCE | `bool` | `true` if `PUBLIC_INSTANCE_URL` is set | +| PUBLIC_THEME | system\|dark\|light | system | +| PUBLIC_EXPANDABLE_IMAGES | `bool` | true | +| PUBLIC_MARK_READ_POSTS | `bool` | true | +| PUBLIC_REVERT_VOTE_COLORS | `bool` | false | +| PUBLIC_SHOW_INSTANCES_USER | `bool` | false | +| PUBLIC_SHOW_INSTANCES_COMMUNITY | `bool` | true | +| PUBLIC_SHOW_INSTANCES_COMMENTS | `bool` | false | +| PUBLIC_SHOW_COMPACT_POSTS | `bool` | false | +| PUBLIC_DEFAULT_FEED_SORT | `SortType` | Active | +| PUBLIC_DEFAULT_FEED | `ListingType` | Local | +| PUBLIC_DEFAULT_COMMENT_SORT | `CommentSortType` | Hot | +| PUBLIC_HIDE_DELETED | `bool` | true | +| PUBLIC_HIDE_REMOVED | `bool` | false | +| PUBLIC_FULL_WIDTH_LAYOUT | `bool` | false | +| PUBLIC_EXPAND_SIDEBAR | `bool` | true | +| PUBLIC_DISPLAY_NAMES | `bool` | true | +| PUBLIC_NSFW_BLUR | `bool` | true | +| PUBLIC_NEW_VOTE_BUTTONS | `bool` | false | +| PUBLIC_RANDOM_PLACEHOLDERS | `bool` | true | The values for `SortType`, `ListingType`, and `CommentSortType` are defined by the lemmy-js-client library. diff --git a/package.json b/package.json index 07b64092..debb7037 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photon-lemmy", - "version": "0.9.26", + "version": "0.9.27", "private": true, "scripts": { "dev": "vite dev", diff --git a/src/lib/instance.ts b/src/lib/instance.ts index 639a3a67..29d750f3 100644 --- a/src/lib/instance.ts +++ b/src/lib/instance.ts @@ -3,6 +3,9 @@ import { env } from '$env/dynamic/public' import { writable } from 'svelte/store' -export const LINKED_INSTANCE_URL = env.PUBLIC_INSTANCE_URL +export const LINKED_INSTANCE_URL = + (env.PUBLIC_LOCK_TO_INSTANCE ?? 'true').toLowerCase() == 'true' + ? env.PUBLIC_INSTANCE_URL + : undefined export const DEFAULT_INSTANCE_URL = env.PUBLIC_INSTANCE_URL || 'lemmy.ml' export let instance = writable(DEFAULT_INSTANCE_URL)