Skip to content

ISSUE-443: Better Date Range Facets + Core Ajax improvements + New conditionals #478

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

Merged
merged 79 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
fc41582
Date Range Facet WIP
DiegoPino Oct 24, 2024
64f9851
Update slider via inputs
DiegoPino Oct 24, 2024
6f1a367
Adds a fixed cap too, even if use results is used as max/min
DiegoPino Oct 24, 2024
845b70a
Unrelated IABookreader
DiegoPino Oct 31, 2024
a48b58d
commit bc working on another commit!
DiegoPino Nov 12, 2024
8458fac
Merge branch 'ISSUE-479' into ISSUE-443
DiegoPino Nov 14, 2024
55ca8cd
Merge branch 'ISSUE-479' into ISSUE-443
DiegoPino Nov 14, 2024
c7619d8
Merge branch 'ISSUE-479' into ISSUE-443
DiegoPino Nov 14, 2024
facb352
Merge branch 'ISSUE-479' into ISSUE-443
DiegoPino Nov 18, 2024
412e5c9
Adds working Custom Mirador 4 with image tools
DiegoPino Nov 22, 2024
7746dad
Don't die on {{ Array }}. Log the issue, output a NULL. Override Drupal
DiegoPino Nov 22, 2024
e74813b
Well.. something was not right. Stale caches. Not good
DiegoPino Nov 23, 2024
cf4c5e5
That was hard!
DiegoPino Nov 23, 2024
66589b1
Drupal uses Exceptions to cut (deliver) an Ajax response! So we can't ..
DiegoPino Nov 25, 2024
36e4caa
mmm.. strange. why i had this?
DiegoPino Nov 27, 2024
b02b8fd
Update hook for correct text/plain mimetype
DiegoPino Dec 2, 2024
c8bfa09
wrong mimetype!
DiegoPino Dec 2, 2024
4775c65
More legacy text/text
DiegoPino Dec 2, 2024
54c0f20
Updates to Mirador Alpha 4 and Mirador 3.4.0
DiegoPino Dec 2, 2024
77efe63
Proper capitalization is needed now for Access-Control-Allow-Origin
DiegoPino Dec 6, 2024
327f18b
If there is a range (even if complete size) return a range 206/not a 200
DiegoPino Dec 6, 2024
977d654
More JS parsing options, also for external canvases now
DiegoPino Dec 6, 2024
032f042
adds the sbf_drupal_view_paged extension. Allows a View via twig
DiegoPino Jan 9, 2025
5ed5cc4
Better OSD Manifest Parsing + Image loading via Promises
DiegoPino Jan 9, 2025
0ce1740
Allow new sequence_id + internal_sequence_id to exist in SBF
DiegoPino Jan 9, 2025
2cd9760
Allow multiple SBF Documents to feed the annotation overlay for ML
DiegoPino Jan 10, 2025
2febe99
Avoid 2X calls with racing data. If outer click is not on a rect (so …
DiegoPino Jan 10, 2025
b4a86d9
Adds the context repository to the View Mode resolver. Might not be n…
DiegoPino Jan 23, 2025
7269f8f
Allows Dynamic annotation rendering to focus on a single SBF Flavor ID
DiegoPino Jan 23, 2025
108041a
Type in comment
DiegoPino Jan 23, 2025
3d5009c
commit but not commit to it right yet
DiegoPino Jan 24, 2025
d6dc07d
Fixes old Pager Arguments mismatching new queries on Ajax driven Views
DiegoPino Jan 24, 2025
4442978
spreadsyntax can only allow existing values
DiegoPino Jan 25, 2025
01d5db7
Even if our priority is higher, once a Node moves into print mode...
DiegoPino Feb 11, 2025
37240c2
Wrong indentation (PHPStorm went crazy)
DiegoPino Mar 13, 2025
fafeac1
Adds the Flavour Condition for Blocks
DiegoPino Mar 12, 2025
4733035
Settings Command was overwriting the Ajax Page State. This solves ..
DiegoPino Mar 17, 2025
3782a67
Fixes Block/Facet environment to deal with even more drupal 10.4 changes
DiegoPino Mar 17, 2025
01ab1e3
Patch the lack of sessions for update facet blocks on our own side.
DiegoPino Mar 17, 2025
504c747
Attach any views/exposed form libraries and settings
DiegoPino Mar 17, 2025
fcb219c
Act at the Render Array level for excluding text autosubmits for moda…
DiegoPino Mar 17, 2025
b766f78
Simplify the Ajax Facet block controller override
DiegoPino Mar 19, 2025
f7a985a
Ok, i got the facet controller fixed. But core one does not pass JS s…
DiegoPino Mar 19, 2025
9dedf54
Adds #type keys to sub elements of date range slider
DiegoPino Mar 19, 2025
067d64b
Fix small comments and better naming of variables
DiegoPino Mar 19, 2025
9a00ec5
adds title to the range slider theme hook
DiegoPino Mar 19, 2025
dc75520
Enables a new Twig extension, with paging AND also exposed filters
DiegoPino Mar 19, 2025
cc35e5f
To be safe. Name this queries. Facet module is bananas...
DiegoPino Mar 19, 2025
db867ff
Update JS/Adds Chart.js usage, adds new options
DiegoPino Mar 24, 2025
d7a8e48
Remove suffix/prefix from date range slider. These are dates. No setting
DiegoPino Mar 25, 2025
3225f12
First pass on using combined query_type and JSON Facet Range
DiegoPino Mar 25, 2025
61fbd85
Small Chart make-up changes
DiegoPino Mar 28, 2025
019589a
Small stats/facet comment change
DiegoPino Mar 28, 2025
a8b24aa
mmm.. loooks like we need to deep merge the settings on the facet ajax
DiegoPino Mar 31, 2025
a745ccc
For reasons of speed. I no longer call the parent Facet Ajax Controll…
DiegoPino Mar 31, 2025
267f0cb
Merge pull request #499 from esmero/ISSUE-498
DiegoPino Mar 31, 2025
4600c5d
Too many settings. like show BC/AD is not an urgency right now
DiegoPino Apr 2, 2025
38b684f
Make date range slider histogram a setting and allow custom colors
DiegoPino Apr 2, 2025
3a5e027
On date (range) slider, don't show a count for facet reset (show all)
DiegoPino Apr 2, 2025
f648bec
Fix some range slider wording
DiegoPino Apr 2, 2025
90adaf4
Change label of our old Date Picker
DiegoPino Apr 2, 2025
5db28e3
Uses the actual User (or Search API setting if defined) $timezone
DiegoPino Apr 2, 2025
4e3fb99
Pass time zones (for visual display) around
DiegoPino Apr 2, 2025
602b0c7
WIP add "advanced Mapping" sub form so we can map more than one view
DiegoPino Mar 3, 2025
dbbc4ed
adds Ajax wrappers (this will be complicated!)
DiegoPino Mar 7, 2025
356c337
Add Dec 31 to max date on slider
DiegoPino Apr 7, 2025
38d30b1
Remove comment. I might remove this whole thing even if it is cool
DiegoPino Apr 7, 2025
c9f4c40
Sadly we have to read the time zone from the configs
DiegoPino Apr 7, 2025
a6e03b1
Allow either Facets to define range/User input
DiegoPino Apr 7, 2025
521ba25
Also shift Query arguments based on Backend offset
DiegoPino Apr 7, 2025
816e4d1
Gosh Drupal. Drupal settings/Ajax page state and Libraries with Facet…
DiegoPino Apr 8, 2025
1984615
Remove the Solarium Facet subscriber. Went for a less code way
DiegoPino Apr 8, 2025
a7b52c2
Use UTC as default for the widget. In case there is not time zone def…
DiegoPino Apr 8, 2025
372caf4
Unix time does not use DateTimeZone. Also give min/max defaults
DiegoPino Apr 8, 2025
817b074
Ok. Now we respect input IF the facet that comes back falls in the sa…
DiegoPino Apr 8, 2025
bba40b7
Remove commented out. We don't want this! *lets make a pizza
DiegoPino Apr 8, 2025
19deaeb
This is a comment. Might be needed in the future. Solo dev means i ha…
DiegoPino Apr 10, 2025
71ad25c
Adds IIIF Content Search API Metadata search Option
DiegoPino Apr 25, 2025
dca60ba
Merge branch 'ISSUE-443' of https://github.com/esmero/format_strawber…
DiegoPino May 12, 2025
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
1 change: 0 additions & 1 deletion config/schema/format_strawberryfield.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ field.formatter.settings.strawberry_pannellum_formatter:
hide_on_embargo:
type: string
label: 'Hide Viewer if embargo is resolved as embargoed.'

field.formatter.settings.strawberry_video_formatter:
type: mapping
label: 'Specific Config for strawberry_video_formatter'
Expand Down
12 changes: 6 additions & 6 deletions format_strawberryfield.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,23 @@ pdfs_strawberry:
- format_strawberryfield/iiif_formatstrawberryfield_utils

mirador_projectmirador:
version: 3.3.0
version: 3.4.0
license:
name: Apache
url: //github.com/ProjectMirador/mirador/blob/master/LICENSE
gpl-compatible: true
js:
https://cdn.jsdelivr.net/npm/mirador@3.3.0/dist/mirador.min.js: { external: true, minified: true, preprocess: false}
https://cdn.jsdelivr.net/npm/mirador@3.4.0/dist/mirador.min.js: { external: true, minified: true, preprocess: false}
https://cdn.jsdelivr.net/npm/redux-saga@1.2.3/dist/redux-saga.umd.min.js: { external: true, minified: true, preprocess: false}

mirador_projectmirador_4:
version: 4.0.0-alpha
version: 4.0.0-alpha4
license:
name: Apache
url: //github.com/ProjectMirador/mirador/blob/master/LICENSE
gpl-compatible: true
js:
https://unpkg.com/mirador@4.0.0-alpha.2/dist/mirador.min.js: { external: true, minified: true, preprocess: false}
https://unpkg.com/mirador@4.0.0-alpha.4/dist/mirador.min.js: { external: true, minified: true, preprocess: false}
https://cdn.jsdelivr.net/npm/redux-saga@1.2.3/dist/redux-saga.umd.min.js: { external: true, minified: true, preprocess: false}
dependencies:
- format_strawberryfield/mirador_font
Expand All @@ -220,13 +220,13 @@ mirador_font:
'https://fonts.googleapis.com/css?family=Roboto:300,400,500': { external: true }

mirador_archipelago_custom:
version: 3.3.0
version: 4.0.0
license:
name: Apache
url: //github.com/ProjectMirador/mirador/blob/master/LICENSE
gpl-compatible: true
js:
js/mirador-archipelago.js: {minified: false, preprocess: false}
js/mirador4-image.min.js: {minified: false, preprocess: false}
https://cdn.jsdelivr.net/npm/redux-saga@1.2.3/dist/redux-saga.umd.min.js: { external: true, minified: true, preprocess: false}

mirador_strawberry:
Expand Down
2 changes: 1 addition & 1 deletion format_strawberryfield.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
arguments: [ '@string_translation', '@messenger', '@logger.factory' ]
format_strawberryfield.view_mode_resolver:
class: Drupal\format_strawberryfield\ViewModeResolver
arguments: ['@strawberryfield.utility', '@config.factory']
arguments: ['@strawberryfield.utility', '@config.factory', '@context.repository']
format_strawberryfield.embargo_resolver:
class: Drupal\format_strawberryfield\EmbargoResolver
arguments: ['@config.factory', '@current_user', '@request_stack']
Expand Down
5 changes: 5 additions & 0 deletions js/iiif-annotations_strawberry.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
var disableUrlClickWhenVisible = function (event) {
// Bound to groupsetting (this)
event.preventDefault();
// We have no way of cancelling / avoiding bubbling on the annotation onClik
// we actually have to check if someone clicked the SVG wrapper.
if (event.target.tagName != 'svg') {
return;
}
// If there is a Link around the image we will reuse as direct link
// if we don't prevent the default.
// Sadly there is no getVisible() method. But we can check the annotationlayer if any
Expand Down
16 changes: 14 additions & 2 deletions js/iiif-archipelago-interactions_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
var FormatStrawberryfieldIiifUtils = {

images_jmespath_pattern: "items[?type == 'Canvas'].{\"canvas_id\":id ,\"items\": items[?type == 'AnnotationPage'].{\"id\":id,\"image_ids\": items[?motivation == 'painting'].body.id, \"service_ids\": items[?motivation == 'painting'].body.service[].{type: not_null(type, \"@type\"), id: not_null(id, \"@id\")}[?starts_with(type, 'ImageService')].id }}",
images_canvas_jmespath_pattern: "[{\"canvas_id\":id ,\"items\": items[?type == 'AnnotationPage'].{\"id\":id,\"image_ids\": items[?motivation == 'painting'].body.id, \"service_ids\": items[?motivation == 'painting'].body.service[].{type: not_null(type, \"@type\"), id: not_null(id, \"@id\")}[?starts_with(type, 'ImageService')].id }}]",
geoannotation_jmespath_pattern: "items[?type == 'Canvas'].{\"canvas_id\":id ,\"annotations\": annotations[?type == 'AnnotationPage'].{\"id\":id, \"annotation\": items[?motivation == 'georeferencing'].{\"features\": not_null(body[].features[], body.features), \"target\": target}}}",
geoannotation_jmespath_pattern_split: "items[?type == 'Canvas'].{\"canvas_id\":id ,\"annotations\": annotations[?type == 'AnnotationPage'].{\"id\":id,\"features\": items[?motivation == 'georeferencing'].body[].features, \"target\": items[?motivation == 'georeferencing'].target}}",
images_jmespath_pattern_with_canvasids: "items[?type == 'Canvas' && id=='{{token1}}'].{\"canvas_id\":id ,\"items\": items[?type == 'AnnotationPage'].{\"id\":id,\"image_ids\": items[?motivation == 'painting'].body.id, \"service_ids\": items[?motivation == 'painting'].body.service[].{type: not_null(type, \"@type\"), id: not_null(id, \"@id\")}[?starts_with(type, 'ImageService')].id }}",
Expand Down Expand Up @@ -100,7 +101,11 @@
return this;
},
fetchIIIFManifest: async function (iiifmanifesturl) {
const response = await fetch(iiifmanifesturl);
const response = await fetch(iiifmanifesturl, {
mode: 'cors',
method: 'GET'
}
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
Expand Down Expand Up @@ -281,8 +286,15 @@
// @by awesome https://github.com/digitaldogsbody Mike Bennet
const image_services = jmespath.search(iiifmanifest, this.images_jmespath_pattern);
return image_services;
},

getIIIFServicesForCanvas: function (iiifcanvas) {
// See https://github.com/esmero/format_strawberryfield/pull/252/commits/81094b6cc1d7db6e12602022d7813e9361099595
// @by awesome https://github.com/digitaldogsbody Mike Bennet
const image_services = jmespath.search(iiifcanvas, this.images_canvas_jmespath_pattern);
return image_services;
}
};
};

/* Make it part of the Global Drupal Object */
Drupal.FormatStrawberryfieldIiifUtils = FormatStrawberryfieldIiifUtils;
Expand Down
44 changes: 41 additions & 3 deletions js/iiif-openseadragon_strawberry.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@
if (!groupsinfojsons.hasOwnProperty(group)) {
groupsinfojsons[group] = [infojson];
groupsinfomanifests[group] = [drupalSettings.format_strawberryfield.openseadragon[element_id]?.manifesturl];
if (drupalSettings.format_strawberryfield.openseadragon[element_id]?.manifestother) {
groupsinfomanifests[group].push(...drupalSettings.format_strawberryfield.openseadragon[element_id]?.manifestother);
}
if (typeof icons_prefixurl == "undefined" || icons_prefixurl == "") {
icons_prefixurl = "https://cdn.jsdelivr.net/npm/openseadragon@2.4.2/build/openseadragon/images/";
}
Expand Down Expand Up @@ -585,6 +588,7 @@
}
else {
groupsinfojsons[group].push(infojson);
groupsinfomanifests[group].push(...drupalSettings.format_strawberryfield.openseadragon[element_id]?.manifestother);
groupsinfomanifests[group].push(drupalSettings.format_strawberryfield.openseadragon[element_id]?.manifesturl);
// hide other strawberry-media-items
$(this).height(0);
Expand Down Expand Up @@ -674,13 +678,45 @@
const $iiifmanifest = Drupal.FormatStrawberryfieldIiifUtils.fetchIIIFManifest($manifest);
$iiifmanifest.then(iiifmanifest_promise_resolved => {
let $iiif_parsed = Drupal.FormatStrawberryfieldIiifUtils.getIIIFServices(iiifmanifest_promise_resolved);
let future_canvas_promises = [];
if (Array.isArray($iiif_parsed)) {
$iiif_parsed = $iiif_parsed.map($canvas_structure => {
const first_image_service = $canvas_structure.items.map($item => $item.service_ids[0]);
infojson.push(first_image_service[0]+'/info.json');
// this is async so it should have started already
if ($canvas_structure?.items !== null) {
// this is async so it should have started already
const first_image_service = $canvas_structure.items.map($item => $item.service_ids[0]);
infojson.push(first_image_service[0] + '/info.json');
} else if ($canvas_structure?.canvas_id) {
const $iiifCanvas = Drupal.FormatStrawberryfieldIiifUtils.fetchIIIFManifest($canvas_structure.canvas_id);
future_canvas_promises.push($iiifCanvas);
}
});
}
if (future_canvas_promises.length > 0) {
Promise.allSettled(future_canvas_promises).then(iiifCanvas_promises_resolved => {
iiifCanvas_promises_resolved.forEach((iiifCanvas_promise_resolved) => {
if (iiifCanvas_promise_resolved.status == "fulfilled") {
let $iiif_canvas_parsed = Drupal.FormatStrawberryfieldIiifUtils.getIIIFServicesForCanvas(iiifCanvas_promise_resolved.value);
if (Array.isArray($iiif_canvas_parsed)) {
$iiif_canvas_parsed = $iiif_canvas_parsed.map($canvas_structure_remote => {
if ($canvas_structure_remote?.items !== null) {
// this is async so it should have started already
const first_image_service = $canvas_structure_remote.items.map($item => $item.service_ids[0]);
tiles.push(first_image_service[0] + '/info.json');
viewers[element_id].addTiledImage({tileSource: first_image_service[0] + '/info.json'});
//viewers[element_id].tileSources = viewers[element_id].tileSources.concat(first_image_service[0] + '/info.json');
if (tiles.length > 1) {
viewers[element_id].addReferenceStrip();
}
}
});
}
}});
viewers[element_id].open(tiles, 0);
viewers[element_id].addReferenceStrip();
}
)
}

infojson.forEach($tile => {tiles.push($tile);viewers[element_id].addTiledImage({tileSource: $tile });});
viewers[element_id].tileSources = viewers[element_id].tileSources.concat(infojson);
if (infojson.length >= 1) {
Expand All @@ -691,6 +727,8 @@
loadFirstAnnotationOfGroup(group);
viewers[element_id].goToPage(0);
}
}).catch(function () {
console.log("IIIF Loading from URL failed and Rejected");
});
});
}
Expand Down
2 changes: 2 additions & 0 deletions js/mirador4-image.min.js

