-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Blacklight hit-highlighting in the full-text field #1030
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 }); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
dt.blacklight-full_text_tesimv { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid qualifying class selectors with an element. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We unfortunately have to provide element because the same class is on two elements that we want to treat differently. This was pulled over from the previous PR, and seems like is safe to ignore in this case. |
||
@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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid qualifying class selectors with an element. |
||
float: none; | ||
margin-left: 0; | ||
|
||
em { | ||
font-weight: bold; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Blacklight' is not defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This addressed by the
global
above.