From ee0c49fea5ac218a8d808aecf179ec0482de7c7f Mon Sep 17 00:00:00 2001 From: ajstanley Date: Sat, 2 Dec 2023 15:27:59 -0400 Subject: [PATCH 1/4] Change to Boolean logic --- modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index 779d3d06b..4360e2c2e 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -343,7 +343,7 @@ protected function getCanvasDimensions(string $iiif_url, FieldItemInterface $ima // If this is a TIFF AND we don't know the width/height // see if we can get the image size via PHP's core function. - if ($mime_type === 'image/tiff' && !($width || !$height)) { + if ($mime_type === 'image/tiff' && (!$width || !$height)) { $uri = $image->entity->getFileUri(); $path = $this->fileSystem->realpath($uri); $image_size = getimagesize($path); From 11c889b22234fe8a374fefc34ca5ae16bb41f7fa Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Mon, 4 Dec 2023 08:05:21 -0500 Subject: [PATCH 2/4] remove accidental newline --- modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index 42262a0b5..4360e2c2e 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -343,7 +343,6 @@ protected function getCanvasDimensions(string $iiif_url, FieldItemInterface $ima // If this is a TIFF AND we don't know the width/height // see if we can get the image size via PHP's core function. - if ($mime_type === 'image/tiff' && (!$width || !$height)) { $uri = $image->entity->getFileUri(); $path = $this->fileSystem->realpath($uri); From 6ab7dc562dd6a1cdd02019fe69f84dac211b25dd Mon Sep 17 00:00:00 2001 From: ajstanley Date: Sun, 10 Dec 2023 13:19:07 -0400 Subject: [PATCH 3/4] added forward slash to path --- .../islandora_iiif/src/Plugin/views/style/IIIFManifest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index 4360e2c2e..cf8f5c14d 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -167,8 +167,8 @@ public function render() { // @todo assumming the view is a path like /node/1/manifest.json $url_components = explode('/', trim($request_url, '/')); array_pop($url_components); - $content_path = implode('/', $url_components); - $iiif_base_id = $request_host . '/' . $content_path; + $content_path = '/' . implode('/', $url_components); + $iiif_base_id = "{$request_host}{$content_path}"; // @see https://iiif.io/api/presentation/2.1/#manifest $json += [ From f20e2fcc521c23df7092758471117b04c1d41077 Mon Sep 17 00:00:00 2001 From: ajstanley Date: Wed, 13 Dec 2023 15:32:57 -0400 Subject: [PATCH 4/4] Made Viewer display configurable --- .../config/schema/islandora_iiif.schema.yml | 7 +++++-- .../src/Form/IslandoraIIIFConfigForm.php | 14 +++++++++++++ .../src/Plugin/views/style/IIIFManifest.php | 20 ++++++++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml b/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml index f9e870efa..1f91450fa 100644 --- a/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml +++ b/modules/islandora_iiif/config/schema/islandora_iiif.schema.yml @@ -6,8 +6,11 @@ islandora_iiif.settings: type: string label: 'IIIF Server Url' use_relative_paths: - type: boolean - label: 'Use relative paths in manifest.' + type: boolean + label: 'Use relative paths in manifest.' + show_title: + type: string + label: 'Show title in view' views.style.iiif_manifest: type: views_style diff --git a/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php b/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php index a99539a3c..41bd84a4e 100644 --- a/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php +++ b/modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php @@ -66,6 +66,11 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { + $options = [ + 'none' => $this->t('None'), + 'view' => $this->t("From view title"), + 'node' => $this->t("From node title"), + ]; $config = $this->config('islandora_iiif.settings'); $form['iiif_server'] = [ '#type' => 'url', @@ -84,6 +89,14 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $config->get('use_relative_paths'), ]; + $form['show_title'] = [ + '#type' => 'select', + '#options' => $options, + '#title' => $this->t("Show title in viewer."), + '#description' => $this->t("Show title on your viewer, if viewer allows"), + '#default_value' => $config->get('show_title'), + ]; + return parent::buildForm($form, $form_state); } @@ -111,6 +124,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('islandora_iiif.settings') ->set('iiif_server', $form_state->getValue('iiif_server')) ->set('use_relative_paths', $form_state->getValue('use_relative_paths')) + ->set('show_title', $form_state->getValue('show_title')) ->save(); } diff --git a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php index cf8f5c14d..2fc8a431a 100644 --- a/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php +++ b/modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php @@ -169,13 +169,31 @@ public function render() { array_pop($url_components); $content_path = '/' . implode('/', $url_components); $iiif_base_id = "{$request_host}{$content_path}"; + $display = $this->iiifConfig->get('show_title'); + switch ($display) { + case 'none': + $label = ''; + break; + + case 'view': + $label = $this->view->getTitle(); + break; + + case 'node': + $label = $this->getEntityTitle($content_path); + + break; + + default: + $label = $this->t("IIIF Manifest"); + } // @see https://iiif.io/api/presentation/2.1/#manifest $json += [ '@type' => 'sc:Manifest', '@id' => $request_url, // If the View has a title, set the View title as the manifest label. - 'label' => $this->view->getTitle() ?: $this->getEntityTitle($content_path), + 'label' => $label, '@context' => 'http://iiif.io/api/presentation/2/context.json', // @see https://iiif.io/api/presentation/2.1/#sequence 'sequences' => [