Skip to content

Commit

Permalink
Cdn change (#26)
Browse files Browse the repository at this point in the history
Changes code to use a CDN for the openseadragon JS and images
  • Loading branch information
dannylamb authored Nov 20, 2020
1 parent 84f424d commit 6c9ae44
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 14 additions & 3 deletions openseadragon.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
10 changes: 3 additions & 7 deletions openseadragon.module
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
];
Expand Down Expand Up @@ -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,
];
Expand Down

0 comments on commit 6c9ae44

Please sign in to comment.