blacklight 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. data/VERSION +1 -1
  2. data/app/helpers/blacklight_helper.rb +2 -215
  3. data/app/helpers/facets_helper.rb +114 -0
  4. data/app/helpers/html_head_helper.rb +103 -0
  5. data/app/views/catalog/_document.html.erb +0 -2
  6. data/app/views/catalog/show.html.erb +0 -1
  7. data/app/views/kaminari/blacklight/_paginator.html.erb +1 -1
  8. data/lib/blacklight.rb +1 -0
  9. data/lib/blacklight/catalog.rb +0 -22
  10. data/lib/blacklight/kaminari_relevant_pages_patch.rb +37 -0
  11. data/lib/blacklight/routes.rb +0 -1
  12. data/lib/blacklight/solr/document.rb +3 -3
  13. data/lib/blacklight/solr_helper.rb +2 -2
  14. data/lib/generators/blacklight/assets_generator.rb +1 -1
  15. data/lib/generators/blacklight/templates/config/blacklight_config.rb +7 -13
  16. data/lib/railties/blacklight_rspec.rake +3 -1
  17. data/test_support/bin/run-tests.sh +64 -0
  18. data/test_support/bin/test.sh +12 -4
  19. data/test_support/features/step_definitions/search_steps.rb +0 -4
  20. data/test_support/features/support/paths.rb +0 -9
  21. data/test_support/spec/controllers/catalog_controller_spec.rb +0 -45
  22. data/test_support/spec/helpers/blacklight_helper_spec.rb +2 -174
  23. data/test_support/spec/helpers/facets_helper_spec.rb +100 -0
  24. data/test_support/spec/helpers/html_head_helper_spec.rb +90 -0
  25. data/test_support/spec/helpers/solr_helper_spec.rb +1 -1
  26. metadata +85 -120
  27. data/app/views/catalog/_unapi_microformat.html.erb +0 -1
  28. data/app/views/catalog/unapi.xml.builder +0 -6
  29. data/test_support/features/unapi.feature +0 -30
  30. data/test_support/spec/views/catalog/unapi.xml.builder_spec.rb +0 -46
