Skip to content

Commit

Permalink
Bugfix for BL8 bookmark actions; replace @document_list. Fixes TD-1390.
Browse files Browse the repository at this point in the history
- @document_list was removed in BL8 in favor of @response.documents
  • Loading branch information
seanaery committed Dec 10, 2024
1 parent 7e7df6b commit 2c70e82
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
23 changes: 13 additions & 10 deletions app/controllers/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ class BookmarksController < CatalogController
include TrlnArgon::BookmarksControllerBehavior
include BookmarksHelper

# blacklight 7 will try, in default configuration to POST any request
# Blacklight will try, in default configuration to POST any request
# which is blocked by our Solr configuration, so we need to ensure
# our requests are done via GET
# our requests are done via GET (i.e., don't use search_service.fetch)
# rubocop:disable Layout/LineLength
# rubocop:disable Metrics/MethodLength
def index
Expand All @@ -14,7 +14,7 @@ def index

if bookmark_ids.empty?
@response = Blacklight::Solr::Response.new({}, {})
@document_list = []
@documents = []
else
query_params = {
q: bookmarks_query(bookmark_ids),
Expand All @@ -23,7 +23,7 @@ def index
}
# search_service.fetch does this internally (7.25)
@response = search_service.repository.search(query_params)
@document_list = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(@response.documents, 'The @document_list instance variable is now deprecated and will be removed in Blacklight 8.0')
@documents = @response.documents
end

respond_to do |format|
Expand All @@ -40,18 +40,21 @@ def index

# Override BL core to query Solr via GET rather than POST
# for bookmarks tools, e.g., Cite, Email, SMS. See:
# https://github.com/projectblacklight/blacklight/blob/main/app/controllers/concerns/blacklight/bookmarks.rb#L27-L31
# https://github.com/projectblacklight/blacklight/blob/main/app/controllers/concerns/blacklight/catalog.rb#L126-L131
# https://github.com/projectblacklight/blacklight/blob/release-8.x/app/controllers/concerns/blacklight/bookmarks.rb#L27-L31
# https://github.com/projectblacklight/blacklight/blob/release-8.x/app/controllers/concerns/blacklight/catalog.rb#L115-L122
# See also: lib/trln_argon/controller_override.rb
def action_documents
@bookmarks = token_or_current_or_guest_user.bookmarks
bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }
bookmarks = token_or_current_or_guest_user.bookmarks
bookmark_ids = bookmarks.collect { |b| b.document_id.to_s }
query_params = {
q: bookmarks_query(bookmark_ids),
defType: 'lucene',
rows: bookmark_ids.count
}
solr_response = search_service.repository.search(query_params)
[solr_response, solr_response.documents]
@response = search_service.repository.search(query_params)
@documents = @response.documents
raise Blacklight::Exceptions::RecordNotFound if @documents.blank?

@documents
end
end
2 changes: 1 addition & 1 deletion app/views/catalog/_citation.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= render Blacklight::System::ModalComponent.new do |component| %>
<% component.with_title { t('blacklight.tools.citation_note_html') } %>
<%= render TrlnArgon::Document::CitationComponent.with_collection(@documents) if @documents.present? %>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion lib/trln_argon/controller_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def is_advanced_search?(req_params = params)
# rubocop:enable Naming/PredicateName

def render_ris_action?
doc = @document || (@document_list || []).first
doc = @document || (@response.documents || []).first
doc && doc.respond_to?(:export_formats) && doc.export_formats.keys.include?(:ris)
end

Expand Down

0 comments on commit 2c70e82

Please sign in to comment.