blacklight 5.6.0 → 5.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 479622c28e8d18d1eeec6cd98d645dc569661dbc
4
- data.tar.gz: 86833f67f334ec5ace5b41ceab9aa0bbf78e01b7
3
+ metadata.gz: 6fcfb6f2ba3d0e2311b6707cc12d3e39a82ae03a
4
+ data.tar.gz: 7efc0f476b12a8096ff9f58d5e1f15344bd6b282
5
5
  SHA512:
6
- metadata.gz: cf903983243c985c8088492ce6c3bae681879b41a653e11e7893885190255c651971358bceb9dbfb0f62dfb088af8139058664c32314b919f722f6f5ecba4da3
7
- data.tar.gz: 8e814b2f64604fc14f0a43ac0bdd44f1fd45825046d1eca6bcafc5c5c9df4e0bc1281743b11eb459b38d73a597440a8cd0d3509e7497a24095cf38c0b8ed71cd
6
+ metadata.gz: 48281cc2fc1f409cf634100dd44a16415c2a531e65dd2d6f89764023b6e1c42e0cea1173692d1b8897e7f61f7b525b8d6e950c983a4af0d735265d044c31449b
7
+ data.tar.gz: 0bb285df7cbaa528c95b6495b87ac7523e44c9226ec3d1a51fd09ffaca51f0e201420aa6885e7efa3b7bb27815994f2a2a3d180bb1590a6a632bb4dc77a5d8d6
data/.travis.yml CHANGED
@@ -2,32 +2,34 @@ notifications:
2
2
  email: false
3
3
 
4
4
  rvm:
5
- - 2.1.1
6
- - 2.0.0
5
+ - 2.1.2
7
6
 
8
7
  matrix:
9
8
  include:
10
- - rvm: 2.1.0
11
- gemfile: gemfiles/rails4.gemfile
9
+ - rvm: 2.1.2
10
+ env: "RAILS_VERSION=4.0.9"
11
+ - rvm: 2.0.0
12
+ env: "RAILS_VERSION=4.1.5"
12
13
  - rvm: 1.9.3
13
- gemfile: gemfiles/rails4.gemfile
14
+ env: "RAILS_VERSION=4.1.5"
14
15
  - rvm: jruby
15
- gemfile: gemfiles/rails4.gemfile
16
-
16
+ env: "RAILS_VERSION=4.1.5 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
17
+ - rvm: 2.1.2
18
+ env: "RAILS_VERSION=4.2.0.beta1"
19
+ allow_failures:
20
+ - env: "RAILS_VERSION=4.2.0.beta1"
21
+
17
22
  before_install:
18
- - gem install bundler
23
+ - gem install bundler
19
24
 
20
- gemfile:
21
- - gemfiles/rails3.gemfile
22
- - gemfiles/rails4.gemfile
23
- - gemfiles/rails4.1.gemfile
25
+ env:
26
+ - "RAILS_VERSION=3.2.19"
27
+ - "RAILS_VERSION=4.1.5"
24
28
 
25
29
  notifications:
26
30
  irc: "irc.freenode.org#blacklight"
27
31
  email:
28
32
  - blacklight-commits@googlegroups.com
29
33
 
30
- env:
31
- global:
32
- - JRUBY_OPTS="-J-Xms512m -J-Xmx1024m"
33
- - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
34
+ global_env:
35
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
data/Gemfile CHANGED
@@ -3,7 +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
-
7
6
  # Peg simplecov to < 0.8 until this is resolved:
8
7
  # https://github.com/colszowka/simplecov/issues/281
9
8
  gem 'simplecov', '~> 0.7.1', require: false
