blacklight 8.0.0.beta1 → 8.0.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.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/.env +1 -0
  3. data/.github/workflows/ruby.yml +6 -0
  4. data/.gitignore +1 -0
  5. data/.rubocop_todo.yml +3 -1
  6. data/README.md +1 -1
  7. data/Rakefile +18 -0
  8. data/VERSION +1 -1
  9. data/app/assets/config/blacklight/manifest.js +3 -0
  10. data/app/assets/javascripts/blacklight/blacklight.esm.js +132 -140
  11. data/app/assets/javascripts/blacklight/blacklight.esm.js.map +1 -1
  12. data/app/assets/javascripts/blacklight/blacklight.js +132 -140
  13. data/app/assets/javascripts/blacklight/blacklight.js.map +1 -1
  14. data/app/assets/stylesheets/blacklight/_bootstrap_overrides.scss +1 -1
  15. data/app/assets/stylesheets/blacklight/_facets.scss +32 -5
  16. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +1 -1
  17. data/app/components/blacklight/advanced_search_form_component.rb +3 -3
  18. data/app/components/blacklight/document/actions_component.rb +1 -1
  19. data/app/components/blacklight/document/show_tools_component.html.erb +12 -0
  20. data/app/components/blacklight/document/show_tools_component.rb +23 -0
  21. data/app/components/blacklight/document_component.rb +48 -20
  22. data/app/components/blacklight/document_metadata_component.html.erb +4 -2
  23. data/app/components/blacklight/document_metadata_component.rb +8 -2
  24. data/app/components/blacklight/facet_field_checkboxes_component.html.erb +2 -2
  25. data/app/components/blacklight/facet_field_list_component.html.erb +2 -2
  26. data/app/components/blacklight/metadata_field_component.html.erb +2 -2
  27. data/app/components/blacklight/metadata_field_layout_component.rb +7 -4
  28. data/app/components/blacklight/metadata_field_plain_text_layout_component.rb +17 -0
  29. data/app/components/blacklight/response/facet_group_component.html.erb +2 -1
  30. data/app/components/blacklight/response/facet_group_component.rb +1 -1
  31. data/app/components/blacklight/response/sort_component.rb +1 -1
  32. data/app/components/blacklight/response/spellcheck_component.rb +1 -1
  33. data/app/components/blacklight/response/view_type_button_component.rb +1 -1
  34. data/app/components/blacklight/response/view_type_component.rb +2 -2
  35. data/app/components/blacklight/search/sidebar_component.html.erb +1 -1
  36. data/app/components/blacklight/search_context/server_applied_params_component.html.erb +4 -0
  37. data/app/components/blacklight/search_context/server_applied_params_component.rb +13 -0
  38. data/app/components/blacklight/search_context/server_item_pagination_component.rb +71 -0
  39. data/app/components/blacklight/system/dropdown_component.rb +3 -3
  40. data/app/components/blacklight/system/flash_message_component.rb +2 -2
  41. data/app/components/blacklight/system/modal_component.rb +1 -1
  42. data/app/components/blacklight/top_navbar_component.html.erb +1 -1
  43. data/app/components/blacklight/top_navbar_component.rb +4 -0
  44. data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
  45. data/app/controllers/concerns/blacklight/search_context.rb +46 -6
  46. data/app/helpers/blacklight/blacklight_helper_behavior.rb +0 -101
  47. data/app/helpers/blacklight/catalog_helper_behavior.rb +27 -54
  48. data/app/helpers/blacklight/component_helper_behavior.rb +0 -11
  49. data/app/helpers/blacklight/document_helper_behavior.rb +76 -0
  50. data/app/helpers/blacklight/layout_helper_behavior.rb +59 -0
  51. data/app/helpers/blacklight/render_partials_helper_behavior.rb +1 -0
  52. data/app/helpers/blacklight/url_helper_behavior.rb +11 -3
  53. data/app/javascript/blacklight/bookmark_toggle.js +8 -15
  54. data/app/javascript/blacklight/button_focus.js +10 -10
  55. data/app/javascript/blacklight/index.js +6 -5
  56. data/app/javascript/blacklight/modal.js +24 -24
  57. data/app/javascript/blacklight/search_context.js +51 -57
  58. data/app/models/concerns/blacklight/document.rb +11 -0
  59. data/app/models/record_mailer.rb +19 -15
  60. data/app/presenters/blacklight/document_presenter.rb +13 -11
  61. data/app/presenters/blacklight/index_presenter.rb +1 -1
  62. data/app/presenters/blacklight/rendering/abstract_step.rb +4 -0
  63. data/app/presenters/blacklight/rendering/join.rb +7 -1
  64. data/app/presenters/blacklight/rendering/link_to_facet.rb +1 -1
  65. data/app/presenters/blacklight/rendering/microdata.rb +1 -1
  66. data/app/services/blacklight/search_service.rb +2 -1
  67. data/app/views/catalog/_document.atom.builder +1 -1
  68. data/app/views/catalog/_document.html.erb +3 -8
  69. data/app/views/catalog/_document_list.html.erb +2 -1
  70. data/app/views/catalog/_facet_layout.html.erb +2 -2
  71. data/app/views/catalog/_show_main_content.html.erb +5 -11
  72. data/app/views/catalog/_show_tools.html.erb +1 -14
  73. data/app/views/catalog/facet.html.erb +3 -3
  74. data/app/views/catalog/index.html.erb +3 -0
  75. data/app/views/catalog/show.html.erb +1 -6
  76. data/app/views/layouts/blacklight/base.html.erb +4 -5
  77. data/app/views/record_mailer/email_record.text.erb +4 -3
  78. data/app/views/record_mailer/sms_record.text.erb +4 -4
  79. data/blacklight.gemspec +2 -2
  80. data/config/importmap.rb +1 -1
  81. data/config/locales/blacklight.ar.yml +209 -232
  82. data/config/locales/blacklight.ca.yml +0 -6
  83. data/config/locales/blacklight.de.yml +197 -215
  84. data/config/locales/blacklight.en.yml +2 -6
  85. data/config/locales/blacklight.es.yml +196 -215
  86. data/config/locales/blacklight.fr.yml +196 -219
  87. data/config/locales/blacklight.hu.yml +193 -212
  88. data/config/locales/blacklight.it.yml +197 -215
  89. data/config/locales/blacklight.nl.yml +193 -212
  90. data/config/locales/blacklight.pt-BR.yml +195 -215
  91. data/config/locales/blacklight.sq.yml +193 -212
  92. data/config/locales/blacklight.zh.yml +194 -213
  93. data/docker-compose.yml +1 -0
  94. data/lib/blacklight/configuration/session_tracking_config.rb +45 -0
  95. data/lib/blacklight/configuration/view_config.rb +0 -4
  96. data/lib/blacklight/configuration.rb +8 -4
  97. data/lib/blacklight/engine.rb +6 -7
  98. data/lib/blacklight/routes/searchable.rb +1 -0
  99. data/lib/generators/blacklight/assets/importmap_generator.rb +9 -8
  100. data/lib/generators/blacklight/assets/propshaft_generator.rb +11 -2
  101. data/lib/generators/blacklight/assets/sprockets_generator.rb +2 -0
  102. data/lib/generators/blacklight/assets_generator.rb +3 -1
  103. data/lib/generators/blacklight/install_generator.rb +3 -1
  104. data/lib/generators/blacklight/templates/solr_document.rb +0 -6
  105. data/package.json +7 -4
  106. data/rollup.config.js +11 -1
  107. data/spec/components/blacklight/document_component_spec.rb +66 -15
  108. data/spec/components/blacklight/header_component_spec.rb +20 -0
  109. data/spec/components/blacklight/response/view_type_component_spec.rb +17 -0
  110. data/spec/components/blacklight/search_bar_component_spec.rb +1 -1
  111. data/spec/components/blacklight/search_context/server_applied_params_component_spec.rb +29 -0
  112. data/spec/components/blacklight/{search_context_component_spec.rb → search_context/server_item_pagination_component_spec.rb} +15 -4
  113. data/spec/controllers/bookmarks_controller_spec.rb +1 -1
  114. data/spec/controllers/catalog_controller_spec.rb +18 -6
  115. data/spec/features/component_template_override_spec.rb +8 -0
  116. data/spec/features/modal_spec.rb +12 -0
  117. data/spec/features/sitelinks_search_box_spec.rb +13 -0
  118. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +1 -1
  119. data/spec/helpers/blacklight_helper_spec.rb +0 -56
  120. data/spec/helpers/catalog_helper_spec.rb +56 -0
  121. data/spec/lib/blacklight/configuration/session_tracking_config_spec.rb +38 -0
  122. data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +2 -2
  123. data/spec/models/blacklight/configuration_spec.rb +2 -2
  124. data/spec/models/blacklight/icon_spec.rb +0 -2
  125. data/spec/models/blacklight/search_builder_spec.rb +3 -3
  126. data/spec/models/blacklight/solr/request_spec.rb +2 -2
  127. data/spec/models/record_mailer_spec.rb +36 -23
  128. data/spec/presenters/blacklight/document_presenter_spec.rb +1 -0
  129. data/spec/presenters/blacklight/field_presenter_spec.rb +2 -2
  130. data/spec/presenters/blacklight/index_presenter_spec.rb +1 -0
  131. data/spec/presenters/blacklight/show_presenter_spec.rb +1 -0
  132. data/spec/presenters/pipeline_spec.rb +13 -2
  133. data/spec/routing/catalog_routing_spec.rb +4 -0
  134. data/spec/spec_helper.rb +1 -1
  135. data/spec/support/view_component_test_helpers.rb +21 -0
  136. data/spec/test_app_templates/Gemfile.extra +4 -0
  137. data/spec/test_app_templates/lib/generators/test_app_generator.rb +8 -0
  138. data/spec/views/catalog/_document.html.erb_spec.rb +22 -1
  139. data/spec/views/catalog/_document_list.html.erb_spec.rb +7 -2
  140. data/spec/views/catalog/_show_tools.html.erb_spec.rb +2 -2
  141. data/spec/views/catalog/index.json.jbuilder_spec.rb +1 -1
  142. data/tasks/blacklight.rake +1 -1
  143. metadata +39 -21
  144. data/app/components/blacklight/search_context_component.rb +0 -68
  145. data/app/models/concerns/blacklight/document/email.rb +0 -27
  146. data/app/models/concerns/blacklight/document/sms.rb +0 -25
  147. data/spec/features/sitelinks_search_box.rb +0 -13
  148. data/spec/models/blacklight/document/email_spec.rb +0 -57
  149. data/spec/models/blacklight/document/sms_spec.rb +0 -58
  150. data/spec/support/view_component_capybara_test_helpers.rb +0 -8
  151. /data/app/components/blacklight/{search_context_component.html.erb → search_context/server_item_pagination_component.html.erb} +0 -0
