Skip to content

Add Clover IIIF viewer and install generator (rails g hyrax:iiif_viewer clover)#7400

Merged
eltiffster merged 9 commits intomainfrom
install-iiif-av-viewer
Mar 25, 2026
Merged

Add Clover IIIF viewer and install generator (rails g hyrax:iiif_viewer clover)#7400
eltiffster merged 9 commits intomainfrom
install-iiif-av-viewer

Conversation

@eltiffster
Copy link
Copy Markdown
Contributor

@eltiffster eltiffster commented Mar 23, 2026

This PR addresses this issue on the March 26 Samvera Community Sprint Board. It's primarily motivated by the need to display subtitles or captions in the audio/video player (i.e. IIIF viewer). Universal Viewer does not support subtitles or captions at time of writing.

Summary

Add Clover IIIF Viewer and rake task generator for installing and configuring Clover as the default audio/video viewer.

Guidance for testing, such as acceptance criteria or new user interface behaviors:

  • In your test app (Dassie) folder, run rails generate hyrax:iiif_viewer clover rails hyrax:clover:install
  • The rake task generator should copy HTML, CSS, and JS files into your app's public/clover directory, and a _clover.html.erb into app/views/hyrax/base/iiif_viewers
  • It should add config.iiif_av_viewer = :clover into your app's config/initializers/hyrax.rb
  • Restart the rails server (or Docker container, if using) so that the changes to the initializer are picked up
  • To remove the viewer files and de-configure Clover, run rails destroy hyrax:iiif_viewer clover Hyrax::InstallIiifViewerService.remove(:clover) in the rails console (and restart).

Type of change (for release notes)

  • notes-minor New Features that are backward compatible

Detailed Description

Why Use a Flat/Vanilla JavaScript File?

Based on discussions about an install generator for Ramp into Hyrax with @kirkkwang, @Dananji, @cjcolvar, and @nhomenda, I decided to use this "Vanilla JavaScript" example as a model for this implementation for these reasons:

  • No extra dependencies: this implementation doesn't rely on any gems or additional JS bundlers to render the viewer as is.
  • Resilience to future Rails changes: Since Rails 8 changes the way the assets pipeline and JS bundling works, I hope to avoid increasing maintenance workload by sidestepping the assets pipeline altogether.

Tradeoffs and Caveats

Since the JS file is minified/pre-bundled, it can be hard to configure/customize Clover without using JS frameworks like Node, React, Next.js, etc. (Minor changes are possible but not easy to read; see comments in clover.js.)

Also, there doesn't seem to be an easy way to turn off the "Download" option in the options menu.

clover_download_button

I hope that's not a dealbreaker since default Hyrax treats read/download permissions as equivalent. However, administrators/developers of downstream apps may want to be aware of this. I think Ramp disables that feature by default, so Ramp could be a future alternative for those who need stricter permissions for downloads.

Backwards Compatibility

I see minimal impact on existing applications, but let me know if there's anything I've missed. I modified app/helpers/hyrax/iiif_helper to use a generalized iiif_viewer_base_url method so it would work with Clover and potentially other IIIF viewers as well. The universal_viewer_base_url method still exists with these changes.

Notes on Potential Reuse

You can reuse the install generator for other IIIF viewers. For example, if you have a vanilla JS implementation prepared for Ramp with a file structure like so:

# previously lib/generators/hyrax/templates/iiif_viewers, see discussion below
lib/generators/hyrax/iiif_viewer/templates 
  |__ _ramp.html.erb
  |__ ramp
       |__ ramp.js
       |__ ramp.html
       |__ ramp.css

Then run the following on the command line:

# Copies your files and adds config.iiif_av_viewer = :ramp to Hyrax initializer
rails generate hyrax:iiif_viewer ramp

# Removes files and de-configures ramp
rails destroy hyrax:iiif_viewer ramp

When running in a test environment, the service generator copies files into the tmp directory instead to avoid mishaps with your dev environment.

@samvera/hyrax-code-reviewers

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 23, 2026

Test Results

    17 files  ± 0      17 suites  ±0   3h 28m 40s ⏱️ + 1m 3s
 7 199 tests + 6   6 893 ✅ + 6  306 💤 ±0  0 ❌ ±0 
