Module: DepictionsHelper

Defined in:
app/helpers/depictions_helper.rb

Instance Method Summary collapse

Instance Method Details

#depiction_svg_tag(depiction) ⇒ Object

!! NOT USED



34
35
36
37
38
39
40
41
# File 'app/helpers/depictions_helper.rb', line 34

def depiction_svg_tag(depiction)
  anchor = "clip_#{depiction.id}"
  (:svg, {foo: nil, "viewBox" => depiction.svg_view_box, xmlns: "http://www.w3.org/2000/svg", 'xmlns:xlink' => "http://www.w3.org/1999/xlink"}) do
    ( ('clip-path', depiction.svg_clip, id: anchor ).html_safe +
     (:image, href: depiction.image.image_file.url, 'clip-path' => "url(##{anchor})" ).html_safe
    ).html_safe
  end
end

#depiction_tag(depiction, size: :thumb) ⇒ Object

Should this have Image?



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/depictions_helper.rb', line 4

def depiction_tag(depiction, size: :thumb)
  return nil if depiction.nil?
  if depiction.from_sled?
    depictions_sled_tag(depiction, size: size)
    # depiction_svg_tag(depiction)
  else
    tag.figure do
      image_tag(depiction.image.image_file.url(size)) +
        tag.figcaption(image_context_depiction_tag(depiction))
    end
  end
end

#depiction_to_json(depiction) ⇒ Object

TODO: this should evolve, maybe, into an IIIF response with the context being the depictied object.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/helpers/depictions_helper.rb', line 52

def depiction_to_json(depiction)
  return nil if depiction.nil?
  a = {
    caption: depiction.caption,
    figure_label: depiction.figure_label,
    position: depiction.position,
    thumb: short_url(depiction.image.image_file.url(:thumb)),
    medium: short_url(depiction.image.image_file.url(:medium)),
    content_type: depiction.image.image_file_content_type,
    original_png: original_as_png_via_api(depiction.image)
  }
  a
end

#depictions_sled_tag(depiction, size: :thumb) ⇒ Object



43
44
45
46
47
48
# File 'app/helpers/depictions_helper.rb', line 43

def depictions_sled_tag(depiction, size: :thumb)
  (:figure) do
    image_tag(depiction.sled_extraction_path(size), skip_pipeline: true) +
      (:figcaption, image_context_depiction_tag(depiction))
  end
end

#image_context_depiction_tag(depiction) ⇒ Object



27
28
29
30
# File 'app/helpers/depictions_helper.rb', line 27

def image_context_depiction_tag(depiction)
  return nil if depiction.nil?
  object_tag(depiction.depiction_object.metamorphosize)
end

#label_for_depiction(depiction) ⇒ Object

Only text, no HTML



18
19
20
21
22
23
24
25
# File 'app/helpers/depictions_helper.rb', line 18

def label_for_depiction(depiction)
  return nil if depiction.nil?
  [
    depiction.figure_label,
    depiction.caption,
   ('Depicts ' + label_for(depiction.depiction_object.metamorphosize).to_s + ', ' + Utilities::Strings.a_label(depiction.depiction_object_type).to_s + '.'),
  ].compact.join('. ').gsub(/\.\./, '')
end