Files
dsantillan 22654c61fc
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Podcasts: en español solamente, y se acuerdan de dónde ibas
Música tiene una sección **Podcasts**: programas por categoría —Salud y fitness,
Deporte, Comedia, Noticias, Historia, Crímenes reales, Ciencia, Tecnología,
Sociedad y cultura, Negocios, Ficción, Educación, Música, Ocio— que suenan mientras
entrenás y siguen donde los dejaste. Sin dependencias nuevas y sin clave de API: el
directorio de Apple es público.

**En español se comprueba, no se supone.** La tienda dice dónde se *vende* un
podcast, no en qué idioma está —en el ranking español de comedia hay uno en catalán
y en el argentino uno en inglés—, así que se lee el `<language>` del feed de cada
programa (los primeros 64 KB, con una petición `Range`: el idioma está en las
primeras líneas) y se descarta lo que no sea español. Un feed sin etiqueta se queda:
feeds genuinamente españoles la omiten, y tirarlos por una omisión sería sacar
podcasts buenos de la lista. La respuesta cuenta cuántos quedaron afuera y por qué
(`skipped`), así que una lista corta nunca es un misterio, y abrir un programa en
otro idioma se contesta con `spanish:false` en vez de con una lista vacía.

Es la otra mitad de la radio y es lo contrario en todo lo que le importa al
reproductor: un podcast es un **archivo** —tiene principio, final y un minuto en el
que ibas—. Por eso hay un módulo de reglas puras (`lib/podcast-view.js`: dónde
retomar, qué cuenta como escuchado, cuál sigue, cuántas posiciones se guardan) y
por eso `lib/radio-player.js` pasa a ser `lib/player.js`: **un solo elemento de
audio** para las dos cosas, que es lo que impide que una emisora y un episodio suenen
a la vez. La barra crece línea de progreso, −15 s, +30 s, siguiente episodio y reloj;
la posición se guarda por perfil (con tope de 200, lo más nuevo primero) en pausa, al
parar, al terminar y cuando la app se va al fondo, porque con la pantalla bloqueada
iOS suspende los temporizadores y un guardado sólo desde el tick perdería lo
escuchado con el teléfono guardado. Media Session muestra episodio, programa y
progreso en la pantalla bloqueada.

Nada se descarga y nada pasa por el servidor: el episodio llega como la URL del
`enclosure` y el audio va de quien lo publica al teléfono. Acá no hay lista blanca
posible —un feed vive en cualquier host—, así que la puerta es **https, host real y
nunca una dirección privada**, comprobada en la URL y en dónde terminó el pedido, con
el cuerpo leído a tope y la conexión cortada al llegar: este contenedor vive adentro
de una casa.

Verificado con datos reales: 20 programas en español por categoría (idiomas es, es-ES,
es-mx), un feed de 40 episodios parseado, un feed en inglés contestado como
`spanish:false` y la dirección de metadatos rechazada con 400 sin hacer el pedido.

Fuera de los podcasts: la página de la API ocultaba `health` y `music` enteras —el
generador sólo dibuja las secciones de su tabla de etiquetas—, así que ahora están,
con radio y podcasts incluidas.
2026-09-23 21:11:20 -04:00

11 KiB
Raw Permalink Blame History

Building the mobile app (iOS / Android)

KuentaGYM ships in two flavors from the same codebase:

