Skip to content

Commit 30de3c9

Browse files
committed
WIP
1 parent e905f73 commit 30de3c9

23 files changed

Lines changed: 146 additions & 159 deletions

Gemfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ gem 'view_component'
4141
gem 'zip_tricks'
4242

4343
# Stanford related gems
44-
gem 'blacklight', '~> 7.41'
45-
# pinned because 6.7.0 is effectively coupled to BL >= 8.3.0 and Argo hasn't been updated to BL8 yet
46-
gem 'blacklight-hierarchy', '~> 6.6.0'
44+
gem 'blacklight', '~> 9.0'
45+
gem 'blacklight-hierarchy', '~> 6.9'
4746
gem 'cocina_display', '~> 2'
4847
gem 'dor-services-client', '~> 15.1'
4948
gem 'druid-tools'

Gemfile.lock

Lines changed: 7 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/components/document_component.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ def initialize(document: nil, **kwargs)
66
end
77

88
def child_component
9+
return super unless @view_context.action_name == 'show' && @view_context.controller_name == 'catalog'
10+
911
component_class.new(presenter: @presenter)
1012
end
1113

app/components/document_title_component.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
<%= version_banner %>
77
<% if show_latest_link? %>
88
<div class="text-body">
9-
<%= link_to('View latest version', solr_document_path(@document.id)) %>
9+
<%= link_to('View latest version', solr_document_path(@presenter.document.id)) %>
1010
</div>
1111
<% end %>
1212
</div>
1313
</div>
1414
<% end %>
1515
<div class="row">
16-
<%= render OpenCloseComponent.new(id: @document.id) if helpers.can?(:update, @presenter.cocina) && !version_or_user_version_view? %>
16+
<%= render OpenCloseComponent.new(id: @presenter.document.id) if helpers.can?(:update, @presenter.cocina) && !version_or_user_version_view? %>
1717

1818
<%= content_tag @as, class: @classes do %>
1919
<%= title -%>

app/components/document_title_component.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
class DocumentTitleComponent < Blacklight::DocumentTitleComponent
44
def object_type_label
5-
return 'apo' if @document.admin_policy?
5+
return 'apo' if @presenter.document.admin_policy?
66

7-
@document.object_type
7+
@presenter.document.object_type
88
end
99

1010
def object_type_class

app/components/search_navbar_component.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
# frozen_string_literal: true
22

3-
# @TODO after upgrading to BL 8, inherit from Blacklight::SearchNavbarComponent and remove most of it except for
4-
# "container_classes"
5-
class SearchNavbarComponent < Blacklight::Component
6-
def initialize(blacklight_config:)
7-
@blacklight_config = blacklight_config
8-
end
9-
10-
attr_reader :blacklight_config
11-
3+
class SearchNavbarComponent < Blacklight::SearchNavbarComponent
124
def container_classes
135
'container'
146
end
@@ -22,7 +14,7 @@ def search_bar_component
2214
url: helpers.search_action_url,
2315
advanced_search_url: helpers.search_action_url(action: 'advanced_search'),
2416
params: helpers.search_state.params_for_search.except(:qt),
25-
autocomplete_path: suggest_index_catalog_path
17+
autocomplete_path: helpers.suggest_index_catalog_path
2618
)
2719
end
2820

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<search>
2+
<% facet_group_names.each do |groupname| %>
3+
<% fields = facet_fields_in_group(groupname) %>
4+
<%= render group_component_class.new(id: groupname) do |component| %>
5+
<% component.with_body do %>
6+
<%= render Blacklight::FacetComponent.with_collection(fields, response: response) %>
7+
<% end %>
8+
<% end %>
9+
<% end %>
10+
11+
<% unless has_search_parameters? || params[:all] %>
12+
<%= link_to 'Show more facets', root_path(all: true), class: 'btn btn-primary mb-4' %>
13+
<% end %>
14+
</search>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
class SidebarComponent < Blacklight::Search::SidebarComponent
4+
def initialize(response:, **kwargs)
5+
@response = response
6+
super
7+
end
8+
9+
delegate :has_search_parameters?, to: :helpers
10+
11+
def root_path(args = {})
12+
helpers.root_path(args)
13+
end
14+
end

