From ec29a45bde5af814c1717c85238013c07495154b Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Mon, 20 Nov 2023 01:22:12 -0400 Subject: [PATCH] 959-iiif-width-height-caching Islandora IIIF: Add search endpoint config to manifest. --- .../config/schema/islandora_iiif.schema.yml | 12 ++++++++ .../src/Plugin/views/style/IIIFManifest.php | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml b/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml index f9e870ef..e02f443f 100644 --- a/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml +++ b/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml @@ -16,3 +16,15 @@ views.style.iiif_manifest: type: sequence sequence: type: string + label: "Tile source field(s)" + iiif_ocr_file_field: + type: sequence + sequence: + type: string: + label: "IIIF hOCR file field" + structured_text_term: + type: string + label: "Structured text term" + search_endpoint: + type: string + label: "Search endpoint path" diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index b2ea900d..77763458 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -215,6 +215,9 @@ class IIIFManifest extends StylePluginBase { $content_type = 'json'; +// Add a search endpoint if one is defined +$this->addSearchEndpoint($json, $url_components); + // Give other modules a chance to alter the manifest. $this->moduleHandler->alter('islandora_iiif_manifest', $json, $this); @@ -459,6 +462,23 @@ class IIIFManifest extends StylePluginBase { return $entity_title; } + protected function addSearchEndpoint(array &$json, array $url_components) { + $url_base = $this->getRequest()->getSchemeAndHttpHost(); + $hocr_search_path = $this->options['search_endpoint']; + $hocr_search_url = $url_base . '/' . ltrim($hocr_search_path, '/'); + + $hocr_search_url = str_replace('%node', $url_components[1], $hocr_search_url); + + $json['service'][] = [ + "@context" => "http://iiif.io/api/search/0/context.json", + "@id" => $hocr_search_url, + "profile" => "http://iiif.io/api/search/0/search", + "label" => t("Search inside this work"), + ]; + + + } + /** * {@inheritdoc} */ @@ -539,6 +559,14 @@ class IIIFManifest extends StylePluginBase { '#required' => FALSE, '#description' => $this->t('Term indicating the media that holds structured text, such as hOCR, for the given object. Use this if the text is on a separate media from the tile source.'), ]; + + $form['search_endpoint'] = [ + '#type' => 'textfield', + '#title' => $this->t("Search endpoint path."), + '#description' => $this->t("If there is a search endpoint to search within the book that returns IIIF annotations, put it here. Use substitutions %node and %keywords.
E.g., paged-content-search/%node?search-in-pages=%keywords"), + '#default_value' => $this->options['search_endpoint'], + '#required' => FALSE, + ]; } /**