Self-hosted (this repo's default) Mobile app (VITE_MOBILE=1)
Runs in any browser, against your own server natively on iPhone / Android (Capacitor shell)
Accounts passkey sign-in, one profile per person none — the phone is the account
Data synced to your server, readable on desktop stays on the device (file in the app's private storage)
Reminders Web Push from your server native local notifications, no server involved
Exercise media served by your server (img/, gif/) loaded from the jsDelivr CDN

The mobile flavor never talks to a backend by default: no sign-in screen, no sync, no telemetry. State is mirrored from localStorage into kuentagym-state.json in the app's private data directory on every change (iOS is allowed to evict WebView storage under pressure — the file mirror is the durable copy and is restored on launch). Backups go out through the OS share sheet instead of a browser download.

Connecting the app to your own server

On first launch the app asks how you want to use it. Alongside the fully local mode above, you can instead connect it to a self-hosted KuentaGYM server — your data then lives there, synced the same way the browser PWA does, instead of only on the phone. This is a mode of the same app, not a different build or download.

Passkeys can't be used for this: the app's WebView runs at its own origin, which never matches the real hostname WebAuthn needs. Instead you pair the device from a browser that's already signed in: Settings → "Pair the mobile app" shows a one-time code (valid 5 minutes); enter your server's address and that code in the app (same first-launch screen, or Settings → "Connect to my server" later) to finish. Notes:

  • Requires network access every time the app is used — there's no offline file mirror once connected, same as the browser PWA.
  • Use an HTTPS address if at all possible: the connection carries a bearer token instead of a cookie, and that token would otherwise cross the network in plain text.
  • "Sign out everywhere" (Settings → Account, in the browser) revokes a paired app's access too — it's the same signed session token either way, just delivered over a header instead of a cookie. See /api/pair/create and /api/pair/redeem in api/server.js for the exchange itself.
  • Settings → "Disconnect" syncs one last time, then drops the device cleanly back to local mode.

Prerequisites

  • Node 20+
  • Android: Android Studio (bundles the SDK). Java 21 for Gradle.
  • iOS: a Mac with Xcode 15+ and CocoaPods (brew install cocoapods). A free Apple ID is enough to run the app on your own iPhone (see below); paid membership is only needed for App Store distribution, which KuentaGYM doesn't do.

Build & run

cd frontend
npm install
npm run build:mobile        # VITE_MOBILE build + `cap sync` into android/ and ios/

npx cap open android        # opens Android Studio → run on emulator or device
npx cap open ios            # opens Xcode (Mac only) → set your signing team, then run

npm run build:mobile bakes the CDN media base into the bundle and copies the web build into both native projects — re-run it after every web-code change before building natively.

Heads-up: after build:mobile, frontend/dist contains the mobile bundle. Run a plain npm run build again before deploying dist to a server.

App icons & splash screens

frontend/resources/icon.png (1024×1024) is the source: the app's brand image from assets/logoym.png, centred on the emblem's own dark green so the square is fully opaque — a maskable icon may not be transparent. It is generated, not hand-drawn, so replacing the brand image means regenerating every icon the app ships, in one step:

cd frontend
node scripts/build-app-icons.mjs

That writes resources/icon.png plus the three the web app serves: public/icon-512.png (declared any maskable in the manifest, hence the opaque background), public/icon-180.png (iOS home screen and favicon) and public/logo.png (transparent, for the tab bar's Start button, the login screen and the boot placeholder). Change ICON_BG in that script to re-skin all of them at once.

The launch screen comes from the same place: assets/splash.jpg (the photograph, deliberately not committed — 12 MB off a camera) is what scripts/build-app-icons.mjs turns into public/splash.webp for the web boot screen and resources/splash.jpg (2732×2732, on the aura's base colour, fitted rather than cropped) for @capacitor/assets. Drop a replacement at that path and the script regenerates both; without it, it says so and skips them.

iOS launch screens are the same source: 14 apple-touch-startup-image entries in frontend/index.html, one per device pixel size, cropped cover from the photograph by the same script. They matter because an installed iOS web app paints its own screen before any of our code runs — without a matching entry that screen is blank, which is the white flash on open that no CSS can reach. The script fails if the sizes it generates and the sizes index.html links ever drift: iOS answers a missing launch image with the blank screen, so a stale list is worse than no list.

Then generate the platform assets from it:

cd frontend
npx @capacitor/assets generate --splashBackgroundColor '#0c0e12'

The icon's background colour is already baked into icon.png, so only the splash needs one here. resources/icon.svg is the vector drawing of the dumbbell glyph the app used before it had this mark: nothing generates from it any more (@capacitor/assets prefers .png over .svg in the same directory — see the extension order in its loadInputAsset), and it is kept only as that drawing.

Distribution — deliberately no app stores

KuentaGYM's mobile app is not on the Play Store or App Store, and that's a choice: no store accounts, no store rules, no yearly fees between you and an open-source app.

Android — build and sideload the APK yourself

This fork publishes no APK. There is no download page, no package in a registry and no release asset to point at, and no CI job that builds one: the build:apk job upstream uses lives in the dormant .gitlab-ci.yml, which no host runs for this fork. The in-app update check reads this repository's releases on Gitea and will find nothing until a release carries a signed APK and its .sha256 (see Release notes for maintainers below). Until then the APK you run is the one you build and sign yourself, with your own key.

Android asks you to allow installs from the browser the first time — standard for any app outside the Play Store, and no different for a build you made yourself.

To build and sign your own:

cd frontend && npm run build:mobile
cd android && ./gradlew assembleRelease            # → app/build/outputs/apk/release/app-release-unsigned.apk

# one-time: create a keystore. KEEP IT — updates must be signed with the same key,
# or Android refuses to install the new version over the old one.
keytool -genkeypair -keystore my.keystore -alias kuentagym -keyalg RSA -validity 10950

# align + sign (zipalign/apksigner ship with the Android SDK build-tools)
zipalign -f -p 4 app-release-unsigned.apk aligned.apk
apksigner sign --ks my.keystore --ks-key-alias kuentagym --out KuentaGYM.apk aligned.apk

iPhone — what's actually possible

Apple does not allow installing apps outside the App Store, so there is no .ipa download that would simply install. Your free options:

  • Self-host + PWA (recommended): open your instance in Safari → Share → Add to Home Screen. Full-screen app, no expiry, plus sync and passkeys.
  • Xcode free signing: open ios/ in Xcode with a free Apple ID as the team and run it onto your own iPhone. Apple expires the signature after 7 days; re-run from Xcode to renew.
  • AltStore: automates that 7-day re-signing over Wi-Fi via a Mac companion app.

Upstream's pipeline has a build:ios job for exactly that path — the same mobile bundle, xcodebuild archive without a signing identity, and an unsigned .ipa (plus .sha256) for AltStore/Sideloadly users to sign with their own Apple ID. It needs a Mac, and it lives in the dormant .gitlab-ci.yml: no host runs it for this fork, so there is no .ipa job, no runner to register and no IOS_RUNNER_TAG variable to set. An unsigned .ipa is a manual xcodebuild run on a Mac and nothing more; nobody here does it for you. A signed build (TestFlight, App Store) would additionally need an Apple Developer Program membership, the distribution certificate and profile, and an -exportArchive step — none of that is set up.

Audio with the screen locked (the shells only)

The web app plays radio and podcasts fine with the phone locked: Safari and Chrome keep the audio alive underneath the page, and Media Session puts the station — or the episode, with its progress bar — and the controls on the lock screen. The packaged shells are a different story, and it is a config gap rather than a code one:

  • iOS (frontend/ios) — the app needs UIBackgroundModes: audio in Info.plist. Without it, iOS suspends the WebView's audio a moment after the screen locks.
  • Android (frontend/android) — a WebView needs a foreground service (with a mediaPlayback type and its notification) to keep playing while the app is not in front; android:foregroundServiceType plus the service's own declaration, not a manifest flag alone.

Neither is set today, so audio in a packaged build stops when the screen locks — install the PWA instead (Add to Home Screen) if that matters, which is the recommended path here anyway. One more consequence for podcasts: a locked page's timers are suspended, so the listening position is written to the profile on pause, on stop, when an episode ends and when the app goes to the background — never from a tick alone, which is why locking the phone does not lose your place.

Release notes for maintainers

  • Bump versionName/versionCode in android/app/build.gradle per release; keep them in step with frontend/package.json. versionCode must strictly increase or updates won't install over an existing APK. Upstream names the APK from frontend/package.json; your own build is named whatever you pass to apksigner.
  • A push to main and a published Gitea release are what build and push the two container images (.gitea/workflows/docker-publish.yml). Nothing packages an APK or writes release notes for you: if you publish a release, attach the signed APK and its .sha256 by hand — that asset is also what the Android build's in-app update check looks for.
  • License: KuentaGYM is AGPL-3.0, which by itself sits badly with app-store terms of service. NOTICE.md carries an app-store exception (an additional permission under AGPL §7) granted by the copyright holder — relevant only if store distribution ever happens.
  • The app requests notification permission only when the workout-day reminder is switched on, and (on Android) declares SCHEDULE_EXACT_ALARM so the reminder fires to the minute where the user allows it.