Module: IiifPrint::IiifManifestPresenter::DisplayImagePresenterDecorator

Extended by:
ActiveSupport::Concern
Defined in:
app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb

Overview

OVERRIDE: Hyrax v3.x

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_urlObject

Extending the presenter to the base url which includes the protocol. We need the base url to render the facet links and normalize the interface.



9
10
11
# File 'app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb', line 9

def base_url
  @base_url
end

Instance Method Details

#abilityObject

Extending this class because there is an #ability= but not #ability and this definition mirrors the Hyrax::IiifManifestPresenter#ability.



13
14
15
# File 'app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb', line 13

def ability
  @ability ||= NullAbility.new
end

#display_contentObject

OVERRIDE: IIIF Hyrax AV v0.2 #display_content for prez 3 manifests



31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb', line 31

def display_content
  return nil unless latest_file_id
  return super unless model.image?

  IIIFManifest::V3::DisplayContent
    .new(display_image_url(hostname),
      format: image_format(alpha_channels),
      width: width,
      height: height,
      type: 'Image',
      iiif_endpoint: iiif_endpoint(latest_file_id, base_url: hostname))
end

#display_imageObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb', line 17

def display_image
  return nil unless latest_file_id
  return nil unless model.image?
  return nil unless IiifPrint.config.default_iiif_manifest_version == 2

  IIIFManifest::DisplayImage
    .new(display_image_url(hostname),
      format: image_format(alpha_channels),
      width: width,
      height: height,
      iiif_endpoint: iiif_endpoint(latest_file_id, base_url: hostname))
end

#display_image_url(base_url) ⇒ Object



44
45
46
47
48
49
50
51
# File 'app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb', line 44

def display_image_url(base_url)
  if ENV['EXTERNAL_IIIF_URL'].present?
    # At the moment we are only concerned about Hyrax's default image url builder
    iiif_image_url_builder(url_builder: Hyrax.config.iiif_image_url_builder)
  else
    super
  end
end

#hostnameObject



64
65
66
# File 'app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb', line 64

def hostname
  @hostname || 'localhost'
end

#iiif_endpoint(file_id, base_url: request.base_url) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb', line 53

def iiif_endpoint(file_id, base_url: request.base_url)
  if ENV['EXTERNAL_IIIF_URL'].present?
    IIIFManifest::IIIFEndpoint.new(
      File.join(ENV['EXTERNAL_IIIF_URL'], file_id),
      profile: Hyrax.config.iiif_image_compliance_level_uri
    )
  else
    super
  end
end

#work?Boolean

Returns false.

Returns:

  • (Boolean)

    false



70
71
72
# File 'app/presenters/iiif_print/iiif_manifest_presenter/display_image_presenter_decorator.rb', line 70

def work?
  false
end