@@ -20,4 +19,9 @@ file = File.expand_path("Gemfile", ENV['ENGINE_CART_DESTINATION'] || ENV['RAILS_
20
19
  if File.exists?(file)
21
20
  puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
22
21
  instance_eval File.read(file)
22
+ else
23
+ gem 'rails', ENV['RAILS_VERSION'] if ENV['RAILS_VERSION']
24
+
25
+ # explicitly include sass-rails to get compatible sprocket dependencies
26
+ gem 'sass-rails'
23
27
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.6.0
1
+ 5.7.0
@@ -4,8 +4,13 @@
4
4
  //change form submit toggle to checkbox
5
5
  Blacklight.do_bookmark_toggle_behavior = function() {
6
6
  $(Blacklight.do_bookmark_toggle_behavior.selector).bl_checkbox_submit({
7
- //css_class is added to elements added, plus used for id base
8
- css_class: "toggle_bookmark"
7
+ //css_class is added to elements added, plus used for id base
8
+ css_class: "toggle_bookmark",
9
+ success: function(checked, response) {
10
+ if (response.bookmarks) {
11
+ $('#bookmarks_nav span[data-role=bookmark-counter]').text(response.bookmarks.count);
12
+ }
13
+ }
9
14
  });
10
15
  };
11
16
  Blacklight.do_bookmark_toggle_behavior.selector = "form.bookmark_toggle";
@@ -109,7 +109,7 @@
109
109
  update_state_for(checked);
110
110
  label.removeAttr("disabled");
111
111
  checkbox.removeAttr("disabled");
112
- options.success.call(form, checked);
112
+ options.success.call(form, checked, xhr.responseJSON);
113
113
  } else {
114
114
  alert("Error");
115
115
  update_state_for(checked);
@@ -64,11 +64,11 @@ class BookmarksController < CatalogController
64
64
  current_or_guest_user.save! unless current_or_guest_user.persisted?
65
65
 
66
66
  success = @bookmarks.all? do |bookmark|
67
- current_or_guest_user.bookmarks.create(bookmark) unless current_or_guest_user.bookmarks.where(bookmark).exists?
67
+ current_or_guest_user.bookmarks.where(bookmark).exists? || current_or_guest_user.bookmarks.create(bookmark)
68
68
  end
69
69
 
70
70
  if request.xhr?
71
- success ? head(:no_content) : render(:text => "", :status => "500")
71
+ success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(:text => "", :status => "500")
72
72
  else
73
73
  if @bookmarks.length > 0 && success
74
74
  flash[:notice] = I18n.t('blacklight.bookmarks.add.success', :count => @bookmarks.length)
@@ -96,10 +96,10 @@ class BookmarksController < CatalogController
96
96
  redirect_to :back
97
97
  else
98
98
  # ajaxy request needs no redirect and should not have flash set
99
- success ? head(:no_content) : render(:text => "", :status => "500")
99
+ success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count }}) : render(:text => "", :status => "500")
100
100
  end
101
101
  end
102
-
102
+
103
103
  def clear
104
104
  if current_or_guest_user.bookmarks.clear
105
105
  flash[:notice] = I18n.t('blacklight.bookmarks.clear.success')
@@ -276,11 +276,14 @@ module Blacklight::UrlHelperBehavior
276
276
  # This method should move to BlacklightMarc in Blacklight 6.x
277
277
  def refworks_export_url params = {}
278
278
  if params.is_a? ::SolrDocument or (params.nil? and instance_variable_defined? :@document)
279
- Deprecation.warn self, "#refworks_export_url with a SolrDocument is deprecated. Pass in { url: url_for_document(@document) } instead"
280
- url = url_for_document(params || @document, format: :refworks_marc_txt, only_path: false)
281
- params = { url: url }
279
+ Deprecation.warn self, "Calling #refworks_export_url without a :url is deprecated. Pass in e.g. { url: url_for_document(@document, format: :refworks_marc_txt) } instead"
280
+ url = url_for_document(params || @document)
281
+ params = { url: polymorphic_url(url, format: :refworks_marc_txt, only_path: false) }
282
+ elsif params[:id]
283
+ Deprecation.warn self, "Calling #refworks_export_url without a :url is deprecated. Pass in e.g. { url: url_for_document(@document, format: :refworks_marc_txt) } instead"
284
+ params = { url: polymorphic_url(url_for_document(params), format: :refworks_marc_txt, only_path: false) }
282
285
  end
283
-
286
+
284
287
  "http://www.refworks.com/express/expressimport.asp?vendor=#{CGI.escape(params[:vendor] || application_name)}&filter=#{CGI.escape(params[:filter] || "MARC Format")}&encoding=65001" + (("&url=#{CGI.escape(params[:url])}" if params[:url]) || "")
285
288
  end
286
289
 
@@ -2,7 +2,10 @@
2
2
  <ul class="nav navbar-nav">
3
3
  <% if render_bookmarks_control? %>
4
4
  <li>
5
- <%= link_to t('blacklight.header_links.bookmarks'), bookmarks_path %>
5
+ <%= link_to bookmarks_path, id:'bookmarks_nav' do %>
6
+ <%= t('blacklight.header_links.bookmarks') %>
7
+ (<span data-role='bookmark-counter'><%= current_or_guest_user.bookmarks.count %></span>)
8
+ <% end %>
6
9
  </li>
7
10
  <% end %>
8
11
  <% if has_user_authentication_provider? and current_user %>
@@ -33,4 +36,4 @@
33
36
  <% end %>
34
37
  </ul>
35
38
  <% end %>
36
- </div>
39
+ </div>
@@ -24,7 +24,7 @@
24
24
  <% end %>
25
25
  <% if @document.export_formats.keys.include?( :refworks_marc_txt ) %>
26
26
  <li class="refworks">
27
- <%= link_to t('blacklight.tools.refworks'), refworks_export_url(:id => @document) %>
27
+ <%= link_to t('blacklight.tools.refworks'), refworks_export_url(url: polymorphic_url(url_for_document(@document), format: :refworks_marc_txt, only_path: false)) %>
28
28
  </li>
29
29
  <% end %>
30
30
  <% if @document.export_formats.keys.include?( :endnote ) %>
@@ -1,4 +1,4 @@
1
- <div id="content" class="col-md-9 show-document">
1
+ <div id="content" class="col-md-9 col-sm-8 show-document">
2
2
 
3
3
  <%= render 'previous_next_doc' %>
4
4
 
@@ -29,6 +29,6 @@
29
29
 
30
30
  </div>
31
31
 
32
- <div id="sidebar" class="col-md-3">
32
+ <div id="sidebar" class="col-md-3 col-sm-4">
33
33
  <%= render_document_sidebar_partial %>
34
34
  </div>
@@ -35,16 +35,37 @@ module Blacklight::SolrResponse::Facets
35
35
  end
36
36
 
37
37
  def limit
38
- @options[:limit]
38
+ @options[:limit] || solr_default_limit
39
39
  end
40
40
 
41
41
  def sort
42
- @options[:sort] || 'index'
42
+ @options[:sort] || solr_default_sort
43
43
  end
44
44
 
45
45
  def offset
46
- @options[:offset] || 0
46
+ @options[:offset] || solr_default_offset
47
47
  end
48
+
49
+ private
50
+ # Per https://wiki.apache.org/solr/SimpleFacetParameters#facet.limit
51
+ def solr_default_limit
52
+ 100
53
+ end
54
+
55
+ # Per https://wiki.apache.org/solr/SimpleFacetParameters#facet.sort
56
+ def solr_default_sort
57
+ if limit > 0
58
+ 'count'
59
+ else
60
+ 'index'
61
+ end
62
+ end
63
+
64
+ # Per https://wiki.apache.org/solr/SimpleFacetParameters#facet.offset
65
+ def solr_default_offset
66
+ 0
67
+ end
68
+
48
69
  end
49
70
 
50
71
  # @response.facets.each do |facet|
@@ -3,13 +3,14 @@ require 'spec_helper'
3
3
  describe BookmarksController do
4
4
  # jquery 1.9 ajax does error callback if 200 returns empty body. so use 204 instead.
5
5
  describe "update" do
6
- it "has a 204 status code when creating a new one" do
6
+ it "has a 200 status code when creating a new one" do
7
7
  xhr :put, :update, :id => '2007020969', :format => :js
8
8
  expect(response).to be_success
9
- expect(response.code).to eq "204"
9
+ expect(response.code).to eq "200"
10
+ expect(JSON.parse(response.body)["bookmarks"]["count"]).to eq 1
10
11
  end
11
12
 
12
- it "has a 500 status code when fails is success" do
13
+ it "has a 500 status code when create is not success" do
13
14
  allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(false)
14
15
  allow(@controller).to receive_message_chain(:current_or_guest_user, :persisted?).and_return(true)
15
16
  allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :where, :exists?).and_return(false)
@@ -25,10 +26,11 @@ describe BookmarksController do
25
26
  @controller.send(:current_or_guest_user).bookmarks.create! document_id: '2007020969', document_type: "SolrDocument"
26
27
  end
27
28
 
28
- it "has a 204 status code when delete is success" do
29
+ it "has a 200 status code when delete is success" do
29
30
  xhr :delete, :destroy, :id => '2007020969', :format => :js
30
31
  expect(response).to be_success
31
- expect(response.code).to eq "204"
32
+ expect(response.code).to eq "200"
33
+ expect(JSON.parse(response.body)["bookmarks"]["count"]).to eq 0
32
34
  end
33
35
 
34
36
  it "has a 500 status code when delete is not success" do
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Facets" do
@@ -6,4 +7,29 @@ describe "Facets" do
6
7
  expect(page).to have_selector(".modal-title", :text => "Language")
7
8
  expect(page).to have_selector(".facet_select", :text => "Tibetan")
8
9
  end
9
- end
10
+
11
+ it "should paginate through a facet's values" do
12
+ visit catalog_facet_path("subject_topic_facet")
13
+ expect(page).to have_selector '.facet-values li:first', text: "Japanese drama"
14
+ expect(page).to have_link "A-Z Sort"
15
+ expect(page).to have_selector '.sort_options .active', text: "Numerical Sort"
16
+ within ".modal-footer" do
17
+ click_on "Next »"
18
+ end
19
+ expect(page).to have_selector '.facet-values li:first', text: "Jewish law"
20
+ expect(page).to have_link "« Previous"
21
+ end
22
+
23
+ it "should be able to change the facet sort" do
24
+ visit catalog_facet_path("subject_topic_facet")
25
+ expect(page).to have_selector '.facet-values li:first', text: "Japanese drama"
26
+ within ".modal-footer" do
27
+ click_on "A-Z Sort"
28
+ end
29
+ expect(page).to have_selector '.facet-values li:first', text: "Accident insurance"
30
+ expect(page).to have_link "Numerical Sort"
31
+ expect(page).to have_selector '.sort_options .active', text: "A-Z Sort"
32
+
33
+
34
+ end
35
+ end
@@ -37,4 +37,13 @@ describe "Record View" do
37
37
  expect(page.driver.status_code).to eq 404
38
38
  expect(page).to have_content "The page you were looking for doesn't exist."
39
39
  end
40
+
41
+ describe "Tools" do
42
+ it "should have a refworks link" do
43
+ visit catalog_path('2008305903')
44
+ expect(page).to have_link "Export to Refworks"
45
+ link = find_link("Export to Refworks")
46
+ expect(link['href']).to include CGI.escape(catalog_path('2008305903', format: :refworks_marc_txt))
47
+ end
48
+ end
40
49
  end
@@ -7,8 +7,8 @@ describe Blacklight::SolrResponse::Facets do
7
7
  subject { Blacklight::SolrResponse::Facets::FacetField.new "my_field", [] }
8
8
 
9
9
  its(:name) { should eq "my_field" }
10
- its(:limit) { should eq nil }
11
- its(:sort) { should eq 'index' }
10
+ its(:limit) { should eq 100 }
11
+ its(:sort) { should eq 'count' }
12
12
  its(:offset) { should eq 0 }
13
13
  end
14
14
 
@@ -40,8 +40,8 @@ describe Blacklight::SolrResponse::Facets do
40
40
  expect(subject.facet_by_field_name('my_field').limit).to eq 15
41
41
  end
42
42
 
43
- it "should be nil if no value is found" do
44
- expect(subject.facet_by_field_name('my_field').limit).to be_nil
43
+ it "should be the solr default limit if no value is found" do
44
+ expect(subject.facet_by_field_name('my_field').limit).to eq 100
45
45
  end
46
46
  end
47
47
 
@@ -74,9 +74,14 @@ describe Blacklight::SolrResponse::Facets do
74
74
  expect(subject.facet_by_field_name('my_field').sort).to eq 'alpha'
75
75
  end
76
76
 
77
- it "should default to index if no value is found" do
77
+ it "should default to count if no value is found and the default limit is used" do
78
+ expect(subject.facet_by_field_name('my_field').sort).to eq 'count'
79
+ end
80
+
81
+ it "should default to index if no value is found and the limit is unlimited" do
82
+ request_params['facet.limit'] = -1
78
83
  expect(subject.facet_by_field_name('my_field').sort).to eq 'index'
