Browse Source

959-iiif-width-height-caching Islandora IIIF: Add search endpoint config to manifest.

959-iiif-width-height-caching
Alexander O'Neill 12 months ago
parent
commit
ec29a45bde
  1. 12
      modules/islandora_iiif/config/schema/islandora_iiif.schema.yml
  2. 28
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

12
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"

28
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.<br>E.g., paged-content-search/%node?search-in-pages=%keywords"),
'#default_value' => $this->options['search_endpoint'],
'#required' => FALSE,
];
}
/**

Loading…
Cancel
Save