blacklight 6.5.0 → 6.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +5 -0
  4. data/.rubocop_todo.yml +114 -213
  5. data/{.solr_wrapper → .solr_wrapper.yml} +0 -0
  6. data/.yardopts +3 -1
  7. data/Gemfile +0 -3
  8. data/Rakefile +1 -1
  9. data/VERSION +1 -1
  10. data/Vagrantfile +0 -2
  11. data/app/controllers/bookmarks_controller.rb +0 -2
  12. data/app/controllers/catalog_controller.rb +0 -2
  13. data/app/controllers/concerns/blacklight/base.rb +0 -1
  14. data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
  15. data/app/controllers/concerns/blacklight/catalog.rb +7 -11
  16. data/app/controllers/concerns/blacklight/controller.rb +11 -7
  17. data/app/controllers/concerns/blacklight/default_component_configuration.rb +24 -37
  18. data/app/controllers/concerns/blacklight/facet.rb +2 -11
  19. data/app/controllers/concerns/blacklight/request_builders.rb +1 -3
  20. data/app/controllers/concerns/blacklight/search_context.rb +0 -1
  21. data/app/controllers/concerns/blacklight/search_fields.rb +2 -2
  22. data/app/controllers/concerns/blacklight/search_helper.rb +14 -24
  23. data/app/controllers/concerns/blacklight/token_based_user.rb +0 -2
  24. data/app/helpers/blacklight/blacklight_helper_behavior.rb +27 -28
  25. data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -15
  26. data/app/helpers/blacklight/component_helper_behavior.rb +2 -5
  27. data/app/helpers/blacklight/configuration_helper_behavior.rb +2 -3
  28. data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -3
  29. data/app/helpers/blacklight/facets_helper_behavior.rb +21 -25
  30. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -2
  31. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +8 -9
  32. data/app/helpers/blacklight/render_partials_helper.rb +14 -13
  33. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -4
  34. data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
  35. data/app/models/blacklight/facet_paginator.rb +2 -2
  36. data/app/models/concerns/blacklight/document.rb +1 -6
  37. data/app/models/concerns/blacklight/document/active_model_shim.rb +0 -1
  38. data/app/models/concerns/blacklight/document/cache_key.rb +3 -3
  39. data/app/models/concerns/blacklight/document/dublin_core.rb +0 -1
  40. data/app/models/concerns/blacklight/document/email.rb +0 -2
  41. data/app/models/concerns/blacklight/document/export.rb +1 -2
  42. data/app/models/concerns/blacklight/document/schema_org.rb +0 -2
  43. data/app/models/concerns/blacklight/document/sms.rb +0 -2
  44. data/app/models/concerns/blacklight/solr/document.rb +0 -1
  45. data/app/models/record_mailer.rb +0 -1
  46. data/app/models/solr_document.rb +0 -2
  47. data/app/presenters/blacklight/document_presenter.rb +14 -11
  48. data/app/presenters/blacklight/index_presenter.rb +5 -5
  49. data/app/presenters/blacklight/json_presenter.rb +0 -1
  50. data/app/presenters/blacklight/rendering/abstract_step.rb +0 -1
  51. data/app/presenters/blacklight/rendering/helper_method.rb +5 -5
  52. data/app/presenters/blacklight/rendering/link_to_facet.rb +1 -1
  53. data/app/presenters/blacklight/show_presenter.rb +4 -5
  54. data/app/services/blacklight/field_retriever.rb +8 -9
  55. data/app/views/catalog/_facet_limit.html.erb +1 -1
  56. data/blacklight.gemspec +4 -0
  57. data/lib/blacklight.rb +2 -2
  58. data/lib/blacklight/abstract_repository.rb +4 -3
  59. data/lib/blacklight/configuration.rb +57 -92
  60. data/lib/blacklight/configuration/context.rb +3 -3
  61. data/lib/blacklight/configuration/fields.rb +24 -7
  62. data/lib/blacklight/exceptions.rb +0 -2
  63. data/lib/blacklight/parameters.rb +1 -1
  64. data/lib/blacklight/search_builder.rb +92 -96
  65. data/lib/blacklight/search_state.rb +2 -1
  66. data/lib/blacklight/solr/repository.rb +3 -4
  67. data/lib/blacklight/solr/request.rb +0 -2
  68. data/lib/blacklight/solr/response/facets.rb +23 -28
  69. data/lib/blacklight/solr/response/group.rb +0 -1
  70. data/lib/blacklight/solr/response/group_response.rb +1 -5
  71. data/lib/blacklight/solr/response/pagination_methods.rb +0 -1
  72. data/lib/blacklight/solr/response/response.rb +1 -1
  73. data/lib/blacklight/solr/response/spelling.rb +0 -4
  74. data/lib/blacklight/solr/search_builder_behavior.rb +29 -41
  75. data/lib/blacklight/utils.rb +10 -7
  76. data/lib/generators/blacklight/assets_generator.rb +0 -1
  77. data/lib/generators/blacklight/document_generator.rb +0 -1
  78. data/lib/generators/blacklight/install_generator.rb +2 -6
  79. data/lib/generators/blacklight/models_generator.rb +0 -3
  80. data/lib/generators/blacklight/search_builder_generator.rb +0 -1
  81. data/lib/generators/blacklight/solr4_generator.rb +0 -2
  82. data/lib/generators/blacklight/solr5_generator.rb +15 -1
  83. data/lib/generators/blacklight/test_support_generator.rb +0 -1
  84. data/lib/railties/blacklight.rake +3 -3
  85. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -4
  86. data/spec/controllers/blacklight/search_helper_spec.rb +5 -7
  87. data/spec/controllers/blacklight/suggest_search_spec.rb +2 -2
  88. data/spec/controllers/bookmarks_controller_spec.rb +2 -2
  89. data/spec/controllers/catalog_controller_spec.rb +6 -6
  90. data/spec/features/search_context_spec.rb +4 -5
  91. data/spec/features/search_formats_spec.rb +0 -6
  92. data/spec/helpers/blacklight_helper_spec.rb +7 -7
  93. data/spec/helpers/catalog_helper_spec.rb +10 -10
  94. data/spec/helpers/configuration_helper_spec.rb +3 -3
  95. data/spec/helpers/facets_helper_spec.rb +1 -2
  96. data/spec/helpers/render_constraints_helper_spec.rb +8 -0
  97. data/spec/integration/generators/blacklight/solr5_generator_spec.rb +60 -0
  98. data/spec/models/blacklight/document_spec.rb +1 -1
  99. data/spec/models/blacklight/search_builder_spec.rb +5 -4
  100. data/spec/models/blacklight/solr/search_builder_spec.rb +12 -18
  101. data/spec/presenters/pipeline_spec.rb +1 -1
  102. data/spec/spec_helper.rb +43 -0
  103. data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -1
  104. data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -1
  105. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
  106. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -1
  107. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +3 -3
  108. data/spec/views/catalog/index.html.erb_spec.rb +1 -1
  109. data/spec/views/catalog/index.json.jbuilder_spec.rb +2 -2
  110. data/tasks/blacklight.rake +3 -0
  111. metadata +61 -3
