-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
675 additions
and
469 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import Mirador from '@columbia-libraries/mirador/dist/es/src'; | ||
import miradorDownloadPlugins from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-downloaddialog'; | ||
import canvasRelatedLinksPlugin from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-canvasRelatedLinks'; | ||
import citationSidebar from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-citations'; | ||
import hintingSidebar from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-hinting-sidebar'; | ||
import videoJSPlugin from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-videojs'; | ||
import viewerNavigation from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-pageIconViewerNavigation'; | ||
import viewXmlPlugin from '@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-viewXml'; | ||
import collectionFoldersPlugin from | ||
'@columbia-libraries/mirador/dist/es/src/culPlugins/mirador-selectCollectionFolders'; | ||
|
||
const flattenPluginConfigs = (...plugins) => plugins.reduce((acc, curr) => acc.concat([...curr]), []); | ||
|
||
function loadMirador() { | ||
const miradorDiv = document.getElementById('mirador'); | ||
if (!miradorDiv) return; | ||
|
||
const manifestUrl = miradorDiv.dataset.manifest; | ||
if (manifestUrl) { | ||
const numChildren = miradorDiv.dataset['num-children'] || 1; | ||
|
||
const getStartCanvas = (queryParams) => { | ||
if (queryParams.get('canvas')) { | ||
const canvases = queryParams.get('canvas').split(','); | ||
const canvas = canvases[0]; | ||
return canvas.startsWith('../') ? manifestUrl.replace('/manifest', canvas.slice(2)) : canvas; | ||
} | ||
return null; | ||
}; | ||
const startCanvas = getStartCanvas(new URL(document.location).searchParams); | ||
const viewConfig = {}; | ||
if (numChildren && numChildren === 1) { | ||
viewConfig.views = [{ key: 'single' }]; | ||
viewConfig.defaultView = 'single'; | ||
} | ||
const culMiradorPlugins = flattenPluginConfigs( | ||
canvasRelatedLinksPlugin, | ||
citationSidebar, | ||
hintingSidebar, | ||
miradorDownloadPlugins, | ||
videoJSPlugin, | ||
viewerNavigation, | ||
viewXmlPlugin, | ||
); | ||
const foldersAttValue = miradorDiv.dataset['use-folders']; | ||
const useFolders = (Boolean(foldersAttValue) && !String.toString(foldersAttValue).match(/false/i)); | ||
if (useFolders) { | ||
culMiradorPlugins.push(...collectionFoldersPlugin); | ||
viewConfig.allowTopCollectionButton = true; | ||
viewConfig.sideBarOpen = true; | ||
} | ||
|
||
Mirador.viewer( | ||
{ | ||
id: 'mirador', | ||
window: { | ||
allowClose: false, | ||
allowFullscreen: true, | ||
allowMaximize: false, | ||
panels: { | ||
info: true, | ||
canvas: true, | ||
}, | ||
canvasLink: { | ||
active: true, | ||
enabled: true, | ||
singleCanvasOnly: false, | ||
providers: [], | ||
getCanvasLink: (manifestId, canvases) => { | ||
const baseUri = window.location.href.replace(window.location.search, ''); | ||
const isManifest = (canvas) => canvas.id.startsWith(manifestId.replace('/manifest', '')); | ||
const canvasIndices = canvases.map( | ||
(canvas) => (isManifest(canvas) ? `../canvas/${canvas.id.split('/').slice(-2).join('/')}` : canvas.id), | ||
); | ||
return `${baseUri}?canvas=${canvasIndices.join(',')}`; | ||
}, | ||
}, | ||
...viewConfig, | ||
}, | ||
windows: [ | ||
{ manifestId: manifestUrl, canvasId: startCanvas }, | ||
], | ||
workspace: { | ||
showZoomControls: true, | ||
}, | ||
workspaceControlPanel: { | ||
enabled: false, | ||
}, | ||
miradorDownloadPlugin: { | ||
restrictDownloadOnSizeDefinition: true, | ||
}, | ||
translations: { | ||
en: { openCompanionWindow_citation: 'Citation' }, | ||
}, | ||
}, | ||
culMiradorPlugins, | ||
); | ||
} | ||
} | ||
|
||
export default loadMirador; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'rails_helper' | ||
|
||
describe Acfa::Viewers::MiradorComponent, type: :component do | ||
subject(:component) { described_class.new(document: document, presenter: document_presenter) } | ||
|
||
let(:document) { instance_double(SolrDocument, digital_objects: []) } | ||
let(:document_presenter) { instance_double(Arclight::ShowPresenter, fields_to_render: [double]) } | ||
|
||
|
||
include_context "renderable view components" | ||
it "does not render" do | ||
expect(component.render?).to be false | ||
end | ||
context "has one embeddable resource" do | ||
let(:label) { 'resource label' } | ||
let(:href) { 'https://doi.org/10.7916/d8-3tyk-ew60' } | ||
let(:iiif_object) { instance_double(Arclight::DigitalObject, label: label, href: href) } | ||
let(:document) { instance_double(SolrDocument, digital_objects: [iiif_object], parents: []) } | ||
it "renders" do | ||
expect(rendered_node).to have_selector 'div#mirador' | ||
end | ||
end | ||
context "has multiple embeddable resources" do | ||
let(:label1) { 'resource label 1' } | ||
let(:href1) { 'https://doi.org/10.7916/d8-3tyk-ew60' } | ||
let(:iiif_object1) { instance_double(Arclight::DigitalObject, label: label1, href: href1) } | ||
|
||
let(:label2) { 'resource label 2' } | ||
let(:href2) { 'https://doi.org/10.7916/d8-3tyk-ew61' } | ||
let(:iiif_object2) { instance_double(Arclight::DigitalObject, label: label2, href: href2) } | ||
|
||
let(:document) { instance_double(SolrDocument, digital_objects: [iiif_object1, iiif_object2], parents: []) } | ||
it "renders" do | ||
expect(rendered_node).to have_selector 'div#mirador' | ||
end | ||
end | ||
end |
Oops, something went wrong.