Module: IiifPrintHelper
- Includes:
- IiifPrint::IiifPrintHelperBehavior
- Defined in:
- app/helpers/iiif_print_helper.rb,
lib/generators/iiif_print/templates/helpers/iiif_print_helper.rb
Instance Method Summary collapse
-
#highlight_matches(document, hl_fl, hl_tag) ⇒ String
return the matching highlighted terms from Solr highlight field.
-
#iiif_search_anchor(query_params_hash) ⇒ String
create link anchor to be read by UniversalViewer in order to show keyword search.
-
#search_query(query_params_hash) ⇒ String
get the query, which may be in a different object, depending if regular search or newspapers_search was run.
Methods included from IiifPrint::IiifPrintHelperBehavior
Instance Method Details
#highlight_matches(document, hl_fl, hl_tag) ⇒ String
return the matching highlighted terms from Solr highlight field
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/helpers/iiif_print_helper.rb', line 30 def highlight_matches(document, hl_fl, hl_tag) hl_matches = [] # regex: find all chars between hl_tag, but NOT other <element> regex = /<#{hl_tag}>[^<>]+<\/#{hl_tag}>/ hls = document.highlight_field(hl_fl) return nil if hls.blank? hls.each do |hl| matches = hl.scan(regex) matches.each do |match| hl_matches << match.gsub(/<[\/]*#{hl_tag}>/, '').downcase end end hl_matches.uniq.sort.join(' ') end |
#iiif_search_anchor(query_params_hash) ⇒ String
create link anchor to be read by UniversalViewer in order to show keyword search
7 8 9 10 11 |
# File 'app/helpers/iiif_print_helper.rb', line 7 def iiif_search_anchor(query_params_hash) query = search_query(query_params_hash) return nil if query.blank? "?h=#{query}" end |
#search_query(query_params_hash) ⇒ String
get the query, which may be in a different object,
depending if regular search or newspapers_search was run
18 19 20 |
# File 'app/helpers/iiif_print_helper.rb', line 18 def search_query(query_params_hash) query_params_hash[:q] || query_params_hash[:all_fields] end |