Module: Macros::IIIF

Defined in:
lib/macros/iiif.rb

Overview

Macros for extracting Stanford Specific MODS values from Nokogiri documents

Instance Method Summary collapse

Instance Method Details

#grab_iiif_manifest(manifest) ⇒ Object


6
7
8
# File 'lib/macros/iiif.rb', line 6

def grab_iiif_manifest(manifest)
  ::DLME::Utils.fetch_json(manifest)
end

#iiif_sequence_id(iiif_json) ⇒ Object


26
27
28
# File 'lib/macros/iiif.rb', line 26

def iiif_sequence_id(iiif_json)
  rep_iiif_resource(iiif_json).dig('@id')
end

#iiif_sequence_service_conforms_to(iiif_json) ⇒ Object


38
39
40
# File 'lib/macros/iiif.rb', line 38

def iiif_sequence_service_conforms_to(iiif_json)
  iiif_service_conforms_to(rep_iiif_resource(iiif_json).dig('service', 'profile'))
end

#iiif_sequence_service_id(iiif_json) ⇒ Object


30
31
32
# File 'lib/macros/iiif.rb', line 30

def iiif_sequence_service_id(iiif_json)
  rep_iiif_resource(iiif_json).dig('service', '@id')
end

#iiif_sequence_service_protocol(iiif_json) ⇒ Object


34
35
36
# File 'lib/macros/iiif.rb', line 34

def iiif_sequence_service_protocol(iiif_json)
  rep_iiif_resource(iiif_json).dig('service', 'profile')
end

#iiif_service_conforms_to(service_profile) ⇒ Object


46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/macros/iiif.rb', line 46

def iiif_service_conforms_to(service_profile)
  # Using the thumbnail service profile for now
  if service_profile.include? 'http://iiif.io/api/image/'
    'http://iiif.io/api/image/'
  elsif service_profile.include? 'http://iiif.io/api/auth/'
    'http://iiif.io/api/auth/'
  elsif service_profile.include? 'http://iiif.io/api/presentation/'
    'http://iiif.io/api/presentation/'
  elsif service_profile.include? 'http://iiif.io/api/search/'
    'http://iiif.io/api/search/'
  end
end

#iiif_thumbnail_id(iiif_json) ⇒ Object


10
11
12
# File 'lib/macros/iiif.rb', line 10

def iiif_thumbnail_id(iiif_json)
  iiif_json.dig('thumbnail', '@id')
end

#iiif_thumbnail_service_conforms_to(iiif_json) ⇒ Object


22
23
24
# File 'lib/macros/iiif.rb', line 22

def iiif_thumbnail_service_conforms_to(iiif_json)
  iiif_service_conforms_to(iiif_json.dig('thumbnail', 'service', 'profile'))
end

#iiif_thumbnail_service_id(iiif_json) ⇒ Object


14
15
16
# File 'lib/macros/iiif.rb', line 14

def iiif_thumbnail_service_id(iiif_json)
  iiif_json.dig('thumbnail', 'service', '@id')
end

#iiif_thumbnail_service_protocol(iiif_json) ⇒ Object


18
19
20
# File 'lib/macros/iiif.rb', line 18

def iiif_thumbnail_service_protocol(iiif_json)
  iiif_json.dig('thumbnail', 'service', 'profile')
end

#rep_iiif_resource(manifest_json) ⇒ Object


42
43
44
# File 'lib/macros/iiif.rb', line 42

def rep_iiif_resource(manifest_json)
  manifest_json['sequences'].first['canvases'].first['images'].first['resource'] || {}
end