Browse Source

Issue 1000 (#1001)

* Change to Boolean logic
* added forward slash to path
* Made Viewer display configurable

---------
Co-authored-by: Rosie Le Faive <lefaive@gmail.com>
pull/913/merge
Alan Stanley 1 year ago committed by GitHub
parent
commit
d0e0c29921
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      modules/islandora_iiif/config/schema/islandora_iiif.schema.yml
  2. 14
      modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php
  3. 24
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

7
modules/islandora_iiif/config/schema/islandora_iiif.schema.yml

@ -6,8 +6,11 @@ islandora_iiif.settings:
type: string type: string
label: 'IIIF Server Url' label: 'IIIF Server Url'
use_relative_paths: use_relative_paths:
type: boolean type: boolean
label: 'Use relative paths in manifest.' label: 'Use relative paths in manifest.'
show_title:
type: string
label: 'Show title in view'
views.style.iiif_manifest: views.style.iiif_manifest:
type: views_style type: views_style

14
modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php

@ -66,6 +66,11 @@ class IslandoraIIIFConfigForm extends ConfigFormBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, FormStateInterface $form_state) { 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'); $config = $this->config('islandora_iiif.settings');
$form['iiif_server'] = [ $form['iiif_server'] = [
'#type' => 'url', '#type' => 'url',
@ -84,6 +89,14 @@ class IslandoraIIIFConfigForm extends ConfigFormBase {
'#default_value' => $config->get('use_relative_paths'), '#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); return parent::buildForm($form, $form_state);
} }
@ -111,6 +124,7 @@ class IslandoraIIIFConfigForm extends ConfigFormBase {
$this->config('islandora_iiif.settings') $this->config('islandora_iiif.settings')
->set('iiif_server', $form_state->getValue('iiif_server')) ->set('iiif_server', $form_state->getValue('iiif_server'))
->set('use_relative_paths', $form_state->getValue('use_relative_paths')) ->set('use_relative_paths', $form_state->getValue('use_relative_paths'))
->set('show_title', $form_state->getValue('show_title'))
->save(); ->save();
} }

24
modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

@ -167,15 +167,33 @@ class IIIFManifest extends StylePluginBase {
// @todo assumming the view is a path like /node/1/manifest.json // @todo assumming the view is a path like /node/1/manifest.json
$url_components = explode('/', trim($request_url, '/')); $url_components = explode('/', trim($request_url, '/'));
array_pop($url_components); array_pop($url_components);
$content_path = implode('/', $url_components); $content_path = '/' . implode('/', $url_components);
$iiif_base_id = $request_host . '/' . $content_path; $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 // @see https://iiif.io/api/presentation/2.1/#manifest
$json += [ $json += [
'@type' => 'sc:Manifest', '@type' => 'sc:Manifest',
'@id' => $request_url, '@id' => $request_url,
// If the View has a title, set the View title as the manifest label. // 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', '@context' => 'http://iiif.io/api/presentation/2/context.json',
// @see https://iiif.io/api/presentation/2.1/#sequence // @see https://iiif.io/api/presentation/2.1/#sequence
'sequences' => [ 'sequences' => [

Loading…
Cancel
Save