From fe3568b5c795e5f88f5ea2f48454f9ea74c54628 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Mon, 13 Jul 2020 15:40:54 -0300 Subject: [PATCH 1/5] Trying to require js through packagist --- composer.json | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 52f2d5a..2d46cd2 100644 --- a/composer.json +++ b/composer.json @@ -10,9 +10,16 @@ "support": { "issues": "https://github.com/Islandora/documentation/issues" }, + "repositories": [ + { + "type": "composer", + "url": "https://asset-packagist.org" + } + ], "require": { "drupal/libraries": "dev-3.x", - "drupal/token": "^1.3" + "drupal/token": "^1.3", + "npm-asset/openseadragon": "^2.4" }, "authors": [ { @@ -30,5 +37,13 @@ "email": "jwhiklo@gmail.com", "role": "Maintainer" } - ] + ], + "extra": { + "installer-types": [ + "npm-asset" + ], + "installer-paths": { + "web/libraries/{$name}": ["type:npm-asset"] + } + } } From f7cb945f9daf951bfc89dfa6c0e41ee299484018 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Mon, 13 Jul 2020 16:23:49 -0300 Subject: [PATCH 2/5] Do we need that really? --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 2d46cd2..4aa44bb 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ } ], "require": { - "drupal/libraries": "dev-3.x", "drupal/token": "^1.3", "npm-asset/openseadragon": "^2.4" }, From b25d0f3d985155e500e0acc31a6756c8f3ebe67f Mon Sep 17 00:00:00 2001 From: dannylamb Date: Wed, 15 Jul 2020 10:53:39 -0300 Subject: [PATCH 3/5] Maybe it'll be easier with a CDN --- composer.json | 20 +++----------------- openseadragon.libraries.yml | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/composer.json b/composer.json index 4aa44bb..52f2d5a 100644 --- a/composer.json +++ b/composer.json @@ -10,15 +10,9 @@ "support": { "issues": "https://github.com/Islandora/documentation/issues" }, - "repositories": [ - { - "type": "composer", - "url": "https://asset-packagist.org" - } - ], "require": { - "drupal/token": "^1.3", - "npm-asset/openseadragon": "^2.4" + "drupal/libraries": "dev-3.x", + "drupal/token": "^1.3" }, "authors": [ { @@ -36,13 +30,5 @@ "email": "jwhiklo@gmail.com", "role": "Maintainer" } - ], - "extra": { - "installer-types": [ - "npm-asset" - ], - "installer-paths": { - "web/libraries/{$name}": ["type:npm-asset"] - } - } + ] } diff --git a/openseadragon.libraries.yml b/openseadragon.libraries.yml index c62d11b..5cfc5ed 100644 --- a/openseadragon.libraries.yml +++ b/openseadragon.libraries.yml @@ -6,6 +6,17 @@ init: component: css/openseadragon.css: {} dependencies: - - core/jquery - - core/jquery.once - - core/drupalSettings + - core/jquery + - core/jquery.once + - core/drupalSettings + - openseadragon/openseadragon + +openseadragon: + remote: https://openseadragon.github.io + version: 2.4.2 + license: + name: New BSD + url: https://openseadragon.github.io/license/ + gpl-compatible: true + js: + https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/openseadragon.min.js { type: external, minified: true } From f958ec9ffecac2bb1428b959e9c173b3b7c34be1 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Wed, 15 Jul 2020 11:42:51 -0300 Subject: [PATCH 4/5] Working with CDNJS --- README.md | 10 ++++------ openseadragon.libraries.yml | 2 +- openseadragon.module | 10 +++------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4a8ed71..f0dc301 100644 --- a/README.md +++ b/README.md @@ -11,18 +11,16 @@ Drupal 8 FieldFormatter to display an image or generic file using a IIIF Image s * [drupal/libraries](https://www.drupal.org/project/libraries) * [drupal/token](https://www.drupal.org/project/token) -* [OpenSeadragon library](https://github.com/openseadragon/openseadragon) ## Installation -As a Drupal module, this module can be installed via composer and enabled via Drush, like: +This module can be installed via composer and enabled via Drush, like: 1. `composer require islandora/openseadragon:dev-8.x-1.x` -2. download the version of OpenSeadragon that you want to install (i.e. download a release zip or tar from https://github.com/openseadragon/openseadragon/releases and unarchive it) -3. place the version of OpenSeadragon in your drupal install in a location such as `web/sites/all/assets/vendor/openseadragon` -4. `drush pm-en openseadragon` +1. `drush pm-en openseadragon` -If you are using the [islandora-playbook](https://github.com/Islandora-Devops/islandora-playbook), there is an [Ansible role](https://github.com/Islandora-Devops/ansible-role-drupal-openseadragon) already built for installing OpenSeadragon. +Downloading/deploying the openseadragon library itself is not neccessary, as it is referenced externally via a CDN. +If you are using the [islandora-playbook](https://github.com/Islandora-Devops/islandora-playbook), there is an [Ansible role](https://github.com/Islandora-Devops/ansible-role-drupal-openseadragon) already built for installing OpenSeadragon. ## Configuration diff --git a/openseadragon.libraries.yml b/openseadragon.libraries.yml index 5cfc5ed..1954322 100644 --- a/openseadragon.libraries.yml +++ b/openseadragon.libraries.yml @@ -19,4 +19,4 @@ openseadragon: url: https://openseadragon.github.io/license/ gpl-compatible: true js: - https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/openseadragon.min.js { type: external, minified: true } + https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/openseadragon.min.js: { type: external, minified: true } diff --git a/openseadragon.module b/openseadragon.module index 396702a..fe61b09 100644 --- a/openseadragon.module +++ b/openseadragon.module @@ -20,13 +20,12 @@ function openseadragon_libraries_info() { 'download url' => 'https://github.com/openseadragon/openseadragon/master/zipball', 'version arguments' => [ 'file' => 'openseadragon.js', - // //! openseadragon 2.2.1. 'pattern' => '@openseadragon ([0-9\.-]+)@', 'lines' => 1, 'columns' => 50, ], 'versions' => [ - '2.2.1' => [ + '2.4.2' => [ 'files' => [ 'js' => [ 'openseadragon.js', @@ -68,9 +67,6 @@ function template_preprocess_openseadragon_formatter(&$variables) { $config = \Drupal::service('openseadragon.config'); $fileinfo_service = \Drupal::service('openseadragon.fileinfo'); - // TODO: Once Libraries API is finished find a function for this. - $base_library_path = 'sites/all/assets/vendor'; - $classes_array = ['openseadragon-viewer']; $viewer_settings = $config->getSettings(TRUE); $iiif_address = $config->getIiifAddress(); @@ -106,7 +102,7 @@ function template_preprocess_openseadragon_formatter(&$variables) { 'fitToAspectRatio' => $viewer_settings['fit_to_aspect_ratio'], 'options' => [ 'id' => $openseadragon_viewer_id, - 'prefixUrl' => file_create_url("{$base_library_path}/openseadragon/images/"), + 'prefixUrl' => 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/images/' 'tileSources' => $tile_sources, ] + $viewer_settings, ]; @@ -151,7 +147,7 @@ function template_preprocess_openseadragon_iiif_manifest_block(&$variables) { 'fitToAspectRatio' => $viewer_settings['fit_to_aspect_ratio'], 'options' => [ 'id' => $openseadragon_viewer_id, - 'prefixUrl' => file_create_url("{$base_library_path}/openseadragon/images/"), + 'prefixUrl' => 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/images/', 'tileSources' => $tile_sources, ] + $viewer_settings, ]; From 348df7fc684bece29bd21cbd98f6d735342601d5 Mon Sep 17 00:00:00 2001 From: dannylamb Date: Wed, 15 Jul 2020 16:06:41 -0300 Subject: [PATCH 5/5] *facepalm* missing a comma --- openseadragon.module | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openseadragon.module b/openseadragon.module index fe61b09..0f5fa10 100644 --- a/openseadragon.module +++ b/openseadragon.module @@ -102,7 +102,7 @@ function template_preprocess_openseadragon_formatter(&$variables) { 'fitToAspectRatio' => $viewer_settings['fit_to_aspect_ratio'], 'options' => [ 'id' => $openseadragon_viewer_id, - 'prefixUrl' => 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/images/' + 'prefixUrl' => 'https://cdnjs.cloudflare.com/ajax/libs/openseadragon/2.4.2/images/', 'tileSources' => $tile_sources, ] + $viewer_settings, ];