blacklight 8.8.3 → 9.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env +3 -3
- data/.github/pull_request_template.md +7 -0
- data/.github/workflows/ruby.yml +1 -9
- data/.rubocop.yml +2 -2
- data/.rubocop_todo.yml +0 -9
- data/README.md +30 -8
- data/VERSION +1 -1
- data/app/assets/builds/blacklight.css +448 -0
- data/app/assets/javascripts/blacklight/blacklight.esm.js +18 -15
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +18 -15
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/assets/stylesheets/blacklight/_balanced_list.scss +1 -4
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +1 -3
- data/app/assets/stylesheets/blacklight/_bookmark.scss +44 -41
- data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +7 -26
- data/app/assets/stylesheets/blacklight/_constraints.scss +15 -24
- data/app/assets/stylesheets/blacklight/_controls.scss +2 -18
- data/app/assets/stylesheets/blacklight/_facets.scss +15 -82
- data/app/assets/stylesheets/blacklight/_group.scss +2 -5
- data/app/assets/stylesheets/blacklight/_header.scss +4 -11
- data/app/assets/stylesheets/blacklight/_icons.scss +0 -8
- data/app/assets/stylesheets/blacklight/_modal.scss +2 -2
- data/app/assets/stylesheets/blacklight/_pagination.scss +0 -4
- data/app/assets/stylesheets/blacklight/_search_form.scss +0 -1
- data/app/assets/stylesheets/blacklight/_search_history.scss +0 -4
- data/app/assets/stylesheets/blacklight/_search_results.scss +1 -15
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +9 -14
- data/app/assets/stylesheets/blacklight/build.scss +4 -0
- data/app/components/blacklight/advanced_search_form_component.rb +1 -1
- data/app/components/blacklight/constraint_component.rb +1 -1
- data/app/components/blacklight/constraint_layout_component.html.erb +2 -2
- data/app/components/blacklight/constraints_component.html.erb +2 -2
- data/app/components/blacklight/constraints_component.rb +1 -1
- data/app/components/blacklight/document/action_component.rb +3 -1
- data/app/components/blacklight/document/bookmark_component.html.erb +3 -3
- data/app/components/blacklight/document/group_component.html.erb +1 -1
- data/app/components/blacklight/document/page_header_component.rb +1 -1
- data/app/components/blacklight/document/sidebar_component.rb +5 -5
- data/app/components/blacklight/document_component.rb +9 -13
- data/app/components/blacklight/document_title_component.rb +3 -2
- data/app/components/blacklight/facet_field_component.html.erb +5 -5
- data/app/components/blacklight/facet_field_list_component.rb +4 -22
- data/app/components/blacklight/facet_item_component.rb +2 -2
- data/app/components/blacklight/facet_item_pivot_component.rb +2 -2
- data/app/components/blacklight/response/facet_group_component.html.erb +3 -18
- data/app/components/blacklight/response/facet_group_component.rb +7 -23
- data/app/components/blacklight/response/facet_toggle_button_component.html.erb +16 -0
- data/app/components/blacklight/response/facet_toggle_button_component.rb +14 -0
- data/app/components/blacklight/response/pagination_component.html.erb +1 -1
- data/app/components/blacklight/response/pagination_component.rb +2 -1
- data/app/components/blacklight/response/sort_component.rb +1 -0
- data/app/components/blacklight/response/view_type_button_component.html.erb +1 -1
- data/app/components/blacklight/response/view_type_component.html.erb +1 -1
- data/app/components/blacklight/search/facet_suggest_input.html.erb +7 -7
- data/app/components/blacklight/search/facet_suggest_input.rb +0 -4
- data/app/components/blacklight/search/per_page_component.html.erb +1 -1
- data/app/components/blacklight/search/per_page_component.rb +1 -0
- data/app/components/blacklight/search/sidebar_component.html.erb +1 -1
- data/app/components/blacklight/search/sidebar_component.rb +1 -1
- data/app/components/blacklight/search_bar_component.html.erb +3 -3
- data/app/components/blacklight/search_bar_component.rb +2 -2
- data/app/components/blacklight/search_button_component.rb +2 -2
- data/app/components/blacklight/search_context/server_applied_params_component.html.erb +2 -2
- data/app/components/blacklight/search_context/server_applied_params_component.rb +9 -0
- data/app/components/blacklight/skip_link_component.html.erb +1 -1
- data/app/components/blacklight/skip_link_component.rb +7 -3
- data/app/components/blacklight/skip_link_item_component.rb +18 -0
- data/app/components/blacklight/top_navbar_component.html.erb +1 -1
- data/app/controllers/concerns/blacklight/catalog.rb +3 -2
- data/app/controllers/concerns/blacklight/search_context.rb +0 -12
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +0 -6
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -11
- data/app/helpers/blacklight/configuration_helper_behavior.rb +0 -12
- data/app/helpers/blacklight/document_helper_behavior.rb +0 -26
- data/app/helpers/blacklight/icon_helper_behavior.rb +1 -9
- data/app/helpers/blacklight/layout_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +0 -14
- data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
- data/app/javascript/{blacklight → blacklight-frontend}/bookmark_toggle.js +1 -1
- data/app/javascript/{blacklight → blacklight-frontend}/core.js +2 -10
- data/app/javascript/{blacklight → blacklight-frontend}/debounce.js +1 -1
- data/app/javascript/{blacklight → blacklight-frontend}/facet_suggest.js +3 -3
- data/app/javascript/blacklight-frontend/index.js +18 -0
- data/app/javascript/{blacklight → blacklight-frontend}/modal.js +16 -2
- data/app/models/concerns/blacklight/document.rb +0 -11
- data/app/models/concerns/blacklight/user.rb +1 -1
- data/app/presenters/blacklight/facet_field_presenter.rb +2 -2
- data/app/presenters/blacklight/json_presenter.rb +3 -1
- data/app/services/blacklight/search_params_yaml_coder.rb +0 -2
- data/app/views/bookmarks/_clear_bookmarks_widget.html.erb +0 -2
- data/app/views/bookmarks/index.html.erb +1 -1
- data/app/views/catalog/_results_pagination.html.erb +2 -5
- data/app/views/catalog/_search_results.html.erb +4 -4
- data/app/views/catalog/_search_results_header.html.erb +1 -1
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/_sort_widget.html.erb +1 -0
- data/app/views/catalog/facet.html.erb +1 -1
- data/app/views/catalog/show.html.erb +2 -3
- data/app/views/kaminari/blacklight/_paginator.html.erb +1 -2
- data/app/views/layouts/blacklight/base.html.erb +3 -7
- data/app/views/search_history/index.html.erb +0 -2
- data/blacklight.gemspec +4 -4
- data/config/importmap.rb +1 -1
- data/config/locales/blacklight.ar.yml +4 -4
- data/config/locales/blacklight.ca.yml +124 -124
- data/config/locales/blacklight.de.yml +2 -2
- data/config/locales/blacklight.en.yml +14 -14
- data/config/locales/blacklight.es.yml +4 -4
- data/config/locales/blacklight.fr.yml +4 -4
- data/config/locales/blacklight.hu.yml +4 -4
- data/config/locales/blacklight.it.yml +3 -3
- data/config/locales/blacklight.nl.yml +3 -3
- data/config/locales/blacklight.pt-BR.yml +3 -3
- data/config/locales/blacklight.sq.yml +4 -4
- data/config/locales/blacklight.zh.yml +4 -4
- data/lib/blacklight/configuration/display_field.rb +1 -1
- data/lib/blacklight/configuration/fields.rb +3 -3
- data/lib/blacklight/configuration/view_config.rb +0 -2
- data/lib/blacklight/configuration.rb +7 -12
- data/lib/blacklight/engine.rb +0 -6
- data/lib/blacklight/open_struct_with_hash_access.rb +4 -4
- data/lib/blacklight/search_builder.rb +4 -4
- data/lib/blacklight/search_state/filter_field.rb +2 -2
- data/lib/blacklight/solr/request.rb +1 -7
- data/lib/blacklight/solr/response/group_response.rb +2 -2
- data/lib/blacklight.rb +1 -1
- data/lib/generators/blacklight/assets/importmap_generator.rb +8 -24
- data/lib/generators/blacklight/assets/propshaft_generator.rb +1 -1
- data/lib/generators/blacklight/assets_generator.rb +3 -3
- data/lib/generators/blacklight/controller_generator.rb +3 -3
- data/lib/generators/blacklight/user_generator.rb +9 -10
- data/package.json +14 -4
- data/rollup.config.js +1 -1
- data/spec/components/blacklight/document/action_component_spec.rb +1 -5
- data/spec/components/blacklight/document/sidebar_component_spec.rb +5 -20
- data/spec/components/blacklight/facet_field_checkboxes_component_spec.rb +2 -2
- data/spec/components/blacklight/facet_field_list_component_spec.rb +2 -2
- data/spec/components/blacklight/search/facet_suggest_input_spec.rb +2 -18
- data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +1 -1
- data/spec/features/axe_spec.rb +6 -11
- data/spec/features/bookmarks_spec.rb +48 -11
- data/spec/features/facets_spec.rb +21 -36
- data/spec/features/search_context_spec.rb +1 -2
- data/spec/features/search_filters_spec.rb +6 -6
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +0 -9
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +1 -1
- data/spec/lib/blacklight/parameters_spec.rb +1 -12
- data/spec/lib/blacklight/search_state/filter_field_spec.rb +0 -18
- data/spec/models/blacklight/solr/request_spec.rb +7 -0
- data/spec/services/blacklight/search_service_spec.rb +1 -1
- data/spec/test_app_templates/Gemfile.extra +0 -1
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +3 -3
- data/spec/views/catalog/index.html.erb_spec.rb +6 -3
- data/spec/views/catalog/show.html.erb_spec.rb +1 -0
- data/tasks/blacklight.rake +8 -5
- metadata +30 -54
- data/app/assets/stylesheets/blacklight/_autocomplete.scss +0 -25
- data/app/assets/stylesheets/blacklight/_mixins.scss +0 -20
- data/app/components/blacklight/icons/legacy_icon_component.rb +0 -30
- data/app/javascript/blacklight/index.js +0 -18
- data/app/views/catalog/_constraints.html.erb +0 -1
- data/app/views/catalog/_facets.html.erb +0 -5
- data/app/views/catalog/_search_form.html.erb +0 -7
- data/app/views/catalog/_search_header.html.erb +0 -1
- data/app/views/catalog/_show_sidebar.html.erb +0 -3
- data/app/views/catalog/_show_tools.html.erb +0 -2
- data/app/views/catalog/_start_over.html.erb +0 -1
- data/app/views/shared/_header_navbar.html.erb +0 -1
- data/lib/generators/blacklight/assets/sprockets_generator.rb +0 -68
- data/spec/views/catalog/_search_header.erb_spec.rb +0 -14
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +0 -24
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +0 -37
- /data/app/javascript/{blacklight → blacklight-frontend}/button_focus.js +0 -0
- /data/app/javascript/{blacklight → blacklight-frontend}/checkbox_submit.js +0 -0
- /data/app/javascript/{blacklight → blacklight-frontend}/modalForm.js +0 -0
- /data/app/javascript/{blacklight → blacklight-frontend}/search_context.js +0 -0
@@ -90,7 +90,7 @@ zh:
|
|
90
90
|
close: 隐藏方面
|
91
91
|
open: 显示方面
|
92
92
|
missing: "[未找到]"
|
93
|
-
more_html: 更多 <span class="
|
93
|
+
more_html: 更多 <span class="visually-hidden">%{field_name}</span> »
|
94
94
|
pivot:
|
95
95
|
hide: 关
|
96
96
|
show: 打开
|
@@ -100,8 +100,8 @@ zh:
|
|
100
100
|
count: 按数量排序
|
101
101
|
index: 按字母排序
|
102
102
|
suggest:
|
103
|
-
label:
|
104
|
-
placeholder:
|
103
|
+
label: Filter %{field_label}
|
104
|
+
placeholder: Filter...
|
105
105
|
title: 限定搜索
|
106
106
|
filters:
|
107
107
|
label: "%{label}:"
|
@@ -139,7 +139,7 @@ zh:
|
|
139
139
|
aria_label: 结果导航
|
140
140
|
button_label: "%{count} 每页"
|
141
141
|
button_label_html: '%{count}<span class="d-none d-sm-inline"> 每页</span>'
|
142
|
-
label: '%{count}<span class="
|
142
|
+
label: '%{count}<span class="visually-hidden"> 每页</span>'
|
143
143
|
submit: 更新
|
144
144
|
title: 每页显示结果数
|
145
145
|
rss_feed: 搜索结果RSS
|
@@ -81,7 +81,7 @@ module Blacklight
|
|
81
81
|
#
|
82
82
|
# add_blacklight_field :index_field, [{ :field => 'format', :label => 'Format' }, IndexField.new(:field => 'date', :label => 'Date')]
|
83
83
|
#
|
84
|
-
def add_blacklight_field
|
84
|
+
def add_blacklight_field(config_key, *args, &)
|
85
85
|
field_config = case args.first
|
86
86
|
when String
|
87
87
|
field_config_from_key_and_hash(config_key, *args)
|
@@ -89,7 +89,7 @@ module Blacklight
|
|
89
89
|
args[0] = args[0].to_s
|
90
90
|
field_config_from_key_and_hash(config_key, *args)
|
91
91
|
when Array
|
92
|
-
field_config_from_array(config_key, *args, &
|
92
|
+
field_config_from_array(config_key, *args, &)
|
93
93
|
return # we've iterated over the array above.
|
94
94
|
else
|
95
95
|
field_config_from_field_or_hash(config_key, *args)
|
@@ -101,7 +101,7 @@ module Blacklight
|
|
101
101
|
|
102
102
|
# look up any dynamic fields
|
103
103
|
if field_config.match
|
104
|
-
handle_matching_fields(config_key, field_config, &
|
104
|
+
handle_matching_fields(config_key, field_config, &)
|
105
105
|
return
|
106
106
|
end
|
107
107
|
|
@@ -4,8 +4,6 @@ class Blacklight::Configuration
|
|
4
4
|
class ViewConfig < Blacklight::OpenStructWithHashAccess
|
5
5
|
# @!attribute template
|
6
6
|
# @return [String] partial to render around the documents
|
7
|
-
# @!attribute partials
|
8
|
-
# @return [Array<String>] partials to render for each document(see #render_document_partials)
|
9
7
|
# @!attribute document_presenter_class
|
10
8
|
# @return [Class] document presenter class used by helpers and views
|
11
9
|
# @!attribute document_component
|
@@ -43,6 +43,7 @@ module Blacklight
|
|
43
43
|
default_configuration do
|
44
44
|
property :logo_link, default: nil
|
45
45
|
property :skip_link_component, default: Blacklight::SkipLinkComponent
|
46
|
+
property :skip_link_item_component, default: Blacklight::SkipLinkItemComponent
|
46
47
|
property :header_component, default: Blacklight::HeaderComponent
|
47
48
|
property :full_width_layout, default: false
|
48
49
|
|
@@ -137,8 +138,8 @@ module Blacklight
|
|
137
138
|
# @!attribute bookmark_icon_component
|
138
139
|
# @since v8.3.1
|
139
140
|
# component class used to render a document
|
140
|
-
# set to
|
141
|
-
property :bookmark_icon_component, default:
|
141
|
+
# set to nil if a checkbox is prefered to the icon
|
142
|
+
property :bookmark_icon_component, default: Blacklight::Icons::BookmarkIconComponent
|
142
143
|
|
143
144
|
# @!attribute index
|
144
145
|
# General configuration for all views
|
@@ -156,8 +157,6 @@ module Blacklight
|
|
156
157
|
display_type_field: nil,
|
157
158
|
# the "field access" key to use to look up the document display fields
|
158
159
|
document_fields_key: :index_fields,
|
159
|
-
# partials to render for each document(see #render_document_partials)
|
160
|
-
partials: [],
|
161
160
|
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
162
161
|
collection_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
163
162
|
# what field, if any, to use to render grouped results
|
@@ -165,9 +164,9 @@ module Blacklight
|
|
165
164
|
# additional response formats for search results
|
166
165
|
respond_to: OpenStructWithHashAccess.new,
|
167
166
|
# component class used to render the facet grouping
|
168
|
-
facet_group_component:
|
167
|
+
facet_group_component: Blacklight::Response::FacetGroupComponent,
|
169
168
|
# component class used to render search constraints
|
170
|
-
constraints_component:
|
169
|
+
constraints_component: Blacklight::ConstraintsComponent,
|
171
170
|
# component class used to render the search bar
|
172
171
|
search_bar_component: nil,
|
173
172
|
# component class used to render the header above the documents
|
@@ -183,9 +182,7 @@ module Blacklight
|
|
183
182
|
# document presenter class used by helpers and views
|
184
183
|
document_presenter_class: nil,
|
185
184
|
document_component: Blacklight::DocumentComponent,
|
186
|
-
|
187
|
-
# be Blacklight::Document::ShowToolsComponent
|
188
|
-
show_tools_component: nil,
|
185
|
+
show_tools_component: Blacklight::Document::ShowToolsComponent,
|
189
186
|
show_header_tools_component: nil,
|
190
187
|
document_header_component: Blacklight::Document::PageHeaderComponent,
|
191
188
|
sidebar_component: Blacklight::Document::SidebarComponent,
|
@@ -196,8 +193,6 @@ module Blacklight
|
|
196
193
|
# Set this to a hash with additional arguments to merge into the route,
|
197
194
|
# or set `controller: :current` to route to the current controller.
|
198
195
|
route: nil,
|
199
|
-
# partials to render for each document(see #render_document_partials)
|
200
|
-
partials: [],
|
201
196
|
document_actions: NestedOpenStructWithHashAccess.new(ToolConfig),
|
202
197
|
header_actions: NestedOpenStructWithHashAccess.new(ToolConfig)
|
203
198
|
)
|
@@ -584,7 +579,7 @@ module Blacklight
|
|
584
579
|
|
585
580
|
##
|
586
581
|
# Add a section of config that only applies to documents with a matching display type
|
587
|
-
def for_display_type
|
582
|
+
def for_display_type(display_type, &)
|
588
583
|
fields_for_type[display_type] ||= self.class.new
|
589
584
|
|
590
585
|
fields_for_type[display_type].tap do |conf|
|
data/lib/blacklight/engine.rb
CHANGED
@@ -72,12 +72,6 @@ module Blacklight
|
|
72
72
|
outer_window: 2
|
73
73
|
}
|
74
74
|
|
75
|
-
# Blacklight 9 moves the next button after the page numbers. This behavior can be configured
|
76
|
-
# in Blacklight 8 by setting the next_button_position to :after
|
77
|
-
bl_global_config.paginator = {
|
78
|
-
next_button_position: :before
|
79
|
-
}
|
80
|
-
|
81
75
|
bl_global_config.search_params_permitted_classes = [ActiveSupport::HashWithIndifferentAccess, Symbol]
|
82
76
|
|
83
77
|
# Anything that goes into Blacklight::Engine.config is stored as a class
|
@@ -53,14 +53,14 @@ module Blacklight
|
|
53
53
|
self.class.new @table.deep_dup
|
54
54
|
end
|
55
55
|
|
56
|
-
def deep_transform_values(&
|
57
|
-
self.class.new @table.deep_transform_values(&
|
56
|
+
def deep_transform_values(&)
|
57
|
+
self.class.new @table.deep_transform_values(&)
|
58
58
|
end
|
59
59
|
|
60
|
-
def try(method_name = nil, *args, &
|
60
|
+
def try(method_name = nil, *args, &)
|
61
61
|
if method_name.nil? && block_given?
|
62
62
|
if b.arity.zero?
|
63
|
-
instance_eval(&
|
63
|
+
instance_eval(&)
|
64
64
|
else
|
65
65
|
yield self
|
66
66
|
end
|
@@ -95,20 +95,20 @@ module Blacklight
|
|
95
95
|
|
96
96
|
##
|
97
97
|
# Merge additional, repository-specific parameters
|
98
|
-
def merge(extra_params, &
|
98
|
+
def merge(extra_params, &)
|
99
99
|
if extra_params
|
100
100
|
params_will_change!
|
101
|
-
@merged_params.merge!(extra_params.to_hash, &
|
101
|
+
@merged_params.merge!(extra_params.to_hash, &)
|
102
102
|
end
|
103
103
|
self
|
104
104
|
end
|
105
105
|
|
106
106
|
##
|
107
107
|
# "Reverse merge" additional, repository-specific parameters
|
108
|
-
def reverse_merge(extra_params, &
|
108
|
+
def reverse_merge(extra_params, &)
|
109
109
|
if extra_params
|
110
110
|
params_will_change!
|
111
|
-
@reverse_merged_params.reverse_merge!(extra_params.to_hash, &
|
111
|
+
@reverse_merged_params.reverse_merge!(extra_params.to_hash, &)
|
112
112
|
end
|
113
113
|
self
|
114
114
|
end
|
@@ -145,8 +145,8 @@ module Blacklight
|
|
145
145
|
def permitted_params
|
146
146
|
if config.pivot
|
147
147
|
{
|
148
|
-
filters_key => config.pivot.each_with_object({}) { |key, filter| filter.merge
|
149
|
-
inclusive_filters_key => config.pivot.each_with_object({}) { |key, filter| filter.merge
|
148
|
+
filters_key => config.pivot.each_with_object({}) { |key, filter| filter.merge(key => [], "-#{key}" => []) },
|
149
|
+
inclusive_filters_key => config.pivot.each_with_object({}) { |key, filter| filter.merge(key => []) }
|
150
150
|
}
|
151
151
|
else
|
152
152
|
{
|
@@ -3,12 +3,6 @@
|
|
3
3
|
class Blacklight::Solr::InvalidParameter < ArgumentError; end
|
4
4
|
|
5
5
|
class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
|
6
|
-
# @deprecated
|
7
|
-
SINGULAR_KEYS = %w(facet fl q qt rows start spellcheck spellcheck.q sort per_page wt hl group defType)
|
8
|
-
|
9
|
-
# @deprecated
|
10
|
-
ARRAY_KEYS = %w(facet.field facet.query facet.pivot fq hl.fl)
|
11
|
-
|
12
6
|
def initialize(constructor = {})
|
13
7
|
if constructor.is_a?(Hash)
|
14
8
|
super()
|
@@ -42,7 +36,7 @@ class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
|
|
42
36
|
self[:json][:query] ||= { bool: { bool_operator => [] } }
|
43
37
|
self[:json][:query][:bool][bool_operator] ||= []
|
44
38
|
|
45
|
-
if self['q']
|
39
|
+
if self['q'].present?
|
46
40
|
self[:json][:query][:bool][:must] ||= []
|
47
41
|
self[:json][:query][:bool][:must] << self['q']
|
48
42
|
delete 'q'
|
@@ -51,9 +51,9 @@ class Blacklight::Solr::Response::GroupResponse
|
|
51
51
|
)
|
52
52
|
end
|
53
53
|
|
54
|
-
def method_missing
|
54
|
+
def method_missing(meth, *args, &)
|
55
55
|
if response.respond_to? meth
|
56
|
-
response.send(meth, *args, &
|
56
|
+
response.send(meth, *args, &)
|
57
57
|
else
|
58
58
|
super
|
59
59
|
end
|
data/lib/blacklight.rb
CHANGED
@@ -116,7 +116,7 @@ module Blacklight
|
|
116
116
|
|
117
117
|
# returns the full path the the blacklight plugin installation
|
118
118
|
def self.root
|
119
|
-
@root ||= File.expand_path(File.dirname(
|
119
|
+
@root ||= File.expand_path(File.dirname(__FILE__, 2))
|
120
120
|
end
|
121
121
|
|
122
122
|
def self.deprecation
|
@@ -5,18 +5,12 @@ module Blacklight
|
|
5
5
|
class ImportmapGenerator < Rails::Generators::Base
|
6
6
|
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '~> 5.3'), desc: "Set the generated app's bootstrap version"
|
7
7
|
|
8
|
-
# This could be skipped if you want to use webpacker
|
9
|
-
def add_javascript_dependencies
|
10
|
-
gem 'bootstrap', options[:'bootstrap-version'].presence # in rails 7, only for stylesheets
|
11
|
-
gem 'jquery-rails' if bootstrap_4? # Bootstrap 4 has a dependency on jquery
|
12
|
-
end
|
13
|
-
|
14
8
|
def import_javascript_assets
|
15
9
|
append_to_file 'config/importmap.rb' do
|
16
10
|
<<~CONTENT
|
17
11
|
pin "@github/auto-complete-element", to: "https://cdn.skypack.dev/@github/auto-complete-element"
|
18
12
|
pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.6/dist/umd/popper.min.js"
|
19
|
-
pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.3.
|
13
|
+
pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.3.3'}/dist/js/bootstrap.js"
|
20
14
|
CONTENT
|
21
15
|
end
|
22
16
|
|
@@ -40,39 +34,29 @@ module Blacklight
|
|
40
34
|
append_to_file 'app/javascript/application.js' do
|
41
35
|
<<~CONTENT
|
42
36
|
import githubAutoCompleteElement from "@github/auto-complete-element"
|
43
|
-
import Blacklight from "blacklight"
|
37
|
+
import Blacklight from "blacklight-frontend"
|
44
38
|
CONTENT
|
45
39
|
end
|
46
40
|
end
|
47
41
|
|
48
42
|
def add_stylesheet
|
49
43
|
if File.exist? 'app/assets/stylesheets/application.bootstrap.scss'
|
50
|
-
if ENV['CI']
|
51
|
-
run "yarn add file:#{Blacklight::Engine.root}"
|
52
|
-
else
|
53
|
-
run "yarn add blacklight-frontend@#{Blacklight::VERSION}"
|
54
|
-
end
|
55
|
-
|
56
44
|
append_to_file 'app/assets/stylesheets/application.bootstrap.scss' do
|
57
45
|
<<~CONTENT
|
58
|
-
@import "blacklight
|
46
|
+
@import url("blacklight.css");
|
59
47
|
CONTENT
|
60
48
|
end
|
61
49
|
else
|
62
|
-
|
63
|
-
|
64
|
-
create_file 'app/assets/stylesheets/blacklight.scss' do
|
50
|
+
append_to_file 'app/assets/stylesheets/application.css' do
|
65
51
|
<<~CONTENT
|
66
|
-
|
67
|
-
|
52
|
+
/*
|
53
|
+
*= require blacklight
|
54
|
+
*/
|
55
|
+
@import url(https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css);
|
68
56
|
CONTENT
|
69
57
|
end
|
70
58
|
end
|
71
59
|
end
|
72
|
-
|
73
|
-
def bootstrap_4?
|
74
|
-
options[:'bootstrap-version'].match?(/\A[^0-9]*4\./)
|
75
|
-
end
|
76
60
|
end
|
77
61
|
end
|
78
62
|
end
|
@@ -18,7 +18,7 @@ module Blacklight
|
|
18
18
|
def add_package_assets
|
19
19
|
append_to_file 'app/assets/stylesheets/application.bootstrap.scss' do
|
20
20
|
<<~CONTENT
|
21
|
-
@import "blacklight
|
21
|
+
@import url("blacklight.css");
|
22
22
|
CONTENT
|
23
23
|
end
|
24
24
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Blacklight
|
4
4
|
class AssetsGenerator < Rails::Generators::Base
|
5
|
-
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '
|
5
|
+
class_option :'bootstrap-version', type: :string, default: ENV.fetch('BOOTSTRAP_VERSION', '5.3.3'), desc: "Set the generated app's bootstrap version"
|
6
6
|
|
7
7
|
def run_asset_pipeline_specific_generator
|
8
8
|
generated_options = "--bootstrap-version='#{options[:'bootstrap-version']}'" if options[:'bootstrap-version']
|
@@ -11,8 +11,8 @@ module Blacklight
|
|
11
11
|
'blacklight:assets:importmap'
|
12
12
|
elsif defined?(Propshaft)
|
13
13
|
'blacklight:assets:propshaft'
|
14
|
-
|
15
|
-
|
14
|
+
else
|
15
|
+
raise "Unsupported path"
|
16
16
|
end
|
17
17
|
|
18
18
|
generate generator, generated_options if generator
|
@@ -16,9 +16,9 @@ module Blacklight
|
|
16
16
|
# Add Blacklight to the application controller
|
17
17
|
def inject_blacklight_controller_behavior
|
18
18
|
inject_into_class "app/controllers/application_controller.rb", "ApplicationController" do
|
19
|
-
" # Adds a few additional behaviors into the application controller\n" \
|
20
|
-
"
|
21
|
-
"
|
19
|
+
" # Adds a few additional behaviors into the application controller\n " \
|
20
|
+
"include Blacklight::Controller\n " \
|
21
|
+
"layout :determine_layout if respond_to? :layout\n\n"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -34,13 +34,6 @@ module Blacklight
|
|
34
34
|
generate "devise", model_name.classify
|
35
35
|
generate "devise_guests", model_name.classify
|
36
36
|
|
37
|
-
# add the #to_s to the model.
|
38
|
-
insert_into_file("app/models/#{model_name}.rb", before: /end(\n| )*$/) do
|
39
|
-
"\n # Configuration added by Blacklight; Blacklight::User uses a method key on your\n" \
|
40
|
-
" # user class to get a user-displayable login/identifier for\n" \
|
41
|
-
" # the account.\n" \
|
42
|
-
" self.string_display_key ||= :email\n"
|
43
|
-
end
|
44
37
|
gsub_file("config/initializers/devise.rb", "config.sign_out_via = :delete", "config.sign_out_via = :get")
|
45
38
|
# Work around for https://github.com/heartcombo/devise/issues/5720
|
46
39
|
gsub_file("config/initializers/devise.rb", "# config.reload_routes = true", "config.reload_routes = false")
|
@@ -51,13 +44,19 @@ module Blacklight
|
|
51
44
|
file_path = "app/models/#{model_name.underscore}.rb"
|
52
45
|
if File.exist?(File.expand_path(file_path, destination_root))
|
53
46
|
inject_into_class file_path, model_name.classify do
|
54
|
-
|
55
|
-
|
47
|
+
<<~EOS
|
48
|
+
# Connects this user object to Blacklights Bookmarks.
|
49
|
+
include Blacklight::User
|
50
|
+
|
51
|
+
# Blacklight::User uses a method on your User class to get a user-displayable
|
52
|
+
# label (e.g. login or identifier) for the account. Blacklight uses `email' by default.
|
53
|
+
# self.string_display_key = :email
|
54
|
+
EOS
|
56
55
|
end
|
57
56
|
else
|
58
57
|
say_status "warning", <<~EOS, :yellow
|
59
58
|
Blacklight authenticated user functionality not installed, as a user model
|
60
|
-
could not be found at
|
59
|
+
could not be found at #{file_path}. If you used a different name,
|
61
60
|
please re-run the migration and provide that name as an argument. E.g.:
|
62
61
|
|
63
62
|
`rails -g blacklight:user client`
|
data/package.json
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
{
|
2
2
|
"name": "blacklight-frontend",
|
3
|
-
"version": "
|
3
|
+
"version": "9.0.0-beta1",
|
4
4
|
"description": "The frontend code and styles for Blacklight",
|
5
|
-
"
|
5
|
+
"exports": {
|
6
|
+
"./blacklight.esm.js": "./app/assets/javascripts/blacklight/blacklight.esm.js",
|
7
|
+
"./stylesheets/*": "./app/assets/stylesheets/blacklight/*",
|
8
|
+
".": {
|
9
|
+
"import": "./app/javascript/blacklight-frontend/index.js",
|
10
|
+
"require": "./app/assets/javascripts/blacklight.js"
|
11
|
+
},
|
12
|
+
"./*": "./app/javascript/blacklight-frontend/*.js"
|
13
|
+
},
|
6
14
|
"type": "module",
|
7
|
-
"module": "app/assets/javascripts/blacklight/blacklight.esm.js",
|
8
15
|
"scripts": {
|
16
|
+
"build": "sass ./app/assets/stylesheets/blacklight/build.scss:./app/assets/builds/blacklight.css --no-source-map --load-path=node_modules --quiet-deps",
|
9
17
|
"prepare": "rollup --config rollup.config.js --sourcemap && ESM=true rollup --config rollup.config.js --sourcemap"
|
10
18
|
},
|
11
19
|
"repository": {
|
@@ -24,7 +32,9 @@
|
|
24
32
|
"homepage": "https://github.com/projectblacklight/blacklight#readme",
|
25
33
|
"devDependencies": {
|
26
34
|
"rollup": "^4.24.0",
|
27
|
-
"rollup-plugin-includepaths": "^0.2.4"
|
35
|
+
"rollup-plugin-includepaths": "^0.2.4",
|
36
|
+
"sass": "^1.80.3",
|
37
|
+
"bootstrap": "^5.3.3"
|
28
38
|
},
|
29
39
|
"browserslist": [
|
30
40
|
"defaults",
|
data/rollup.config.js
CHANGED
@@ -16,7 +16,7 @@ let includePathOptions = {
|
|
16
16
|
};
|
17
17
|
|
18
18
|
const rollupConfig = {
|
19
|
-
input: 'app/javascript/blacklight/index.js',
|
19
|
+
input: 'app/javascript/blacklight-frontend/index.js',
|
20
20
|
output: {
|
21
21
|
file: `app/assets/javascripts/blacklight/${fileDest}.js`,
|
22
22
|
format: ESM ? 'es' : 'umd',
|
@@ -23,11 +23,7 @@ RSpec.describe Blacklight::Document::ActionComponent, type: :component do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'renders an action link' do
|
26
|
-
|
27
|
-
allow(view_context).to receive(:some_tool_solr_document_path).with(document, { only_path: true }).and_return('/asdf')
|
28
|
-
else
|
29
|
-
allow(view_context).to receive(:some_tool_solr_document_path).with(document).and_return('/asdf')
|
30
|
-
end
|
26
|
+
allow(view_context).to receive(:some_tool_solr_document_path).with(document, { only_path: true }).and_return('/asdf')
|
31
27
|
|
32
28
|
expect(rendered).to have_link 'Some tool', href: '/asdf'
|
33
29
|
end
|
@@ -33,29 +33,14 @@ RSpec.describe Blacklight::Document::SidebarComponent, type: :component do
|
|
33
33
|
# rubocop:disable RSpec/SubjectStub
|
34
34
|
before do
|
35
35
|
allow(component).to receive(:render).with(an_instance_of(Blacklight::Document::MoreLikeThisComponent)).and_return("")
|
36
|
+
blacklight_config.show.show_tools_component = show_tools_component
|
37
|
+
allow(component).to receive(:render).with(an_instance_of(show_tools_component)).and_return(expected_html)
|
36
38
|
end
|
37
39
|
|
38
|
-
|
39
|
-
before do
|
40
|
-
allow(component).to receive(:render).with('show_tools', document: presented_document, silence_deprecation: false).and_return(expected_html)
|
41
|
-
end
|
40
|
+
let(:show_tools_component) { Class.new(Blacklight::Document::ShowToolsComponent) }
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "with a configured ShowTools component" do
|
49
|
-
let(:show_tools_component) { Class.new(Blacklight::Document::ShowToolsComponent) }
|
50
|
-
|
51
|
-
before do
|
52
|
-
blacklight_config.show.show_tools_component = show_tools_component
|
53
|
-
allow(component).to receive(:render).with(an_instance_of(show_tools_component)).and_return(expected_html)
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'renders configured show_tools component' do
|
57
|
-
expect(rendered).to have_css 'div[@class="expected-show_tools"]'
|
58
|
-
end
|
42
|
+
it 'renders configured show_tools component' do
|
43
|
+
expect(rendered).to have_css 'div[@class="expected-show_tools"]'
|
59
44
|
end
|
60
45
|
# rubocop:enable RSpec/SubjectStub
|
61
46
|
end
|
@@ -32,8 +32,8 @@ RSpec.describe Blacklight::FacetFieldCheckboxesComponent, type: :component do
|
|
32
32
|
let(:search_state) { Blacklight::SearchState.new(params.with_indifferent_access, Blacklight::Configuration.new) }
|
33
33
|
let(:params) { { f: { field: ['a'] } } }
|
34
34
|
|
35
|
-
it 'renders
|
36
|
-
expect(rendered).to have_css '.
|
35
|
+
it 'renders an accordion item' do
|
36
|
+
expect(rendered).to have_css '.accordion-item'
|
37
37
|
expect(rendered).to have_button 'Field'
|
38
38
|
expect(rendered).to have_css 'button[data-bs-target="#facet-field"]'
|
39
39
|
expect(rendered).to have_css '#facet-field.collapse.show'
|
@@ -30,8 +30,8 @@ RSpec.describe Blacklight::FacetFieldListComponent, type: :component do
|
|
30
30
|
])
|
31
31
|
end
|
32
32
|
|
33
|
-
it 'renders
|
34
|
-
expect(rendered).to have_css '.
|
33
|
+
it 'renders an accordion item' do
|
34
|
+
expect(rendered).to have_css '.accordion-item'
|
35
35
|
expect(rendered).to have_button 'Field'
|
36
36
|
expect(rendered).to have_css 'button[data-bs-target="#facet-field"]'
|
37
37
|
expect(rendered).to have_css '#facet-field.collapse.show'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
RSpec.describe Blacklight::Search::FacetSuggestInput, type: :component do
|
6
|
-
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet'
|
6
|
+
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet' }
|
7
7
|
let(:presenter) { instance_double(Blacklight::FacetFieldPresenter) }
|
8
8
|
|
9
9
|
before do
|
@@ -26,24 +26,8 @@ RSpec.describe Blacklight::Search::FacetSuggestInput, type: :component do
|
|
26
26
|
expect(label.text.strip).to eq 'Filter Language'
|
27
27
|
|
28
28
|
id_in_label_for = label.attribute('for').text
|
29
|
-
expect(id_in_label_for).to eq('
|
29
|
+
expect(id_in_label_for).to eq('facet-suggest-language_facet')
|
30
30
|
|
31
31
|
expect(rendered.css('input').first.attribute('id').text).to eq id_in_label_for
|
32
32
|
end
|
33
|
-
|
34
|
-
context 'when the facet is explicitly configured to suggest: false' do
|
35
|
-
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet', suggest: false }
|
36
|
-
|
37
|
-
it 'does not display' do
|
38
|
-
expect(render_inline(described_class.new(facet: facet, presenter: presenter)).to_s).to eq ''
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'when the facet is not explicitly configured with a suggest key' do
|
43
|
-
let(:facet) { Blacklight::Configuration::FacetField.new key: 'language_facet' }
|
44
|
-
|
45
|
-
it 'does not display' do
|
46
|
-
expect(render_inline(described_class.new(facet: facet, presenter: presenter)).to_s).to eq ''
|
47
|
-
end
|
48
|
-
end
|
49
33
|
end
|
@@ -85,7 +85,7 @@ RSpec.describe Blacklight::SearchBarComponent, type: :component do
|
|
85
85
|
subject(:render) { render_inline(instance) }
|
86
86
|
|
87
87
|
it 'sets the rounded border class' do
|
88
|
-
expect(render.css('.rounded-
|
88
|
+
expect(render.css('.rounded-start')).to be_present
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -803,7 +803,7 @@ RSpec.describe CatalogController, :api do
|
|
803
803
|
end
|
804
804
|
|
805
805
|
it "is empty for empty result sets", :integration do
|
806
|
-
get :page_links, params: { f: { "format" =>
|
806
|
+
get :page_links, params: { f: { "format" => 'empty-result-set' }, counter: 1 }
|
807
807
|
expect(assigns(:page_link_data)).to be_empty
|
808
808
|
end
|
809
809
|
end
|
data/spec/features/axe_spec.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
RSpec.describe 'Accessibility testing', :js, api: false do
|
4
4
|
it 'validates the home page' do
|
5
5
|
visit root_path
|
6
|
-
expect(page).to
|
6
|
+
expect(page).to be_axe_clean
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'validates the catalog page' do
|
@@ -11,28 +11,23 @@ RSpec.describe 'Accessibility testing', :js, api: false do
|
|
11
11
|
fill_in "q", with: 'history'
|
12
12
|
click_on 'search'
|
13
13
|
|
14
|
-
expect(page).to
|
14
|
+
expect(page).to be_axe_clean
|
15
15
|
|
16
|
-
within '.
|
16
|
+
within '.accordion-item.blacklight-language_ssim' do
|
17
17
|
click_on 'Language'
|
18
18
|
click_on "Tibetan"
|
19
19
|
end
|
20
20
|
|
21
|
-
expect(page).to
|
21
|
+
expect(page).to be_axe_clean
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'validates the advanced search form' do
|
25
25
|
visit advanced_search_catalog_path
|
26
|
-
expect(page).to
|
26
|
+
expect(page).to be_axe_clean
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'validates the single results page' do
|
30
30
|
visit solr_document_path('2007020969')
|
31
|
-
expect(page).to
|
32
|
-
end
|
33
|
-
|
34
|
-
def be_accessible(skipping: [])
|
35
|
-
# typeahead does funny things with the search bar
|
36
|
-
be_axe_clean.excluding('.tt-hint').skipping(skipping + [('color-contrast' if defined?(Bootstrap) && Bootstrap::VERSION < '5')].compact)
|
31
|
+
expect(page).to be_axe_clean
|
37
32
|
end
|
38
33
|
end
|