Sha256: ff3a298dca7e490cfe27e65b2cb8fd24586bccb56f44ac35c2ed8129f68dd48e

Contents?: true

Size: 1.19 KB

Versions: 20

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true
ActiveSupport::Reloader.to_prepare do
  Riiif::Image.file_resolver = Riiif::HttpFileResolver.new
  Riiif::Image.info_service = lambda do |id, _file|
    # id will look like a path to a pcdm:file
    # (e.g. rv042t299%2Ffiles%2F6d71677a-4f80-42f1-ae58-ed1063fd79c7)
    # but we just want the id for the FileSet it's attached to.

    # Capture everything before the first slash
    fs_id = id.sub(/\A([^\/]*)\/.*/, '\1')
    resp = Hyrax::SolrService.get("id:#{fs_id}")
    doc = resp['response']['docs'].first
    raise "Unable to find solr document with id:#{fs_id}" unless doc
    { height: doc['height_is'], width: doc['width_is'], format: doc['mime_type_ssi'], channels: doc['alpha_channels_ssi'] }
  end

  Riiif::Image.file_resolver.id_to_uri = lambda do |id|
    Hyrax::Base.id_to_uri(CGI.unescape(id)).tap do |url|
      Rails.logger.info "Riiif resolved #{id} to #{url}"
    end
  end

  Riiif::Image.authorization_service = Hyrax::IIIFAuthorizationService

  Riiif.not_found_image = Rails.root.join('app', 'assets', 'images', 'us_404.svg')
  Riiif.unauthorized_image = Rails.root.join('app', 'assets', 'images', 'us_404.svg')

  Riiif::Engine.config.cache_duration = 365.days
end

Version data entries

20 entries across 10 versions & 1 rubygems

Version Path
hyrax-3.6.0 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.6.0 .dassie/config/initializers/riiif.rb
hyrax-3.5.0 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.5.0 .dassie/config/initializers/riiif.rb
hyrax-3.4.2 .dassie/config/initializers/riiif.rb
hyrax-3.4.2 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.4.1 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.4.1 .dassie/config/initializers/riiif.rb
hyrax-3.4.0 .dassie/config/initializers/riiif.rb
hyrax-3.4.0 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.3.0 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.3.0 .dassie/config/initializers/riiif.rb
hyrax-3.2.0 .dassie/config/initializers/riiif.rb
hyrax-3.2.0 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.1.0 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.1.0 .dassie/config/initializers/riiif.rb
hyrax-3.0.2 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.0.2 .dassie/config/initializers/riiif.rb
hyrax-3.0.1 lib/generators/hyrax/templates/config/initializers/riiif.rb
hyrax-3.0.1 .dassie/config/initializers/riiif.rb