blacklight 5.1.1 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/VERSION +1 -1
  4. data/app/assets/javascripts/blacklight/search_context.js +38 -24
  5. data/app/helpers/blacklight/blacklight_helper_behavior.rb +49 -70
  6. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -8
  7. data/app/helpers/blacklight/configuration_helper_behavior.rb +10 -2
  8. data/app/helpers/blacklight/facets_helper_behavior.rb +4 -1
  9. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +2 -2
  10. data/app/helpers/blacklight/url_helper_behavior.rb +41 -7
  11. data/app/views/catalog/_facet_layout.html.erb +2 -2
  12. data/app/views/catalog/_per_page_widget.html.erb +4 -4
  13. data/app/views/catalog/_previous_next_doc.html.erb +1 -1
  14. data/app/views/catalog/_show_tools.html.erb +1 -1
  15. data/app/views/catalog/show.html.erb +1 -1
  16. data/app/views/layouts/blacklight.html.erb +1 -1
  17. data/blacklight.gemspec +1 -1
  18. data/config/jetty.yml +3 -0
  19. data/config/locales/blacklight.es.yml +220 -0
  20. data/gemfiles/rails4.1.gemfile +10 -0
  21. data/lib/blacklight/base.rb +1 -1
  22. data/lib/blacklight/catalog/search_context.rb +15 -15
  23. data/lib/blacklight/catalog.rb +19 -6
  24. data/lib/blacklight/configuration.rb +126 -31
  25. data/lib/blacklight/document_presenter.rb +168 -0
  26. data/lib/blacklight/request_builders.rb +288 -0
  27. data/lib/blacklight/routes.rb +6 -2
  28. data/lib/blacklight/solr/request.rb +1 -1
  29. data/lib/blacklight/solr_helper.rb +50 -323
  30. data/lib/blacklight/solr_response/facets.rb +7 -3
  31. data/lib/blacklight/utils.rb +39 -7
  32. data/lib/blacklight.rb +5 -3
  33. data/lib/generators/blacklight/install_generator.rb +17 -5
  34. data/lib/generators/blacklight/models_generator.rb +0 -1
  35. data/lib/generators/blacklight/templates/catalog_controller.rb +6 -0
  36. data/lib/generators/blacklight/templates/config/jetty.yml +8 -4
  37. data/lib/generators/blacklight/templates/config/solr.yml +2 -0
  38. data/spec/controllers/catalog_controller_spec.rb +41 -22
  39. data/spec/features/alternate_controller_spec.rb +1 -1
  40. data/spec/features/search_filters_spec.rb +24 -24
  41. data/spec/features/search_results_spec.rb +9 -4
  42. data/spec/features/search_sort_spec.rb +1 -1
  43. data/spec/helpers/blacklight_helper_spec.rb +87 -0
  44. data/spec/helpers/catalog_helper_spec.rb +5 -10
  45. data/spec/helpers/configuration_helper_spec.rb +22 -1
  46. data/spec/helpers/facets_helper_spec.rb +6 -0
  47. data/spec/helpers/render_constraints_helper_spec.rb +1 -2
  48. data/spec/helpers/url_helper_spec.rb +45 -2
  49. data/spec/lib/blacklight/routes_spec.rb +4 -4
  50. data/spec/lib/blacklight/solr_helper_spec.rb +364 -253
  51. data/spec/lib/blacklight/solr_response/facets_spec.rb +82 -0
  52. data/spec/lib/blacklight/solr_response_spec.rb +3 -1
  53. data/spec/lib/document_presenter_spec.rb +216 -0
  54. data/spec/lib/utils_spec.rb +8 -0
  55. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  56. data/spec/views/catalog/index.html.erb_spec.rb +29 -21
  57. data/spec/views/catalog/show.html.erb_spec.rb +11 -7
  58. data/template.demo.rb +20 -0
  59. metadata +12 -4
  60. data/lib/generators/blacklight/jetty_generator.rb +0 -70
