Module: GeoblacklightHelper

Defined in:
app/helpers/geoblacklight_helper.rb

Instance Method Summary collapse

Instance Method Details

#document_available?Boolean

Returns:

  • (Boolean)

11
12
13
# File 'app/helpers/geoblacklight_helper.rb', line 11

def document_available?
  @document.public? || (@document.same_institution? && user_signed_in?)
end

#document_downloadable?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'app/helpers/geoblacklight_helper.rb', line 15

def document_downloadable?
  document_available? && @document.downloadable?
end

#download_text(format) ⇒ Object

Wraps download text with proper_case_format


69
70
71
# File 'app/helpers/geoblacklight_helper.rb', line 69

def download_text(format)
  "#{t 'geoblacklight.download.download'} #{proper_case_format(format)}".html_safe
end

#email_helperObject


7
8
9
# File 'app/helpers/geoblacklight_helper.rb', line 7

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)

62
63
64
# File 'app/helpers/geoblacklight_helper.rb', line 62

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

#geoblacklight_icon(name) ⇒ Object


35
36
37
# File 'app/helpers/geoblacklight_helper.rb', line 35

def geoblacklight_icon(name)
   :span, '', class: "geoblacklight-icon geoblacklight-#{name.downcase.gsub(' ', '-')}", title: name
end

#proper_case_format(format) ⇒ Object

Looks up properly formatted names for formats


54
55
56
# File 'app/helpers/geoblacklight_helper.rb', line 54

def proper_case_format(format)
  t "geoblacklight.formats.#{format.downcase}"
end

Renders an unique array of search links based off of terms passed in using the facet parameter


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

def render_facet_links(facet, items)
  items.uniq.map { |item| link_to item, catalog_index_path(f: { "#{facet}" => [item] }) }.join(', ').html_safe
end

#render_facet_tags(facet) ⇒ Object


31
32
33
# File 'app/helpers/geoblacklight_helper.rb', line 31

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


39
40
41
# File 'app/helpers/geoblacklight_helper.rb', line 39

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


82
83
84
85
86
# File 'app/helpers/geoblacklight_helper.rb', line 82

def render_value_as_truncate_abstract(args)
   :div, class: 'truncate-abstract' do
    args[:value]
  end
end

#show_attribute_table?Boolean

Returns:

  • (Boolean)

73
74
75
# File 'app/helpers/geoblacklight_helper.rb', line 73

def show_attribute_table?
  return true if document_available? && @document.viewer_protocol == 'wms'
end

#sms_helperObject


3
4
5
# File 'app/helpers/geoblacklight_helper.rb', line 3

def sms_helper()
  (:i, '', :class => 'fa fa-mobile fa-fw') + ' ' + t('blacklight.tools.sms')
end

#snippit(text) ⇒ Object


19
20
21
22
23
24
25
26
27
28
29
# File 'app/helpers/geoblacklight_helper.rb', line 19

def snippit(text)
  if (text)
    if (text.length > 150)
      text.slice(0,150) + '...'
    else
      text
    end
  else
    ''
  end
end