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
File without changes
data/.yardopts CHANGED
@@ -1,4 +1,6 @@
1
1
  --protected
2
+ --exclude lib/generators/blacklight/templates/
2
3
  -
3
- app/**/*.rb
4
+ README.md
5
+ LICENSE
4
6
 
data/Gemfile CHANGED
@@ -3,9 +3,6 @@ source 'https://rubygems.org'
3
3
  # Please see blacklight.gemspec for dependency information.
4
4
  gemspec path: File.expand_path('..', __FILE__)
5
5
 
6
- gem 'simplecov', '~> 0.10', require: false
7
- gem 'coveralls', require: false
8
-
9
6
  group :test do
10
7
  gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
11
8
  end
data/Rakefile CHANGED
@@ -12,4 +12,4 @@ Bundler::GemHelper.install_tasks
12
12
  load "tasks/blacklight.rake"
13
13
  load "lib/railties/blacklight.rake"
14
14
 
15
- task :default => [:ci]
15
+ task :default => [:rubocop, :ci]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.5.0
1
+ 6.6.0
@@ -6,7 +6,6 @@
6
6
  # backwards compatibility). Please don't change it unless you know what
7
7
  # you're doing.
8
8
  Vagrant.configure(2) do |config|
9
-
10
9
  # The most common configuration options are documented and commented below.
11
10
  # For a complete reference, please see the online documentation at
12
11
  # https://docs.vagrantup.com.
@@ -17,7 +16,6 @@ Vagrant.configure(2) do |config|
17
16
  config.vm.hostname = "blacklight"
18
17
  config.vm.synced_folder ".", "/home/vagrant/sync", type: 'virtualbox'
19
18
 
20
-
21
19
  # Disable automatic box update checking. If you disable this, then
22
20
  # boxes will only be checked for updates when the user runs
23
21
  # `vagrant box outdated`. This is not recommended.
@@ -1,6 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class BookmarksController < CatalogController
3
-
4
3
  include Blacklight::Bookmarks
5
-
6
4
  end
@@ -1,6 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class CatalogController < ApplicationController
3
-
4
3
  include Blacklight::Catalog
5
-
6
4
  end
@@ -18,7 +18,6 @@ module Blacklight::Base
18
18
 
19
19
  # when The index throws an error (Blacklight::Exceptions::InvalidRequest), this method is executed.
20
20
  def handle_request_error(exception)
21
-
22
21
  if Rails.env.development? || Rails.env.test?
23
22
  raise exception # Rails own code will catch and give usual Rails error page with stack trace
24
23
  else
@@ -57,7 +57,6 @@ module Blacklight::Bookmarks
57
57
  end
58
58
  end
59
59
 
60
-
61
60
  def update
62
61
  create
63
62
  end
@@ -135,6 +134,7 @@ module Blacklight::Bookmarks
135
134
  end
136
135
 
137
136
  protected
137
+
138
138
  def verify_user
139
139
  unless current_or_guest_user or (action == "index" and token_or_current_or_guest_user)
140
140
  flash[:notice] = I18n.t('blacklight.bookmarks.need_login') and raise Blacklight::Exceptions::AccessDenied
@@ -103,6 +103,7 @@ module Blacklight::Catalog
103
103
  end
104
104
 
105
105
  protected
106
+
106
107
  #
107
108
  # non-routable methods ->
108
109
  #
@@ -178,9 +179,6 @@ module Blacklight::Catalog
178
179
  # By default, any search action from a Blacklight::Catalog controller
179
180
  # should use the current controller when constructing the route.
180
181
  def search_action_url options = {}
181
- raise ArgumentError, "Options was not a hash (#{options.class}" unless options.is_a? Hash
182
- # We don't want to permit here because one of the options could be :only_path, which is an option, but not a parameter
183
- # options.permit!
184
182
  url_for(options.merge(action: 'index'))
185
183
  end
186
184
 
@@ -206,14 +204,13 @@ module Blacklight::Catalog
206
204
  end
207
205
 
208
206
  def validate_sms_params
209
- case
210
- when params[:to].blank?
207
+ if params[:to].blank?
211
208
  flash[:error] = I18n.t('blacklight.sms.errors.to.blank')
