Repository navigation
fix(web): link the source name for nested and flat source metadata - #853
Merged
Merged
Conversation
A nested `source: { name, url }` block was not rendered at all, and the
flat `source.name` / `source.url` keys showed up as two separate pills.
Both forms now go through the cooklang metadata parser, like a plain
`source` value, and render one source pill with the name linked to the
URL. Menus no longer repeat `source.*` keys as custom metadata. Names
are HTML-escaped and URLs that are not http(s) are never links.
Closes cooklang#848
Co-authored-by: Codex <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
|
Thanks, this is a clean fix. The flat |
Contributor
Author
|
Thanks! Agreed, the parser is the right place for it. Once cooklang-rs#159 is released, I'm happy to open the follow-up that drops the fallback in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #848
What changes
sourcemetadata now renders the same way in every form, on recipe and menu pages and in both server and static mode:source:with nestednameandurlsource.name+source.urlsource: Some bookorsource: https://…src/web/builders.rs: a smallsource_metadatahelper readssourcewith cooklang'sas_name_and_url(so the nested mapping, a plain string andName <url>are all handled by the parser), then falls back to the flatsource.name/source.urlkeys. Recipes and menus both use it. Menus now skipsource.*keys in the custom metadata pills, as recipes already did.templates/source_metadata.html: the shared source pill, included byrecipe.htmlandmenu.htmlin place of the two duplicated blocks. Askama escapes the name, and the existingis_web_urlfilter decides whether the URL becomes a link, so ajavascript:URL stays plain text.Tests
tests/source_metadata_test.rs: 5 tests that build real recipe and menu pages (server and static mode) from metadata and check the rendered pill: nested, flat, name only, URL only, plain text / plain URL, and escaping (an<img onerror>tag as the name, ajavascript:URL), for both the nested and the flat form.--no-default-features.cargo fmt --all -- --check,cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo test --workspace(1909 passed, 0 failed) andcargo test --no-default-features(491 passed, 0 failed).I didn't add a CHANGELOG entry, since release-please builds it from the commit message.
This was implemented with OpenAI Codex, then reviewed and re-tested with Claude Code.
🤖 Generated with Claude Code