From 995bc26f57b6854c5ebb883276ca6ef77828729a Mon Sep 17 00:00:00 2001 From: lorinjameson Date: Wed, 13 Nov 2024 16:44:59 -0500 Subject: [PATCH 1/4] WIP --- generate-iiif-3-manifests.ts | 88 ++++++++++--------- .../EventViewer/AnnotationUI/TagFilter.tsx | 12 +-- 2 files changed, 55 insertions(+), 45 deletions(-) diff --git a/generate-iiif-3-manifests.ts b/generate-iiif-3-manifests.ts index 15b7a11..4ef70e8 100644 --- a/generate-iiif-3-manifests.ts +++ b/generate-iiif-3-manifests.ts @@ -19,7 +19,7 @@ export const createAnnotationPage = ( pageId: string, targetCanvas: string, id: string, - avFile: string + timeOffset: number ) => { let output: AnnotationPage[] = []; // Iterate all annotations and look for this event @@ -58,7 +58,9 @@ export const createAnnotationPage = ( motivation: ['commenting', 'tagging'], }, ], - target: `${avFile}#t=${annotation.start_time},${annotation.end_time}`, + target: `${targetCanvas}#t=${timeOffset + annotation.start_time},${ + timeOffset + annotation.end_time + }`, }; annotation.tags.forEach((tag) => { @@ -126,21 +128,27 @@ export const createManifest = ( const eventId = `${siteURL}/${snakeCase( eventData.label - )}/canvas-${canvasCount}/canvas`; + )}/canvas/${canvasCount}`; let pageCount = 1; + const avFiles = []; + let duration = 0; for (const [_key, avFile] of Object.entries( eventData.audiovisual_files )) { - const type = mime.lookup(avFile.file_url); - const event: Canvas = { - id: eventId, - type: 'Canvas', - duration: avFile.duration, - annotations: [], - items: [], - }; - + avFiles.push(avFile); + duration += avFile.duration; + } + const event: Canvas = { + id: eventId, + type: 'Canvas', + duration: duration, + annotations: [], + items: [], + }; + + let timeOffset = 0; + avFiles.forEach((avFile) => { const annos = createAnnotationPage( dataDir, siteURL, @@ -152,8 +160,9 @@ export const createManifest = ( }`, eventId, `${eventId}/page${pageCount}`, - avFile.file_url + timeOffset ); + timeOffset += avFile.duration; if (annos.length > 0) { if (allowSubPages === 'true' || allowSubPages === 'TRUE') { @@ -182,37 +191,36 @@ export const createManifest = ( ...annos, ]; } + } - event.items?.push({ - id: `${siteURL}/${snakeCase( - eventData.label - )}-canvas${canvasCount}/paintings`, - type: 'AnnotationPage', - items: [ - { - id: `${siteURL}/${snakeCase( - eventData.label - )}-canvas${canvasCount}/paintings`, - type: 'Annotation', - motivation: 'painting', - body: { - id: avFile.file_url, - type: eventData.item_type === 'Audio' ? 'Sound' : 'Video', - format: type ? type : 'unknown', - }, - target: `${siteURL}/${snakeCase( - `${eventData.label}` - )}-canvas${canvasCount}`, + event.items?.push({ + id: `${siteURL}/${snakeCase( + eventData.label + )}-canvas${canvasCount}/paintings`, + type: 'AnnotationPage', + items: [ + { + id: `${siteURL}/${snakeCase( + eventData.label + )}-canvas${canvasCount}/paintings`, + type: 'Annotation', + motivation: 'painting', + body: { + id: avFile.file_url, + type: eventData.item_type === 'Audio' ? 'Sound' : 'Video', + format: mime.contentType(avFile.file_url) || 'unknown', + duration: avFile.duration, }, - ], - }); + target: eventId, + }, + ], + }); - output.items.push(event); - pageCount++; - } - } + output.items.push(event); + pageCount++; + }); + canvasCount++; } - canvasCount++; }); writeFileSync( diff --git a/src/components/EventViewer/AnnotationUI/TagFilter.tsx b/src/components/EventViewer/AnnotationUI/TagFilter.tsx index 010cdfc..e464542 100644 --- a/src/components/EventViewer/AnnotationUI/TagFilter.tsx +++ b/src/components/EventViewer/AnnotationUI/TagFilter.tsx @@ -44,18 +44,20 @@ const TagFilter = (props: TagFilterProps) => { const setsToShow = thisPlayer.sets?.length > 0 - ? props.annotationSets.filter((set) => thisPlayer.sets.includes(set.id)) + ? props.annotationSets.filter((set: any) => + thisPlayer.sets.includes(set.id) + ) : props.annotationSets; - setsToShow.forEach((set) => { - set?.data.annotations.forEach((ann) => { + setsToShow.forEach((set: any) => { + set?.data.annotations.forEach((ann: any) => { if (ann.tags && ann.tags.length) { ann.tags.forEach((tag: { category: string; tag: string }) => { const cat = tag.category.toLowerCase(); tagsObj[cat] ||= { tags: [], color: - tagGroups.find((grp) => grp.category.toLowerCase() === cat) + tagGroups.find((grp: any) => grp.category.toLowerCase() === cat) ?.color || '#FFF', }; if (!tagsObj[cat].tags.includes(tag.tag)) { @@ -105,7 +107,7 @@ const TagFilter = (props: TagFilterProps) => { )} - {props.annotationSets.map((set) => ( + {props.annotationSets.map((set: any) => (
Date: Wed, 13 Nov 2024 17:00:07 -0500 Subject: [PATCH 2/4] WIP --- generate-iiif-3-manifests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate-iiif-3-manifests.ts b/generate-iiif-3-manifests.ts index 4ef70e8..12fd0ff 100644 --- a/generate-iiif-3-manifests.ts +++ b/generate-iiif-3-manifests.ts @@ -208,7 +208,7 @@ export const createManifest = ( body: { id: avFile.file_url, type: eventData.item_type === 'Audio' ? 'Sound' : 'Video', - format: mime.contentType(avFile.file_url) || 'unknown', + format: mime.lookup(avFile.file_url) || 'unknown', duration: avFile.duration, }, target: eventId, From b3200c4582e364f0f600ebc0ed49ebacfea71306 Mon Sep 17 00:00:00 2001 From: lorinjameson Date: Thu, 14 Nov 2024 08:49:37 -0500 Subject: [PATCH 3/4] WIP --- generate-iiif-3-manifests.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/generate-iiif-3-manifests.ts b/generate-iiif-3-manifests.ts index 12fd0ff..30c7f16 100644 --- a/generate-iiif-3-manifests.ts +++ b/generate-iiif-3-manifests.ts @@ -193,6 +193,9 @@ export const createManifest = ( } } + const source = avFile.file_url.split('?'); + const type = mime.lookup(source[0]); + event.items?.push({ id: `${siteURL}/${snakeCase( eventData.label @@ -208,7 +211,7 @@ export const createManifest = ( body: { id: avFile.file_url, type: eventData.item_type === 'Audio' ? 'Sound' : 'Video', - format: mime.lookup(avFile.file_url) || 'unknown', + format: type ? type : 'unknown', duration: avFile.duration, }, target: eventId, From 5148ecd599b35c001d0f2443f4087fbaf8e0063f Mon Sep 17 00:00:00 2001 From: lorinjameson Date: Mon, 18 Nov 2024 16:07:56 -0500 Subject: [PATCH 4/4] Adjusting motivations --- generate-iiif-3-manifests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generate-iiif-3-manifests.ts b/generate-iiif-3-manifests.ts index 30c7f16..090b1aa 100644 --- a/generate-iiif-3-manifests.ts +++ b/generate-iiif-3-manifests.ts @@ -46,7 +46,7 @@ export const createAnnotationPage = ( const item: Annotation = { '@context': 'http://www.w3.org/ns/anno.jsonld', type: 'Annotation', - motivation: 'supplementing', + motivation: ['commenting', 'tagging'], id: id, body: [ { @@ -55,7 +55,7 @@ export const createAnnotationPage = ( .map((n) => Node.string(n)) .join('\n'), format: 'text/plain', - motivation: ['commenting', 'tagging'], + motivation: 'commenting', }, ], target: `${targetCanvas}#t=${timeOffset + annotation.start_time},${