-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Blacklight hit-highlighting in the full-text field
- Loading branch information
Showing
9 changed files
with
203 additions
and
2 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,23 @@ | ||
/* global Blacklight */ | ||
|
||
Blacklight.onLoad(function(){ | ||
var uniqueId = (function() { | ||
var uuid = 0; | ||
|
||
return function(el) { | ||
el.id = 'ui-id-' + ( ++uuid ); | ||
}; | ||
} )(); | ||
|
||
$('dd.blacklight-full_text_tesimv').addClass('collapse').each(function() { | ||
$(this).attr('id', uniqueId(this)); | ||
}); | ||
|
||
$('dt.blacklight-full_text_tesimv').each(function() { | ||
$(this).text($(this).text().replace(/:$/, '')); | ||
$(this).attr('data-toggle', 'collapse'); | ||
$(this).attr('data-target', '#' + $(this).next('dd').attr('id')); | ||
}); | ||
|
||
$('dd.blacklight-full_text_tesimv').collapse({ toggle: false }); | ||
}); |
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,32 @@ | ||
dt.blacklight-full_text_tesimv { | ||
@extend .h4; | ||
cursor: pointer; | ||
display: inline-block; | ||
float: none; | ||
text-align: initial; | ||
width: auto; | ||
// collapse carets shamelessly stolen from blacklight facets | ||
&[data-toggle="collapse"]::after { | ||
// symbol for "opening" panels | ||
content: "\e114"; | ||
float: right; | ||
font-family: "Glyphicons Halflings"; | ||
font-size: 0.8em; | ||
line-height: normal; | ||
padding-left: 2ch; | ||
} | ||
|
||
&.collapsed::after { | ||
// symbol for "collapsed" panels | ||
content: "\e080"; | ||
} | ||
} | ||
|
||
dd.blacklight-full_text_tesimv { | ||
float: none; | ||
margin-left: 0; | ||
|
||
em { | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.feature 'Full text highlighting' do | ||
let(:exhibit) { create(:exhibit) } | ||
let(:dor_harvester) { DorHarvester.new(druid_list: druid, exhibit: exhibit) } | ||
|
||
before do | ||
allow(Spotlight::Engine.config).to receive(:filter_resources_by_exhibit).and_return(false) | ||
end | ||
|
||
context 'when a document has a full text highlight hit' do | ||
it 'shows the full-text hightlight field and provides a toggle', js: true do | ||
visit spotlight.search_exhibit_catalog_path(exhibit, q: 'structure') | ||
|
||
expect(page).to have_css('dt', text: 'Preview matches in document text') | ||
|
||
expect(page).not_to have_css('dd p', text: 'about need for data structures capable of storing', visible: true) | ||
page.find('dt', text: 'Preview matches in document text').click | ||
expect(page).to have_css('dd p', text: 'about need for data structures capable of storing', visible: true) | ||
end | ||
end | ||
|
||
context 'when a document does not have a full text highlight hit' do | ||
it 'does not include full-text highlight', js: true do | ||
visit spotlight.search_exhibit_catalog_path(exhibit, q: 'Maps') | ||
|
||
expect(page).to have_css('.documents-list .document') # there are results | ||
|
||
expect(page).not_to have_css('dt', text: 'Preview matches in document text') | ||
end | ||
end | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
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