@@ -0,0 +1,100 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ describe FacetsHelper do
3
+
4
+ describe "add_facet_params" do
5
+ before do
6
+ @params_no_existing_facet = {:q => "query", :search_field => "search_field", :per_page => "50"}
7
+ @params_existing_facets = {:q => "query", :search_field => "search_field", :per_page => "50", :f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]}}
8
+ end
9
+
10
+ it "should add facet value for no pre-existing facets" do
11
+ helper.stub!(:params).and_return(@params_no_existing_facet)
12
+
13
+ result_params = helper.add_facet_params("facet_field", "facet_value")
14
+ result_params[:f].should be_a_kind_of(Hash)
15
+ result_params[:f]["facet_field"].should be_a_kind_of(Array)
16
+ result_params[:f]["facet_field"].should == ["facet_value"]
17
+ end
18
+
19
+ it "should add a facet param to existing facet constraints" do
20
+ helper.stub!(:params).and_return(@params_existing_facets)
21
+
22
+ result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
23
+
24
+ result_params[:f].should be_a_kind_of(Hash)
25
+
26
+ @params_existing_facets[:f].each_pair do |facet_field, value_list|
27
+ result_params[:f][facet_field].should be_a_kind_of(Array)
28
+
29
+ if facet_field == 'facet_field_2'
30
+ result_params[:f][facet_field].should == (@params_existing_facets[:f][facet_field] | ["new_facet_value"])
31
+ else
32
+ result_params[:f][facet_field].should == @params_existing_facets[:f][facet_field]
33
+ end
34
+ end
35
+ end
36
+ it "should leave non-facet params alone" do
37
+ [@params_existing_facets, @params_no_existing_facet].each do |params|
38
+ helper.stub!(:params).and_return(params)
39
+
40
+ result_params = helper.add_facet_params("facet_field_2", "new_facet_value")
41
+
42
+ params.each_pair do |key, value|
43
+ next if key == :f
44
+ result_params[key].should == params[key]
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "add_facet_params_and_redirect" do
51
+ before do
52
+ catalog_facet_params = {:q => "query",
53
+ :search_field => "search_field",
54
+ :per_page => "50",
55
+ :page => "5",
56
+ :f => {"facet_field_1" => ["value1"], "facet_field_2" => ["value2", "value2a"]},
57
+ Blacklight::Solr::FacetPaginator.request_keys[:offset] => "100",
58
+ Blacklight::Solr::FacetPaginator.request_keys[:sort] => "index",
59
+ :id => 'facet_field_name'
60
+ }
61
+ helper.stub!(:params).and_return(catalog_facet_params)
62
+ end
63
+ it "should redirect to 'index' action" do
64
+ params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
65
+
66
+ params[:action].should == "index"
67
+ end
68
+ it "should not include request parameters used by the facet paginator" do
69
+ params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
70
+
71
+ bad_keys = Blacklight::Solr::FacetPaginator.request_keys.values + [:id]
72
+ bad_keys.each do |paginator_key|
73
+ params.keys.should_not include(paginator_key)
74
+ end
75
+ end
76
+ it 'should remove :page request key' do
77
+ params = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
78
+
79
+ params.keys.should_not include(:page)
80
+ end
81
+ it "should otherwise do the same thing as add_facet_params" do
82
+ added_facet_params = helper.add_facet_params("facet_field_2", "facet_value")
83
+ added_facet_params_from_facet_action = helper.add_facet_params_and_redirect("facet_field_2", "facet_value")
84
+
85
+ added_facet_params_from_facet_action.each_pair do |key, value|
86
+ next if key == :action
87
+ value.should == added_facet_params[key]
88
+ end
89
+ end
90
+ end
91
+
92
+ describe "remove_facet_params" do
93
+
94
+ end
95
+
96
+ describe "facet_in_params?" do
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,90 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+ describe HtmlHeadHelper do
3
+
4
+ describe "render_js_includes" do
5
+ helper do
6
+ def javascript_includes
7
+ [
8
+ ["some_js.js", {:plugin => :blacklight}],
9
+ ["other_js"]
10
+ ]
11
+ end
12
+ end
13
+ it "should include script tags specified in controller#javascript_includes" do
14
+ html = helper.render_js_includes
15
+ if use_asset_pipeline?
16
+ html.should have_selector("script[src='/assets/some_js.js'][type='text/javascript']")
17
+ html.should have_selector("script[src='/assets/other_js.js'][type='text/javascript']")
18
+ else
19
+ html.should have_selector("script[src='/javascripts/some_js.js'][type='text/javascript']")
20
+ html.should have_selector("script[src='/javascripts/other_js.js'][type='text/javascript']")
21
+ end
22
+
23
+ html.html_safe?.should == true
24
+ end
25
+ end
26
+
27
+ describe "render_stylesheet_links" do
28
+ helper do
29
+ def stylesheet_links
30
+ [
31
+ ["my_stylesheet", {:plugin => :blacklight}],
32
+ ["other_stylesheet"]
33
+ ]
34
+ end
35
+ end
36
+ it "should render stylesheets specified in controller #stylesheet_links" do
37
+ html = helper.render_stylesheet_includes
38
+ if use_asset_pipeline?
39
+ html.should have_selector("link[href='/assets/my_stylesheet.css'][rel='stylesheet'][type='text/css']")
40
+ html.should have_selector("link[href='/assets/other_stylesheet.css'][rel='stylesheet'][type='text/css']")
41
+ else
42
+ html.should have_selector("link[href='/stylesheets/my_stylesheet.css'][rel='stylesheet'][type='text/css']")
43
+ html.should have_selector("link[href='/stylesheets/other_stylesheet.css'][rel='stylesheet'][type='text/css']")
44
+ end
45
+ html.html_safe?.should == true
46
+ end
47
+ end
48
+
49
+ describe "render_extra_head_content" do
50
+ helper do
51
+ def extra_head_content
52
+ ['<link rel="a">', '<link rel="b">']
53
+ end
54
+ end
55
+
56
+ it "should include content specified in controller#extra_head_content" do
57
+ html = helper.render_extra_head_content
58
+
59
+ html.should have_selector("link[rel=a]")
60
+ html.should have_selector("link[rel=b]")
61
+
62
+ html.html_safe?.should == true
63
+ end
64
+ end
65
+
66
+ describe "render_head_content" do
67
+ describe "with no methods defined" do
68
+ it "should return empty string without complaint" do
69
+ lambda {helper.render_head_content}.should_not raise_error
70
+ helper.render_head_content.should be_blank
71
+ helper.render_head_content.html_safe?.should == true
72
+ end
73
+ end
74
+ describe "with methods defined" do
75
+ it "should include all head content" do
76
+ helper.should_receive(:render_extra_head_content).and_return("".html_safe)
77
+ helper.should_receive(:render_js_includes).and_return("".html_safe)
78
+ helper.should_receive(:render_stylesheet_includes).and_return("".html_safe)
79
+ helper.should_receive(:content_for).with(:head).and_return("".html_safe)
80
+ helper.render_head_content.should be_html_safe
81
+ end
82
+ end
83
+ end
84
+
85
+ private
86
+ def use_asset_pipeline?
87
+ (Rails::VERSION::MAJOR >= 3 and Rails::VERSION::MINOR >= 1) and Rails.application.config.assets.enabled
88
+ end
89
+
90
+ end
@@ -74,7 +74,7 @@ describe 'Blacklight::SolrHelper' do
74
74
  end