79
84
  end
80
85
  end
81
86
  end
82
- end
87
+ end
@@ -16,7 +16,14 @@ module Features
16
16
  visit new_user_session_path
17
17
  fill_in("user_email", :with => email)
18
18
  fill_in("user_password", :with => "password")
19
- click_button("Sign in")
19
+
20
+ if has_button? "Sign in"
21
+ click_button("Sign in")
22
+ elsif has_button? "Log in"
23
+ click_button("Log in")
24
+ else
25
+ raise "Unable to find sign in button"
26
+ end
20
27
  end
21
28
  end
22
29
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe "_user_util_links" do
4
+
5
+ let :blacklight_config do
6
+ Blacklight::Configuration.new
7
+ end
8
+
9
+ it "should render the correct bookmark count" do
10
+ count = rand(99)
11
+ allow(view).to receive(:blacklight_config).and_return(blacklight_config)
12
+ allow(view).to receive(:render_bookmarks_control?).and_return true
13
+ allow(view).to receive(:has_user_authentication_provider?). and_return false
14
+ allow(view).to receive_message_chain(:current_or_guest_user, :bookmarks, :count).and_return(count)
15
+ render :partial => "user_util_links"
16
+ expect(rendered).to have_selector('#bookmarks_nav span[data-role=bookmark-counter]', text: "#{count}")
17
+ end
18
+
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.6.0
4
+ version: 5.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
@@ -17,7 +17,7 @@ authors:
17
17
  autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
- date: 2014-08-13 00:00:00.000000000 Z
20
+ date: 2014-08-28 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails
@@ -392,9 +392,6 @@ files:
392
392
  - db/migrate/20140202020201_create_searches.rb
393
393
  - db/migrate/20140202020202_create_bookmarks.rb
394
394
  - db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb
395
- - gemfiles/rails3.gemfile
396
- - gemfiles/rails4.1.gemfile
397
- - gemfiles/rails4.gemfile
398
395
  - lib/blacklight.rb
399
396
  - lib/blacklight/base.rb
400
397
  - lib/blacklight/catalog.rb
@@ -513,6 +510,7 @@ files:
513
510
  - spec/support/features/session_helpers.rb
514
511
  - spec/support/include_text.rb
515
512
  - spec/test_app_templates/lib/generators/test_app_generator.rb
513
+ - spec/views/_user_util_links.html.erb_spec.rb
516
514
  - spec/views/catalog/_constraints.html.erb_spec.rb
517
515
  - spec/views/catalog/_constraints_element.html.erb_spec.rb
518
516
  - spec/views/catalog/_document.html.erb_spec.rb
@@ -555,7 +553,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
555
553
  version: '0'
556
554
  requirements: []
557
555
  rubyforge_project:
558
- rubygems_version: 2.2.2
556
+ rubygems_version: 2.2.0
559
557
  signing_key:
560
558
  specification_version: 4
561
559
  summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
@@ -621,6 +619,7 @@ test_files:
621
619
  - spec/support/features/session_helpers.rb
622
620
  - spec/support/include_text.rb
623
621
  - spec/test_app_templates/lib/generators/test_app_generator.rb
622
+ - spec/views/_user_util_links.html.erb_spec.rb
624
623
  - spec/views/catalog/_constraints.html.erb_spec.rb
625
624
  - spec/views/catalog/_constraints_element.html.erb_spec.rb
626
625
  - spec/views/catalog/_document.html.erb_spec.rb
@@ -1,9 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- file = File.expand_path("../../Gemfile", __FILE__)
4
- if File.exists?(file)
5
- puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
6
- instance_eval File.read(file)
7
- end
8
-
9
- gem 'rails', "3.2.19"
@@ -1,12 +0,0 @@
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
- gem 'sass', '~> 3.2.15'
10
- gem 'sprockets', '~> 2.11.0'
11
-
12
- gem 'rails', '4.1.4'
@@ -1,13 +0,0 @@
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 'sass', '~> 3.2.15'
11
- gem 'sprockets', '~> 2.11.0'
12
-
13
- gem 'rails', '4.0.8'