@@ -0,0 +1,220 @@
1
+ es:
2
+ views:
3
+ pagination:
4
+ first: '« Primero'
5
+ last: 'Ultimo »'
6
+ previous: '« Anterior'
7
+ next: 'Siguiente »'
8
+ truncate: '…'
9
+
10
+ pagination_compact:
11
+ previous: '« Anterior'
12
+ next: 'Siguiente »'
13
+
14
+ blacklight:
15
+ application_name: 'Blacklight'
16
+
17
+ header_links:
18
+ login: 'Entrar'
19
+ logout: 'Salir'
20
+ bookmarks: 'Favoritos'
21
+ saved_searches: 'Búsquedas guardadas'
22
+ search_history: 'Historia'
23
+
24
+ welcome: '¡Bienvenido!'
25
+ and: 'y'
26
+ or: 'o'
27
+
28
+ bookmarks:
29
+ title: 'Favoritos'
30
+ no_bookmarks: 'Usted no tiene favoritos'
31
+ add:
32
+ button: 'Favoritos'
33
+ success:
34
+ one: 'Éxito al añadir su favorito.'
35
+ other: 'Éxito añadido favorito.'
36
+ failure: 'Lo siento, hubo un problema al guardar los favoritos.'
37
+ remove:
38
+ button: 'Borrar favorito'
39
+ success: 'Borrado favorito.'
40
+ failure: 'Lo siento, hubo un problema al borrar los favoritos.'
41
+ action_confirm: '¿Quitar este favorito?'
42
+ clear:
43
+ action_title: 'Borrar favorito'
44
+ action_confirm: '¿Borrar sus favoritos?'
45
+ success: 'Se borraron sus favoritos.'
46
+ failure: 'Lo siento, hubo un problema al borrar sus favoritos.'
47
+ need_login: 'Por favor, inicie sesión para administrar y ver sus favoritos.'
48
+ list_title: 'Mis Favoritos'
49
+ delete: 'Borrar'
50
+
51
+ saved_searches:
52
+ add:
53
+ success: 'Éxito al añadir su búsqueda.'
54
+ failure: 'Hubo un problema al guardar su búsqueda.'
55
+ remove:
56
+ success: 'Éxito al borrar su búsqueda.'
57
+ failure: 'Lo siento, hubo un problema al borrar su busqueda.'
58
+ clear:
59
+ action_title: 'Borrar Búsquedas Guardadas'
60
+ action_confirm: '¿Borrar Búsquedas Guardadas?'
61
+ success: 'Se borraron sus búsquedas guardadas'
62
+ failure: 'Hubo un problema al borrar sus búsquedas.'
63
+ title: 'Búsquedas guardadas'
64
+ need_login: 'Por favor, inicie sesión para administrar y ver sus búsquedas guardadas.'
65
+ no_searches: 'No tienes búsquedas guardadas'
66
+ list_title: 'Sus búsquedas guardadas'
67
+ delete: 'Borrar'
68
+
69
+ search_history:
70
+ clear:
71
+ action_title: 'Borrar historial de búsqueda'
72
+ action_confirm: '¿Borrar el historial de búsqueda?'
73
+ success: 'Se borro el historial de búsqueda.'
74
+ failure: 'Hubo un problema al borrar su historial de búsqueda.'
75
+ title: 'Historia'
76
+ no_history: 'Usted no tiene historial de búsqueda'
77
+ recent: 'Sus búsquedas recientes'
78
+ forget: 'Olvidar'
79
+ save: 'Guardar'
80
+
81
+ tools:
82
+ title: 'Herramientas'
83
+ cite: 'Cité'
84
+ endnote: 'Exportar a EndNote'
85
+ refworks: 'Exportar a Refworks'
86
+ email: 'Correo electrónico'
87
+ sms: 'Enviar SMS'
88
+ clear: 'Borrar'
89
+
90
+ citation:
91
+ mla: 'MLA'
92
+ apa: 'APA'
93
+ chicago: 'Chicago'
94
+
95
+ email:
96
+ form:
97
+ title: 'Enviar'
98
+ to: 'Email:'
99
+ message: 'Mensaje:'
100
+ submit: 'Enviar'
101
+ text:
102
+ title: 'Titulo: %{value}'
103
+ author: 'Autor: %{value}'
104
+ format: 'Formato: %{value}'
105
+ language: 'Idioma: %{value}'
106
+ subject:
107
+ one: 'Ficha artículo: %{title}'
108
+ other: 'Ficha artículos'
109
+ url: 'URL: %{url}'
110
+ message: 'Mensaje: %{message}'
111
+
112
+ success: "Email enviado"
113
+
114
+ errors:
115
+ to:
116
+ invalid: 'Debe entrar un email válido'
117
+ blank: 'Debe introducir un destinatario para enviar este mensaje'
118
+ sms:
119
+ form:
120
+ title: 'Enviar SMS'
121
+ to: 'Número de teléfono:'
122
+ carrier: 'Compañía telefónica'
123
+ carrier_prompt: 'Por favor, seleccione su compañía telefónica'
124
+ submit: 'Enviar'
125
+ text:
126
+ title: '%{value}'
127
+ author: 'por %{value}'
128
+ url: 'Link: %{url}'
129
+ success: "SMS enviado"
130
+ errors:
131
+ to:
132
+ invalid: 'Debe entrar un número de teléfono válido de 10 dígitos'
133
+ blank: "Debe introducir el número de teléfono del destinatario para enviar este mensaj"
134
+ carrier:
135
+ blank: 'Debe seleccionar compañía telefónica'
136
+ invalid: "Debe entrar una compañía telefónica válida"
137
+
138
+ back_to_search: 'Volver a Buscar'
139
+ back_to_bookmarks: 'Volver a sus favoritos'
140
+
141
+ search:
142
+ title: '%{application_name} Resultados de la búsqueda'
143
+ search_results_header: 'Buscar'
144
+ search_results: 'Resultados de la búsqueda'
145
+ errors:
146
+ request_error: "Lo siento, no entiendo esta búsqueda"
147
+ invalid_solr_id: "Lo sentimos, usted ha solicitado un registro que no existe."
148
+ per_page:
149
+ label: '%{count}<span class="sr-only"> por página</span>'
150
+ button_label: '%{count} por página'
151
+ title: 'El número de resultados a mostrar por página'
152
+ submit: 'Actualización'
153
+ sort:
154
+ label: 'Ordenar por %{field}'
155
+ submit: 'Resultados de ordenación'
156
+ form:
157
+ search_field:
158
+ label: 'Buscar en'
159
+ title: 'Opciones de Búsqueda temática'
160
+ post_label: 'para'
161
+ q: 'Buscar...'
162
+ submit: 'Buscar'
163
+ pagination:
164
+ title: 'Resultados de navegación'
165
+ pagination_info:
166
+ no_items_found: 'No %{entry_name} encontrado'
167
+ single_item_found: '<strong>1</strong> %{entry_name} encontrado'
168
+ pages:
169
+ one: '<strong>%{start_num}</strong> - <strong>%{end_num}</strong> de <strong>%{total_num}</strong>'
170
+ other: '<strong>%{start_num}</strong> - <strong>%{end_num}</strong> de <strong>%{total_num}</strong>'
171
+ entry_pagination_info:
172
+ one: '<strong>1 de 1</strong>'
173
+ other: '<strong>%{current}</strong> de <strong>%{total}</strong>'
174
+ documents:
175
+ counter: '%{counter}.'
176
+ facets:
177
+ title: 'Limite su búsqueda'
178
+ sort:
179
+ count: 'Ordenación numérica'
180
+ index: 'Ordenación A-Z'
181
+ count: '%{number}'
182
+ more: 'más »'
183
+ selected:
184
+ remove: '[borrar]'
185
+ group:
186
+ more: 'más »'
187
+ filters:
188
+ title: 'Usted ha buscado:'
189
+ label: '%{label}:'
190
+ remove:
191
+ value: 'Eliminar la restricción %{value}'
192
+ label_value: 'Eliminar la restricción%{label}: %{value}'
193
+ start_over: 'Volver a empezar'
194
+ index:
195
+ label: '%{label}:'
196
+ show:
197
+ title: '%{document_title} - %{application_name}'
198
+ label: '%{label}:'
199
+ rss_feed: 'RSS de los resultados'
200
+ atom_feed: 'Atom de los resultados'
201
+ fields:
202
+ default: 'Palabra clave'
203
+ bookmarks:
204
+ present: "En Favoritos"
205
+ absent: "Favoritos"
206
+ inprogress: "Guardando..."
207
+ zero_results:
208
+ title: "No se han encontrado resultados para su búsqueda"
209
+ modify_search: "Intente modificar su búsqueda"
210
+ use_fewer_keywords: "Use menos palabras para empezar, y luego refinar la búsqueda utilizando los enlaces de la izquierda."
211
+ search_fields: "Usted busco por %{search_fields}"
212
+ search_everything: "Pruebe a buscar de todo"
213
+ view_title: "Ver Resultados por: "
214
+ view:
215
+ list: "Lista"
216
+
217
+ entry_name:
218
+ default: 'entrada'
219
+
220
+ did_you_mean: '¿Quiere decir %{options}?'
@@ -0,0 +1,10 @@
1
+ source 'http://rubygems.org'
2
+
3
+ file = File.expand_path("../../Gemfile", __FILE__)
4
+
5
+ if File.exists?(file)
6
+ puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
7
+ instance_eval File.read(file)
8
+ end
9
+
10
+ gem 'rails', '4.1.0.rc1'
@@ -20,7 +20,7 @@ module Blacklight::Base
20
20
  # when solr (RSolr) throws an error (RSolr::RequestError), this method is executed.
