From be9936bf1ef5d3aaab756a7b45c563f8132ce150 Mon Sep 17 00:00:00 2001 From: nruest Date: Wed, 16 Aug 2023 20:46:42 -0400 Subject: [PATCH 1/6] Allow OSD to show on restricted paged objects. - Alternate implementation of https://github.com/Islandora/openseadragon/pull/51 - Resolves https://github.com/yorkulibraries/york_drupal_theme/issues/78 --- openseadragon.module | 4 +++- src/IIIFManifestParser.php | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/openseadragon.module b/openseadragon.module index 161e42d..caff59b 100644 --- a/openseadragon.module +++ b/openseadragon.module @@ -89,6 +89,7 @@ function template_preprocess_openseadragon_formatter(&$variables) { $variables['#attached']['library'] = [ 'openseadragon/init', ]; + $access_token = \Drupal::service('jwt.authentication.jwt')->generateToken(); $variables['#attached']['drupalSettings']['openseadragon'][$openseadragon_viewer_id] = [ 'basePath' => Url::fromUri($iiif_address), 'fitToAspectRatio' => $viewer_settings['fit_to_aspect_ratio'], @@ -110,11 +111,12 @@ function template_preprocess_openseadragon_formatter(&$variables) { * Implements template_preprocess_HOOK(). */ function template_preprocess_openseadragon_iiif_manifest_block(&$variables) { + $access_token = \Drupal::service('jwt.authentication.jwt')->generateToken(); $cache_meta = CacheableMetadata::createFromRenderArray($variables); // Get the tile sources from the manifest. $parser = \Drupal::service('openseadragon.manifest_parser'); - $tile_sources = $parser->getTileSources($variables['iiif_manifest_url']); + $tile_sources = $parser->getTileSources($variables['iiif_manifest_url'], $access_token); if (empty($tile_sources)) { $cache_meta->applyTo($variables); diff --git a/src/IIIFManifestParser.php b/src/IIIFManifestParser.php index fc98f6a..e360aef 100644 --- a/src/IIIFManifestParser.php +++ b/src/IIIFManifestParser.php @@ -64,11 +64,13 @@ public function __construct( * * @param string $manifest_url * The location of the IIIF manifest, which can include tokens. + * @param string $access_token + * The JWT Access token. * * @return array * The URLs of all the tile sources in a manifest. */ - public function getTileSources($manifest_url) { + public function getTileSources($manifest_url, $access_token = NULL) { // Try to construct the URL out of a tokenized string // if the node is available. @@ -85,7 +87,16 @@ public function getTileSources($manifest_url) { try { // Request the manifest. - $manifest_response = $this->httpClient->get($manifest_url); + if (empty($access_token)) { + $manifest_response = $this->httpClient->get($manifest_url); + } + else { + $manifest_response = $this->httpClient->request('GET', $manifest_url, [ + 'headers' => [ + 'Authorization' => 'Bearer ' . $access_token, + ], + ]); + } // Decode the manifest json. $manifest_string = (string) $manifest_response->getBody(); From bce5b7dc990687731a039cd8208030982805c6c0 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 18 Oct 2023 14:15:41 -0300 Subject: [PATCH 2/6] Add in missing property definition. (#56) --- src/Config.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Config.php b/src/Config.php index 572910e..279c1cc 100644 --- a/src/Config.php +++ b/src/Config.php @@ -15,6 +15,13 @@ class Config implements ConfigInterface { use RefinableCacheableDependencyTrait; + /** + * The config factory service. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + /** * The openseadragon config. * From 9b517269f7a21f1577387b6c6e0c384f9c576cea Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Wed, 25 Oct 2023 14:20:59 -0300 Subject: [PATCH 3/6] Add PHP 8.2 and Drupal 10.2 to build matrix. (#58) --- .github/workflows/build-2.x.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-2.x.yml b/.github/workflows/build-2.x.yml index 23abfd8..7c34aa6 100644 --- a/.github/workflows/build-2.x.yml +++ b/.github/workflows/build-2.x.yml @@ -22,8 +22,8 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ["8.1"] - drupal-version: ["9.5.x", "10.0.x", "10.1.x"] + php-versions: ["8.1", "8.2"] + drupal-version: ["10.0.x", "10.1.x", "10.2.x-dev"] allowed_failure: [false] mysql: ["8.0"] From a8c84e0373cca3bc89a5c62bcca4d5a2df80e8fa Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Thu, 26 Oct 2023 11:12:29 -0300 Subject: [PATCH 4/6] Update gitlab-mirror.yml --- .github/workflows/gitlab-mirror.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gitlab-mirror.yml b/.github/workflows/gitlab-mirror.yml index 1693362..38a5306 100644 --- a/.github/workflows/gitlab-mirror.yml +++ b/.github/workflows/gitlab-mirror.yml @@ -2,8 +2,8 @@ name: Mirror to Drupal.org GitLab on: push: - branches: - - 2.x + branches: [2.x] + tags: '*' jobs: build: From 629226c396c51d49038a4d93f449e34454a011bf Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Wed, 15 Nov 2023 14:17:15 -0400 Subject: [PATCH 5/6] Add COI integration to settings form. (#57) * Add COI integration to settings form. * Tabs to spaces. * Composer suggest COI module. --- composer.json | 3 +++ src/Form/OpenSeadragonSettingsForm.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/composer.json b/composer.json index 8d02970..66819d1 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,9 @@ "conflict": { "drupal/core": "<9.1" }, + "suggest": { + "drupal/coi": "Some configuration fields work with Config Override Inspector." + }, "authors": [ { "name": "Islandora Foundation", diff --git a/src/Form/OpenSeadragonSettingsForm.php b/src/Form/OpenSeadragonSettingsForm.php index 0641d5a..88bb4b0 100644 --- a/src/Form/OpenSeadragonSettingsForm.php +++ b/src/Form/OpenSeadragonSettingsForm.php @@ -96,6 +96,9 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $this->seadragonConfig->getIiifAddress(), '#required' => TRUE, '#description' => t('Please enter the image server location without trailing slash. eg: http://www.example.org/iiif/2.'), + '#config' => [ + 'key' => 'openseadragon.settings:iiif_server', + ], ], 'manifest_view' => [ '#type' => 'select', From 0949b1b5070dd3c41e0d6c4b6d6e19163660aae8 Mon Sep 17 00:00:00 2001 From: nruest Date: Thu, 15 Feb 2024 16:01:11 -0500 Subject: [PATCH 6/6] Fix for OSD paged viewer isn't showing up on french pages. - Resolves https://redmine.library.yorku.ca/issues/3957 --- src/IIIFManifestParser.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/IIIFManifestParser.php b/src/IIIFManifestParser.php index e360aef..56820ae 100644 --- a/src/IIIFManifestParser.php +++ b/src/IIIFManifestParser.php @@ -82,7 +82,20 @@ public function getTileSources($manifest_url, $access_token = NULL) { // If the URL is relative, make it absolute. if (substr($manifest_url, 0, 4) !== "http") { $manifest_url = ltrim($manifest_url, '/'); - $manifest_url = Url::fromRoute('', [], ['absolute' => TRUE])->toString() . $manifest_url; + + // Check if the URL starts with "/fr/" and adjust accordingly. + // https://redmine.library.yorku.ca/issues/3957 + if (strpos($manifest_url, '/fr/') === 0) { + // If the URL starts with "/fr/", don't trim the first slash. + $append_slash = ''; + } + else { + // If the URL doesn't start with "/fr/", trim the first slash. + $append_slash = '/'; + } + + // Construct the absolute URL. + $manifest_url = Url::fromRoute('', [], ['absolute' => TRUE])->toString() . $append_slash . $manifest_url; } try {