From c560b6c0023e75c41ed7c627e550c6dcc401eba7 Mon Sep 17 00:00:00 2001 From: yugusaa <69077005+pinguDevelopment@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:46:54 +0000 Subject: [PATCH] Doku auf Deutsch und Englisch README.md ist jetzt die Startseite mit Sprachauswahl (README.en.md / README.de.md). Anleitungen liegen unter docs/de/ und docs/en/, jede Seite verlinkt oben auf die andere Sprache. Verweise in App-READMEs, Dockerfile, docker-compose.yml und Release-Texten angepasst. --- .github/workflows/android-app.yml | 2 +- .github/workflows/android-tv.yml | 2 +- Dockerfile | 2 +- README.de.md | 78 +++++++++++++++++ README.en.md | 78 +++++++++++++++++ README.md | 83 +++--------------- android-app/README.md | 2 +- android-tv/README.md | 2 +- docker-compose.yml | 2 +- docs/{ => de}/android-app.md | 2 + docs/{ => de}/android-tv.md | 2 + docs/{ => de}/login-einrichten.md | 2 + docs/{ => de}/self-hosting.md | 2 + docs/en/android-app.md | 52 +++++++++++ docs/en/android-tv.md | 82 +++++++++++++++++ docs/en/login-setup.md | 141 ++++++++++++++++++++++++++++++ docs/en/self-hosting.md | 83 ++++++++++++++++++ 17 files changed, 542 insertions(+), 75 deletions(-) create mode 100644 README.de.md create mode 100644 README.en.md rename docs/{ => de}/android-app.md (98%) rename docs/{ => de}/android-tv.md (99%) rename docs/{ => de}/login-einrichten.md (99%) rename docs/{ => de}/self-hosting.md (98%) create mode 100644 docs/en/android-app.md create mode 100644 docs/en/android-tv.md create mode 100644 docs/en/login-setup.md create mode 100644 docs/en/self-hosting.md diff --git a/.github/workflows/android-app.yml b/.github/workflows/android-app.yml index 6fc3060..e5971a3 100644 --- a/.github/workflows/android-app.yml +++ b/.github/workflows/android-app.yml @@ -82,7 +82,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | version="1.0.${GITHUB_RUN_NUMBER}" - notes="Handy-App für Cinemood, Version ${version}. Installation: docs/android-app.md. Installierte Apps finden diese Version von selbst (Update-Prüfung beim Start)." + notes="Handy-App für Cinemood, Version ${version}. Installation: docs/de/android-app.md (English: docs/en/android-app.md). Installierte Apps finden diese Version von selbst (Update-Prüfung beim Start)." printf '{"versionCode": %s, "versionName": "%s", "apk": "https://github.com/%s/releases/download/handy-app/cinemood-handy.apk"}\n' \ "$GITHUB_RUN_NUMBER" "$version" "$GITHUB_REPOSITORY" > version.json if gh release view handy-app >/dev/null 2>&1; then diff --git a/.github/workflows/android-tv.yml b/.github/workflows/android-tv.yml index 8544877..3445670 100644 --- a/.github/workflows/android-tv.yml +++ b/.github/workflows/android-tv.yml @@ -80,7 +80,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | version="1.0.${GITHUB_RUN_NUMBER}" - notes="Android-TV-App für Cinemood, Version ${version}. Installation: docs/android-tv.md. Installierte Apps finden diese Version von selbst (Update-Prüfung beim Start)." + notes="Android-TV-App für Cinemood, Version ${version}. Installation: docs/de/android-tv.md (English: docs/en/android-tv.md). Installierte Apps finden diese Version von selbst (Update-Prüfung beim Start)." printf '{"versionCode": %s, "versionName": "%s", "apk": "https://github.com/%s/releases/download/tv-app/cinemood-tv.apk"}\n' \ "$GITHUB_RUN_NUMBER" "$version" "$GITHUB_REPOSITORY" > version.json if gh release view tv-app >/dev/null 2>&1; then diff --git a/Dockerfile b/Dockerfile index b120cd3..e4519d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Cinemood zum Selbst-Hosten. Standard: SQLite in einer Datei unter /data, ohne Mail-Login. # Bauen: docker build -t cinemood . -# Starten: siehe docker-compose.yml oder docs/self-hosting.md +# Starten: siehe docker-compose.yml oder docs/de/self-hosting.md (English: docs/en/self-hosting.md) # Volles Image zum Installieren: better-sqlite3 wird dabei übersetzt (braucht python3, make, g++) FROM node:22-bookworm AS deps diff --git a/README.de.md b/README.de.md new file mode 100644 index 0000000..7eb1359 --- /dev/null +++ b/README.de.md @@ -0,0 +1,78 @@ +[English](README.en.md) · **Deutsch** + +# Cinemood + +Gemeinsam schnell einen Film finden: Der Host erstellt eine Runde und wählt die Streaming-Anbieter, +alle joinen per QR-Code, wählen Genres und swipen Filme. Am Ende gewinnt der Film, den alle +(oder die meisten) sehen wollen. Filme, die die Crew schon gesehen hat, landen im **Abspann** +und werden nicht mehr vorgeschlagen. + +Die Oberfläche gibt es auf Deutsch und Englisch (Sprachauswahl oben auf jeder Seite, Standard nach Browsersprache). + +## Sprachen + +- Texte: `src/lib/i18n/de.tsx` und `src/lib/i18n/en.tsx` (TypeScript prüft, dass keine Übersetzung fehlt). +- Fehlermeldungen der API kommen deutsch vom Server und werden im Browser übersetzt (`src/lib/i18n/errors.ts`). +- Die Adressen haben kein Sprachkürzel: `src/proxy.ts` schreibt intern auf `/de/...` bzw. `/en/...` um + (gespeicherte Wahl im Cookie `lang`, sonst Browsersprache, sonst Englisch). +- Filmtitel und Beschreibungen werden beim Start einer Runde auf Deutsch und Englisch gespeichert, + Genres und Tags beim Ausliefern übersetzt. + +## Technik + +- Next.js 16 (App Router) + Tailwind CSS 4 +- Datenbank wählbar: Supabase (Standard, mit Mail-Login), MariaDB/MySQL oder SQLite (Self-Hosting, ohne Login). + Alle Zugriffe laufen über [Kysely](https://kysely.dev), derselbe Code für alle Datenbanken (`src/lib/server/db.ts`). +- Live-Stand per regelmäßigem Nachfragen (kein Realtime nötig) +- TMDB für Filmdaten, Poster und Streaming-Anbieter + +## Datenbank wählen + +| `DATABASE` | Wofür | Login (Google / Mail) | Tabellen anlegen | +| --- | --- | --- | --- | +| `supabase` (Standard) | Vercel | ja | SQL aus `supabase/` im Supabase SQL Editor | +| `mariadb` / `mysql` | eigener Server | nein | macht die App selbst | +| `sqlite` | kleiner Self-Host (eine Datei) | nein | macht die App selbst | +| `postgres` | eigener Postgres-Server | nein | `supabase/setup-alles.sql` einmal ausführen | + +Verbindung über `DATABASE_URL` (bei SQLite stattdessen `SQLITE_FILE`). Selbst hosten mit Docker: +siehe [docs/de/self-hosting.md](docs/de/self-hosting.md). + +## Apps + +- Handy (Android): [docs/de/android-app.md](docs/de/android-app.md), Download unter `/handy-app` +- Fernseher (Android TV / Fire TV): [docs/de/android-tv.md](docs/de/android-tv.md), Download unter `/tv-app` +- Login mit Google oder Mail einrichten: [docs/de/login-einrichten.md](docs/de/login-einrichten.md) + +## Sicherheitsmodell (Kurzfassung) + +- Browser sprechen nie direkt mit der Datenbank. Alles läuft über die Next.js-API, die + Zugangsdaten zur Datenbank liegen nur auf dem Server. +- RLS ist auf allen Tabellen aktiv, ohne Policies für Client-Rollen. +- Teilnehmer, Hosts und Crews werden über zufällige 256-Bit-Tokens in httpOnly-Cookies + erkannt. In der DB liegt nur der HMAC. +- Raum-Codes sind 10 Zeichen aus 31 Zeichen (~49 Bit) und werden mit Rate Limiting geschützt. +- Externe TMDB-Daten werden mit zod validiert, bevor sie gespeichert oder angezeigt werden. + +## Lokal starten + +```bash +npm install +cp .env.example .env.local # Werte eintragen +npm run dev +``` + +Datenbank: Am einfachsten lokal `DATABASE=sqlite` in `.env.local`, dann legt die App alles selbst an. +Mit Supabase: Migrationen in `supabase/migrations/` im Supabase-Dashboard (SQL Editor) ausführen +oder mit `npx supabase db push`. + +## Checks + +```bash +npm test # Unit-Tests +npm run typecheck +npm run lint +npm run e2e # Ende-zu-Ende: Host + 2 Gäste spielen eine Runde (braucht laufenden Dev-Server) +``` + +Für lokale Tests ohne TMDB-Zugang `TMDB_MOCK=1` in `.env.local` setzen (wirkt nie in Produktion). diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..df6286b --- /dev/null +++ b/README.en.md @@ -0,0 +1,78 @@ +**English** · [Deutsch](README.de.md) + +# Cinemood + +Find a movie together, fast: the host creates a round and picks the streaming services, +everyone joins by QR code, chooses genres and swipes movies. The movie everyone (or most people) +wants to watch wins. Movies the crew has already seen go into the **credits** +and won't be suggested again. + +The interface is available in English and German (language switch at the top of every page, default based on browser language). + +## Languages + +- Texts: `src/lib/i18n/de.tsx` and `src/lib/i18n/en.tsx` (TypeScript checks that no translation is missing). +- API error messages come from the server in German and are translated in the browser (`src/lib/i18n/errors.ts`). +- URLs have no language prefix: `src/proxy.ts` rewrites internally to `/de/...` or `/en/...` + (saved choice in the `lang` cookie, otherwise browser language, otherwise English). +- Movie titles and descriptions are stored in German and English when a round starts; + genres and tags are translated when they are served. + +## Tech + +- Next.js 16 (App Router) + Tailwind CSS 4 +- Database of your choice: Supabase (default, with email sign-in), MariaDB/MySQL or SQLite (self-hosting, without sign-in). + All queries go through [Kysely](https://kysely.dev), the same code for every database (`src/lib/server/db.ts`). +- Live updates by regular polling (no realtime needed) +- TMDB for movie data, posters and streaming services + +## Choosing a database + +| `DATABASE` | For | Sign-in (Google / email) | Creating tables | +| --- | --- | --- | --- | +| `supabase` (default) | Vercel | yes | SQL from `supabase/` in the Supabase SQL Editor | +| `mariadb` / `mysql` | your own server | no | the app does it itself | +| `sqlite` | small self-host (one file) | no | the app does it itself | +| `postgres` | your own Postgres server | no | run `supabase/setup-alles.sql` once | + +Connection via `DATABASE_URL` (for SQLite use `SQLITE_FILE` instead). Self-hosting with Docker: +see [docs/en/self-hosting.md](docs/en/self-hosting.md). + +## Apps + +- Phone (Android): [docs/en/android-app.md](docs/en/android-app.md), download at `/handy-app` +- TV (Android TV / Fire TV): [docs/en/android-tv.md](docs/en/android-tv.md), download at `/tv-app` +- Setting up sign-in with Google or email: [docs/en/login-setup.md](docs/en/login-setup.md) + +## Security model (short version) + +- Browsers never talk to the database directly. Everything goes through the Next.js API; + database credentials live only on the server. +- RLS is enabled on all tables, with no policies for client roles. +- Participants, hosts and crews are identified by random 256-bit tokens in httpOnly cookies. + The database only stores their HMAC. +- Room codes are 10 characters from a 31-character alphabet (~49 bits) and are protected by rate limiting. +- External TMDB data is validated with zod before it is stored or displayed. + +## Running locally + +```bash +npm install +cp .env.example .env.local # fill in the values +npm run dev +``` + +Database: the easiest option locally is `DATABASE=sqlite` in `.env.local`; the app then creates everything itself. +With Supabase: run the migrations in `supabase/migrations/` in the Supabase dashboard (SQL Editor) +or with `npx supabase db push`. + +## Checks + +```bash +npm test # unit tests +npm run typecheck +npm run lint +npm run e2e # end-to-end: host + 2 guests play a round (needs a running dev server) +``` + +For local tests without TMDB access, set `TMDB_MOCK=1` in `.env.local` (never takes effect in production). diff --git a/README.md b/README.md index 3c5f80c..57dc1f3 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,21 @@ # Cinemood -Gemeinsam schnell einen Film finden: Der Host erstellt eine Runde und wählt die Streaming-Anbieter, -alle joinen per QR-Code, wählen Genres und swipen Filme. Am Ende gewinnt der Film, den alle -(oder die meisten) sehen wollen. Filme, die die Crew schon gesehen hat, landen im **Abspann** -und werden nicht mehr vorgeschlagen. +Find a movie together, fast. Everyone joins by QR code, picks genres and swipes movies. +The movie most people want to watch wins. -Die Oberfläche gibt es auf Deutsch und Englisch (Sprachauswahl oben auf jeder Seite, Standard nach Browsersprache). +Gemeinsam schnell einen Film finden. Alle joinen per QR-Code, wählen Genres und swipen Filme. +Der Film, den die meisten sehen wollen, gewinnt. -## Sprachen +**Choose your language / Sprache wählen:** -- Texte: `src/lib/i18n/de.tsx` und `src/lib/i18n/en.tsx` (TypeScript prüft, dass keine Übersetzung fehlt). -- Fehlermeldungen der API kommen deutsch vom Server und werden im Browser übersetzt (`src/lib/i18n/errors.ts`). -- Die Adressen haben kein Sprachkürzel: `src/proxy.ts` schreibt intern auf `/de/...` bzw. `/en/...` um - (gespeicherte Wahl im Cookie `lang`, sonst Browsersprache, sonst Englisch). -- Filmtitel und Beschreibungen werden beim Start einer Runde auf Deutsch und Englisch gespeichert, - Genres und Tags beim Ausliefern übersetzt. +- 🇬🇧 [English](README.en.md) +- 🇩🇪 [Deutsch](README.de.md) -## Technik +## Docs / Anleitungen -- Next.js 16 (App Router) + Tailwind CSS 4 -- Datenbank wählbar: Supabase (Standard, mit Mail-Login), MariaDB/MySQL oder SQLite (Self-Hosting, ohne Login). - Alle Zugriffe laufen über [Kysely](https://kysely.dev), derselbe Code für alle Datenbanken (`src/lib/server/db.ts`). -- Live-Stand per regelmäßigem Nachfragen (kein Realtime nötig) -- TMDB für Filmdaten, Poster und Streaming-Anbieter - -## Datenbank wählen - -| `DATABASE` | Wofür | Login (Google / Mail) | Tabellen anlegen | -| --- | --- | --- | --- | -| `supabase` (Standard) | Vercel | ja | SQL aus `supabase/` im Supabase SQL Editor | -| `mariadb` / `mysql` | eigener Server | nein | macht die App selbst | -| `sqlite` | kleiner Self-Host (eine Datei) | nein | macht die App selbst | -| `postgres` | eigener Postgres-Server | nein | `supabase/setup-alles.sql` einmal ausführen | - -Verbindung über `DATABASE_URL` (bei SQLite stattdessen `SQLITE_FILE`). Selbst hosten mit Docker: -siehe [docs/self-hosting.md](docs/self-hosting.md). - -## Apps - -- Handy (Android): [docs/android-app.md](docs/android-app.md), Download unter `/handy-app` -- Fernseher (Android TV / Fire TV): [docs/android-tv.md](docs/android-tv.md), Download unter `/tv-app` -- Login mit Google oder Mail einrichten: [docs/login-einrichten.md](docs/login-einrichten.md) - -## Sicherheitsmodell (Kurzfassung) - -- Browser sprechen nie direkt mit der Datenbank. Alles läuft über die Next.js-API, die - Zugangsdaten zur Datenbank liegen nur auf dem Server. -- RLS ist auf allen Tabellen aktiv, ohne Policies für Client-Rollen. -- Teilnehmer, Hosts und Crews werden über zufällige 256-Bit-Tokens in httpOnly-Cookies - erkannt. In der DB liegt nur der HMAC. -- Raum-Codes sind 10 Zeichen aus 31 Zeichen (~49 Bit) und werden mit Rate Limiting geschützt. -- Externe TMDB-Daten werden mit zod validiert, bevor sie gespeichert oder angezeigt werden. - -## Lokal starten - -```bash -npm install -cp .env.example .env.local # Werte eintragen -npm run dev -``` - -Datenbank: Am einfachsten lokal `DATABASE=sqlite` in `.env.local`, dann legt die App alles selbst an. -Mit Supabase: Migrationen in `supabase/migrations/` im Supabase-Dashboard (SQL Editor) ausführen -oder mit `npx supabase db push`. - -## Checks - -```bash -npm test # Unit-Tests -npm run typecheck -npm run lint -npm run e2e # Ende-zu-Ende: Host + 2 Gäste spielen eine Runde (braucht laufenden Dev-Server) -``` - -Für lokale Tests ohne TMDB-Zugang `TMDB_MOCK=1` in `.env.local` setzen (wirkt nie in Produktion). +| | English | Deutsch | +| --- | --- | --- | +| Self-hosting | [docs/en/self-hosting.md](docs/en/self-hosting.md) | [docs/de/self-hosting.md](docs/de/self-hosting.md) | +| Android phone app / Handy-App | [docs/en/android-app.md](docs/en/android-app.md) | [docs/de/android-app.md](docs/de/android-app.md) | +| Android TV app / Fernseher-App | [docs/en/android-tv.md](docs/en/android-tv.md) | [docs/de/android-tv.md](docs/de/android-tv.md) | +| Sign-in setup / Login einrichten | [docs/en/login-setup.md](docs/en/login-setup.md) | [docs/de/login-einrichten.md](docs/de/login-einrichten.md) | diff --git a/android-app/README.md b/android-app/README.md index a097725..4f915ae 100644 --- a/android-app/README.md +++ b/android-app/README.md @@ -1,7 +1,7 @@ # Cinemood Handy-App (Android) Android-App für Handy und Tablet: Runden erstellen, per QR-Code beitreten und abstimmen, mit Anmeldung über Google. -Die App zeigt die Web-App von Cinemood in einer WebView. Installation und Einrichtung: [docs/android-app.md](../docs/android-app.md). +Die App zeigt die Web-App von Cinemood in einer WebView. Installation und Einrichtung: [Deutsch](../docs/de/android-app.md) · [English](../docs/en/android-app.md). - Code: `app/src/main/java/app/cinemood/handy/` - `MainActivity`: WebView, Google-Anmeldung im Custom Tab, Rücksprung über `cinemood://anmelden`, QR-Links (`/r/…`) diff --git a/android-tv/README.md b/android-tv/README.md index f9e980b..3356303 100644 --- a/android-tv/README.md +++ b/android-tv/README.md @@ -1,7 +1,7 @@ # Cinemood TV (Android TV / Google TV) Kleine Android-App, die die Fernseher-Seite `/tv` von Cinemood im Vollbild in einer WebView öffnet. -Installation und Bedienung: [docs/android-tv.md](../docs/android-tv.md). +Installation und Bedienung: [Deutsch](../docs/de/android-tv.md) · [English](../docs/en/android-tv.md). - Code: `app/src/main/java/app/cinemood/tv/` (eine Activity für die Seite, eine für die Server-Adresse) - Bauen: `./gradlew assembleRelease` (braucht JDK 17 und das Android SDK), Ergebnis unter diff --git a/docker-compose.yml b/docker-compose.yml index c861ac6..1b83776 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ # Cinemood selbst hosten: `docker compose up -d`, danach http://:3000 öffnen. # Vorher eine Datei .env anlegen (siehe .env.example): TMDB_READ_TOKEN und APP_SECRET reichen. -# Anleitung: docs/self-hosting.md +# Anleitung / Guide: docs/de/self-hosting.md · docs/en/self-hosting.md services: cinemood: diff --git a/docs/android-app.md b/docs/de/android-app.md similarity index 98% rename from docs/android-app.md rename to docs/de/android-app.md index ea4c936..2100d25 100644 --- a/docs/android-app.md +++ b/docs/de/android-app.md @@ -1,3 +1,5 @@ +[English](../en/android-app.md) · **Deutsch** + # Cinemood als App fürs Handy (Android, z. B. Samsung Galaxy) Die App **Cinemood** fürs Handy und Tablet kann alles, was die Webseite kann: Runde erstellen, Freunde per diff --git a/docs/android-tv.md b/docs/de/android-tv.md similarity index 99% rename from docs/android-tv.md rename to docs/de/android-tv.md index fea2cd7..5e9bd9b 100644 --- a/docs/android-tv.md +++ b/docs/de/android-tv.md @@ -1,3 +1,5 @@ +[English](../en/android-tv.md) · **Deutsch** + # Cinemood auf dem Android-Fernseher Die App **Cinemood TV** öffnet die Fernseher-Seite (`/tv`) im Vollbild. Am Fernseher musst du nichts diff --git a/docs/login-einrichten.md b/docs/de/login-einrichten.md similarity index 99% rename from docs/login-einrichten.md rename to docs/de/login-einrichten.md index c803993..1dd7f78 100644 --- a/docs/login-einrichten.md +++ b/docs/de/login-einrichten.md @@ -1,3 +1,5 @@ +[English](../en/login-setup.md) · **Deutsch** + # Login einrichten: Google und Magic-Link (Supabase) Das Konto ist freiwillig und nur für Hosts gedacht. Gäste treten weiterhin nur mit ihrem Namen bei. diff --git a/docs/self-hosting.md b/docs/de/self-hosting.md similarity index 98% rename from docs/self-hosting.md rename to docs/de/self-hosting.md index 638d4ce..96fc93a 100644 --- a/docs/self-hosting.md +++ b/docs/de/self-hosting.md @@ -1,3 +1,5 @@ +[English](../en/self-hosting.md) · **Deutsch** + # Cinemood selbst hosten Cinemood läuft auch ohne Supabase und Vercel auf einem eigenen Rechner (Raspberry Pi, NAS, Server). diff --git a/docs/en/android-app.md b/docs/en/android-app.md new file mode 100644 index 0000000..4918aeb --- /dev/null +++ b/docs/en/android-app.md @@ -0,0 +1,52 @@ +**English** · [Deutsch](../de/android-app.md) + +# Cinemood as a phone app (Android, e.g. Samsung Galaxy) + +The **Cinemood** app for phones and tablets can do everything the website can: create a round, invite friends +by QR code, pick genres and vote. On top of that there is **sign-in with Google**: tap once, +choose your Google account, done. Your crews, the credits and your favorite services are tied to this account +and are there on every device where you sign in with the same Google account. + +Guests need neither the app nor an account. They scan the QR code and join in the browser. + +## Download and install + +1. On your phone, open `cinemood.yugusaa.de/handy-app` in the browser. This downloads the current APK + (`https://github.com/pinguDevelopment/cinemood/releases/download/handy-app/cinemood-handy.apk`). +2. Tap the downloaded file. The first time, Android asks whether the browser (Samsung Internet + or Chrome) may install apps: **Settings → Allow**, then go back and tap **Install**. +3. Google Play Protect may warn about an "unknown app" because it doesn't come from the Play Store: + **More details → Install anyway**. +4. Open Cinemood. Under **Account**, tap **Sign in with Google**. + +The app checks for new versions on its own at startup and asks whether to install the update. +For that, allow Cinemood to install apps once (the app takes you there). + +## Opening QR codes directly in the app + +If someone with the app installed scans an invite QR code, Android opens the round directly in the app. +If that doesn't work and the browser opens instead: turn on **Settings → Apps → Cinemood → Set as default → +Open supported links**. + +## Settings + +**Press and hold** the Cinemood icon on the home screen **→ Settings**: a different server address (your own server), +reload page, check for updates. + +## How Google sign-in works in the app + +Google doesn't allow signing in inside an in-app view (WebView). So the app briefly opens the sign-in +in the browser (it looks like a window of the app), and then jumps back into the app automatically. +Only a short-lived, signed ticket travels back, and it is valid only together with a secret that +only the app knows. This way the actual sign-in ends up in the app and not in the browser. + +Requirement: Google is set up in Supabase, see [login-setup.md](login-setup.md#setting-up-google-sign-in). +Without that setup, the app (and the website) simply shows no Google button. + +## Your own server or your own signing key + +- Different start address at build time: on GitHub under **Actions → Handy-App → Run workflow**, enter an address. +- The app is signed with the same sideload key as the TV app. If you use your own key via the GitHub secret + `CINEMOOD_KEYSTORE_B64`, enter its SHA-256 fingerprint in Vercel as + `ANDROID_CERT_SHA256`, otherwise QR codes open in the browser instead of the app + (`keytool -list -v -keystore your-own.jks` shows the fingerprint). diff --git a/docs/en/android-tv.md b/docs/en/android-tv.md new file mode 100644 index 0000000..fa49746 --- /dev/null +++ b/docs/en/android-tv.md @@ -0,0 +1,82 @@ +**English** · [Deutsch](../de/android-tv.md) + +# Cinemood on an Android TV + +The **Cinemood TV** app opens the TV page (`/tv`) in full screen. You don't have to operate anything on +the TV: it shows a 6-digit code, which you as the host enter in the lobby on your phone. After that the +TV shows the QR code for joining, the progress and, at the end, the winning movie. + +The app runs on **Android TV and Google TV** (e.g. Chromecast with Google TV, Nvidia Shield, +Fire TV Stick, Sony, Philips, TCL). Samsung TVs (Tizen) and LG (webOS) are not Android; there you +simply open `/tv` in the TV's browser. + +## Download + +- Direct link to the current APK: + `https://github.com/pinguDevelopment/cinemood/releases/download/tv-app/cinemood-tv.apk` +- Short (redirects to the same link): `cinemood.yugusaa.de/tv-app` + +The APK is rebuilt automatically whenever the app changes (GitHub Actions, workflow +"Android-TV-App"). + +## Installing with the Downloader app (easiest) + +1. On the TV, install the **Downloader** app (by AFTVnews) from the Play Store. +2. Open the TV's settings: **Apps → Security & restrictions → Unknown sources** + and allow **Downloader** there. (On Google TV: **Settings → System → About**, click + **Android TV OS build** seven times to unlock the developer options; then allow Downloader under + **Apps → Security & restrictions → Install unknown apps**. + On Fire TV: **My Fire TV → Developer Options → Install unknown apps**.) +3. Open Downloader, enter `cinemood.yugusaa.de/tv-app` as the address, then **Go**. +4. After the download, press **Install**. You can let it delete the APK afterwards. +5. Cinemood now appears among the apps on the home screen. + +## Installing via adb (from a computer) + +1. Unlock the developer options on the TV (see above) and turn on **USB debugging** or + **Network debugging** there. The IP address is under **Network & Internet**. +2. On the computer (with the Android Platform Tools): + ```bash + adb connect 192.168.1.50 # IP of the TV + adb install -r cinemood-tv.apk + ``` +3. The first time you connect, the TV asks whether to allow the computer: **Yes**. + +## Using the app + +- Start the app: the pairing code appears right away. The screen stays on while the app is running. +- **Menu button** or **hold OK for about a second**: opens the settings. There you can change the + server address, **reload the page** (e.g. if it hangs) and **check for updates**. +- **Press Back twice**: exits the app. +- If the server can't be reached, the app shows a notice and tries again every 10 seconds. + +## Your own domain or your own server + +By default the app opens `https://cinemood.yugusaa.de/tv`. If you run Cinemood yourself, enter +your own address: + +- **In the app:** Menu button (or hold OK), type the address, e.g. `movies.example.com` or + `http://192.168.1.20:3000` for a server on your home network, then **Save**. The app adds `https://` + and `/tv` itself. **Default** resets the address. +- **Built in:** on GitHub under **Actions → Android-TV-App → Run workflow**, enter your own address in the + "Server-Adresse" field. The finished APK is then in that run under **Artifacts**. + (This run doesn't replace the public APK.) + +## Updates + +At every start the app checks GitHub for a new version (release `tv-app`, file +`version.json`). If there is one, it asks: **Install** downloads the new version, after which Android +itself asks once more "Do you want to update this app?". Your settings are kept. You can also do this +manually from the menu with **Check for updates**. + +For the first update you have to allow the app to install apps once. The app opens the right +setting if it can. On Fire TV: turn on **My Fire TV → Developer Options → Install unknown apps → +Cinemood**. + +If you still have an older app without the "Check for updates" button, update once by hand: install the +new APK exactly like the first time; the old version is replaced and your settings are kept. +All versions are signed with the same key +(`android-tv/signing/sideload.jks`). If you want your own secret key, create the secrets +`CINEMOOD_KEYSTORE_B64` (the .jks file as Base64), `CINEMOOD_KEYSTORE_PASSWORD`, `CINEMOOD_KEY_ALIAS` +and `CINEMOOD_KEY_PASSWORD` on GitHub under **Settings → Secrets and variables → Actions**. Note: +after changing the key, the old app has to be uninstalled once. diff --git a/docs/en/login-setup.md b/docs/en/login-setup.md new file mode 100644 index 0000000..5157a46 --- /dev/null +++ b/docs/en/login-setup.md @@ -0,0 +1,141 @@ +**English** · [Deutsch](../de/login-einrichten.md) + +# Setting up sign-in: Google and magic link (Supabase) + +The account is optional and meant only for hosts. Guests still join with just their name. +With an account, crews, the credits and favorite services are there on every device. + +No new environment variables are needed. The server uses the existing `SUPABASE_URL` and the service role key. + +There are two ways to sign in; both lead to the same account if the email address is the same: + +- **With Google** (recommended): no email sending needed, also works in the phone app. Setup: [below](#setting-up-google-sign-in). +- **By email** (link or code): for more than a few test emails you need your own SMTP service (step 5). + +## 1. Update the database (before merging!) + +In the Supabase dashboard under **SQL Editor**, paste the full contents of `supabase/update-auf-aktuell.sql` and click **Run**. +The check at the very bottom must return an empty result. + +## 2. Turn on email sign-in + +**Authentication → Sign In / Providers → Email** + +- *Enable Email provider*: on +- *Confirm email*: on (default) +- Under **Authentication → Sign In / Providers**, *Allow new users to sign up* must be on, otherwise nobody can sign in for the first time. + +## 3. Allow addresses + +**Authentication → URL Configuration** + +- **Site URL**: your production address, e.g. `https://cinemood.vercel.app` +- **Redirect URLs** (add each line separately with *Add URL*): + - `http://localhost:3000/**` (locally with `npm run dev`) + - `https://*.*.devtunnels.ms/**` (VS Code port forwarding, addresses like `abc123-3000.euw.devtunnels.ms`) + - `https://cinemood-*-steallights-projects.vercel.app/**` (Vercel previews per PR) + - `https://cinemood.vercel.app/**` or your own domain + +The Vercel addresses depend on the name of the Vercel project. If the project still has a different name (e.g. `choosify` or `filmabend`), +they are `choosify.vercel.app` or `choosify-*-steallights-projects.vercel.app` accordingly. After a rename or a +new domain, add the new addresses here (the old ones can stay until nobody uses them anymore). + +The link in the email always leads back to the address where the sign-in was requested. +If that address is not in the list, Supabase sends the link to the Site URL. The app catches this on the home page, +but then you end up on production instead of locally. + +## 4. Adjust the email templates + +**Authentication → Emails → Templates**. Both templates, **Magic Link** and **Confirm signup**, get the same content +(new addresses get "Confirm signup" the first time, "Magic Link" after that). + +Supabase only has one template for everyone, so the email is bilingual (German and English). + +Subject: `Dein Login für Cinemood · Your Cinemood sign-in` + +```html +

