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 @@