Skip to content

Commit

Permalink
iiif rodeo includes
Browse files Browse the repository at this point in the history
  • Loading branch information
orangewolf committed Sep 21, 2023
1 parent e60efac commit 7510b7c
Showing 1 changed file with 53 additions and 8 deletions.
61 changes: 53 additions & 8 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,35 @@
Bundler.require(*groups)

module Hyku
# Providing a common method to ensure consistent UTF-8 encoding. Also removing the tricksy Byte
# Order Marker character which is an invisible 0 space character.
#
# @note In testing, we encountered errors with the file's character encoding
# (e.g. `Encoding::UndefinedConversionError`). The following will force the encoding to
# UTF-8 and replace any invalid or undefined characters from the original encoding with a
# "?".
#
# Given that we still have the original, and this is a derivative, the forced encoding
# should be acceptable.
#
# @param [String]
# @return [String]
#
# @see https://sentry.io/organizations/scientist-inc/issues/3773392603/?project=6745020&query=is%3Aunresolved&referrer=issue-stream
# @see https://github.com/samvera-labs/bulkrax/pull/689
# @see https://github.com/samvera-labs/bulkrax/issues/688
# @see https://github.com/scientist-softserv/adventist-dl/issues/179
def self.utf_8_encode(string)
string
.encode(Encoding.find('UTF-8'), invalid: :replace, undef: :replace, replace: "?")
.delete("\xEF\xBB\xBF")
end

class Application < Rails::Application
# Add this line to load the lib folder first because we need
# IiifPrint::SplitPdfs::AdventistPagesToJpgsSplitter
config.autoload_paths.unshift("#{Rails.root}/lib")

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
Expand All @@ -33,22 +61,37 @@ class Application < Rails::Application
end

config.to_prepare do
# Allows us to use decorator files in the app directory

# By default plain text files are not processed for text extraction. In adding
# Adventist::TextFileTextExtractionService to the beginning of the services array we are
# enabling text extraction from plain text files.
Hyrax::DerivativeService.services = [
Adventist::TextFileTextExtractionService,
IiifPrint::PluggableDerivativeService]

# When you are ready to use the derivative rodeo instead of the pluggable uncomment the
# following and comment out the preceding Hyrax::DerivativeService.service
#
# Hyrax::DerivativeService.services = [
# Adventist::TextFileTextExtractionService,
# IiifPrint::DerivativeRodeoService,
# Hyrax::FileSetDerivativesService]

DerivativeRodeo::Generators::HocrGenerator.additional_tessearct_options = "-l eng_best"

# Allows us to use decorator files
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

config.to_prepare do
# Allows us to use decorator files in the app directory
Dir.glob(File.join(File.dirname(__FILE__), "../lib/**/*_decorator*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

# OAI additions
Dir.glob(File.join(File.dirname(__FILE__), "../lib/oai/**/*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
# OAI additions
Dir.glob(File.join(File.dirname(__FILE__), "../lib/oai/**/*.rb")).sort.each do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end

# resolve reloading issue in dev mode
Expand All @@ -67,6 +110,8 @@ class Application < Rails::Application
Object.include(AccountSwitch)
end

# copies tinymce assets directly into public/assets
config.tinymce.install = :copy
##
# Psych Allow YAML Classes
#
Expand Down

0 comments on commit 7510b7c

Please sign in to comment.