@@ -8,7 +8,6 @@ module Blacklight::TokenBasedUser
8
8
  rescue_from Blacklight::Exceptions::ExpiredSessionToken do
9
9
  head :unauthorized
10
10
  end
11
-
12
11
  end
13
12
 
14
13
  protected
@@ -49,5 +48,4 @@ module Blacklight::TokenBasedUser
49
48
  def message_encryptor
50
49
  ActiveSupport::MessageEncryptor.new(export_secret_token)
51
50
  end
52
-
53
51
  end
@@ -36,8 +36,8 @@ module Blacklight::BlacklightHelperBehavior
36
36
  #
37
37
  # Returns empty string if no links available.
38
38
  #
39
- # @params [SolrDocument] document
40
- # @params [Hash] options
39
+ # @param [SolrDocument] document
40
+ # @param [Hash] options
41
41
  # @option options [Boolean] :unique ensures only one link is output for every
42
42
  # content type, e.g. as required by atom
43
43
  # @option options [Array<String>] :exclude array of format shortnames to not include in the output
@@ -122,13 +122,13 @@ module Blacklight::BlacklightHelperBehavior
122
122
  # @overload render_index_field_label(options)
123
123
  # Use the default, document-agnostic configuration
124
124
  # @param [Hash] opts
125
- # @options opts [String] :field
125
+ # @option opts [String] :field
126
126
  # @overload render_index_field_label(document, options)
