Skip to content

Commit

Permalink
Viewer testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnyder committed Oct 5, 2023
1 parent 7b834da commit 2486fa5
Show file tree
Hide file tree
Showing 8 changed files with 625 additions and 4 deletions.
118 changes: 118 additions & 0 deletions juncture/components/Compare.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<template>
<div id="main" :style="containerStyle">
<div id="osd"></div>
</div>
</template>

<script>
// https://cuberis.github.io/openseadragon-curtain-sync/
const iiifService = 'https://iiif.juncture-digital.org'
const prefixUrl = 'https://openseadragon.github.io/openseadragon/images/'
module.exports = {
name: 've-compare',
props: {
items: { type: Array, default: () => ([]) },
viewerIsActive: Boolean
},
data: () => ({
viewerLabel: 'Image Compare',
viewerIcon: 'fas fa-images',
dependencies: [
'https://cdn.jsdelivr.net/npm/[email protected]/build/openseadragon/openseadragon.min.js',
'https://jstor-labs.github.io/juncture/js/openseadragon-curtain-sync.min.js'
],
tileSources: [],
viewer: null
}),
computed: {
containerStyle() { return { height: this.viewerIsActive ? '100%' : '0' } },
compareItems() { return this.items.filter(item => item[this.$options.name]) },
mode() { let itemsWithMode = this.compareItems.filter(item => item.sync || item.curtain).map(item => item.sync ? 'sync' : 'curtain')
return itemsWithMode.length > 0 ? itemsWithMode[0] : 'curtain'
},
images() { return this.tileSources.map((tileSource, idx) => {
return { key: `item-${idx}`, tileSource, shown: true }
})
}
},
mounted() { this.loadDependencies(this.dependencies, 0, this.init) },
methods: {
init() { this.loadManifests() },
initViewer() {
if (this.viewerIsActive) {
let main = document.getElementById('main')
let container = document.getElementById('osd')
if (container) {
main.removeChild(container)
}
container = document.createElement('div')
container.id = 'osd'
container.style.height = '100%'
main.appendChild(container)
this.$nextTick(() => {
this.viewer = new CurtainSyncViewer({
mode: this.mode, // 'sync' or 'curtain'
container,
images: this.images,
osdOptions: { // OpenSeaDragon options
autoHideControls: false,
showHomeControl: true,
showZoomControl: true,
homeFillsViewer: false,
prefixUrl,
zoomPerClick: 2,
visibilityRatio: 1,
wrapHorizontal: false,
constrainDuringPan: true,
minZoomImageRatio: 1.35,
// maxZoomPixelRatio: Infinity,
maxZoomPixelRatio: 3,
viewportMargins: {left:0, top:0, bottom:0, right:0}
}
})
})
}
},
loadManifests() {
let promises = this.compareItems.map(item => {
if (item.manifest) {
return fetch(item.manifest).then(resp => resp.json())
} else if (item.url) {
let data = {};
['url', 'label', 'description', 'attribution', 'license'].forEach(field => {
if (item[field]) data[field] = item[field]
})
return fetch(`${iiifService}/manifest/`, {
method: 'POST',
headers: {'Content-type': 'application/json'},
body: JSON.stringify(data)
}).then(resp => resp.json())
}
})
Promise.all(promises).then(manifests => {
this.manifests = manifests.map((manifest, idx) => {return {...manifest, ...this.compareItems[idx]}})
this.tileSources = this.manifests.map((manifest, idx) => {
const opacity = idx === 0 ? 1 : this.mode === 'layers' ? 0 : 1
const tileSource = manifest.sequences[0].canvases[manifest.seq || 0].images[0].resource.service
? `${manifest.sequences[0].canvases[manifest.seq || 0].images[0].resource.service['@id']}/info.json`
: { url: manifest.sequences[0].canvases[manifest.seq || 0].images[0].resource['@id'] || manifest.metadata.find(md => md.label === 'source').value,
type: 'image', buildPyramid: true }
return tileSource
})
})
}
},
watch: {
compareItems() { this.loadManifests() },
images() { this.initViewer() },
active() { this.initViewer() }
}
}
</script>

<style>
</style>
50 changes: 50 additions & 0 deletions juncture/components/IFrame.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<div :style="containerStyle">

<iframe :id="id" :name="name" :allow="allow" :height="iframeHeight" :width="iframeWidth" :allowfullscreen="allowfullscreen" :mozallowfullscreen="allowfullscreen" :msallowfullscreen="allowfullscreen" :webkitallowfullscreen="allowfullscreen" :frameborder="frameborder" :src="src" :allowtransparency="allowtransparency" :referrerpolicy="referrerpolicy"></iframe>

