Module: GeoblacklightHelper
- Extended by:
- Deprecation
- Defined in:
- app/helpers/geoblacklight_helper.rb
Instance Method Summary collapse
-
#cartodb_link(file_link) ⇒ String
deprecated
Deprecated.
Use #carto_link instead.
-
#cartodb_provider ⇒ Object
deprecated
Deprecated.
Use #carto_provider instead.
- #document_available? ⇒ Boolean
- #document_downloadable? ⇒ Boolean
-
#download_text(format) ⇒ Object
Wraps download text with proper_case_format.
- #email_helper ⇒ Object
-
#formatted_name_reference(reference) ⇒ String
Looks up formatted names for references.
-
#geoblacklight_basemap ⇒ String
Selects the basemap used for map displays.
- #geoblacklight_icon(name) ⇒ Object
- #iiif_jpg_url ⇒ Object
-
#leaflet_options ⇒ Object
Returns a hash of the leaflet plugin settings to pass to the viewer.
-
#proper_case_format(format) ⇒ Object
Looks up properly formatted names for formats.
-
#render_facet_item_with_icon(field_name, item) ⇒ Object
Renders a facet item with an icon placed as the first child of ‘.facet-label`.
-
#render_facet_links(facet, items) ⇒ Object
Renders an unique array of search links based off of terms passed in using the facet parameter.
- #render_facet_tags(facet) ⇒ Object
- #render_search_form_no_navbar ⇒ Object
-
#render_value_as_truncate_abstract(args) ⇒ Object
Render value for a document’s field as a truncate abstract div.
-
#render_web_services(reference) ⇒ Object
Renders the partials for a Geoblacklight::Reference in the web services modal.
-
#show_attribute_table? ⇒ Boolean
Deteremines if item view should include attribute table.
- #sms_helper ⇒ Object
-
#snippit(args) ⇒ String
Blacklight catalog controller helper method to truncate field value to 150 chars.
Instance Method Details
#cartodb_link(file_link) ⇒ String
Use #carto_link instead.
Creates a Carto OneClick link link, using the configuration link
120 121 122 |
# File 'app/helpers/geoblacklight_helper.rb', line 120 def cartodb_link(file_link) carto_link(file_link) end |
#cartodb_provider ⇒ Object
Use #carto_provider instead.
Removes blank space from provider to accomodate CartoDB OneClick
110 111 112 |
# File 'app/helpers/geoblacklight_helper.rb', line 110 def cartodb_provider carto_provider end |
#document_available? ⇒ Boolean
13 14 15 |
# File 'app/helpers/geoblacklight_helper.rb', line 13 def document_available? @document.public? || (@document.same_institution? && user_signed_in?) end |
#document_downloadable? ⇒ Boolean
17 18 19 |
# File 'app/helpers/geoblacklight_helper.rb', line 17 def document_downloadable? document_available? && @document.downloadable? end |
#download_text(format) ⇒ Object
Wraps download text with proper_case_format
78 79 80 |
# File 'app/helpers/geoblacklight_helper.rb', line 78 def download_text(format) "#{t 'geoblacklight.download.download'} #{proper_case_format(format)}".html_safe end |
#email_helper ⇒ Object
9 10 11 |
# File 'app/helpers/geoblacklight_helper.rb', line 9 def email_helper content_tag(:i, '', class: 'fa fa-envelope fa-fw') + ' ' + t('blacklight.tools.email') end |
#formatted_name_reference(reference) ⇒ String
Looks up formatted names for references
71 72 73 |
# File 'app/helpers/geoblacklight_helper.rb', line 71 def formatted_name_reference(reference) t "geoblacklight.references.#{reference}" end |
#geoblacklight_basemap ⇒ String
Selects the basemap used for map displays
103 104 105 |
# File 'app/helpers/geoblacklight_helper.rb', line 103 def geoblacklight_basemap blacklight_config.basemap_provider || 'positron' end |
#geoblacklight_icon(name) ⇒ Object
39 40 41 42 43 44 |
# File 'app/helpers/geoblacklight_helper.rb', line 39 def geoblacklight_icon(name) content_tag :span, '', class: "geoblacklight-icon geoblacklight-#{name.parameterize}", title: name end |
#iiif_jpg_url ⇒ Object
21 22 23 |
# File 'app/helpers/geoblacklight_helper.rb', line 21 def iiif_jpg_url @document.references.iiif.endpoint.sub! 'info.json', 'full/full/0/default.jpg' end |
#leaflet_options ⇒ Object
Returns a hash of the leaflet plugin settings to pass to the viewer. @return
141 142 143 |
# File 'app/helpers/geoblacklight_helper.rb', line 141 def Settings.LEAFLET end |
#proper_case_format(format) ⇒ Object
Looks up properly formatted names for formats
63 64 65 |
# File 'app/helpers/geoblacklight_helper.rb', line 63 def proper_case_format(format) t "geoblacklight.formats.#{format.downcase}" end |
#render_facet_item_with_icon(field_name, item) ⇒ Object
Renders a facet item with an icon placed as the first child of ‘.facet-label`. This works with `render_facet_value` and `render_selected_facet_value`
150 151 152 153 154 155 |
# File 'app/helpers/geoblacklight_helper.rb', line 150 def render_facet_item_with_icon(field_name, item) doc = Nokogiri::HTML.fragment(render_facet_item(field_name, item)) doc.at_css('.facet-label').children.first .add_previous_sibling(geoblacklight_icon(item.value)) doc.to_html.html_safe end |
#render_facet_links(facet, items) ⇒ Object
Renders an unique array of search links based off of terms passed in using the facet parameter
54 55 56 57 58 |
# File 'app/helpers/geoblacklight_helper.rb', line 54 def render_facet_links(facet, items) items.uniq.map do |item| link_to item, search_catalog_path(f: { facet => [item] }) end.join(', ').html_safe end |
#render_facet_tags(facet) ⇒ Object
33 34 35 36 37 |
# File 'app/helpers/geoblacklight_helper.rb', line 33 def (facet) render_facet_limit(facets_from_request(facet).first, partial: 'facet_tag_item', layout: 'facet_tag_layout') end |
#render_search_form_no_navbar ⇒ Object
46 47 48 |
# File 'app/helpers/geoblacklight_helper.rb', line 46 def render partial: 'catalog/search_form_no_navbar' end |
#render_value_as_truncate_abstract(args) ⇒ Object
Render value for a document’s field as a truncate abstract div. Arguments come from Blacklight::DocumentPresenter’s get_field_values method
94 95 96 97 98 |
# File 'app/helpers/geoblacklight_helper.rb', line 94 def render_value_as_truncate_abstract(args) content_tag :div, class: 'truncate-abstract' do Array(args[:value]).flatten.join(' ') end end |
#render_web_services(reference) ⇒ Object
Renders the partials for a Geoblacklight::Reference in the web services modal
129 130 131 132 133 134 135 136 |
# File 'app/helpers/geoblacklight_helper.rb', line 129 def render_web_services(reference) render( partial: "web_services_#{reference.type}", locals: { reference: reference } ) rescue ActionView::MissingTemplate render partial: 'web_services_default', locals: { reference: reference } end |
#show_attribute_table? ⇒ Boolean
Deteremines if item view should include attribute table
85 86 87 |
# File 'app/helpers/geoblacklight_helper.rb', line 85 def show_attribute_table? document_available? && @document.inspectable? end |
#sms_helper ⇒ Object
5 6 7 |
# File 'app/helpers/geoblacklight_helper.rb', line 5 def sms_helper content_tag(:i, '', class: 'fa fa-mobile fa-fw') + ' ' + t('blacklight.tools.sms') end |
#snippit(args) ⇒ String
Blacklight catalog controller helper method to truncate field value to 150 chars
29 30 31 |
# File 'app/helpers/geoblacklight_helper.rb', line 29 def snippit(args) truncate(Array(args[:value]).flatten.join(' '), length: 150) end |