127
127
  # Allow an extention point where information in the document
128
128
  # may drive the value of the field
129
129
  # @param [SolrDocument] doc
130
130
  # @param [Hash] opts
131
- # @options opts [String] :field
131
+ # @option opts [String] :field
132
132
  def render_index_field_label *args
133
133
  options = args.extract_options!
134
134
  document = args.first
@@ -143,23 +143,23 @@ module Blacklight::BlacklightHelperBehavior
143
143
  # @overload render_index_field_value(options)
144
144
  # Use the default, document-agnostic configuration
145
145
  # @param [Hash] opts
146
- # @options opts [String] :field
147
- # @options opts [String] :value
148
- # @options opts [String] :document
146
+ # @option opts [String] :field
147
+ # @option opts [String] :value
148
+ # @option opts [String] :document
149
149
  # @overload render_index_field_value(document, options)
150
150
  # Allow an extention point where information in the document
151
151
  # may drive the value of the field
152
152
  # @param [SolrDocument] doc
153
153
  # @param [Hash] opts
154
- # @options opts [String] :field
155
- # @options opts [String] :value
154
+ # @option opts [String] :field
155
+ # @option opts [String] :value
156
156
  # @overload render_index_field_value(document, field, options)
157
157
  # Allow an extention point where information in the document
158
158
  # may drive the value of the field
159
159
  # @param [SolrDocument] doc
160
160
  # @param [String] field
161
161
  # @param [Hash] opts
162
- # @options opts [String] :value
162
+ # @option opts [String] :value
163
163
  # @deprecated use IndexPresenter#field_value
164
164
  def render_index_field_value *args
165
165
  render_field_value(*args)
@@ -182,13 +182,13 @@ module Blacklight::BlacklightHelperBehavior
182
182
  # @overload render_document_show_field_label(options)
183
183
  # Use the default, document-agnostic configuration
184
184
  # @param [Hash] opts
185
- # @options opts [String] :field
185
+ # @option opts [String] :field
186
186
  # @overload render_document_show_field_label(document, options)
187
187
  # Allow an extention point where information in the document
188
188
  # may drive the value of the field
189
189
  # @param [SolrDocument] doc
190
190
  # @param [Hash] opts
191
- # @options opts [String] :field
191
+ # @option opts [String] :field
192
192
  def render_document_show_field_label *args
193
193
  options = args.extract_options!
194
194
  document = args.first
@@ -204,30 +204,29 @@ module Blacklight::BlacklightHelperBehavior
204
204
  # @overload render_document_show_field_value(options)
205
205
  # Use the default, document-agnostic configuration
206
206
  # @param [Hash] opts
207
- # @options opts [String] :field
208
- # @options opts [String] :value
209
- # @options opts [String] :document
207
+ # @option opts [String] :field
208
+ # @option opts [String] :value
209
+ # @option opts [String] :document
210
210
  # @overload render_document_show_field_value(document, options)
211
211
  # Allow an extention point where information in the document
212
212
  # may drive the value of the field
213
213
  # @param [SolrDocument] doc
214
214
  # @param [Hash] opts
215
- # @options opts [String] :field
216
- # @options opts [String] :value
215
+ # @option opts [String] :field
216
+ # @option opts [String] :value
217
217
  # @overload render_document_show_field_value(document, field, options)
218
218
  # Allow an extention point where information in the document
219
219
  # may drive the value of the field
220
220
  # @param [SolrDocument] doc
221
221
  # @param [String] field
222
222
  # @param [Hash] opts
223
- # @options opts [String] :value
223
+ # @option opts [String] :value
224
224
  # @deprecated use ShowPresenter#field_value
225
225
  def render_document_show_field_value *args
226
226
  render_field_value(*args)
227
227
  end
228
228
  deprecation_deprecate render_document_show_field_value: 'replaced by ShowPresenter#field_value'
229
229
 
230
-
231
230
  ##
232
231
  # Get the value of the document's "title" field, or a placeholder
233
232
  # value (if empty)
@@ -255,12 +254,12 @@ module Blacklight::BlacklightHelperBehavior
255
254
  ##
