fix(build): a single file of a kind is taken whatever it is called, and a file that is not used is said (#94)
Closes #94.
On the build page, picking a video did nothing unless the file was called exactly what the source calls it. Now a single file of the right kind is taken whatever it is called, and a file that is not used is said, with why.
What changes
- One rule for both pages, in
build-source.ts'smatchNamed, whichmatchFilesis for files and the play page'slinksForis for addresses: by name first; then, where one path of a kind (.mp4) is left without its file and one chosen file of that kind is left without a path, that is its file. With more of a kind on either side, names decide as before. The play page's own copy of the rule is gone; it uses this one. - The row says which file was taken where its name is not the source's: "chosen: IMG_0042.mp4, 2.1 MB".
- A file picked again for that path replaces the one before, whether either is called as the source calls it or not.
- A picked file that no path takes is said under the list: "notes.pdf is not used: the source names no file of that kind.", or, with several of a kind, that each has to be called as the source calls it.
- The step's line says so too: "Each is matched by its name, and a single file of a kind fits whatever it is called."
Testing
By hand, as this repository has no page tests: the built site served locally, a source that names walkthrough.mp4, files picked through the page's own field.
| Picked | Before (the live page) | Now |
|---|---|---|
IMG_0042.mp4 | "not chosen yet", nothing said; Build: "The source has 1 problem" | "chosen: IMG_0042.mp4, 2.1 MB"; Build: built, 6.3 MB, plays |
then second take.mp4 | replaces it | |
then notes.pdf | "notes.pdf is not used: the source names no file of that kind." | |
then walkthrough.mp4 | "chosen, 2.1 MB" | "chosen, 2.1 MB", and the one before goes |
| two unnamed videos at once | neither taken, and why is said |
- The play page, framed, with the four card behaviours of #93: unchanged (one save for one press, one
built, no restart; an old card's file under another name still builds). - An address given to the play page under another name (
IMG_0042.mp4forwalkthrough.mp4) plays at once; under another kind (.mp3) it is not taken, and the file is asked for. - No page error.
pnpm buildandpnpm typecheckpass. Screenshots of the Files step looked at.
Not verified
- Chromium only.
- A source that names several files of one kind was not run through the page; the rule leaves those to their names, as before.
Summary by cubic
Fixes the build page so a single file of the right kind is taken whatever it's called, and files that end up unused are explained.
The build page only matched picked files to source paths when names were identical, so a video named by a camera or chat stayed "not chosen yet" and no reason was given. One rule now lives in build-source.ts's matchFiles, used by both the build and play pages: match by name first, then a single file of a kind fits a single path of that kind.
- Rows name the file taken when its name differs from the source's.
- A file picked again for the same path replaces the previous one.
- Picked files no path takes are listed with the reason.
- The play page now uses the shared rule instead of its own copy.