75
75
  end
76
76
 
77
- CustomizableHelper.solr_search_params_logic << :add_foo_to_solr_params
77
+ CustomizableHelper.solr_search_params_logic += [:add_foo_to_solr_params]
78
78
 
79
79
 
80
80
  obj = CustomizableHelper.new
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: blacklight
3
- version: !ruby/object:Gem::Version
4
- hash: 7
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.1.0
5
5
  prerelease:
6
- segments:
7
- - 3
8
- - 0
9
- - 0
10
- version: 3.0.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Jonathan Rochkind
14
9
  - Matt Mitchell
15
10
  - Chris Beer
@@ -21,124 +16,97 @@ authors:
21
16
  autorequire:
22
17
  bindir: bin
23
18
  cert_chain: []
24
-
25
- date: 2011-07-11 00:00:00 -04:00
19
+ date: 2011-09-28 00:00:00.000000000 -04:00
26
20
  default_executable:
27
- dependencies:
28
- - !ruby/object:Gem::Dependency
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
29
23
  name: rails
30
- prerelease: false
31
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirement: &2161073300 !ruby/object:Gem::Requirement
32
25
  none: false
33
- requirements:
26
+ requirements:
34
27
  - - ~>
35
- - !ruby/object:Gem::Version
36
- hash: 7
37
- segments:
38
- - 3
39
- - 0
40
- version: "3.0"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
41
30
  type: :runtime
42
- version_requirements: *id001
43
- - !ruby/object:Gem::Dependency
44
- name: nokogiri
45
31
  prerelease: false
46
- requirement: &id002 !ruby/object:Gem::Requirement
32
+ version_requirements: *2161073300
33
+ - !ruby/object:Gem::Dependency
34
+ name: nokogiri
35
+ requirement: &2161072180 !ruby/object:Gem::Requirement
47
36
  none: false
48
- requirements:
37
+ requirements:
49
38
  - - ~>
50
- - !ruby/object:Gem::Version
51
- hash: 5
52
- segments:
53
- - 1
54
- - 5
55
- version: "1.5"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
56
41
  type: :runtime
57
- version_requirements: *id002
58
- - !ruby/object:Gem::Dependency
59
- name: unicode
60
42
  prerelease: false
61
- requirement: &id003 !ruby/object:Gem::Requirement
43
+ version_requirements: *2161072180
44
+ - !ruby/object:Gem::Dependency
45
+ name: unicode
46
+ requirement: &2161071400 !ruby/object:Gem::Requirement
62
47
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- hash: 3
67
- segments:
68
- - 0
69
- version: "0"
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
70
52
  type: :runtime
71
- version_requirements: *id003
72
- - !ruby/object:Gem::Dependency
73
- name: marc
74
53
  prerelease: false
75
- requirement: &id004 !ruby/object:Gem::Requirement
54
+ version_requirements: *2161071400
55
+ - !ruby/object:Gem::Dependency
56
+ name: marc
57
+ requirement: &2161070280 !ruby/object:Gem::Requirement
76
58
  none: false
77
- requirements:
59
+ requirements:
78
60
  - - ~>
79
- - !ruby/object:Gem::Version
80
- hash: 9
81
- segments:
82
- - 0
83
- - 4
84
- - 3
61
+ - !ruby/object:Gem::Version
85
62
  version: 0.4.3
86
63
  type: :runtime
87
- version_requirements: *id004
88
- - !ruby/object:Gem::Dependency
89
- name: rsolr
90
64
  prerelease: false
91
- requirement: &id005 !ruby/object:Gem::Requirement
65
+ version_requirements: *2161070280
66
+ - !ruby/object:Gem::Dependency
67
+ name: rsolr
68
+ requirement: &2161069300 !ruby/object:Gem::Requirement
92
69
  none: false