256
255
  # Render the document "heading" (title) in a content tag
257
256
  # @overload render_document_heading(document, options)
258
- # @params [SolrDocument] document
259
- # @params [Hash] options
260
- # @options options [Symbol] :tag
257
+ # @param [SolrDocument] document
258
+ # @param [Hash] options
259
+ # @option options [Symbol] :tag
261
260
  # @overload render_document_heading(options)
262
- # @params [Hash] options
263
- # @options options [Symbol] :tag
261
+ # @param [Hash] options
262
+ # @option options [Symbol] :tag
264
263
  def render_document_heading(*args)
265
264
  options = args.extract_options!
266
265
  document = args.first
@@ -280,8 +279,8 @@ module Blacklight::BlacklightHelperBehavior
280
279
  # - helper_method
281
280
  # - link_to_search
282
281
  # @param [SolrDocument] document
283
- # @param [String] field name
284
- # @param [Blacklight::Configuration::Field] solr field configuration
282
+ # @param [String] _field name
283
+ # @param [Blacklight::Configuration::Field] field_config solr field configuration
285
284
  # @param [Hash] options additional options to pass to the rendering helpers
286
285
  def get_field_values document, _field, field_config, options = {}
287
286
  presenter(document).field_values field_config, options
@@ -291,7 +290,7 @@ module Blacklight::BlacklightHelperBehavior
291
290
  ##
292
291
  # Get the current "view type" (and ensure it is a valid type)
293
292
  #
294
- # @param [Hash] the query parameters to check
293
+ # @param [Hash] query_params the query parameters to check
295
294
  # @return [Symbol]
296
295
  def document_index_view_type query_params=params
297
296
  view_param = query_params[:view]
@@ -324,7 +323,7 @@ module Blacklight::BlacklightHelperBehavior
324
323
  # Should we render a grouped response (because the response
325
324
  # contains a grouped response instead of the normal response)
326
325
  def render_grouped_response? response = @response
327
- return response.grouped?
326
+ response.grouped?
328
327
  end
329
328
 
330
329
  ##
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Blacklight::CatalogHelperBehavior
3
-
4
3
  # @param [Hash] options
5
4
  # @option options :route_set the route scope to use when constructing the link
6
5
  def rss_feed_link_tag(options = {})
@@ -18,7 +17,7 @@ module Blacklight::CatalogHelperBehavior
18
17
  # implementation.
19
18
  # Displays the "showing X through Y of N" message.
20
19
  #
21
- # @param [RSolr::Resource] (or other Kaminari-compatible objects)
20
+ # @param [RSolr::Resource] collection (or other Kaminari-compatible objects)
22
21
  # @return [String]
23
22
  def page_entries_info(collection, options = {})
24
23
  return unless show_pagination? collection
@@ -67,7 +66,8 @@ module Blacklight::CatalogHelperBehavior
67
66
  ##
68
67
  # Get the offset counter for a document
69
68
  #
70
- # @param [Integer] document index
69
+ # @param [Integer] idx document index
70
+ # @param [Integer] offset additional offset to incremenet the counter by
71
71
  # @return [Integer]
72
72
  def document_counter_with_offset idx, offset = nil
73
73
  offset ||= @response.start if @response
@@ -134,7 +134,7 @@ module Blacklight::CatalogHelperBehavior
134
134
  ##
135
135
  # Render the sidebar partial for a document
136
136
  #
137
- # @param [SolrDocument]
137
+ # @param [SolrDocument] document
138
138
  # @return [String]
139
139
  def render_document_sidebar_partial(document = @document)
140
140
  render :partial => 'show_sidebar'
@@ -143,7 +143,7 @@ module Blacklight::CatalogHelperBehavior
143
143
  ##
144
144
  # Render the main content partial for a document
145
145
  #
146
- # @param [SolrDocument]
146
+ # @param [SolrDocument] document
147
147
  # @return [String]
148
148
  def render_document_main_content_partial(document = @document)
149
149
  render partial: 'show_main_content'
@@ -152,7 +152,7 @@ module Blacklight::CatalogHelperBehavior
152
152
  ##
153
153
  # Should we display the sort and per page widget?
154
154
  #
155
- # @param [Blacklight::Solr::Response]
155
+ # @param [Blacklight::Solr::Response] response
156
156
  # @return [Boolean]
