Module: GeoblacklightHelper

Extended by:
Deprecation
Defined in:
app/helpers/geoblacklight_helper.rb

Instance Method Summary collapse

Instance Method Details

Deprecated.

Use #carto_link instead.

Creates a Carto OneClick link link, using the configuration link

Parameters:

  • file_link (String)

Returns:

  • (String)


120
121
122
# File 'app/helpers/geoblacklight_helper.rb', line 120

def cartodb_link(file_link)
  carto_link(file_link)
end

#cartodb_providerObject

Deprecated.

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

Returns:

  • (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

Returns:

  • (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_helperObject



9
10
11
# File 'app/helpers/geoblacklight_helper.rb', line 9

def email_helper
  (:i, '', class: 'fa fa-envelope fa-fw') + ' ' + t('blacklight.tools.email')
end

#formatted_name_reference(reference) ⇒ String

Looks up formatted names for references

Parameters:

  • reference (String, Symbol)

Returns:

  • (String)


71
72
73
# File 'app/helpers/geoblacklight_helper.rb', line 71

def formatted_name_reference(reference)
  t "geoblacklight.references.#{reference}"
end

#geoblacklight_basemapString

Selects the basemap used for map displays

Returns:

  • (String)


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)
   :span,
              '',
              class: "geoblacklight-icon geoblacklight-#{name.parameterize}",
              title: name
end

#iiif_jpg_urlObject



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_optionsObject

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 leaflet_options
  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`

Returns:

  • String



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

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 render_facet_tags(facet)
  render_facet_limit(facets_from_request(facet).first,
                     partial: 'facet_tag_item',
                     layout: 'facet_tag_layout')
end

#render_search_form_no_navbarObject



46
47
48
# File 'app/helpers/geoblacklight_helper.rb', line 46

def render_search_form_no_navbar
  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

Parameters:

  • args (Hash)

    from get_field_values



94
95
96
97
98
# File 'app/helpers/geoblacklight_helper.rb', line 94

def render_value_as_truncate_abstract(args)
   :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

Parameters:



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

Returns:

  • (Boolean)


85
86
87
# File 'app/helpers/geoblacklight_helper.rb', line 85

def show_attribute_table?
  document_available? && @document.inspectable?
end

#sms_helperObject



5
6
7
# File 'app/helpers/geoblacklight_helper.rb', line 5

def sms_helper
  (: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

Parameters:

  • args (SolrDocument)

Returns:

  • (String)


29
30
31
# File 'app/helpers/geoblacklight_helper.rb', line 29

def snippit(args)
  truncate(Array(args[:value]).flatten.join(' '), length: 150)
end