blacklight 5.10.2 → 5.10.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d53a3586635ad7513ad3cfbd39d178c248e7836
4
- data.tar.gz: b3f18bb4c468758d1ed21e3a5faad5261513a824
3
+ metadata.gz: 0d8ff5b59fd2f2f4492d6a334429e34d65eecb73
4
+ data.tar.gz: 1c5518ceb4bbba537374113d4ba12830276dcb50
5
5
  SHA512:
6
- metadata.gz: 9789e89bc7c855b96bf969f4b2691fa9c830cfcb5ca126004aeed2200a9d7fb659fa351da420b95454a5770a568de66f2ba5993765593dae98e93072e1e6cbeb
7
- data.tar.gz: 6abdbabd10009fba2f694e7d7faca33b668dd3b7fe386cc32ba2608e04bd5367cf313485be7a1db2bf32a9111357c8a2bdc0feb60a8a8914997f95f7b1fc531e
6
+ metadata.gz: 56d549c7e95d7a3bc1aef93b961e8403a9697e07562c5f76e5f16da795d9545de919fec3455b31ee1453a323a16db89486f166774ce7568b84d703b5cce3ad03
7
+ data.tar.gz: 51b5768632c4336d9b1242d3b3872cd97de4e8e6ecf42b7d01d3e43d052d06d515e7dba26a1d60aba9d7c61d3dfd26851298b86d9254107d7b445c788503dffe
@@ -15,6 +15,8 @@ matrix:
15
15
  env: "RAILS_VERSION=4.1.9"
16
16
  - rvm: 2.1.5
17
17
  env: "RAILS_VERSION=4.2.0"
18
+ - rvm: 2.1.5
19
+ env: "RAILS_VERSION=4.2.1"
18
20
  - rvm: jruby
19
21
  env: "RAILS_VERSION=4.2.0 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
20
22
  - rvm: 1.9.3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.10.2
1
+ 5.10.3
@@ -87,13 +87,11 @@ module Blacklight::ConfigurationHelperBehavior
87
87
  # Look up the label for the facet field
88
88
  def facet_field_label field
89
89
  field_config = blacklight_config.facet_fields[field]
90
+ defaults = [:"blacklight.search.fields.facet.#{field}", :"blacklight.search.fields.#{field}"]
91
+ defaults << field_config.label if field_config
92
+ defaults << field.to_s.humanize
90
93
 
91
- field_label(
92
- :"blacklight.search.fields.facet.#{field}",
93
- :"blacklight.search.fields.#{field}",
94
- (field_config.label if field_config),
95
- field.to_s.humanize
96
- )
94
+ field_label *defaults
97
95
  end
98
96
 
99
97
  ##
@@ -109,7 +107,7 @@ module Blacklight::ConfigurationHelperBehavior
109
107
  # @param [Symbol] any number of additional keys
110
108
  # @param [Symbol] ...
111
109
  def field_label *i18n_keys
112
- first, *rest = i18n_keys
110
+ first, *rest = i18n_keys.compact
113
111
 
114
112
  t(first, default: rest)
115
113
  end
@@ -82,10 +82,15 @@ module Blacklight::UrlHelperBehavior
82
82
  return {}
83
83
  end
84
84
 
85
- { :data => {:'context-href' => track_solr_document_path(document, per_page: params.fetch(:per_page, search_session['per_page']), counter: counter, search_id: current_search_session.try(:id))}}
85
+ { :data => {:'context-href' => session_tracking_path(document, per_page: params.fetch(:per_page, search_session['per_page']), counter: counter, search_id: current_search_session.try(:id))}}
86
86
  end
87
87
  protected :session_tracking_params
88
88
 
89
+ ##
90
+ # Get the URL for tracking search sessions across pages using polymorphic routing
91
+ def session_tracking_path document, params = {}
92
+ polymorphic_path([:track, document], params)
93
+ end
89
94
 
90
95
  #
91
96
  # link based helpers ->
@@ -5,7 +5,10 @@ class Bookmark < ActiveRecord::Base
5
5
  belongs_to :document, polymorphic: true
6
6
 
7
7
  validates_presence_of :user_id, :scope=>:document_id