21
21
  def rsolr_request_error(exception)
22
22
 
23
- if Rails.env.development?
23
+ if Rails.env.development? || Rails.env.test?
24
24
  raise exception # Rails own code will catch and give usual Rails error page with stack trace
25
25
  else
26
26
 
@@ -6,17 +6,17 @@ module Blacklight::Catalog::SearchContext
6
6
  # own controller.
7
7
  included do
8
8
  helper_method :current_search_session, :search_session
9
- before_filter :search_session, :history_session, :current_search_session
9
+
10
10
  end
11
-
12
- protected
13
11
 
14
- # sets up the session[:history] hash if it doesn't already exist.
15
- # assigns all Search objects (that match the searches in session[:history]) to a variable @searches.
16
- def history_session
17
- session[:history] ||= []
18
- @searches = searches_from_history # <- in BlacklightController
12
+ module ClassMethods
13
+ # Save the submitted search parameters in the search session
14
+ def record_search_parameters opts = { only: :index}
15
+ before_filter :current_search_session, opts
16
+ end
19
17
  end
18
+
19
+ protected
20
20
 
21
21
  # sets up the session[:search] hash if it doesn't already exist
22
22
  def search_session
@@ -37,15 +37,15 @@ module Blacklight::Catalog::SearchContext
37
37
  rescue ActiveRecord::RecordNotFound
