blacklight 7.11.1 → 7.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/.solr_wrapper.yml +5 -0
  4. data/VERSION +1 -1
  5. data/app/builders/blacklight/action_builder.rb +6 -0
  6. data/app/components/blacklight/constraint_component.html.erb +5 -0
  7. data/app/components/blacklight/constraint_component.rb +13 -0
  8. data/app/components/blacklight/constraint_layout_component.rb +2 -1
  9. data/app/components/blacklight/constraints_component.html.erb +10 -0
  10. data/app/components/blacklight/constraints_component.rb +65 -0
  11. data/app/components/blacklight/document/action_component.html.erb +9 -0
  12. data/app/components/blacklight/document/action_component.rb +38 -0
  13. data/app/components/blacklight/document/actions_component.html.erb +13 -0
  14. data/app/components/blacklight/document/actions_component.rb +26 -0
  15. data/app/components/blacklight/document/bookmark_component.html.erb +1 -1
  16. data/app/components/blacklight/document/bookmark_component.rb +8 -0
  17. data/app/components/blacklight/document/citation_component.html.erb +4 -2
  18. data/app/components/blacklight/document/citation_component.rb +8 -1
  19. data/app/components/blacklight/document/group_component.html.erb +9 -0
  20. data/app/components/blacklight/document/group_component.rb +26 -0
  21. data/app/components/blacklight/document/more_like_this_component.rb +2 -0
  22. data/app/components/blacklight/document/thumbnail_component.html.erb +12 -0
  23. data/app/components/blacklight/document/thumbnail_component.rb +25 -0
  24. data/app/components/blacklight/document_component.rb +27 -26
  25. data/app/components/blacklight/facet_field_filter_component.html.erb +12 -0
  26. data/app/components/blacklight/facet_field_filter_component.rb +25 -0
  27. data/app/components/blacklight/facet_field_pagination_component.html.erb +19 -0
  28. data/app/components/blacklight/facet_field_pagination_component.rb +21 -0
  29. data/app/components/blacklight/facet_item_component.rb +4 -8
  30. data/app/components/blacklight/response/facet_group_component.html.erb +3 -1
  31. data/app/components/blacklight/response/facet_group_component.rb +8 -1
  32. data/app/components/blacklight/response/pagination_component.rb +3 -0
  33. data/app/components/blacklight/response/sort_component.html.erb +1 -1
  34. data/app/components/blacklight/response/spellcheck_component.rb +9 -2
  35. data/app/components/blacklight/response/view_type_component.html.erb +11 -0
  36. data/app/components/blacklight/response/view_type_component.rb +36 -0
  37. data/app/components/blacklight/search_bar_component.html.erb +1 -1
  38. data/app/components/blacklight/search_bar_component.rb +6 -0
  39. data/app/components/blacklight/search_context_component.rb +6 -2
  40. data/app/components/blacklight/system/dropdown_component.html.erb +1 -1
  41. data/app/components/blacklight/system/flash_message_component.html.erb +4 -0
  42. data/app/components/blacklight/system/flash_message_component.rb +24 -0
  43. data/app/controllers/concerns/blacklight/catalog.rb +7 -1
  44. data/app/controllers/concerns/blacklight/controller.rb +12 -3
  45. data/app/controllers/concerns/blacklight/facet.rb +19 -5
  46. data/app/controllers/concerns/blacklight/search_fields.rb +7 -1
  47. data/app/helpers/blacklight/blacklight_helper_behavior.rb +127 -17
  48. data/app/helpers/blacklight/catalog_helper_behavior.rb +36 -5
  49. data/app/helpers/blacklight/component_helper_behavior.rb +36 -6
  50. data/app/helpers/blacklight/configuration_helper_behavior.rb +32 -4
  51. data/app/helpers/blacklight/facets_helper_behavior.rb +31 -8
  52. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +5 -0
  53. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +28 -11
  54. data/app/helpers/blacklight/render_partials_helper_behavior.rb +8 -3
  55. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +4 -2
  56. data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
  57. data/app/helpers/blacklight/url_helper_behavior.rb +23 -3
  58. data/app/models/blacklight/icon.rb +0 -1
  59. data/app/models/concerns/blacklight/document.rb +1 -1
  60. data/app/models/concerns/blacklight/suggest/response.rb +1 -1
  61. data/app/models/record_mailer.rb +1 -1
  62. data/app/presenters/blacklight/document_presenter.rb +42 -1
  63. data/app/presenters/blacklight/facet_field_presenter.rb +3 -1
  64. data/app/presenters/blacklight/facet_item_presenter.rb +8 -0
  65. data/app/presenters/blacklight/field_presenter.rb +9 -6
  66. data/app/presenters/blacklight/json_presenter.rb +3 -1
  67. data/app/presenters/blacklight/show_presenter.rb +4 -30
  68. data/app/presenters/blacklight/thumbnail_presenter.rb +5 -1
  69. data/app/services/blacklight/document_factory.rb +3 -0
  70. data/app/services/blacklight/field_retriever.rb +18 -4
  71. data/app/services/blacklight/search_service.rb +0 -1
  72. data/app/views/bookmarks/_tools.html.erb +12 -7
  73. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  74. data/app/views/catalog/_constraints.html.erb +12 -7
  75. data/app/views/catalog/_document.atom.builder +9 -6
  76. data/app/views/catalog/_document.rss.builder +4 -2
  77. data/app/views/catalog/_facet_index_navigation.html.erb +1 -10
  78. data/app/views/catalog/_facet_pagination.html.erb +1 -19
  79. data/app/views/catalog/_facets.html.erb +1 -1
  80. data/app/views/catalog/_group.html.erb +1 -9
  81. data/app/views/catalog/_index.html.erb +1 -1
  82. data/app/views/catalog/_search_results.html.erb +1 -1
  83. data/app/views/catalog/_show.html.erb +1 -1
  84. data/app/views/catalog/_show_header.html.erb +1 -1
  85. data/app/views/catalog/_show_main_content.html.erb +2 -2
  86. data/app/views/catalog/_show_tools.html.erb +12 -8
  87. data/app/views/catalog/_start_over.html.erb +1 -1
  88. data/app/views/catalog/_thumbnail.html.erb +1 -5
  89. data/app/views/catalog/_view_type_group.html.erb +5 -13
  90. data/app/views/catalog/index.json.jbuilder +8 -6
  91. data/app/views/catalog/show.json.jbuilder +1 -1
  92. data/app/views/shared/_flash_msg.html.erb +1 -15
  93. data/blacklight.gemspec +1 -0
  94. data/config/locales/blacklight.ca.yml +241 -0
  95. data/lib/blacklight/abstract_repository.rb +13 -4
  96. data/lib/blacklight/configuration.rb +11 -5
  97. data/lib/blacklight/configuration/display_field.rb +50 -0
  98. data/lib/blacklight/configuration/facet_field.rb +58 -1
  99. data/lib/blacklight/configuration/field.rb +13 -0
  100. data/lib/blacklight/configuration/index_field.rb +5 -0
  101. data/lib/blacklight/configuration/search_field.rb +3 -0
  102. data/lib/blacklight/configuration/show_field.rb +5 -0
  103. data/lib/blacklight/configuration/sort_field.rb +3 -0
  104. data/lib/blacklight/configuration/tool_config.rb +1 -0
  105. data/lib/blacklight/configuration/view_config.rb +25 -0
  106. data/lib/blacklight/search_state.rb +4 -2
  107. data/lib/blacklight/solr/repository.rb +1 -1
  108. data/lib/generators/blacklight/templates/catalog_controller.rb +8 -7
  109. data/spec/components/blacklight/document/action_component_spec.rb +43 -0
  110. data/spec/components/blacklight/document/group_component_spec.rb +45 -0
  111. data/spec/components/blacklight/document_component_spec.rb +8 -0
  112. data/spec/components/blacklight/facet_item_pivot_component_spec.rb +0 -1
  113. data/spec/components/blacklight/system/flash_message_component_spec.rb +54 -0
  114. data/spec/controllers/blacklight/search_fields_spec.rb +2 -0
  115. data/spec/controllers/catalog_controller_spec.rb +2 -0
  116. data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +6 -1
  117. data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +2 -0
  118. data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +2 -0
  119. data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +3 -1
  120. data/spec/helpers/blacklight/url_helper_behavior_spec.rb +2 -0
  121. data/spec/helpers/blacklight_helper_spec.rb +10 -0
  122. data/spec/helpers/catalog_helper_spec.rb +4 -4
  123. data/spec/lib/blacklight/configuration/facet_field_spec.rb +17 -0
  124. data/spec/models/blacklight/search_builder_spec.rb +1 -1
  125. data/spec/models/blacklight/solr/search_builder_spec.rb +8 -0
  126. data/spec/presenters/blacklight/field_presenter_spec.rb +30 -5
  127. data/spec/services/blacklight/search_service_spec.rb +1 -5
  128. data/spec/views/catalog/_constraints.html.erb_spec.rb +2 -1
  129. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -2
  130. data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
  131. data/spec/views/catalog/show.json.jbuilder_spec.rb +1 -0
  132. data/tasks/blacklight.rake +27 -12
  133. metadata +47 -2
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Blacklight::RenderPartialsHelperBehavior
3
+ extend Deprecation
4
+
3
5
  ##
