Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore IIIF choice annotations on in-page figures #995

Merged
merged 5 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/11ty/_includes/components/figure/image/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import { html } from '#lib/common-tags/index.js'
* @return {String} HTML containing a `figureImageElement`, a caption and annotations UI
*/
export default function (eleventyConfig) {
const annotationsUI = eleventyConfig.getFilter('annotationsUI')
const figureCaption = eleventyConfig.getFilter('figureCaption')
const figureImageElement = eleventyConfig.getFilter('figureImageElement')
const figureLabel = eleventyConfig.getFilter('figureLabel')
const figureModalLink = eleventyConfig.getFilter('figureModalLink')

return async function (figure) {
const {
annotations,
caption,
credit,
id,
Expand All @@ -24,18 +26,25 @@ export default function (eleventyConfig) {
} = figure

const labelElement = figureLabel({ id, label, isSequence })
const interactive = (annotations ?? []).length > 0

/**
* Wrap image in modal link
*/
let imageElement = figureImageElement(figure, { interactive: false })
* Construct the HTML figure:
* - Wrap image in modal link
* - Add caption
* - Add optional annotations UI
**/

mphstudios marked this conversation as resolved.
Show resolved Hide resolved
let imageElement = figureImageElement(figure, { interactive })
imageElement = figureModalLink({ content: imageElement, id })

const captionElement = figureCaption({ caption, content: labelElement, credit })
const annotationsUIElement = !isSequence ? annotationsUI({ figure, lightbox: true }) : ''

return html`
${imageElement}
${captionElement}
${annotationsUIElement}
`
}
}
5 changes: 3 additions & 2 deletions packages/11ty/_plugins/figures/annotation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const logger = chalkFactory('Figures:Annotation')
*/
export default class Annotation {
constructor (figure, data) {
const { annotationCount, iiifConfig, outputDir, outputFormat, src: figureSrc, zoom } = figure
const { annotationCount, iiifConfig, outputDir, outputFormat, printImage, src: figureSrc, zoom } = figure
const { baseURI, tilesDirName } = iiifConfig
const { label, region, selected, src, text } = data
const { base, name } = src ? path.parse(src) : {}
Expand Down Expand Up @@ -75,7 +75,8 @@ export default class Annotation {
const uri = () => {
switch (true) {
case isImageService:
return info()
// NB: Annotations for imageServices are *max jpeg*s not the service endpoint
mphstudios marked this conversation as resolved.
Show resolved Hide resolved
return path.join(outputDir, name, printImage)
default:
try {
return new URL(path.join(baseURI, outputDir, base)).href
Expand Down
14 changes: 12 additions & 2 deletions packages/11ty/_plugins/figures/iiif/manifest/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# IIIF Manifests
The `Manifest` module accepts a `Figure` instance and provides `toJSON()` and `write()` methods for generating and writing a IIIF manifest.
The `Manifest` module accepts a `Figure` instance and provides `toJSON()` and `write()` methods for generating and writing a IIIF Presentation API manifest.

## Figures Data to IIIF Schema Details
Manifests are generated for figures:
- with `zoom: true`
- with annotations (see below)
- with sequences

### Manifests
Each manifest contains a Canvas annotated with an AnnotationPage whose items contain at least one Annotation with `motivation:painting`, whose `service` key points to the Service data for quire's IIIF Image API level 0 implementation.

IDs for the Canvas and AnnotationPage are mostly just used for internal routing (eg, passing a manifest and canvas ID to display to canvas-panel) and do not provide JSON responses, but note that by community convention painting Annotations must use image-returning URLs even if these URLs are disgarded in favor of using the IIIF Service for image delivery. Quire uses the print-image.jpg as the ID for this canvas.

## Features
### Annotations
An `annotation` adds additional information (for example an image) to a canvas.

Expand Down