212
- when params[:carrier].blank?
209
+ elsif params[:carrier].blank?
213
210
  flash[:error] = I18n.t('blacklight.sms.errors.carrier.blank')
214
- when params[:to].gsub(/[^\d]/, '').length != 10
211
+ elsif params[:to].gsub(/[^\d]/, '').length != 10
215
212
  flash[:error] = I18n.t('blacklight.sms.errors.to.invalid', :to => params[:to])
216
- when !sms_mappings.values.include?(params[:carrier])
213
+ elsif !sms_mappings.values.include?(params[:carrier])
217
214
  flash[:error] = I18n.t('blacklight.sms.errors.carrier.invalid')
218
215
  end
219
216
 
@@ -225,10 +222,9 @@ module Blacklight::Catalog
225
222
  end
226
223
 
227
224
  def validate_email_params
228
- case
229
- when params[:to].blank?
225
+ if params[:to].blank?
230
226
  flash[:error] = I18n.t('blacklight.email.errors.to.blank')
231
- when !params[:to].match(defined?(Devise) ? Devise.email_regexp : /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/)
227
+ elsif !params[:to].match(defined?(Devise) ? Devise.email_regexp : /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/)
232
228
  flash[:error] = I18n.t('blacklight.email.errors.to.invalid', :to => params[:to])
233
229
  end
234
230
 
@@ -2,8 +2,9 @@
2
2
  # Filters added to this controller apply to all controllers in the hosting application
3
3
  # as this module is mixed-in to the application controller in the hosting app on installation.
4
4
  module Blacklight::Controller
5
-
6
5
  extend ActiveSupport::Concern
6
+ extend Deprecation
7
+ self.deprecation_horizon = 'blacklight 7.x'
7
8
 
8
9
  included do
9
10
  include Blacklight::SearchFields
@@ -22,24 +23,20 @@ module Blacklight::Controller
22
23
  # extra head content
23
24
  helper_method :has_user_authentication_provider?
24
25
  helper_method :blacklight_config, :blacklight_configuration_context
25
- helper_method :search_action_url, :search_action_path, :search_facet_url
26
+ helper_method :search_action_url, :search_action_path, :search_facet_url, :search_facet_path
26
27
  helper_method :search_state
27
28
 
28
-
29
29
  # This callback runs when a user first logs in
30
30
 
31
31
  define_callbacks :logging_in_user
32
32
  set_callback :logging_in_user, :before, :transfer_guest_user_actions_to_current_user
33
-
34
33
  end
35
34
 
36
35
  def default_catalog_controller
37
36
  CatalogController
38
37
  end
39
38
 
40
- def blacklight_config
41
- default_catalog_controller.blacklight_config
42
- end
39
+ delegate :blacklight_config, to: :default_catalog_controller
43
40
 
44
41
  protected
45
42
 
@@ -88,6 +85,13 @@ module Blacklight::Controller
88
85
  opts = search_state.to_h.merge(action: "facet").merge(options).except(:page)
89
86
  url_for opts
90
87
  end
88
+ deprecation_deprecate search_facet_url: 'Use search_facet_path instead.'
89
+
90
+ def search_facet_path(options = {})
91
+ Deprecation.silence(Blacklight::Controller) do
92
+ search_facet_url(options.merge(only_path: true))
93
+ end
94
+ end
91
95
 
92
96
  # Returns a list of Searches from the ids in the user's history.
93
97
  def searches_from_history
@@ -20,21 +20,26 @@ module Blacklight
20
20
  add_nav_action(:search_history, partial: 'blacklight/nav/search_history')
21
21
  end
22
22
 
23
- def render_sms_action? config, options = {}
23
+ def render_sms_action?(_config, _options)
24
24
  sms_mappings.present?
25
25
  end
26
26
 
27
27
  module ClassMethods
28
+ # YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
29
+ # rubocop:disable Metrics/LineLength
30
+
31
+ # @!macro partial_if_unless
32
+ # @param name [String] the name of the document partial
33
+ # @param opts [Hash]
34
+ # @option opts [Symbol,Proc] :if render this action if the method identified by the symbol or the proc evaluates to true. The proc will receive the action configuration and the document or documents for the action.
35
+ # @option opts [Symbol,Proc] :unless render this action unless the method identified by the symbol or the proc evaluates to true. The proc will receive the action configuration and the document or documents for the action.
28
36
 