@@ -1,59 +1,53 @@
1
- import Blacklight from './core'
2
-
3
- const SearchContext = (() => {
4
- Blacklight.doSearchContextBehavior = function() {
5
- document.addEventListener('click', (e) => {
6
- if (e.target.matches('[data-context-href]')) {
7
- Blacklight.handleSearchContextMethod.call(e.target, e)
8
- }
9
- })
10
- };
11
-
12
- Blacklight.csrfToken = () => document.querySelector('meta[name=csrf-token]')?.content
13
- Blacklight.csrfParam = () => document.querySelector('meta[name=csrf-param]')?.content
14
-
15
- // this is the Rails.handleMethod with a couple adjustments, described inline:
16
- // first, we're attaching this directly to the event handler, so we can check for meta-keys
17
- Blacklight.handleSearchContextMethod = function(event) {
18
- const link = this
19
-
20
- // instead of using the normal href, we need to use the context href instead
21
- let href = link.getAttribute('data-context-href')
22
- let target = link.getAttribute('target')
23
- let csrfToken = Blacklight.csrfToken()
24
- let csrfParam = Blacklight.csrfParam()
25
- let form = document.createElement('form')
26
- form.method = 'post'
27
- form.action = href
28
-
29
-
30
- let formContent = `<input name="_method" value="post" type="hidden" />
31
- <input name="redirect" value="${link.getAttribute('href')}" type="hidden" />`
32
-
33
- // check for meta keys.. if set, we should open in a new tab
34
- if(event.metaKey || event.ctrlKey) {
35
- target = '_blank';
36
- }
37
-
38
- if (csrfParam !== undefined && csrfToken !== undefined) {
39
- formContent += `<input name="${csrfParam}" value="${csrfToken}" type="hidden" />`
40
- }
41
-
42
- // Must trigger submit by click on a button, else "submit" event handler won't work!
43
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit
44
- formContent += '<input type="submit" />'
45
-
46
- if (target) { form.setAttribute('target', target); }
47
-
48
- form.style.display = 'none'
49
- form.innerHTML = formContent
50
- document.body.appendChild(form)
51
- form.querySelector('[type="submit"]').click()
52
-
53
- event.preventDefault()
54
- };
55
-
56
- Blacklight.doSearchContextBehavior();
57
- })()
1
+ const SearchContext = (e) => {
2
+ if (e.target.matches('[data-context-href]')) {
3
+ SearchContext.handleSearchContextMethod.call(e.target, e)
4
+ }
5
+ }
6
+
7
+ SearchContext.csrfToken = () => document.querySelector('meta[name=csrf-token]')?.content
8
+ SearchContext.csrfParam = () => document.querySelector('meta[name=csrf-param]')?.content
9
+
10
+ // this is the Rails.handleMethod with a couple adjustments, described inline:
11
+ // first, we're attaching this directly to the event handler, so we can check for meta-keys
12
+ SearchContext.handleSearchContextMethod = function(event) {
13
+ const link = this
14
+
15
+ // instead of using the normal href, we need to use the context href instead
16
+ let href = link.getAttribute('data-context-href')
17
+ let target = link.getAttribute('target')
18
+ let csrfToken = SearchContext.csrfToken()
19
+ let csrfParam = SearchContext.csrfParam()
20
+ let form = document.createElement('form')
21
+ form.method = 'post'
22
+ form.action = href
23
+
24
+
25
+ let formContent = `<input name="_method" value="post" type="hidden" />
26
+ <input name="redirect" value="${link.getAttribute('href')}" type="hidden" />`
27
+
28
+ // check for meta keys.. if set, we should open in a new tab
29
+ if(event.metaKey || event.ctrlKey) {
30
+ target = '_blank';
31
+ }
32
+
33
+ if (csrfParam !== undefined && csrfToken !== undefined) {
34
+ formContent += `<input name="${csrfParam}" value="${csrfToken}" type="hidden" />`
35
+ }
36
+
37
+ // Must trigger submit by click on a button, else "submit" event handler won't work!
38
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit
39
+ formContent += '<input type="submit" />'
40
+
41
+ if (target) { form.setAttribute('target', target); }
42
+
43
+ form.style.display = 'none'
44
+ form.innerHTML = formContent
45
+ document.body.appendChild(form)
46
+ form.querySelector('[type="submit"]').click()
47
+
48
+ event.preventDefault()
49
+ };
50
+
51
+ document.addEventListener('click', SearchContext)
58
52
 
