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 for the purposes of object ancestry.
-
#child_work_attributes_function ⇒ Object
Here we allow for customization of the child work attributes.
- #default_iiif_manifest_version ⇒ Object
-
#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.
-
#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.
-
#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
- #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
138 139 140 |
# File 'lib/iiif_print/configuration.rb', line 138 def @additional_tesseract_options || "" 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.
206 207 208 209 210 |
# File 'lib/iiif_print/configuration.rb', line 206 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 for the purposes of object ancestry.
20 21 22 |
# File 'lib/iiif_print/configuration.rb', line 20 def ancestory_identifier_function @ancestory_identifier_function ||= ->(work) { work.id } end |
#child_work_attributes_function ⇒ Object
Here we allow for customization of the child work attributes
161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/iiif_print/configuration.rb', line 161 def child_work_attributes_function @child_work_attributes_function ||= lambda do |parent_work:, admin_set_id:| { admin_set_id: admin_set_id.to_s, creator: parent_work.creator.to_a, rights_statement: parent_work.rights_statement.to_a, visibility: parent_work.visibility.to_s, is_child: true } end end |
#default_iiif_manifest_version ⇒ Object
94 95 96 |
# File 'lib/iiif_print/configuration.rb', line 94 def default_iiif_manifest_version @default_iiif_manifest_version.presence || 2 end |
#excluded_model_name_solr_field_key ⇒ String
A string of a solr field key
88 89 90 91 |
# File 'lib/iiif_print/configuration.rb', line 88 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']
28 29 30 31 |
# File 'lib/iiif_print/configuration.rb', line 28 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.
220 221 222 |
# File 'lib/iiif_print/configuration.rb', line 220 def @iiif_metadata_field_presentation_order || nil 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
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/iiif_print/configuration.rb', line 103 def @metadata_fields ||= { 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].
194 195 196 197 198 |
# File 'lib/iiif_print/configuration.rb', line 194 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 |
#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.
182 183 184 |
# File 'lib/iiif_print/configuration.rb', line 182 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
62 63 64 65 66 67 68 69 |
# File 'lib/iiif_print/configuration.rb', line 62 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
154 155 156 |
# File 'lib/iiif_print/configuration.rb', line 154 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 -)
147 148 149 |
# File 'lib/iiif_print/configuration.rb', line 147 def uv_config_path @uv_config_path || "/uv/uv-config.json" end |
Instance Method Details
#handle_after_create_fileset(file_set, user) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/iiif_print/configuration.rb', line 8 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.
231 232 233 |
# File 'lib/iiif_print/configuration.rb', line 231 def @questioning_authority_fields ||= ['rights_statement', 'license'] end |
#questioning_authority_fields=(fields) ⇒ Object
224 225 226 |
# File 'lib/iiif_print/configuration.rb', line 224 def (fields) @questioning_authority_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.
77 78 79 80 81 82 83 |
# File 'lib/iiif_print/configuration.rb', line 77 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.
41 42 43 |
# File 'lib/iiif_print/configuration.rb', line 41 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
33 34 35 |
# File 'lib/iiif_print/configuration.rb', line 33 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 |