blacklight 5.17.2 → 5.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +2 -11
- data/app/controllers/concerns/blacklight/search_history.rb +31 -0
- data/app/controllers/search_history_controller.rb +1 -18
- data/lib/blacklight.rb +28 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +18 -4
- data/spec/helpers/url_helper_spec.rb +7 -0
- data/spec/lib/blacklight_spec.rb +51 -2
- data/spec/models/blacklight/solr/search_builder_spec.rb +20 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a0b1d1a62262bce3d881921729256a4171e29b8
|
4
|
+
data.tar.gz: b245309f402218cf2a31ecc8140b2ded3415b6f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 982f053854b9ace7a94da7f6f5590ab79a5d516855b556ea8f48aa79e71dda90adbe7caf80cd17ddc7d486de4c7b4f1077f32de4e65daea5362614b2c3ea8953
|
7
|
+
data.tar.gz: f96310c7a544d0179e42253dba5255f8cdfceb1c231ad13ed156e68b043ee8dff64f836bd8f85c8349b3093478dbef378eb3075759794a3d0cc266ef5ebda817
|
data/Gemfile
CHANGED
@@ -8,7 +8,7 @@ gem 'coveralls', '~> 0.8.6', require: false
|
|
8
8
|
gem 'autoprefixer-rails', '~> 6.0.0' if RUBY_VERSION < '2.0'
|
9
9
|
|
10
10
|
group :test do
|
11
|
-
gem "blacklight-marc",
|
11
|
+
gem "blacklight-marc", '~> 5.0'
|
12
12
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
13
13
|
end
|
14
14
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.18.0
|
@@ -64,18 +64,9 @@
|
|
64
64
|
}
|
65
65
|
|
66
66
|
@mixin hyphens-auto {
|
67
|
-
|
68
|
-
// be too big
|
69
|
-
// from http://kenneth.io/blog/2012/03/04/word-wrapping-hypernation-using-css/
|
70
|
-
-ms-word-break: break-all;
|
71
|
-
word-break: break-all;
|
72
|
-
|
73
|
-
// Non standard for webkit
|
74
|
-
word-break: break-word;
|
75
|
-
|
67
|
+
overflow-wrap: break-word;
|
76
68
|
-webkit-hyphens: auto;
|
77
|
-
-
|
78
|
-
-ms-hyphens: auto;
|
69
|
+
-o-hyphens: auto;
|
79
70
|
hyphens: auto;
|
80
71
|
}
|
81
72
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Blacklight
|
2
|
+
module SearchHistory
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
include Blacklight::Configurable
|
5
|
+
|
6
|
+
included do
|
7
|
+
copy_blacklight_config_from(CatalogController)
|
8
|
+
end
|
9
|
+
|
10
|
+
def index
|
11
|
+
@searches = searches_from_history
|
12
|
+
end
|
13
|
+
|
14
|
+
# TODO: we may want to remove unsaved (those without user_id) items from
|
15
|
+
# the database when removed from history
|
16
|
+
def clear
|
17
|
+
if session[:history].clear
|
18
|
+
flash[:notice] = I18n.t('blacklight.search_history.clear.success')
|
19
|
+
else
|
20
|
+
flash[:error] = I18n.t('blacklight.search_history.clear.failure')
|
21
|
+
end
|
22
|
+
|
23
|
+
if respond_to? :redirect_back
|
24
|
+
redirect_back fallback_location: blacklight.search_history_path
|
25
|
+
else
|
26
|
+
# Deprecated in Rails 5.0
|
27
|
+
redirect_to :back
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,21 +1,4 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
class SearchHistoryController < ApplicationController
|
3
|
-
include Blacklight::
|
4
|
-
|
5
|
-
copy_blacklight_config_from(CatalogController)
|
6
|
-
|
7
|
-
def index
|
8
|
-
@searches = searches_from_history
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
#TODO we may want to remove unsaved (those without user_id) items from the database when removed from history
|
13
|
-
def clear
|
14
|
-
if session[:history].clear
|
15
|
-
flash[:notice] = I18n.t('blacklight.search_history.clear.success')
|
16
|
-
else
|
17
|
-
flash[:error] = I18n.t('blacklight.search_history.clear.failure')
|
18
|
-
end
|
19
|
-
redirect_to :back
|
20
|
-
end
|
3
|
+
include Blacklight::SearchHistory
|
21
4
|
end
|
data/lib/blacklight.rb
CHANGED
@@ -62,8 +62,10 @@ module Blacklight
|
|
62
62
|
default_index.connection
|
63
63
|
end
|
64
64
|
|
65
|
+
##
|
66
|
+
# The default index connection for the search index
|
65
67
|
def self.default_index
|
66
|
-
@default_index ||=
|
68
|
+
@default_index ||= repository_class.new(default_configuration)
|
67
69
|
end
|
68
70
|
|
69
71
|
def self.solr_config
|
@@ -71,6 +73,31 @@ module Blacklight
|
|
71
73
|
connection_config
|
72
74
|
end
|
73
75
|
|
76
|
+
##
|
77
|
+
# The configured repository class. By convention, this is
|
78
|
+
# the class Blacklight::{name of the adapter}::Repository, e.g.
|
79
|
+
# elastic_search => Blacklight::ElasticSearch::Repository
|
80
|
+
def self.repository_class
|
81
|
+
case connection_config[:adapter]
|
82
|
+
when 'solr'
|
83
|
+
Blacklight::Solr::Repository
|
84
|
+
when /::/
|
85
|
+
connection_config[:adapter].constantize
|
86
|
+
when nil, ''
|
87
|
+
Rails.logger.warn "The value for :adapter was not found in the blacklight.yml config, and will be required in Blacklight 6.0.0"
|
88
|
+
|
89
|
+
Blacklight::Solr::Repository
|
90
|
+
else
|
91
|
+
"Blacklight/#{connection_config.fetch(:adapter)}/Repository".classify.constantize
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# The default Blacklight configuration.
|
97
|
+
def self.default_configuration
|
98
|
+
Blacklight::Configuration.new
|
99
|
+
end
|
100
|
+
|
74
101
|
def self.connection_config
|
75
102
|
@connection_config ||= begin
|
76
103
|
raise "The #{::Rails.env} environment settings were not found in the blacklight.yml config" unless blacklight_yml[::Rails.env]
|
@@ -139,10 +139,8 @@ module Blacklight::Solr
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
-
|
143
|
-
|
144
|
-
# want to page at, according to configured facet limits.
|
145
|
-
solr_parameters[:"f.#{facet.field}.facet.limit"] = (facet_limit_for(field_name) + 1) if facet_limit_for(field_name)
|
142
|
+
limit = facet_limit_with_pagination(field_name)
|
143
|
+
solr_parameters[:"f.#{facet.field}.facet.limit"] = limit if limit
|
146
144
|
end
|
147
145
|
end
|
148
146
|
|
@@ -250,6 +248,22 @@ module Blacklight::Solr
|
|
250
248
|
end
|
251
249
|
end
|
252
250
|
|
251
|
+
# Support facet paging and 'more'
|
252
|
+
# links, by sending a facet.limit one more than what we
|
253
|
+
# want to page at, according to configured facet limits.
|
254
|
+
def facet_limit_with_pagination(field_name)
|
255
|
+
limit = facet_limit_for(field_name)
|
256
|
+
|
257
|
+
return if limit.nil?
|
258
|
+
|
259
|
+
if limit > 0
|
260
|
+
limit + 1
|
261
|
+
else
|
262
|
+
limit
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
|
253
267
|
##
|
254
268
|
# A helper method used for generating solr LocalParams, put quotes
|
255
269
|
# around the term unless it's a bare-word. Escape internal quotes
|
@@ -129,6 +129,13 @@ describe BlacklightUrlHelper do
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
+
describe "link_to_previous_document" do
|
133
|
+
context "when the argument is nil" do
|
134
|
+
subject { helper.link_to_previous_document(nil) }
|
135
|
+
it { is_expected.to eq '<span class="previous">« Previous</span>' }
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
132
139
|
describe "link_to_query" do
|
133
140
|
it "should build a link tag to catalog using query string (no other params)" do
|
134
141
|
query = "brilliant"
|
data/spec/lib/blacklight_spec.rb
CHANGED
@@ -1,14 +1,63 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Blacklight do
|
4
|
-
|
5
4
|
context 'root' do
|
6
|
-
|
7
5
|
let(:blroot) { File.expand_path(File.join(__FILE__, '..', '..', '..' )) }
|
8
6
|
|
9
7
|
it 'should return the full path to the BL plugin' do
|
10
8
|
expect(Blacklight.root).to eq blroot
|
11
9
|
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '.default_index' do
|
13
|
+
context 'for a solr index' do
|
14
|
+
before do
|
15
|
+
allow(Blacklight).to receive(:connection_config).and_return(adapter: 'solr')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'is an instance of Blacklight::SolrRepository' do
|
19
|
+
expect(Blacklight.default_index).to be_a Blacklight::Solr::Repository
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.repository_class' do
|
25
|
+
context 'for a solr index' do
|
26
|
+
before do
|
27
|
+
allow(Blacklight).to receive(:connection_config).and_return(adapter: 'solr')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'resolves to the SolrRepository implementation' do
|
31
|
+
expect(Blacklight.repository_class).to eq Blacklight::Solr::Repository
|
32
|
+
end
|
33
|
+
end
|
12
34
|
|
35
|
+
context 'for an elastic_search index' do
|
36
|
+
before do
|
37
|
+
stub_const("Blacklight::ElasticSearch::Repository", double)
|
38
|
+
allow(Blacklight).to receive(:connection_config).and_return(adapter: 'elastic_search')
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'resolves to the ElasticSearch::Repository implementation' do
|
42
|
+
expect(Blacklight.repository_class).to eq Blacklight::ElasticSearch::Repository
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'for an explicitly provided class' do
|
47
|
+
before do
|
48
|
+
stub_const("CustomSearch::Repository", double)
|
49
|
+
allow(Blacklight).to receive(:connection_config).and_return(adapter: 'CustomSearch::Repository')
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'resolves to the custom implementation' do
|
53
|
+
expect(Blacklight.repository_class).to eq CustomSearch::Repository
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '.default_configuration' do
|
59
|
+
it 'is a Blacklight configuration' do
|
60
|
+
expect(Blacklight.default_configuration).to be_a Blacklight::Configuration
|
61
|
+
end
|
13
62
|
end
|
14
63
|
end
|
@@ -102,6 +102,26 @@ describe Blacklight::Solr::SearchBuilderBehavior do
|
|
102
102
|
expect(subject[:"f.subject_topic_facet.facet.limit"]).to eq 21
|
103
103
|
end
|
104
104
|
|
105
|
+
context 'with a negative facet limit' do
|
106
|
+
before do
|
107
|
+
blacklight_config.facet_fields['subject_topic_facet'].limit = -1
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'is negative' do
|
111
|
+
expect(subject[:"f.subject_topic_facet.facet.limit"]).to eq -1
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'with a facet limit set to 0' do
|
116
|
+
before do
|
117
|
+
blacklight_config.facet_fields['subject_topic_facet'].limit = 0
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'is negative' do
|
121
|
+
expect(subject[:"f.subject_topic_facet.facet.limit"]).to eq 0
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
105
125
|
it "should handle no facet_limits in config" do
|
106
126
|
blacklight_config.facet_fields = {}
|
107
127
|
expect(subject).not_to have_key(:"f.subject_topic_facet.facet.limit")
|
@@ -17,7 +17,7 @@ class TestAppGenerator < Rails::Generators::Base
|
|
17
17
|
|
18
18
|
def run_blacklight_generator
|
19
19
|
say_status("warning", "GENERATING BL", :yellow)
|
20
|
-
gem 'blacklight-marc', "~> 5.0"
|
20
|
+
gem 'blacklight-marc', "~> 5.0"
|
21
21
|
|
22
22
|
Bundler.with_clean_env do
|
23
23
|
run "bundle install"
|
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.
|
4
|
+
version: 5.18.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: 2016-01-
|
20
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|
@@ -290,6 +290,7 @@ files:
|
|
290
290
|
- app/controllers/concerns/blacklight/search_context.rb
|
291
291
|
- app/controllers/concerns/blacklight/search_fields.rb
|
292
292
|
- app/controllers/concerns/blacklight/search_helper.rb
|
293
|
+
- app/controllers/concerns/blacklight/search_history.rb
|
293
294
|
- app/controllers/saved_searches_controller.rb
|
294
295
|
- app/controllers/search_history_controller.rb
|
295
296
|
- app/helpers/blacklight/blacklight_helper_behavior.rb
|