59
53
  export default SearchContext
@@ -31,6 +31,17 @@ module Blacklight::Document
31
31
  class_attribute :inspector_fields, default: [:_source]
32
32
  end
33
33
 
34
+ Email = Module.new do
35
+ def self.included(mod)
36
+ Blacklight.deprecation.warn("Blacklight::Document::Email is deprecated and will be removed (included in #{mod}).")
37
+ end
38
+ end
39
+ Sms = Module.new do
40
+ def self.included(mod)
41
+ Blacklight.deprecation.warn("Blacklight::Document::Sms is deprecated and will be removed (included in #{mod}).")
42
+ end
43
+ end
44
+
34
45
  attr_reader :response, :_source
35
46
  alias_method :solr_response, :response
36
47
 
@@ -2,27 +2,21 @@
2
2
 
3
3
  # Only works for documents with a #to_marc right now.
4
4
  class RecordMailer < ApplicationMailer
5
- def email_record(documents, details, url_gen_params)
6
- title = begin
7
- title_field = details[:config].email.title_field
8
- if title_field
9
- [documents.first[title_field]].flatten.first
10
- else
11
- documents.first.to_semantic_values[:title]
12
- end
13
- rescue
14
- I18n.t('blacklight.email.text.default_title')
15
- end
16
-
17
- subject = I18n.t('blacklight.email.text.subject',
18
- count: documents.length,
19
- title: Array(title).first)
5
+ helper CatalogHelper
6
+ helper_method :blacklight_config, :blacklight_configuration_context
20
7
 