24 109 runs  +26  23 518 ✅ +26  591 💤 ±0  0 ❌ ±0 

Results for commit 3631843. ± Comparison against base commit aced8ad.

This pull request removes 443 and adds 449 tests. Note that renamed tests count towards both.
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplate:0x00007f2f62855500>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplate:0x00007f54353fba48>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplate:0x00007f97b013c5a0>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplate:0x00007ffa38ca1900>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplateAccess:0x00007f2f62943700>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplateAccess:0x00007f5435409ee0>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplateAccess:0x00007f97b0149750>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplateAccess:0x00007ffa38d5b198>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to destroy AdminSet: 4251c83c-7d1a-4331-9e55-8e28f922f236
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to destroy Hyrax::AdministrativeSet: 3b890769-98ca-44ff-a6da-9ceff7541e61
…
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplate:0x00007f2d38b844c8>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplate:0x00007f7fd917e750>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplate:0x00007f91a2c26060>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplate:0x00007fec224521d8>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplateAccess:0x00007f2d38cd76e0>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplateAccess:0x00007f7fd91bdae0>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplateAccess:0x00007f91a2c55c98>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to create #<Hyrax::PermissionTemplateAccess:0x00007fec22540798>
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to destroy AdminSet: fe3b0c39-ddd6-4939-9379-def72699dcfd
spec.abilities.ability_spec ‑ Hyrax::Ability AdminSets and PermissionTemplates a user without edit access is expected not to be able to destroy Hyrax::AdministrativeSet: 37b9e63c-3709-42ea-bf72-2c6dcdb6366a
…

♻️ This comment has been updated with latest results.

@eltiffster eltiffster marked this pull request as ready for review March 24, 2026 15:50
@dlpierce
Copy link
Copy Markdown
Member

Thanks for this! Since this generates files in the codebase, I'm concerned this is setup to run via a rake task calling a Thor::Group service instead of as a rails generator (which are also based on Thor::Group) like the other hyrax generators. Is there a reason for that?

Copy link
Copy Markdown
Member

@cjcolvar cjcolvar left a comment

Choose a reason for hiding this comment

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

I tested this out locally (at least installing) and it worked great!

iiif_viewer_base_url(:universal_viewer)
end

def iiif_viewer_base_url(viewer)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Love this refactor!

@cjcolvar
Copy link
Copy Markdown
Member

I'm going to try basing my Ramp installer on this branch.

@eltiffster
Copy link
Copy Markdown
Contributor Author

Thanks @dlpierce for the feedback!

I think it was just easier for me to wrap my head around it conceptually at first as a service, and also handy for testing. Now that you mention it, I do see that it would make sense as a rails generator. And it would probably make the code cleaner too. It shouldn't be too hard to refactor.

@eltiffster eltiffster changed the title Add Clover IIIF viewer and rake task (rails hyrax:clover:install) Add Clover IIIF viewer and install generator (rails g hyrax:iiif_viewer clover) Mar 25, 2026
…ce class)

To install Clover:
  rails generate hyrax:iiif_viewer clover

To remove Clover:
  rails destroy hyrax:iiif_viewer clover
@eltiffster
Copy link
Copy Markdown
Contributor Author

eltiffster commented Mar 25, 2026

@cjcolvar Since converting this to a generator, this would be the new hypothetical file structure for ramp:

lib/generators/hyrax/iiif_viewer/templates
  |__ _ramp.html.erb
  |__ ramp
       |__ ramp.js
       |__ ramp.html
       |__ ramp.css

And the new commands:

rails generate hyrax:iiif_viewer ramp
rails destroy hyrax:iiif_viewer ramp

Hope this helps!

@kirkkwang
Copy link
Copy Markdown
Contributor

this is super cool!

@eltiffster eltiffster merged commit 0f1d0f8 into main Mar 25, 2026
20 checks passed
@eltiffster eltiffster deleted the install-iiif-av-viewer branch March 25, 2026 21:14
@dlpierce dlpierce added the notes-minor Release Notes: Non-breaking features label Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes-minor Release Notes: Non-breaking features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants