Module: DepictionsHelper
- Defined in:
- app/helpers/depictions_helper.rb
Instance Method Summary collapse
-
#depiction_svg_tag(depiction) ⇒ Object
!! NOT USED.
-
#depiction_tag(depiction, size: :thumb) ⇒ Object
Should this have Image?.
-
#depiction_to_json(depiction) ⇒ Object
TODO: this should evolve, maybe, into an IIIF response with the context being the depictied object.
- #depictions_sled_tag(depiction, size: :thumb) ⇒ Object
- #image_context_depiction_tag(depiction) ⇒ Object
-
#label_for_depiction(depiction) ⇒ Object
Only text, no HTML.
Instance Method Details
#depiction_svg_tag(depiction) ⇒ Object
!! NOT USED
35 36 37 38 39 40 41 42 |
# File 'app/helpers/depictions_helper.rb', line 35 def depiction_svg_tag(depiction) anchor = "clip_#{depiction.id}" content_tag(:svg, {foo: nil, "viewBox" => depiction.svg_view_box, xmlns: "http://www.w3.org/2000/svg", 'xmlns:xlink' => "http://www.w3.org/1999/xlink"}) do ( content_tag('clip-path', depiction.svg_clip, id: anchor ).html_safe + content_tag(: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.(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.
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/depictions_helper.rb', line 53 def depiction_to_json(depiction) return nil if depiction.nil? a = { caption: depiction., 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
44 45 46 47 48 49 |
# File 'app/helpers/depictions_helper.rb', line 44 def depictions_sled_tag(depiction, size: :thumb) content_tag(:figure) do image_tag(depiction.sled_extraction_path(size), skip_pipeline: true) + content_tag(:figcaption, image_context_depiction_tag(depiction)) end end |
#image_context_depiction_tag(depiction) ⇒ Object
28 29 30 31 |
# File 'app/helpers/depictions_helper.rb', line 28 def image_context_depiction_tag(depiction) return nil if depiction.nil? object_tag(depiction.depiction_object.) end |
#label_for_depiction(depiction) ⇒ Object
Only text, no HTML
18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/depictions_helper.rb', line 18 def label_for_depiction(depiction) return nil if depiction.nil? [ label_for(depiction.depiction_object.).to_s + ':', [depiction.figure_label, depiction.].compact.join('. ') + '.', '(' + depiction.depiction_object_type.to_s + ').' # ('Depicts ' + label_for(depiction.depiction_object.metamorphosize).to_s + ', ' + Utilities::Strings.a_label(depiction.depiction_object_type).to_s + '.'), ].compact.join(' ').gsub(/\.\./, '.').gsub(' . ', ' ') end |