8
+ def email_record(documents, details, url_gen_params)
21
9
  @documents = documents
22
10
  @message = details[:message]
23
11
  @config = details[:config]
24
12
  @url_gen_params = url_gen_params
25
13
 
14
+ title = view_context.document_presenter(documents.first).html_title || I18n.t('blacklight.email.text.default_title')
15
+
16
+ subject = I18n.t('blacklight.email.text.subject',
17
+ count: documents.length,
18
+ title: Array(title).first)
19
+
26
20
  mail(to: details[:to], subject: subject)
27
21
  end
28
22
 
@@ -33,4 +27,14 @@ class RecordMailer < ApplicationMailer
33
27
 
34
28
  mail(to: details[:to], subject: "") # rubocop:disable Rails/I18nLocaleTexts
35
29
  end
30
+
31
+ def blacklight_config
32
+ @config || Blacklight.default_configuration
33
+ end
34
+
35
+ ##
36
+ # Context in which to evaluate blacklight configuration conditionals
37
+ def blacklight_configuration_context
38
+ @blacklight_configuration_context ||= Blacklight::Configuration::Context.new(self)
39
+ end
36
40
  end
@@ -11,18 +11,20 @@ module Blacklight
11
11
  # @param [SolrDocument] document
12
12
  # @param [ActionView::Base] view_context scope for linking and generating urls
