-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds full-text searching to Lux sites. (#753)
* Adds full-text searching to Lux sites. * rubocop appeasement. * Reconfigure css.
- Loading branch information
Showing
15 changed files
with
158 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<%# | ||
# gem 'newspaper_works', v1.0.2 | ||
# Refer to the gem repository for more details: https://github.com/samvera-labs/newspaper_works | ||
# Released under license Apache License 2.0: https://github.com/samvera-labs/newspaper_works/blob/main/LICENSE | ||
# This gem is not yet compatible with Hyrax v3, hence why I am only using the portions relevant to our use case | ||
# This gem is used for keyword highlighting in search results | ||
%> | ||
|
||
/* toggle the ocr snippets collapse link text */ | ||
$(document).ready(function(){ | ||
$('.ocr_snippets_expand').click(function() { | ||
$(this).text($(this).text() == '<%= I18n.t('blacklight.search.results.snippets.more') %>' ? '<%= I18n.t('blacklight.search.results.snippets.less') %>' : '<%= I18n.t('blacklight.search.results.snippets.more') %>'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// gem 'newspaper_works', v1.0.2 | ||
// Refer to the gem repository for more details: https://github.com/samvera-labs/newspaper_works | ||
// Released under license Apache License 2.0: https://github.com/samvera-labs/newspaper_works/blob/main/LICENSE | ||
// This gem is not yet compatible with Hyrax v3, hence why I am only using the portions relevant to our use case | ||
// This gem is used for keyword highlighting in search results | ||
|
||
$highlight-background-color: rgba(5,166,86,0.36); | ||
|
||
// #search-results .thumbnail_highlight, #documents .thumbnail_highlight { | ||
// background-color: $highlight-background-color; | ||
// z-index: 1000; | ||
// position: absolute; | ||
// } | ||
|
||
.ocr_snippet em { | ||
background-color: $highlight-background-color; | ||
font-weight: bold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app/helpers/newspaper_works/newspaper_works_helper_behavior.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
# gem 'newspaper_works', v1.0.2 | ||
# Refer to the gem repository for more details: https://github.com/samvera-labs/newspaper_works | ||
# Released under license Apache License 2.0: https://github.com/samvera-labs/newspaper_works/blob/main/LICENSE | ||
# This gem is not yet compatible with Hyrax v3, hence why I am only using the portions relevant to our use case | ||
# This gem is used for keyword highlighting in search results | ||
|
||
module NewspaperWorks | ||
module NewspaperWorksHelperBehavior | ||
## | ||
# print the ocr snippets. if more than one, separate with <br/> | ||
# | ||
# @param options [Hash] options hash provided by Blacklight | ||
# @return [String] snippets HTML to be rendered | ||
# rubocop:disable Rails/OutputSafety | ||
def render_ocr_snippets(options = {}) | ||
snippets = options[:value] | ||
snippets_content = [tag.div("... #{snippets.first} ...".html_safe, | ||
class: 'ocr_snippet first_snippet')] | ||
if snippets.length > 1 | ||
snippets_content << render(partial: 'catalog/snippets_more', | ||
locals: { | ||
snippets: snippets.drop(1), | ||
options: options | ||
}) | ||
end | ||
snippets_content.join("\n").html_safe | ||
end | ||
# rubocop:enable Rails/OutputSafety | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<%# | ||
# gem 'newspaper_works', v1.0.2 | ||
# Refer to the gem repository for more details: https://github.com/samvera-labs/newspaper_works | ||
# Released under license Apache License 2.0: https://github.com/samvera-labs/newspaper_works/blob/main/LICENSE | ||
# This gem is not yet compatible with Hyrax v3, hence why I am only using the portions relevant to our use case | ||
# This gem is used for keyword highlighting in search results | ||
%> | ||
<%# additional ocr snippets, with a Bootstrap collapse toggle control %> | ||
<% document_id = options[:document].id %> | ||
<div class="collapse ocr_snippet" id="<%= "snippet_collapse_#{document_id}" %>"> | ||
<% snippets.each do |snippet| %> | ||
<%= content_tag('div', | ||
"... #{snippet} ...".html_safe, | ||
class: 'ocr_snippet') %> | ||
<% end %> | ||
</div> | ||
<%= link_to(t('blacklight.search.results.snippets.more'), | ||
"#snippet_collapse_#{document_id}", | ||
data: {toggle: 'collapse'}, | ||
'aria-expanded' => 'false', | ||
'aria-controls' => "#snippet_collapse_#{document_id}", | ||
class: 'ocr_snippets_expand js-controls') | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
# gem 'newspaper_works', v1.0.2 | ||
# Refer to the gem repository for more details: https://github.com/samvera-labs/newspaper_works | ||
# Released under license Apache License 2.0: https://github.com/samvera-labs/newspaper_works/blob/main/LICENSE | ||
# This gem is not yet compatible with Hyrax v3, hence why I am only using the portions relevant to our use case | ||
# This gem is used for keyword highlighting in search results | ||
|
||
module NewspaperWorks | ||
# add highlighting on _stored_ full text field if this is a keyword search | ||
# can be added to default_processor_chain in a SearchBuilder class | ||
module HighlightSearchParams | ||
# add highlights on full text field, if there is a keyword query | ||
def highlight_search_params(solr_parameters = {}) | ||
return unless solr_parameters[:q] || solr_parameters[:all_fields] | ||
solr_parameters[:hl] = true | ||
solr_parameters[:'hl.fl'] = 'all_text_tsimv' | ||
solr_parameters[:'hl.fragsize'] = 100 | ||
solr_parameters[:'hl.snippets'] = 5 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters