GymLog: Gym- & Körpergewicht-Tracker — PWA mit Passkey-Login
Frontend: Static-SPA (Vanilla JS) — Dashboard, Wochenplan mit Per-Tag-Umplanung, geführter Workout-Flow (Körpergewicht-Abfrage, Set-Logging, Rest-Timer, PR-Erkennung, Gewichts-Bestätigung pro Übung), Activity-Heatmap, Kraft- & Gewichts-Charts, Übungs-Bibliothek (1324 Übungen, autoplay GIFs), Swipe-Sheets, PWA/offline. Backend: Node + @simplewebauthn — Passkey-Registrierung/-Login (Face ID), HMAC-Session-Cookies, Per-User-State-Sync mit JSON-File-Storage. Übungsdaten aus hasaneyldrm/exercises-dataset (Medien via scripts/fetch-media.sh).
This commit is contained in:
commit
29f5f64f8e
15 files changed
+2476
No files matched your search
@@ -0,0 +1,8 @@
|
||||
# Übungs-Medien (via scripts/fetch-media.sh aus hasaneyldrm/exercises-dataset)
|
||||
app/img/
|
||||
app/gif/
|
||||
|
||||
node_modules/
|
||||
data/
|
||||
*.log
|
||||
.DS_Store
|
||||
@@ -0,0 +1,53 @@
|
||||
# GymLog 🏋️
|
||||
|
||||
Persönlicher Gym- & Körpergewicht-Tracker als mobile-first Web-App (PWA) —
|
||||
mit Apple-Passkey-Login (Face ID) und eigenem Profil pro Person.
|
||||
|
||||
**Live:** https://gym.duarte-santos.ch
|
||||
|
||||
## Features
|
||||
|
||||
- **Dashboard** — Wochenübersicht, Today-Card, Körpergewicht-Kurve, Streak & Volumen-Tiles
|
||||
- **Trainingsplan** — Wochenplan (Wochentag → Routine) + Routine-Editor mit Übungs-Picker
|
||||
(1'324 Übungen mit Animationen, Suche + Muskelgruppen-Filter)
|
||||
- **Umplanen per Kalender** — einzelne Tage überschreiben (krank / verpasst / andere Session),
|
||||
ohne den Wochenplan zu ändern
|
||||
- **Workout-Flow** — Start erkennt den Wochentag und startet die heutige Session direkt.
|
||||
Vorher wird immer das Körpergewicht abgefragt. Sätze abhaken, Gewichte vom letzten Mal
|
||||
vorausgefüllt, Rest-Timer mit Beep, Progression-Hints, PR-Erkennung
|
||||
- **Gewichts-Tracking pro Übung** — am Ende jeder Übung wird das Arbeitsgewicht bestätigt;
|
||||
das höchste je eingegebene Gewicht ist beim nächsten Mal der Startwert
|
||||
- **Stats** — GitHub-Style Activity-Heatmap (12 Monate), Körpergewicht-Chart,
|
||||
Kraft-Progression pro Übung, komplette Historie
|
||||
- **Passkeys statt Passwörter** — WebAuthn mit Face ID / Touch ID, Profile synchronisieren
|
||||
über Geräte; Gast-Modus (nur lokal) möglich
|
||||
- **PWA** — „Zum Home-Bildschirm", offline-fähig (Service Worker)
|
||||
|
||||
## Struktur
|
||||
|
||||
```
|
||||
app/ Frontend — handgebaute Static-SPA, kein Build-Step (Vanilla JS, Hash-Routing)
|
||||
api/ Backend — Node 22, kein Framework, @simplewebauthn/server, JSON-File-Storage
|
||||
scripts/ fetch-media.sh lädt die Übungs-Bilder/GIFs (nicht im Repo, ~140 MB)
|
||||
```
|
||||
|
||||
## Übungs-Medien
|
||||
|
||||
Die Übungsdaten (`app/data.js`) und Medien stammen aus
|
||||
[hasaneyldrm/exercises-dataset](https://github.com/hasaneyldrm/exercises-dataset).
|
||||
Bilder/GIFs sind nicht eingecheckt — einmalig holen mit:
|
||||
|
||||
```bash
|
||||
./scripts/fetch-media.sh # füllt app/img/ (12 MB) und app/gif/ (126 MB)
|
||||
```
|
||||
|
||||
## Betrieb
|
||||
|
||||
- `app/` wird von einem beliebigen Static-Server ausgeliefert (nginx); JS/CSS/HTML mit
|
||||
`no-cache`, `img/`+`gif/` lange cachen. Assets sind mit `?v=N` versioniert.
|
||||
- `api/` läuft als Container (siehe `api/Dockerfile`), Env: `RP_ID` (Domain), `ORIGIN`
|
||||
(https-Origin), `DATA_DIR` (Volume, default `/data`). Reverse-Proxy routet `/api/*`
|
||||
auf Port 3000 der API, alles andere auf die Static-Site — **gleiche Domain**, sonst
|
||||
funktionieren Passkeys nicht.
|
||||
- User/Credentials liegen in `DATA_DIR/db.json`, App-State pro User in
|
||||
`DATA_DIR/state-<uid>.json`, Session-Secret in `DATA_DIR/secret` → Volume sichern.
|
||||
@@ -0,0 +1,8 @@
|
||||
FROM node:22-alpine
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json* ./
|
||||
RUN npm install --omit=dev && npm cache clean --force
|
||||
COPY server.js ./
|
||||
ENV NODE_ENV=production
|
||||
EXPOSE 3000
|
||||
CMD ["node", "server.js"]
|
||||
Generated
+253
@@ -0,0 +1,253 @@
|
||||
{
|
||||
"name": "gym-api",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "gym-api",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@simplewebauthn/server": "^13.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@hexagon/base64": {
|
||||
"version": "1.1.28",
|
||||
"resolved": "https://registry.npmjs.org/@hexagon/base64/-/base64-1.1.28.tgz",
|
||||
"integrity": "sha512-lhqDEAvWixy3bZ+UOYbPwUbBkwBq5C1LAJ/xPC8Oi+lL54oyakv/npbA0aU2hgCsx/1NUd4IBvV03+aUBWxerw=="
|
||||
},
|
||||
"node_modules/@levischuck/tiny-cbor": {
|
||||
"version": "0.2.11",
|
||||
"resolved": "https://registry.npmjs.org/@levischuck/tiny-cbor/-/tiny-cbor-0.2.11.tgz",
|
||||
"integrity": "sha512-llBRm4dT4Z89aRsm6u2oEZ8tfwL/2l6BwpZ7JcyieouniDECM5AqNgr/y08zalEIvW3RSK4upYyybDcmjXqAow=="
|
||||
},
|
||||
"node_modules/@peculiar/asn1-android": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-android/-/asn1-android-2.8.0.tgz",
|
||||
"integrity": "sha512-skLbS+IOGv1lUgDqtChr8xvtvEr3HMse/JGBaL2r1J1o/n7a8wqOrovMtlRq/UXLhxvmLaONP67hwtshgzwfzA==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-cms": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.8.0.tgz",
|
||||
"integrity": "sha512-NgekZOrSJFSBFLFoLfwePguAWAx7z1+f2TEsWFUMyiqqfntZ4+S/S5hzqME3q4pCA0iOsFKdwiQ35dwY24eVqA==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"@peculiar/asn1-x509": "^2.8.0",
|
||||
"@peculiar/asn1-x509-attr": "^2.8.0",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-csr": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.8.0.tgz",
|
||||
"integrity": "sha512-akbF8+uvleHs8sejNPQxwmVFuInAg6FMNHOwMILXfP518YfFJwdR3jr6oNUPOaEJfuEhn/vkNOCIT6ASUd4mbg==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"@peculiar/asn1-x509": "^2.8.0",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-ecc": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.8.0.tgz",
|
||||
"integrity": "sha512-ohwlk+u9Rv2NOAY1c6MfHj45ATVF8R1DUN/WCgABiRtLi2ZftlZWZX7KvpAbU8v9xPcmoILfELeEABj/rn18AQ==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"@peculiar/asn1-x509": "^2.8.0",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-pfx": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.8.0.tgz",
|
||||
"integrity": "sha512-5yof1ytoB++RQtaFbqSUJ8pxDJtZT6vbVqZ8XoJ61ph7UjNVvfFwAilnCodqkNsAodpy13gDhoxZXw00pghnyg==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-cms": "^2.8.0",
|
||||
"@peculiar/asn1-pkcs8": "^2.8.0",
|
||||
"@peculiar/asn1-rsa": "^2.8.0",
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-pkcs8": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.8.0.tgz",
|
||||
"integrity": "sha512-qAKXtLpBEw9LqhKpjw3ajZSXlBur+ipW+y2ivVBQAG6F6qRx94yO+1ZR4mvw+YaCfKSaOzLeYEzsPaBp4SJELA==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"@peculiar/asn1-x509": "^2.8.0",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-pkcs9": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.8.0.tgz",
|
||||
"integrity": "sha512-b5nDWCnkV60+cQ141D6sVVwK9nz64R5n3zSVnklGd+ECdkW2Ol3U1a6yYFlalpSOaD557yuJB64A+q42jG7lUQ==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-cms": "^2.8.0",
|
||||
"@peculiar/asn1-pfx": "^2.8.0",
|
||||
"@peculiar/asn1-pkcs8": "^2.8.0",
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"@peculiar/asn1-x509": "^2.8.0",
|
||||
"@peculiar/asn1-x509-attr": "^2.8.0",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-rsa": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.8.0.tgz",
|
||||
"integrity": "sha512-zHEUlCqB2mk7x2lxDwHHJy7hWZOPdGHVlsmITWKB5/PbQo61atbu9PJ/0r9dQNMwFzbKPXZ8uK8/91eUhRznSg==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"@peculiar/asn1-x509": "^2.8.0",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-schema": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.8.0.tgz",
|
||||
"integrity": "sha512-7YT0U/ze0tF2QOBbE15gKZwy5tvgGyLRiRHLzhlbOpf7BT032oBSd0haZqXn5W6l26WLlu3dyxzjM+2638/z2Q==",
|
||||
"dependencies": {
|
||||
"@peculiar/utils": "^2.0.2",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-x509": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.8.0.tgz",
|
||||
"integrity": "sha512-N0CMuhWUzsWEVq6F1q9X6+VKUnWzSW+cSVg+aPaGGwDdbFoFWTYgin5MHwXgpWd6y9COMBxnfy/Qc+Xc7F0Zwg==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"@peculiar/utils": "^2.0.2",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/asn1-x509-attr": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.8.0.tgz",
|
||||
"integrity": "sha512-tHjkfS/qhMnmrlB2J9NhflQlQ7In3khO3CfmVrriOlpTeErY9ZIKOso1hQ5JQiyrJ7ShvqVPk7E5fQmbclkSKA==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-schema": "^2.8.0",
|
||||
"@peculiar/asn1-x509": "^2.8.0",
|
||||
"asn1js": "^3.0.10",
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/utils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.3.tgz",
|
||||
"integrity": "sha512-+oL3HPFRIZ1St2K50lWCXiioIgSoxzz7R1J3uF6neO2yl1sgmpgY6XXJH4BdpoDkMWznQTeYF6oWNDZLCdQ4eQ==",
|
||||
"dependencies": {
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@peculiar/x509": {
|
||||
"version": "1.14.3",
|
||||
"resolved": "https://registry.npmjs.org/@peculiar/x509/-/x509-1.14.3.tgz",
|
||||
"integrity": "sha512-C2Xj8FZ0uHWeCXXqX5B4/gVFQmtSkiuOolzAgutjTfseNOHT3pUjljDZsTSxXFGgio54bCzVFqmEOUrIVk8RDA==",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-cms": "^2.6.0",
|
||||
"@peculiar/asn1-csr": "^2.6.0",
|
||||
"@peculiar/asn1-ecc": "^2.6.0",
|
||||
"@peculiar/asn1-pkcs9": "^2.6.0",
|
||||
"@peculiar/asn1-rsa": "^2.6.0",
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.0",
|
||||
"pvtsutils": "^1.3.6",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"tslib": "^2.8.1",
|
||||
"tsyringe": "^4.10.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@simplewebauthn/server": {
|
||||
"version": "13.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@simplewebauthn/server/-/server-13.3.2.tgz",
|
||||
"integrity": "sha512-KEDhfcGP1PAKRVSDjA3npTQFqS2b/srm+ipoNBNHdkzrHAlaRQUTE+a5f4ywsx6thxAw1NU2rYcLEY1949RGbQ==",
|
||||
"dependencies": {
|
||||
"@hexagon/base64": "^1.1.27",
|
||||
"@levischuck/tiny-cbor": "^0.2.2",
|
||||
"@peculiar/asn1-android": "^2.6.0",
|
||||
"@peculiar/asn1-ecc": "^2.6.1",
|
||||
"@peculiar/asn1-rsa": "^2.6.1",
|
||||
"@peculiar/asn1-schema": "^2.6.0",
|
||||
"@peculiar/asn1-x509": "^2.6.1",
|
||||
"@peculiar/x509": "^1.14.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/asn1js": {
|
||||
"version": "3.0.10",
|
||||
"resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.10.tgz",
|
||||
"integrity": "sha512-S2s3aOytiKdFRdulw2qPE51MzjzVOisppcVv7jVFR+Kw0kxwvFrDcYA0h7Ndqbmj0HkMIXYWaoj7fli8kgx1eg==",
|
||||
"dependencies": {
|
||||
"pvtsutils": "^1.3.6",
|
||||
"pvutils": "^1.1.5",
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pvtsutils": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz",
|
||||
"integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==",
|
||||
"dependencies": {
|
||||
"tslib": "^2.8.1"
|
||||
}
|
||||
},
|
||||
"node_modules/pvutils": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.1.5.tgz",
|
||||
"integrity": "sha512-KTqnxsgGiQ6ZAzZCVlJH5eOjSnvlyEgx1m8bkRJfOhmGRqfo5KLvmAlACQkrjEtOQ4B7wF9TdSLIs9O90MX9xA==",
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/reflect-metadata": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz",
|
||||
"integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q=="
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="
|
||||
},
|
||||
"node_modules/tsyringe": {
|
||||
"version": "4.10.0",
|
||||
"resolved": "https://registry.npmjs.org/tsyringe/-/tsyringe-4.10.0.tgz",
|
||||
"integrity": "sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw==",
|
||||
"dependencies": {
|
||||
"tslib": "^1.9.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tsyringe/node_modules/tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "gym-api",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@simplewebauthn/server": "^13.1.1"
|
||||
}
|
||||
}
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
/* gym-api — passkey (WebAuthn) auth + per-user state storage for GymLog
|
||||
No framework, JSON-file storage, signed session cookies. */
|
||||
import http from 'node:http';
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import {
|
||||
generateRegistrationOptions, verifyRegistrationResponse,
|
||||
generateAuthenticationOptions, verifyAuthenticationResponse
|
||||
} from '@simplewebauthn/server';
|
||||
|
||||
const PORT = +(process.env.PORT || 3000);
|
||||
const DATA = process.env.DATA_DIR || '/data';
|
||||
const RP_ID = process.env.RP_ID || 'gym.duarte-santos.ch';
|
||||
const ORIGIN = process.env.ORIGIN || 'https://gym.duarte-santos.ch';
|
||||
const RP_NAME = 'GymLog';
|
||||
const SESSION_DAYS = 365;
|
||||
const MAX_BODY = 5 * 1024 * 1024;
|
||||
|
||||
fs.mkdirSync(DATA, { recursive: true });
|
||||
|
||||
/* ---------- secret + db ---------- */
|
||||
const secretFile = path.join(DATA, 'secret');
|
||||
if (!fs.existsSync(secretFile)) fs.writeFileSync(secretFile, crypto.randomBytes(32).toString('hex'), { mode: 0o600 });
|
||||
const SECRET = fs.readFileSync(secretFile, 'utf8').trim();
|
||||
|
||||
const dbFile = path.join(DATA, 'db.json');
|
||||
let db = { users: [], creds: [] };
|
||||
try { db = JSON.parse(fs.readFileSync(dbFile, 'utf8')); } catch {}
|
||||
function saveDb() { atomicWrite(dbFile, JSON.stringify(db, null, 2)); }
|
||||
function atomicWrite(file, content) {
|
||||
const tmp = file + '.tmp';
|
||||
fs.writeFileSync(tmp, content);
|
||||
fs.renameSync(tmp, file);
|
||||
}
|
||||
const stateFile = uid => path.join(DATA, 'state-' + uid.replace(/[^a-zA-Z0-9_-]/g, '') + '.json');
|
||||
|
||||
/* ---------- sessions (signed cookie) ---------- */
|
||||
function sign(payload) {
|
||||
const mac = crypto.createHmac('sha256', SECRET).update(payload).digest('base64url');
|
||||
return payload + '.' + mac;
|
||||
}
|
||||
function verifySig(token) {
|
||||
const i = token.lastIndexOf('.');
|
||||
if (i < 0) return null;
|
||||
const payload = token.slice(0, i), mac = token.slice(i + 1);
|
||||
const expect = crypto.createHmac('sha256', SECRET).update(payload).digest('base64url');
|
||||
try {
|
||||
if (!crypto.timingSafeEqual(Buffer.from(mac), Buffer.from(expect))) return null;
|
||||
} catch { return null; }
|
||||
return payload;
|
||||
}
|
||||
function makeSession(uid) {
|
||||
const exp = Date.now() + SESSION_DAYS * 86400000;
|
||||
return sign(uid + ':' + exp);
|
||||
}
|
||||
function readSession(req) {
|
||||
const cookies = Object.fromEntries((req.headers.cookie || '').split(';').map(c => {
|
||||
const i = c.indexOf('='); return i < 0 ? ['', ''] : [c.slice(0, i).trim(), c.slice(i + 1).trim()];
|
||||
}));
|
||||
const tok = cookies.gymsid;
|
||||
if (!tok) return null;
|
||||
const payload = verifySig(tok);
|
||||
if (!payload) return null;
|
||||
const [uid, exp] = payload.split(':');
|
||||
if (!uid || +exp < Date.now()) return null;
|
||||
return db.users.find(u => u.id === uid) || null;
|
||||
}
|
||||
function sessionCookie(uid) {
|
||||
return `gymsid=${makeSession(uid)}; Path=/; Max-Age=${SESSION_DAYS * 86400}; HttpOnly; Secure; SameSite=Lax`;
|
||||
}
|
||||
const clearCookie = 'gymsid=; Path=/; Max-Age=0; HttpOnly; Secure; SameSite=Lax';
|
||||
|
||||
/* ---------- challenge store (in-memory, 5 min TTL) ---------- */
|
||||
const challenges = new Map(); // cid -> {challenge, name?, uid?, exp}
|
||||
function putChallenge(data) {
|
||||
const cid = crypto.randomBytes(16).toString('base64url');
|
||||
challenges.set(cid, { ...data, exp: Date.now() + 5 * 60000 });
|
||||
return cid;
|
||||
}
|
||||
function takeChallenge(cid) {
|
||||
const c = challenges.get(cid);
|
||||
challenges.delete(cid);
|
||||
if (!c || c.exp < Date.now()) return null;
|
||||
return c;
|
||||
}
|
||||
setInterval(() => { for (const [k, v] of challenges) if (v.exp < Date.now()) challenges.delete(k); }, 60000).unref();
|
||||
|
||||
/* ---------- helpers ---------- */
|
||||
function json(res, code, obj, extraHeaders) {
|
||||
const body = JSON.stringify(obj);
|
||||
res.writeHead(code, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store', ...(extraHeaders || {}) });
|
||||
res.end(body);
|
||||
}
|
||||
function readBody(req) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let size = 0; const chunks = [];
|
||||
req.on('data', d => {
|
||||
size += d.length;
|
||||
if (size > MAX_BODY) { reject(new Error('body too large')); req.destroy(); return; }
|
||||
chunks.push(d);
|
||||
});
|
||||
req.on('end', () => {
|
||||
try { resolve(chunks.length ? JSON.parse(Buffer.concat(chunks).toString('utf8')) : {}); }
|
||||
catch { reject(new Error('bad json')); }
|
||||
});
|
||||
req.on('error', reject);
|
||||
});
|
||||
}
|
||||
const b64uToBuf = s => Buffer.from(s, 'base64url');
|
||||
|
||||
/* ---------- routes ---------- */
|
||||
const routes = {
|
||||
'GET /api/health': async (req, res) => json(res, 200, { ok: true, users: db.users.length }),
|
||||
|
||||
'GET /api/me': async (req, res) => {
|
||||
const user = readSession(req);
|
||||
if (!user) return json(res, 401, { error: 'not signed in' });
|
||||
json(res, 200, { user: { id: user.id, name: user.name } });
|
||||
},
|
||||
|
||||
'POST /api/register/options': async (req, res) => {
|
||||
const body = await readBody(req);
|
||||
const name = String(body.name || '').trim().slice(0, 40);
|
||||
if (!name) return json(res, 400, { error: 'name required' });
|
||||
const uid = crypto.randomBytes(12).toString('base64url');
|
||||
const options = await generateRegistrationOptions({
|
||||
rpName: RP_NAME, rpID: RP_ID,
|
||||
userID: Buffer.from(uid), userName: name, userDisplayName: name,
|
||||
attestationType: 'none',
|
||||
authenticatorSelection: { residentKey: 'required', userVerification: 'preferred' },
|
||||
excludeCredentials: []
|
||||
});
|
||||
const cid = putChallenge({ challenge: options.challenge, name, uid });
|
||||
json(res, 200, { cid, options });
|
||||
},
|
||||
|
||||
'POST /api/register/verify': async (req, res) => {
|
||||
const body = await readBody(req);
|
||||
const c = takeChallenge(body.cid);
|
||||
if (!c || !c.uid) return json(res, 400, { error: 'challenge expired — try again' });
|
||||
let verification;
|
||||
try {
|
||||
verification = await verifyRegistrationResponse({
|
||||
response: body.credential,
|
||||
expectedChallenge: c.challenge,
|
||||
expectedOrigin: ORIGIN,
|
||||
expectedRPID: RP_ID,
|
||||
requireUserVerification: false
|
||||
});
|
||||
} catch (e) { return json(res, 400, { error: 'verification failed: ' + e.message }); }
|
||||
if (!verification.verified) return json(res, 400, { error: 'not verified' });
|
||||
const { credential } = verification.registrationInfo;
|
||||
if (db.creds.find(x => x.id === credential.id)) return json(res, 409, { error: 'credential already registered' });
|
||||
const user = { id: c.uid, name: c.name, created: new Date().toISOString() };
|
||||
db.users.push(user);
|
||||
db.creds.push({
|
||||
id: credential.id, userId: user.id,
|
||||
publicKey: Buffer.from(credential.publicKey).toString('base64url'),
|
||||
counter: credential.counter || 0,
|
||||
transports: body.credential?.response?.transports || []
|
||||
});
|
||||
saveDb();
|
||||
json(res, 200, { user: { id: user.id, name: user.name } }, { 'Set-Cookie': sessionCookie(user.id) });
|
||||
},
|
||||
|
||||
'POST /api/login/options': async (req, res) => {
|
||||
const options = await generateAuthenticationOptions({
|
||||
rpID: RP_ID, userVerification: 'preferred', allowCredentials: []
|
||||
});
|
||||
const cid = putChallenge({ challenge: options.challenge });
|
||||
json(res, 200, { cid, options });
|
||||
},
|
||||
|
||||
'POST /api/login/verify': async (req, res) => {
|
||||
const body = await readBody(req);
|
||||
const c = takeChallenge(body.cid);
|
||||
if (!c) return json(res, 400, { error: 'challenge expired — try again' });
|
||||
const cred = db.creds.find(x => x.id === body.credential?.id);
|
||||
if (!cred) return json(res, 404, { error: 'unknown passkey — create a profile first' });
|
||||
let verification;
|
||||
try {
|
||||
verification = await verifyAuthenticationResponse({
|
||||
response: body.credential,
|
||||
expectedChallenge: c.challenge,
|
||||
expectedOrigin: ORIGIN,
|
||||
expectedRPID: RP_ID,
|
||||
requireUserVerification: false,
|
||||
credential: {
|
||||
id: cred.id,
|
||||
publicKey: b64uToBuf(cred.publicKey),
|
||||
counter: cred.counter,
|
||||
transports: cred.transports
|
||||
}
|
||||
});
|
||||
} catch (e) { return json(res, 400, { error: 'verification failed: ' + e.message }); }
|
||||
if (!verification.verified) return json(res, 400, { error: 'not verified' });
|
||||
cred.counter = verification.authenticationInfo.newCounter;
|
||||
saveDb();
|
||||
const user = db.users.find(u => u.id === cred.userId);
|
||||
if (!user) return json(res, 500, { error: 'user missing' });
|
||||
json(res, 200, { user: { id: user.id, name: user.name } }, { 'Set-Cookie': sessionCookie(user.id) });
|
||||
},
|
||||
|
||||
'POST /api/logout': async (req, res) => json(res, 200, { ok: true }, { 'Set-Cookie': clearCookie }),
|
||||
|
||||
'GET /api/data': async (req, res) => {
|
||||
const user = readSession(req);
|
||||
if (!user) return json(res, 401, { error: 'not signed in' });
|
||||
try {
|
||||
const state = JSON.parse(fs.readFileSync(stateFile(user.id), 'utf8'));
|
||||
json(res, 200, { state });
|
||||
} catch { json(res, 200, { state: null }); }
|
||||
},
|
||||
|
||||
'PUT /api/data': async (req, res) => {
|
||||
const user = readSession(req);
|
||||
if (!user) return json(res, 401, { error: 'not signed in' });
|
||||
const body = await readBody(req);
|
||||
if (!body.state || typeof body.state !== 'object') return json(res, 400, { error: 'state required' });
|
||||
delete body.state.active; // in-progress workouts stay device-local
|
||||
atomicWrite(stateFile(user.id), JSON.stringify(body.state));
|
||||
json(res, 200, { ok: true, ts: body.state._ts || null });
|
||||
}
|
||||
};
|
||||
|
||||
http.createServer(async (req, res) => {
|
||||
const url = new URL(req.url, 'http://x');
|
||||
const key = req.method + ' ' + url.pathname;
|
||||
const handler = routes[key];
|
||||
if (!handler) return json(res, 404, { error: 'not found' });
|
||||
try { await handler(req, res); }
|
||||
catch (e) {
|
||||
console.error(key, e);
|
||||
if (!res.headersSent) json(res, 500, { error: 'server error' });
|
||||
}
|
||||
}).listen(PORT, () => console.log(`gym-api on :${PORT} (rpID=${RP_ID}, origin=${ORIGIN})`));
|
||||
+1568
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
const EXDB=[{"id":"0001","n":"3/4 sit-up","bp":"waist","eq":"body weight","tg":"abs","mg":"hip flexors","sm":["hip flexors","lower back"],"st":["Lie flat on your back with your knees bent and feet flat on the ground.","Place your hands behind your head with your elbows pointing outwards.","Engaging your abs, slowly lift your upper body off the ground, curling forward until your torso is at a 45-degree angle.","Pause for a moment at the top, then slowly lower your upper body back down to the starting position.","Repeat for the desired number of repetitions."],"img":"0001-2gPfomN.jpg","gif":"0001-2gPfomN.gif"},{"id":"0002","n":"45° side bend","bp":"waist","eq":"body weight","tg":"abs","mg":"obliques","sm":["obliques"],"st":["Stand with your feet shoulder-width apart and your arms extended straight down by your sides.","Keeping your back straight and your core engaged, slowly bend your torso to one side, lowering your hand towards your knee.","Pause for a moment at the bottom, then slowly return to the starting position.","Repeat on the other side.","Continue alternating sides for the desired number of repetitions."],"img":"0002-Hy9D21L.jpg","gif":"0002-Hy9D21L.gif"},{"id":"0003","n":"air bike","bp":"waist","eq":"body weight","tg":"abs","mg":"hip flexors","sm":["hip flexors"],"st":["Lie flat on your back with your hands placed behind your head.","Lift your legs off the ground and bend your knees at a 90-degree angle.","Bring your right elbow towards your left knee while simultaneously straightening your right leg.","Return to the starting position and repeat the movement on the opposite side, bringing your left elbow towards your right knee while straightening your left leg.","Continue alternating sides in a pedaling motion for the desired number of repetitions."],"img":"0003-1ZFqTDN.jpg","gif":"0003-1ZFqTDN.gif"},{"id":"1512","n":"all fours squad stretch","bp":"upper legs","eq":"body weight","tg":"quads","mg":"hamstrings","sm":["hamstrings","glutes"],"st":["Start on all fours with your hands directly under your shoulders and your knees directly under your hips.","Extend one leg straight back, keeping your knee bent and your foot flexed.","Slowly lower your hips towards the ground, feeling a stretch in your quads.","Hold this position for 20-30 seconds.","Switch legs and repeat the stretch on the other side."],"img":"1512-qBcKorM.jpg","gif":"1512-qBcKorM.gif"},{"id":"0006","n":"alternate heel touchers","bp":"waist","eq":"body weight","tg":"abs","mg":"obliques","sm":["obliques"],"st":["Lie flat on your back with your knees bent and feet flat on the ground.","Extend your arms straight out to the sides, parallel to the ground.","Engaging your abs, lift your shoulders off the ground and reach your right hand towards your right heel.","Return to the starting position and repeat on the left side, reaching your left hand towards your left heel.","Continue alternating sides for the desired number of repetitions."],"img":"0006-qaZVsGk.jpg","gif":"0006-qaZVsGk.gif"},{"id":"0007","n":"alternate lateral pulldown","bp":"back","eq":"cable","tg":"lats","mg":"biceps","sm":["biceps","rhomboids"],"st":["Sit on the cable machine with your back straight and feet flat on the ground.","Grasp the handles with an overhand grip, slightly wider than shoulder-width apart.","Lean back slightly and pull the handles towards your chest, squeezing your shoulder blades together.","Pause for a moment at the peak of the movement, then slowly release the handles back to the starting position.","Repeat for the desired number of repetitions."],"img":"0007-4IKbhHV.jpg","gif":"0007-4IKbhHV.gif"},{"id":"1368","n":"ankle circles","bp":"lower legs","eq":"body weight","tg":"calves","mg":"ankle stabilizers","sm":["ankle stabilizers"],"st":["Sit on the ground with your legs extended in front of you.","Lift one leg off the ground and rotate your ankle in a circular motion.","Perform the desired number of circles in one direction, then switch to the other direction.","Repeat with the other leg."],"img":"1368-uL9CsKm.jpg","gif":"1368-uL9CsKm.gif"},{"id":"3293","n":"archer pull up","bp":"back","eq":"body weight","tg":"lats","mg":"biceps","sm":["biceps","forearms"],"st":["Start by hanging from a pull-up bar with an overhand grip, slightly wider than shoulder-width apart.","Engage your core and pull your shoulder blades down and back.","As you pull yourself up, bend one arm and bring your elbow towards your side, while keeping the other arm straight.","Continue pulling until your chin is above the bar and your bent arm is fully flexed.","Lower yourself back down with control, straightening the bent arm and repeating the movement on the other side.","Alternate sides with each repetition."],"img":"3293-72BC5Za.jpg","gif":"3293-72BC5Za.gif"},{"id":"3294","n":"archer push up","bp":"chest","eq":"body weight","tg":"pectorals","mg":"triceps","sm":["triceps","shoulders","core"],"st":["Start in a push-up position with your hands slightly wider than shoulder-width aparLine truncated
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 515 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover,user-scalable=no">
|
||||
<title>GymLog</title>
|
||||
<meta name="description" content="Personal gym & body weight tracker">
|
||||
<meta name="theme-color" content="#0c0e12">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="GymLog">
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<link rel="apple-touch-icon" href="icon-180.png">
|
||||
<link rel="icon" type="image/png" href="icon-180.png">
|
||||
<link rel="stylesheet" href="style.css?v=5">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"><div style="padding-top:42vh;text-align:center;font-size:2.2rem">🏋️</div></div>
|
||||
|
||||
<nav id="tabbar">
|
||||
<button data-tab="home" aria-label="Home">
|
||||
<svg viewBox="0 0 24 24"><path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h14V9.5"/></svg>
|
||||
<span>Home</span>
|
||||
</button>
|
||||
<button data-tab="plan" aria-label="Plan">
|
||||
<svg viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="16" rx="2"/><path d="M8 3v4M16 3v4M3 11h18"/></svg>
|
||||
<span>Plan</span>
|
||||
</button>
|
||||
<button data-tab="workout" class="start" aria-label="Start workout">
|
||||
<span class="cir"><svg viewBox="0 0 24 24"><path d="M6.5 6.5v11M17.5 6.5v11M2.5 9.5v5M21.5 9.5v5M6.5 12h11"/></svg></span>
|
||||
<span>Start</span>
|
||||
</button>
|
||||
<button data-tab="stats" aria-label="Stats">
|
||||
<svg viewBox="0 0 24 24"><path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/></svg>
|
||||
<span>Stats</span>
|
||||
</button>
|
||||
<button data-tab="library" aria-label="Library">
|
||||
<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>
|
||||
<span>Exercises</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div id="timer-root"></div>
|
||||
<div id="modal-root"></div>
|
||||
<div id="toast"></div>
|
||||
|
||||
<script src="data.js?v=5"></script>
|
||||
<script src="app.js?v=5"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "GymLog",
|
||||
"short_name": "GymLog",
|
||||
"description": "Personal gym & body weight tracker",
|
||||
"start_url": "./",
|
||||
"scope": "./",
|
||||
"display": "standalone",
|
||||
"orientation": "portrait",
|
||||
"background_color": "#0c0e12",
|
||||
"theme_color": "#0c0e12",
|
||||
"icons": [
|
||||
{ "src": "icon-180.png", "sizes": "180x180", "type": "image/png" },
|
||||
{ "src": "icon-512.png", "sizes": "512x512", "type": "image/png" }
|
||||
]
|
||||
}
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
/* GymLog — mobile-first dark theme */
|
||||
:root{
|
||||
--bg:#0c0e12; --bg2:#14171d; --card:#1a1e26; --card2:#222733;
|
||||
--line:#2b3140; --txt:#eef1f6; --mut:#8b94a7; --dim:#5c6475;
|
||||
--acc:#a3e635; --acc2:#84cc16; --accT:rgba(163,230,53,.14);
|
||||
--blue:#60a5fa; --orange:#fb923c; --red:#f87171; --gold:#fbbf24;
|
||||
--r:16px; --pad:16px;
|
||||
--sab:env(safe-area-inset-bottom,0px); --sat:env(safe-area-inset-top,0px);
|
||||
}
|
||||
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
|
||||
html{font-size:16px}
|
||||
body{
|
||||
background:var(--bg); color:var(--txt);
|
||||
font-family:-apple-system,BlinkMacSystemFont,'SF Pro Text','Segoe UI',Roboto,sans-serif;
|
||||
min-height:100vh; overscroll-behavior-y:none;
|
||||
-webkit-font-smoothing:antialiased; touch-action:manipulation;
|
||||
}
|
||||
button{font:inherit;color:inherit;background:none;border:none;cursor:pointer}
|
||||
input,select,textarea{font:inherit;color:var(--txt)}
|
||||
img{max-width:100%}
|
||||
a{color:var(--acc)}
|
||||
|
||||
#app{padding:calc(var(--sat) + 10px) var(--pad) calc(96px + var(--sab)); max-width:560px; margin:0 auto}
|
||||
|
||||
/* ---------- header ---------- */
|
||||
.hdr{display:flex;align-items:center;justify-content:space-between;margin:6px 0 16px}
|
||||
.hdr h1{font-size:1.7rem;font-weight:800;letter-spacing:-.02em}
|
||||
.hdr .sub{color:var(--mut);font-size:.86rem;margin-top:2px}
|
||||
.iconbtn{width:42px;height:42px;border-radius:12px;background:var(--card);border:1px solid var(--line);
|
||||
display:flex;align-items:center;justify-content:center;font-size:1.15rem;flex:none}
|
||||
.iconbtn:active{background:var(--card2)}
|
||||
|
||||
/* ---------- cards ---------- */
|
||||
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--r);padding:16px;margin-bottom:14px}
|
||||
.card h2{font-size:.8rem;text-transform:uppercase;letter-spacing:.08em;color:var(--mut);font-weight:700;margin-bottom:10px}
|
||||
.card .big{font-size:1.9rem;font-weight:800;letter-spacing:-.02em}
|
||||
.row{display:flex;align-items:center;gap:12px}
|
||||
.row.between{justify-content:space-between}
|
||||
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
|
||||
.muted{color:var(--mut)} .dim{color:var(--dim)} .small{font-size:.82rem}
|
||||
.accent{color:var(--acc)}
|
||||
|
||||
/* ---------- buttons ---------- */
|
||||
.btn{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;
|
||||
padding:15px;border-radius:14px;font-weight:700;font-size:1rem;
|
||||
background:var(--card2);border:1px solid var(--line);transition:transform .08s}
|
||||
.btn:active{transform:scale(.97)}
|
||||
.btn.primary{background:var(--acc);color:#111;border:none}
|
||||
.btn.danger{background:rgba(248,113,113,.12);color:var(--red);border-color:rgba(248,113,113,.3)}
|
||||
.btn.ghost{background:none}
|
||||
.btn.sm{padding:9px 14px;width:auto;font-size:.86rem;border-radius:11px}
|
||||
.btn:disabled{opacity:.4}
|
||||
|
||||
/* ---------- tab bar ---------- */
|
||||
#tabbar{position:fixed;left:0;right:0;bottom:0;z-index:50;
|
||||
background:rgba(16,18,24,.88);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);
|
||||
border-top:1px solid var(--line);
|
||||
display:flex;justify-content:space-around;align-items:flex-end;
|
||||
padding:8px 6px calc(8px + var(--sab))}
|
||||
#tabbar button{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;
|
||||
color:var(--dim);font-size:.62rem;font-weight:600;padding-top:4px}
|
||||
#tabbar button svg{width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
|
||||
#tabbar button.on{color:var(--txt)}
|
||||
#tabbar button.start{margin-top:-26px}
|
||||
#tabbar button.start .cir{width:58px;height:58px;border-radius:50%;background:var(--acc);
|
||||
display:flex;align-items:center;justify-content:center;box-shadow:0 6px 20px rgba(163,230,53,.35)}
|
||||
#tabbar button.start .cir svg{width:26px;height:26px;stroke:#111;stroke-width:2.2}
|
||||
#tabbar button.start span{color:var(--acc)}
|
||||
#tabbar button.start.rec .cir{background:var(--orange);box-shadow:0 6px 20px rgba(251,146,60,.4);animation:pulse 1.6s infinite}
|
||||
#tabbar button.start.rec span{color:var(--orange)}
|
||||
@keyframes pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.06)}}
|
||||
|
||||
/* ---------- week strip ---------- */
|
||||
.week{display:flex;justify-content:space-between;gap:6px}
|
||||
.wday{flex:1;text-align:center;padding:9px 2px 10px;border-radius:12px;background:var(--bg2);border:1px solid transparent}
|
||||
.wday .lbl{font-size:.62rem;color:var(--dim);font-weight:700;text-transform:uppercase}
|
||||
.wday .num{font-size:.95rem;font-weight:700;margin:3px 0}
|
||||
.wday .dot{width:7px;height:7px;border-radius:50%;background:var(--line);margin:0 auto}
|
||||
.wday .dot.plan{background:var(--blue)}
|
||||
.wday .dot.ovr{background:var(--orange)}
|
||||
.wday .dot.done{background:var(--acc)}
|
||||
.wday:active{background:var(--card2)}
|
||||
.wday.today{border-color:var(--acc);background:var(--accT)}
|
||||
|
||||
/* ---------- lists ---------- */
|
||||
.list{display:flex;flex-direction:column;gap:10px}
|
||||
.item{display:flex;align-items:center;gap:12px;background:var(--card);border:1px solid var(--line);
|
||||
border-radius:14px;padding:12px;min-height:60px}
|
||||
.item:active{background:var(--card2)}
|
||||
.thumb{width:52px;height:52px;border-radius:10px;object-fit:cover;background:#fff;flex:none}
|
||||
.item .tt{font-weight:600;font-size:.93rem;line-height:1.25;text-transform:capitalize}
|
||||
.item .ss{color:var(--mut);font-size:.78rem;margin-top:2px;text-transform:capitalize}
|
||||
.item .grow{flex:1;min-width:0}
|
||||
.chev{color:var(--dim);flex:none}
|
||||
.tag{display:inline-block;background:var(--bg2);border:1px solid var(--line);color:var(--mut);
|
||||
border-radius:99px;padding:2px 9px;font-size:.7rem;font-weight:600;text-transform:capitalize}
|
||||
.tag.acc{background:var(--accT);border-color:transparent;color:var(--acc)}
|
||||
|
||||
/* ---------- chips ---------- */
|
||||
.chips{display:flex;gap:8px;overflow-x:auto;padding-bottom:4px;scrollbar-width:none;-webkit-overflow-scrolling:touch}
|
||||
.chips::-webkit-scrollbar{display:none}
|
||||
.chip{flex:none;padding:8px 14px;border-radius:99px;background:var(--card);border:1px solid var(--line);
|
||||
font-size:.82rem;font-weight:600;color:var(--mut);text-transform:capitalize}
|
||||
.chip.on{background:var(--acc);color:#111;border-color:var(--acc)}
|
||||
|
||||
/* ---------- inputs ---------- */
|
||||
.input{width:100%;background:var(--bg2);border:1px solid var(--line);border-radius:12px;
|
||||
padding:13px 14px;font-size:1rem;outline:none}
|
||||
.input:focus{border-color:var(--acc)}
|
||||
.search{position:relative}
|
||||
.search .input{padding-left:40px}
|
||||
.search svg{position:absolute;left:13px;top:50%;transform:translateY(-50%);width:17px;height:17px;
|
||||
stroke:var(--dim);fill:none;stroke-width:2;stroke-linecap:round}
|
||||
|
||||
/* stepper */
|
||||
.step{display:flex;align-items:center;gap:2px;background:var(--bg2);border:1px solid var(--line);border-radius:12px}
|
||||
.step button{width:38px;height:44px;font-size:1.25rem;color:var(--mut);flex:none}
|
||||
.step input{width:58px;text-align:center;background:none;border:none;font-size:1.05rem;font-weight:700;outline:none;
|
||||
-moz-appearance:textfield}
|
||||
.step input::-webkit-inner-spin-button{display:none}
|
||||
|
||||
/* ---------- workout ---------- */
|
||||
.wprog{height:5px;background:var(--bg2);border-radius:99px;overflow:hidden;margin-bottom:14px}
|
||||
.wprog i{display:block;height:100%;background:var(--acc);border-radius:99px;transition:width .3s}
|
||||
.exmedia{position:relative;border-radius:var(--r);overflow:hidden;background:#fff;margin-bottom:12px}
|
||||
.exmedia img{width:100%;height:340px;object-fit:contain;display:block}
|
||||
.exmedia .gifhint{position:absolute;right:10px;bottom:10px;background:rgba(0,0,0,.62);color:#fff;
|
||||
border-radius:99px;padding:4px 11px;font-size:.72rem;font-weight:600}
|
||||
.setrow{display:flex;align-items:center;gap:9px;padding:9px 0;border-bottom:1px solid var(--bg2)}
|
||||
.setrow:last-child{border-bottom:none}
|
||||
.setrow .n{width:26px;height:26px;border-radius:50%;background:var(--bg2);color:var(--mut);
|
||||
display:flex;align-items:center;justify-content:center;font-size:.78rem;font-weight:700;flex:none}
|
||||
.setrow .prev{width:74px;font-size:.72rem;color:var(--dim);flex:none;line-height:1.2}
|
||||
.setrow.done .n{background:var(--acc);color:#111}
|
||||
.setrow.done{opacity:.55}
|
||||
.ck{width:44px;height:44px;border-radius:12px;background:var(--bg2);border:1px solid var(--line);
|
||||
display:flex;align-items:center;justify-content:center;flex:none}
|
||||
.ck svg{width:20px;height:20px;stroke:var(--dim);fill:none;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round}
|
||||
.ck.on{background:var(--acc);border-color:var(--acc)}
|
||||
.ck.on svg{stroke:#111}
|
||||
|
||||
/* rest timer */
|
||||
#timer{position:fixed;left:14px;right:14px;bottom:calc(92px + var(--sab));z-index:60;
|
||||
background:var(--card2);border:1px solid var(--acc);border-radius:16px;padding:13px 16px;
|
||||
display:flex;align-items:center;gap:14px;box-shadow:0 10px 30px rgba(0,0,0,.5);
|
||||
animation:slideup .25s}
|
||||
@keyframes slideup{from{transform:translateY(20px);opacity:0}to{transform:none;opacity:1}}
|
||||
#timer .t{font-size:1.5rem;font-weight:800;font-variant-numeric:tabular-nums;min-width:74px}
|
||||
#timer .bar{flex:1;height:5px;background:var(--bg);border-radius:99px;overflow:hidden}
|
||||
#timer .bar i{display:block;height:100%;background:var(--acc);transition:width 1s linear}
|
||||
|
||||
/* ---------- modal ---------- */
|
||||
#modal-root{position:fixed;inset:0;z-index:100;display:none}
|
||||
#modal-root.open{display:block}
|
||||
.mback{position:absolute;inset:0;background:rgba(0,0,0,.6);backdrop-filter:blur(3px)}
|
||||
.sheet{position:absolute;left:0;right:0;bottom:0;background:var(--bg2);
|
||||
border-radius:22px 22px 0 0;padding:10px 18px calc(22px + var(--sab));
|
||||
max-height:88vh;overflow-y:auto;-webkit-overflow-scrolling:touch;animation:slideup .28s;
|
||||
overscroll-behavior:contain;touch-action:pan-y}
|
||||
.sheet .grab{width:40px;height:4px;border-radius:99px;background:var(--line);margin:4px auto 14px}
|
||||
.sheet h3{font-size:1.15rem;font-weight:800;margin-bottom:12px}
|
||||
.center{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:min(88vw,360px);
|
||||
background:var(--bg2);border:1px solid var(--line);border-radius:20px;padding:22px}
|
||||
|
||||
/* emoji grid picker */
|
||||
.emoji-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}
|
||||
.emoji-cell{font-size:1.9rem;padding:10px 0;border-radius:14px;background:var(--card);
|
||||
border:1px solid var(--line);line-height:1}
|
||||
.emoji-cell:active{background:var(--card2)}
|
||||
.emoji-cell.on{background:var(--accT);border-color:var(--acc)}
|
||||
|
||||
/* big weight input */
|
||||
.bwin{display:flex;align-items:baseline;justify-content:center;gap:8px;margin:18px 0}
|
||||
.bwin input{width:150px;background:none;border:none;outline:none;text-align:right;
|
||||
font-size:3.2rem;font-weight:800;letter-spacing:-.03em;color:var(--txt)}
|
||||
.bwin span{color:var(--mut);font-size:1.2rem;font-weight:600}
|
||||
|
||||
/* ---------- charts ---------- */
|
||||
.chart{width:100%;overflow:hidden}
|
||||
.chart svg{display:block;width:100%;height:auto}
|
||||
|
||||
/* activity heatmap (GitHub-style) */
|
||||
.hm-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;padding-bottom:2px}
|
||||
.hm-wrap::-webkit-scrollbar{display:none}
|
||||
.hm-months{display:flex;margin-left:30px;margin-bottom:4px}
|
||||
.hm-months span{flex:none;width:14px;font-size:.62rem;color:var(--dim);white-space:nowrap;overflow:visible}
|
||||
.hm-body{display:flex}
|
||||
.hm-days{display:flex;flex-direction:column;gap:3px;flex:none;width:30px}
|
||||
.hm-days span{height:11px;font-size:.6rem;color:var(--dim);line-height:11px}
|
||||
.hm-grid{display:flex;gap:3px}
|
||||
.hm-col{display:flex;flex-direction:column;gap:3px}
|
||||
.hm-c{width:11px;height:11px;border-radius:3px;background:var(--bg2);flex:none}
|
||||
.hm-c.l1{background:#33451b}
|
||||
.hm-c.l2{background:#527221}
|
||||
.hm-c.l3{background:#7aa629}
|
||||
.hm-c.l4{background:var(--acc)}
|
||||
.hm-c.today{outline:1.5px solid var(--txt);outline-offset:-1.5px}
|
||||
.hm-c.future{opacity:.28}
|
||||
.hm-legend{display:flex;align-items:center;gap:4px;justify-content:flex-end;margin-top:8px;
|
||||
font-size:.65rem;color:var(--dim)}
|
||||
.hm-legend .hm-c{width:10px;height:10px}
|
||||
|
||||
/* stat tiles */
|
||||
.tiles{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-bottom:14px}
|
||||
.tile{background:var(--card);border:1px solid var(--line);border-radius:var(--r);padding:14px}
|
||||
.tile .v{font-size:1.45rem;font-weight:800;letter-spacing:-.02em;margin-top:2px}
|
||||
.tile .l{color:var(--mut);font-size:.72rem;font-weight:600;text-transform:uppercase;letter-spacing:.06em}
|
||||
|
||||
/* PR badge */
|
||||
.pr{display:inline-flex;align-items:center;gap:4px;background:rgba(251,191,36,.15);color:var(--gold);
|
||||
border-radius:99px;padding:3px 10px;font-size:.72rem;font-weight:700}
|
||||
|
||||
/* toast */
|
||||
#toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(100px + var(--sab));z-index:200;
|
||||
background:var(--card2);border:1px solid var(--line);border-radius:99px;padding:10px 20px;
|
||||
font-size:.88rem;font-weight:600;box-shadow:0 8px 24px rgba(0,0,0,.5);
|
||||
opacity:0;pointer-events:none;transition:opacity .25s}
|
||||
#toast.show{opacity:1}
|
||||
|
||||
/* misc */
|
||||
.empty{text-align:center;color:var(--mut);padding:34px 16px;font-size:.9rem;line-height:1.5}
|
||||
.empty .ico{font-size:2.4rem;margin-bottom:10px}
|
||||
.divider{height:1px;background:var(--line);margin:12px 0}
|
||||
.capitalize{text-transform:capitalize}
|
||||
h4.sec{font-size:.8rem;text-transform:uppercase;letter-spacing:.08em;color:var(--mut);margin:20px 0 10px;font-weight:700}
|
||||
.steps-list{padding-left:20px;color:var(--mut);font-size:.9rem;line-height:1.55;display:flex;flex-direction:column;gap:8px}
|
||||
@@ -0,0 +1,31 @@
|
||||
/* GymLog service worker — network-first for app shell, cache-first for media */
|
||||
const CACHE = 'gymlog-v5';
|
||||
const SHELL = ['./', 'index.html', 'style.css?v=5', 'app.js?v=5', 'data.js?v=5', 'manifest.json'];
|
||||
|
||||
self.addEventListener('install', e => {
|
||||
e.waitUntil(caches.open(CACHE).then(c => c.addAll(SHELL)).then(() => self.skipWaiting()));
|
||||
});
|
||||
self.addEventListener('activate', e => {
|
||||
e.waitUntil(caches.keys().then(keys =>
|
||||
Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))
|
||||
).then(() => self.clients.claim()));
|
||||
});
|
||||
self.addEventListener('fetch', e => {
|
||||
const url = new URL(e.request.url);
|
||||
if (e.request.method !== 'GET' || url.origin !== location.origin) return;
|
||||
if (url.pathname.startsWith('/api/')) return; // auth/data requests: never cache
|
||||
const isMedia = url.pathname.includes('/img/') || url.pathname.includes('/gif/');
|
||||
if (isMedia) {
|
||||
// cache-first: exercise images never change
|
||||
e.respondWith(caches.open(CACHE).then(c => c.match(e.request).then(hit =>
|
||||
hit || fetch(e.request).then(res => { if (res.ok) c.put(e.request, res.clone()); return res; })
|
||||
)));
|
||||
} else {
|
||||
// network-first: shell updates propagate, offline falls back to cache
|
||||
e.respondWith(fetch(e.request).then(res => {
|
||||
if (res.ok) caches.open(CACHE).then(c => c.put(e.request, res.clone()));
|
||||
return res;
|
||||
}).catch(() => caches.match(e.request, { ignoreSearch: false })
|
||||
.then(hit => hit || caches.match('index.html'))));
|
||||
}
|
||||
});
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
# Holt die Übungs-Bilder (JPG) und Animationen (GIF) aus dem Upstream-Dataset.
|
||||
# Nicht im Repo, weil ~140 MB Binärdaten und 1:1 aus hasaneyldrm/exercises-dataset.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
git clone --depth 1 https://github.com/hasaneyldrm/exercises-dataset "$tmp"
|
||||
mkdir -p app/img app/gif
|
||||
cp "$tmp"/images/*.jpg app/img/
|
||||
cp "$tmp"/videos/*.gif app/gif/
|
||||
echo "OK: $(ls app/img | wc -l) Bilder, $(ls app/gif | wc -l) GIFs"
|
||||
Reference in new issue
Block a user