13
13
  # @param [Blacklight::Configuration] configuration
14
- def initialize(document, view_context, configuration = view_context.blacklight_config)
14
+ def initialize(document, view_context, configuration = view_context.blacklight_config, view_config: nil, field_presenter_options: {})
15
15
  @document = document
16
16
  @view_context = view_context
17
17
  @configuration = configuration
18
+ @view_config = view_config
19
+ @field_presenter_options = field_presenter_options
18
20
  end
19
21
 
20
22
  # @return [Hash<String,Configuration::Field>] all the fields for this index view that should be rendered
21
- def fields_to_render
22
- return to_enum(:fields_to_render) unless block_given?
23
+ def fields_to_render(document_fields = fields, **kwargs)
24
+ return to_enum(:fields_to_render, document_fields, **kwargs) unless block_given?
23
25
 
24
- fields.each do |name, field_config|
25
- field_presenter = field_presenter(field_config)
26
+ document_fields.each do |name, field_config|
27
+ field_presenter = field_presenter(field_config, kwargs)
26
28
 
27
29
  next unless field_presenter.render_field? && field_presenter.any?
28
30
 
@@ -30,10 +32,10 @@ module Blacklight
30
32
  end
31
33
  end
32
34
 
33
- def field_presenters
34
- return to_enum(:field_presenters) unless block_given?
35
+ def field_presenters(document_fields = fields, **kwargs)
36
+ return to_enum(:field_presenters, document_fields, **kwargs) unless block_given?
35
37
 
36
- fields_to_render.each { |_, _, config| yield config }
38
+ fields_to_render(document_fields, **kwargs).each { |_, _, config| yield config }
37
39
  end
38
40
 
39
41
  ##
@@ -116,11 +118,11 @@ module Blacklight
116
118
  end
117
119
 
118
120
  def view_config
119
- show_view_config
121
+ @view_config ||= show_view_config
120
122
  end
121
123
 
122
124
  def show_view_config
123
- configuration.view_config(:show)
125
+ configuration.view_config(:show, action_name: view_context.action_name)
124
126
  end
125
127
 
126
128
  def inspect
@@ -150,7 +152,7 @@ module Blacklight
150
152
  end
151
153
 
152
154
  def field_presenter_options
153
- {}
155
+ @field_presenter_options ||= {}
154
156
  end
155
157
  end
156
158
  end
@@ -3,7 +3,7 @@
3
3
  module Blacklight
4
4
  class IndexPresenter < DocumentPresenter
5
5
  def view_config
6
- configuration.view_config(view_context.document_index_view_type)
6
+ @view_config ||= configuration.view_config(view_context.document_index_view_type, action_name: view_context.action_name)
7
7
  end
8
8
  end
9
9
  end
@@ -20,6 +20,10 @@ module Blacklight
20
20
  first, *rest = *stack
21
21
  first.new(output_values, config, document, context, options, rest).render
22
22
  end
23
+
24
+ def html?
25
+ options[:format].nil? || options[:format].to_s == 'html'
26
+ end
23
27
  end
24
28
  end
25
29
  end
@@ -5,7 +5,13 @@ module Blacklight
5
5
  class Join < AbstractStep
6
6
  def render
7
7
  options = config.separator_options || {}
8
- next_step(values.map { |x| x.html_safe? ? x : html_escape(x) }.to_sentence(options).html_safe)
8
+ if values.one? || values.none?
9
+ next_step(values.first)
10
+ elsif !html?
11
+ next_step(values.to_sentence(options))
12
+ else
13
+ next_step(values.map { |x| x.html_safe? ? x : html_escape(x) }.to_sentence(options).html_safe)
14
+ end
9
15
  end
10
16
 
11
17
  private
@@ -4,7 +4,7 @@ module Blacklight
4
4
  module Rendering
5
5
  class LinkToFacet < AbstractStep
6
6
  def render
7
- return next_step(values) unless config.link_to_facet
7
+ return next_step(values) unless config.link_to_facet && html?
8
8
 
9
9
  next_step(render_link)
10
10
  end
@@ -5,7 +5,7 @@ module Blacklight
5
5
  class Microdata < AbstractStep
6
6
  include ActionView::Helpers::TagHelper
7
7
  def render
8
- return next_step(values) unless config.itemprop
8
+ return next_step(values) unless config.itemprop && html?
9
9
 
10
10
  next_step(values.map { |x| itemprop(x, config.itemprop) })
11
11
  end
@@ -44,7 +44,8 @@ module Blacklight
44
44
 
45
45
  # retrieve a document, given the doc id
46
46
  # @param [Array{#to_s},#to_s] id
47
- # @return [Blacklight::SolrDocument] the solr response object and the first document
47
+ # @return [Blacklight::SolrDocument] the solr document (or array of
48
+ # documents if an array of ids was given)
48
49
  def fetch(id = nil, extra_controller_params = {})
49
50
  if id.is_a? Array
50
51
  fetch_many(id, extra_controller_params)
@@ -21,7 +21,7 @@ xml.entry do
21
21
  with_format(:html) do
22
22
  xml.summary "type" => "html" do
23
23
  document_component = blacklight_config.view_config(:atom).summary_component
24
- xml.text! render document_component.new(presenter: document_presenter(document), component: :div, show: true)
24
+ xml.text! render document_component.new(document_component.collection_parameter => document_presenter(document), component: :div, show: true)
25
25
  end
26
26
  end
27
27
 
@@ -1,9 +1,4 @@
1
1
  <% # container for a single doc -%>
2
- <% view_config = local_assigns[:view_config] || blacklight_config.view_config(document_index_view_type) %>
3
- <%= render view_config.document_component.new(presenter: document_presenter(document), counter: document_counter_with_offset(document_counter)) do |component| %>
4
- <% view_config.partials.each do |partial| %>
5
- <% component.partial do %>
6
- <%= render_document_partial document, partial, component: component, document_counter: document_counter %>
7
- <% end %>
8
- <% end %>
9
- <% end %>
2
+ <% view_config = local_assigns[:view_config] || blacklight_config.view_config(document_index_view_type, action_name: action_name) %>
3
+ <% document_component = view_config.document_component -%>
4
+ <%= render document_component.new(document_component.collection_parameter => document_presenter(document), counter: document_counter_with_offset(document_counter), partials: view_config&.partials) %>
@@ -1,5 +1,6 @@
1
1
  <% # container for all documents in index list view -%>
2
2
  <% view_config = local_assigns[:view_config] || blacklight_config&.view_config(document_index_view_type) %>
3
3
  <div id="documents" class="documents-<%= view_config&.key || document_index_view_type %>">
4
- <%= render documents, as: :document, view_config: view_config %>
4
+ <% document_presenters = documents.map { |doc| document_presenter(doc) } -%>
5
+ <%= render view_config.document_component.with_collection(document_presenters, partials: view_config.partials, counter_offset: @response&.start || 0) %>
5
6
  </div>
@@ -1,8 +1,8 @@
1
1
  <%= render(Blacklight::FacetFieldComponent.new(facet_field: facet_field_presenter(facet_field, nil))) do |component| %>
2
- <% component.label do %>
2
+ <% component.with_label do %>
3
3
  <%= facet_field_label(facet_field.key) %>
4
4
  <% end %>
5
- <% component.body do %>
5
+ <% component.with_body do %>
6
6
  <%= yield %>
7
7
  <% end %>
8
8
  <% end %>