157
157
  def show_sort_and_per_page? response = nil
158
158
  response ||= @response
@@ -162,7 +162,7 @@ module Blacklight::CatalogHelperBehavior
162
162
  ##
163
163
  # Should we display the pagination controls?
164
164
  #
165
- # @param [Blacklight::Solr::Response]
165
+ # @param [Blacklight::Solr::Response] response
166
166
  # @return [Boolean]
167
167
  def show_pagination? response = nil
168
168
  response ||= @response
@@ -183,7 +183,7 @@ module Blacklight::CatalogHelperBehavior
183
183
  ##
184
184
  # Does the document have a thumbnail to render?
185
185
  #
186
- # @param [SolrDocument]
186
+ # @param [SolrDocument] document
187
187
  # @return [Boolean]
188
188
  def has_thumbnail? document
189
189
  blacklight_config.view_config(document_index_view_type).thumbnail_method.present? or
@@ -194,9 +194,9 @@ module Blacklight::CatalogHelperBehavior
194
194
  # Render the thumbnail, if available, for a document and
195
195
  # link it to the document record.
196
196
  #
197
- # @param [SolrDocument]
198
- # @param [Hash] options to pass to the image tag
199
- # @param [Hash] url options to pass to #link_to_document
197
+ # @param [SolrDocument] document
198
+ # @param [Hash] image_options to pass to the image tag
199
+ # @param [Hash] url_options to pass to #link_to_document
200
200
  # @return [String]
201
201
  def render_thumbnail_tag document, image_options = {}, url_options = {}
202
202
  value = if blacklight_config.view_config(document_index_view_type).thumbnail_method
@@ -208,7 +208,7 @@ module Blacklight::CatalogHelperBehavior
208
208
  end
209
209
 
210
210
  if value
211
- if url_options === false || url_options[:suppress_link]
211
+ if url_options == false || url_options[:suppress_link]
212
212
  value
213
213
  else
214
214
  link_to_document document, value, url_options
@@ -219,7 +219,7 @@ module Blacklight::CatalogHelperBehavior
219
219
  ##
220
220
  # Get the URL to a document's thumbnail image
221
221
  #
222
- # @param [SolrDocument]
222
+ # @param [SolrDocument] document
223
223
  # @return [String]
224
224
  def thumbnail_url document
225
225
  if document.has? blacklight_config.view_config(document_index_view_type).thumbnail_field
@@ -230,7 +230,7 @@ module Blacklight::CatalogHelperBehavior
230
230
  ##
231
231
  # Render the view type icon for the results view picker
232
232
  #
233
- # @param [String]
233
+ # @param [String] view
234
234
  # @return [String]
235
235
  def render_view_type_group_icon view
236
236
  content_tag :span, '', class: "glyphicon #{blacklight_config.view[view].icon_class || default_view_type_group_icon_classes(view)}"
@@ -239,7 +239,7 @@ module Blacklight::CatalogHelperBehavior
239
239
  ##
240
240
  # Get the default view type classes for a view in the results view picker
241
241
  #
242
- # @param [String]
242
+ # @param [String] view
243
243
  # @return [String]
244
244
  def default_view_type_group_icon_classes view
245
245
  "glyphicon-#{view.to_s.parameterize} view-icon-#{view.to_s.parameterize}"
@@ -1,16 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
  module Blacklight
3
3
  module ComponentHelperBehavior
4
-
5
4
  def document_action_label action, opts
6
5
  t("blacklight.tools.#{action}", default: opts.label || action.to_s.humanize)
7
6
  end
8
7
 
9
8
  def document_action_path action_opts, url_opts = nil
10
- case
11
- when action_opts.path
9
+ if action_opts.path
12
10
  self.send(action_opts.path, url_opts)
13
- when url_opts[:id].class.respond_to?(:model_name)
11
+ elsif url_opts[:id].class.respond_to?(:model_name)
14
12
  url_for([action_opts.key, url_opts[:id]])
15
13
  else
16
14
  self.send("#{action_opts.key}_#{controller_name}_path", url_opts)
@@ -80,6 +78,5 @@ module Blacklight
80
78
  def render_show_doc_actions(document=@document, options={}, &block)
