Browse Source

Merge branch 'Islandora:2.x' into has_media_view_filter

pull/880/head
Seth Shaw 2 years ago committed by GitHub
parent
commit
cc958f4164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      .github/workflows/build-2.x.yml
  2. 12
      config/schema/islandora.schema.yml
  3. 13
      islandora.module
  4. 13
      islandora.views.inc
  5. 2
      modules/islandora_core_feature/config/install/filehash.settings.yml
  6. 50
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
  7. 2
      modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
  8. 4
      src/Commands/IslandoraCommands.php
  9. 11
      tests/src/Functional/IslandoraImageFormatterTest.php

21
.github/workflows/build-2.x.yml

@ -77,11 +77,6 @@ jobs:
mysql: "8.0" mysql: "8.0"
test-suite: "functional-javascript" test-suite: "functional-javascript"
allowed_failure: true allowed_failure: true
- drupal-version: '10.0.x-dev'
php-versions: '8.0'
mysql: "8.0"
test-suite: "kernel"
allowed_failure: true
# 9.4.x-dev on PHP 8.1 # 9.4.x-dev on PHP 8.1
- drupal-version: '9.4.x-dev' - drupal-version: '9.4.x-dev'
php-versions: '8.1' php-versions: '8.1'
@ -98,22 +93,6 @@ jobs:
mysql: "8.0" mysql: "8.0"
test-suite: "functional-javascript" test-suite: "functional-javascript"
allowed_failure: true allowed_failure: true
# 10.0.x-dev on PHP 8.0
- drupal-version: '10.0.x-dev'
php-versions: '8.0'
mysql: "8.0"
test-suite: "kernel"
allowed_failure: true
- drupal-version: '10.0.x-dev'
php-versions: '8.0'
mysql: "8.0"
test-suite: "functional"
allowed_failure: true
- drupal-version: '10.0.x-dev'
php-versions: '8.0'
mysql: "8.0"
test-suite: "functional-javascript"
allowed_failure: true
# 10.0.x-dev on PHP 8.1 # 10.0.x-dev on PHP 8.1
- drupal-version: '10.0.x-dev' - drupal-version: '10.0.x-dev'
php-versions: '8.1' php-versions: '8.1'

12
config/schema/islandora.schema.yml

@ -158,14 +158,6 @@ condition.plugin.node_had_namespace:
pid_field: pid_field:
type: ignore type: ignore
label: 'PID field' label: 'PID field'
field.formatter.settings.islandora_image: field.formatter.settings.islandora_image:
type: mapping type: field.formatter.settings.image
label: 'Image field display format settings' label: 'Islandora image field display format settings'
mapping:
image_link:
type: string
label: 'Link image to'
image_style:
type: string
label: 'Image style'

13
islandora.module

