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

Cdn #26

Merged
merged 5 commits into from
Nov 20, 2020
Merged

Cdn #26

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
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