Skip to content

Commit

Permalink
Issue 1000 (#1001)
Browse files Browse the repository at this point in the history
* Change to Boolean logic
* added forward slash to path
* Made Viewer display configurable

---------
Co-authored-by: Rosie Le Faive <lefaive@gmail.com>
  • Loading branch information
ajstanley authored and rosiel committed Apr 2, 2024
1 parent 67561ff commit 372d019
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions modules/islandora_iiif/src/Form/IslandoraIIIFConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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);
}

Expand Down Expand Up @@ -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();
}

Expand Down
24 changes: 21 additions & 3 deletions modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,33 @@ 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}";
$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' => [
Expand Down

0 comments on commit 372d019

Please sign in to comment.