Skip to content

Commit

Permalink
🎁 IiifPrint configuration
Browse files Browse the repository at this point in the history
- Adds configurations to support tenants in iiif_print PDF
splitting feature.
  • Loading branch information
LaRita Robinson committed Apr 17, 2024
1 parent 8fb8723 commit 475b198
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 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
12 changes: 12 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 All @@ -167,6 +178,7 @@ def iiif_media?(presenter: representative_presenter)
#
# OVERRIDE Hyrax::WorkShowPresenter; this override introduces behavior to handle over-rides.
def iiif_viewer?
return false
Hyrax.config.iiif_image_server? &&
representative_id.present? &&
representative_presenter.present? &&
Expand Down
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

0 comments on commit 475b198

Please sign in to comment.