Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Printed routine: the rep range, the drop-set or rest-pause, and the body part translated as its own word
Duarte Santos5f884b17e632
diff --git a/frontend/src/lib/plan-print.test.js b/frontend/src/lib/plan-print.test.jsindex b4ba73036..35284f433 100644--- a/frontend/src/lib/plan-print.test.js+++ b/frontend/src/lib/plan-print.test.js@@ -69,3 +69,29 @@ describe('planPrintHTML exercise-name casing per language', () => {})}})++// QA 1.3.9: the printout read "3 × 12" for an 8–12 range, left the drop-set out, and glued an+// untranslated body part onto the name ("…Curlupper Legs").+describe('planPrintHTML prints the exercise as it is prescribed', () => {+ const S2 = {+ unit: 'kg', week: {},+ routines: [{ id: 'r', name: 'Legs', ex: [+ { id: '0025', sets: 3, mode: 'reps', reps: 12, repsMin: 8, weight: 60, intensifier: { type: 'dropset', count: 2, pct: 20 } },+ { id: '0027', sets: 1, mode: 'reps', reps: 8, weight: 40, intensifier: { type: 'restpause', totalReps: 20, restSec: 15 } },+ ] }],+ }+ afterEach(() => _setLangState('en', {}, null, null))++ it('keeps the rep range and names the intensifier', () => {+ const body = text(planPrintHTML(S2, '', { routineId: 'r' }))+ expect(body).toContain('3 × 8–12 · 60 kg · Drop-set 2× −20%')+ expect(body).toContain('1 × 8 · 40 kg · Rest-pause 20 reps')+ })++ it('translates the body part and keeps it a separate word', () => {+ _setLangState('de', { chest: 'Brust', 'Drop-set': 'Dropsatz' }, null, null)+ const html = planPrintHTML(S2, '', { routineId: 'r' })+ expect(html).toContain(' <span class="part">Brust</span>')+ expect(text(html)).toContain('Dropsatz 2×')+ })+})diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.jsindex ca3f12413..6f21134d4 100644--- a/frontend/src/lib/plan-share.js+++ b/frontend/src/lib/plan-share.js@@ -10,9 +10,9 @@import { EXIDX, isBodyweightEq } from './exercises.js'import { cleanUrl } from './media-refs.js'-import { modeOf, fmtSec, isBw, isPerSide, sideReps, MAX_PLANNED_WARMUPS } from './history.js'+import { modeOf, exLine, MAX_PLANNED_WARMUPS } from './history.js'import { deriveSessionName } from './session-merge.js'-import { uid, todayISO, DAYN, weekOrder, weekStartOf, fmtNum, exCount } from './format.js'+import { uid, todayISO, DAYN, weekOrder, weekStartOf, exCount } from './format.js'import { t, exerciseNameFor, exerciseNameClass, getLang, RTL_LANGS } from './i18n-core.js'import { convertWeight } from './units.js'import { fmtSpeed, speedUnitOf } from './speed.js'@@ -296,8 +296,10 @@ export function mergePlan(s, bundle, { schedule } = {}) {const esc = str => String(str == null ? '' : str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')-// One exercise's scheme, e.g. "3 × 10 · 60 kg", "3 × 0:45" or "2 × 20 min @ 8 km/h" — the speed-// in the profile's unit (lib/speed.js), like the weight.+// One exercise's scheme, e.g. "3 × 8–12 · 60 kg · drop-set 1× −20%", "3 × 0:45" or+// "2 × 20 min @ 8 km/h" — the speed in the profile's unit (lib/speed.js), like the weight. The+// reps half is exLine's, so a double-progression range prints as the range it is ("8–12", not+// the top alone) and a per-side split reads "8/side" exactly as the routine editor shows it.function scheme(e, unit, speedUnit) {const sets = e.sets || 1const mode = modeOf(e)@@ -305,11 +307,19 @@ function scheme(e, unit, speedUnit) {const body = `${e.min || 20} min @ ${fmtSpeed(e.speed || 8, speedUnit)}`return sets > 1 ? `${sets} × ${body}` : body}- let s = mode === 'time' ? `${sets} × ${fmtSec(e.sec || 45)}` : `${sets} × ${e.reps ?? 10}`- if (e.weight) s += ` · ${isBw(e) ? '+' : ''}${fmtNum(e.weight)} ${unit}`- // A printed plan is read at the rack, so the split earns its four characters.- if (mode !== 'time' && isPerSide(e)) s += ` · ${t('{0}/side', fmtNum(sideReps(e.reps ?? 10)))}`- return s+ const line = exLine({ ...e, reps: e.reps ?? 10 }, unit, speedUnit)+ const intens = intensifierLine(e.intensifier)+ return intens ? `${line} · ${intens}` : line+}++// A drop-set or rest-pause is how the exercise is prescribed, so the printout names it — the+// sheet at the rack otherwise reads as plain straight sets.+function intensifierLine(x) {+ const intens = cleanIntensifier(x)+ if (!intens) return ''+ return intens.type === 'dropset'+ ? `${t('Drop-set')} ${intens.count}× −${intens.pct}%`+ : `${t('Rest-pause')} ${intens.totalReps} ${t('reps')}`}// Group consecutive exercises sharing a superset id into rendered units.@@ -330,7 +340,9 @@ function routineHTML(r, unit, { bare = false, speedUnit } = {}) {const items = u.map(e => {const ex = EXIDX[e.id]const name = ex ? exerciseNameFor(ex) : t('Unknown exercise')- const part = ex && ex.bp && ex.bp !== 'cardio' ? `<span class="part">${esc(ex.bp)}</span>` : ''+ // Translated, and set apart by a real space: glued to the name, "capitalize" read the two as+ // one word and printed "Curlupper Legs".+ const part = ex && ex.bp && ex.bp !== 'cardio' ? ` <span class="part">${esc(t(ex.bp))}</span>` : ''const note = e.note ? `<div class="ex-note">${esc(e.note)}</div>` : ''return `<div class="ex"><div class="ex-row"><div class="ex-n ${ex ? exerciseNameClass(ex) : ''}">${esc(name)}${part}</div><div class="ex-s">${esc(scheme(e, unit, speedUnit))}</div></div>${note}</div>`}).join('')@@ -411,7 +423,8 @@ export function planPrintHTML(S, owner, { routineId } = {}) {.ex-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }.ex-n { font-weight: 500; }.ex-n.capitalize { text-transform: capitalize; }- .ex-n .part { text-transform: capitalize; color: #9aa0ae; font-weight: 400; font-size: 12px; margin-inline-start: 8px; }+ .ex-n .part { display: inline-block; text-transform: none; color: #9aa0ae; font-weight: 400; font-size: 12px; margin-inline-start: 4px; }+ .ex-n .part::first-letter { text-transform: uppercase; }.ex-s { color: #3d424e; white-space: nowrap; font-variant-numeric: tabular-nums; }.ex-note { color: #6a7080; font-size: 12px; margin-top: 2px; }.ex.empty, .none { color: #a2a8b6; }