@@ -1,20 +1,14 @@
1
- <%= render(Blacklight::SearchContextComponent.new(search_context: @search_context, search_session: search_session)) if search_session['document_id'] == @document.id %>
2
-
1
+ <%= render blacklight_config.track_search_session.item_pagination_component.new(search_context: @search_context, search_session: search_session, current_document: @document) if blacklight_config.track_search_session.item_pagination_component %>
3
2
  <% @page_title = t('blacklight.search.show.title', document_title: document_presenter(@document).html_title, application_name: application_name).html_safe %>
4
3
  <% content_for(:head) { render_link_rel_alternates } %>
5
4
 
6
- <%= render (blacklight_config.view_config(:show).document_component).new(presenter: document_presenter(@document), component: :div, show: true) do |component| %>
7
- <% component.title(as: 'h1', classes: '', link_to_document: false, actions: false) %>
8
- <% component.footer do %>
5
+ <% document_component = blacklight_config.view_config(:show).document_component -%>
6
+ <%= render (document_component).new(document_component.collection_parameter => document_presenter(@document), component: :div, show: true, partials: blacklight_config.view_config(:show).partials) do |component| %>
7
+ <% component.with_title(as: 'h1', classes: '', link_to_document: false, actions: false) %>
8
+ <% component.with_footer do %>
9
9
  <% if @document.respond_to?(:export_as_openurl_ctx_kev) %>
10
10
  <!-- COinS, for Zotero among others. -->
11
11
  <span class="Z3988" title="<%= @document.export_as_openurl_ctx_kev(document_presenter(@document).display_type) %>"></span>
12
12
  <% end %>
13
13
  <% end %>
14
-
15
- <% blacklight_config.view_config(:show).partials.each do |partial| %>
16
- <% component.partial do %>
17
- <%= render_document_partial @document, partial, component: component %>
18
- <% end %>
19
- <% end %>
20
14
  <% end %>
@@ -1,14 +1 @@
1
- <% if show_doc_actions? %>
2
- <div class="card show-tools">
3
- <div class="card-header">
4
- <h2 class="mb-0 h6"><%= t('blacklight.tools.title') %></h2>
5
- </div>
6
- <%= render Blacklight::Document::ActionsComponent.new(document: document,
7
- tag: 'ul',
8
- classes: 'list-group list-group-flush',
9
- wrapping_tag: 'li',
10
- wrapping_classes: 'list-group-item list-group-item-action',
11
- actions: document_actions(document),
12
- url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h)) %>
13
- </div>
14
- <% end %>
1
+ <%= render Blacklight::Document::ShowToolsComponent.new(document: document) %>
@@ -1,11 +1,11 @@
1
1
  <%= render Blacklight::System::ModalComponent.new do |component| %>
2
- <% component.prefix do %>
2
+ <% component.with_prefix do %>
3
3
  <div class="facet-pagination top row justify-content-between">
4
4
  <%= render :partial=>'facet_pagination' %>
5
5
  </div>
6
6
  <% end %>
7
7
 
8
- <% component.title { facet_field_label(@facet.key) } %>
8
+ <% component.with_title { facet_field_label(@facet.key) } %>
9
9
 
10
10
  <%= render partial: 'facet_index_navigation' if @facet.index_range && @display_facet.index? %>
11
11
 
@@ -15,7 +15,7 @@
15
15
  layout: false) %>
16
16
  </div>
17
17
 
18
- <% component.footer do %>
18
+ <% component.with_footer do %>
19
19
  <div class="facet-pagination bottom flex-row justify-content-between">
20
20
  <%= render :partial=>'facet_pagination' %>
21
21
  </div>
@@ -1,3 +1,6 @@
1
+ <% content_for(:head) do %>
2
+ <meta name="blacklight-search-storage" content="<%= blacklight_config.track_search_session.storage %>">
3
+ <% end %>
1
4
  <% content_for(:sidebar) do %>
2
5
  <% conf = blacklight_config.view_config(document_index_view_type) %>