8
- attr_accessible :id, :document_id, :document_type, :title if Rails::VERSION::MAJOR < 4
8
+
9
+ if Blacklight::Utils.needs_attr_accessible?
10
+ attr_accessible :id, :document_id, :document_type, :title
11
+ end
9
12
 
10
13
  def document
11
14
  document_type.new document_type.unique_key => document_id
@@ -5,10 +5,13 @@ class Search < ActiveRecord::Base
5
5
 
6
6
  serialize :query_params
7
7
 
8
- if Rails::VERSION::MAJOR < 4
8
+ if Blacklight::Utils.needs_attr_accessible?
9
9
  attr_accessible :query_params
10
-
11
- scope :none, where(:id => nil).where("id IS NOT ?", nil)
10
+ end
11
+
12
+ unless respond_to?(:none)
13
+ # polyfill
14
+ scope :none, where(id: nil).where("id IS NOT ?", nil)
12
15
  end
13
16
 
14
17
  # A Search instance is considered a saved search if it has a user_id.
@@ -1,9 +1,49 @@
1
- <h4><%= t('blacklight.welcome') %></h4>
2
- <p>&nbsp;</p>
3
- <p>To modify this text to your specifications, copy this file located in the blacklight plugin directory:<br/>
4
- &nbsp;&nbsp;&nbsp;<%= Blacklight.root %>/app/views/catalog/_home_text.html.erb</p>
5
- <p>to your top level rails app:<br/>
6
- &nbsp;&nbsp;&nbsp;<%= Rails.root %>/app/views/catalog/_home_text.html.erb</p>
7
- <p>Note that you will need to create the 'catalog' directory under views.</p>
8
- <% #Creates a bit space in the page -%>
1
+ <div class="page-header row">
2
+ <h1 class="col-md-8"><%= t('blacklight.welcome') %></h1>
3
+
4
+ <ul class="nav nav-pills col-md-4">
5
+ <li><a href="https://github.com/projectblacklight/blacklight/">Github</a></li>
6
+ <li><a href="https://github.com/projectblacklight/blacklight/wiki">Wiki</a></li>
7
+ <li><a href="https://github.com/projectblacklight/blacklight/releases/tag/v<%= Blacklight::VERSION %>">Release Notes</a></li>
8
+ </ul>
9
9
 
10
+
11
+ </div>
12
+
13
+ <div id="getting-started">
14
+ <h2>Here&rsquo;s how to get started:</h2>
15
+
16
+ <ol>
17
+ <li>To modify this text, you need to <a href="http://guides.rubyonrails.org/engines.html#improving-engine-functionality">override the Blacklight-provided view</a>.
18
+ You can copy this file, located in the blacklight gem: <br />
19
+ <%= Blacklight.root %>/app/views/catalog/_home_text.html.erb <br />
20
+ to your own application: <br />
21
+ <%= Rails.root %>/app/views/catalog/_home_text.html.erb
22
+ </li>
23
+ <li><a href="https://github.com/projectblacklight/blacklight/wiki/Indexing-your-data-into-solr">Index your own data</a> into Solr</li>
24
+ <li><a href="https://github.com/projectblacklight/blacklight/wiki#blacklight-configuration">Configure Blacklight</a> to match your data and user-experience needs</li>
25
+ <li><a href="https://github.com/projectblacklight/blacklight/wiki#support">Get in touch</a> with your comments, questions, and ideas</li>
26
+ </ol>
27
+ </div>
28
+
29
+ <%# This is the same panel shown in the Rails welcome template %>
30
+ <div id="about">
31
+ <h3><a href="/rails/info/properties">About your application&rsquo;s environment</a></h3>
32
+ <div id="about-content" class="well" style="display: none"></div>
33
+ </div>
34
+
35
+ <script>
36
+ $(function() {
37
+ $('#about a').on('click', function(e) {
38
+ e.preventDefault();
39
+
40
+ if ($('#about-content').html() == "") {
41
+ $('#about-content').load($(this).attr("href"), function() {
42
+ $('#about-content').show();
43
+ });
44
+ } else {
45
+ $('#about-content').toggle();
46
+ }
47
+ });
48
+ });
49
+ </script>
@@ -19,7 +19,7 @@
19
19
 
20
20
  </div>
21
21
  <% @documents.each do |doc| %>
22
- <%=hidden_field_tag "id[]", doc.get(:id)%>
22
+ <%=hidden_field_tag "id[]", doc.id %>
23
23
  <% end %>
24
24
  </div>
25
25
  <div class="modal-footer">
@@ -1,10 +1,13 @@
1
1
  development:
2
2
  startup_wait: 15
3
3
  jetty_port: 8983
4
+ java_version: ">= 1.7"
4
5
  test:
5
6
  startup_wait: 60
6
7
  jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
7
8
  <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
9
+ java_version: ">= 1.7"
8
10
  production:
9
11
  startup_wait: 15
10
12
  jetty_port: 8983
13
+ java_version: ">= 1.7"
@@ -1,6 +1,8 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'kaminari'
3
3
  require 'deprecation'
4
+ require 'blacklight/utils'
5
+
4
6
  module Blacklight
5
7
  autoload :Configurable, 'blacklight/configurable'
6
8
  autoload :Configuration, 'blacklight/configuration'
@@ -28,8 +30,7 @@ module Blacklight
28
30
  autoload :DocumentPresenter, 'blacklight/document_presenter'
29
31
 
30
32
  autoload :Routes, 'blacklight/routes'
31
-
32
- autoload :OpenStructWithHashAccess, 'blacklight/utils'
33
+
33
34
  autoload :SolrResponse, 'blacklight/solr_response'
34
35
  autoload :Facet, 'blacklight/facet'
35
36
 
@@ -144,7 +145,13 @@ module Blacklight
144
145
  end
145
146
 
146
147
  def self.logger
147
- ::Rails.logger
148
+ @logger ||= begin
149
+ ::Rails.logger if defined? Rails and Rails.respond_to? :logger
150
+ end
151
+ end
152
+
153
+ def self.logger= logger
154
+ @logger = logger
148
155
  end
149
156
 
150
157
  #############
@@ -23,7 +23,7 @@ module Blacklight
23
23
  end
24
24
 
25
25
  def logger
26
- @logger ||= Rails.logger if defined? Rails
26
+ @logger ||= Blacklight.logger
27
27
  end
28
28
  end
29
29
  end
@@ -102,7 +102,7 @@ module Blacklight::Catalog::SearchContext
102
102
  @next_document = documents.last
103
103
  end
104
104
  rescue Blacklight::Exceptions::InvalidRequest => e
105
- Rails.logger.warn "Unable to setup next and previous documents: #{e}"
105
+ logger.warn "Unable to setup next and previous documents: #{e}"
106
106
  end
107
107
 
108
108
  end
@@ -5,7 +5,7 @@ module Blacklight
5
5
 
6
6
  self.collapse = true if self.collapse.nil?
7
7
  self.show = true if self.show.nil?
8
- self.if ||= self.show
8
+ self.if = self.show if self.if.nil?
9
9
 
10
10
  super
11
11
 
@@ -1,7 +1,7 @@
1
1
  module Blacklight
2
2
  class Configuration::SearchField < Blacklight::Configuration::Field
3
3
  def normalize! blacklight_config = nil
4
- self.if ||= self.include_in_simple_select
4
+ self.if = self.include_in_simple_select if self.if.nil?
5
5
 
6
6
  super
7
7
  self.qt ||= blacklight_config.default_solr_params[:qt] if blacklight_config && blacklight_config.default_solr_params
@@ -31,7 +31,7 @@ module Blacklight::Document
31
31
  include Blacklight::Document::Extensions
32
32
  end
33
33
 
34
- attr_reader :response
34
+ attr_reader :response, :_source
35
35
  alias_method :solr_response, :response
36
36
 
37
37
  def initialize(source_doc={}, response=nil)
@@ -52,11 +52,23 @@ module Blacklight::Document
52
52
  # If a method is missing, it gets sent to @_source
53
53
  # with all of the original params and block
54
54
  def method_missing(m, *args, &b)
55
- @_source.send(m, *args, &b)
55
+ if _source and _source.respond_to? m
56
+ _source.send(m, *args, &b)
57
+ else
58
+ super
59
+ end
60
+ end
61
+
62
+ def respond_to_missing? *args
63
+ (_source && _source.respond_to?(*args)) || super
56
64
  end
57
65
 
58
66
  def [] *args
59
- @_source.send :[], *args
67
+ _source.send :[], *args
68
+ end
69
+
70
+ def _read_attribute(attr)
71
+ self[attr]
60
72
  end
61
73
 
62
74
  # Helper method to check if value/multi-values exist for a given key.
@@ -81,7 +93,7 @@ module Blacklight::Document
81
93
  end
82
94
 
83
95
  def key? k
84
- @_source.key? k
96
+ _source.key? k
85
97
  end
86
98
 
87
99
  # helper
@@ -112,7 +124,7 @@ module Blacklight::Document
112
124
  end
113
125
 
114
126
  def as_json(options = nil)
115
- @_source.as_json(options)
127
+ _source.as_json(options)
116
128
  end
117
129
 
118
130
  def to_partial_path
@@ -135,6 +147,12 @@ module Blacklight::Document
135
147
  nil
136
148
  end
137
149
 
150
+ ##
151
+ # Implementations that support More-Like-This should override this method
152
+ # to return an array of documents that are like this one.
153
+ def more_like_this
154
+ []
155
+ end
138
156
 
139
157
  # Certain class-level methods needed for the document-specific
140
158
  # extendability architecture
@@ -153,4 +171,4 @@ module Blacklight::Document
153
171
  self
154
172
  end
155
173
  end
156
- end
174
+ end
@@ -45,8 +45,8 @@ module Blacklight
45
45
 
46
46
  solr_response = blacklight_config.response_model.new(res, solr_params, document_model: blacklight_config.document_model)
47
47
 
48
- Rails.logger.debug("Solr query: #{solr_params.inspect}")
49
- Rails.logger.debug("Solr response: #{solr_response.inspect}") if defined?(::BLACKLIGHT_VERBOSE_LOGGING) and ::BLACKLIGHT_VERBOSE_LOGGING
48
+ Blacklight.logger.debug("Solr query: #{solr_params.inspect}")
49
+ Blacklight.logger.debug("Solr response: #{solr_response.inspect}") if defined?(::BLACKLIGHT_VERBOSE_LOGGING) and ::BLACKLIGHT_VERBOSE_LOGGING
50
50
  solr_response
51
51
  end
52
52
  rescue Errno::ECONNREFUSED => e
@@ -1,5 +1,28 @@
1
1
  require 'ostruct'
2
2
  module Blacklight
3
+
4
+ module Utils
5
+ def self.needs_attr_accessible?
6
+ if rails_3?
7
+ !strong_parameters_enabled?
8
+ else
9
+ protected_attributes_enabled?
10
+ end
11
+ end
12
+
13
+ def self.rails_3?
14
+ Rails::VERSION::MAJOR == 3
15
+ end
16
+
17
+ def self.strong_parameters_enabled?
18
+ defined?(ActionController::StrongParameters)
19
+ end
20
+
21
+ def self.protected_attributes_enabled?
22
+ defined?(ActiveModel::MassAssignmentSecurity)
23
+ end
24
+ end
25
+
3
26
  ##
4
27
  # An OpenStruct that responds to common Hash methods
5
28
  class OpenStructWithHashAccess < OpenStruct
@@ -1,10 +1,13 @@
1
1
  development:
2
2
  startup_wait: 15
3
3
  jetty_port: 8983
4
+ java_version: ">= 1.7"
4
5
  test:
5
6
  startup_wait: 60
6
7
  jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
7
8
  <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
9
+ java_version: ">= 1.7"
8
10
  production:
9
11
  startup_wait: 15
10
12
  jetty_port: 8983
13
+ java_version: ">= 1.7"
@@ -47,7 +47,9 @@ This generator makes the following changes to your application:
47
47
  file_path = "app/models/#{model_name.underscore}.rb"
48
48
  if File.exists?(file_path)
49
49
  inject_into_class file_path, model_name.classify do
50
- "\n attr_accessible :email, :password, :password_confirmation if Rails::VERSION::MAJOR < 4\n" +
50
+ "\n if Blacklight::Utils.needs_attr_accessible?\n" +
51
+ "\n attr_accessible :email, :password, :password_confirmation" +
52
+ "\n end\n" +
51
53
  "# Connects this user object to Blacklights Bookmarks. " +
52
54
  "\n include Blacklight::User\n"
53
55
  end