29
- ##
30
37
  # Add a partial to the tools for rendering a document
31
- # @param partial [String] the name of the document partial
32
- # @param opts [Hash]
33
- # @option opts [Symbol,Proc] :if render this action if the method identified by the symbol or the proc evaluates to true.
34
- # The proc will receive the action configuration and the document or documents for the action.
35
- # @option opts [Symbol,Proc] :unless render this action unless the method identified by the symbol or the proc evaluates to true
36
- # The proc will receive the action configuration and the document or documents for the action.
37
- def add_show_tools_partial name, opts = {}
38
+ # @!macro partial_if_unless
39
+ # @option opts [Boolean] :define_method define a controller method as named, default: true
40
+ # @option opts [Symbol] :validator method for toggling between success and failure, should return Boolean (true if valid)
41
+ # @option opts [Symbol] :callback method for further processing of documents, receives Array of documents
42
+ def add_show_tools_partial(name, opts = {})
38
43
  blacklight_config.add_show_tools_partial(name, opts)
39
44
 
40
45
  return if method_defined?(name) || opts[:define_method] == false
@@ -43,9 +48,8 @@ module Blacklight
43
48
  define_method name do
44
49
  @response, @documents = action_documents
45
50
 
46
- if request.post? and
47
- opts[:callback] and
48
- (opts[:validator].blank? || self.send(opts[:validator]))
51
+ if request.post? && opts[:callback] &&
52
+ (opts[:validator].blank? || self.send(opts[:validator]))
49
53
 
50
54
  self.send(opts[:callback], @documents)
51
55
 
@@ -63,40 +67,23 @@ module Blacklight
63
67
  end
64
68
  end
65
69
  end
70
+ # rubocop:enable Metrics/LineLength
66
71
 
67
- ##
68
72
  # Add a tool to be displayed for each document in the search results.
69
- # @param partial [String] the name of the document partial
70
- # @param opts [Hash]
71
- # @option opts [Symbol,Proc] :if render this action if the method identified by the symbol or the proc evaluates to true.
72
- # The proc will receive the action configuration and the document or documents for the action.
73
- # @option opts [Symbol,Proc] :unless render this action unless the method identified by the symbol or the proc evaluates to true
74
- # The proc will receive the action configuration and the document or documents for the action.
75
- def add_results_document_tool name, opts = {}
73
+ # @!macro partial_if_unless
74
+ def add_results_document_tool(name, opts = {})
76
75
  blacklight_config.add_results_document_tool(name, opts)
77
76
  end
78
77
 
79
- ##
80
78
  # Add a tool to be displayed for the list of search results themselves.
81
- # @param partial [String] the name of the document partial
82
- # @param opts [Hash]
83
- # @option opts [Symbol,Proc] :if render this action if the method identified by the symbol or the proc evaluates to true.
84
- # The proc will receive the action configuration and the document or documents for the action.
85
- # @option opts [Symbol,Proc] :unless render this action unless the method identified by the symbol or the proc evaluates to true
86
- # The proc will receive the action configuration and the document or documents for the action.
87
- def add_results_collection_tool name, opts = {}
79
+ # @!macro partial_if_unless
80
+ def add_results_collection_tool(name, opts = {})
88
81
  blacklight_config.add_results_collection_tool(name, opts)
89
82
  end
90
83
 
91
- ##
92
- # Add a partial to the header navbar
93
- # @param partial [String] the name of the document partial
94
- # @param opts [Hash]
95
- # @option opts [Symbol,Proc] :if render this action if the method identified by the symbol or the proc evaluates to true.
96
- # The proc will receive the action configuration and the document or documents for the action.
97
- # @option opts [Symbol,Proc] :unless render this action unless the method identified by the symbol or the proc evaluates to true
98
- # The proc will receive the action configuration and the document or documents for the action.
99
- def add_nav_action name, opts = {}
84
+ # Add a partial to the header navbar.
85
+ # @!macro partial_if_unless
86
+ def add_nav_action(name, opts = {})
100
87
  blacklight_config.add_nav_action(name, opts)
