From aced9bbc5032e12105128d8799ecdb800f6ff280 Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Tue, 4 Apr 2023 17:36:39 -0700 Subject: [PATCH 1/2] Update LineageService and config This commit will add an over to IiifPrint::LineageService to look for slugs over ids. Also, we found that in some cases using `--psm 1` had problems where it flips the image incorrectly when the image is already in the right orientation. Considerations will be needed for images that are actually in the wrong orientation though. --- config/initializers/iiif_print.rb | 5 ++--- lib/iiif_print/lineage_service_decorator.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 lib/iiif_print/lineage_service_decorator.rb diff --git a/config/initializers/iiif_print.rb b/config/initializers/iiif_print.rb index 94aa63a1..042dabd9 100644 --- a/config/initializers/iiif_print.rb +++ b/config/initializers/iiif_print.rb @@ -21,9 +21,8 @@ # config.sort_iiif_manifest_canvases_by = :date_published # NOTE: As part of the docker build, we install an "eng_best". And based on - # conversations with the client, we are using --psm 1 (e.g. "Automatic - # page segmentation with OSD.") - config.additional_tessearct_options = "-l eng_best --psm 1" + # conversations with the client) + config.additional_tessearct_options = "-l eng_best" end require "iiif_print/split_pdfs/adventist_pages_to_jpgs_splitter" diff --git a/lib/iiif_print/lineage_service_decorator.rb b/lib/iiif_print/lineage_service_decorator.rb new file mode 100644 index 00000000..4ca26309 --- /dev/null +++ b/lib/iiif_print/lineage_service_decorator.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# OVERRIDE: IIIF Print v1.0.0 to work with slugs +IiifPrint::LineageService.module_eval do + def self.ancestor_ids_for(object) + ancestor_ids ||= [] + object.in_works.each do |work| + # looking for the #slug instead of #id + ancestor_ids << work&.slug || work.id + ancestor_ids += ancestor_ids_for(work) if work.is_child + end + ancestor_ids.flatten.compact.uniq + end +end From dada294f08ab4ebb8833028cc8983d67630b65af Mon Sep 17 00:00:00 2001 From: Kirk Wang Date: Wed, 5 Apr 2023 10:43:19 -0700 Subject: [PATCH 2/2] Use SlugBug instead of override This commit will favor the use of SlugBug over the override since the logic has been set up with the new configuration in IIIF Print. ref: https://github.com/scientist-softserv/iiif_print/pull/209/commits/ba4e955bac649fb0217606a6a0f898ec923ac36d Also, updated to the latest IIIF Print to see improvements with the `identify` call. ref: https://github.com/scientist-softserv/iiif_print/blob/62686fc62180d7d89654bf1fa726efc30cf6d351/lib/iiif_print/image_tool.rb#L77 --- Gemfile | 3 +-- Gemfile.lock | 4 ++-- app/models/concerns/slug_bug.rb | 2 ++ lib/iiif_print/lineage_service_decorator.rb | 14 -------------- 4 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 lib/iiif_print/lineage_service_decorator.rb diff --git a/Gemfile b/Gemfile index 9c504444..f46d0c5f 100644 --- a/Gemfile +++ b/Gemfile @@ -147,5 +147,4 @@ gem 'dog_biscuits', git: 'https://github.com/samvera-labs/dog_biscuits.git' gem 'order_already' gem 'hyrax-v2_graph_indexer' -gem 'iiif_print', "~> 1.0", git: 'https://github.com/scientist-softserv/iiif_print.git', branch: 'main' -# rubocop:enable Metrics/LineLength +gem 'iiif_print', "~> 1.0", git: 'https://github.com/scientist-softserv/iiif_print.git', ref: '97be189' diff --git a/Gemfile.lock b/Gemfile.lock index eeff2142..2c7deb3c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,8 +27,8 @@ GIT GIT remote: https://github.com/scientist-softserv/iiif_print.git - revision: e3384284a9992df867b7bedc256c82485355551d - branch: main + revision: 97be189e30ac002c1beb829f0cb5388a22a38523 + ref: 97be189 specs: iiif_print (1.0.0) blacklight_iiif_search (~> 1.0) diff --git a/app/models/concerns/slug_bug.rb b/app/models/concerns/slug_bug.rb index 71ae257a..b0d67130 100644 --- a/app/models/concerns/slug_bug.rb +++ b/app/models/concerns/slug_bug.rb @@ -41,3 +41,5 @@ def remove_index_and_reindex update_index end end + +IiifPrint.config.ancestory_identifier_function = ->(work) { work.to_param } diff --git a/lib/iiif_print/lineage_service_decorator.rb b/lib/iiif_print/lineage_service_decorator.rb deleted file mode 100644 index 4ca26309..00000000 --- a/lib/iiif_print/lineage_service_decorator.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# OVERRIDE: IIIF Print v1.0.0 to work with slugs -IiifPrint::LineageService.module_eval do - def self.ancestor_ids_for(object) - ancestor_ids ||= [] - object.in_works.each do |work| - # looking for the #slug instead of #id - ancestor_ids << work&.slug || work.id - ancestor_ids += ancestor_ids_for(work) if work.is_child - end - ancestor_ids.flatten.compact.uniq - end -end