</div>
</template>

<script>
module.exports = {
name: 've-iframe',
props: {
items: { type: Array, default: () => ([]) },
viewerIsActive: Boolean
},
data: () => ({
viewerLabel: 'IFrame',
viewerIcon: 'fas fa-file-code',
dependencies: []
}),
computed: {
containerStyle() { return {
position: 'relative',
height: this.viewerIsActive ? '100%' : '0',
overflowY: 'auto !important'
}},
filteredItems() { return this.items.filter(item => item[this.$options.name]) },
item() { return this.filteredItems[0] },
id() { return this.item.id || '' },
name() { return this.item.name || '' },
allow() { return this.item.allow || '' },
iframeHeight() { return this.item.height || '100%' },
iframeWidth() { return this.item.width || '100%' },
allowfullscreen() { return this.item.allowfullscreen || 'true' },
src() { return this.item.src || '' },
allowtransparency() { return this.item.allowtransparency || 'true' },
referrerpolicy() { return this.item.referrerpolicy || '' },
frameborder() { return this.item.frameborder || '0' }
},
mounted() { this.loadDependencies(this.dependencies, 0, this.init) },
methods: {
init() {
}
}
}
</script>

<style>
</style>
12 changes: 11 additions & 1 deletion juncture/components/JunctureV1.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ window.html = `<<HTML>>`
const ENV = 'PROD'
const availableViewers = [
've1-compare',
've1-iframe',
've1-image',
've1-map'
've1-knightlab-timeline',
've1-plant-specimen',
've1-map',
've1-video'
]
const componentPrefix = 've1-'
Expand All @@ -122,10 +127,15 @@ const qargs = {}
module.exports = {
components: {
've1-compare': window.httpVueLoader(`${window.config.baseurl}/juncture/components/Compare.vue`),
've-footer': window.httpVueLoader(`${window.config.baseurl}/juncture/components/Footer.vue`),
've-header': window.httpVueLoader(`${window.config.baseurl}/juncture/components/Header.vue`),
've1-iframe': window.httpVueLoader(`${window.config.baseurl}/juncture/components/IFrame.vue`),
've1-image': window.httpVueLoader(`${window.config.baseurl}/juncture/components/Image.vue`),
've1-map': window.httpVueLoader(`${window.config.baseurl}/juncture/components/Map.vue`),
've1-knightlab-timeline': window.httpVueLoader(`${window.config.baseurl}/juncture/components/KnightlabTimeline.vue`),
've1-plant-specimen': window.httpVueLoader(`${window.config.baseurl}/juncture/components/PlantSpecimen.vue`),
've1-video': window.httpVueLoader(`${window.config.baseurl}/juncture/components/Video.vue`),
've-visual-essay': window.httpVueLoader(`${window.config.baseurl}/juncture/components/VisualEssay.vue`),
},
props: {
Expand Down
49 changes: 49 additions & 0 deletions juncture/components/KnightlabTimeline.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<template>
<div :style="containerStyle">
<iframe
:src="`https://cdn.knightlab.com/libs/timeline3/latest/embed/index.html?source=${item.source}&font=Default&lang=en&timenav_position=${item['timenav-position'] ||
'bottom'}&hash_bookmark=${item['hash_bookmark'] ||
'false'}&initial_zoom=${item['initial-zoom'] || '2'}&height=${item.height || '650'}`"
width="100%"
height="100%"
webkitallowfullscreen mozallowfullscreen allowfullscreen
frameborder="0">
</iframe>
</div>
</template>
<script>
module.exports = {
name: 've-knightlab-timeline',
props: {
items: { type: Array, default: () => ([]) },
viewerIsActive: Boolean
},
data: () => ({
viewerLabel: 'Knightlab Timeline',
viewerIcon: 'fas fa-history',
dependencies: [],
height: 750,
}),
computed: {
containerStyle() { return {
position: 'relative',
height: this.viewerIsActive ? '100%' : '0',
overflowY: 'auto !important'
}},
filteredItems() {
return this.items.filter(item => item[this.$options.name])
},
item() { return this.filteredItems[0] }
},
mounted() { this.loadDependencies(this.dependencies, 0, this.init) },
methods: {
init() {
// console.log(`${this.componentName}: height=${this.height} width=${this.width}`)
}
}
}
</script>

<style>
</style>
Loading

0 comments on commit 2486fa5

Please sign in to comment.