blacklight 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +1 -0
  5. data/.travis.yml +14 -6
  6. data/Gemfile +2 -3
  7. data/README.md +3 -1
  8. data/VERSION +1 -1
  9. data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -0
  10. data/app/assets/stylesheets/blacklight/_dropdown.css.scss +2 -1
  11. data/app/assets/stylesheets/blacklight/_search_history.css.scss +1 -1
  12. data/app/assets/stylesheets/blacklight/blacklight.css.scss +2 -0
  13. data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +2 -0
  14. data/app/helpers/blacklight/blacklight_helper_behavior.rb +199 -48
  15. data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
  16. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
  17. data/app/views/catalog/_document_header.html.erb +1 -1
  18. data/app/views/catalog/_index_default.html.erb +3 -3
  19. data/app/views/catalog/_per_page_widget.html.erb +1 -1
  20. data/app/views/catalog/_show_default.html.erb +3 -3
  21. data/app/views/catalog/_sort_widget.html.erb +1 -1
  22. data/app/views/catalog/show.html.erb +29 -32
  23. data/app/views/layouts/blacklight.html.erb +1 -1
  24. data/blacklight.gemspec +1 -1
  25. data/config/locales/blacklight.fr.yml +236 -0
  26. data/gemfiles/rails3.gemfile +9 -0
  27. data/gemfiles/rails4.gemfile +10 -0
  28. data/lib/blacklight/catalog.rb +22 -10
  29. data/lib/blacklight/configurable.rb +2 -3
  30. data/lib/blacklight/configuration/fields.rb +5 -4
  31. data/lib/blacklight/mash.rb +7 -139
  32. data/lib/blacklight/routes.rb +19 -18
  33. data/lib/blacklight/solr_helper.rb +14 -11
  34. data/lib/blacklight/solr_response.rb +1 -1
  35. data/lib/generators/blacklight/blacklight_generator.rb +9 -1
  36. data/lib/generators/blacklight/test_support_generator.rb +15 -0
  37. data/test_support/bin/setup-test-app.sh +8 -12
  38. data/test_support/bin/test.sh +20 -24
  39. data/test_support/features/search.feature +0 -3
  40. data/test_support/features/search_pagination.feature +53 -0
  41. data/test_support/features/step_definitions/search_pagination_steps.rb +29 -0
  42. data/test_support/features/step_definitions/search_steps.rb +0 -11
  43. data/test_support/spec/controllers/catalog_controller_spec.rb +15 -80
  44. data/test_support/spec/helpers/blacklight_helper_spec.rb +75 -22
  45. data/test_support/spec/helpers/catalog_helper_spec.rb +8 -1
  46. data/test_support/spec/helpers/html_head_helper_spec.rb +21 -7
  47. data/test_support/spec/lib/blacklight_configurable_spec.rb +18 -4
  48. data/test_support/spec/lib/blacklight_configuration_spec.rb +28 -0
  49. data/test_support/spec/lib/solr_helper_spec.rb +14 -4
  50. data/test_support/spec/routing/catalog_routing_spec.rb +67 -0
  51. data/test_support/spec/views/catalog/index.atom.builder_spec.rb +3 -7
  52. metadata +42 -15
  53. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: fd53955e7766d24bb6321e2f1c8276115ef7489f
