Skip to content

Nest handout R2 assets under handouts/<slug>/#94

Merged
PatrikBak merged 1 commit into
mainfrom
patrik/nest-handout-assets-by-slug
May 13, 2026
Merged

Nest handout R2 assets under handouts/<slug>/#94
PatrikBak merged 1 commit into
mainfrom
patrik/nest-handout-assets-by-slug

Conversation

@PatrikBak
Copy link
Copy Markdown
Owner

Summary

  • Every handout image and PDF on R2 was duplicated once per language (angle-basics-1.cs-1.svg, .sk-1.svg, .en-1.svg — three identical copies). Now both artefact kinds live under handouts/<slug>/<file>, language-neutral, where <slug> is the language-stripped handout id (the .tex file stem, matching the English slug in handouts.json).
  • ImageProcessingConfig swaps FileNamePrefix for an OutputFileName: (imageId, counter) -> string delegate so each caller picks its own scheme. Problem images keep their <slug>-<N>.svg shape unchanged; handout images use the source SVG's natural name (angles-vertical.svg).
  • PDFs join the same folder via UploadHandoutPdfAsync (was UploadPdfToR2Async); the slug-derivation regex and the handouts/ R2 prefix live in single helpers (ToHandoutSlug, ToHandoutR2Key) shared by the image and PDF paths.
  • Frontend getProblemImageUrl('handouts', ...) drops the /images/ segment; getHandoutPdfUrl derives the slug from the filename to build handouts/<slug>/<file>.pdf. All 6 image-bearing handout JSONs regenerated — their three language variants now share an identical contentId set.

…are one set

Previously every image and PDF was uploaded once per language: angle-basics-1.cs-1.svg,
angle-basics-1.sk-1.svg, angle-basics-1.en-1.svg — three byte-identical copies of one
SVG. PDFs lived under handouts/pdfs/, images under handouts/images/, with the language
code and a counter baked into each filename.

Both kinds of artefact now live under handouts/<slug>/<file>, where <slug> is the
language-stripped handout id (the .tex file stem, matching the English slug in
handouts.json). All three language versions of factorization point at the same
factorization/box.svg, factorization/ag-proof.svg, and the main + skeleton PDFs join
them in the same folder.

ImageProcessingConfig swaps FileNamePrefix for an OutputFileName delegate so each
caller picks its own naming scheme; problem images keep their <slug>-<N>.svg shape
unchanged. The handouts CLI derives the slug + R2 key via two small helpers
(ToHandoutSlug, ToHandoutR2Key) shared between the image and PDF paths.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
math-comps Ready Ready Preview, Comment May 13, 2026 3:55pm

@PatrikBak PatrikBak merged commit 126dcb2 into main May 13, 2026
4 checks passed
@PatrikBak PatrikBak deleted the patrik/nest-handout-assets-by-slug branch May 13, 2026 16:04
PatrikBak added a commit that referenced this pull request May 13, 2026
External references to handout PDFs use the old /pdfs/ URLs, so the
nested-by-slug layout from PR #94 broke those links. Restore the flat
handouts/pdfs/<file>.pdf layout for PDFs. Images stay nested under
handouts/<slug>/ since they're only referenced from our own handout JSON.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant