Module: DepictionsHelper

Defined in:
app/helpers/depictions_helper.rb

Instance Method Summary collapse

Instance Method Details

#depiction_svg_tag(depiction) ⇒ Object

!! NOT USED



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

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
      tag.image(depiction.image.image_file.url(size)) +
        tag.figcaption(image_context_depiction_tag(depiction))
    end
  end
end

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



41
42
43
44
45
46
# File 'app/helpers/depictions_helper.rb', line 41

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

#image_context_depiction_tag(depiction) ⇒ Object



25
26
27
28
# File 'app/helpers/depictions_helper.rb', line 25

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
# File 'app/helpers/depictions_helper.rb', line 18

def label_for_depiction(depiction)
  return nil if depiction.nil?
  [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