4
6
  # Render the document index view
5
7
  #
@@ -16,6 +18,7 @@ module Blacklight::RenderPartialsHelperBehavior
16
18
  def render_grouped_document_index
17
19
  render 'catalog/group'
18
20
  end
21
+ deprecation_deprecate render_grouped_document_index: 'Removed without replacement'
19
22
 
20
23
  ##
21
24
  # Return the list of partials for a given solr document
@@ -54,7 +57,7 @@ module Blacklight::RenderPartialsHelperBehavior
54
57
  # @param [String] base_name base name for the partial
55
58
  # @param [Hash] locals local variables to pass through to the partials
56
59
  def render_document_partial(doc, base_name, locals = {})
57
- format = document_partial_name(doc, base_name)
60
+ format = Deprecation.silence(Blacklight::RenderPartialsHelperBehavior) { document_partial_name(doc, base_name) }
58
61
 
59
62
  view_type = document_index_view_type
60
63
  template = cached_view ['show', view_type, base_name, format].join('_') do
@@ -111,14 +114,16 @@ module Blacklight::RenderPartialsHelperBehavior
111
114
  ##
112
115
  # Return a normalized partial name for rendering a single document
113
116
  #
117
+ # @private
114
118
  # @param [SolrDocument] document
115
119
  # @param [Symbol] base_name base name for the partial