4
- data.tar.gz: 648c5e33395aa063a7b827e6c1418c12ab84aeae
5
- !binary "U0hBNTEy":
6
- metadata.gz: e73973c3a91c7dfbd0dabea81280af47be472a0c12a89dc37b3060db482d7325c3d564cd510ea006282dc1303838131e1c2bf1106f0a4b52fa983a0c1a660e27
7
- data.tar.gz: 63b8d103ae752c8cb697eb7c831501bb1b535fccdb2df53bb49c77546dd6e2f756bd904fb54eedfa65fef735ba9e9a9ec205a887ada8090149f8826f022d3fef
2
+ SHA1:
3
+ metadata.gz: 85237ab5ca9df6a7dceedb02ee41c653bea8f99b
4
+ data.tar.gz: d8e94fa7a2eb458e6e072f5b9178a59874d28672
5
+ SHA512:
6
+ metadata.gz: cd6f5b56a806020627da8539450d8b9e259960d8f6e74e1cfbc2b2be140868705c69f57edb245bcf3fa971aadef6ad3020c67b4c87d47c2a7d4a9d661767a01d
7
+ data.tar.gz: 3e1b35b3aa99e852e2d43c93135937d0ed4392b7356a08368768f0c2951cd756d0881147aa86e448957322ec2b3d44d5f3227fc4c40afb19eaf999257bed605e
@@ -0,0 +1,2 @@
1
+ H���&�]���]��g��D%��D7���y>�w�*j�燸�t��)+Yz �^���<c��Ҩzv}�u� �ς��/B�`�m��9�����VZ� �@�@�����sF�-^��
2
+ g籘𺍯�a
Binary file
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ tmp/test_app
19
19
  .rvmrc
20
20
  pkg/*
21
21
  *.sw[pon]
22
+ gemfiles/*.gemfile.lock
@@ -1,14 +1,22 @@
1
1
  notifications:
2
2
  email: false
3
-
3
+
4
4
  rvm:
5
- # - 1.8.7
6
5
  - 1.9.3
7
- # - rbx-2.0
8
- # - jruby
6
+ - jruby-19mode
7
+ - 2.0.0
9
8
 
10
- env:
11
- - RAILS_VERISON=3.2.8
9
+ gemfile:
10
+ - gemfiles/rails3.gemfile
11
+ - gemfiles/rails4.gemfile
12
12
 
13
13
  script:
14
14
  - test_support/bin/test.sh
15
+
16
+ notifications:
17
+ irc: "irc.freenode.org#blacklight"
18
+ email:
19
+ - blacklight-commits@googlegroups.com
20
+
21
+ before_install:
22
+ - gem install bundler
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source 'http://rubygems.org'
3
3
  # Please see blacklight.gemspec for dependency information.
4
4
  gemspec
5
5
 
6
- gem 'rcov', :platform => :mri_18
7
- gem 'simplecov', :platform => :mri_19
8
- gem 'simplecov-rcov', :platform => :mri_19
6
+ gem 'simplecov', :platform => :mri
7
+ gem 'simplecov-rcov', :platform => :mri
9
8
 
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Blacklight
2
2
 
3
+ [![Build Status](https://travis-ci.org/projectblacklight/blacklight.png?branch=master)](https://travis-ci.org/projectblacklight/blacklight)
4
+
3
5
  Blacklight is an open source Solr user interface discovery platform.
4
6
  You can use Blacklight to enable searching and browsing of your collections.
5
7
  Blacklight uses the [Apache Solr](http://lucene.apache.org/solr) search engine
@@ -13,7 +15,7 @@ the University of Virginia Library and is made public under an Apache 2.0 licens
13
15
  * [Project Homepage](http://projectblacklight.org)
14
16
  * [Developer Documentation](https://github.com/projectblacklight/blacklight/wiki)
15
17
  * [Quickstart Guide](https://github.com/projectblacklight/blacklight/wiki/Quickstart)
16
- * [JIRA Issue Tracker](http://jira.projectblacklight.org/jira/secure/Dashboard.jspa)
18
+ * [Issue Tracker](https://github.com/projectblacklight/blacklight/issues)
17
19
  * [Support](http://projectblacklight.org/support.html)
18
20
 
19
21
  ## Dependencies
data/VERSION CHANGED
@@ -1 +1 @@
1
- 4.0.1
1
+ 4.1.0
@@ -1,3 +1,4 @@
1
+ @charset "UTF-8";
1
2
 
2
3
  /* This file is generated by Blacklight. You probably don't want to edit
3
4
  this file directly, or you'll have to manually merge your changes if later
@@ -25,6 +25,7 @@
25
25
  ul {
26
26
  list-style: none;
27
27
  position: absolute;
28
+ z-index: $zindexDropdown;
28
29
  top: 100%;
29
30
  left: 0;
30
31
  right: 0;
@@ -53,4 +54,4 @@
53
54
  }
54
55
  }
55
56
  }
56
- }
57
+ }
@@ -32,7 +32,7 @@
32
32
  vertical-align: top;
33
33
  }
34
34
 
35
- .filterName, .label
35
+ .filterName, .filterSeparator
36
36
  {
37
37
  color: gray;
38
38
  }
@@ -1,3 +1,5 @@
1
+ @charset "UTF-8";
2
+
1
3
  /* This is the default blacklight theme. */
2
4
 
3
5
  @import 'blacklight/blacklight_base';
@@ -1,3 +1,5 @@
1
+ @charset "UTF-8";
2
+
1
3
  /*!
2
4
  * Bootstrap Modal
3
5
  *
@@ -105,8 +105,9 @@ module Blacklight::BlacklightHelperBehavior
105
105
  content_tag("div", content.join("\n").html_safe, :class=>"documentFunctions")
106
106
  end
107
107
 
108
- # used in the catalog/_index_partials/_default view
109
- def index_fields
108
+ ##
109
+ # Index fields to display for a type of document
110
+ def index_fields document=nil
110
111
  blacklight_config.index_fields
111
112
  end
112
113
 
@@ -115,50 +116,125 @@ module Blacklight::BlacklightHelperBehavior
115
116
  (document.has_highlight_field? solr_field.field if solr_field.highlight)
116
117
  end
117
118
 
118
- def index_field_names
119
- index_fields.keys
119
+ ##
120
+ # Field keys for the index fields
121
+ # @deprecated
122
+ def index_field_names document=nil
123
+ index_fields(document).keys
120
124
  end
121
125
 
122
- # used in the catalog/_index_partials/_default partial
123
- def index_field_labels
126
+ ##
127
+ # Labels for the index fields
128
+ # @deprecated
129
+ def index_field_labels document=nil
124
130
  # XXX DEPRECATED
125
- Hash[*index_fields.map { |key, field| [key, field.label] }.flatten]
131
+ Hash[*index_fields(document).map { |key, field| [key, field.label] }.flatten]
126
132
  end
127
133
 
128
134
  def spell_check_max
129
135
  blacklight_config.spell_max
130
136
  end
131
137
 
132
- def render_index_field_label args
133
- field = args[:field]
134
- html_escape index_fields[field].label
135
- end
136
-
137
- def render_index_field_value args
138
- value = args[:value]
139
-
140
- if args[:field] and blacklight_config.index_fields[args[:field]]
141
- field_config = blacklight_config.index_fields[args[:field]]
142
- value ||= send(blacklight_config.index_fields[args[:field]][:helper_method], args) if field_config.helper_method
143
- value ||= args[:document].highlight_field(args[:field]) if field_config.highlight
138
+ ##
139
+ # Render the index field label for a document
140
+ #
141
+ # @overload render_index_field_label(options)
142
+ # Use the default, document-agnostic configuration
143
+ # @param [Hash] opts
144
+ # @options opts [String] :field
145
+ # @overload render_index_field_label(document, options)
146
+ # Allow an extention point where information in the document
147
+ # may drive the value of the field
148
+ # @param [SolrDocument] doc
149
+ # @param [Hash] opts
150
+ # @options opts [String] :field
151
+ def render_index_field_label *args
152
+ options = args.extract_options!
153
+ document = args.first
154
+
155
+ field = options[:field]
156
+ html_escape index_fields(document)[field].label
157
+ end
158
+
159
+ ##
160
+ # Render the index field label for a document
161
+ #
162
+ # @overload render_index_field_value(options)
163
+ # Use the default, document-agnostic configuration
164
+ # @param [Hash] opts
165
+ # @options opts [String] :field
166
+ # @options opts [String] :value
167
+ # @options opts [String] :document
168
+ # @overload render_index_field_value(document, options)
169
+ # Allow an extention point where information in the document
170
+ # may drive the value of the field
171
+ # @param [SolrDocument] doc
172
+ # @param [Hash] opts
173
+ # @options opts [String] :field
174
+ # @options opts [String] :value
175
+ # @overload render_index_field_value(document, field, options)
176
+ # Allow an extention point where information in the document
177
+ # may drive the value of the field
178
+ # @param [SolrDocument] doc
179
+ # @param [String] field
180
+ # @param [Hash] opts
181
+ # @options opts [String] :value
182
+ def render_index_field_value *args
183
+ options = args.extract_options!
184
+ document = args.shift || options[:document]
185
+
186
+ field = args.shift || options[:field]
187
+ value = options[:value]
188
+
189
+
190
+ field_config = index_fields(document)[field]
191
+
192
+ value ||= case
193
+ when value
194
+ value
195
+ when (field_config and field_config.helper_method)
196
+ send(field_config.helper_method, options.merge(:document => document, :field => field))
197
+ when (field_config and field_config.highlight)
198
+ document.highlight_field(field_config.field).map { |x| x.html_safe }
199
+ else
200
+ document.get(field, :sep => nil) if field
144
201
  end
145
202
 
146
- value ||= args[:document].get(args[:field], :sep => nil) if args[:document] and args[:field]
147
203
  render_field_value value
148
204
  end
149
205
 
150
206
  # Used in the show view for displaying the main solr document heading
151
- def document_heading
152
- @document[blacklight_config.show.heading] || @document.id
153
- end
207
+ def document_heading document=nil
208
+ document ||= @document
209
+ document[blacklight_config.show.heading] || document.id
210
+ end
211
+
212
+ ##
213
+ # Render the document "heading" (title) in a content tag
214
+ # @overload render_document_heading(tag)
215
+ # @overload render_document_heading(document, options)
216
+ # @params [SolrDocument] document
217
+ # @params [Hash] options
218
+ # @options options [Symbol] :tag
219
+ def render_document_heading(*args)
220
+ options = args.extract_options!
221
+ if args.first.is_a? SolrDocument
222
+ document = args.shift
223
+ tag = options[:tag]
224
+ else
225
+ document = nil
226
+ tag = args.first || options[:tag]
227
+ end
228
+
229
+ tag ||= :h4
154
230
 
155
- def render_document_heading(tag = :h4)
156
- content_tag(tag, render_field_value(document_heading))
231
+ content_tag(tag, render_field_value(document_heading(document)))
157
232
  end
158
233
 
159
234
  # Used in the show view for setting the main html document title
160
- def document_show_html_title
161
- render_field_value(@document[blacklight_config.show.html_title])
235
+ def document_show_html_title document=nil
236
+ document ||= @document
237
+ render_field_value(document[blacklight_config.show.html_title])
162
238
  end
163
239
 
164
240
  # Used in citation view for displaying the title
@@ -172,7 +248,7 @@ module Blacklight::BlacklightHelperBehavior
172
248
  end
173
249
 
174
250
  # Used in the document list partial (search view) for creating a link to the document show action
175
- def document_show_link_field
251
+ def document_show_link_field document=nil
176
252
  blacklight_config.index.show_link.to_sym
177
253
  end
178
254
 
@@ -182,31 +258,84 @@ module Blacklight::BlacklightHelperBehavior
182
258
  end
183
259
 
184
260
  # used in the catalog/_show/_default partial
185
- def document_show_fields
261
+ def document_show_fields document=nil
186
262
  blacklight_config.show_fields
187
263
  end
188
264
 
189
265
  # used in the catalog/_show/_default partial
190
- def document_show_field_labels
266
+ # @deprecated
267
+ def document_show_field_labels document=nil
191
268
  # XXX DEPRECATED
192
- Hash[*blacklight_config.show_fields.map { |key, field| [key, field.label] }.flatten]
193
- end
194
-
195
- def render_document_show_field_label args
196
- field = args[:field]
197
- html_escape blacklight_config.show_fields[field].label
269
+ Hash[*document_show_fields(document).map { |key, field| [key, field.label] }.flatten]
198
270
  end
199
271
 
200
- def render_document_show_field_value args
201
- value = args[:value]
202
-
203
- if args[:field] and blacklight_config.show_fields[args[:field]]
204
- field_config = blacklight_config.show_fields[args[:field]]
205
- value ||= send(blacklight_config.show_fields[args[:field]][:helper_method], args) if field_config.helper_method
206
- value ||= args[:document].highlight_field(args[:field]).map { |x| x.html_safe } if field_config.highlight
272
+ ##
273
+ # Render the show field label for a document
274
+ #
275
+ # @overload render_document_show_field_label(options)
276
+ # Use the default, document-agnostic configuration
277
+ # @param [Hash] opts
278
+ # @options opts [String] :field
279
+ # @overload render_document_show_field_label(document, options)
280
+ # Allow an extention point where information in the document
281
+ # may drive the value of the field
282
+ # @param [SolrDocument] doc
283
+ # @param [Hash] opts
284
+ # @options opts [String] :field
285
+ def render_document_show_field_label *args
286
+ options = args.extract_options!
287
+ document = args.first
288
+
289
+ field = options[:field]
290
+
291
+ html_escape document_show_fields(document)[field].label
292
+ end
293
+
294
+ ##
295
+ # Render the index field label for a document
296
+ #
297
+ # @overload render_document_show_field_value(options)
298
+ # Use the default, document-agnostic configuration
299
+ # @param [Hash] opts
300
+ # @options opts [String] :field
301
+ # @options opts [String] :value
302
+ # @options opts [String] :document
303
+ # @overload render_document_show_field_value(document, options)
304
+ # Allow an extention point where information in the document
305
+ # may drive the value of the field
306
+ # @param [SolrDocument] doc
307
+ # @param [Hash] opts
308
+ # @options opts [String] :field
309
+ # @options opts [String] :value
310
+ # @overload render_document_show_field_value(document, field, options)
311
+ # Allow an extention point where information in the document
312
+ # may drive the value of the field
313
+ # @param [SolrDocument] doc
314
+ # @param [String] field
315
+ # @param [Hash] opts
316
+ # @options opts [String] :value
317
+ def render_document_show_field_value *args
318
+
319
+ options = args.extract_options!
320
+ document = args.shift || options[:document]
321
+
322
+ field = args.shift || options[:field]
323
+ value = options[:value]
324
+
325
+
326
+ field_config = document_show_fields(document)[field]
327
+
328
+ value ||= case
329
+ when value
330
+ value
331
+ when (field_config and field_config.helper_method)
332
+ send(field_config.helper_method, options.merge(:document => document, :field => field))
333
+ when (field_config and field_config.highlight)
334
+ document.highlight_field(field_config.field).map { |x| x.html_safe }
335
+ else
336
+ document.get(field, :sep => nil) if field
207
337
  end
208
338
 
209
- value ||= args[:document].get(args[:field], :sep => nil) if args[:document] and args[:field]
210
339
  render_field_value value
211
340
  end
212
341
 
@@ -359,24 +488,46 @@ module Blacklight::BlacklightHelperBehavior
359
488
  end
360
489
 
361
490
  def params_for_search(options={})
362
- my_params = (options[:params] || params).dup
363
- options[:omit_keys] ||= []
491
+ # special keys
492
+ # params hash to mutate
493
+ source_params = options.delete(:params) || params
494
+ omit_keys = options.delete(:omit_keys) || []
364
495
 
365
- options[:omit_keys].each do |omit_key|
496
+ # params hash we'll return
497
+ my_params = source_params.dup.merge(options.dup)
498
+
499
+
500
+ # remove items from our params hash that match:
501
+ # - a key
502
+ # - a key and a value
503
+ omit_keys.each do |omit_key|
366
504
  case omit_key
367
505
  when Hash
368
506
  omit_key.each do |key, values|
369
- next unless my_params[key]
507
+ next unless my_params.has_key? key
508
+
509
+ # make sure to dup the source key, we don't want to accidentally alter the original
370
510
  my_params[key] = my_params[key].dup
371
511
 
372
512
  values = [values] unless values.respond_to? :each
373
513
  values.each { |v| my_params[key].delete(v) }
514
+
515
+ if my_params[key].empty?
516
+ my_params.delete(key)
517
+ end
374
518
  end
519
+
375
520
  else
376
521
  my_params.delete(omit_key)
377
522
  end
378
523
  end
379
524
 
525
+ if my_params[:page] and (my_params[:per_page] != source_params[:per_page] or my_params[:sort] != source_params[:sort] )
526
+ my_params[:page] = 1
527
+ end
528
+
529
+ my_params.reject! { |k,v| v.nil? }
530
+
380
531
  # removing action and controller from duplicate params so that we don't get hidden fields for them.
381
532
  my_params.delete(:action)
382
533
  my_params.delete(:controller)