@@ -150,6 +150,13 @@ describe BlacklightConfigurationHelper do
150
150
 
151
151
  label = helper.field_label :key_a, :key_b, "default text"
152
152
  end
153
+
154
+ it "should compact nil keys (fixes rails/rails#19419)" do
155
+ allow(helper).to receive(:t).with(:key_a, default: [:key_b])
156
+
157
+ label = helper.field_label :key_a, nil, :key_b
158
+
159
+ end
153
160
  end
154
161
 
155
162
  describe "#default_per_page" do
@@ -449,4 +449,15 @@ describe BlacklightUrlHelper do
449
449
  expect(url).to eq helper.bookmarks_url(format: :html, encrypted_user_id: 'xyz')
450
450
  end
451
451
  end
452
+
453
+ describe "#session_tracking_path" do
454
+ let(:document) { SolrDocument.new(id: 1) }
455
+ it "should determine the correct route for the document class" do
456
+ expect(helper.session_tracking_path(document)).to eq helper.track_solr_document_path(document)
457
+ end
458
+
459
+ it "should pass through tracking parameters" do
460
+ expect(helper.session_tracking_path(document, x: 1)).to eq helper.track_solr_document_path(document, x: 1)
461
+ end
462
+ end
452
463
  end
@@ -213,11 +213,25 @@ describe "Blacklight::Configuration" do
213
213
  "another_field_facet" => {},
214
214
  "a_facet_field" => {},
215
215
  })
216
- expect { |b| @config.add_index_field "*_facet", &b }.to yield_control.twice
217
-
218
- expect(@config.index_fields.keys).to eq ["some_field_facet", "another_field_facet"]
216
+ expect { |b| @config.add_facet_field "*_facet", &b }.to yield_control.twice
217
+ expect(@config.facet_fields.keys).to eq ["some_field_facet", "another_field_facet"]
219
218
  end
220
219
 
220
+ describe "if/unless conditions with legacy show parameter" do
221
+ it "should be hidden if the if condition is false" do
222
+ expect(@config.add_facet_field("hidden", if: false).if).to eq false
223
+ expect(@config.add_facet_field("hidden_with_legacy", if: false, show: true).if).to eq false
224
+ end
225
+
226
+ it "should be true if the if condition is true" do
227
+ expect(@config.add_facet_field("hidden", if: true).if).to eq true
228
+ expect(@config.add_facet_field("hidden_with_legacy", if: true, show: false).if).to eq true
229
+ end
230
+
231
+ it "should be true if the if condition is missing" do
232
+ expect(@config.add_facet_field("hidden", show: true).if).to eq true
233
+ end
234
+ end
221
235
  end
222
236
 
223
237
  describe "add_index_field" do
@@ -261,7 +275,6 @@ describe "Blacklight::Configuration" do
261
275
 
262
276
  expect(@config.index_fields.keys).to eq ["some_field_display", "another_field_display"]
263
277
  end
264
-
265
278
  end
266
279
 
267
280
  describe "add_show_field" do
@@ -370,8 +383,22 @@ describe "Blacklight::Configuration" do
370
383
 
371
384
  expect(@config.search_fields["author_name"].label).to eq "Author Name"
372
385
  end
373
-
374
-
386
+
387
+ describe "if/unless conditions with legacy include_in_simple_search" do
388
+ it "should be hidden if the if condition is false" do
389
+ expect(@config.add_search_field("hidden", if: false).if).to eq false
390
+ expect(@config.add_search_field("hidden_with_legacy", if: false, include_in_simple_search: true).if).to eq false
391
+ end
392
+
393
+ it "should be true if the if condition is true" do
394
+ expect(@config.add_search_field("hidden", if: true).if).to eq true
395
+ expect(@config.add_search_field("hidden_with_legacy", if: true, include_in_simple_search: false).if).to eq true
396
+ end
397
+
398
+ it "should be true if the if condition is missing" do
399
+ expect(@config.add_search_field("hidden", include_in_simple_search: true).if).to eq true
400
+ end
401
+ end
375
402
  end
376
403
 
377
404
  describe "add_sort_field" do
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.10.2
4
+ version: 5.10.3
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: 2015-03-09 00:00:00.000000000 Z
20
+ date: 2015-03-24 00:00:00.000000000 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: rails