116
120
  # @return [String]
117
121
  def document_partial_name(document, base_name = nil)
118
- display_type = show_presenter(document).display_type(base_name, default: 'default')
122
+ display_type = document_presenter(document).display_type(base_name, default: 'default')
119
123
 
120
124
  type_field_to_partial_name(document, display_type)
121
125
  end
126
+ deprecation_deprecate document_partial_name: 'Moving to a private method'
122
127
 
123
128
  private
124
129
 
@@ -127,7 +132,7 @@ module Blacklight::RenderPartialsHelperBehavior
127
132
  # this method can be overridden in order to transform the value
128
133
  # (e.g. 'PdfBook' => 'pdf_book')
129
134
  #
130
- # @param [SolrDocument] document
135
+ # @param [SolrDocument] _document
131
136
  # @param [String, Array] display_type a value suggestive of a partial
132
137
  # @return [String] the name of the partial to render
133
138
  # @example
@@ -20,7 +20,7 @@ module Blacklight::SearchHistoryConstraintsHelperBehavior
20
20
  def render_search_to_s_q(params)
21
21
  return "".html_safe if params['q'].blank?
22
22
 
23
- label = label_for_search_field(params[:search_field]) unless default_search_field && params[:search_field] == default_search_field[:key]
23
+ label = label_for_search_field(params[:search_field]) unless default_search_field?(params[:search_field])
24
24
 
25
25
  render_search_to_s_element(label, render_filter_value(params['q']))
26
26
  end
@@ -60,7 +60,9 @@ module Blacklight::SearchHistoryConstraintsHelperBehavior
60
60
  # Render the value of the facet
61
61
  def render_filter_value value, key = nil
62
62
  display_value = value
