Module: GeoblacklightHelper

Includes:
Blacklight::LayoutHelperBehavior
Defined in:
app/helpers/geoblacklight_helper.rb

Instance Method Summary collapse

Instance Method Details

#document_available?(document) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/helpers/geoblacklight_helper.rb', line 26

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

#formatted_name_reference(reference) ⇒ String

Looks up formatted names for references

Parameters:

  • reference (String, Symbol)

Returns:

  • (String)


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

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

#geoblacklight_icon(name, **args) ⇒ SVG or HTML tag

Returns an SVG icon or empty HTML span element

Returns:

  • (SVG or HTML tag)


41
42
43
44
45
46
47
48
49
# File 'app/helpers/geoblacklight_helper.rb', line 41

def geoblacklight_icon(name, **args)
  icon_name = name ? name.to_s.parameterize : "none"
  camel_icon = icon_name.tr("-", "_").camelize.delete(" ")
  begin
    render "Blacklight::Icons::#{camel_icon}Component".constantize.new(name: icon_name, **args)
  rescue NameError
    tag.span class: "icon-missing geoblacklight-none"
  end
end

#main_content_classesObject

Make the search results take up less space so the facets can take more



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

def main_content_classes
  "col-lg-8"
end

#render_references_url(args) ⇒ Object

Renders a reference url for a document

Parameters:

  • document, (Hash)

    field_name



62
63
64
65
66
67
68
# File 'app/helpers/geoblacklight_helper.rb', line 62

def render_references_url(args)
  url = args[:document]&.references&.url
  return unless url

  endpoint = url.endpoint
  link_to(endpoint, endpoint)
end

#results_js_map_selector(controller_name) ⇒ Object

Returns the data-page attribute value used as the JS map selector



71
72
73
74
75
76
77
78
# File 'app/helpers/geoblacklight_helper.rb', line 71

def results_js_map_selector(controller_name)
  case controller_name
  when "bookmarks"
    "bookmarks"
  else
    "index"
  end
end

#show_content_classesObject

Needed so we keep the defaults instead of using main_content_classes



22
23
24
# File 'app/helpers/geoblacklight_helper.rb', line 22

def show_content_classes
  "col-lg-9 show-document"
end

#show_sidebar_classesObject

Needed so we keep the defaults instead of using sidebar_classes



17
18
19
# File 'app/helpers/geoblacklight_helper.rb', line 17

def show_sidebar_classes
  "page-sidebar col-lg-3"
end

Let the facets take up more space for the locator map



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

def sidebar_classes
  "page-sidebar col-lg-4 order-first"
end

#snippit(args) ⇒ String

Blacklight catalog controller helper method to truncate field value to 150 chars

Parameters:

  • args (SolrDocument)

Returns:

  • (String)


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

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