Publish a browser-only demo to GitHub Pages
Self-hosting is a fair ask once someone knows they want the app, but it's a lot to ask of someone deciding whether to look at it at all. A demo build (VITE_DEMO=1) drops the parts that need the backend — passkeys, sync, admin — and boots straight into guest mode with a seeded example profile, so every screen has real data behind it: twelve weeks of Push/Pull/Legs with progression and the odd missed session, twice-weekly weigh-ins trending toward a goal, PRs, and today's session moved onto the current day so there's always something to press Start on. The seed generator is imported dynamically and the demo-only UI folds away at build time, so none of it lands in the bundle self-hosters ship. Exercise media (~140 MB) isn't committed anywhere, so the demo build points VITE_IMG_BASE / VITE_GIF_BASE at the upstream dataset on jsDelivr, pinned to a commit; unset, both still resolve to img/ and gif/ next to the app exactly as before. Deployed by a Pages workflow on every push to main.
This commit is contained in:
1 parent
3c5bcd5957
commit
e9bf38f39b
11 files changed
+281
-15
No files matched your search
@@ -3,6 +3,7 @@ import { useUI } from '../store/useUI.js'
|
||||
import { webauthnOK, passkeyLogin, passkeyRegister, api, BIO } from '../lib/api.js'
|
||||
import { hasData } from '../store/useStore.js'
|
||||
import { t } from '../lib/i18n.js'
|
||||
import { DEMO, REPO } from '../lib/demo.js'
|
||||
import { useState, useRef, useEffect } from 'react'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
import { Button } from '../components/ui.jsx'
|
||||
@@ -47,10 +48,30 @@ export default function Login() {
|
||||
try { const u = await passkeyLogin(); setUser(u); await pullState(); useUI.getState().toast(t('Welcome back, {0}', u.name)) }
|
||||
catch (e) { if (e.name !== 'NotAllowedError' && e.name !== 'AbortError') useUI.getState().toast(e.message || t('Sign-in failed')) }
|
||||
}
|
||||
const head = <>
|
||||
<div style={{ fontSize: 54, display: 'flex', justifyContent: 'center', color: 'var(--acc)' }}><Icon name="dumbbell" /></div>
|
||||
<h1 style={{ fontSize: 34, fontWeight: 700, letterSpacing: '-.028em', margin: '10px 0 4px' }}>openGym</h1>
|
||||
</>
|
||||
const wrap = { display: 'flex', flexDirection: 'column', justifyContent: 'center', minHeight: '78vh', textAlign: 'center' }
|
||||
|
||||
// Demo build: no backend to sign in against — the only way in is the local guest profile.
|
||||
if (DEMO) return (
|
||||
<div className="narrow" style={wrap}>
|
||||
{head}
|
||||
<div className="muted" style={{ marginBottom: 30 }}>{t('Live demo — everything stays in this browser.')}</div>
|
||||
<Button variant="primary" icon="sparkles" onClick={() => setGuest(true)}>{t('Start the demo')}</Button>
|
||||
<div className="card small muted" style={{ textAlign: 'left', marginTop: 16 }}>
|
||||
{t('This demo runs entirely in your browser on example data — nothing is sent anywhere. Passkey sign-in and sync across your devices come with the openGym server, which you get by self-hosting it.')}
|
||||
</div>
|
||||
<div className="dim small" style={{ marginTop: 22, lineHeight: 1.6 }}>
|
||||
<a href={REPO} target="_blank" rel="noopener">{t('Self-host it in a minute →')}</a>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="narrow" style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', minHeight: '78vh', textAlign: 'center' }}>
|
||||
<div style={{ fontSize: 54, display: 'flex', justifyContent: 'center', color: 'var(--acc)' }}><Icon name="dumbbell" /></div>
|
||||
<h1 style={{ fontSize: 34, fontWeight: 700, letterSpacing: '-.028em', margin: '10px 0 4px' }}>openGym</h1>
|
||||
<div className="narrow" style={wrap}>
|
||||
{head}
|
||||
<div className="muted" style={{ marginBottom: 34 }}>{t('Your workouts. Your weights. Your profile.')}</div>
|
||||
{webauthnOK() ? <>
|
||||
<Button variant="primary" icon="person" onClick={signIn}>{t('Sign in with passkey')}</Button>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { ACCENTS, todayISO, localTZ } from '../lib/format.js'
|
||||
import { webauthnOK, passkeyLogin, passkeyRegister, IS_ANDROID } from '../lib/api.js'
|
||||
import { pushSupported, enablePush, disablePush, sendTestPush } from '../lib/push.js'
|
||||
import { t, LANGS, INSTR_LANGS } from '../lib/i18n.js'
|
||||
import { DEMO, REPO } from '../lib/demo.js'
|
||||
import { loadStarterPlan, confirmSheet } from '../sheets.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
import { Section, Row, SelectRow, Switch, Segmented, Button, TextField } from '../components/ui.jsx'
|
||||
@@ -14,7 +15,7 @@ export default function Settings() {
|
||||
const nav = useNavigate()
|
||||
const S = useStore(s => s.S)
|
||||
const user = useStore(s => s.user)
|
||||
const { update, replaceState, setUser, pullState, pushState, signOut } = useStore()
|
||||
const { update, replaceState, setUser, pullState, pushState, signOut, resetDemo } = useStore()
|
||||
const toast = useUI(s => s.toast)
|
||||
const fileRef = useRef(null)
|
||||
|
||||
@@ -47,9 +48,15 @@ export default function Settings() {
|
||||
<div style={{ flex: 1, marginLeft: 10 }}><h1>{t('Settings')}</h1></div>
|
||||
</div>
|
||||
|
||||
{/* ---------- account ---------- */}
|
||||
<Section title={t('Account')}>
|
||||
{user ? <>
|
||||
{/* ---------- account (demo builds have nothing to sign in to) ---------- */}
|
||||
<Section title={DEMO ? t('Demo') : t('Account')}>
|
||||
{DEMO ? <>
|
||||
<Row icon="sparkles" iconTint="var(--acc)" title={t('You’re in the demo')} subtitle={t('Example data, stored only in this browser — change anything you like.')} />
|
||||
<Row icon="reset" iconTint="var(--blue)" title={t('Reset demo data')} accessory="chevron"
|
||||
onClick={() => confirmSheet({ title: t('Reset demo data?'), message: t('Puts the example plan, workouts and weigh-ins back the way they started.'), confirmText: t('Reset'), onConfirm: () => { resetDemo(); nav('/home'); toast(t('Demo data reset')) } })} />
|
||||
<Row icon="rocket" iconTint="var(--indigo)" title={t('Self-host openGym')} subtitle={t('Passkey sign-in, sync across your devices, your own data.')} accessory="chevron"
|
||||
onClick={() => window.open(REPO, '_blank', 'noopener')} />
|
||||
</> : user ? <>
|
||||
<Row icon="personCircle" iconTint="var(--grey)" title={user.name} subtitle={t('Signed in with passkey — data syncs to this profile.')} />
|
||||
{user.admin && <Row icon="wrench" iconTint="var(--indigo)" title={t('Admin dashboard')} accessory="chevron" onClick={() => nav('/admin')} />}
|
||||
<Row icon="signOut" iconTint="var(--red)" title={t('Sign out')} danger onClick={() => confirmSheet({ title: t('Sign out?'), message: t('Your data is synced to your profile first, then cleared from this device.'), confirmText: t('Sign out'), danger: true, onConfirm: () => { signOut(); nav('/home') } })} />
|
||||
@@ -60,10 +67,10 @@ export default function Settings() {
|
||||
<Row icon="lock" iconTint="var(--grey)" title={t('Passkeys not supported in this browser.')} />
|
||||
)}
|
||||
</Section>
|
||||
{!user && <p className="sect-f" style={{ marginTop: -18, marginBottom: 22 }}>{t('Guest mode — data lives only in this browser.')}</p>}
|
||||
{!user && !DEMO && <p className="sect-f" style={{ marginTop: -18, marginBottom: 22 }}>{t('Guest mode — data lives only in this browser.')}</p>}
|
||||
|
||||
{/* ---------- appearance ---------- */}
|
||||
<Section title={t('Appearance')} footer={t('synced with your profile')}>
|
||||
<Section title={t('Appearance')} footer={DEMO ? undefined : t('synced with your profile')}>
|
||||
<SelectRow
|
||||
icon="globe" iconTint="var(--blue)" title={t('Language')}
|
||||
value={S.lang || 'en'} onChange={v => update(s => { s.lang = v })}
|
||||
|
||||
Reference in new issue
Block a user