blacklight 8.12.2 → 8.13.0
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/.github/matrix.json +43 -26
- data/.github/workflows/test.yml +1 -2
- data/.rubocop.yml +151 -8
- data/.rubocop_todo.yml +65 -53
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
- data/app/components/blacklight/advanced_search_form_component.rb +2 -2
- data/app/components/blacklight/constraints_component.rb +2 -2
- data/app/components/blacklight/document/bookmark_component.rb +2 -2
- data/app/components/blacklight/document/more_like_this_component.rb +2 -2
- data/app/components/blacklight/icons/legacy_icon_component.rb +1 -1
- data/app/components/blacklight/metadata_field_plain_text_layout_component.rb +2 -2
- data/app/controllers/concerns/blacklight/bookmarks.rb +5 -5
- data/app/controllers/concerns/blacklight/search_context.rb +1 -1
- data/app/controllers/concerns/blacklight/search_history.rb +1 -1
- data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/icon_helper_behavior.rb +3 -3
- data/app/helpers/blacklight/layout_helper_behavior.rb +2 -2
- data/app/models/blacklight/icon.rb +3 -2
- data/app/models/concerns/blacklight/user.rb +1 -0
- data/app/presenters/blacklight/facet_field_presenter.rb +2 -2
- data/app/presenters/blacklight/rendering/helper_method.rb +4 -4
- data/app/presenters/blacklight/rendering/join.rb +2 -2
- data/app/presenters/blacklight/rendering/microdata.rb +1 -0
- data/app/values/blacklight/types.rb +2 -2
- data/app/views/catalog/_email_form.html.erb +2 -2
- data/app/views/catalog/_sms_form.html.erb +2 -2
- data/blacklight.gemspec +1 -1
- data/lib/blacklight/abstract_repository.rb +2 -2
- data/lib/blacklight/component.rb +2 -0
- data/lib/blacklight/configuration/context.rb +3 -3
- data/lib/blacklight/configuration/display_field.rb +1 -1
- data/lib/blacklight/configuration/field.rb +10 -10
- data/lib/blacklight/configuration/fields.rb +3 -3
- data/lib/blacklight/configuration/sort_field.rb +2 -2
- data/lib/blacklight/configuration/view_config.rb +2 -2
- data/lib/blacklight/configuration.rb +1 -1
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -1
- data/lib/blacklight/open_struct_with_hash_access.rb +5 -5
- data/lib/blacklight/parameters.rb +1 -1
- data/lib/blacklight/search_builder.rb +4 -4
- data/lib/blacklight/search_state/filter_field.rb +2 -2
- data/lib/blacklight/search_state/pivot_filter_field.rb +1 -1
- data/lib/blacklight/solr/request.rb +1 -1
- data/lib/blacklight/solr/response/facets.rb +2 -2
- data/lib/blacklight/solr/response/group_response.rb +2 -2
- data/lib/blacklight/solr/response.rb +4 -1
- data/lib/blacklight.rb +1 -1
- data/lib/generators/blacklight/assets/importmap_generator.rb +28 -3
- data/lib/generators/blacklight/search_builder_generator.rb +1 -1
- data/lib/generators/blacklight/templates/solr/conf/schema.xml +264 -178
- data/lib/generators/blacklight/templates/solr/conf/solrconfig.xml +6 -18
- data/package.json +1 -1
- data/spec/components/blacklight/document/action_component_spec.rb +1 -1
- data/spec/components/blacklight/document/group_component_spec.rb +1 -1
- data/spec/components/blacklight/document_component_spec.rb +9 -9
- data/spec/components/blacklight/facet_component_spec.rb +2 -2
- data/spec/components/blacklight/facet_field_list_component_spec.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +2 -2
- data/spec/features/advanced_search_spec.rb +12 -12
- data/spec/features/bookmarks_spec.rb +12 -12
- data/spec/features/did_you_mean_spec.rb +17 -17
- data/spec/features/facet_missing_spec.rb +3 -3
- data/spec/features/modal_spec.rb +1 -1
- data/spec/features/record_view_spec.rb +14 -14
- data/spec/features/search_context_spec.rb +7 -7
- data/spec/features/search_filters_spec.rb +12 -12
- data/spec/features/search_formats_spec.rb +2 -2
- data/spec/features/search_history_spec.rb +11 -11
- data/spec/features/search_pagination_spec.rb +9 -9
- data/spec/features/search_results_spec.rb +3 -3
- data/spec/features/search_sort_spec.rb +4 -4
- data/spec/features/search_spec.rb +15 -15
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +14 -14
- data/spec/helpers/blacklight_helper_spec.rb +6 -0
- data/spec/helpers/catalog_helper_spec.rb +6 -6
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +7 -0
- data/spec/lib/blacklight/search_state/pivot_filter_field_spec.rb +1 -1
- data/spec/models/record_mailer_spec.rb +5 -5
- data/spec/models/solr_document_spec.rb +5 -1
- data/spec/presenters/blacklight/index_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/rendering/pipeline_spec.rb +1 -0
- data/spec/presenters/blacklight/show_presenter_spec.rb +1 -0
- data/spec/presenters/blacklight/thumbnail_presenter_spec.rb +1 -0
- data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_search_header.erb_spec.rb +2 -2
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +5 -5
- data/spec/views/catalog/facet.html.erb_spec.rb +1 -1
- data/spec/views/catalog/index.html.erb_spec.rb +2 -2
- data/spec/views/catalog/show.html.erb_spec.rb +3 -3
- metadata +7 -10
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<div class="modal-body">
|
|
8
8
|
<%= render '/shared/flash_msg' %>
|
|
9
|
-
<div class="form-group row">
|
|
9
|
+
<div class="form-group row mb-3">
|
|
10
10
|
<label class="control-label col-sm-2" for="to">
|
|
11
11
|
<%= t('blacklight.email.form.to') %>
|
|
12
12
|
</label>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
<div class="form-group row">
|
|
18
|
+
<div class="form-group row mb-3">
|
|
19
19
|
<label class="control-label col-sm-2" for="message">
|
|
20
20
|
<%= t('blacklight.email.form.message') %>
|
|
21
21
|
</label>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
method: :post do %>
|
|
6
6
|
<div class="modal-body">
|
|
7
7
|
<%= render '/shared/flash_msg' %>
|
|
8
|
-
<div class="form-group row">
|
|
8
|
+
<div class="form-group row mb-3">
|
|
9
9
|
<label class="control-label col-sm-2" for="to">
|
|
10
10
|
<%= t('blacklight.sms.form.to') %>
|
|
11
11
|
</label>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<%= telephone_field_tag :to, params[:to], class: 'form-control', required: true %>
|
|
14
14
|
</div>
|
|
15
15
|
</div>
|
|
16
|
-
<div class="form-group row">
|
|
16
|
+
<div class="form-group row mb-3">
|
|
17
17
|
<label class="control-label col-sm-2" for="carrier">
|
|
18
18
|
<%= t('blacklight.sms.form.carrier') %>
|
|
19
19
|
</label>
|
data/blacklight.gemspec
CHANGED
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
|
|
|
37
37
|
s.add_development_dependency "rsolr", ">= 1.0.6", "< 3" # Library for interacting with rSolr.
|
|
38
38
|
s.add_development_dependency "rspec-rails", ">= 6.1", "< 8"
|
|
39
39
|
s.add_development_dependency "rspec-collection_matchers", ">= 1.0"
|
|
40
|
-
s.add_development_dependency 'axe-core-rspec'
|
|
40
|
+
s.add_development_dependency 'axe-core-rspec', '~> 4.12.0'
|
|
41
41
|
s.add_development_dependency "capybara", '~> 3'
|
|
42
42
|
s.add_development_dependency 'selenium-webdriver'
|
|
43
43
|
s.add_development_dependency 'engine_cart', '~> 2.1'
|
data/lib/blacklight/component.rb
CHANGED
|
@@ -24,16 +24,16 @@ module Blacklight
|
|
|
24
24
|
#
|
|
25
25
|
# @param [#if,#unless] config an object that responds to if/unless
|
|
26
26
|
# @return [Boolean]
|
|
27
|
-
def evaluate_if_unless_configuration(config, *
|
|
27
|
+
def evaluate_if_unless_configuration(config, *)
|
|
28
28
|
return config if config == true || config == false
|
|
29
29
|
|
|
30
30
|
if_value = !config.respond_to?(:if) ||
|
|
31
31
|
config.if.nil? ||
|
|
32
|
-
evaluate_configuration_conditional(config.if, config, *
|
|
32
|
+
evaluate_configuration_conditional(config.if, config, *)
|
|
33
33
|
|
|
34
34
|
unless_value = !config.respond_to?(:unless) ||
|
|
35
35
|
config.unless.nil? ||
|
|
36
|
-
!evaluate_configuration_conditional(config.unless, config, *
|
|
36
|
+
!evaluate_configuration_conditional(config.unless, config, *)
|
|
37
37
|
|
|
38
38
|
if_value && unless_value
|
|
39
39
|
end
|
|
@@ -17,37 +17,37 @@ module Blacklight
|
|
|
17
17
|
|
|
18
18
|
def normalize! _blacklight_config = nil
|
|
19
19
|
self.field ||= key
|
|
20
|
-
self.key ||=
|
|
20
|
+
self.key ||= field
|
|
21
21
|
|
|
22
22
|
self.label ||= default_label
|
|
23
23
|
|
|
24
24
|
self.if = true if self.if.nil?
|
|
25
25
|
self.unless = false if self.unless.nil?
|
|
26
26
|
|
|
27
|
-
self.field &&=
|
|
27
|
+
self.field &&= field.to_s
|
|
28
28
|
|
|
29
29
|
self
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def validate!
|
|
33
|
-
raise ArgumentError, "Must supply a field name" if
|
|
33
|
+
raise ArgumentError, "Must supply a field name" if field.nil?
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
def display_label(context = nil, **
|
|
36
|
+
def display_label(context = nil, **)
|
|
37
37
|
field_label(
|
|
38
38
|
(:"blacklight.search.fields.#{context}.#{key}" if context),
|
|
39
39
|
:"blacklight.search.fields.#{key}",
|
|
40
40
|
label,
|
|
41
41
|
default_label,
|
|
42
|
-
**
|
|
42
|
+
**
|
|
43
43
|
)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def default_label
|
|
47
|
-
if
|
|
48
|
-
|
|
47
|
+
if key.respond_to?(:titleize)
|
|
48
|
+
key.titleize
|
|
49
49
|
else
|
|
50
|
-
|
|
50
|
+
key.to_s.titleize
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
@@ -65,10 +65,10 @@ module Blacklight
|
|
|
65
65
|
# before falling back to the label
|
|
66
66
|
# @param [Symbol] any number of additional keys
|
|
67
67
|
# @param [Symbol] ...
|
|
68
|
-
def field_label
|
|
68
|
+
def field_label(*i18n_keys, **)
|
|
69
69
|
first, *rest = i18n_keys.compact
|
|
70
70
|
|
|
71
|
-
I18n.t(first, default: rest, **
|
|
71
|
+
I18n.t(first, default: rest, **)
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
end
|
|
@@ -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
|
|
|
@@ -10,13 +10,13 @@ module Blacklight
|
|
|
10
10
|
self.field ||= label&.parameterize
|
|
11
11
|
self.field ||= sort
|
|
12
12
|
|
|
13
|
-
self.sort ||=
|
|
13
|
+
self.sort ||= field
|
|
14
14
|
|
|
15
15
|
self
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def validate!
|
|
19
|
-
raise ArgumentError.new, "Must supply a sort string" if
|
|
19
|
+
raise ArgumentError.new, "Must supply a sort string" if sort.nil?
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -26,7 +26,7 @@ class Blacklight::Configuration
|
|
|
26
26
|
# @return [Class] component class used to render the search bar
|
|
27
27
|
# @!attribute search_header_component
|
|
28
28
|
# @return [Class] component class used to render the header above the documents
|
|
29
|
-
def display_label(**
|
|
29
|
+
def display_label(**)
|
|
30
30
|
I18n.t(
|
|
31
31
|
:"blacklight.search.view_title.#{key}",
|
|
32
32
|
default: [
|
|
@@ -35,7 +35,7 @@ class Blacklight::Configuration
|
|
|
35
35
|
title,
|
|
36
36
|
key.to_s.humanize
|
|
37
37
|
],
|
|
38
|
-
**
|
|
38
|
+
**
|
|
39
39
|
)
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -585,7 +585,7 @@ module Blacklight
|
|
|
585
585
|
|
|
586
586
|
##
|
|
587
587
|
# Add a section of config that only applies to documents with a matching display type
|
|
588
|
-
def for_display_type
|
|
588
|
+
def for_display_type(display_type, &)
|
|
589
589
|
fields_for_type[display_type] ||= self.class.new
|
|
590
590
|
|
|
591
591
|
fields_for_type[display_type].tap do |conf|
|
|
@@ -53,19 +53,19 @@ 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,
|
|
60
|
+
def try(method_name = nil, *, &)
|
|
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
|
|
67
67
|
elsif respond_to?(method_name)
|
|
68
|
-
public_send(method_name,
|
|
68
|
+
public_send(method_name, *, &)
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
end
|
|
@@ -79,7 +79,7 @@ module Blacklight
|
|
|
79
79
|
# Facebook's crawler turns array query parameters into a hash with numeric keys. Once we know
|
|
80
80
|
# the expected parameter structure, we can unmangle those parameters to match our expected values.
|
|
81
81
|
def deep_unmangle_params!(params, permitted_params)
|
|
82
|
-
permitted_params.
|
|
82
|
+
permitted_params.grep(Hash).each do |permission|
|
|
83
83
|
permission.each do |key, permitted_value|
|
|
84
84
|
next unless params[key].is_a?(ActionController::Parameters)
|
|
85
85
|
|
|
@@ -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
|
|
@@ -120,8 +120,8 @@ module Blacklight
|
|
|
120
120
|
delegate :any?, to: :values
|
|
121
121
|
|
|
122
122
|
# Appease rubocop rules by implementing #each_value
|
|
123
|
-
def each_value(except: [], &
|
|
124
|
-
values(except: except).each(&
|
|
123
|
+
def each_value(except: [], &)
|
|
124
|
+
values(except: except).each(&)
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
# @param [String,#value] item a filter to remove from the url
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
class Blacklight::Solr::InvalidParameter < ArgumentError; end
|
|
4
4
|
|
|
5
|
-
class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess
|
|
5
|
+
class Blacklight::Solr::Request < ActiveSupport::HashWithIndifferentAccess # rubocop:disable Style/OneClassPerFile
|
|
6
6
|
# @deprecated
|
|
7
7
|
SINGULAR_KEYS = %w(facet fl q qt rows start spellcheck spellcheck.q sort per_page wt hl group defType)
|
|
8
8
|
|
|
@@ -229,7 +229,7 @@ module Blacklight::Solr::Response::Facets
|
|
|
229
229
|
|
|
230
230
|
blacklight_config.facet_fields.select { |_k, v| v.query }.each_with_object({}) do |(field_name, facet_field), hash|
|
|
231
231
|
salient_facet_queries = facet_field.query.map { |_k, x| x[:fq] }
|
|
232
|
-
items = facet_queries.
|
|
232
|
+
items = facet_queries.slice(*salient_facet_queries).reject { |_value, hits| hits.zero? }.map do |value, hits|
|
|
233
233
|
salient_fields = facet_field.query.select { |_key, val| val[:fq] == value }
|
|
234
234
|
key = ((salient_fields.keys if salient_fields.respond_to? :keys) || salient_fields.first).first
|
|
235
235
|
Blacklight::Solr::Response::Facets::FacetItem.new(value: key, hits: hits, label: facet_field.query[key][:label])
|
|
@@ -250,7 +250,7 @@ module Blacklight::Solr::Response::Facets
|
|
|
250
250
|
|
|
251
251
|
salient_facet_queries = facet_field.query.map { |_k, x| x[:fq] }
|
|
252
252
|
|
|
253
|
-
relevant_facet_data = self['facets'].
|
|
253
|
+
relevant_facet_data = self['facets'].slice(*salient_facet_queries).reject { |_key, data| data['count'].zero? }
|
|
254
254
|
|
|
255
255
|
relevant_facet_data.map do |key, data|
|
|
256
256
|
salient_fields = facet_field.query.select { |_key, val| val[:fq] == key }
|
|
@@ -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
|
|
@@ -64,8 +64,10 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
|
|
64
64
|
case value
|
|
65
65
|
when Hash
|
|
66
66
|
value.each { |k, v| value[k] = force_to_utf8(v) }
|
|
67
|
+
value
|
|
67
68
|
when Array
|
|
68
69
|
value.each { |v| force_to_utf8(v) }
|
|
70
|
+
value
|
|
69
71
|
when String
|
|
70
72
|
if value.encoding == Encoding::UTF_8
|
|
71
73
|
value
|
|
@@ -73,7 +75,8 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
|
|
73
75
|
Blacklight.logger&.warn "Found a non utf-8 value in Blacklight::Solr::Response. \"#{value}\" Encoding is #{value.encoding}"
|
|
74
76
|
value.dup.force_encoding('UTF-8')
|
|
75
77
|
end
|
|
78
|
+
else
|
|
79
|
+
value
|
|
76
80
|
end
|
|
77
|
-
value
|
|
78
81
|
end
|
|
79
82
|
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,22 +5,39 @@ 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
8
|
def add_javascript_dependencies
|
|
10
9
|
gem 'bootstrap', options[:'bootstrap-version'].presence # in rails 7, only for stylesheets
|
|
11
10
|
gem 'jquery-rails' if bootstrap_4? # Bootstrap 4 has a dependency on jquery
|
|
12
11
|
end
|
|
13
12
|
|
|
13
|
+
def create_sprockets_manifest_if_needed
|
|
14
|
+
# BL8 still optionally supports Sprockets for CSS, but Rails 8+
|
|
15
|
+
# no longer creates the manifest.js file that Sprockets requires.
|
|
16
|
+
# We don't need to if we already have one, or if we're using
|
|
17
|
+
# cssbundling (which would create an application.bootstrap.scss file)
|
|
18
|
+
# via a `rails new` invocation with `--css bootstrap`.
|
|
19
|
+
return if File.exist?('app/assets/config/manifest.js')
|
|
20
|
+
return if File.exist?('app/assets/stylesheets/application.bootstrap.scss')
|
|
21
|
+
|
|
22
|
+
create_file 'app/assets/config/manifest.js' do
|
|
23
|
+
<<~CONTENT
|
|
24
|
+
//= link_tree ../images
|
|
25
|
+
//= link_directory ../stylesheets .css
|
|
26
|
+
//= link_tree ../../javascript .js
|
|
27
|
+
CONTENT
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
14
31
|
def import_javascript_assets
|
|
15
32
|
append_to_file 'config/importmap.rb' do
|
|
16
33
|
<<~CONTENT
|
|
17
|
-
pin "@github/auto-complete-element", to: "https://cdn.
|
|
34
|
+
pin "@github/auto-complete-element", to: "https://cdn.jsdelivr.net/npm/@github/auto-complete-element@3.8.0/+esm"
|
|
18
35
|
pin "@popperjs/core", to: "https://ga.jspm.io/npm:@popperjs/core@2.11.6/dist/umd/popper.min.js"
|
|
19
36
|
pin "bootstrap", to: "https://ga.jspm.io/npm:bootstrap@#{(defined?(Bootstrap) && Bootstrap::VERSION) || '5.3.2'}/dist/js/bootstrap.js"
|
|
20
37
|
CONTENT
|
|
21
38
|
end
|
|
22
39
|
|
|
23
|
-
return unless
|
|
40
|
+
return unless File.exist?('app/assets/config/manifest.js')
|
|
24
41
|
|
|
25
42
|
append_to_file 'app/assets/config/manifest.js' do
|
|
26
43
|
<<~CONTENT
|
|
@@ -59,6 +76,8 @@ module Blacklight
|
|
|
59
76
|
CONTENT
|
|
60
77
|
end
|
|
61
78
|
else
|
|
79
|
+
# NOTE: sassc-rails pulls in sprockets-rails, which requires that a
|
|
80
|
+
# manifest.js file exists.
|
|
62
81
|
gem "sassc-rails", "~> 2.1"
|
|
63
82
|
|
|
64
83
|
create_file 'app/assets/stylesheets/blacklight.scss' do
|
|
@@ -67,6 +86,12 @@ module Blacklight
|
|
|
67
86
|
@import 'blacklight/blacklight';
|
|
68
87
|
CONTENT
|
|
69
88
|
end
|
|
89
|
+
|
|
90
|
+
# application.css in a Rails 8 app has no Sprockets require
|
|
91
|
+
# directives, so blacklight.scss won't be included unless we add one.
|
|
92
|
+
inject_into_file 'app/assets/stylesheets/application.css',
|
|
93
|
+
"\n *= require blacklight",
|
|
94
|
+
before: "\n */"
|
|
70
95
|
end
|
|
71
96
|
end
|
|
72
97
|
|