38
38
  nil
39
39
  end
40
- elsif search_session[:id]
40
+ elsif search_session['id']
41
41
  begin
42
- searches_from_history.find(search_session[:id])
42
+ searches_from_history.find(search_session['id'])
43
43
  rescue ActiveRecord::RecordNotFound
44
44
  nil
45
45
  end
46
46
  end
47
47
 
48
- search_session[:id] = @current_search_session.id if @current_search_session
48
+ search_session['id'] = @current_search_session.id if @current_search_session
49
49
 
50
50
  @current_search_session
51
51
  end
@@ -92,11 +92,11 @@ module Blacklight::Catalog::SearchContext
92
92
  # calls setup_previous_document then setup_next_document.
93
93
  # used in the show action for single view pagination.
94
94
  def setup_next_and_previous_documents
95
- if search_session[:counter] and current_search_session
96
- index = search_session[:counter].to_i - 1
97
- response, documents = get_previous_and_next_documents_for_search index, current_search_session.query_params
95
+ if search_session['counter'] and current_search_session
96
+ index = search_session['counter'].to_i - 1
97
+ response, documents = get_previous_and_next_documents_for_search index, current_search_session.query_params.with_indifferent_access
98
98
 
99
- search_session[:total] = response.total
99
+ search_session['total'] = response.total
100
100
  @search_context_response = response
