Class: IiifPrint::Configuration
- Inherits:
-
Object
- Object
- IiifPrint::Configuration
- Defined in:
- lib/iiif_print/configuration.rb
Overview
rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
-
#additional_tesseract_options ⇒ String
The additional options to pass to the Tesseract configuration.
-
#after_create_fileset_handler ⇒ Object
writeonly
Sets the attribute after_create_fileset_handler.
-
#all_text_generator_function ⇒ Object
This configuration determines where to pull the full text from.
-
#ancestory_identifier_function ⇒ Proc
The function, with arity 1, that receives a work and returns it’s identifier (as a string) for the purposes of object ancestry.
-
#child_work_attributes_function ⇒ Object
Here we allow for customization of the child work attributes rubocop:disable Metrics/MethodLength, Metrics/BlockLength.
- #default_iiif_manifest_version ⇒ Object
-
#disk_limit ⇒ Object
Example settings in the initializer: config.memory_limit = “512MiB” # Limit for memory usage config.map_limit = “1GiB” # Limit for map usage config.disk_limit = “20KP” # Limit for disk usage.
-
#excluded_model_name_solr_field_key ⇒ String
A string of a solr field key.
-
#excluded_model_name_solr_field_values ⇒ Array<String>
By default, this uses an array of human readable types ex: [‘Generic Work’, ‘Image’].
-
#iiif_metadata_field_presentation_order ⇒ Array<Symbol>
This is the default sorter for the metadata.
- #ingest_queue_name ⇒ Symbol, Proc
-
#map_limit ⇒ Object
Example settings in the initializer: config.memory_limit = “512MiB” # Limit for memory usage config.map_limit = “1GiB” # Limit for map usage config.disk_limit = “20KP” # Limit for disk usage.
-
#memory_limit ⇒ Object
Example settings in the initializer: config.memory_limit = “512MiB” # Limit for memory usage config.map_limit = “1GiB” # Limit for map usage config.disk_limit = “20KP” # Limit for disk usage.
-
#metadata_fields ⇒ Object
private
rubocop:disable Metrics/MethodLength.
-
#ocr_coords_from_json_function ⇒ Object
This is used to determine where to pull the OCR coordinates from.
- #persistence_adapter ⇒ Object
-
#sort_iiif_manifest_canvases_by ⇒ Object
Normally, the canvases are sorted by the ‘ordered_members` association.
-
#unique_child_title_generator_function ⇒ Proc
The function, with keywords (though maybe you’ll want to splat ignore a few), is responsible for generating the child work file title.
-
#uv_base_path ⇒ Object
While we’re at it, we’re going to go ahead and make the base path configurable as well.
-
#uv_config_path ⇒ Object
According to github.com/samvera/hyrax/wiki/Hyrax-Management-Guide#universal-viewer-config the name of the UV config file should be /uv/uv_config.json (with an _) However, in most applications, it is /uv/uv-config.json (with a -).
Instance Method Summary collapse
- #default_persistence_adapter ⇒ Object
- #handle_after_create_fileset(file_set, user) ⇒ Object
-
#questioning_authority_fields ⇒ Object
This is used to explicitly set which fields should be rendered as a Questioning Authority in the UV.
- #questioning_authority_fields=(fields) ⇒ Object
-
#registered_ingest_dirs ⇒ Array<String>
This method wraps Hyrax’s configuration so we can sniff out the correct method to use.
-
#skip_splitting_pdf_files_that_end_with_these_texts ⇒ Object
@return [Array<String>] the file suffixes (e.g. [“.reader.pdf”]) that we will skip.
- #skip_splitting_pdf_files_that_end_with_these_texts=(values) ⇒ Object
Instance Attribute Details
#additional_tesseract_options ⇒ String
The additional options to pass to the Tesseract configuration
177 178 179 |
# File 'lib/iiif_print/configuration.rb', line 177 def || "" end |
#after_create_fileset_handler=(value) ⇒ Object (writeonly)
Sets the attribute after_create_fileset_handler
4 5 6 |
# File 'lib/iiif_print/configuration.rb', line 4 def after_create_fileset_handler=(value) @after_create_fileset_handler = value end |
#all_text_generator_function ⇒ Object
This configuration determines where to pull the full text from. By default, it will pull from the TXT file that is generated by the OCR engine. However, if your application has its own implementation of generating the full text, then you can set your own configuration here.
272 273 274 275 276 |
# File 'lib/iiif_print/configuration.rb', line 272 def all_text_generator_function @all_text_generator_function ||= lambda do |object:| IiifPrint::Data::WorkDerivatives.data(from: object, of_type: 'txt') end end |
#ancestory_identifier_function ⇒ Proc
The function, with arity 1, that receives a work and returns it’s identifier (as a string) for the purposes of object ancestry.
57 58 59 60 61 |
# File 'lib/iiif_print/configuration.rb', line 57 def ancestory_identifier_function # If the work.id is nil, keep it nil. Otherwise cast that id to a string; to deal with the # `Valkyrie::ID`. @ancestory_identifier_function ||= ->(work) { work.id&.to_s } end |
#child_work_attributes_function ⇒ Object
Here we allow for customization of the child work attributes rubocop:disable Metrics/MethodLength, Metrics/BlockLength
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/iiif_print/configuration.rb', line 201 def child_work_attributes_function @child_work_attributes_function ||= lambda do |parent_work:, admin_set_id:| = parent_work. lease = parent_work.lease = {} lease_params = {} visibility_params = {} if = { visibility: 'embargo', visibility_after_embargo: ., visibility_during_embargo: ., embargo_release_date: . } elsif lease lease_params = { visibility: 'lease', visibility_after_lease: lease.visibility_after_lease, visibility_during_lease: lease.visibility_during_lease, lease_release_date: lease.lease_expiration_date } else visibility_params = { visibility: parent_work.visibility.to_s } end params = { admin_set_id: admin_set_id.to_s, creator: parent_work.creator.to_a, rights_statement: parent_work.rights_statement.to_a, is_child: true } params.merge!().merge!(lease_params).merge!(visibility_params) end end |
#default_iiif_manifest_version ⇒ Object
133 134 135 |
# File 'lib/iiif_print/configuration.rb', line 133 def default_iiif_manifest_version @default_iiif_manifest_version.presence || 2 end |
#disk_limit ⇒ Object
Example settings in the initializer: config.memory_limit = “512MiB” # Limit for memory usage config.map_limit = “1GiB” # Limit for map usage config.disk_limit = “20KP” # Limit for disk usage
12 13 14 |
# File 'lib/iiif_print/configuration.rb', line 12 def disk_limit @disk_limit end |
#excluded_model_name_solr_field_key ⇒ String
A string of a solr field key
127 128 129 130 |
# File 'lib/iiif_print/configuration.rb', line 127 def excluded_model_name_solr_field_key return "human_readable_type_sim" unless defined?(@excluded_model_name_solr_field_key) @excluded_model_name_solr_field_key end |
#excluded_model_name_solr_field_values ⇒ Array<String>
By default, this uses an array of human readable types
ex: ['Generic Work', 'Image']
67 68 69 70 |
# File 'lib/iiif_print/configuration.rb', line 67 def excluded_model_name_solr_field_values return @excluded_model_name_solr_field_values unless @excluded_model_name_solr_field_values.nil? @excluded_model_name_solr_field_values = [] end |
#iiif_metadata_field_presentation_order ⇒ Array<Symbol>
This is the default sorter for the metadata. It will sort by the order of the keys specificied. By default, this is turned off as it returns nil. If you want to turn it on, you can set this this to an array of symbols the properties on the work.
286 287 288 |
# File 'lib/iiif_print/configuration.rb', line 286 def || nil end |
#ingest_queue_name ⇒ Symbol, Proc
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/iiif_print/configuration.rb', line 15 def ingest_queue_name return @ingest_queue_name if @ingest_queue_name.present? if defined?(Hyrax) Hyrax.config.ingest_queue_name elsif defined?(Bulkrax) && Bulkrax.config.respond_to?(:ingest_queue_name) Bulkrax.config.ingest_queue_name else :ingest end end |
#map_limit ⇒ Object
Example settings in the initializer: config.memory_limit = “512MiB” # Limit for memory usage config.map_limit = “1GiB” # Limit for map usage config.disk_limit = “20KP” # Limit for disk usage
12 13 14 |
# File 'lib/iiif_print/configuration.rb', line 12 def map_limit @map_limit end |
#memory_limit ⇒ Object
Example settings in the initializer: config.memory_limit = “512MiB” # Limit for memory usage config.map_limit = “1GiB” # Limit for map usage config.disk_limit = “20KP” # Limit for disk usage
12 13 14 |
# File 'lib/iiif_print/configuration.rb', line 12 def memory_limit @memory_limit end |
#metadata_fields ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
To move this to an ‘@api public` state, we need to consider what a proper configuration looks like.
These fields will appear in rendering order.
rubocop:disable Metrics/MethodLength
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/iiif_print/configuration.rb', line 142 def ||= { title: {}, description: {}, collection: {}, abstract: {}, date_modified: {}, creator: { render_as: :faceted }, contributor: { render_as: :faceted }, subject: { render_as: :faceted }, publisher: { render_as: :faceted }, language: { render_as: :faceted }, identifier: { render_as: :linked }, keyword: { render_as: :faceted }, date_created: { render_as: :linked }, based_near_label: {}, related_url: { render_as: :external_link }, resource_type: { render_as: :faceted }, source: {}, extent: {}, rights_statement: { render_as: :rights_statement }, rights_notes: {}, access_right: {}, license: { render_as: :license }, searchable_text: {} } end |
#ocr_coords_from_json_function ⇒ Object
This is used to determine where to pull the OCR coordinates from. By default, it will pull from the JSON file that is generated by the OCR engine. However, if you have a different source, you can set this configuration. Current implementation has access to the ‘file_set_id“ and the `document` [SolrDocument].
260 261 262 263 264 |
# File 'lib/iiif_print/configuration.rb', line 260 def ocr_coords_from_json_function @ocr_coords_from_json_function ||= lambda do |file_set_id:, **| IiifPrint::Data::WorkDerivatives.data(from: file_set_id, of_type: 'json') end end |
#persistence_adapter ⇒ Object
27 28 29 |
# File 'lib/iiif_print/configuration.rb', line 27 def persistence_adapter @persistence_adapter || default_persistence_adapter end |
#sort_iiif_manifest_canvases_by ⇒ Object
Normally, the canvases are sorted by the ‘ordered_members` association. However, if you want it to be sorted by another property, you can set this configuration. Change `nil` to something like `:title` or `:identifier`.
Should you want to sort by the filename of the image, you set ‘nil` to `:label`. This looks at the canvas label, which is typically set to the filename of the image.
248 249 250 |
# File 'lib/iiif_print/configuration.rb', line 248 def sort_iiif_manifest_canvases_by @sort_iiif_manifest_canvases_by || nil end |
#unique_child_title_generator_function ⇒ Proc
The function, with keywords (though maybe you’ll want to splat ignore a few), is responsible for generating the child work file title. of object ancestry.
The keyword parameters that will be passed to this function are:
:original_pdf_path - The fully qualified pathname to the original PDF from which the images
were split.
:image_path - The fully qualified pathname for an image of the single page from the PDF. :parent_work - The object in which we’re “attaching” the image. :page_number - The image is of the N-th page_number of the original PDF :page_padding - A helper number that indicates the number of significant digits of pages
(e.g. 150 pages would have a padding of 3).
rubocop:disable Lint/UnusedBlockArgument
101 102 103 104 105 106 107 108 |
# File 'lib/iiif_print/configuration.rb', line 101 def unique_child_title_generator_function @unique_child_title_generator_function ||= lambda { |original_pdf_path:, image_path:, parent_work:, page_number:, page_padding:| identifier = parent_work.id filename = File.basename(original_pdf_path) page_suffix = "Page #{(page_number.to_i + 1).to_s.rjust(page_padding.to_i, '0')}" "#{identifier} - #{filename} #{page_suffix}" } end |
#uv_base_path ⇒ Object
While we’re at it, we’re going to go ahead and make the base path configurable as well
193 194 195 |
# File 'lib/iiif_print/configuration.rb', line 193 def uv_base_path @uv_base_path || "/uv/uv.html" end |
#uv_config_path ⇒ Object
According to github.com/samvera/hyrax/wiki/Hyrax-Management-Guide#universal-viewer-config the name of the UV config file should be /uv/uv_config.json (with an _) However, in most applications, it is /uv/uv-config.json (with a -)
186 187 188 |
# File 'lib/iiif_print/configuration.rb', line 186 def uv_config_path @uv_config_path || "/uv/uv-config.json" end |
Instance Method Details
#default_persistence_adapter ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/iiif_print/configuration.rb', line 31 def default_persistence_adapter # There's probably some configuration of Hyrax we could use to better refine this; but it's # likely a reasonable guess. The main goal is to not break existing implementations and # maintain an upgrade path. if Gem::Version.new(Hyrax::VERSION) >= Gem::Version.new('6.0.0') IiifPrint::PersistenceLayer::ValkyrieAdapter else IiifPrint::PersistenceLayer::ActiveFedoraAdapter end end |
#handle_after_create_fileset(file_set, user) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/iiif_print/configuration.rb', line 44 def handle_after_create_fileset(file_set, user) if defined? @after_create_fileset_handler @after_create_fileset_handler.call(file_set, user) else IiifPrint::Data.handle_after_create_fileset(file_set, user) end end |
#questioning_authority_fields ⇒ Object
This is used to explicitly set which fields should be rendered as a Questioning Authority in the UV. By default, we render ‘rights_statement` and `license` as QA fields.
297 298 299 |
# File 'lib/iiif_print/configuration.rb', line 297 def ||= ['rights_statement', 'license'] end |
#questioning_authority_fields=(fields) ⇒ Object
290 291 292 |
# File 'lib/iiif_print/configuration.rb', line 290 def (fields) = Array.wrap(fields).map(&:to_s) end |
#registered_ingest_dirs ⇒ Array<String>
This method wraps Hyrax’s configuration so we can sniff out the correct method to use. The Hyrax::Configuration#whitelisted_ingest_dirs is deprecated in favor of Hyrax::Configuration#registered_ingest_dirs.
116 117 118 119 120 121 122 |
# File 'lib/iiif_print/configuration.rb', line 116 def registered_ingest_dirs if Hyrax.config.respond_to?(:registered_ingest_dirs) Hyrax.config.registered_ingest_dirs else Hyrax.config.whitelisted_ingest_dirs end end |
#skip_splitting_pdf_files_that_end_with_these_texts ⇒ Object
@return [Array<String>] the file suffixes (e.g. [“.reader.pdf”]) that we will skip. Per
the implementation of {.split_for_path_suffix?}, these values are cast to
downcase.
80 81 82 |
# File 'lib/iiif_print/configuration.rb', line 80 def skip_splitting_pdf_files_that_end_with_these_texts @skip_splitting_pdf_files_that_end_with_these_texts || [] end |
#skip_splitting_pdf_files_that_end_with_these_texts=(values) ⇒ Object
72 73 74 |
# File 'lib/iiif_print/configuration.rb', line 72 def skip_splitting_pdf_files_that_end_with_these_texts=(values) @skip_splitting_pdf_files_that_end_with_these_texts = Array.wrap(values).map(&:downcase) end |