@ -422,7 +422,7 @@ function islandora_entity_extra_field_info() {
if (!empty($pseudo_bundles)) { if (!empty($pseudo_bundles)) {
foreach ($pseudo_bundles as $key) { foreach ($pseudo_bundles as $key) {
list($bundle, $content_entity) = explode(":", $key); [$bundle, $content_entity] = explode(":", $key);
$extra_field[$content_entity][$bundle]['display']['field_gemini_uri'] = [ $extra_field[$content_entity][$bundle]['display']['field_gemini_uri'] = [
'label' => t('Fedora URI'), 'label' => t('Fedora URI'),
'description' => t('The URI to the persistent'), 'description' => t('The URI to the persistent'),
@ -451,6 +451,17 @@ function islandora_entity_view(array &$build, EntityInterface $entity, EntityVie
// Check if the source file is in Fedora or not. // Check if the source file is in Fedora or not.
$media_source_service = \Drupal::service('islandora.media_source_service'); $media_source_service = \Drupal::service('islandora.media_source_service');
$source_file = $media_source_service->getSourceFile($entity); $source_file = $media_source_service->getSourceFile($entity);
if (!$source_file) {
\Drupal::logger('islandora')->error(
\Drupal::service('string_translation')->translate(
"Can't get source file for @label (@id)", [
'@label' => $entity->label(),
"@id" => $entity->id(),
]
)
);
return;
}
$uri = $source_file->getFileUri(); $uri = $source_file->getFileUri();
$scheme = \Drupal::service('stream_wrapper_manager')->getScheme($uri); $scheme = \Drupal::service('stream_wrapper_manager')->getScheme($uri);
$flysystem_config = Settings::get('flysystem'); $flysystem_config = Settings::get('flysystem');

13
islandora.views.inc

@ -13,13 +13,16 @@ function islandora_views_data_alter(&$data) {
$fields = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('node'); $fields = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions('node');
foreach ($fields as $field => $field_storage_definition) { foreach ($fields as $field => $field_storage_definition) {
if ($field_storage_definition->getType() == 'integer' && strpos($field, "field_") === 0) { if ($field_storage_definition->getType() == 'integer' && strpos($field, "field_") === 0) {
$data['node__' . $field][$field . '_value']['field'] = $data['node__' . $field][$field]['field']; $prefixed_field = 'node__' . $field;
$data['node__' . $field][$field]['title'] = t('Integer Weight Selector (@field)', [ if (isset($data[$prefixed_field])) {
$data[$prefixed_field][$field . '_value']['field'] = $data[$prefixed_field][$field]['field'];
$data[$prefixed_field][$field]['title'] = t('Integer Weight Selector (@field)', [
'@field' => $field, '@field' => $field,
]); ]);
$data['node__' . $field][$field]['help'] = t('Provides a drag-n-drop reordering of integer-based weight fields.'); $data[$prefixed_field][$field]['help'] = t('Provides a drag-n-drop reordering of integer-based weight fields.');
$data['node__' . $field][$field]['title short'] = t('Integer weight selector'); $data[$prefixed_field][$field]['title short'] = t('Integer weight selector');
$data['node__' . $field][$field]['field']['id'] = 'integer_weight_selector'; $data[$prefixed_field][$field]['field']['id'] = 'integer_weight_selector';
}
} }
} }

2
modules/islandora_core_feature/config/install/filehash.settings.yml

@ -2,4 +2,4 @@ algos:
sha1: sha1 sha1: sha1
md5: '0' md5: '0'
sha256: '0' sha256: '0'
dedupe: false dedupe: 0

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

@ -3,8 +3,10 @@
namespace Drupal\islandora_iiif\Plugin\views\style; namespace Drupal\islandora_iiif\Plugin\views\style;
use Drupal\views\Plugin\views\style\StylePluginBase; use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Serializer\SerializerInterface; use Symfony\Component\Serializer\SerializerInterface;
@ -68,6 +70,13 @@ class IIIFManifest extends StylePluginBase {
*/ */
protected $iiifConfig; protected $iiifConfig;
/**
* The Drupal Entity Type Manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/** /**
* The Drupal Filesystem. * The Drupal Filesystem.
* *
@ -85,12 +94,13 @@ class IIIFManifest extends StylePluginBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, FileSystemInterface $file_system, Client $http_client, MessengerInterface $messenger) { public function __construct(array $configuration, $plugin_id, $plugin_definition, SerializerInterface $serializer, Request $request, ImmutableConfig $iiif_config, EntityTypeManagerInterface $entity_type_manager, FileSystemInterface $file_system, Client $http_client, MessengerInterface $messenger) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->serializer = $serializer; $this->serializer = $serializer;
$this->request = $request; $this->request = $request;
$this->iiifConfig = $iiif_config; $this->iiifConfig = $iiif_config;
$this->entityTypeManager = $entity_type_manager;
$this->fileSystem = $file_system; $this->fileSystem = $file_system;
$this->httpClient = $http_client; $this->httpClient = $http_client;
$this->messenger = $messenger; $this->messenger = $messenger;
@ -107,6 +117,7 @@ class IIIFManifest extends StylePluginBase {
$container->get('serializer'), $container->get('serializer'),
$container->get('request_stack')->getCurrentRequest(), $container->get('request_stack')->getCurrentRequest(),
$container->get('config.factory')->get('islandora_iiif.settings'), $container->get('config.factory')->get('islandora_iiif.settings'),
$container->get('entity_type.manager'),
$container->get('file_system'), $container->get('file_system'),
$container->get('http_client'), $container->get('http_client'),
$container->get('messenger') $container->get('messenger')
@ -121,18 +132,21 @@ class IIIFManifest extends StylePluginBase {
$iiif_address = $this->iiifConfig->get('iiif_server'); $iiif_address = $this->iiifConfig->get('iiif_server');
if (!is_null($iiif_address) && !empty($iiif_address)) { if (!is_null($iiif_address) && !empty($iiif_address)) {
// Get the current URL being requested. // Get the current URL being requested.
$request_url = $this->request->getSchemeAndHttpHost() . $this->request->getRequestUri(); $request_host = $this->request->getSchemeAndHttpHost();
$request_url = $this->request->getRequestUri();
// Strip off the last URI component to get the base ID of the URL. // Strip off the last URI component to get the base ID of the URL.
// @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('/', $request_url); $url_components = explode('/', $request_url);
array_pop($url_components); array_pop($url_components);
$iiif_base_id = implode('/', $url_components); $content_path = implode('/', $url_components);
$iiif_base_id = $request_host . '/' . $content_path;
// @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() ?: 'IIIF Manifest', 'label' => $this->view->getTitle() ?: $this->getEntityTitle($content_path),
'@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' => [
@ -260,6 +274,34 @@ class IIIFManifest extends StylePluginBase {
return $canvases; return $canvases;
} }
/**
* Pull a title from the node or media passed to this view.
*
* @param string $content_path
* The path of the content being requested.
*
* @return string
* The entity's title.
*/
public function getEntityTitle(string $content_path): string {
$entity_title = $this->t('IIIF Manifest');
try {
$params = Url::fromUserInput($content_path)->getRouteParameters();
if (isset($params['node'])) {
$node = $this->entityTypeManager->getStorage('node')->load($params['node']);
$entity_title = $node->getTitle();
}
elseif (isset($params['media'])) {
$media = $this->entityTypeManager->getStorage('media')->load($params['media']);
$entity_title = $media->getName();
}
}
catch (\InvalidArgumentException $e) {
}
return $entity_title;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

2
modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php

@ -12,7 +12,7 @@ use Drupal\islandora\Plugin\Action\AbstractGenerateDerivativeMediaFile;
* *
* @Action( * @Action(
* id = "generate_extracted_text_file", * id = "generate_extracted_text_file",
* label = @Translation("Generate an Extracted Text derivative file"), * label = @Translation("Generate Extracted Text for Media Attachment"),
* type = "media" * type = "media"
* ) * )
*/ */

4
src/Commands/IslandoraCommands.php

@ -4,7 +4,7 @@ namespace Drupal\islandora\Commands;
use Consolidation\AnnotatedCommand\CommandData; use Consolidation\AnnotatedCommand\CommandData;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountProxy; use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\Session\AccountSwitcherInterface; use Drupal\Core\Session\AccountSwitcherInterface;
use Drupal\Core\Session\UserSession; use Drupal\Core\Session\UserSession;
use Drush\Commands\DrushCommands; use Drush\Commands\DrushCommands;
@ -39,7 +39,7 @@ class IslandoraCommands extends DrushCommands {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function __construct(EntityTypeManagerInterface $entity_type_manager, AccountProxy $current_user, AccountSwitcherInterface $account_switcher) { public function __construct(EntityTypeManagerInterface $entity_type_manager, AccountProxyInterface $current_user, AccountSwitcherInterface $account_switcher) {
$this->entityTypeManager = $entity_type_manager; $this->entityTypeManager = $entity_type_manager;
$this->currentUser = $current_user; $this->currentUser = $current_user;
$this->accountSwitcher = $account_switcher; $this->accountSwitcher = $account_switcher;

11
tests/src/Functional/IslandoraImageFormatterTest.php

@ -27,13 +27,19 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase {
$testImageMediaType = $this->createMediaType('image', ['id' => 'test_image_media_type']); $testImageMediaType = $this->createMediaType('image', ['id' => 'test_image_media_type']);
$testImageMediaType->save(); $testImageMediaType->save();
$this->createEntityReferenceField('media', $testImageMediaType->id(), 'field_media_of', 'Media Of', 'node', 'default', [], 2); $this->createEntityReferenceField('media', $testImageMediaType->id(), 'field_media_of', 'Media Of', 'node', 'default', [], 2);
// Set the display mode to use the islandora_image formatter. // Set the display mode to use the islandora_image formatter.
// Also, only show the image on display to remove clutter. // Also, only show the image on display to remove clutter.
$display_options = [ $display_options = [
'type' => 'islandora_image', 'type' => 'islandora_image',
'settings' => ['image_style' => NULL, 'image_link' => 'content'], 'settings' => [
'image_style' => '',
'image_link' => 'content',
'image_loading' => [
'attribute' => 'eager',
],
],
]; ];
$display = $this->container->get('entity_display.repository')->getViewDisplay('media', $testImageMediaType->id(), 'default'); $display = $this->container->get('entity_display.repository')->getViewDisplay('media', $testImageMediaType->id(), 'default');
$display->setComponent('field_media_image', $display_options) $display->setComponent('field_media_image', $display_options)
->removeComponent('created') ->removeComponent('created')
@ -47,7 +53,6 @@ class IslandoraImageFormatterTest extends IslandoraFunctionalTestBase {
'title' => 'Test Node', 'title' => 'Test Node',
]); ]);
$node->save(); $node->save();
// Make a image for the Media. // Make a image for the Media.
$file = $this->container->get('entity_type.manager')->getStorage('file')->create([ $file = $this->container->get('entity_type.manager')->getStorage('file')->create([
'uid' => $account->id(), 'uid' => $account->id(),

Loading…
Cancel
Save