Bei Cinemood anmelden

+

Jetzt anmelden

+

Oder gib diesen Code in der App ein: {{ .Token }}

+

Der Code ist praktisch, wenn die Mail auf einem anderen Gerät ankommt als dem, auf dem du dich anmelden willst.

+

Du hast das nicht angefordert? Dann ignoriere diese Mail einfach.

+
+

Sign in to Cinemood

+

Sign in now

+

Or enter this code in the app: {{ .Token }}

+

The code is handy if this email arrives on a different device than the one you want to sign in on.

+

Didn’t request this? Just ignore this email.

+``` + +Important: `{{ .RedirectTo }}` and `{{ .TokenHash }}` must appear exactly like this. The default template with `{{ .ConfirmationURL }}` +doesn't work, because the app only signs in through its own server. + +## 5. Sending email (SMTP) + +Supabase's built-in email sending is only for trying things out: it only sends to addresses in your Supabase team +and only very few emails per hour. For friends you need your own SMTP service, e.g. Resend, Brevo or Postmark +(all with a free tier). + +**Authentication → Emails → SMTP Settings**: turn on *Enable custom SMTP*, then enter host, port, user, password and sender +from the email service. Then under **Authentication → Rate Limits**, set the limit for emails per hour to e.g. 30. + +The SMTP password belongs only in the Supabase dashboard, not in the repo and not in a chat. + +## 6. Try it out + +1. Open `/konto`, enter your email, "Send sign-in link". +2. In the email, tap the link and press "Sign in now", or enter the code in the app. +3. If the device already has a crew, the app asks whether to move it to the account. +4. Sign in on a second device: crew, credits and favorite services are there. + +Locally without real emails: `AUTH_MOCK=1` in `.env.local`. The code is then always `123456` and the link appears in the server log. + +## Setting up Google sign-in + +Takes about 10 minutes. You need a Google account and access to the Supabase dashboard. +The client ID and client secret belong only in the Supabase dashboard, not in the repo and not in a chat. + +### A. Look up the callback address in Supabase + +Open **Authentication → Sign In / Providers → Google** (don't turn it on yet). Under +**Callback URL (for OAuth)** there is an address like `https://.supabase.co/auth/v1/callback`. Copy it. + +### B. Google Cloud Console + +1. Open [console.cloud.google.com](https://console.cloud.google.com) and create a new project at the top, + e.g. "Cinemood". +2. On the left, **APIs & Services → OAuth consent screen** (sometimes also called **Google Auth Platform**) → + **Get started**: + - App name: `Cinemood`, support email: your address + - Audience: **External** + - Contact information: your address, accept the policy, **Create** +3. Under **Audience**, press **Publish app** (status "In production"). Otherwise only explicitly added + test users can sign in. A review by Google is not needed, because Cinemood only asks for + name and email address. +4. **Clients → Create client**: + - Application type: **Web application**, name: `Cinemood` + - **Authorized JavaScript origins**: `https://cinemood.yugusaa.de` + - **Authorized redirect URIs**: the callback address from step A + - **Create**. Google now shows the **Client ID** and **Client secret**. + +The phone app doesn't need anything extra in Google: it signs in through the browser, just like the website. + +### C. Supabase + +1. **Authentication → Sign In / Providers → Google**: turn it on, paste the **Client ID** and **Client Secret** from B.4, + **Save**. +2. **Authentication → URL Configuration → Redirect URLs**: there must be a line for your domain, e.g. + `https://cinemood.yugusaa.de/**` (see step 3 above). After Google, the app redirects back to + `/api/auth/google/zurueck`, which `/**` covers. + +### D. Try it out + +After 5 minutes at most, `/konto` shows the **Sign in with Google** button (the server asks Supabase +whether Google is turned on and remembers the answer for a short while). Tap it, choose a Google account, done. + +If you previously signed in by email and use the same address with Google, you end up in the same +account with the same crews. The TV app has no Google button, because Google doesn't allow signing in +there (and you don't need an account on the TV anyway). + +Locally without Google: with `AUTH_MOCK=1`, `/api/auth/google?mock=you@example.org` jumps straight back and signs in +with that address (for tests only, never takes effect in production). diff --git a/docs/en/self-hosting.md b/docs/en/self-hosting.md new file mode 100644 index 0000000..13a225e --- /dev/null +++ b/docs/en/self-hosting.md @@ -0,0 +1,83 @@ +**English** · [Deutsch](../de/self-hosting.md) + +# Self-hosting Cinemood + +Cinemood also runs without Supabase and Vercel on your own machine (Raspberry Pi, NAS, server). +The data is then stored in an **SQLite file** or in **MariaDB/MySQL**. There is no email sign-in +when self-hosting: everyone simply joins by QR code, and the crew and the credits are tied to the +host's browser. + +## Quick start with Docker (SQLite) + +1. Download the repository and create a file called `.env`: + + ```env + TMDB_READ_TOKEN=your-tmdb-token + APP_SECRET=a-long-random-value-at-least-32-characters + ``` + + Generate `APP_SECRET` e.g. with `openssl rand -base64 32`. You can get the TMDB token at + https://www.themoviedb.org/settings/api. + +2. Start it: + + ```bash + docker compose up -d + ``` + +3. Open `http://:3000` in your browser. Phones on the same Wi-Fi can then scan + the QR code directly. + +The database lives in the Docker volume `cinemood-data` (file `/data/cinemood.db`). The app creates the +tables on first start; nobody needs to run any SQL. + +## MariaDB instead of SQLite + +In `docker-compose.yml`, uncomment the `mariadb` block and set this on the `cinemood` service: + +```yaml + environment: + DATABASE: mariadb + DATABASE_URL: mysql://cinemood:secret@mariadb:3306/cinemood +``` + +An existing MariaDB or MySQL server works the same way; just point `DATABASE_URL` at that server. +The database (here `cinemood`) must exist; the app creates the tables. +Tested with MariaDB 10.11. + +## Without Docker + +```bash +npm ci +DATABASE=sqlite ALLOW_HTTP=1 npm run build +DATABASE=sqlite ALLOW_HTTP=1 npm start +``` + +The values from `.env` (or `.env.local`) apply here too. Set `DATABASE` and `ALLOW_HTTP` already when +building, because the pages are prepared during the build. + +## HTTPS or not? + +- **Home network only** (`http://192.168...`): `ALLOW_HTTP=1` (already set in the Docker image). Otherwise + browsers would discard the round's sign-in cookies. +- **Reachable from the internet**: always put it behind a reverse proxy with HTTPS (e.g. Caddy, Traefik, + Nginx Proxy Manager) and set `ALLOW_HTTP=0`. + +## All settings + +| Variable | Meaning | +| --- | --- | +| `DATABASE` | `sqlite`, `mariadb`, `mysql`, `postgres` or `supabase` | +| `DATABASE_URL` | connection, e.g. `mysql://user:pass@host:3306/cinemood` (not for SQLite) | +| `SQLITE_FILE` | location of the SQLite file (Docker: `/data/cinemood.db`) | +| `TMDB_READ_TOKEN` | TMDB access for movies, posters and streaming services | +| `APP_SECRET` | secret random value, never change it (otherwise all crews/links become invalid) | +| `ALLOW_HTTP` | `1` = running without HTTPS is allowed | +| `ALLOWED_ORIGINS` | additional allowed addresses, if the app is reachable under several names | + +With MariaDB and SQLite the app cleans up expired rounds itself (at most once per hour). + +## Backups + +SQLite: the file `cinemood.db` (while the app is running, preferably with `sqlite3 cinemood.db ".backup copy.db"`). +MariaDB: as usual with `mariadb-dump`.