Module: Krikri::SearchResultsHelperBehavior
- Included in:
- RecordsHelper, ValidationReportsHelper
- Defined in:
- lib/krikri/search_results_helper_behavior.rb
Overview
This module helps controllers that display results from a querying the search index.
Instance Method Summary collapse
-
#link_to_document(document, field_or_opts = nil, opts = {}) ⇒ Object
Override method in Blacklight::UrlHelperBehavior.
-
#link_to_show(options = {}) ⇒ Object
This method is used to link display fields to the document’s show path.
-
#make_this_a_link(options = {}) ⇒ Object
This method is used to make display fields into hyperlinks.
-
#render_bookmarks_control? ⇒ Boolean
Disable bookmarks.
- #render_document_field_data(document, key) ⇒ Object
-
#render_enriched_record(document) ⇒ String
Render enriched record for view.
-
#render_original_record(document) ⇒ String
Render original record for view.
-
#render_thumbnail_tag(document, image_options = {}, url_options = {}) ⇒ Object
Override method in Blacklight::CatalogHelperBehavior.
Instance Method Details
#link_to_document(document, field_or_opts = nil, opts = {}) ⇒ Object
Override method in Blacklight::UrlHelperBehavior.
12 13 14 |
# File 'lib/krikri/search_results_helper_behavior.rb', line 12 def link_to_document(document, field_or_opts = nil, opts = {}) link_to field_or_opts, url_for_document(document) end |
#link_to_show(options = {}) ⇒ Object
This method is used to link display fields to the document’s show path.
26 27 28 29 30 31 32 |
# File 'lib/krikri/search_results_helper_behavior.rb', line 26 def link_to_show( = {}) # options[:document] # the original document # options[:field] # the field to render # options[:value] # the value of the field link_to_document [:document], [:value] end |
#make_this_a_link(options = {}) ⇒ Object
This method is used to make display fields into hyperlinks.
17 18 19 20 21 22 23 |
# File 'lib/krikri/search_results_helper_behavior.rb', line 17 def make_this_a_link( = {}) # options[:document] # the original document # options[:field] # the field to render # options[:value] # the value of the field link_to [:value], [:value] end |
#render_bookmarks_control? ⇒ Boolean
Disable bookmarks.
41 42 43 |
# File 'lib/krikri/search_results_helper_behavior.rb', line 41 def render_bookmarks_control? false end |
#render_document_field_data(document, key) ⇒ Object
34 35 36 37 38 |
# File 'lib/krikri/search_results_helper_behavior.rb', line 34 def render_document_field_data(document, key) if document[key] render_index_field_value document, :field => key end end |
#render_enriched_record(document) ⇒ String
Render enriched record for view
48 49 50 51 52 |
# File 'lib/krikri/search_results_helper_behavior.rb', line 48 def render_enriched_record(document) agg = document.aggregation return error_msg('Aggregation not found.') unless agg.present? JSON.pretty_generate(agg.to_jsonld) end |
#render_original_record(document) ⇒ String
Render original record for view
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/krikri/search_results_helper_behavior.rb', line 57 def render_original_record(document) agg = document.aggregation return error_msg('Aggregation not found.') unless agg.present? begin original_record = agg.original_record rescue StandardError => e logger.error e. return error_msg(e.) end return error_msg('Original record not found.') unless original_record.present? prettify_string(original_record.to_s, original_record.content_type) end |
#render_thumbnail_tag(document, image_options = {}, url_options = {}) ⇒ Object
Override method in Blacklight::CatalogHelperBehavior.
7 8 9 |
# File 'lib/krikri/search_results_helper_behavior.rb', line 7 def render_thumbnail_tag(document, = {}, = {}) link_to image_tag(thumbnail_url(document)), url_for_document(document) end |