Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add site config for IIIF viewer #2197

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions application/src/Controller/IiifViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public function indexAction()
if (isset($miradorConfigUser['window.sideBarOpen'])) {
$miradorConfig['window']['sideBarOpen'] = $miradorConfigUser['window.sideBarOpen'];
}
if (isset($miradorConfigUser['selectedTheme'])) {
$miradorConfig['selectedTheme'] = $miradorConfigUser['selectedTheme'];
}

$view = new ViewModel;
$view->setTerminal(true);
Expand Down
29 changes: 29 additions & 0 deletions application/src/Form/SiteSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function init()
'browse' => 'Browse', // @translate
'show' => 'Show', // @translate
'search' => 'Search', // @translate
'iiif_viewer' => 'IIIF viewer', // @translate
]);

// o:assign_new_items element is a pseudo-setting that's ultimately set
Expand Down Expand Up @@ -424,6 +425,34 @@ public function init()
],
]);

// IIIF viewer section
$this->add([
'type' => 'checkbox',
'name' => 'iiif_viewer_sidebar',
'options' => [
'element_group' => 'iiif_viewer',
'label' => 'Show sidebar', // @translate
],
'attributes' => [
'value' => $settings->get('iiif_viewer_sidebar', false),
],
]);
$this->add([
'type' => 'select',
'name' => 'iiif_viewer_theme',
'options' => [
'element_group' => 'iiif_viewer',
'label' => 'Theme', // @translate
'value_options' => [
'light' => 'Light', // @translate
'dark' => 'Dark', // @translate
],
],
'attributes' => [
'value' => $settings->get('iiif_viewer_theme'),
],
]);

$addEvent = new Event('form.add_elements', $this);
$this->getEventManager()->triggerEvent($addEvent);

Expand Down
20 changes: 17 additions & 3 deletions application/src/Media/Renderer/IiifPresentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,25 @@ class IiifPresentation implements RendererInterface
{
public function render(PhpRenderer $view, MediaRepresentation $media, array $options = [])
{
$miradorConfig = [
'window.sideBarOpen' => false,
'selectedTheme' => 'light',
];
if ($view->status()->isSiteRequest()) {
// Respect site settings for the IIIF viewer.
$miradorConfig['window.sideBarOpen'] = (bool) $view->siteSetting('iiif_viewer_sidebar', false);
switch ($view->siteSetting('iiif_viewer_theme', 'light')) {
case 'dark':
$miradorConfig['selectedTheme'] = 'dark';
break;
case 'light':
default:
$miradorConfig['selectedTheme'] = 'light';
}
}
$query = [
'url' => $media->source(),
'mirador_config' => json_encode([
'window.sideBarOpen' => false,
]),
'mirador_config' => json_encode($miradorConfig),
];
return $view->iiifViewer($query, $options);
}
Expand Down
Loading