app/controllers/apo_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def search_service
142142
end
143143

144144
def link_to_members_with_type(type)
145-
facet_config = facet_configuration_for_field(ApoConcern::FIELD_APO_ID)
145+
facet_config = blacklight_config.facet_configuration_for_field(ApoConcern::FIELD_APO_ID)
146146
search_state = Blacklight::SearchState.new({ f: { SolrDocument::FIELD_OBJECT_TYPE => [type] } }, blacklight_config)
147147
Blacklight::FacetItemPresenter.new(params[:id],
148148
facet_config,

app/controllers/catalog_controller.rb

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class CatalogController < ApplicationController
44
include Blacklight::Catalog
55

66
helper ArgoHelper
7+
helper ItemsHelper
78
include DateFacetConfigurations
89

910
before_action :limit_facets_on_home_page, only: [:index]
@@ -91,28 +92,27 @@ class CatalogController < ApplicationController
9192
config.add_facet_field SolrDocument::FIELD_EXPLODED_NONPROJECT_TAG, label: 'Tag', limit: 100_000,
9293
component: LazyNonprojectTagFacetComponent,
9394
unless: ->(controller, _config, _response) { controller.params[:no_tags] }
94-
config.add_facet_field SolrDocument::FIELD_TICKET_TAG, label: 'Ticket', component: true, limit: 100_000, sort: 'index'
95-
config.add_facet_field 'exclude_google_books', label: 'Exclude Google Books', component: true, query: {
95+
config.add_facet_field SolrDocument::FIELD_TICKET_TAG, label: 'Ticket', limit: 100_000, sort: 'index'
96+
config.add_facet_field 'exclude_google_books', label: 'Exclude Google Books', query: {
9697
yes: {
9798
label: 'Yes',
9899
fq: "-#{SolrDocument::FIELD_APO_ID}:\"#{Settings.google_books_apo}\""
99100
}
100101
}
101-
config.add_facet_field SolrDocument::FIELD_OBJECT_TYPE, label: 'Object Type', component: true, limit: 10
102-
config.add_facet_field SolrDocument::FIELD_CONTENT_TYPE, label: 'Content Type', component: true, limit: 10
103-
config.add_facet_field SolrDocument::FIELD_CONTENT_FILE_MIMETYPES, label: 'MIME Types', component: true, limit: 10
104-
config.add_facet_field SolrDocument::FIELD_CONTENT_FILE_ROLES, label: 'File Role', component: true, limit: 10
105-
config.add_facet_field SolrDocument::FIELD_ACCESS_RIGHTS, label: 'Access Rights', component: true, limit: 1000,
102+
config.add_facet_field SolrDocument::FIELD_OBJECT_TYPE, label: 'Object Type', limit: 10
103+
config.add_facet_field SolrDocument::FIELD_CONTENT_TYPE, label: 'Content Type', limit: 10
104+
config.add_facet_field SolrDocument::FIELD_CONTENT_FILE_MIMETYPES, label: 'MIME Types', limit: 10
105+
config.add_facet_field SolrDocument::FIELD_CONTENT_FILE_ROLES, label: 'File Role', limit: 10
106+
config.add_facet_field SolrDocument::FIELD_ACCESS_RIGHTS, label: 'Access Rights', limit: 1000,
106107
sort: 'index'
107-
config.add_facet_field SolrDocument::FIELD_LICENSE, label: 'License', component: true, limit: 10
108-
config.add_facet_field SolrDocument::FIELD_COLLECTION_TITLE, label: 'Collection', component: true, limit: 10,
108+
config.add_facet_field SolrDocument::FIELD_LICENSE, label: 'License', limit: 10
109+
config.add_facet_field SolrDocument::FIELD_COLLECTION_TITLE, label: 'Collection', limit: 10,
109110
more_limit: 9999, sort: 'index'
110-
config.add_facet_field SolrDocument::FIELD_APO_TITLE, label: 'Admin Policy', component: true, limit: 10,
111+
config.add_facet_field SolrDocument::FIELD_APO_TITLE, label: 'Admin Policy', limit: 10,
111112
more_limit: 9999, sort: 'index'
112-
config.add_facet_field SolrDocument::FIELD_CURRENT_VERSION, label: 'Version', component: true, limit: 10
113-
config.add_facet_field SolrDocument::FIELD_PROCESSING_STATUS, label: 'Processing Status', component: true, limit: 10
113+
config.add_facet_field SolrDocument::FIELD_CURRENT_VERSION, label: 'Version', limit: 10
114+
config.add_facet_field SolrDocument::FIELD_PROCESSING_STATUS, label: 'Processing Status', limit: 10
114115
config.add_facet_field 'released_to_earthworks',
115-
component: true,
116116
query: {
117117
week: {
118118
label: 'Last week',
@@ -136,7 +136,6 @@ class CatalogController < ApplicationController
136136
}
137137
}
138138
config.add_facet_field 'released_to_purl_sitemap',
139-
component: true,
140139
query: {
141140
week: {
142141
label: 'Last week',
@@ -160,7 +159,6 @@ class CatalogController < ApplicationController
160159
}
161160
}
162161
config.add_facet_field 'released_to_searchworks',
163-
component: true,
164162
query: {
165163
week: {
166164
label: 'Last week',
@@ -185,42 +183,41 @@ class CatalogController < ApplicationController
185183
}
186184
config.add_facet_field SolrDocument::FIELD_WORKFLOW_WPS, label: 'Workflows (WPS)', limit: 9999,
187185
component: LazyWpsWorkflowFacetComponent
188-
config.add_facet_field SolrDocument::FIELD_METADATA_SOURCE, label: 'Metadata Source', component: true
186+
config.add_facet_field SolrDocument::FIELD_METADATA_SOURCE, label: 'Metadata Source'
189187

190188
# common method since search results and reports all do the same configuration
191189
add_common_date_facet_fields_to_config! config
192190

193191
config.add_facet_field 'identifiers', label: 'Identifiers',
194-
component: true,
195192
query: {
196193
has_orcids: { label: 'Has contributor ORCIDs',
197194
fq: "+#{SolrDocument::FIELD_ORCIDS}:*" },
198195
has_doi: { label: 'Has DOI', fq: "+#{SolrDocument::FIELD_DOI}:*" },
199196
has_barcode: { label: 'Has barcode', fq: "+#{SolrDocument::FIELD_BARCODE_ID}:*" }
200197
}
201198

202-
config.add_facet_field 'empties', label: 'Empty Fields', component: true,
199+
config.add_facet_field 'empties', label: 'Empty Fields',
203200
query: {
204201
no_mods_typeOfResource_ssim: { label: 'No MODS typeOfResource',
205202
fq: "-#{SolrDocument::FIELD_MODS_TYPE_OF_RESOURCE}:*" },
206203
no_sw_format: { label: 'No SW Format', fq: "-#{SolrDocument::FIELD_SW_FORMAT}:*" }
207204
}
208205

209206
config.add_facet_field SolrDocument::FIELD_SW_FORMAT, label: 'SW Format', limit: -1, sort: :index, component: Blacklight::Hierarchy::FacetFieldListComponent
210-
config.add_facet_field SolrDocument::FIELD_PUBLICATION_DATE, label: 'Date', component: true, limit: 10
211-
config.add_facet_field SolrDocument::FIELD_TOPIC, label: 'Topic', component: true, limit: 10
212-
config.add_facet_field SolrDocument::FIELD_SUBJECT_GEOGRAPHIC, label: 'Region', component: true, limit: 10
213-
config.add_facet_field SolrDocument::FIELD_GENRE, label: 'Genre', component: true, limit: 10
214-
config.add_facet_field SolrDocument::FIELD_SW_LANGUAGE, label: 'Language', component: true, limit: 10
207+
config.add_facet_field SolrDocument::FIELD_PUBLICATION_DATE, label: 'Date', limit: 10
208+
config.add_facet_field SolrDocument::FIELD_TOPIC, label: 'Topic', limit: 10
209+
config.add_facet_field SolrDocument::FIELD_SUBJECT_GEOGRAPHIC, label: 'Region', limit: 10
210+
config.add_facet_field SolrDocument::FIELD_GENRE, label: 'Genre', limit: 10
211+
config.add_facet_field SolrDocument::FIELD_SW_LANGUAGE, label: 'Language', limit: 10
215212

216-
config.add_facet_field SolrDocument::FIELD_MODS_TYPE_OF_RESOURCE, label: 'MODS Resource Type', component: true, limit: 10
213+
config.add_facet_field SolrDocument::FIELD_MODS_TYPE_OF_RESOURCE, label: 'MODS Resource Type', limit: 10
217214
# Adding the facet field allows it to be queried (e.g., from value_helper)
218215
config.add_facet_field SolrDocument::FIELD_APO_ID, if: false
219216
config.add_facet_field SolrDocument::FIELD_COLLECTION_ID, if: false
220217
config.add_facet_field 'tag_ssim', if: false
221218
config.add_facet_field 'project_tag_ssim', if: false
222219

223-
config.add_facet_fields_to_solr_request! # deprecated in newer Blacklights
220+
config.add_facet_fields_to_solr_request!
224221

225222
config.add_search_field 'text', label: 'All Fields'
226223
config.add_sort_field 'score desc, id asc', label: 'Relevance', default: true
@@ -249,6 +246,7 @@ class CatalogController < ApplicationController
249246
# Configure document actions framework
250247
config.index.document_actions.delete(:bookmark)
251248

249+
config.index.sidebar_component = SidebarComponent
252250
config.show.document_component = DocumentComponent
253251
end
254252

@@ -323,17 +321,17 @@ def index
323321

324322
def lazy_nonproject_tag_facet
325323
limit_facets_to([SolrDocument::FIELD_EXPLODED_NONPROJECT_TAG])
326-
(response,) = search_service.search_results
327-
facet_config = facet_configuration_for_field(SolrDocument::FIELD_EXPLODED_NONPROJECT_TAG)
324+
response = search_service.search_results
325+
facet_config = blacklight_config.facet_configuration_for_field(SolrDocument::FIELD_EXPLODED_NONPROJECT_TAG)
328326
display_facet = response.aggregations[facet_config.field]
329327
@facet_field_presenter = facet_config.presenter.new(facet_config, display_facet, view_context)
330328
render partial: 'lazy_nonproject_tag_facet'
331329
end
332330

333331
def lazy_project_tag_facet
334332
limit_facets_to([SolrDocument::FIELD_EXPLODED_PROJECT_TAG])
335-
(response,) = search_service.search_results
336-
facet_config = facet_configuration_for_field(SolrDocument::FIELD_EXPLODED_PROJECT_TAG)
333+
response = search_service.search_results
334+
facet_config = blacklight_config.facet_configuration_for_field(SolrDocument::FIELD_EXPLODED_PROJECT_TAG)
337335
display_facet = response.aggregations[facet_config.field]
338336
@facet_field_presenter = facet_config.presenter.new(facet_config, display_facet, view_context)
339337
render partial: 'lazy_project_tag_facet'
@@ -342,8 +340,8 @@ def lazy_project_tag_facet
342340
def lazy_wps_workflow_facet
343341
limit_facets_to([SolrDocument::FIELD_WORKFLOW_WPS])
344342

345-
(response,) = search_service.search_results
346-
facet_config = facet_configuration_for_field(SolrDocument::FIELD_WORKFLOW_WPS)
343+
response = search_service.search_results
344+
facet_config = blacklight_config.facet_configuration_for_field(SolrDocument::FIELD_WORKFLOW_WPS)
347345
display_facet = response.aggregations[facet_config.field]
348346
@facet_field_presenter = facet_config.presenter.new(facet_config, display_facet, view_context)
349347
render partial: 'lazy_wps_workflow_facet'
@@ -359,7 +357,7 @@ def show
359357
# Skip validating the Cocina underlying the Solr representation
360358
@document = SolrDocument.new(object_client.version.solr(version_param, validate: false))
361359
else
362-
_deprecated_response, @document = search_service.fetch(druid_param)
360+
@document = search_service.fetch(druid_param)
363361
@cocina = Repository.find_lite(druid_param, structural: false)
364362
end
365363

0 commit comments

Comments
 (0)