81
79
  render_filtered_partials(blacklight_config.show.document_actions, { document: document }.merge(options), &block)
82
80
  end
83
-
84
81
  end
85
82
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Blacklight::ConfigurationHelperBehavior
3
-
4
3
  ##
5
4
  # Index fields to display for a type of document
6
5
  #
@@ -42,7 +41,7 @@ module Blacklight::ConfigurationHelperBehavior
42
41
  # Return a label for the currently selected search field.
43
42
  # If no "search_field" or the default (e.g. "all_fields") is selected, then return nil
44
43
  # Otherwise grab the label of the selected search field.
45
- # @param [Hash] query parameters
44
+ # @param [Hash] localized_params query parameters
46
45
  # @return [String]
47
46
  def constraint_query_label(localized_params = params)
48
47
  label_for_search_field(localized_params[:search_field]) unless default_search_field?(localized_params[:search_field])
@@ -50,7 +49,7 @@ module Blacklight::ConfigurationHelperBehavior
50
49
 
51
50
  ##
52
51
  # Is the search form using the default search field ("all_fields" by default)?
53
- # @param [String] the currently selected search_field
52
+ # @param [String] selected_search_field the currently selected search_field
54
53
  # @return [Boolean]
55
54
  def default_search_field?(selected_search_field)
56
55
  selected_search_field.blank? || (default_search_field && selected_search_field == default_search_field[:key])
@@ -51,9 +51,7 @@ module Blacklight
51
51
  end
52
52
  deprecation_deprecate :remove_facet_params
53
53
 
54
- def add_facet_params_and_redirect(field, item)
55
- search_state.add_facet_params_and_redirect(field, item)
56
- end
54
+ delegate :add_facet_params_and_redirect, to: :search_state
57
55
  deprecation_deprecate :add_facet_params_and_redirect
58
56
  end
59
57
  end
@@ -5,7 +5,7 @@ module Blacklight::FacetsHelperBehavior
5
5
  ##
6
6
  # Check if any of the given fields have values
7
7
  #
8
- # @param [Array<String>]
8
+ # @param [Array<String>] fields
9
9
  # @param [Hash] options
10
10
  # @return [Boolean]
11
11
  def has_facet_values? fields = facet_field_names, options = {}
@@ -16,7 +16,7 @@ module Blacklight::FacetsHelperBehavior
16
16
  # Render a collection of facet fields.
17
17
  # @see #render_facet_limit
18
18
  #
19
- # @param [Array<String>]
19
+ # @param [Array<String>] fields
20
20
  # @param [Hash] options
21
21
  # @return String
22
22
  def render_facet_partials fields = facet_field_names, options = {}
@@ -25,7 +25,6 @@ module Blacklight::FacetsHelperBehavior
25
25
  end.compact, "\n")
26
26
  end
27
27
 
28
-
29
28
  ##
30
29
  # Renders a single section for facet limit with a specified
31
30
  # solr field used for faceting. Can be over-ridden for custom
@@ -56,10 +55,7 @@ module Blacklight::FacetsHelperBehavior
56
55
  # removes any elements where render_facet_item returns a nil value. This enables an application
57
56
  # to filter undesireable facet items so they don't appear in the UI
58
57
  def render_facet_limit_list(paginator, facet_field, wrapping_element=:li)
59
- safe_join(paginator.items.
60
- map { |item| render_facet_item(facet_field, item) }.compact.
61
- map { |item| content_tag(wrapping_element,item)}
62
- )
58
+ safe_join(paginator.items.map { |item| render_facet_item(facet_field, item) }.compact.map { |item| content_tag(wrapping_element,item)})
63
59
  end
64
60
 
65
61
  ##
@@ -83,7 +79,7 @@ module Blacklight::FacetsHelperBehavior
83
79
  # display when show is nil or true
84
80
  facet_config = facet_configuration_for_field(display_facet.name)
85
81
  display = should_render_field?(facet_config, display_facet)
86
- return display && display_facet.items.present?
82
+ display && display_facet.items.present?
87
83
  end
88
84
 
89
85
  ##
@@ -92,7 +88,7 @@ module Blacklight::FacetsHelperBehavior
92
88
  # - if the facet is configured to collapse (the default), collapse
93
89
  # - if the facet is configured not to collapse, don't collapse
