blacklight 6.12.0 → 6.13.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/VERSION +1 -1
- data/app/controllers/concerns/blacklight/search_fields.rb +4 -12
- data/app/helpers/blacklight/configuration_helper_behavior.rb +29 -3
- data/app/views/catalog/_sort_widget.html.erb +2 -2
- data/lib/generators/blacklight/install_generator.rb +10 -9
- data/spec/controllers/blacklight/search_fields_spec.rb +9 -13
- data/spec/helpers/configuration_helper_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f8e150bbc29ab7fea77523b447dddfc11c32c7d
|
4
|
+
data.tar.gz: 5e9a545db8bf223f3ebf452464055408739d2620
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a412554969d9774294084579801d8b35804d741952a8795fd45cd0d8c810c66c3a63e96c8611ef9663ecf1574e0ff0e2dc05dda706b2ed778ec0afec332babd8
|
7
|
+
data.tar.gz: 2ab4d5eaf1663d0557f4d196f475f4819d816211b1006cbbc9caa406075c0d7f5c1a9a744de458e5a667ca5f7ecc6f9de6d0a159b57ce062d82c8265b1974695
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.
|
1
|
+
6.13.0
|
@@ -26,6 +26,9 @@
|
|
26
26
|
#
|
27
27
|
##
|
28
28
|
module Blacklight::SearchFields
|
29
|
+
extend Deprecation
|
30
|
+
self.deprecation_horizon = 'blacklight 7.x'
|
31
|
+
|
29
32
|
# Looks up search field config list from blacklight_config[:search_fields], and
|
30
33
|
# 'normalizes' all field config hashes using normalize_config method.
|
31
34
|
def search_field_list
|
@@ -37,22 +40,11 @@ module Blacklight::SearchFields
|
|
37
40
|
def search_field_def_for_key(key)
|
38
41
|
blacklight_config.search_fields[key]
|
39
42
|
end
|
43
|
+
deprecation_deprecate search_field_def_for_key: "Use blacklight_config.search_fields[key]"
|
40
44
|
|
41
45
|
# Returns default search field, used for simpler display in history, etc.
|
42
46
|
# if not set in blacklight_config, defaults to first field listed in #search_field_list
|
43
47
|
def default_search_field
|
44
48
|
blacklight_config.default_search_field || search_field_list.first
|
45
49
|
end
|
46
|
-
|
47
|
-
# Shortcut for commonly needed operation, look up display
|
48
|
-
# label for the key specified. Returns "Keyword" if a label
|
49
|
-
# can't be found.
|
50
|
-
def label_for_search_field(key)
|
51
|
-
field_def = search_field_def_for_key(key)
|
52
|
-
if field_def && field_def.label
|
53
|
-
field_def.label
|
54
|
-
else
|
55
|
-
I18n.t('blacklight.search.fields.default')
|
56
|
-
end
|
57
|
-
end
|
58
50
|
end
|
@@ -14,7 +14,7 @@ module Blacklight::ConfigurationHelperBehavior
|
|
14
14
|
|
15
15
|
# Used in the document_list partial (search view) for building a select element
|
16
16
|
def sort_fields
|
17
|
-
active_sort_fields.map { |
|
17
|
+
active_sort_fields.map { |_sort_key, field_config| [sort_field_label(field_config.key), field_config.key] }
|
18
18
|
end
|
19
19
|
deprecation_deprecate :sort_fields
|
20
20
|
|
@@ -31,8 +31,8 @@ module Blacklight::ConfigurationHelperBehavior
|
|
31
31
|
# an html select based on #search_field_list. Skips search_fields
|
32
32
|
# marked :include_in_simple_select => false
|
33
33
|
def search_field_options_for_select
|
34
|
-
blacklight_config.search_fields.collect do |
|
35
|
-
[field_def.
|
34
|
+
blacklight_config.search_fields.collect do |_key, field_def|
|
35
|
+
[label_for_search_field(field_def.key), field_def.key] if should_render_field?(field_def)
|
36
36
|
end.compact
|
37
37
|
end
|
38
38
|
|
@@ -107,6 +107,32 @@ module Blacklight::ConfigurationHelperBehavior
|
|
107
107
|
)
|
108
108
|
end
|
109
109
|
|
110
|
+
# Shortcut for commonly needed operation, look up display
|
111
|
+
# label for the key specified. Returns "Keyword" if a label
|
112
|
+
# can't be found.
|
113
|
+
def label_for_search_field(key)
|
114
|
+
field_config = blacklight_config.search_fields[key]
|
115
|
+
field_config ||= Blacklight::Configuration::NullField.new(key: key)
|
116
|
+
|
117
|
+
field_label(
|
118
|
+
:"blacklight.search.fields.search.#{field_config.key}",
|
119
|
+
:"blacklight.search.fields.#{field_config.key}",
|
120
|
+
(field_config.label if field_config),
|
121
|
+
key.to_s.humanize
|
122
|
+
)
|
123
|
+
end
|
124
|
+
|
125
|
+
def sort_field_label(key)
|
126
|
+
field_config = blacklight_config.sort_fields[key]
|
127
|
+
field_config ||= Blacklight::Configuration::NullField.new(key: key)
|
128
|
+
|
129
|
+
field_label(
|
130
|
+
:"blacklight.search.fields.sort.#{key}",
|
131
|
+
(field_config.label if field_config),
|
132
|
+
key.to_s.humanize
|
133
|
+
)
|
134
|
+
end
|
135
|
+
|
110
136
|
##
|
111
137
|
# Look up the label for a solr field.
|
112
138
|
#
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<% if show_sort_and_per_page? and active_sort_fields.many? %>
|
2
2
|
<div id="sort-dropdown" class="btn-group">
|
3
3
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
4
|
-
<%= t('blacklight.search.sort.label', :field =>current_sort_field.
|
4
|
+
<%= t('blacklight.search.sort.label', :field =>sort_field_label(current_sort_field.key)) %> <span class="caret"></span>
|
5
5
|
</button>
|
6
6
|
|
7
7
|
<ul class="dropdown-menu" role="menu">
|
8
8
|
<%- active_sort_fields.each do |sort_key, field_config| %>
|
9
|
-
<li><%= link_to(
|
9
|
+
<li><%= link_to(sort_field_label(sort_key), url_for(search_state.params_for_search(sort: sort_key))) %></li>
|
10
10
|
<%- end -%>
|
11
11
|
</ul>
|
12
12
|
</div>
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Blacklight
|
3
3
|
class Install < Rails::Generators::Base
|
4
|
-
|
5
4
|
source_root File.expand_path('../templates', __FILE__)
|
6
|
-
|
5
|
+
|
7
6
|
argument :model_name , type: :string , default: "user"
|
8
7
|
argument :controller_name, type: :string , default: "catalog"
|
9
8
|
argument :document_name, type: :string , default: "solr_document"
|
@@ -14,11 +13,12 @@ module Blacklight
|
|
14
13
|
class_option :jettywrapper, type: :boolean, default: false, desc: "Use jettywrapper to download and control Jetty"
|
15
14
|
class_option :marc , type: :boolean, default: false, aliases: "-m", desc: "Generate MARC-based demo ."
|
16
15
|
class_option :'skip-assets', type: :boolean, default: false, desc: "Skip generating javascript and css assets into the application"
|
16
|
+
class_option :'skip-solr', type: :boolean, default: false, desc: "Skip generating solr configurations."
|
17
17
|
|
18
18
|
desc <<-EOS
|
19
19
|
This generator makes the following changes to your application:
|
20
20
|
1. Generates blacklight:models
|
21
|
-
2. Generates utilities for working with solr
|
21
|
+
2. Generates utilities for working with solr
|
22
22
|
3. Creates a number of public assets, including images, stylesheets, and javascript
|
23
23
|
4. Injects behavior into your user application_controller.rb
|
24
24
|
5. Adds example configurations for dealing with MARC-like data
|
@@ -28,6 +28,7 @@ module Blacklight
|
|
28
28
|
EOS
|
29
29
|
|
30
30
|
def add_solr_wrapper
|
31
|
+
return if options[:'skip-solr']
|
31
32
|
generator_options = '--jettywrapper' if options[:jettywrapper]
|
32
33
|
solr_generator = if options[:jettywrapper]
|
33
34
|
'blacklight:solr4'
|
@@ -47,11 +48,11 @@ module Blacklight
|
|
47
48
|
|
48
49
|
# Copy all files in templates/public/ directory to public/
|
49
50
|
# Call external generator in AssetsGenerator, so we can
|
50
|
-
# leave that callable seperately too.
|
51
|
-
def copy_public_assets
|
51
|
+
# leave that callable seperately too.
|
52
|
+
def copy_public_assets
|
52
53
|
generate "blacklight:assets" unless options[:'skip-assets']
|
53
54
|
end
|
54
|
-
|
55
|
+
|
55
56
|
def generate_blacklight_document
|
56
57
|
generate 'blacklight:document', document_name
|
57
58
|
end
|
@@ -63,20 +64,20 @@ module Blacklight
|
|
63
64
|
def generate_blacklight_models
|
64
65
|
generate 'blacklight:models'
|
65
66
|
end
|
66
|
-
|
67
|
+
|
67
68
|
def generate_blacklight_user
|
68
69
|
generator_args = [model_name]
|
69
70
|
if options[:devise]
|
70
71
|
generator_args << "--devise #{options[:devise]}"
|
71
72
|
end
|
72
|
-
|
73
|
+
|
73
74
|
generate 'blacklight:user', generator_args.join(" ")
|
74
75
|
end
|
75
76
|
|
76
77
|
def generate_controller
|
77
78
|
generate 'blacklight:controller', controller_name
|
78
79
|
end
|
79
|
-
|
80
|
+
|
80
81
|
def add_default_catalog_route
|
81
82
|
route("root to: \"#{controller_name}#index\"")
|
82
83
|
end
|
@@ -29,20 +29,16 @@ describe Blacklight::SearchFields do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
expect(@search_field_obj.search_field_def_for_key("title").key).to eq "title"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "finds label by key" do
|
41
|
-
expect(@search_field_obj.label_for_search_field("title")).to eq "Title"
|
42
|
-
end
|
32
|
+
describe "#search_field_def_for_key" do
|
33
|
+
it "fills in default qt where needed" do
|
34
|
+
expect(Deprecation).to receive(:warn).at_least(:once)
|
35
|
+
expect(@search_field_obj.search_field_def_for_key("all_fields").qt).to eq @config.default_solr_params[:qt]
|
36
|
+
end
|
43
37
|
|
44
|
-
|
45
|
-
|
38
|
+
it "lookups field definitions by key" do
|
39
|
+
expect(Deprecation).to receive(:warn).at_least(:once)
|
40
|
+
expect(@search_field_obj.search_field_def_for_key("title").key).to eq "title"
|
41
|
+
end
|
46
42
|
end
|
47
43
|
|
48
44
|
describe "for unspecified :key" do
|
@@ -270,4 +270,18 @@ describe BlacklightConfigurationHelper do
|
|
270
270
|
expect(select_arguments).not_to include(["No Display", "no_display"])
|
271
271
|
end
|
272
272
|
end
|
273
|
+
|
274
|
+
describe "#label_for_search_field" do
|
275
|
+
before do
|
276
|
+
blacklight_config.add_search_field 'title', :qt => 'title_search'
|
277
|
+
end
|
278
|
+
|
279
|
+
it "finds label by key" do
|
280
|
+
expect(helper.label_for_search_field("title")).to eq "Title"
|
281
|
+
end
|
282
|
+
|
283
|
+
it "supplies default label for key not found" do
|
284
|
+
expect(helper.label_for_search_field("non_existent_key")).to eq "Non existent key"
|
285
|
+
end
|
286
|
+
end
|
273
287
|
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: 6.
|
4
|
+
version: 6.13.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: 2017-
|
20
|
+
date: 2017-12-06 00:00:00.000000000 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rails
|