Skip to content

Commit

Permalink
I350 Derivatives & Update IiifPrint (#2210)
Browse files Browse the repository at this point in the history
* Update IiifPrint

* File Set Specs

Update specs based on derivative & file migration processing in Hyrax.

* Update IiifPrint to released gem

* Bring in most recent Hyrax updates

* Remove solr_document_behavior_decorator

Hyrax now redevines hydra_model so we don't have to.
  • Loading branch information
laritakr authored Jun 7, 2024
1 parent e046dd7 commit 53cf2e8
Show file tree
Hide file tree
Showing 19 changed files with 137 additions and 220 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ RUN wget https://github.com/ImageMagick/ImageMagick/archive/refs/tags/7.1.0-57.t
&& rm -rf ImageMagick* \
&& rm -rf /var/cache/apk/*

# Install "best" training data for Tesseract
RUN echo "📚 Installing Tesseract Best (training data)!" && \
cd /usr/share/tessdata/ && \
wget https://github.com/tesseract-ocr/tessdata_best/blob/main/eng.traineddata?raw=true -O eng_best.traineddata

ARG VIPS_VERSION=8.11.3

RUN set -x -o pipefail \
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ gem 'hyrax-doi', github: 'samvera-labs/hyrax-doi', branch: 'rails_hyrax_upgrade'
gem 'hyrax-iiif_av', github: 'samvera-labs/hyrax-iiif_av', branch: 'rails_hyrax_upgrade'
gem 'i18n-debug', require: false, group: %i[development test]
gem 'i18n-tasks', group: %i[development test]
gem 'iiif_print', github: 'scientist-softserv/iiif_print', branch: 'main'
gem 'iiif_print', '~> 2.0'
gem 'jbuilder', '~> 2.5'
gem 'jquery-rails' # Use jquery as the JavaScript library
gem 'openssl', '>= 3.2.0'
Expand Down
25 changes: 10 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ GIT

GIT
remote: https://github.com/samvera/hyrax.git
revision: 151fb0d38339e12eabdf99ce9d0b1a0f07685fd5
revision: 74f29943d88749a57077818d271b29729a6d7183
branch: double_combo
specs:
hyrax (5.0.1)
Expand Down Expand Up @@ -218,18 +218,6 @@ GIT
public_suffix (>= 2)
rack (>= 1.3.6)

GIT
remote: https://github.com/scientist-softserv/iiif_print.git
revision: 122e86634f17c8f40d9ae4d59d2d7deca00f1694
branch: main
specs:
iiif_print (1.0.0)
blacklight_iiif_search (>= 1.0, < 3.0)
derivative-rodeo (~> 0.5)
hyrax (>= 2.5, < 6)
nokogiri (>= 1.13.2)
rdf-vocab (~> 3.0)

GIT
remote: https://github.com/scientist-softserv/willow_sword.git
revision: 38a0906647fae2020e8b0b08e296f85c457fcb34
Expand Down Expand Up @@ -695,7 +683,8 @@ GEM
hiredis (0.6.3)
htmlentities (4.3.4)
http_logger (0.7.0)
httparty (0.21.0)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
Expand Down Expand Up @@ -767,6 +756,12 @@ GEM
json
iiif_manifest (1.3.1)
activesupport (>= 4)
iiif_print (2.0.0)
blacklight_iiif_search (>= 1.0, < 3.0)
derivative-rodeo (~> 0.5)
hyrax (>= 2.5, < 6)
nokogiri (>= 1.13.2)
rdf-vocab (~> 3.0)
iso-639 (0.3.6)
iso8601 (0.9.1)
jaro_winkler (1.5.6)
Expand Down Expand Up @@ -1504,7 +1499,7 @@ DEPENDENCIES
hyrax-iiif_av!
i18n-debug
i18n-tasks
iiif_print!
iiif_print (~> 2.0)
jbuilder (~> 2.5)
jquery-rails
json-canonicalization (= 0.3.1)
Expand Down
19 changes: 19 additions & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,23 @@ def can_import_works?
def can_export_works?
can_create_any_work?
end

##
# @api public
#
# Overrides hydra-head, (and restores the method from blacklight-access-controls)
def download_permissions
can :download, [::String, ::Valkyrie::ID] do |id|
test_download(id.to_s)
end

can :download, ::SolrDocument do |obj|
if obj.pdf? && !obj.show_pdf_download_button
false
else
cache.put(obj.id, obj)
test_download(obj.id)
end
end
end
end
19 changes: 0 additions & 19 deletions app/models/concerns/hyrax/solr_document_behavior_decorator.rb

This file was deleted.

11 changes: 11 additions & 0 deletions app/services/iiif_print/tenant_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ module PdfSplitter
mattr_accessor :iiif_print_splitter
self.iiif_print_splitter = ::IiifPrint::SplitPdfs::PagesToJpgsSplitter

##
def self.never_split_pdfs?
!TenantConfig.use_iiif_print?
end

##
# @api public
def self.call(*args)
Expand Down Expand Up @@ -147,6 +152,12 @@ def service
# In Hyrax::WorkShowPresenter we're only looking at the underlying file_sets. But IiifPrint
# needs to look at multiple places.
module WorkShowPresenterDecorator
##
# @return [Boolean] Identifies whether IiifPrint PDF splitting is active for this work's tenant
def split_pdfs?
TenantConfig.use_iiif_print?
end

##
# @return [Array<Symbol>] predicate methods (e.g. ending in "?") that reflect the types
# of files we want to consider for showing in the IIIF Viewer.
Expand Down
57 changes: 0 additions & 57 deletions app/views/hyrax/file_sets/_actions.html.erb

This file was deleted.

1 change: 1 addition & 0 deletions config/initializers/iiif_print.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
# config.sort_iiif_manifest_canvases_by = :date_published
config.default_iiif_manifest_version = 3
config.persistence_adapter = IiifPrint::PersistenceLayer::ValkyrieAdapter
config.additional_tesseract_options = "-l eng_best"
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This migration comes from iiif_print (originally 20231110163052)
class AddModelDetailsToIiifPrintPendingRelationships < ActiveRecord::Migration[5.2]
def change
add_column :iiif_print_pending_relationships, :parent_model, :string
add_column :iiif_print_pending_relationships, :child_model, :string
add_column :iiif_print_pending_relationships, :file_id, :string
add_column :iiif_print_pending_relationships, :parent_model, :string unless column_exists?(:iiif_print_pending_relationships, :parent_model)
add_column :iiif_print_pending_relationships, :child_model, :string unless column_exists?(:iiif_print_pending_relationships, :child_model)
add_column :iiif_print_pending_relationships, :file_id, :string unless column_exists?(:iiif_print_pending_relationships, :file_id)
end
end
1 change: 0 additions & 1 deletion docker-compose.bundle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Copy file to docker-compose.override.yml to override docker-compose.yml
# Only use for local development
version: '3.8'
services:
# Uncomment to allow for the use of a ruby debugger (byebug, pry, etc) in Docker.
# See http://playbook-staging.notch8.com/en/devops/docker_debugger for more info.
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.override-nodory.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

services:
solr:
ports:
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.8'

x-app: &app
image: ghcr.io/samvera/hyku:${TAG:-latest}
env_file:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: '3.8'
x-app: &app
build:
context: .
Expand Down
23 changes: 23 additions & 0 deletions spec/fixtures/derivatives/00-xml.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<alto xmlns="http://www.loc.gov/standards/alto/ns-v2#">
<Description>
<MeasurementUnit>pixel</MeasurementUnit>
</Description>
<Layout>
<Page ID="ID1" PHYSICAL_IMG_NR="1" HEIGHT="3685" WIDTH="2457">
<PrintSpace HEIGHT="3685" WIDTH="2457" HPOS="0" VPOS="0">
<TextBlock ID="ID1a" HEIGHT="3685" WIDTH="2457" HPOS="0" VPOS="0">
<TextLine HEIGHT="3685" WIDTH="2457" HPOS="0" VPOS="0">
<String CONTENT=" &#10; &#10; &#10; &#10; &#10; &#10;&#10;" WIDTH="1616" HEIGHT="3128" HPOS="466" VPOS="276"></String>
<String CONTENT=" &#10; &#10; &#10; &#10; &#10; &#10;&#10;" WIDTH="1616" HEIGHT="3128" HPOS="466" VPOS="276"></String>
<String CONTENT=" &#10; &#10; &#10; &#10; &#10; &#10;&#10;" WIDTH="1616" HEIGHT="3128" HPOS="466" VPOS="276"></String>
<String CONTENT=" &#10; &#10; &#10; &#10; &#10; &#10;&#10;" WIDTH="1616" HEIGHT="3128" HPOS="466" VPOS="276"></String>
<String CONTENT=" &#10; &#10; &#10; &#10; &#10; &#10;&#10;" WIDTH="1616" HEIGHT="3128" HPOS="466" VPOS="276"></String>
<String CONTENT=" &#10; &#10; &#10; &#10; &#10; &#10;&#10;" WIDTH="1616" HEIGHT="3128" HPOS="466" VPOS="276"></String>
<String CONTENT=" &#10; &#10; &#10; &#10; &#10; &#10;&#10;" WIDTH="1616" HEIGHT="3128" HPOS="466" VPOS="276"></String>
</TextLine>
</TextBlock>
</PrintSpace>
</Page>
</Layout>
</alto>
Binary file added spec/fixtures/derivatives/b6-thumbnail.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion spec/indexers/generic_work_resource_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

RSpec.describe GenericWorkResourceIndexer do
let(:indexer_class) { described_class }
let(:resource) { GenericWorkResource.new }
let!(:resource) { Hyrax.persister.save(resource: GenericWorkResource.new) }

it_behaves_like 'a Hyrax::Resource indexer'
end
2 changes: 1 addition & 1 deletion spec/indexers/image_resource_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

RSpec.describe ImageResourceIndexer do
let(:indexer_class) { described_class }
let(:resource) { ImageResource.new }
let!(:resource) { Hyrax.persister.save(resource: ImageResource.new) }

it_behaves_like 'a Hyrax::Resource indexer'
end

This file was deleted.

Loading

0 comments on commit 53cf2e8

Please sign in to comment.