93
- requirements:
70
+ requirements:
94
71
  - - ~>
95
- - !ruby/object:Gem::Version
96
- hash: 15
97
- segments:
98
- - 1
99
- - 0
100
- version: "1.0"
72
+ - !ruby/object:Gem::Version
73
+ version: '1.0'
101
74
  type: :runtime
102
- version_requirements: *id005
103
- - !ruby/object:Gem::Dependency
104
- name: rsolr-ext
105
75
  prerelease: false
106
- requirement: &id006 !ruby/object:Gem::Requirement
76
+ version_requirements: *2161069300
77
+ - !ruby/object:Gem::Dependency
78
+ name: rsolr-ext
79
+ requirement: &2161067680 !ruby/object:Gem::Requirement
107
80
  none: false
108
- requirements:
81
+ requirements:
109
82
  - - ~>
110
- - !ruby/object:Gem::Version
111
- hash: 15
112
- segments:
113
- - 1
114
- - 0
115
- version: "1.0"
83
+ - !ruby/object:Gem::Version
84
+ version: '1.0'
116
85
  type: :runtime
117
- version_requirements: *id006
118
- - !ruby/object:Gem::Dependency
119
- name: kaminari
120
86
  prerelease: false
121
- requirement: &id007 !ruby/object:Gem::Requirement
87
+ version_requirements: *2161067680
88
+ - !ruby/object:Gem::Dependency
89
+ name: kaminari
90
+ requirement: &2161066800 !ruby/object:Gem::Requirement
122
91
  none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: 3
127
- segments:
128
- - 0
129
- version: "0"
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
130
96
  type: :runtime
131
- version_requirements: *id007
132
- description: "Blacklight is a free and open source ruby-on-rails based discovery interface (a.k.a. \xE2\x80\x9Cnext-generation catalog\xE2\x80\x9D) especially optimized for heterogeneous collections. You can use it as a library catalog, as a front end for a digital repository, or as a single-search interface to aggregate digital content that would otherwise be siloed."
133
- email:
97
+ prerelease: false
98
+ version_requirements: *2161066800
99
+ description: Blacklight is a free and open source ruby-on-rails based discovery interface
100
+ (a.k.a. “next-generation catalog”) especially optimized for heterogeneous collections.
101
+ You can use it as a library catalog, as a front end for a digital repository, or
102
+ as a single-search interface to aggregate digital content that would otherwise be
103
+ siloed.
104
+ email:
134
105
  - blacklight-development@googlegroups.com
135
106
  executables: []
136
-
137
107
  extensions: []
138
-
139
108
  extra_rdoc_files: []
140
-
141
- files:
109
+ files:
142
110
  - .gitignore
143
111
  - .gitmodules
144
112
  - .yardopts
@@ -185,8 +153,10 @@ files:
185
153
  - app/helpers/blacklight_helper.rb
186
154
  - app/helpers/bookmarks_helper.rb
187
155
  - app/helpers/catalog_helper.rb
156
+ - app/helpers/facets_helper.rb
188
157
  - app/helpers/feedback_helper.rb
189
158
  - app/helpers/hash_as_hidden_fields.rb
159
+ - app/helpers/html_head_helper.rb
190
160
  - app/helpers/render_constraints_helper.rb
191
161
  - app/helpers/saved_searches_helper.rb
192
162
  - app/helpers/search_history_helper.rb
@@ -223,7 +193,6 @@ files:
223
193
  - app/views/catalog/_show_tools.html.erb
224
194
  - app/views/catalog/_sms_form.html.erb
225
195
  - app/views/catalog/_sort_and_per_page.html.erb
226
- - app/views/catalog/_unapi_microformat.html.erb
227
196
  - app/views/catalog/citation.html.erb
228
197
  - app/views/catalog/email.erb
229
198
  - app/views/catalog/endnote.endnote.erb
@@ -239,7 +208,6 @@ files:
239
208
  - app/views/catalog/show.html.erb
240
209
  - app/views/catalog/show.refworks.erb
241
210
  - app/views/catalog/sms.erb
242
- - app/views/catalog/unapi.xml.builder
243
211
  - app/views/feedback/complete.html.erb
244
212
  - app/views/feedback/show.html.erb
245
213
  - app/views/folder/_tools.html.erb
