Skip to content

Commit

Permalink
Revert "Upgrade to Blacklight 8.6.1 (#4546)" (#4572)
Browse files Browse the repository at this point in the history
This reverts commit c27bf59

Co-authored-by: Kevin Reiss <[email protected]>
Co-authored-by: Max Kadel <[email protected]>
Co-authored-by: regineheberlein <[email protected]>
Co-authored-by: Ryan Laddusaw <[email protected]>
  • Loading branch information
5 people authored Nov 14, 2024
1 parent 5b8b80a commit 401453b
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gem 'alma'
gem 'babel-transpiler'
gem 'bcrypt_pbkdf'
# Blacklight
gem 'blacklight', '~> 8.6.1'
gem 'blacklight', '~> 7.38.0'
gem 'blacklight_dynamic_sitemap'
gem 'blacklight-hierarchy'
gem 'blacklight-marc', '~>8.1'
Expand Down
11 changes: 6 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,16 @@ GEM
parser (>= 2.4)
smart_properties
bigdecimal (3.1.8)
blacklight (8.6.1)
blacklight (7.38.0)
deprecation
globalid
hashdiff
i18n (>= 1.7.0)
jbuilder (~> 2.7)
kaminari (>= 0.15)
ostruct (>= 0.3.2)
rails (>= 6.1, < 8)
view_component (>= 2.74, < 4)
zeitwerk
rails (>= 5.1, < 7.3)
view_component (>= 2.66, < 4)
blacklight-hierarchy (6.4.0)
blacklight (>= 7.18, < 9)
deprecation
Expand Down Expand Up @@ -746,7 +747,7 @@ DEPENDENCIES
axe-core-rspec
babel-transpiler
bcrypt_pbkdf
blacklight (~> 8.6.1)
blacklight (~> 7.38.0)
blacklight-hierarchy
blacklight-marc (~> 8.1)
blacklight_dynamic_sitemap
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%# This can be removed after migrating to Blacklight 8 %>
<div class='pagination-search-widgets'>

<div class="page-links">
<%= link_to_previous_document %> |

<%= item_page_entry_info %> |

<%= link_to_next_document %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# This can be removed after migrating to Blacklight 8
module Blacklight
module SearchContext
# This class makes the ServerItemPaginationComponent that is present in Blacklight 8
# available while we are still on Blacklight 7
class ServerItemPaginationComponent < Blacklight::SearchContextComponent
with_collection_parameter :search_context

def initialize(search_context:, search_session:, current_document:)
@search_context = search_context
@search_session = search_session
@current_document_id = current_document.id
end
end
end
end
47 changes: 47 additions & 0 deletions app/models/concerns/blacklight/document/email.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

# This module provides the body of an email export based on the document's semantic values
module Blacklight
module Document
module Email
include ActionView::Helpers::UrlHelper
# Return a text string that will be the body of the email
def to_email_text
body = []
add_bibliographic_text(body)
add_online_text(body, self[:electronic_access_1display])
body.join("\n") unless body.empty?
end

private

def add_single_valued_field(body, i18_label, value)
body << I18n.t(i18_label, value:) if value.present?
end

def add_multi_valued_field(body, i18_label, value)
value.each { |v| add_single_valued_field(body, i18_label, v) } if value.present?
end

def add_bibliographic_text(body)
add_single_valued_field(body, 'blacklight.email.text.title', self[:title_vern_display])
add_single_valued_field(body, 'blacklight.email.text.title', self[:title_display])
add_multi_valued_field(body, 'blacklight.email.text.author', self[:author_display])
add_multi_valued_field(body, 'blacklight.email.text.publish', self[:pub_created_display])
add_multi_valued_field(body, 'blacklight.email.text.format', self[:format])
end

def add_online_text(body, links_field)
if links_field.present?
body << I18n.t('blacklight.email.text.online')
links = JSON.parse(links_field)
links.each do |url, text|
link = "#{text[0]}: #{url}"
link = "#{text[1]} - " + link if text[1]
body << "\t" + link
end
end
end
end
end
end
4 changes: 2 additions & 2 deletions spec/components/index_document_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe IndexDocumentComponent, type: :component do
let(:blacklight_config) do
Blacklight::Configuration.new do |config|
config.track_search_session.storage = false
config.track_search_session = false
end
end
before do
Expand All @@ -16,7 +16,7 @@
end
subject do
document = SolrDocument.new(id: 'SCSB-1234')
presenter = Blacklight::DocumentPresenter.new(document, instance_double(ActionView::Base, action_name: 'show'), blacklight_config)
presenter = Blacklight::DocumentPresenter.new(document, instance_double(ActionView::Base), blacklight_config)
allow(presenter).to receive(:fields).and_return([])
allow(document).to receive(:export_as_openurl_ctx_kev).and_return 'ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.issn=1045-4438'
render_inline(described_class.new(document:, presenter:))
Expand Down
4 changes: 2 additions & 2 deletions spec/components/index_metadata_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def call
expect(render_inline(component).css('li').first.text.strip).to eq('Hello')
end
it 'renders multi-valued fields' do
expect(render_inline(component).search('./li/ul/li/ul/li').length).to eq(2)
expect(render_inline(component).search('./li/ul/li/ul/li').map(&:text).map(&:strip)).to eq(['Goodbye', 'Auf Wiedersehen'])
expect(render_inline(component).search('./li/ul/li').length).to eq(2)
expect(render_inline(component).search('./li/ul/li').map(&:text).map(&:strip)).to eq(['Goodbye', 'Auf Wiedersehen'])
end
context 'when the index field is configured to use a component' do
let(:blacklight_config) do
Expand Down
2 changes: 1 addition & 1 deletion spec/components/index_title_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end
let(:blacklight_config) do
Blacklight::Configuration.new do |config|
config.track_search_session.storage = false
config.track_search_session = false
config.index.document_actions[:bookmark].partial = '/catalog/bookmark_control'
end
end
Expand Down

0 comments on commit 401453b

Please sign in to comment.