63
- display_value = facet_display_value(key, value) if key
63
+ Deprecation.silence(Blacklight::FacetsHelperBehavior) do
64
+ display_value = facet_display_value(key, value) if key
65
+ end
64
66
  tag.span(h(display_value),
65
67
  class: 'filter-value')
66
68
  end
@@ -2,6 +2,7 @@
2
2
  module Blacklight
3
3
  module SuggestHelperBehavior
4
4
  ##
5
+ # @deprecated
5
6
  # @return [Boolean] should autocomplete be enabled in the UI
6
7
  def autocomplete_enabled?
7
8
  blacklight_config.autocomplete_enabled.present? &&
@@ -2,9 +2,13 @@
2
2
  ##
3
3
  # URL helper methods
4
4
  module Blacklight::UrlHelperBehavior
5
+ extend Deprecation
6
+
7
+ # @deprecated
5
8
  def url_for_document(doc, options = {})
6
9
  search_state.url_for_document(doc, options)
7
10
  end
11
+ deprecation_deprecate url_for_document: 'Use SearchState#url_for_document directly'
8
12
 
9
13
  # Uses the catalog_path route to create a link to the show page for an item.
10
14
  # catalog_path accepts a hash. The solr query params are stored in the session,
@@ -21,10 +25,10 @@ module Blacklight::UrlHelperBehavior
21
25
  def link_to_document(doc, field_or_opts = nil, opts = { counter: nil })
22
26
  label = case field_or_opts
23
27
  when NilClass
24
- index_presenter(doc).heading
28
+ document_presenter(doc).heading
25
29
  when Hash
26
30
  opts = field_or_opts
27
- index_presenter(doc).heading
31
+ document_presenter(doc).heading
28
32
  when Proc, Symbol
29
33
  Deprecation.warn(self, "passing a #{field_or_opts.class} to link_to_document is deprecated and will be removed in Blacklight 8")
30
34
  Deprecation.silence(Blacklight::IndexPresenter) do
@@ -34,9 +38,12 @@ module Blacklight::UrlHelperBehavior
34
38
  field_or_opts
35
39
  end
36
40
 
37
- link_to label, url_for_document(doc), document_link_params(doc, opts)
41
+ Deprecation.silence(Blacklight::UrlHelperBehavior) do
42
+ link_to label, url_for_document(doc), document_link_params(doc, opts)
43
+ end
38
44
  end
39
45
 
46
+ # @private
40
47
  def document_link_params(doc, opts)
41
48
  session_tracking_params(doc, opts[:counter]).deep_merge(opts.except(:label, :counter))
42
49
  end
@@ -44,24 +51,29 @@ module Blacklight::UrlHelperBehavior
44
51
 
45
52
  ##
46
53
  # Link to the previous document in the current search context
54
+ # @deprecated
47
55
  def link_to_previous_document(previous_document)
48
56
  link_opts = session_tracking_params(previous_document, search_session['counter'].to_i - 1).merge(class: "previous", rel: 'prev')
49
57
  link_to_unless previous_document.nil?, raw(t('views.pagination.previous')), url_for_document(previous_document), link_opts do
50
58
  tag.span raw(t('views.pagination.previous')), class: 'previous'
51
59
  end
52
60
  end
61
+ deprecation_deprecate link_to_previous_document: 'Moving to Blacklight::SearchContextComponent'
53
62
 
54
63
  ##
55
64
  # Link to the next document in the current search context
65
+ # @deprecated
56
66
  def link_to_next_document(next_document)
57
67
  link_opts = session_tracking_params(next_document, search_session['counter'].to_i + 1).merge(class: "next", rel: 'next')
58
68
  link_to_unless next_document.nil?, raw(t('views.pagination.next')), url_for_document(next_document), link_opts do
59
69
  tag.span raw(t('views.pagination.next')), class: 'next'
60
70
  end
61
71
  end
72
+ deprecation_deprecate link_to_previous_document: 'Moving to Blacklight::SearchContextComponent'
62
73
 
63
74
  ##
64
75
  # Attributes for a link that gives a URL we can use to track clicks for the current search session
76
+ # @private
65
77
  # @param [SolrDocument] document
66
78
  # @param [Integer] counter
