Skip to content

Commit

Permalink
iiif rodeo includes (#1985)
Browse files Browse the repository at this point in the history
* iiif rodeo includes

* Remove Adventist specific code from application.rb

---------

Co-authored-by: Kirk Wang <[email protected]>
  • Loading branch information
orangewolf and kirkkwang authored Sep 25, 2023
1 parent 5e6d249 commit 4574ecc
Showing 1 changed file with 48 additions and 8 deletions.
56 changes: 48 additions & 8 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,34 @@
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
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 +60,33 @@ class Application < Rails::Application
end

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

# Add any extra services before IiifPrint::PluggableDerivativeService to enable processing
Hyrax::DerivativeService.services = [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 +105,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 4574ecc

Please sign in to comment.