From 8c2e3999d8f0ab04c34568aee0d243510af3d6bf Mon Sep 17 00:00:00 2001 From: Chris Hallberg Date: Thu, 12 Dec 2024 17:42:01 -0500 Subject: [PATCH 1/3] feat(embed): move /uv.html to options.embedTemplate for easier embedding when uv.html isn't in webroot. --- .../uv-aleph-extension/Extension.ts | 11 +++++++--- .../uv-aleph-extension/config/config.json | 2 +- .../extensions/uv-av-extension/Extension.ts | 15 +++++++++++--- .../uv-av-extension/config/config.json | 2 +- .../uv-default-extension/Extension.ts | 14 ++++++++++--- .../uv-default-extension/config/config.json | 2 +- .../uv-ebook-extension/Extension.ts | 12 ++++++++--- .../uv-ebook-extension/config/config.json | 2 +- .../uv-mediaelement-extension/Extension.ts | 14 ++++++++++--- .../config/config.json | 2 +- .../uv-model-viewer-extension/Extension.ts | 14 ++++++++++--- .../config/config.json | 2 +- .../uv-openseadragon-extension/Extension.ts | 20 +++++++++++++++---- .../config/config.json | 2 +- .../extensions/uv-pdf-extension/Extension.ts | 14 ++++++++++--- .../uv-pdf-extension/config/config.json | 2 +- .../modules/uv-shared-module/BaseExtension.ts | 9 ++------- src/uv-iiif-config.json | 5 +++++ 18 files changed, 104 insertions(+), 40 deletions(-) diff --git a/src/content-handlers/iiif/extensions/uv-aleph-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-aleph-extension/Extension.ts index 75bf2f9c0..88bfa1916 100644 --- a/src/content-handlers/iiif/extensions/uv-aleph-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-aleph-extension/Extension.ts @@ -121,16 +121,21 @@ export default class Extension } getEmbedScript(template: string, width: number, height: number): string { + const hashParams = new URLSearchParams({ + manifest: this.helper.manifestUri, + }); + const appUri: string = this.getAppUri(); - const title: string = this.helper.getLabel() || ""; - const iframeSrc: string = `${appUri}#?manifest=${this.helper.manifestUri}`; + const title: string = this.helper.getLabel() ?? ""; const script: string = Strings.format( template, - iframeSrc, + appUri, + hashParams.toString(), width.toString(), height.toString(), title ); + return script; } } diff --git a/src/content-handlers/iiif/extensions/uv-aleph-extension/config/config.json b/src/content-handlers/iiif/extensions/uv-aleph-extension/config/config.json index f53a7097f..3151d013c 100644 --- a/src/content-handlers/iiif/extensions/uv-aleph-extension/config/config.json +++ b/src/content-handlers/iiif/extensions/uv-aleph-extension/config/config.json @@ -239,7 +239,7 @@ "options": { "embedEnabled": true, "shareEnabled": true, - "embedTemplate": "", + "embedTemplate": "", "instructionsEnabled": false, "shareFrameEnabled": true, "shareManifestsEnabled": true, diff --git a/src/content-handlers/iiif/extensions/uv-av-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-av-extension/Extension.ts index 2319b82f7..46bc548ca 100644 --- a/src/content-handlers/iiif/extensions/uv-av-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-av-extension/Extension.ts @@ -149,16 +149,25 @@ export default class Extension } getEmbedScript(template: string, width: number, height: number): string { + const hashParams = new URLSearchParams({ + manifest: this.helper.manifestUri, + c: this.helper.collectionIndex.toString(), + m: this.helper.manifestIndex.toString(), + cv: this.helper.canvasIndex.toString(), + rid: this.helper.rangeId?.toString() ?? "" + }); + const appUri: string = this.getAppUri(); - const title: string = this.helper.getLabel() || ""; - const iframeSrc: string = `${appUri}#?manifest=${this.helper.manifestUri}&c=${this.helper.collectionIndex}&m=${this.helper.manifestIndex}&cv=${this.helper.canvasIndex}&rid=${this.helper.rangeId}`; + const title: string = this.helper.getLabel() ?? ""; const script: string = Strings.format( template, - iframeSrc, + appUri, + hashParams.toString(), width.toString(), height.toString(), title ); + return script; } diff --git a/src/content-handlers/iiif/extensions/uv-av-extension/config/config.json b/src/content-handlers/iiif/extensions/uv-av-extension/config/config.json index ab32b2ed9..8064cca57 100644 --- a/src/content-handlers/iiif/extensions/uv-av-extension/config/config.json +++ b/src/content-handlers/iiif/extensions/uv-av-extension/config/config.json @@ -283,7 +283,7 @@ "options": { "embedEnabled": true, "shareEnabled": true, - "embedTemplate": "", + "embedTemplate": "", "instructionsEnabled": false, "shareFrameEnabled": true, "shareManifestsEnabled": true, diff --git a/src/content-handlers/iiif/extensions/uv-default-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-default-extension/Extension.ts index 2cbc30b26..28d7e91b0 100644 --- a/src/content-handlers/iiif/extensions/uv-default-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-default-extension/Extension.ts @@ -116,16 +116,24 @@ export default class Extension } getEmbedScript(template: string, width: number, height: number): string { + const hashParams = new URLSearchParams({ + manifest: this.helper.manifestUri, + c: this.helper.collectionIndex.toString(), + m: this.helper.manifestIndex.toString(), + cv: this.helper.canvasIndex.toString(), + }); + const appUri: string = this.getAppUri(); - const title: string = this.helper.getLabel() || ""; - const iframeSrc: string = `${appUri}#?manifest=${this.helper.manifestUri}&c=${this.helper.collectionIndex}&m=${this.helper.manifestIndex}&cv=${this.helper.canvasIndex}`; + const title: string = this.helper.getLabel() ?? ""; const script: string = Strings.format( template, - iframeSrc, + appUri, + hashParams.toString(), width.toString(), height.toString(), title ); + return script; } } diff --git a/src/content-handlers/iiif/extensions/uv-default-extension/config/config.json b/src/content-handlers/iiif/extensions/uv-default-extension/config/config.json index 4c01ff653..9590b8f01 100644 --- a/src/content-handlers/iiif/extensions/uv-default-extension/config/config.json +++ b/src/content-handlers/iiif/extensions/uv-default-extension/config/config.json @@ -65,7 +65,7 @@ "options": { "embedEnabled": true, "shareEnabled": true, - "embedTemplate": "", + "embedTemplate": "", "instructionsEnabled": false, "shareFrameEnabled": true, "shareManifestsEnabled": true, diff --git a/src/content-handlers/iiif/extensions/uv-ebook-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-ebook-extension/Extension.ts index a5b0f4592..cfadf23cb 100644 --- a/src/content-handlers/iiif/extensions/uv-ebook-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-ebook-extension/Extension.ts @@ -142,16 +142,22 @@ export default class Extension } getEmbedScript(template: string, width: number, height: number): string { + const hashParams = new URLSearchParams({ + manifest: this.helper.manifestUri, + cfi: this.cfiFragement, + }); + const appUri: string = this.getAppUri(); - const title: string = this.helper.getLabel() || ""; - const iframeSrc: string = `${appUri}#?manifest=${this.helper.manifestUri}&cfi=${this.cfiFragement}`; + const title: string = this.helper.getLabel() ?? ""; const script: string = Strings.format( template, - iframeSrc, + appUri, + hashParams.toString(), width.toString(), height.toString(), title ); + return script; } diff --git a/src/content-handlers/iiif/extensions/uv-ebook-extension/config/config.json b/src/content-handlers/iiif/extensions/uv-ebook-extension/config/config.json index 1df06c3ff..d231e8328 100644 --- a/src/content-handlers/iiif/extensions/uv-ebook-extension/config/config.json +++ b/src/content-handlers/iiif/extensions/uv-ebook-extension/config/config.json @@ -234,7 +234,7 @@ "options": { "embedEnabled": true, "shareEnabled": true, - "embedTemplate": "", + "embedTemplate": "", "instructionsEnabled": false, "shareFrameEnabled": true, "shareManifestsEnabled": true, diff --git a/src/content-handlers/iiif/extensions/uv-mediaelement-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-mediaelement-extension/Extension.ts index 37dec4ade..4f7a4bc96 100644 --- a/src/content-handlers/iiif/extensions/uv-mediaelement-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-mediaelement-extension/Extension.ts @@ -236,16 +236,24 @@ export default class Extension } getEmbedScript(template: string, width: number, height: number): string { + const hashParams = new URLSearchParams({ + manifest: this.helper.manifestUri, + c: this.helper.collectionIndex.toString(), + m: this.helper.manifestIndex.toString(), + cv: this.helper.canvasIndex.toString(), + }); + const appUri: string = this.getAppUri(); - const title: string = this.helper.getLabel() || ""; - const iframeSrc: string = `${appUri}#?manifest=${this.helper.manifestUri}&c=${this.helper.collectionIndex}&m=${this.helper.manifestIndex}&cv=${this.helper.canvasIndex}`; + const title: string = this.helper.getLabel() ?? ""; const script: string = Strings.format( template, - iframeSrc, + appUri, + hashParams.toString(), width.toString(), height.toString(), title ); + return script; } diff --git a/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/config.json b/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/config.json index ecd1734e5..c8ee38fe5 100644 --- a/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/config.json +++ b/src/content-handlers/iiif/extensions/uv-mediaelement-extension/config/config.json @@ -65,7 +65,7 @@ "options": { "embedEnabled": true, "shareEnabled": true, - "embedTemplate": "", + "embedTemplate": "", "instructionsEnabled": false, "shareFrameEnabled": true, "shareManifestsEnabled": true, diff --git a/src/content-handlers/iiif/extensions/uv-model-viewer-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-model-viewer-extension/Extension.ts index 7ff9a38da..adee391bb 100644 --- a/src/content-handlers/iiif/extensions/uv-model-viewer-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-model-viewer-extension/Extension.ts @@ -255,16 +255,24 @@ export default class ModelViewerExtension extends BaseExtension { } getEmbedScript(template: string, width: number, height: number): string { + const hashParams = new URLSearchParams({ + manifest: this.helper.manifestUri, + c: this.helper.collectionIndex.toString(), + m: this.helper.manifestIndex.toString(), + cv: this.helper.canvasIndex.toString(), + }); + const appUri: string = this.getAppUri(); - const title: string = this.helper.getLabel() || ""; - const iframeSrc: string = `${appUri}#?manifest=${this.helper.manifestUri}&c=${this.helper.collectionIndex}&m=${this.helper.manifestIndex}&cv=${this.helper.canvasIndex}`; + const title: string = this.helper.getLabel() ?? ""; const script: string = Strings.format( template, - iframeSrc, + appUri, + hashParams.toString(), width.toString(), height.toString(), title ); + return script; } } diff --git a/src/content-handlers/iiif/extensions/uv-model-viewer-extension/config/config.json b/src/content-handlers/iiif/extensions/uv-model-viewer-extension/config/config.json index 13479234c..f44b295ea 100644 --- a/src/content-handlers/iiif/extensions/uv-model-viewer-extension/config/config.json +++ b/src/content-handlers/iiif/extensions/uv-model-viewer-extension/config/config.json @@ -78,7 +78,7 @@ "options": { "embedEnabled": true, "shareEnabled": true, - "embedTemplate": "", + "embedTemplate": "", "instructionsEnabled": false, "shareFrameEnabled": true, "shareManifestsEnabled": true, diff --git a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts index eee4845fc..d15a340f3 100644 --- a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/Extension.ts @@ -1369,18 +1369,30 @@ export default class OpenSeadragonExtension extends BaseExtension { zoom: string, rotation: number ): string { - const config: string = this.data.config!.uri || ""; - const locales: string | null = this.getSerializedLocales(); + const config: string = this.data.config?.uri ?? ""; + const locales: string = this.getSerializedLocales() ?? ""; + const hashParams = new URLSearchParams({ + manifest: this.helper.manifestUri, + c: this.helper.collectionIndex.toString(), + m: this.helper.manifestIndex.toString(), + cv: this.helper.canvasIndex.toString(), + config: config, + locales: locales, + xywh: zoom, + r: rotation.toString(), + }); + const appUri: string = this.getAppUri(); const title: string = this.helper.getLabel() || ""; - const iframeSrc: string = `${appUri}#?manifest=${this.helper.manifestUri}&c=${this.helper.collectionIndex}&m=${this.helper.manifestIndex}&cv=${this.helper.canvasIndex}&config=${config}&locales=${locales}&xywh=${zoom}&r=${rotation}`; const script: string = Strings.format( template, - iframeSrc, + appUri, + hashParams.toString(), width.toString(), height.toString(), title ); + return script; } diff --git a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/config/config.json b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/config/config.json index 6fa3d2127..39a6b2da3 100644 --- a/src/content-handlers/iiif/extensions/uv-openseadragon-extension/config/config.json +++ b/src/content-handlers/iiif/extensions/uv-openseadragon-extension/config/config.json @@ -445,7 +445,7 @@ "shareDialogue": { "options": { "embedEnabled": true, - "embedTemplate": "", + "embedTemplate": "", "instructionsEnabled": false, "shareEnabled": true, "shareFrameEnabled": true, diff --git a/src/content-handlers/iiif/extensions/uv-pdf-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-pdf-extension/Extension.ts index 596d7dc7b..f7fd40c02 100644 --- a/src/content-handlers/iiif/extensions/uv-pdf-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-pdf-extension/Extension.ts @@ -160,16 +160,24 @@ export default class Extension } getEmbedScript(template: string, width: number, height: number): string { + const hashParams = new URLSearchParams({ + manifest: this.helper.manifestUri, + c: this.helper.collectionIndex.toString(), + m: this.helper.manifestIndex.toString(), + cv: this.helper.canvasIndex.toString(), + }); + const appUri: string = this.getAppUri(); - const title: string = this.helper.getLabel() || ""; - const iframeSrc: string = `${appUri}#?manifest=${this.helper.manifestUri}&c=${this.helper.collectionIndex}&m=${this.helper.manifestIndex}&cv=${this.helper.canvasIndex}`; + const title: string = this.helper.getLabel() ?? ""; const script: string = Strings.format( template, - iframeSrc, + appUri, + hashParams.toString(), width.toString(), height.toString(), title ); + return script; } } diff --git a/src/content-handlers/iiif/extensions/uv-pdf-extension/config/config.json b/src/content-handlers/iiif/extensions/uv-pdf-extension/config/config.json index 7aafa2bed..65d445307 100644 --- a/src/content-handlers/iiif/extensions/uv-pdf-extension/config/config.json +++ b/src/content-handlers/iiif/extensions/uv-pdf-extension/config/config.json @@ -289,7 +289,7 @@ "options": { "embedEnabled": true, "shareEnabled": true, - "embedTemplate": "", + "embedTemplate": "", "instructionsEnabled": false, "shareFrameEnabled": true, "shareManifestsEnabled": true, diff --git a/src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts b/src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts index 6d850cfab..b72ef596b 100644 --- a/src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts +++ b/src/content-handlers/iiif/modules/uv-shared-module/BaseExtension.ts @@ -765,13 +765,8 @@ export class BaseExtension implements IExtension { } getAppUri(): string { - const appUri: string = - window.location.protocol + - "//" + - window.location.hostname + - (window.location.port ? ":" + window.location.port : ""); - - return appUri + "/uv.html"; + const port = window.location.port ? `:${window.location.port}` : ""; + return `${window.location.protocol}//${window.location.hostname}${port}`; } getSettings(): ISettings { diff --git a/src/uv-iiif-config.json b/src/uv-iiif-config.json index 108d55ca5..10df1e846 100644 --- a/src/uv-iiif-config.json +++ b/src/uv-iiif-config.json @@ -43,6 +43,11 @@ "options": { "downloadEnabled": true } + }, + "shareDialogue": { + "options": { + "embedTemplate": "" + } } } } From ea32f49b57d5e0af42ebd5ab69e0c7ac259fd797 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 22:43:07 +0000 Subject: [PATCH 2/3] Commit from GitHub Actions (Lint code) --- .../iiif/extensions/uv-av-extension/Extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content-handlers/iiif/extensions/uv-av-extension/Extension.ts b/src/content-handlers/iiif/extensions/uv-av-extension/Extension.ts index 46bc548ca..ea50ca548 100644 --- a/src/content-handlers/iiif/extensions/uv-av-extension/Extension.ts +++ b/src/content-handlers/iiif/extensions/uv-av-extension/Extension.ts @@ -154,7 +154,7 @@ export default class Extension c: this.helper.collectionIndex.toString(), m: this.helper.manifestIndex.toString(), cv: this.helper.canvasIndex.toString(), - rid: this.helper.rangeId?.toString() ?? "" + rid: this.helper.rangeId?.toString() ?? "", }); const appUri: string = this.getAppUri(); From 40ac1f1f53bc5e564b03ed87559a1f4a753a1346 Mon Sep 17 00:00:00 2001 From: Chris Hallberg Date: Mon, 16 Dec 2024 10:16:05 -0500 Subject: [PATCH 3/3] revert: test code Co-authored-by: Demian Katz --- src/uv-iiif-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uv-iiif-config.json b/src/uv-iiif-config.json index 10df1e846..12c4346f4 100644 --- a/src/uv-iiif-config.json +++ b/src/uv-iiif-config.json @@ -46,7 +46,7 @@ }, "shareDialogue": { "options": { - "embedTemplate": "" + "embedTemplate": "" } } }