Large diffs are not rendered by default.

35 changes: 27 additions & 8 deletions js/mirador_strawberry.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@
manifestId: manifest.id,
})).view
}
let allCanvases = yield effects.select(Mirador.selectors.getCanvases, { windowId});

let canvasIds = [];
let currentDrupalNodeId = [];
let currentDrupalNodeForViews = [];
Expand Down Expand Up @@ -382,12 +384,6 @@
allowClose: false,
imageToolsEnabled: true,
imageToolsOpen: true,
views: [
{ key: 'single', behaviors: [null, 'individuals'] },
{ key: 'book', behaviors: [null, 'paged'] },
{ key: 'scroll', behaviors: ['continuous'] },
{ key: 'gallery' },
],
};
$options.windows[0].workspaceControlPanel = {
enabled: false
Expand All @@ -396,6 +392,18 @@
isWorkspaceAddVisible: false,
allowNewWindows: true,
};
// Needed bc of how Image Pluging uses Canvas info/get Image from OSD to apply effects.
$options.osdConfig = {
crossOriginPolicy: 'Anonymous'
}
$options.theme = {
palette: {
primary: {
main: '#1967d2',
},
},
};

}


Expand Down Expand Up @@ -483,6 +491,7 @@
});
}
}

$options = {
...$options,
...viewer_override,
Expand All @@ -492,8 +501,16 @@

//@TODO add an extra Manifests key with every other one so people can select the others.
if (drupalSettings.format_strawberryfield.mirador[element_id]['custom_js'] == true) {
const miradorInstance = renderMirador($options);
console.log('initializing Custom Mirador 3.3.0')
const miradorInstance = Mirador.viewerWithImagePlugin($options, [formatStrawberryFieldReactPlugin]);
console.log('initializing Custom Mirador 4.0 with Image Tools')
if (miradorInstance) {
// To allow bubling up we need to add this one to the document
// Multiple Miradors will replace each other?
// @TODO check on that diego..
document.addEventListener('sbf:canvas:change', CaptureAdoMiradorCanvasChange.bind(document, miradorInstance, element_id));
document.addEventListener('sbf:ado:change', CaptureAdoMiradorAdoChange.bind(document, miradorInstance, element_id));
const windowId = Object.keys(miradorInstance.store.getState().windows)[0];
}
}
else {
const miradorInstance = Mirador.viewer($options, [formatStrawberryFieldReactPlugin]);
Expand All @@ -504,8 +521,10 @@
// @TODO check on that diego..
document.addEventListener('sbf:canvas:change', CaptureAdoMiradorCanvasChange.bind(document, miradorInstance, element_id));
document.addEventListener('sbf:ado:change', CaptureAdoMiradorAdoChange.bind(document, miradorInstance, element_id));
const windowId = Object.keys(miradorInstance.store.getState().windows)[0];
}
}

