From a9bf3497fe7e429acfcd617f37db8cef3ee23c3f Mon Sep 17 00:00:00 2001 From: larsi Date: Sat, 14 Nov 2026 01:06:07 +0100 Subject: [PATCH] feat: single-community mode (PUBLIC_SINGLE_COMMUNITY) For instances that are one community (thebitcoin.win): "/" reroutes to the community page, community browsing and explore lead back to it, community names/handles are hidden on posts and in the header, and create-post preselects the community. Unset, behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_011c5BZVwWdVLrdQi9htmuth --- .github/README.md | 18 ++++++++++++ src/hooks.ts | 16 ++++++++++ src/lib/app/single.ts | 11 +++++++ .../feature/community/CommunityHeader.svelte | 3 ++ src/lib/feature/post/PostMeta.svelte | 7 +++-- src/lib/feature/post/feed/PostFeed.svelte | 9 ++++-- src/lib/feature/post/feed/VirtualFeed.svelte | 3 ++ src/lib/ui/navbar/Navbar.svelte | 17 ++++++----- src/lib/ui/navbar/commands/actions.svelte.ts | 29 ++++++++++++------- src/routes/create/post/+page.svelte | 7 +++-- src/routes/create/post/+page.ts | 12 +++++++- 11 files changed, 105 insertions(+), 27 deletions(-) create mode 100644 src/hooks.ts create mode 100644 src/lib/app/single.ts diff --git a/.github/README.md b/.github/README.md index a10fe88c..0cbffcb6 100644 --- a/.github/README.md +++ b/.github/README.md @@ -154,3 +154,21 @@ Want your instance added here? Make a GitHub issue or make a PR. (this is for ge I've put my best effort into developing and maintaining this open source app. If you'd like to support ongoing development, you can donate, or just recommend this client to others! [Buy me a Coffee](https://buymeacoffee.com/xylight) + +--- + +## thebitcoin.win fork + +This fork adds a **single-community mode** for sites where the whole instance is one community +(thebitcoin.win). Set `PUBLIC_SINGLE_COMMUNITY=` and: + +- `/` shows that community's feed (address stays `/`), and `/communities`, `/explore/*` and + other `/c/` pages lead back to it (`src/hooks.ts`, SvelteKit `reroute`) +- the Explore nav item, community browser entries in the command palette and the + "communities" buttons on empty feeds are hidden +- community names, handles and links are not shown on posts or in the community header +- creating a post preselects the community + +Unset, the client behaves exactly like upstream Photon. All changes are guarded by +`SINGLE_COMMUNITY` from `src/lib/app/single.ts`. Licensed AGPL-3.0 like upstream; source of the +running site: https://gitea.ihler.tech/larsi/photon-tbw diff --git a/src/hooks.ts b/src/hooks.ts new file mode 100644 index 00000000..4c28673d --- /dev/null +++ b/src/hooks.ts @@ -0,0 +1,16 @@ +import type { Reroute } from '@sveltejs/kit' +import { SINGLE_COMMUNITY } from '$lib/app/single' + +/** + * Single-community mode: serve the community page for "/" and for every route that would + * otherwise list or browse communities. The address bar keeps the original path, so the home + * page stays "/". The community's own sub-pages (e.g. /c//settings) are left alone. + */ +export const reroute: Reroute = ({ url }) => { + if (!SINGLE_COMMUNITY) return + const path = url.pathname + const home = `/c/${SINGLE_COMMUNITY}` + if (path === '/' || path === '/communities' || path.startsWith('/explore')) return home + const other = path.match(/^\/c\/([^/]+)\/?$/) + if (other && other[1] !== SINGLE_COMMUNITY) return home +} diff --git a/src/lib/app/single.ts b/src/lib/app/single.ts new file mode 100644 index 00000000..5c65c826 --- /dev/null +++ b/src/lib/app/single.ts @@ -0,0 +1,11 @@ +import { env } from '$env/dynamic/public' + +/** + * Single-community mode (thebitcoin.win fork). + * + * When PUBLIC_SINGLE_COMMUNITY is set, the site IS that one local community: "/" shows its + * feed, the community browser and explore pages lead back to it, and the UI stops showing + * community names and handles. Unset, Photon behaves exactly like upstream. + */ +export const SINGLE_COMMUNITY: string | undefined = + env.PUBLIC_SINGLE_COMMUNITY?.trim() || undefined diff --git a/src/lib/feature/community/CommunityHeader.svelte b/src/lib/feature/community/CommunityHeader.svelte index a637cec6..2a557291 100644 --- a/src/lib/feature/community/CommunityHeader.svelte +++ b/src/lib/feature/community/CommunityHeader.svelte @@ -1,4 +1,5 @@