67
79
  # @example
@@ -100,15 +112,18 @@ module Blacklight::UrlHelperBehavior
100
112
  #
101
113
 
102
114
  # create link to query (e.g. spelling suggestion)
115
+ # @deprecated
103
116
  def link_to_query(query)
104
117
  p = search_state.to_h.except(:page, :action)
105
118
  p[:q] = query
106
119
  link_to(query, search_action_path(p))
107
120
  end
121
+ deprecation_deprecate link_to_query: 'Removed without replacement'
108
122
 
109
123
  ##
110
124
  # Get the path to the search action with any parameters (e.g. view type)
111
125
  # that should be persisted across search sessions.
126
+ # @deprecated
112
127
  def start_over_path query_params = params
113
128
  h = {}
114
129
  current_index_view_type = document_index_view_type(query_params)
@@ -116,6 +131,7 @@ module Blacklight::UrlHelperBehavior
116
131
 
117
132
  search_action_path(h)
118
133
  end
134
+ deprecation_deprecate start_over_path: 'Removed without replacement'
119
135
 
120
136
  # Create a link back to the index screen, keeping the user's facet, query and paging choices intact by using session.
121
137
  # @example
@@ -156,17 +172,21 @@ module Blacklight::UrlHelperBehavior
156
172
 
157
173
  # Get url parameters to a search within a grouped result set
158
174
  #
175
+ # @deprecated
159
176
  # @param [Blacklight::Solr::Response::Group] group
160
177
  # @return [Hash]
161
178
  def add_group_facet_params_and_redirect group
162
179
  search_state.add_facet_params_and_redirect(group.field, group.key)
163
180
  end
181
+ deprecation_deprecate add_group_facet_params_and_redirect: 'Removed without replacement'
164
182
 
165
183
  # A URL to refworks export, with an embedded callback URL to this app.
166
184
  # the callback URL is to bookmarks#export, which delivers a list of
167
185
  # user's bookmarks in 'refworks marc txt' format -- we tell refworks
168
186
  # to expect that format.
187
+ # @deprecated
169
188
  def bookmarks_export_url(format, params = {})
170
189
  bookmarks_url(params.merge(format: format, encrypted_user_id: encrypt_user_id(current_or_guest_user.id)))
171
190
  end
191
+ deprecation_deprecate bookmarks_export_url: 'Removed without replacement'
172
192
  end
@@ -6,7 +6,6 @@ module Blacklight
6
6
 
7
7
  ##
8
8
  # @param [String, Symbol] icon_name
9
- # @param [Hash] options
10
9
  # @param [String] classes additional classes separated by a string
11
10
  # @param [Boolean] aria_hidden include aria_hidden attribute
12
11
  # @param [Boolean] label include <title> and aria-label as part of svg
@@ -111,7 +111,7 @@ module Blacklight::Document
111
111
  end
112
112
 
113
113
  # Define an attribute reader on a document model
114
- # @Example
114
+ # @example
115
115
  # class SolrDocument
116
116
  # include Blacklight::Solr::Document
117
117
  # attribute :title, Blacklight::Types::String, 'title_tesim'
@@ -18,7 +18,7 @@ module Blacklight
18
18
  end
19
19
 
20
20
  ##
21
- # Trys the suggestor response to return suggestions if they are
21
+ # Trys the suggester response to return suggestions if they are
22
22
  # present
23
23
  # @return [Array]
24
24
  def suggestions
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  # Only works for documents with a #to_marc right now.
3
- class RecordMailer < ApplicationMailer
3
+ class RecordMailer < ActionMailer::Base
4
4
  def email_record(documents, details, url_gen_params)
5
5
  title = begin
6
6
  documents.first.to_semantic_values[:title]
@@ -49,11 +49,36 @@ module Blacklight
49
49
  f ? field_value(f, except_operations: [Rendering::HelperMethod]) : ""
50
50
  end
51
51
 