// Work around https://github.com/ProjectMirador/mirador/issues/3486
const mirador_window = document.getElementById(element_id);
var observer = new MutationObserver(function(mutations) {
Expand Down
59 changes: 56 additions & 3 deletions js/plugin.iiif-iabookreader_strawberry.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ BookReader.prototype.setup = (function(super_) {
numPages: null,
bookUrl: null
};
this.leafsToUUids = {};
this.searchTerm = '';
this.searchResults = null;
this.searchInsideUrl = options.searchInsideUrl;
Expand Down Expand Up @@ -382,6 +383,7 @@ function processBehaviorToIABookreaderModeV2(jsonLd) {

BookReader.prototype.parseSequence = function (sequenceId) {
var self = this;

// viewingDirection is the same in V2 and V3 BUT on V2 it can be inside a sequence ..
if (typeof(self.jsonLd.viewingDirection) !== "undefined") {
if (self.jsonLd.viewingDirection == "right-to-left") {
Expand Down Expand Up @@ -560,11 +562,14 @@ BookReader.prototype.parseSequence = function (sequenceId) {
imageObj.canvasHeight = canvas.height;

if (!(/#xywh/).test(image.on)) {
imagesList.push(imageObj);
imagesList.push(imageObj);
const UUIDandSequence = self.getUUIDAndSequencefromCanvas(canvas['@id']);
if (UUIDandSequence) {
self.leafsToUUids[UUIDandSequence] = imagesList.length;
}
}
}
});

}
});

Expand Down Expand Up @@ -598,6 +603,10 @@ BookReader.prototype.parseSequence = function (sequenceId) {
// Add it to the images list
if (!(/#xywh/).test(annotation.target)) {
imagesList.push(imageObj);
const UUIDandSequence = self.getUUIDAndSequencefromCanvas(item.id);
if (UUIDandSequence) {
self.leafsToUUids[UUIDandSequence] = imagesList.length;
}
}
}
});
Expand Down Expand Up @@ -703,6 +712,41 @@ BookReader.prototype.getIIIFInfoJsonFromURL = function(string){
}
}

BookReader.prototype.getUUIDAndSequencefromCanvas = function(string){
let url;

try {
url = new URL(string);
} catch (_) {
return '';
}
let path = url.pathname;
// IIIF will have id/crop/size/rotation/filename So we will split and reverse
if (path !== '/') {
// Assumes /somestuff/84e618e0-3456-4edd-841e-5b4c9e8e0490/canvas/p1
let path_parts = path.split("/");
if (path_parts.length >= 5) {
path_parts = path_parts.reverse();
path_parts = path_parts.slice(0,3);
if (path_parts.length == 3) {
const page = path_parts[0].replace(/\D/g,'');
const uuid = path_parts[2];
// We will use this as an index to match File UUIDs and their internal Sequence IDs to IABookreader pages.
return uuid + '/' + page;
}
}
else {
// Might be non IIIF, so we return the Image itself.
return null;
}
}
else {
return null;
}
}



/**
* @param {number} index
* @return {Number|undefined}
Expand Down Expand Up @@ -893,13 +937,22 @@ BookReader.prototype.search = (function(super_) {
return typeof a === 'object' && !Array.isArray(a) && a !== null
}
);

searchInsideResults.matches.forEach(function(match,index,array) {
let uuid = match?.sbf_metadata.file_uuid;
match.par[0].boxes.forEach(function(box,index,array) {
var pageindex = self.leafNumToIndex(array[index].page);
let page = array[index].page;
if (self.leafsToUUids.hasOwnProperty(uuid+'/'+(parseInt(page)+1))) {
page = self.leafsToUUids[uuid+'/'+(parseInt(page)+1)];
page = page - 1;
}
var pageindex = self.leafNumToIndex(page);
array[index].l = Math.round(box.l * self.getPageWidth(pageindex));
array[index].t = Math.round(box.t * self.getPageHeight(pageindex));
array[index].r = Math.round(box.r * self.getPageWidth(pageindex));
array[index].b = Math.round(box.b * self.getPageHeight(pageindex));
array[index].page = page;
match.par[0].page = page;
})
});
hasCustomSuccess
Expand Down
Loading