3
6
  <%= render conf.sidebar_component.new(blacklight_config: blacklight_config,
@@ -1,9 +1,4 @@
1
- <% if current_search_session %>
2
- <div id="appliedParams" class="clearfix constraints-container">
3
- <%= render 'start_over' %>
4
- <%= link_back_to_catalog class: 'btn btn-outline-secondary' %>
5
- </div>
6
- <% end %>
1
+ <%= render blacklight_config.track_search_session.applied_params_component.new if blacklight_config.track_search_session.applied_params_component %>
7
2
 
8
3
  <%= render 'show_main_content' %>
9
4
 
@@ -15,21 +15,20 @@
15
15
  <%= opensearch_description_tag application_name, opensearch_catalog_url(format: 'xml') %>
16
16
  <%= favicon_link_tag %>
17
17
  <%= stylesheet_link_tag "application", media: "all", "data-turbo-track": "reload" %>
18
- <%= stylesheet_link_tag "https://ga.jspm.io/npm:dialog-polyfill@0.5.6/dist/dialog-polyfill.css" %>
19
18
  <% if defined? Importmap %>
20
19
  <%= javascript_importmap_tags %>
21
20
  <% elsif defined? Propshaft %>
22
21
  <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
23
- <% else %>
22
+ <% else %>
24
23
  <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
25
24
  <%= javascript_include_tag "blacklight/blacklight", type: 'module' %>
25
+ <script type="module">
26
+ import githubAutoCompleteElement from 'https://cdn.skypack.dev/@github/auto-complete-element';
27
+ </script>
26
28
  <% end %>
27
29
 
28
30
  <%= csrf_meta_tags %>
29
31
  <%= content_for(:head) %>
30
- <script type="module">
31
- import githubAutoCompleteElement from 'https://cdn.skypack.dev/@github/auto-complete-element';
32
- </script>
33
32
  </head>
34
33
  <body class="<%= render_body_class %>">
35
34
  <nav id="skip-link" role="navigation" aria-label="<%= t('blacklight.skip_links.label') %>">
@@ -1,6 +1,7 @@
1
+ <%= t('blacklight.email.text.message', message: @message) %>
2
+
1
3
  <% @documents.each do |document| %>
2
- <%= document.to_email_text %>
3
- <%= t('blacklight.email.text.url', :url =>polymorphic_url(document, @url_gen_params)) %>
4
+ <%= render Blacklight::DocumentMetadataComponent.new(fields: document_presenter(document).field_presenters(blacklight_config.email_fields), tag: nil, field_layout: Blacklight::MetadataFieldPlainTextLayoutComponent, field_presenter_options: { format: 'text' }) %>
4
5
 
6
+ <%= t('blacklight.email.text.url', url: polymorphic_url(document, @url_gen_params)) %>
5
7
  <% end %>
6
- <%= t('blacklight.email.text.message', :message => @message) %>
@@ -1,4 +1,4 @@
1
- <% @documents.each do |document| %>
2
- <%= document.to_sms_text(@config) %>
3
- <%= t('blacklight.sms.text.url', :url => polymorphic_url(document, @url_gen_params) ) %>
4
- <% end %>
1
+ <% @documents.each do |document| %>
2
+ <%= render Blacklight::DocumentMetadataComponent.new(fields: document_presenter(document).field_presenters(blacklight_config.sms_fields), tag: nil, field_layout: Blacklight::MetadataFieldPlainTextLayoutComponent, field_presenter_options: { format: 'text' }) %>
3
+ <%= t('blacklight.sms.text.url', url: polymorphic_url(document, @url_gen_params)) %>
4
+ <% end %>
data/blacklight.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  full text and/or metadata.)
18
18
  s.license = "Apache 2.0"
19
19
 
20
- s.files = `git ls-files -z`.split("\x0")
20
+ s.files = `git ls-files -z`.split("\x0") + Dir.glob("app/assets/javascripts/blacklight/**/*")
21
21
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
22
22
  s.bindir = 'exe'
23
23
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
32
32
  s.add_dependency "i18n", '>= 1.7.0' # added named parameters
33
33
  s.add_dependency "ostruct", '>= 0.3.2'
34
- s.add_dependency "view_component", '~> 2.66'
34
+ s.add_dependency "view_component", '>= 2.66', '< 3.1'
35
35
 
36
36
  s.add_development_dependency "rsolr", ">= 1.0.6", "< 3" # Library for interacting with rSolr.
37
37
  s.add_development_dependency "rspec-rails", "~> 6.0"
data/config/importmap.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- pin_all_from File.expand_path("../app/javascript/blacklight", __dir__)
3
+ pin_all_from File.expand_path("../app/javascript/blacklight", __dir__), under: "blacklight"