101
101
  @previous_document = documents.first
102
102
  @next_document = documents.last
@@ -9,19 +9,20 @@ module Blacklight::Catalog
9
9
  # The following code is executed when someone includes blacklight::catalog in their
10
10
  # own controller.
11
11
  included do
12
- helper_method :sms_mappings
12
+ helper_method :sms_mappings, :has_search_parameters?
13
13
 
14
14
  # Whenever an action raises SolrHelper::InvalidSolrID, this block gets executed.
15
15
  # Hint: the SolrHelper #get_solr_response_for_doc_id method raises this error,
16
16
  # which is used in the #show action here.
17
17
  rescue_from Blacklight::Exceptions::InvalidSolrID, :with => :invalid_solr_id_error
18
+
19
+ record_search_parameters
18
20
  end
19
21
 
20
22
  # get search results from the solr index
21
23
  def index
22
24
 
23
25
  (@response, @document_list) = get_search_results
24
- @filters = params[:f] || []
25
26
 
26
27
  respond_to do |format|
27
28
  format.html { }
@@ -56,11 +57,16 @@ module Blacklight::Catalog
56
57
  end
57
58
 
58
59
  # updates the search counter (allows the show view to paginate)
59
- def update
60
- search_session[:counter] = params[:counter]
61
- redirect_to :action => "show", :status => 303
60
+ def track
61
+ search_session['counter'] = params[:counter]
62
+ path = if params[:redirect] and (params[:redirect].starts_with?("/") or params[:redirect] =~ URI::regexp)
63
+ URI.parse(params[:redirect]).path
64
+ else
65
+ { action: 'show' }
66
+ end
67
+ redirect_to path, :status => 303
62
68
  end
63
-
69
+
64
70
  # displays values and pagination links for a single facet field
65
71
  def facet
66
72
  @facet = blacklight_config.facet_fields[params[:id]]
@@ -149,6 +155,13 @@ module Blacklight::Catalog
149
155
  format.html
150
156
  end
151
157
  end
158
+
159
+ ##
160
+ # Check if any search parameters have been set
161
+ # @return [Boolean]
162
+ def has_search_parameters?
163
+ !params[:q].blank? or !params[:f].blank? or !params[:search_field].blank?
164
+ end
152
165
 
153
166
  protected
154
167
  #
@@ -5,6 +5,13 @@ module Blacklight
5
5
  class Configuration < OpenStructWithHashAccess
6
6
 
7
7
  require 'blacklight/configuration/view_config'
8
+ # XXX this isn't very pretty, but it works.
9
+ require 'blacklight/configuration/fields'
10
+ require 'blacklight/configuration/solr_field'
11
+ require 'blacklight/configuration/search_field'
12
+ require 'blacklight/configuration/facet_field'
13
+ require 'blacklight/configuration/sort_field'
14
+ include Fields
8
15
 
9
16
  # Set up Blacklight::Configuration.default_values to contain
10
17
  # the basic, required Blacklight fields
@@ -14,45 +21,92 @@ module Blacklight
14
21
  unique_key = ((SolrDocument.unique_key if defined?(SolrDocument)) || 'id')
15
22
 
