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

Add islandora_mirador submodule #10

Merged
merged 41 commits into from
Sep 4, 2020

Conversation

elizoller
Copy link
Member

@elizoller elizoller commented Sep 18, 2019

What does this Pull Request do?

Adds Mirador 3 JS and a Mirador block with a configuration for the manifest URL.

What's new?

  • Adds a Mirador block with template
  • Adds MIrador JS (version 3)
  • Adds extremely minimal CSS
  • Adds a config on the block for the IIIF manifest URL
  • Passes the manifest URL to the block

How should this be tested?

  • Pull down the PR
  • Add the "Mirador" term to the islandora display taxonomy (this could be done manually or by running the migration on islandora_defaults_tags like drush migrate:import islandora_defaults_tags)
  • Config import to the islandora_defaults config changes - they are config/install/context.context.openseadragon_block.yml and config/install/views.view.iiif_manifest.yml and all of the config/install/core.entity_view_display.node.islandora_object* files (for all display modes of the islandora_object content type) (my preferred method for importing just a few configs is copy them to a directory like /var/www/html/drupal/config/onetime and then run drush config:import --partial --source /var/www/html/drupal/config/onetime
  • Enable the Islandora Mirador Module
  • Have either a paged content object or an image object with the display hint of Mirador selected
  • clear the cache

Interested parties

@Islandora-CLAW/committers

@Natkeeran
Copy link
Contributor

Natkeeran commented Sep 19, 2019

@elizoller

Yes, if you don't set a context, then you will see a white screen for all pages. But, if you restrict the viewer to only show on Paged Content nodes, it works as described above.

Nice work. Thank you.

@elizoller
Copy link
Member Author

I'll see if there is anything else I can come up with to avoid a white screen without a context to limit the application of the block because that doesn't seem great to get an automatic white screen when you enable the module

@elizoller
Copy link
Member Author

I added the default context to the PR so this should avoid the white screen issue.

@DonRichards
Copy link
Member

@elizoller Any progress on this?

@elizoller
Copy link
Member Author

I need to revise this PR before it can be tested. Hopefully in the next week.

@elizoller
Copy link
Member Author

@Islandora-CLAW/committers This should be ready for re-review

@manez
Copy link
Member

manez commented Aug 24, 2020

Just dropping a note that I have not been able to acheive the command line magic required to pull this in and test it locally, so I think I have to bow out of the group of testers. Sorry!

@jordandukart
Copy link
Member

Likely should spun off another ticket but should DrupalPractise be added as a sniff to phpcs?

FILE: ...ults/modules/islandora_mirador/src/Plugin/Block/MiradorBlock.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
 63 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
    |         | (DrupalPractice.Objects.GlobalDrupal.GlobalDrupal)
 64 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
    |         | (DrupalPractice.Objects.GlobalDrupal.GlobalDrupal)
 65 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
    |         | (DrupalPractice.Objects.GlobalDrupal.GlobalDrupal)
 67 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
    |         | (DrupalPractice.Objects.GlobalDrupal.GlobalDrupal)
 70 | WARNING | #description values usually have to run through t()
    |         | for translation
    |         | (DrupalPractice.General.DescriptionT.DescriptionT)
----------------------------------------------------------------------


FILE: ...irador/src/Plugin/Field/FieldFormatter/MiradorImageFormatter.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
 47 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
    |         | (DrupalPractice.Objects.GlobalDrupal.GlobalDrupal)
 49 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
    |         | (DrupalPractice.Objects.GlobalDrupal.GlobalDrupal)
 50 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
    |         | (DrupalPractice.Objects.GlobalDrupal.GlobalDrupal)
----------------------------------------------------------------------

Not sure how this would lineup with what other modules are doing @dannylamb @Islandora/8-x-committers, for reference: https://www.drupal.org/docs/drupal-apis/services-and-dependency-injection/services-and-dependency-injection-in-drupal-8#s-using-dependency-injection.

mirador:
version: 1.x
js:
js/mirador.min.js: {minified}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a discussion point than anything actionable but what's the undertook approach in Islandora in general for relying on external libraries? Seems Openseadragon at one point pointed out to Git and there's also the inflight CDN pull: https://github.com/Islandora/openseadragon/pull/26/files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did that cdn exist or did islandora put it there? it looks like there is https://www.jsdelivr.com/package/npm/mirador - i could probably swap that out if that's the way we want to go
@dannylamb

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That CDN exists I believe. I'm not sure what the defacto Drupal 8 approach is for pulling in packages tbh. One option would be to do something like https://www.bounteous.com/insights/2020/04/22/guide-loading-external-javascript-drupal/?lang=en-ca and utilize https://asset-packagist.org/.

However, not sure entirely this is the "correct" thing to do and may add more work on top of this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed it to the cdn version in 4a8a86b - what do people think of that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no preference around version or how things should be pulled in, was trying to get @dannylamb's attention to what we may want to do (know this discussion has come up on committers before).

* The DOM element that represents the Singleton Instance of this class.
* @type {string}
*/
var base = 'mirador';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something to note as an improvement / future use case. Would we want to bring this in as a setting and look to do something like https://github.com/Islandora/openseadragon/pull/26/files to support having multiple Miradors rendered on a page? In @seth-shaw-unlv's case he had a carousel where the viewers were being rendered.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can i assume you mean this one Islandora/openseadragon#28 ? i'll see if i can to do the same for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops ya 28. I mean don't necessary need to do it in this ticket just noting for a future improvement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems silly not to have it...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright... i think i might have to leave this as is and let someone else tackle it. my first several attempts didn't work as expected

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not entirely sure mirador allows this. i saw a reference that said multiple miradors in a single page would require iframes, but they may pertain only to older versions. so for now i enforced unique HTML ids, so some of the groundwork is at least laid.

modules/islandora_mirador/src/Form/MiradorConfigForm.php Outdated Show resolved Hide resolved
@dannylamb
Copy link
Contributor

@jordandukart The issues that DrupalPractise are unearthing are usually enforced. It would be nice to automate that enforcement though, just to guarantee it. I'm not sure what else it flags, but it's probably all good stuff.

@jordandukart
Copy link
Member

Forgot to mention on my review, functionality wise this totally works and is a great contribution from @elizoller! Code style things are the only things that stood out to me.

@kayakr
Copy link

kayakr commented Aug 28, 2020

Keen to try this out but it doesn't apply as a patch on top of 8.x-1.x, could do with a rebase...

@jordandukart
Copy link
Member

@kayakr I don't see any merge conflicts off of 8.x-1.x?

vagrant@islandora8:/var/www/html/drupal/web/modules/contrib$ git clone git@github.com:Islandora/islandora_defaults.git
Cloning into 'islandora_defaults'...
cremote: Enumerating objects: 30, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (26/26), done.
iremote: Total 1027 (delta 9), reused 12 (delta 4), pack-reused 997
Receiving objects: 100% (1027/1027), 221.47 KiB | 815.00 KiB/s, done.
Resolving deltas: 100% (687/687), done.
vagrant@islandora8:/var/www/html/drupal/web/modules/contrib$ cd islandora_defaults/
vagrant@islandora8:/var/www/html/drupal/web/modules/contrib/islandora_defaults$ git branch
* 8.x-1.x
vagrant@islandora8:/var/www/html/drupal/web/modules/contrib/islandora_defaults$ git remote add asu git@github.com:asulibraries/islandora_defaults.git
vagrant@islandora8:/var/www/html/drupal/web/modules/contrib/islandora_defaults$ git fetch asu
remote: Enumerating objects: 215, done.
remote: Counting objects: 100% (215/215), done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 291 (delta 130), reused 189 (delta 106), pack-reused 76
Receiving objects: 100% (291/291), 433.14 KiB | 1.45 MiB/s, done.
Resolving deltas: 100% (142/142), completed with 30 local objects.
From github.com:asulibraries/islandora_defaults
 * [new branch]      8.x-1.x         -> asu/8.x-1.x
 * [new branch]      collections     -> asu/collections
 * [new branch]      issue-962       -> asu/issue-962
 * [new branch]      master          -> asu/master
 * [new branch]      mirador         -> asu/mirador
 * [new branch]      pull/10         -> asu/pull/10
 * [new branch]      release         -> asu/release
 * [new branch]      solr_test2      -> asu/solr_test2
 * [new branch]      text_extraction -> asu/text_extraction
 * [new branch]      url-refactor    -> asu/url-refactor
vagrant@islandora8:/var/www/html/drupal/web/modules/contrib/islandora_defaults$ git merge asu/mirador
Merge made by the 'recursive' strategy.
 config/install/context.context.openseadragon_block.yml                                              |   5 +-
 config/install/core.entity_view_display.node.islandora_object.binary.yml                            |   3 +
 config/install/core.entity_view_display.node.islandora_object.default.yml                           |   5 +-
 config/install/core.entity_view_display.node.islandora_object.open_seadragon.yml                    |   3 +
 config/install/core.entity_view_display.node.islandora_object.pdfjs.yml                             |   3 +
 config/install/core.entity_view_display.node.islandora_object.teaser.yml                            |   3 +
 config/install/views.view.iiif_manifest.yml                                                         | 157 +++++++++++++++++++++-
 migrate/tags.csv                                                                                    |   1 +
 modules/islandora_mirador/config/install/context.context.mirador.yml                                |  28 ++++
 modules/islandora_mirador/config/install/context.context.paged_content_mirador.yml                  |  42 ++++++
 modules/islandora_mirador/config/install/core.entity_view_display.media.file.mirador.yml            |  41 ++++++
 modules/islandora_mirador/config/install/core.entity_view_display.media.image.mirador.yml           |  45 +++++++
 modules/islandora_mirador/config/install/core.entity_view_display.node.islandora_object.mirador.yml | 339 +++++++++++++++++++++++++++++++++++++++++++++++
 modules/islandora_mirador/config/install/core.entity_view_mode.media.mirador.yml                    |   9 ++
 modules/islandora_mirador/config/install/core.entity_view_mode.node.mirador.yml                     |   9 ++
 modules/islandora_mirador/config/install/islandora_mirador.settings.yml                             |   1 +
 modules/islandora_mirador/config/install/views.view.mirador_evas.yml                                | 477 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 modules/islandora_mirador/config/schema/islandora_mirador.schema.yml                                |   7 +
 modules/islandora_mirador/css/mirador.css                                                           |   3 +
 modules/islandora_mirador/islandora_mirador.features.yml                                            |   1 +
 modules/islandora_mirador/islandora_mirador.info.yml                                                |  11 ++
 modules/islandora_mirador/islandora_mirador.libraries.yml                                           |  15 +++
 modules/islandora_mirador/islandora_mirador.links.menu.yml                                          |   5 +
 modules/islandora_mirador/islandora_mirador.module                                                  |  26 ++++
 modules/islandora_mirador/islandora_mirador.routing.yml                                             |   7 +
 modules/islandora_mirador/js/mirador.min.js                                                         |   2 +
 modules/islandora_mirador/js/mirador_viewer.js                                                      |  47 +++++++
 modules/islandora_mirador/src/Form/MiradorConfigForm.php                                            |  68 ++++++++++
 modules/islandora_mirador/src/Plugin/Block/MiradorBlock.php                                         | 122 +++++++++++++++++
 modules/islandora_mirador/src/Plugin/Field/FieldFormatter/MiradorImageFormatter.php                 | 122 +++++++++++++++++
 modules/islandora_mirador/templates/mirador.html.twig                                               |  62 +++++++++
 modules/islandora_mirador/templates/miradordiv.html.twig                                            |  62 +++++++++
 32 files changed, 1727 insertions(+), 4 deletions(-)
 create mode 100644 modules/islandora_mirador/config/install/context.context.mirador.yml
 create mode 100644 modules/islandora_mirador/config/install/context.context.paged_content_mirador.yml
 create mode 100644 modules/islandora_mirador/config/install/core.entity_view_display.media.file.mirador.yml
 create mode 100644 modules/islandora_mirador/config/install/core.entity_view_display.media.image.mirador.yml
 create mode 100644 modules/islandora_mirador/config/install/core.entity_view_display.node.islandora_object.mirador.yml
 create mode 100644 modules/islandora_mirador/config/install/core.entity_view_mode.media.mirador.yml
 create mode 100644 modules/islandora_mirador/config/install/core.entity_view_mode.node.mirador.yml
 create mode 100644 modules/islandora_mirador/config/install/islandora_mirador.settings.yml
 create mode 100644 modules/islandora_mirador/config/install/views.view.mirador_evas.yml
 create mode 100644 modules/islandora_mirador/config/schema/islandora_mirador.schema.yml
 create mode 100644 modules/islandora_mirador/css/mirador.css
 create mode 100644 modules/islandora_mirador/islandora_mirador.features.yml
 create mode 100644 modules/islandora_mirador/islandora_mirador.info.yml
 create mode 100644 modules/islandora_mirador/islandora_mirador.libraries.yml
 create mode 100644 modules/islandora_mirador/islandora_mirador.links.menu.yml
 create mode 100644 modules/islandora_mirador/islandora_mirador.module
 create mode 100644 modules/islandora_mirador/islandora_mirador.routing.yml
 create mode 100644 modules/islandora_mirador/js/mirador.min.js
 create mode 100644 modules/islandora_mirador/js/mirador_viewer.js
 create mode 100644 modules/islandora_mirador/src/Form/MiradorConfigForm.php
 create mode 100644 modules/islandora_mirador/src/Plugin/Block/MiradorBlock.php
 create mode 100644 modules/islandora_mirador/src/Plugin/Field/FieldFormatter/MiradorImageFormatter.php
 create mode 100644 modules/islandora_mirador/templates/mirador.html.twig
 create mode 100644 modules/islandora_mirador/templates/miradordiv.html.twig
vagrant@islandora8:/var/www/html/drupal/web/modules/contrib/islandora_defaults$ 

@kayakr
Copy link

kayakr commented Aug 28, 2020

@jordandukart I was trying to apply the pull request as a patch on 8.x-1.x and composer says the patch won't apply...

@jordandukart
Copy link
Member

Chatted with @elizoller in Slack and his changes since the last bit of review uncovered a bug with the implementation. That is with how viewElements is being used it expects that the entity is rendered on the node route only. There are scenarios where entities can be rendered outside of this context (views/search results and so on).

Slack conversation for posterity and more details: https://islandora.slack.com/archives/CM5PPAV28/p1598647657104600.

…e field value to the node - this implies a media is only attached to a single node.
@jordandukart jordandukart dismissed dannylamb’s stale review September 3, 2020 11:01

Outdated and already addressed.

@jordandukart
Copy link
Member

This looks good to me, going to let this percolate for 24 hours and if no-one else chimes in will merge tomorrow, thanks for the contribution @elizoller!

@jordandukart jordandukart merged commit 475bd28 into Islandora:8.x-1.x Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants