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_generated_body(format) ⇒ Object
- #download_link_direct(text, document) ⇒ Object
- #download_link_generated(download_type, document) ⇒ Object
- #download_link_hgl(text, document) ⇒ Object
-
#download_link_iiif ⇒ String
Generates the link markup for the IIIF JPEG download.
-
#download_text(format) ⇒ Object
Wraps download text with proper_case_format.
- #email_helper ⇒ Object
-
#first_metadata?(document, metadata) ⇒ Boolean
Determines whether or not the metadata is the first within the array of References.
-
#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_transformed_metadata(metadata) ⇒ String
Renders the transformed metadata (Renders a partial when the metadata isn’t available).
-
#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
195 196 197 |
# File 'app/helpers/geoblacklight_helper.rb', line 195 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
185 186 187 |
# File 'app/helpers/geoblacklight_helper.rb', line 185 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_generated_body(format) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'app/helpers/geoblacklight_helper.rb', line 141 def download_generated_body(format) value = proper_case_format(format) value = case value when t('geoblacklight.formats.shapefile') t('geoblacklight.download.export_shapefile_link') when t('geoblacklight.formats.kmz') t('geoblacklight.download.export_kmz_link') when t('geoblacklight.formats.geojson') t('geoblacklight.download.export_geojson_link') else value end value.html_safe end |
#download_link_direct(text, document) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/geoblacklight_helper.rb', line 25 def download_link_direct(text, document) link_to( text, document.direct_download[:download], 'contentUrl' => document.direct_download[:download], class: ['btn', 'btn-primary', 'btn-block', 'download', 'download-original'], data: { download: 'trigger', download_type: 'direct', download_id: document.id } ) end |
#download_link_generated(download_type, document) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/helpers/geoblacklight_helper.rb', line 67 def download_link_generated(download_type, document) link_to( t('geoblacklight.download.export_link', download_format: proper_case_format(download_type)), '', class: ['btn', 'btn-primary', 'btn-block', 'download', 'download-generated'], data: { download_path: download_path(document.id, type: download_type), download: 'trigger', download_type: download_type, download_id: document.id } ) end |
#download_link_hgl(text, document) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/geoblacklight_helper.rb', line 39 def download_link_hgl(text, document) link_to( text, download_hgl_path(id: document), class: ['btn', 'btn-primary', 'btn-block', 'download', 'download-original'], data: { ajax_modal: 'trigger', download: 'trigger', download_type: 'harvard-hgl', download_id: document.id } ) end |
#download_link_iiif ⇒ String
Generates the link markup for the IIIF JPEG download
55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/geoblacklight_helper.rb', line 55 def download_link_iiif link_to( download_text('JPG'), iiif_jpg_url, 'contentUrl' => iiif_jpg_url, class: ['btn', 'btn-primary', 'btn-block', 'download', 'download-generated'], data: { download: 'trigger' } ) end |
#download_text(format) ⇒ Object
Wraps download text with proper_case_format
135 136 137 138 139 |
# File 'app/helpers/geoblacklight_helper.rb', line 135 def download_text(format) download_format = proper_case_format(format) value = t('geoblacklight.download.download_link', download_format: download_format) value.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 |
#first_metadata?(document, metadata) ⇒ Boolean
Determines whether or not the metadata is the first within the array of References
252 253 254 |
# File 'app/helpers/geoblacklight_helper.rb', line 252 def (document, ) document.references..first.type == .type end |
#formatted_name_reference(reference) ⇒ String
Looks up formatted names for references
128 129 130 |
# File 'app/helpers/geoblacklight_helper.rb', line 128 def formatted_name_reference(reference) t "geoblacklight.references.#{reference}" end |
#geoblacklight_basemap ⇒ String
Selects the basemap used for map displays
178 179 180 |
# File 'app/helpers/geoblacklight_helper.rb', line 178 def geoblacklight_basemap blacklight_config.basemap_provider || 'positron' end |
#geoblacklight_icon(name) ⇒ Object
95 96 97 98 99 100 101 |
# File 'app/helpers/geoblacklight_helper.rb', line 95 def geoblacklight_icon(name) icon_name = name ? name.parameterize : 'none' content_tag :span, '', class: "geoblacklight-icon geoblacklight-#{icon_name}", 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
216 217 218 |
# File 'app/helpers/geoblacklight_helper.rb', line 216 def Settings.LEAFLET end |
#proper_case_format(format) ⇒ Object
Looks up properly formatted names for formats
120 121 122 |
# File 'app/helpers/geoblacklight_helper.rb', line 120 def proper_case_format(format) t("geoblacklight.formats.#{format.to_s.parameterize(separator: '_')}") 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`
225 226 227 228 229 230 |
# File 'app/helpers/geoblacklight_helper.rb', line 225 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
111 112 113 114 115 |
# File 'app/helpers/geoblacklight_helper.rb', line 111 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
89 90 91 92 93 |
# File 'app/helpers/geoblacklight_helper.rb', line 89 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
103 104 105 |
# File 'app/helpers/geoblacklight_helper.rb', line 103 def render partial: 'catalog/search_form_no_navbar' end |
#render_transformed_metadata(metadata) ⇒ String
Renders the transformed metadata (Renders a partial when the metadata isn’t available)
237 238 239 240 241 242 243 244 245 |
# File 'app/helpers/geoblacklight_helper.rb', line 237 def () render partial: 'catalog/metadata/content', locals: { content: .transform.html_safe } rescue Geoblacklight::MetadataTransformer::TransformError => transform_err Geoblacklight.logger.warn transform_err. render partial: 'catalog/metadata/markup', locals: { content: .to_xml } rescue => err Geoblacklight.logger.warn err. render partial: 'catalog/metadata/missing' 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
169 170 171 172 173 |
# File 'app/helpers/geoblacklight_helper.rb', line 169 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
204 205 206 207 208 209 210 211 |
# File 'app/helpers/geoblacklight_helper.rb', line 204 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
160 161 162 |
# File 'app/helpers/geoblacklight_helper.rb', line 160 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
85 86 87 |
# File 'app/helpers/geoblacklight_helper.rb', line 85 def snippit(args) truncate(Array(args[:value]).flatten.join(' '), length: 150) end |