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.
- checksums.yaml +6 -6
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/.travis.yml +14 -6
- data/Gemfile +2 -3
- data/README.md +3 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_blacklight_base.css.scss +1 -0
- data/app/assets/stylesheets/blacklight/_dropdown.css.scss +2 -1
- data/app/assets/stylesheets/blacklight/_search_history.css.scss +1 -1
- data/app/assets/stylesheets/blacklight/blacklight.css.scss +2 -0
- data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +2 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +199 -48
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -1
- data/app/views/catalog/_document_header.html.erb +1 -1
- data/app/views/catalog/_index_default.html.erb +3 -3
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_show_default.html.erb +3 -3
- data/app/views/catalog/_sort_widget.html.erb +1 -1
- data/app/views/catalog/show.html.erb +29 -32
- data/app/views/layouts/blacklight.html.erb +1 -1
- data/blacklight.gemspec +1 -1
- data/config/locales/blacklight.fr.yml +236 -0
- data/gemfiles/rails3.gemfile +9 -0
- data/gemfiles/rails4.gemfile +10 -0
- data/lib/blacklight/catalog.rb +22 -10
- data/lib/blacklight/configurable.rb +2 -3
- data/lib/blacklight/configuration/fields.rb +5 -4
- data/lib/blacklight/mash.rb +7 -139
- data/lib/blacklight/routes.rb +19 -18
- data/lib/blacklight/solr_helper.rb +14 -11
- data/lib/blacklight/solr_response.rb +1 -1
- data/lib/generators/blacklight/blacklight_generator.rb +9 -1
- data/lib/generators/blacklight/test_support_generator.rb +15 -0
- data/test_support/bin/setup-test-app.sh +8 -12
- data/test_support/bin/test.sh +20 -24
- data/test_support/features/search.feature +0 -3
- data/test_support/features/search_pagination.feature +53 -0
- data/test_support/features/step_definitions/search_pagination_steps.rb +29 -0
- data/test_support/features/step_definitions/search_steps.rb +0 -11
- data/test_support/spec/controllers/catalog_controller_spec.rb +15 -80
- data/test_support/spec/helpers/blacklight_helper_spec.rb +75 -22
- data/test_support/spec/helpers/catalog_helper_spec.rb +8 -1
- data/test_support/spec/helpers/html_head_helper_spec.rb +21 -7
- data/test_support/spec/lib/blacklight_configurable_spec.rb +18 -4
- data/test_support/spec/lib/blacklight_configuration_spec.rb +28 -0
- data/test_support/spec/lib/solr_helper_spec.rb +14 -4
- data/test_support/spec/routing/catalog_routing_spec.rb +67 -0
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +3 -7
- metadata +42 -15
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 85237ab5ca9df6a7dceedb02ee41c653bea8f99b
|
4
|
+
data.tar.gz: d8e94fa7a2eb458e6e072f5b9178a59874d28672
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd6f5b56a806020627da8539450d8b9e259960d8f6e74e1cfbc2b2be140868705c69f57edb245bcf3fa971aadef6ad3020c67b4c87d47c2a7d4a9d661767a01d
|
7
|
+
data.tar.gz: 3e1b35b3aa99e852e2d43c93135937d0ed4392b7356a08368768f0c2951cd756d0881147aa86e448957322ec2b3d44d5f3227fc4c40afb19eaf999257bed605e
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
Binary file
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -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
|
-
|
8
|
-
|
6
|
+
- jruby-19mode
|
7
|
+
- 2.0.0
|
9
8
|
|
10
|
-
|
11
|
-
-
|
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 '
|
7
|
-
gem 'simplecov', :platform => :
|
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
|
+
[](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
|
-
* [
|
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
|
+
4.1.0
|
@@ -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
|
-
|
109
|
-
|
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
|
-
|
119
|
-
|
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
|
-
|
123
|
-
|
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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
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
|
-
|
153
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
266
|
+
# @deprecated
|
267
|
+
def document_show_field_labels document=nil
|
191
268
|
# XXX DEPRECATED
|
192
|
-
Hash[*
|
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
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
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
|
-
|
363
|
-
|
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
|
-
|
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
|
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)
|