Repository navigation
feat: IIIF manifest metadata resolver and getMapMeta iiif - #147
Merged
Merged
Conversation
Add src/iiif/manifest.ts, a set of pure functions (no network, no DOM) that read a IIIF Presentation 2/3 manifest and pick the values to copy into a map's metadata keys: listIiifCanvases, proposeIiifBindings, resolveIiifMetadata, compareIiifCopy, iiifRightsToLicense, and the IIIF_BINDABLE_KEYS table. HTML values go through a sanitizer passed in by the caller. Add a "iiif" profile to sanitizeHtml (tags/attributes from sanitize-allowlist.json, links get target/rel, href limited to http(s)) and export sanitizeIiifHtml. getMapMeta now returns an optional `iiif` entry (manifest, canvas, image, copiedAt, display, metadata) when the map data has a `iiif` section. The viewer never fetches the manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Niigata map now carries metadata copied from the NDL manifest (produced by resolveIiifMetadata with sanitizeIiifHtml), and a second entry of the same map shows the default "hidden" display. The demo section shows the copied values, the full metadata table, a try-out of the resolver and comparison functions, and how malicious values are sanitized. The e2e checks the table, the display setting and that no manifest is requested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tadata entries
- @maplat/core/common now exports sanitizeIiifHtml, the MapMetaIiif type
and the isIiifMetadataEntry guard.
- When a map is loaded, iiif.copiedMetadata entries that are not
{ from: "manifest" | "canvas", label: Localized, value: Localized }
are dropped, with one console.warn per map, so getMapMeta().iiif.metadata
only contains well-formed entries.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- proposeIiifBindings proposes only title, attr, license and description, and only when the chosen source has the property. Data attribution and data license are no longer filled from the image's values by default. - resolveIiifMetadata tells "missing" from "unreadable" in its warnings, and no longer recurses into nested arrays (deeply nested or cyclic values no longer throw). - isIiifMetadataEntry rejects array labels and values. - Test that the iiif forbidContents list matches DOMPurify's default minus thead. - Docs: sanitizeIiifHtml, MapMetaIiif and isIiifMetadataEntry are available from @maplat/core/common. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kochizufan
force-pushed
the
dec26/m13-t3-iiif-metadata
branch
from
October 28, 2026 15:52
c3f59bc to
5d7c84d
Compare
kochizufan
marked this pull request as ready for review
October 28, 2026 16:56
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.
Summary
src/iiif/manifest.ts(new): pure functions to read a IIIF Presentation 2/3 manifest without fetching it and without touching the DOM:listIiifCanvases,proposeIiifBindings,resolveIiifMetadata,compareIiifCopy,iiifRightsToLicense, theIIIF_BINDABLE_KEYStable (metadata key → IIIF property) andIIIF_METADATA_DISPLAY_DEFAULT("hidden"). It is not exported fromsrc/index; authoring tools import it from@maplat/core/src/iiif/manifest.sanitizeHtml(dirty, { profile: "iiif" })andsanitizeIiifHtml: a narrower allowlist kept insanitize-allowlist.json(a b br i p small span sub sup,hrefonly, http(s) links gettarget="_blank"andrel="noopener noreferrer").sanitizeIiifHtmlneedswindow(DOMPurify), so call it in the browser / renderer. The defaultsanitizeHtmlbehaviour is unchanged.@maplat/core/commonexportssanitizeIiifHtml, theMapMetaIiiftype and theisIiifMetadataEntryguard.getMapMetareturns an optionaliiifentry (manifest,canvas,image,copiedAt,display,metadata) when the map data has aiiifsection.displaycomes from the app settingiiifMetadata("all"/"hidden", default"hidden").proposeIiifBindingsproposes onlytitle,attr,licenseanddescription, and only when the manifest has the property. MalformedcopiedMetadataentries are dropped with one warning per map. The viewer never fetches the manifest.Test plan
pnpm run typecheckpnpm exec vitest run(51 files, 972 passed, 1 skipped, after rebasing onto the current base)node_modules/.bin/eslint src spec(0 errors)playwright testwith the CI config (76 passed, 1 skipped, after the rebase);e2e/iiif-image.spec.tscovers the metadata table and that no manifest is requesteddist/rebuilt (pnpm run buildleavesgit status --short distempty)node scripts/verify-demo-content.js🤖 Generated with Claude Code