16
23
  {
17
- :solr_path => 'select',
24
+ # HTTP method to use when making requests to solr; valid
25
+ # values are :get and :post.
26
+ :http_method => :get,
27
+ # The solr request handler ('qt') to use for search requests
18
28
  :qt => 'search',
29
+ # The path to send requests to solr.
30
+ :solr_path => 'select',
31
+ # Default values of parameters to send with every search request
19
32
  :default_solr_params => {},
20
- :document_solr_request_handler => nil,
21
- :default_document_solr_params => {},
22
- :show => ViewConfig::Show.new(:partials => [:show_header, :show]),
23
- :index => ViewConfig::Index.new(:partials => [:index_header, :thumbnail, :index],
33
+ # The solr rqeuest handler to use when requesting only a single document
34
+ :document_solr_request_handler => 'document',
35
+ # THe path to send single document requests to solr
36
+ :document_solr_path => nil,
37
+ :document_unique_id_param => :id,
38
+ # Default values of parameters to send when requesting a single document
39
+ :default_document_solr_params => {
40
+ ## Blacklight provides these settings in the /document request handler
41
+ ## by default, we just ask for all fields.
42
+ #:fl => '*',
43
+ ## this is a fancy way to say "find the document by id using
44
+ ## the value in the id query parameter"
45
+ #:q => "{!raw f=#{unique_key} v=$id}",
46
+ ## disable features we don't need
47
+ #:facet => false,
48
+ #:rows => 1
49
+ },
50
+ # General configuration for all views
51
+ :index => ViewConfig::Index.new(
52
+ # solr field to use to render a document title
24
53
  :title_field => unique_key,
54
+ # solr field to use to render format-specific partials
25
55
  :display_type_field => 'format',
56
+ # partials to render for each document(see #render_document_partials)
57
+ :partials => [:index_header, :thumbnail, :index],
58
+ # what field, if any, to use to render grouped results
26
59
  :group => false,
60
+ # additional response formats for search results
27
61
  :respond_to => OpenStructWithHashAccess.new()
28
62
  ),
63
+ # Additional configuration when displaying a single document
64
+ :show => ViewConfig::Show.new(:partials => [:show_header, :show]),
65
+ # Configurations for specific types of index views
29
66
  :view => NestedOpenStructWithHashAccess.new(ViewConfig, 'list'),
67
+ # Maxiumum number of spelling suggestions to offer
30
68
  :spell_max => 5,
69
+ # Maximum number of results to show per page
31
70
  :max_per_page => 100,
71
+ # Options for the user for number of results to show per page
32
72
  :per_page => [10,20,50,100],
73
+ :default_per_page => nil,
74
+ # how many searches to save in session history
75
+ # (TODO: move the value into the configuration?)
33
76
  :search_history_window => Blacklight::Catalog::SearchHistoryWindow,
34
- :add_facet_fields_to_solr_request => false,
35
- :add_field_configuration_to_solr_request => false,
36
- :http_method => :get
77
+ ## deprecated; use add_facet_field :include_in_request instead;
78
+ # if this is configured true, all facets will be included in the solr request
79
+ # unless explicitly disabled.
80
+ :add_facet_fields_to_solr_request => false,
81
+ ## deprecated; use add_index_field :include_in_request instead;
82
+ # if this is configured true, all show and index will be included in the solr request
83
+ # unless explicitly disabled.
84
+ :add_field_configuration_to_solr_request => false
37
85
  }
38
86
  end
39
87
  end
40
88
  end
41
89
 
42
-
43
- # XXX this isn't very pretty, but it works.
44
- require 'blacklight/configuration/fields'
45
- require 'blacklight/configuration/solr_field'
46
- require 'blacklight/configuration/search_field'
47
- require 'blacklight/configuration/facet_field'
48
- require 'blacklight/configuration/sort_field'
49
- include Fields
50
-
51
- # Create collections of solr fields
90
+ ##
91
+ # Create collections of solr field configurations.
92
+ # This will create array-like accessor methods for
93
+ # the given field, and an #add_x_field convenience
94
+ # method for adding new fields to the configuration
95
+
96
+ # facet fields
52
97
  define_field_access :facet_field
98
+
99
+ # solr fields to display on search results
53
100
  define_field_access :index_field
101
+
102
+ # solr fields to display when showing single documents
54
103
  define_field_access :show_field
104
+
105
+ # solr "fields" to use for scoping user search queries
106
+ # to particular fields
55
107
  define_field_access :search_field
108
+
109
+ # solr fields to use for sorting results
56
110
  define_field_access :sort_field
57
111
 
58
112
  def initialize(*args)
@@ -70,6 +124,14 @@ module Blacklight
70
124
  end
71
125
  end
72
126
 
127
+ ##
128
+ # DSL helper
129
+ def configure
130
+ yield self if block_given?
131
+ self
132
+ end
133
+
134
+ ##
73
135
  # Returns default search field, used for simpler display in history, etc.
74
136
  # if not set, defaults to first defined search field
75
137
  def default_search_field
@@ -80,6 +142,7 @@ module Blacklight
80
142
  field
81
143
  end
82
144
 
145
+ ##
83
146
  # Returns default sort field, used for simpler display in history, etc.
84
147
  # if not set, defaults to first defined sort field
85
148
  def default_sort_field
@@ -90,20 +153,56 @@ module Blacklight
90
153
  field
91
154
  end
92
155
 
156
+ ##
93
157
  # Add any configured facet fields to the default solr parameters hash
94
- def add_facet_fields_to_solr_request!
95
- self.add_facet_fields_to_solr_request = true
158
+ # @overload add_facet_fields_to_solr_request!
159
+ # add all facet fields to the solr request
160
+ # @overload add_facet_fields_to_solr_request! field, field, field
161
+ # @param [Symbol] Field names to add to the solr request
162
+ # @param [Symbol]
163
+ # @param [Symbol]
164
+ def add_facet_fields_to_solr_request! *fields
165
+ if fields.empty?
166
+ self.add_facet_fields_to_solr_request = true
167
+ else
168
+ facet_fields.slice(*fields).each do |k,v|
169
+ v.include_in_request = true
170
+ end
171
+ end
96
172
  end
97
173
 
174
+ ##
98
175
  # Add any configured facet fields to the default solr parameters hash
99
- def add_field_configuration_to_solr_request!
100
- self.add_field_configuration_to_solr_request = true
176
+ # @overload add_field_configuration_to_solr_request!
177
+ # add all index, show, and facet fields to the solr request
178
+ # @overload add_field_configuration_to_solr_request! field, field, field
179
+ # @param [Symbol] Field names to add to the solr request
180
+ # @param [Symbol]
181
+ # @param [Symbol]
182
+ def add_field_configuration_to_solr_request! *fields
183
+ if fields.empty?
184
+ self.add_field_configuration_to_solr_request = true
185
+ else
186
+ index_fields.slice(*fields).each do |k,v|
187
+ v.include_in_request = true
188
+ end
189
+
190
+ show_fields.slice(*fields).each do |k,v|
191
+ v.include_in_request = true
192
+ end
193
+ facet_fields.slice(*fields).each do |k,v|
194
+ v.include_in_request = true
195
+ end
196
+ end
101
197
  end
102
198
 
199
+ ##
200
+ # Deprecated. Get the list of facet fields to explicitly
201
+ # add to the solr request
103
202
  def facet_fields_to_add_to_solr
104
- return facet_fields.reject { |k,v| v[:query] || v[:pivot] }.map { |k,v| v.field } if self.add_facet_fields_to_solr_request
105
-
106
- []
203
+ facet_fields.select { |k,v| v.include_in_request }
204
+ .reject { |k,v| v[:query] || v[:pivot] }
205
+ .map { |k,v| v.field }
107
206
  end
108
207
 
109
208
  ##
@@ -116,12 +215,8 @@ module Blacklight
116
215
  alias_method :inheritable_copy, :deep_copy
117
216
 
118
217
  ##
119
- # DSL helper
120
- def configure
121
- yield self if block_given?
122
- self
123
- end
124
-
218
+ # Get a view configuration for the given view type
219
+ # including default values from the index configuration
125
220
  def view_config view_type
126
221
  if view_type == :show
127
222
  self.index.merge self.show