@@ -263,7 +231,6 @@ files:
263
231
  - db/seeds.rb
264
232
  - install.rb
265
233
  - install/solr.yml
266
- - lib/.DS_Store
267
234
  - lib/blacklight.rb
268
235
  - lib/blacklight/catalog.rb
269
236
  - lib/blacklight/comma_link_renderer.rb
@@ -271,6 +238,7 @@ files:
271
238
  - lib/blacklight/controller.rb
272
239
  - lib/blacklight/engine.rb
273
240
  - lib/blacklight/exceptions.rb
241
+ - lib/blacklight/kaminari_relevant_pages_patch.rb
274
242
  - lib/blacklight/routes.rb
275
243
  - lib/blacklight/search_fields.rb
276
244
  - lib/blacklight/solr.rb
@@ -320,6 +288,7 @@ files:
320
288
  - lib/railties/solr_marc.rake
321
289
  - tasks/blacklight_tasks.rake
322
290
  - test_support/.rspec
291
+ - test_support/bin/run-tests.sh
323
292
  - test_support/bin/test.sh
324
293
  - test_support/data/test_data.utf8.mrc
325
294
  - test_support/features/bookmarks.feature
@@ -348,7 +317,6 @@ files:
348
317
  - test_support/features/support/env.rb
349
318
  - test_support/features/support/paths.rb
350
319
  - test_support/features/support/selectors.rb
351
- - test_support/features/unapi.feature
352
320
  - test_support/spec/controllers/application_controller_spec.rb
353
321
  - test_support/spec/controllers/catalog_controller_spec.rb
354
322
  - test_support/spec/controllers/folder_controller_spec.rb
@@ -357,7 +325,9 @@ files:
357
325
  - test_support/spec/data/test_data.utf8.mrc
358
326
  - test_support/spec/helpers/blacklight_helper_spec.rb
359
327
  - test_support/spec/helpers/catalog_helper_spec.rb
328
+ - test_support/spec/helpers/facets_helper_spec.rb
360
329
  - test_support/spec/helpers/hash_as_hidden_fields_spec.rb
330
+ - test_support/spec/helpers/html_head_helper_spec.rb
361
331
  - test_support/spec/helpers/render_constraints_helper_spec.rb
362
332
  - test_support/spec/helpers/search_history_helper_spec.rb
363
333
  - test_support/spec/helpers/solr_helper_spec.rb
@@ -391,41 +361,36 @@ files:
391
361
  - test_support/spec/views/catalog/_show_partials/_default.html.erb_spec.rb
392
362
  - test_support/spec/views/catalog/index.atom.builder_spec.rb
393
363
  - test_support/spec/views/catalog/show.html.erb_spec.rb
394
- - test_support/spec/views/catalog/unapi.xml.builder_spec.rb
395
364
  - uninstall.rb
396
365
  has_rdoc: true
397
366
  homepage: http://projectblacklight.org/
398
367
  licenses: []
399
-
400
368
  post_install_message:
401
369
  rdoc_options: []
402
-
403
- require_paths:
370
+ require_paths:
404
371
  - lib
405
- required_ruby_version: !ruby/object:Gem::Requirement
372
+ required_ruby_version: !ruby/object:Gem::Requirement
406
373
  none: false
407
- requirements:
408
- - - ">="
409
- - !ruby/object:Gem::Version
410
- hash: 3
411
- segments:
374
+ requirements:
375
+ - - ! '>='
376
+ - !ruby/object:Gem::Version
377
+ version: '0'
378
+ segments:
412
379
  - 0
413
- version: "0"
414
- required_rubygems_version: !ruby/object:Gem::Requirement
380
+ hash: 2766889527846263557
381
+ required_rubygems_version: !ruby/object:Gem::Requirement
415
382
  none: false
416
- requirements:
417
- - - ">="
418
- - !ruby/object:Gem::Version
419
- hash: 3
420
- segments:
383
+ requirements:
384
+ - - ! '>='
385
+ - !ruby/object:Gem::Version
386
+ version: '0'
387
+ segments:
421
388
  - 0
422
- version: "0"
389
+ hash: 2766889527846263557
423
390
  requirements: []
424
-
425
391
  rubyforge_project: blacklight
426
- rubygems_version: 1.5.2
392
+ rubygems_version: 1.6.2
427
393
  signing_key:
428
394
  specification_version: 3
429
395
  summary: A next-geration Library Catalag for Universities
430
396
  test_files: []
431
-