Module: DepictionsHelper
- Includes:
- RecordNavigationHelper
- Defined in:
- app/helpers/depictions_helper.rb
Instance Method Summary collapse
- #depiction_autocomplete_tag(depiction) ⇒ Object
-
#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.
-
#next_records(depiction) ⇒ Object
!!Array!!.
-
#previous_records(depiction) ⇒ Object
!!Array!!.
Methods included from RecordNavigationHelper
Instance Method Details
#depiction_autocomplete_tag(depiction) ⇒ Object
18 19 20 |
# File 'app/helpers/depictions_helper.rb', line 18 def depiction_autocomplete_tag(depiction) depiction_tag(depiction) end |
#depiction_svg_tag(depiction) ⇒ Object
!! NOT USED
40 41 42 43 44 45 46 47 |
# File 'app/helpers/depictions_helper.rb', line 40 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?
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/depictions_helper.rb', line 5 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 style: 'margin: 0.5em; margin-left: 0; margin-right: 0;' 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.
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/helpers/depictions_helper.rb', line 58 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
49 50 51 52 53 54 |
# File 'app/helpers/depictions_helper.rb', line 49 def depictions_sled_tag(depiction, size: :thumb) content_tag(:figure, style: 'margin: 0.5em; margin-left: 0; margin-right: 0;') 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
33 34 35 36 |
# File 'app/helpers/depictions_helper.rb', line 33 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
23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/depictions_helper.rb', line 23 def label_for_depiction(depiction) return nil if depiction.nil? [ label_for(depiction.depiction_object.).to_s + ':', [depiction.figure_label, depiction.caption].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 |
#next_records(depiction) ⇒ Object
Returns !!Array!!.
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/helpers/depictions_helper.rb', line 86 def next_records(depiction) # !! Note we only return depictions on Otus currently. d = ::Depiction .joins("JOIN otus ON depictions.depiction_object_type = 'Otu' AND depictions.depiction_object_id = otus.id") .where(project_id: depiction.project_id) .where('depictions.id > ?', depiction.id) .order(:id) .first [d].compact end |
#previous_records(depiction) ⇒ Object
Returns !!Array!!.
73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/helpers/depictions_helper.rb', line 73 def previous_records(depiction) # !! Note we only return depictions on Otus currently. d = ::Depiction .joins("JOIN otus ON depictions.depiction_object_type = 'Otu' AND depictions.depiction_object_id = otus.id") .where(project_id: depiction.project_id) .where('depictions.id < ?', depiction.id) .order(id: :desc) .first [d].compact end |