52
+ ##
53
+ # Get the document's "title" to display in the <title> element.
54
+ # (by default, use the #document_heading)
55
+ #
56
+ # @see #document_heading
57
+ # @return [String]
58
+ def html_title
59
+ return field_value(view_config.html_title_field) if view_config.html_title_field.is_a? Blacklight::Configuration::Field
60
+
61
+ if view_config.html_title_field
62
+ fields = Array.wrap(view_config.html_title_field) + [configuration.document_model.unique_key]
63
+ f = fields.lazy.map { |field| field_config(field) }.detect { |field_config| field_presenter(field_config).any? }
64
+ field_value(f)
65
+ else
66
+ heading
67
+ end
68
+ end
69
+
52
70
  def display_type(base_name = nil, default: nil)
53
71
  fields = []
54
72
  fields += Array.wrap(view_config[:"#{base_name}_display_type_field"]) if base_name && view_config.key?(:"#{base_name}_display_type_field")
55
73
  fields += Array.wrap(view_config.display_type_field)
56
74
 
75
+ if fields.empty?
76
+ fields += Array.wrap(configuration.show[:"#{base_name}_display_type_field"]) if base_name && configuration.show.key?(:"#{base_name}_display_type_field")
77
+ fields += Array.wrap(configuration.show.display_type_field)
78
+ end
79
+
80
+ fields += ['format'] if fields.empty? # backwards compatibility with the old default value for display_type_field
81
+
57
82
  display_type = fields.lazy.map { |field| field_presenter(field_config(field)) }.detect(&:any?)&.values
58
83
  display_type ||= Array(default) if default
59
84
 
@@ -76,6 +101,18 @@ module Blacklight
76
101
  @thumbnail ||= thumbnail_presenter.new(document, view_context, view_config)
77
102
  end
78
103
 
104
+ ##
105
+ # Create <link rel="alternate"> links from a documents dynamically
106
+ # provided export formats. Returns empty string if no links available.
107
+ #
108
+ # @param [Hash] options
109
+ # @option options [Boolean] :unique ensures only one link is output for every
110
+ # content type, e.g. as required by atom
111
+ # @option options [Array<String>] :exclude array of format shortnames to not include in the output
112
+ def link_rel_alternates(options = {})
113
+ LinkAlternatePresenter.new(view_context, document, options).render
114
+ end
115
+
79
116
  private
80
117
 
81
118
  def render_field?(field_config)
@@ -100,7 +137,11 @@ module Blacklight
100
137
 
101
138
  def field_presenter(field_config, options = {})
102
139
  presenter_class = field_config.presenter || Blacklight::FieldPresenter
103
- presenter_class.new(view_context, document, field_config, options)
140
+ presenter_class.new(view_context, document, field_config, options.merge(field_presenter_options))
141
+ end
142
+
143
+ def field_presenter_options
144
+ {}
104
145
  end
105
146
  end
106
147
  end
@@ -51,7 +51,9 @@ module Blacklight
51
51
  def paginator
52
52
  return unless display_facet
53
53
 
54
- @paginator ||= view_context.facet_paginator(facet_field, display_facet)
54
+ Deprecation.silence(Blacklight::Facet) do
55
+ @paginator ||= view_context.facet_paginator(facet_field, display_facet)
56
+ end
55
57
  end
56
58
  end
57
59
  end
@@ -21,6 +21,10 @@ module Blacklight
21
21
  search_state.has_facet? facet_config, value: facet_value
22
22
  end
23
23
 
24
+ def field_label
25
+ facet_field_presenter.label
26
+ end
27
+
24
28
  ##
25
29
  # Get the displayable version of a facet's value
26
30
  #
@@ -77,5 +81,9 @@ module Blacklight
77
81
  facet_item
78
82
  end
79
83
  end
84
+
85
+ def facet_field_presenter
86
+ @facet_field_presenter ||= view_context.facet_field_presenter(facet_config, {})
87
+ end
80
88
  end
81
89
  end
@@ -24,6 +24,7 @@ module Blacklight
24
24
  end
25
25
 
26
26
  @except_operations = options[:except_operations] || []
27
+ @except_operations += field_config.except_operations || []
27
28
  # Implicitly prevent helper methods from drawing when drawing the label for the document
28
29
  @except_operations += [Rendering::HelperMethod] if options.key? :value
29
30
  end
@@ -31,21 +32,24 @@ module Blacklight
31
32
  attr_reader :view_context, :document, :field_config, :except_operations, :options