101
88
  end
102
89
  end
@@ -4,6 +4,8 @@ module Blacklight
4
4
  # They are only dependent on `blacklight_config` and `@response`
5
5
  #
6
6
  module Facet
7
+ delegate :facet_configuration_for_field, to: :blacklight_config
8
+
7
9
  def facet_paginator(field_config, display_facet)
8
10
  blacklight_config.facet_paginator_class.new(
9
11
  display_facet.items,
@@ -22,17 +24,6 @@ module Blacklight
22
24
  blacklight_config.facet_fields.values.map(&:field)
23
25
  end
24
26
 
25
- # @param [String] field Solr facet name
26
- # @return [Blacklight::Configuration::FacetField] Blacklight facet configuration for the solr field
27
- def facet_configuration_for_field(field)
28
- # short-circuit on the common case, where the solr field name and the blacklight field name are the same.
29
- return blacklight_config.facet_fields[field] if blacklight_config.facet_fields[field] && blacklight_config.facet_fields[field].field == field
30
-
31
- # Find the facet field configuration for the solr field, or provide a default.
32
- blacklight_config.facet_fields.values.find { |v| v.field.to_s == field.to_s } ||
33
- Blacklight::Configuration::FacetField.new(field: field).normalize!
34
- end
35
-
36
27
  # Get a FacetField object from the @response
37
28
  def facet_by_field_name(field_or_field_name)
38
29
  case field_or_field_name
@@ -10,9 +10,7 @@ module Blacklight
10
10
  end
11
11
 
12
12
  # Override this method to use a search builder other than the one in the config
13
- def search_builder_class
14
- blacklight_config.search_builder_class
15
- end
13
+ delegate :search_builder_class, to: :blacklight_config
16
14
 
17
15
  def search_builder
18
16
  search_builder_class.new(self)
@@ -6,7 +6,6 @@ module Blacklight::SearchContext
6
6
  # own controller.
7
7
  included do
8
8
  helper_method :current_search_session, :search_session
9
-
10
9
  end
11
10
 
12
11
  module ClassMethods
@@ -13,9 +13,9 @@
13
13
  # [:qt]
14
14
  # "search", # Solr qt param, request handler, usually can be left blank; defaults to nil if not explicitly specified
15
15
  # [:solr_parameters]
16
- # {:qf => "something"} # optional hash of additional parameters to pass to solr for searches on this field.
16
+ # { :qf => "something" } # optional hash of additional parameters to pass to solr for searches on this field.
17
17
  # [:solr_local_parameters]
18
- # {:qf => "$something"} # optional hash of additional parameters that will be passed using Solr LocalParams syntax, that can use dollar sign to reference other solr variables.
18
+ # { :qf => "$something" } # optional hash of additional parameters that will be passed using Solr LocalParams syntax, that can use dollar sign to reference other solr variables.
19
19
  # [:include_in_simple_select]
20
20
  # false. Defaults to true, but you can set to false to have a search field defined for deep-links or BL extensions, but not actually included in the HTML select for simple search choice.
21
21
  #
@@ -1,13 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
  # SearchHelper is a controller layer mixin. It is in the controller scope: request params, session etc.
3
- #
3
+ #
4
4
  # NOTE: Be careful when creating variables here as they may be overriding something that already exists.
5
5
  # The ActionController docs: http://api.rubyonrails.org/classes/ActionController/Base.html
6
6
  #
7
7
  # Override these methods in your own controller for customizations:
8
- #
8
+ #
9
9
  # class CatalogController < ActionController::Base
10
- #
11
10
  # include Blacklight::Catalog
12
11
  #
13
12
  # def repository_class
@@ -21,7 +20,6 @@
21
20
  # end
22
21
  #
23
22
  # class CatalogController < ActionController::Base
24
- #
25
23
  # include Blacklight::Catalog
26
24
  # include LocalSearchHelperExtension
27
25
  #
@@ -50,23 +48,19 @@ module Blacklight::SearchHelper
50
48
 
51
49
  # a solr query method
52
50
  # @param [Hash] user_params ({}) the user provided parameters (e.g. query, facets, sort, etc)
53
- # @yield [search_builder] optional block yields configured SearchBuilder, caller can modify or create new SearchBuilder to be used. Block should return SearchBuilder to be used.
51
+ # @yield [search_builder] optional block yields configured SearchBuilder, caller can modify or create new SearchBuilder to be used. Block should return SearchBuilder to be used.
54
52
  # @return [Blacklight::Solr::Response] the solr response object
55
53
  def search_results(user_params)
56
54
  builder = search_builder.with(user_params)
57
- builder.page(user_params[:page]) if user_params[:page]
58
- builder.rows(user_params[:per_page] || user_params[:rows]) if user_params[:per_page] or user_params[:rows]
59
-
60
- if block_given?
61
- builder = yield(builder)
62
- end
55
+ builder.page = user_params[:page] if user_params[:page]
56
+ builder.rows = (user_params[:per_page] || user_params[:rows]) if user_params[:per_page] || user_params[:rows]
63
57
 
58
+ builder = yield(builder) if block_given?
64
59
  response = repository.search(builder)
65
60
 
66
- case
67
- when (response.grouped? && grouped_key_for_results)
61
+ if response.grouped? && grouped_key_for_results
68
62
  [response.group(grouped_key_for_results), []]
69
- when (response.grouped? && response.grouped.length == 1)
63
+ elsif response.grouped? && response.grouped.length == 1
70
64
  [response.grouped.first, []]
71
65
  else
72
66
  [response, response.documents]
@@ -74,8 +68,9 @@ module Blacklight::SearchHelper
74
68
  end
75
69
 
76
70
  # retrieve a document, given the doc id
71
+ # @param [Array{#to_s},#to_s] id
77
72
  # @return [Blacklight::Solr::Response, Blacklight::SolrDocument] the solr response object and the first document
78
- def fetch(id=nil, extra_controller_params={})
73
+ def fetch(id = nil, extra_controller_params = {})
79
74
  if id.is_a? Array
80
75
  fetch_many(id, search_state.to_h, extra_controller_params)
81
76
  else
@@ -95,26 +90,23 @@ module Blacklight::SearchHelper
95
90
  # @return [Blacklight::Solr::Response, Array<Blacklight::SolrDocument>] the solr response and a list of the first and last document
96
91
  def get_previous_and_next_documents_for_search(index, request_params, extra_controller_params={})
97
92
  p = previous_and_next_document_params(index)
98
-
99
93
  query = search_builder.with(request_params).start(p.delete(:start)).rows(p.delete(:rows)).merge(extra_controller_params).merge(p)
100
94
  response = repository.search(query)
101
-
102
95
  document_list = response.documents
103
96
 
104
97
  # only get the previous doc if there is one
105
98
  prev_doc = document_list.first if index > 0
106
99
  next_doc = document_list.last if (index + 1) < response.total
107
-
108
100
  [response, [prev_doc, next_doc]]
109
101
  end
110
-
102
+
111
103
  # a solr query method
112
104
  # does a standard search but returns a simplified object.
113
105
  # an array is returned, the first item is the query string,
114
106
  # the second item is an other array. This second array contains
115
107
  # all of the field values for each of the documents...
116
108
  # where the field is the "field" argument passed in.
117
- def get_opensearch_response(field=nil, request_params = params || {}, extra_controller_params={})
109
+ def get_opensearch_response(field = nil, request_params = params || {}, extra_controller_params = {})
118
110
  field ||= blacklight_config.view_config('opensearch').title_field
119
111
 
120
112
  query = search_builder.with(request_params).merge(solr_opensearch_params(field)).merge(extra_controller_params)
@@ -124,14 +116,12 @@ module Blacklight::SearchHelper
124
116
  end
125
117
 
126
118
  ##
127
- # The key to use to retrieve the grouped field to display
119
+ # The key to use to retrieve the grouped field to display
128
120
  def grouped_key_for_results
129
121
  blacklight_config.index.group
130
122
  end
131
123
 
132
- def repository_class
133
- blacklight_config.repository_class
134
- end
124
+ delegate :repository_class, to: :blacklight_config
135
125
 
136
126
  def repository
137
127
  repository_class.new(blacklight_config)