blacklight 6.7.0 → 6.8.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 +4 -4
- data/.rubocop.yml +12 -0
- data/.rubocop_todo.yml +69 -40
- data/.travis.yml +9 -8
- data/Gemfile +1 -0
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_header.scss +9 -1
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +2 -1
- data/app/controllers/concerns/blacklight/catalog.rb +2 -2
- data/app/controllers/concerns/blacklight/controller.rb +6 -1
- data/app/controllers/concerns/blacklight/facet.rb +5 -5
- data/app/controllers/concerns/blacklight/request_builders.rb +2 -2
- data/app/controllers/concerns/blacklight/token_based_user.rb +12 -1
- data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +7 -7
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +1 -1
- data/app/models/concerns/blacklight/document.rb +6 -1
- data/app/models/concerns/blacklight/user.rb +3 -4
- data/app/presenters/blacklight/link_alternate_presenter.rb +8 -4
- data/app/presenters/blacklight/rendering/pipeline.rb +6 -1
- data/app/views/catalog/_facet_limit.html.erb +2 -2
- data/blacklight.gemspec +2 -2
- data/config/locales/blacklight.es.yml +1 -0
- data/config/locales/blacklight.fr.yml +1 -0
- data/config/locales/blacklight.pt-BR.yml +17 -0
- data/lib/blacklight/configuration.rb +3 -13
- data/lib/blacklight/search_state.rb +6 -2
- data/lib/blacklight/solr/repository.rb +1 -1
- data/lib/blacklight/solr/response/spelling.rb +2 -2
- data/lib/blacklight/solr/response.rb +1 -1
- data/lib/blacklight/solr/search_builder_behavior.rb +6 -6
- data/lib/generators/blacklight/templates/catalog_controller.rb +2 -0
- data/spec/controllers/blacklight/search_helper_spec.rb +15 -1
- data/spec/controllers/catalog_controller_spec.rb +18 -0
- data/spec/features/autocomplete_spec.rb +6 -0
- data/spec/helpers/deprecated_url_helper_behavior_spec.rb +1 -0
- data/spec/helpers/facets_helper_spec.rb +0 -2
- data/spec/helpers/render_constraints_helper_spec.rb +1 -0
- data/spec/models/blacklight/document_spec.rb +15 -2
- data/spec/models/blacklight/solr/search_builder_spec.rb +46 -0
- data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +30 -0
- data/spec/presenters/pipeline_spec.rb +9 -0
- data/spec/spec_helper.rb +1 -0
- metadata +17 -13
|
@@ -4,13 +4,13 @@ module Blacklight
|
|
|
4
4
|
include ActionView::Helpers::OutputSafetyHelper
|
|
5
5
|
include ActionView::Helpers::TagHelper
|
|
6
6
|
|
|
7
|
-
def initialize(
|
|
8
|
-
@
|
|
7
|
+
def initialize(view_context, document, options)
|
|
8
|
+
@view_context = view_context
|
|
9
9
|
@document = document
|
|
10
10
|
@options = { unique: false, exclude: [] }.merge(options)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
attr_reader :
|
|
13
|
+
attr_reader :view_context, :document, :options
|
|
14
14
|
|
|
15
15
|
# Renders links to alternate representations
|
|
16
16
|
# provided by export formats. Returns empty string if no links available.
|
|
@@ -22,8 +22,12 @@ module Blacklight
|
|
|
22
22
|
|
|
23
23
|
seen.add(spec[:content_type])
|
|
24
24
|
|
|
25
|
-
tag(:link, rel: "alternate", title: format, type: spec[:content_type], href:
|
|
25
|
+
tag(:link, rel: "alternate", title: format, type: spec[:content_type], href: href(format))
|
|
26
26
|
end.compact, "\n")
|
|
27
27
|
end
|
|
28
|
+
|
|
29
|
+
def href(format)
|
|
30
|
+
view_context.polymorphic_url(view_context.search_state.url_for_document(document), format: format)
|
|
31
|
+
end
|
|
28
32
|
end
|
|
29
33
|
end
|
|
@@ -2,6 +2,11 @@ module Blacklight
|
|
|
2
2
|
module Rendering
|
|
3
3
|
# The field rendering pipeline
|
|
4
4
|
class Pipeline
|
|
5
|
+
class_attribute :operations
|
|
6
|
+
|
|
7
|
+
# The ordered list of pipeline operations
|
|
8
|
+
self.operations = [HelperMethod, LinkToFacet, Microdata, Join]
|
|
9
|
+
|
|
5
10
|
def initialize(values, config, document, context, options)
|
|
6
11
|
@values = values
|
|
7
12
|
@config = config
|
|
@@ -25,7 +30,7 @@ module Blacklight
|
|
|
25
30
|
|
|
26
31
|
# Ordered list of operations, Terminator must be at the end.
|
|
27
32
|
def stack
|
|
28
|
-
|
|
33
|
+
operations + [Terminator]
|
|
29
34
|
end
|
|
30
35
|
end
|
|
31
36
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<ul class="facet-values list-unstyled">
|
|
2
2
|
<% paginator = facet_paginator(facet_field, display_facet) %>
|
|
3
|
-
<%= render_facet_limit_list paginator,
|
|
3
|
+
<%= render_facet_limit_list paginator, facet_field.key %>
|
|
4
4
|
|
|
5
5
|
<% unless paginator.last_page? || params[:action] == "facet" %>
|
|
6
6
|
<li class="more_facets_link">
|
|
7
7
|
<%= link_to t("more_#{field_name}_html", scope: 'blacklight.search.facets', default: :more_html, field_name: facet_field.label),
|
|
8
|
-
search_facet_path(id:
|
|
8
|
+
search_facet_path(id: facet_field.key), class: "more_facets_link" %>
|
|
9
9
|
</li>
|
|
10
10
|
<% end %>
|
|
11
11
|
</ul>
|
data/blacklight.gemspec
CHANGED
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
|
29
29
|
s.add_dependency "globalid"
|
|
30
30
|
s.add_dependency "nokogiri", "~>1.6" # XML Parser
|
|
31
31
|
s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
|
|
32
|
-
s.add_dependency "rsolr",
|
|
32
|
+
s.add_dependency "rsolr", ">= 1.0.6", "< 3" # Library for interacting with rSolr.
|
|
33
33
|
s.add_dependency "bootstrap-sass", "~> 3.2"
|
|
34
34
|
s.add_dependency "deprecation"
|
|
35
35
|
s.add_dependency "twitter-typeahead-rails", '0.11.1.pre.corejavascript'
|
|
@@ -45,5 +45,5 @@ Gem::Specification.new do |s|
|
|
|
45
45
|
s.add_development_dependency "coveralls"
|
|
46
46
|
s.add_development_dependency "simplecov"
|
|
47
47
|
s.add_development_dependency "rubocop"
|
|
48
|
-
s.add_development_dependency "rubocop-rspec"
|
|
48
|
+
s.add_development_dependency "rubocop-rspec", '~> 1.8.0'
|
|
49
49
|
end
|
|
@@ -127,12 +127,14 @@ pt-BR:
|
|
|
127
127
|
title: '%{value}'
|
|
128
128
|
author: ' por %{value}'
|
|
129
129
|
url: 'Link: %{url}'
|
|
130
|
+
success: 'SMS Enviado'
|
|
130
131
|
errors:
|
|
131
132
|
to:
|
|
132
133
|
invalid: 'Você precisa digitar um número de telefone válido'
|
|
133
134
|
blank: "Você precisa digitar o número de telefone do destinatário para enviar uma mensagem"
|
|
134
135
|
carrier:
|
|
135
136
|
blank: 'Você precisa selecionar a operadora'
|
|
137
|
+
invalid: 'Você precisa usar uma operadora válida'
|
|
136
138
|
|
|
137
139
|
back_to_search: 'Voltar a busca'
|
|
138
140
|
back_to_bookmarks: 'Voltar aos Favoritos'
|
|
@@ -189,6 +191,7 @@ pt-BR:
|
|
|
189
191
|
more_html: 'mais <span class="sr-only">%{field_name}</span> »'
|
|
190
192
|
selected:
|
|
191
193
|
remove: '[remover]'
|
|
194
|
+
missing: '[Faltando]'
|
|
192
195
|
filters:
|
|
193
196
|
title: 'Sua busca por:'
|
|
194
197
|
label: '%{label}:'
|
|
@@ -202,6 +205,20 @@ pt-BR:
|
|
|
202
205
|
atom_feed: 'Atom para resultados'
|
|
203
206
|
fields:
|
|
204
207
|
default: 'Palavra-chave'
|
|
208
|
+
bookmarks:
|
|
209
|
+
present: 'Nos Favoritos'
|
|
210
|
+
absent: 'Favorite'
|
|
211
|
+
inprogress: 'Salvando...'
|
|
212
|
+
zero_results:
|
|
213
|
+
title: 'Não foram encontratos resultados para a sua busca'
|
|
214
|
+
modify_search: 'Tente modificar sua busca'
|
|
215
|
+
use_fewer_keywords: 'Use menos palavras para começar, depois refine sua busca usando os links à esquerda.'
|
|
216
|
+
search_fields: 'você buscou por %{search_fields}'
|
|
217
|
+
search_everything: 'tente buscar em tudo'
|
|
218
|
+
view_title: 'Ver resultados como: '
|
|
219
|
+
view:
|
|
220
|
+
list: 'Lista'
|
|
221
|
+
|
|
205
222
|
|
|
206
223
|
entry_name:
|
|
207
224
|
default: 'registro'
|
|
@@ -163,18 +163,9 @@ module Blacklight
|
|
|
163
163
|
# solr fields to use for sorting results
|
|
164
164
|
define_field_access :sort_field
|
|
165
165
|
|
|
166
|
-
def initialize(
|
|
167
|
-
super(
|
|
168
|
-
initialize_default_values!
|
|
166
|
+
def initialize(hash = {})
|
|
167
|
+
super(self.class.default_values.deep_dup.merge(hash))
|
|
169
168
|
yield(self) if block_given?
|
|
170
|
-
self
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
# Initialize default values from the class attribute
|
|
174
|
-
def initialize_default_values!
|
|
175
|
-
Marshal.load(Marshal.dump(self.class.default_values)).each do |k, v|
|
|
176
|
-
self[k] ||= v
|
|
177
|
-
end
|
|
178
169
|
end
|
|
179
170
|
|
|
180
171
|
def document_model
|
|
@@ -295,8 +286,7 @@ module Blacklight
|
|
|
295
286
|
end
|
|
296
287
|
end
|
|
297
288
|
|
|
298
|
-
|
|
299
|
-
# Provide a 'deep copy' of Blacklight::Configuration that can be modifyed without affecting
|
|
289
|
+
# Provide a 'deep copy' of Blacklight::Configuration that can be modified without effecting
|
|
300
290
|
# the original Blacklight::Configuration instance.
|
|
301
291
|
#
|
|
302
292
|
# Rails 4.x provides `#deep_dup`, but it aggressively `#dup`'s class names
|
|
@@ -32,9 +32,13 @@ module Blacklight
|
|
|
32
32
|
alias to_h to_hash
|
|
33
33
|
|
|
34
34
|
def reset
|
|
35
|
-
|
|
35
|
+
self.class.new(ActionController::Parameters.new, blacklight_config)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
##
|
|
39
|
+
# Extension point for downstream applications
|
|
40
|
+
# to provide more interesting routing to
|
|
41
|
+
# documents
|
|
38
42
|
def url_for_document(doc, options = {})
|
|
39
43
|
if respond_to?(:blacklight_config) and
|
|
40
44
|
blacklight_config.show.route and
|
|
@@ -116,7 +120,7 @@ module Blacklight
|
|
|
116
120
|
# @yield [params] The merged parameters hash before being sanitized
|
|
117
121
|
def params_for_search(params_to_merge={}, &block)
|
|
118
122
|
# params hash we'll return
|
|
119
|
-
my_params = params.dup.merge(
|
|
123
|
+
my_params = params.dup.merge(self.class.new(params_to_merge, blacklight_config))
|
|
120
124
|
|
|
121
125
|
if block_given?
|
|
122
126
|
yield my_params
|
|
@@ -22,7 +22,7 @@ module Blacklight::Solr::Response::Spelling
|
|
|
22
22
|
# combination of words may not have results.
|
|
23
23
|
# Thanks to Naomi Dushay!
|
|
24
24
|
def words
|
|
25
|
-
@words ||=
|
|
25
|
+
@words ||= begin
|
|
26
26
|
word_suggestions = []
|
|
27
27
|
spellcheck = self.response[:spellcheck]
|
|
28
28
|
if spellcheck && spellcheck[:suggestions]
|
|
@@ -69,7 +69,7 @@ module Blacklight::Solr::Response::Spelling
|
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
word_suggestions.flatten.compact.uniq
|
|
72
|
-
|
|
72
|
+
end
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def collation
|
|
@@ -93,7 +93,7 @@ class Blacklight::Solr::Response < ActiveSupport::HashWithIndifferentAccess
|
|
|
93
93
|
value.each { |v| force_to_utf8(v) }
|
|
94
94
|
when String
|
|
95
95
|
if value.encoding != Encoding::UTF_8
|
|
96
|
-
|
|
96
|
+
Blacklight.logger.warn "Found a non utf-8 value in Blacklight::Solr::Response. \"#{value}\" Encoding is #{value.encoding}"
|
|
97
97
|
value.dup.force_encoding('UTF-8')
|
|
98
98
|
else
|
|
99
99
|
value
|
|
@@ -182,14 +182,14 @@ module Blacklight::Solr
|
|
|
182
182
|
|
|
183
183
|
# Now override with our specific things for fetching facet values
|
|
184
184
|
facet_ex = facet_config.respond_to?(:ex) ? facet_config.ex : nil
|
|
185
|
-
solr_params[:"facet.field"] = with_ex_local_param(facet_ex,
|
|
185
|
+
solr_params[:"facet.field"] = with_ex_local_param(facet_ex, facet_config.field)
|
|
186
186
|
|
|
187
187
|
limit = if scope.respond_to?(:facet_list_limit)
|
|
188
188
|
scope.facet_list_limit.to_s.to_i
|
|
189
189
|
elsif solr_params["facet.limit"]
|
|
190
190
|
solr_params["facet.limit"].to_i
|
|
191
191
|
else
|
|
192
|
-
20
|
|
192
|
+
facet_config.fetch(:more_limit, 20)
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
page = blacklight_params.fetch(request_keys[:page], 1).to_i
|
|
@@ -200,13 +200,13 @@ module Blacklight::Solr
|
|
|
200
200
|
|
|
201
201
|
# Need to set as f.facet_field.facet.* to make sure we
|
|
202
202
|
# override any field-specific default in the solr request handler.
|
|
203
|
-
solr_params[:"f.#{
|
|
204
|
-
solr_params[:"f.#{
|
|
203
|
+
solr_params[:"f.#{facet_config.field}.facet.limit"] = limit + 1
|
|
204
|
+
solr_params[:"f.#{facet_config.field}.facet.offset"] = offset
|
|
205
205
|
if blacklight_params[request_keys[:sort]]
|
|
206
|
-
solr_params[:"f.#{
|
|
206
|
+
solr_params[:"f.#{facet_config.field}.facet.sort"] = sort
|
|
207
207
|
end
|
|
208
208
|
if blacklight_params[request_keys[:prefix]]
|
|
209
|
-
solr_params[:"f.#{
|
|
209
|
+
solr_params[:"f.#{facet_config.field}.facet.prefix"] = prefix
|
|
210
210
|
end
|
|
211
211
|
solr_params[:rows] = 0
|
|
212
212
|
end
|
|
@@ -38,10 +38,12 @@ class <%= controller_name.classify %>Controller < ApplicationController
|
|
|
38
38
|
# solr field configuration for search results/index views
|
|
39
39
|
config.index.title_field = 'title_display'
|
|
40
40
|
config.index.display_type_field = 'format'
|
|
41
|
+
#config.index.thumbnail_field = 'thumbnail_path_ss'
|
|
41
42
|
|
|
42
43
|
# solr field configuration for document/show views
|
|
43
44
|
#config.show.title_field = 'title_display'
|
|
44
45
|
#config.show.display_type_field = 'format'
|
|
46
|
+
#config.show.thumbnail_field = 'thumbnail_path_ss'
|
|
45
47
|
|
|
46
48
|
# solr fields that will be treated as facets by the blacklight application
|
|
47
49
|
# The ordering of the field names is the order of the display
|
|
@@ -34,7 +34,7 @@ describe Blacklight::SearchHelper do
|
|
|
34
34
|
|
|
35
35
|
let(:blacklight_config) { Blacklight::Configuration.new }
|
|
36
36
|
let(:copy_of_catalog_config) { ::CatalogController.blacklight_config.deep_copy }
|
|
37
|
-
let(:blacklight_solr) { RSolr.connect(Blacklight.connection_config) }
|
|
37
|
+
let(:blacklight_solr) { RSolr.connect(Blacklight.connection_config.except(:adapter)) }
|
|
38
38
|
|
|
39
39
|
before(:each) do
|
|
40
40
|
@all_docs_query = ''
|
|
@@ -392,6 +392,20 @@ describe Blacklight::SearchHelper do
|
|
|
392
392
|
expect(subject.facet_limit_for("language_facet")).to eq 10
|
|
393
393
|
end
|
|
394
394
|
end
|
|
395
|
+
|
|
396
|
+
context 'for facet fields with a key that is different from the field name' do
|
|
397
|
+
let(:blacklight_config) do
|
|
398
|
+
Blacklight::Configuration.new do |config|
|
|
399
|
+
config.add_facet_field 'some_key', field: 'x', limit: true
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
it 'gets the limit from the facet field in the @response' do
|
|
404
|
+
response = instance_double(Blacklight::Solr::Response, aggregations: { 'x' => double(limit: 16) })
|
|
405
|
+
subject.instance_variable_set(:@response, response)
|
|
406
|
+
expect(subject.facet_limit_for('some_key')).to eq 15
|
|
407
|
+
end
|
|
408
|
+
end
|
|
395
409
|
end
|
|
396
410
|
|
|
397
411
|
# TODO: more complex queries! phrases, offset into search results, non-latin, boosting(?)
|
|
@@ -523,6 +523,24 @@ describe CatalogController do
|
|
|
523
523
|
expect(json["response"]["facets"]["items"].first["value"]).to eq 'Book'
|
|
524
524
|
end
|
|
525
525
|
end
|
|
526
|
+
|
|
527
|
+
context 'for a facet field with a key different from the underlying field name' do
|
|
528
|
+
before do
|
|
529
|
+
controller.blacklight_config.add_facet_field 'params_key', field: 'format'
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
it 'is successful' do
|
|
533
|
+
get :facet, params: { id: 'params_key' }
|
|
534
|
+
|
|
535
|
+
expect(response).to be_successful
|
|
536
|
+
|
|
537
|
+
expect(assigns[:facet]).to be_kind_of Blacklight::Configuration::FacetField
|
|
538
|
+
expect(assigns[:facet].key).to eq 'params_key'
|
|
539
|
+
expect(assigns[:facet].field).to eq 'format'
|
|
540
|
+
|
|
541
|
+
expect(assigns[:pagination].items.first['value']).to eq 'Book'
|
|
542
|
+
end
|
|
543
|
+
end
|
|
526
544
|
end
|
|
527
545
|
|
|
528
546
|
describe "#add_to_search_history" do
|
|
@@ -16,6 +16,7 @@ describe Blacklight::DeprecatedUrlHelperBehavior do
|
|
|
16
16
|
allow(helper).to receive(:search_state).and_return(search_state)
|
|
17
17
|
allow(helper).to receive(:params).and_return(params)
|
|
18
18
|
allow(helper).to receive(:blacklight_config).and_return(blacklight_config)
|
|
19
|
+
allow(controller).to receive(:search_state_class).and_return(Blacklight::SearchState)
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
describe '#params_for_search' do
|
|
@@ -70,6 +70,7 @@ describe RenderConstraintsHelper do
|
|
|
70
70
|
let(:params) { ActionController::Parameters.new f: { 'type' => [''] } }
|
|
71
71
|
before do
|
|
72
72
|
allow(helper).to receive(:blacklight_config).and_return(config)
|
|
73
|
+
allow(controller).to receive(:search_state_class).and_return(Blacklight::SearchState)
|
|
73
74
|
end
|
|
74
75
|
subject { helper.render_constraints_filters(params) }
|
|
75
76
|
|
|
@@ -2,10 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
describe Blacklight::Document do
|
|
4
4
|
let(:data) { {} }
|
|
5
|
-
|
|
5
|
+
let(:test_class) do
|
|
6
6
|
Class.new do
|
|
7
7
|
include Blacklight::Document
|
|
8
|
-
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
subject { test_class.new(data) }
|
|
12
|
+
|
|
13
|
+
describe '.new' do
|
|
14
|
+
it 'accepts a hash' do
|
|
15
|
+
expect(test_class.new(id: 1)[:id]).to eq 1
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'accepts a SolrDocument' do
|
|
19
|
+
expect(Deprecation).to receive(:warn)
|
|
20
|
+
expect(test_class.new(test_class.new(id: 1))[:id]).to eq 1
|
|
21
|
+
end
|
|
9
22
|
end
|
|
10
23
|
|
|
11
24
|
describe "#has?" do
|
|
@@ -146,6 +146,21 @@ describe Blacklight::Solr::SearchBuilderBehavior do
|
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
+
context "facet parameters" do
|
|
150
|
+
let(:blacklight_config) do
|
|
151
|
+
Blacklight::Configuration.new.tap do |config|
|
|
152
|
+
config.add_facet_field key: 'param_key', field: 'solr_field', limit: 50, ex: 'other'
|
|
153
|
+
|
|
154
|
+
config.add_facet_fields_to_solr_request!
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "should use the configured solr field name in queries" do
|
|
159
|
+
expect(subject).to include 'f.solr_field.facet.limit': 51,
|
|
160
|
+
'facet.field': ['{!ex=other}solr_field']
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
149
164
|
describe 'for an entirely empty search' do
|
|
150
165
|
|
|
151
166
|
it 'should not have a q param' do
|
|
@@ -564,6 +579,7 @@ describe Blacklight::Solr::SearchBuilderBehavior do
|
|
|
564
579
|
config.add_facet_field 'format'
|
|
565
580
|
config.add_facet_field 'format_ordered', sort: :count
|
|
566
581
|
config.add_facet_field 'format_limited', limit: 5
|
|
582
|
+
config.add_facet_field 'format_more_limited', limit: 5, more_limit: 50
|
|
567
583
|
end
|
|
568
584
|
end
|
|
569
585
|
|
|
@@ -588,6 +604,36 @@ describe Blacklight::Solr::SearchBuilderBehavior do
|
|
|
588
604
|
expect(solr_parameters[:"f.#{facet_field}.facet.offset"]).to eq 20
|
|
589
605
|
end
|
|
590
606
|
end
|
|
607
|
+
|
|
608
|
+
context 'for a field with a configured more_limit' do
|
|
609
|
+
let(:facet_field) { 'format_more_limited' }
|
|
610
|
+
|
|
611
|
+
it 'uses the more_limit configuration' do
|
|
612
|
+
expect(solr_parameters[:"f.#{facet_field}.facet.limit"]).to eq 51
|
|
613
|
+
end
|
|
614
|
+
end
|
|
615
|
+
|
|
616
|
+
context 'for a field with a param key different from the field name' do
|
|
617
|
+
let(:user_params) { { page_key => 2, 'facet.sort': 'index', 'facet.prefix': 'x' } }
|
|
618
|
+
let(:facet_field) { 'param_key' }
|
|
619
|
+
|
|
620
|
+
let(:blacklight_config) do
|
|
621
|
+
Blacklight::Configuration.new.tap do |config|
|
|
622
|
+
config.add_facet_field key: 'param_key', field: 'solr_field', more_limit: 50, ex: 'other'
|
|
623
|
+
|
|
624
|
+
config.add_facet_fields_to_solr_request!
|
|
625
|
+
end
|
|
626
|
+
end
|
|
627
|
+
|
|
628
|
+
it "should use the configured solr field name in queries" do
|
|
629
|
+
expect(solr_parameters).to include 'f.solr_field.facet.limit': 51,
|
|
630
|
+
'f.solr_field.facet.offset': 50,
|
|
631
|
+
'f.solr_field.facet.sort': 'index',
|
|
632
|
+
'f.solr_field.facet.prefix': 'x',
|
|
633
|
+
'facet.field': '{!ex=other}solr_field'
|
|
634
|
+
end
|
|
635
|
+
end
|
|
636
|
+
|
|
591
637
|
it 'defaults limit to 20' do
|
|
592
638
|
expect(solr_parameters[:"f.#{facet_field}.facet.limit"]).to eq 21
|
|
593
639
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
RSpec.describe Blacklight::LinkAlternatePresenter do
|
|
5
|
+
let(:view_context) { double }
|
|
6
|
+
let(:document) { SolrDocument.new(id: 9999) }
|
|
7
|
+
let(:options) { {} }
|
|
8
|
+
let(:config) { Blacklight::Configuration.new }
|
|
9
|
+
let(:parameter_class) { ActionController::Parameters }
|
|
10
|
+
let(:params) { parameter_class.new }
|
|
11
|
+
let(:search_state) { Blacklight::SearchState.new(params, config) }
|
|
12
|
+
|
|
13
|
+
let(:presenter) { described_class.new(view_context, document, options) }
|
|
14
|
+
before do
|
|
15
|
+
allow(view_context).to receive(:search_state).and_return(search_state)
|
|
16
|
+
allow(view_context).to receive(:polymorphic_url) do |doc, opts|
|
|
17
|
+
"http://test.host/catalog/#{doc.to_param}.#{opts[:format]}"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe "#render" do
|
|
22
|
+
subject { presenter.render }
|
|
23
|
+
let(:expected_html) do
|
|
24
|
+
'<link rel="alternate" title="xml" type="application/xml" href="http://test.host/catalog/9999.xml" />' \
|
|
25
|
+
'<link rel="alternate" title="dc_xml" type="text/xml" href="http://test.host/catalog/9999.dc_xml" />' \
|
|
26
|
+
'<link rel="alternate" title="oai_dc_xml" type="text/xml" href="http://test.host/catalog/9999.oai_dc_xml" />'
|
|
27
|
+
end
|
|
28
|
+
it { is_expected.to be_equivalent_to expected_html }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -6,6 +6,7 @@ describe Blacklight::Rendering::Pipeline do
|
|
|
6
6
|
let(:context) { double }
|
|
7
7
|
let(:options) { double }
|
|
8
8
|
let(:presenter) { described_class.new(values, field_config, document, context, options) }
|
|
9
|
+
|
|
9
10
|
describe "render" do
|
|
10
11
|
subject { presenter.render }
|
|
11
12
|
let(:values) { ['a', 'b'] }
|
|
@@ -24,4 +25,12 @@ describe Blacklight::Rendering::Pipeline do
|
|
|
24
25
|
it { is_expected.to have_selector("span[@itemprop='some-prop']", :text => "a") }
|
|
25
26
|
end
|
|
26
27
|
end
|
|
28
|
+
|
|
29
|
+
describe "#operations" do
|
|
30
|
+
subject { described_class.operations }
|
|
31
|
+
it { is_expected.to eq [Blacklight::Rendering::HelperMethod,
|
|
32
|
+
Blacklight::Rendering::LinkToFacet,
|
|
33
|
+
Blacklight::Rendering::Microdata,
|
|
34
|
+
Blacklight::Rendering::Join] }
|
|
35
|
+
end
|
|
27
36
|
end
|
data/spec/spec_helper.rb
CHANGED
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: 6.
|
|
4
|
+
version: 6.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Rochkind
|
|
@@ -17,7 +17,7 @@ authors:
|
|
|
17
17
|
autorequire:
|
|
18
18
|
bindir: exe
|
|
19
19
|
cert_chain: []
|
|
20
|
-
date:
|
|
20
|
+
date: 2017-03-03 00:00:00.000000000 Z
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|
|
23
23
|
name: rails
|
|
@@ -85,22 +85,22 @@ dependencies:
|
|
|
85
85
|
name: rsolr
|
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
|
87
87
|
requirements:
|
|
88
|
-
- - "~>"
|
|
89
|
-
- !ruby/object:Gem::Version
|
|
90
|
-
version: '1.0'
|
|
91
88
|
- - ">="
|
|
92
89
|
- !ruby/object:Gem::Version
|
|
93
90
|
version: 1.0.6
|
|
91
|
+
- - "<"
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '3'
|
|
94
94
|
type: :runtime
|
|
95
95
|
prerelease: false
|
|
96
96
|
version_requirements: !ruby/object:Gem::Requirement
|
|
97
97
|
requirements:
|
|
98
|
-
- - "~>"
|
|
99
|
-
- !ruby/object:Gem::Version
|
|
100
|
-
version: '1.0'
|
|
101
98
|
- - ">="
|
|
102
99
|
- !ruby/object:Gem::Version
|
|
103
100
|
version: 1.0.6
|
|
101
|
+
- - "<"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '3'
|
|
104
104
|
- !ruby/object:Gem::Dependency
|
|
105
105
|
name: bootstrap-sass
|
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -301,16 +301,16 @@ dependencies:
|
|
|
301
301
|
name: rubocop-rspec
|
|
302
302
|
requirement: !ruby/object:Gem::Requirement
|
|
303
303
|
requirements:
|
|
304
|
-
- - "
|
|
304
|
+
- - "~>"
|
|
305
305
|
- !ruby/object:Gem::Version
|
|
306
|
-
version:
|
|
306
|
+
version: 1.8.0
|
|
307
307
|
type: :development
|
|
308
308
|
prerelease: false
|
|
309
309
|
version_requirements: !ruby/object:Gem::Requirement
|
|
310
310
|
requirements:
|
|
311
|
-
- - "
|
|
311
|
+
- - "~>"
|
|
312
312
|
- !ruby/object:Gem::Version
|
|
313
|
-
version:
|
|
313
|
+
version: 1.8.0
|
|
314
314
|
description: |-
|
|
315
315
|
Blacklight is an open source Solr user interface discovery platform.
|
|
316
316
|
You can use Blacklight to enable searching and browsing of your
|
|
@@ -628,6 +628,7 @@ files:
|
|
|
628
628
|
- spec/controllers/search_history_controller_spec.rb
|
|
629
629
|
- spec/controllers/suggest_controller_spec.rb
|
|
630
630
|
- spec/features/alternate_controller_spec.rb
|
|
631
|
+
- spec/features/autocomplete_spec.rb
|
|
631
632
|
- spec/features/bookmarks_spec.rb
|
|
632
633
|
- spec/features/did_you_mean_spec.rb
|
|
633
634
|
- spec/features/facets_spec.rb
|
|
@@ -687,6 +688,7 @@ files:
|
|
|
687
688
|
- spec/models/record_mailer_spec.rb
|
|
688
689
|
- spec/models/search_spec.rb
|
|
689
690
|
- spec/models/solr_document_spec.rb
|
|
691
|
+
- spec/presenters/blacklight/link_alternate_presenter_spec.rb
|
|
690
692
|
- spec/presenters/document_presenter_spec.rb
|
|
691
693
|
- spec/presenters/index_presenter_spec.rb
|
|
692
694
|
- spec/presenters/pipeline_spec.rb
|
|
@@ -746,7 +748,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
746
748
|
version: '0'
|
|
747
749
|
requirements: []
|
|
748
750
|
rubyforge_project:
|
|
749
|
-
rubygems_version: 2.
|
|
751
|
+
rubygems_version: 2.6.8
|
|
750
752
|
signing_key:
|
|
751
753
|
specification_version: 4
|
|
752
754
|
summary: Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr)
|
|
@@ -765,6 +767,7 @@ test_files:
|
|
|
765
767
|
- spec/controllers/search_history_controller_spec.rb
|
|
766
768
|
- spec/controllers/suggest_controller_spec.rb
|
|
767
769
|
- spec/features/alternate_controller_spec.rb
|
|
770
|
+
- spec/features/autocomplete_spec.rb
|
|
768
771
|
- spec/features/bookmarks_spec.rb
|
|
769
772
|
- spec/features/did_you_mean_spec.rb
|
|
770
773
|
- spec/features/facets_spec.rb
|
|
@@ -824,6 +827,7 @@ test_files:
|
|
|
824
827
|
- spec/models/record_mailer_spec.rb
|
|
825
828
|
- spec/models/search_spec.rb
|
|
826
829
|
- spec/models/solr_document_spec.rb
|
|
830
|
+
- spec/presenters/blacklight/link_alternate_presenter_spec.rb
|
|
827
831
|
- spec/presenters/document_presenter_spec.rb
|
|
828
832
|
- spec/presenters/index_presenter_spec.rb
|
|
829
833
|
- spec/presenters/pipeline_spec.rb
|