32
33
  delegate :key, to: :field_config
33
34
 
35
+ # @return [String]
34
36
  def render
35
37
  Rendering::Pipeline.new(values, field_config, document, view_context, pipeline_steps, options).render
36
38
  end
37
39
 
40
+ # @return [Enumerable]
38
41
  def values
39
42
  @values ||= retrieve_values
40
43
  end
41
44
 
42
- def label(context = 'index', **options)
43
- field_config.display_label(context, count: retrieve_values.count, **options)
45
+ # @param [String] context
46
+ # @return [String]
47
+ def label(context = nil, **options)
48
+ field_config.display_label(context || options.fetch(:context, 'index'), count: retrieve_values.count, **options)
44
49
  end
45
50
 
46
51
  ##
47
52
  # Check to see if the given field should be rendered in this context
48
- # @param [Blacklight::Configuration::Field] field_config
49
53
  # @return [Boolean]
50
54
  def render_field?
51
55
  view_context.should_render_field?(field_config, document)
@@ -54,7 +58,6 @@ module Blacklight
54
58
  ##
55
59
  # Check if a document has (or, might have, in the case of accessor methods) a value for
56
60
  # the given solr field
57
- # @param [Blacklight::Configuration::Field] field_config
58
61
  # @return [Boolean]
59
62
  def any?
60
63
  values.present?
@@ -63,11 +66,11 @@ module Blacklight
63
66
  private
64
67
 
65
68
  def pipeline_steps
66
- (options[:steps] || Rendering::Pipeline.operations) - except_operations
69
+ (options[:steps] || field_config[:steps] || Rendering::Pipeline.operations) - except_operations
67
70
  end
68
71
 
69
72
  def retrieve_values
70
- FieldRetriever.new(document, field_config).fetch
73
+ FieldRetriever.new(document, field_config, view_context).fetch
71
74
  end
72
75
  end
73
76
  end
@@ -18,7 +18,9 @@ module Blacklight
18
18
 
19
19
  # @return [Array<Blacklight::Solr::Response::Facets::FacetField>]
20
20
  def search_facets
21
- facets_from_request(facet_field_names, @response).select { |display_facet| display_facet.items.present? }
21
+ Deprecation.silence(Blacklight::Facet) do
22
+ facets_from_request(facet_field_names, @response).select { |display_facet| display_facet.items.present? }
23
+ end
22
24
  end
23
25
 
24
26
  # extract the pagination info from the response object
@@ -1,36 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Blacklight
3
3
  class ShowPresenter < DocumentPresenter
4
- ##
5
- # Create <link rel="alternate"> links from a documents dynamically
6
- # provided export formats. Returns empty string if no links available.
7
- #
8
- # @param [Hash] options
9
- # @option options [Boolean] :unique ensures only one link is output for every
10
- # content type, e.g. as required by atom
11
- # @option options [Array<String>] :exclude array of format shortnames to not include in the output
12
- def link_rel_alternates(options = {})
13
- LinkAlternatePresenter.new(view_context, document, options).render
14
- end
15
-
16
- ##
17
- # Get the document's "title" to display in the <title> element.
18
- # (by default, use the #document_heading)
19
- #
20
- # @see #document_heading
21
- # @return [String]
22
- def html_title
23
- return field_value(view_config.html_title_field) if view_config.html_title_field.is_a? Blacklight::Configuration::Field
24
-
25
- if view_config.html_title_field
26
- fields = Array.wrap(view_config.html_title_field) + [configuration.document_model.unique_key]
27
- f = fields.lazy.map { |field| field_config(field) }.detect { |field_config| field_presenter(field_config).any? }
28
- field_value(f)
29
- else
30
- heading
31
- end
32
- end
33
-
34
4
  private
35
5
 
36
6
  # @return [Hash<String,Configuration::Field>]
@@ -45,5 +15,9 @@ module Blacklight
45
15
  def field_config(field)
46
16
  configuration.show_fields.fetch(field) { Configuration::NullField.new(field) }
47
17
  end
18
+
19
+ def field_presenter_options
20
+ { context: 'show' }
21
+ end
48
22
  end
49
23
  end