94
90
  #
95
- # @param [Blacklight::Configuration::FacetField]
91
+ # @param [Blacklight::Configuration::FacetField] facet_field
96
92
  # @return [Boolean]
97
93
  def should_collapse_facet? facet_field
98
94
  !facet_field_in_params?(facet_field.field) && facet_field.collapse
@@ -117,8 +113,8 @@ module Blacklight::FacetsHelperBehavior
117
113
  # partial and catalog/facet expanded list. Will output facet value name as
118
114
  # a link to add that to your restrictions, with count in parens.
119
115
  #
120
- # @param [Blacklight::Solr::Response::Facets::FacetField]
121
- # @param [String] facet item
116
+ # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
117
+ # @param [String] item
122
118
  # @param [Hash] options
123
119
  # @option options [Boolean] :suppress_link display the facet, but don't link to it
124
120
  # @return [String]
@@ -131,8 +127,8 @@ module Blacklight::FacetsHelperBehavior
131
127
 
132
128
  ##
133
129
  # Where should this facet link to?
134
- # @param [Blacklight::Solr::Response::Facets::FacetField]
135
- # @param [String] facet item
130
+ # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
131
+ # @param [String] item
136
132
  # @return [String]
137
133
  def path_for_facet(facet_field, item)
138
134
  facet_config = facet_configuration_for_field(facet_field)
@@ -145,7 +141,9 @@ module Blacklight::FacetsHelperBehavior
145
141
 
146
142
  ##
147
143
  # Standard display of a SELECTED facet value (e.g. without a link and with a remove button)
148
- # @params (see #render_facet_value)
144
+ # @see #render_facet_value
145
+ # @param [Blacklight::Solr::Response::Facets::FacetField] facet_field
146
+ # @param [String] item
149
147
  def render_selected_facet_value(facet_field, item)
150
148
  remove_href = search_action_path(search_state.remove_facet_params(facet_field, item))
151
149
  content_tag(:span, class: "facet-label") do
@@ -162,7 +160,7 @@ module Blacklight::FacetsHelperBehavior
162
160
  # Renders a count value for facet limits. Can be over-ridden locally
163
161
  # to change style. And can be called by plugins to get consistent display.
164
162
  #
165
- # @param [Integer] number of facet results
163
+ # @param [Integer] num number of facet results
166
164
  # @param [Hash] options
167
165
  # @option options [Array<String>] an array of classes to add to count span.
168
166
  # @return [String]
@@ -174,7 +172,7 @@ module Blacklight::FacetsHelperBehavior
174
172
  ##
175
173
  # Are any facet restrictions for a field in the query parameters?
176
174
  #
177
- # @param [String] facet field
175
+ # @param [String] field
178
176
  # @return [Boolean]
179
177
  def facet_field_in_params? field
180
178
  !facet_params(field).blank?
@@ -184,8 +182,8 @@ module Blacklight::FacetsHelperBehavior
184
182
  # Check if the query parameters have the given facet field with the
185
183
  # given value.
186
184
  #
187
- # @param [Object] facet field
188
- # @param [Object] facet value
185
+ # @param [Object] field
186
+ # @param [Object] item facet value
189
187
  # @return [Boolean]
190
188
  def facet_in_params?(field, item)
191
189
  value = facet_value_for_facet_item(item)
@@ -216,14 +214,13 @@ module Blacklight::FacetsHelperBehavior
216
214
  facet_value_for_facet_item(item)
217
215
  end
218
216
 
219
- case
220
- when facet_config.helper_method
217
+ if facet_config.helper_method
221
218
  send facet_config.helper_method, value
222
- when (facet_config.query and facet_config.query[value])
219
+ elsif facet_config.query && facet_config.query[value]
223
220
  facet_config.query[value][:label]
224
- when facet_config.date
225
- localization_options = {}
226
- localization_options = facet_config.date unless facet_config.date === true
221
+ elsif facet_config.date
222
+ localization_options = facet_config.date == true ? {} : facet_config.date
223
+
227
224
  l(value.to_datetime, localization_options)
228
225
  else
229
226
  value
@@ -243,5 +240,4 @@ module Blacklight::FacetsHelperBehavior
243
240
  item
244
241
  end
245
242
  end
246
-
247
243
  end