blacklight-hierarchy 6.3.0 → 6.5.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/.github/dependabot.yml +6 -0
- data/.github/workflows/ruby.yml +26 -26
- data/README.md +7 -0
- data/app/assets/stylesheets/blacklight/hierarchy/hierarchy.scss +13 -8
- data/app/models/blacklight/hierarchy/facet_tree.rb +2 -0
- data/blacklight-hierarchy.gemspec +1 -1
- data/lib/blacklight/hierarchy/version.rb +1 -1
- data/package.json +1 -1
- data/spec/models/blacklight/hierarchy/facet_tree_spec.rb +57 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0087020faf523fb8671351fa18c62b7d4f2bd09f254b24564a5a5d7aac9d5593'
|
4
|
+
data.tar.gz: 6ffb7349402eea8340d105cc747d95d0089c94a552700f5f1106cb6fb069173a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66d064cea30098266d2276b2806775a348250f8f1eb9bd27958018502589dbd6402bf18273ab1cd034e85a6747ef0fa74aee88e93d0d1bda71552284c656d192
|
7
|
+
data.tar.gz: 685bd238b6bec0f0c41d2b3bbd831111734c3b472f5949e8f27b90f13ffa3c387784d486b617b4cab07ba5b16e490bd6584c94b0c20e557f0c0479a5697107d3
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,40 +9,40 @@ name: CI
|
|
9
9
|
|
10
10
|
on:
|
11
11
|
push:
|
12
|
-
branches: [
|
12
|
+
branches: [main]
|
13
13
|
pull_request:
|
14
|
-
branches: [
|
14
|
+
branches: [main]
|
15
15
|
|
16
16
|
jobs:
|
17
17
|
test:
|
18
18
|
runs-on: ubuntu-latest
|
19
19
|
strategy:
|
20
20
|
matrix:
|
21
|
-
ruby: [
|
22
|
-
rails_version: [
|
23
|
-
blacklight_version: [
|
21
|
+
ruby: ["3.3", "3.4"]
|
22
|
+
rails_version: ["7.2.2.1", "8.0.2"]
|
23
|
+
blacklight_version: ["8.8.4"]
|
24
24
|
include:
|
25
|
-
- ruby:
|
26
|
-
rails_version:
|
27
|
-
- ruby:
|
28
|
-
rails_version:
|
29
|
-
name:
|
30
|
-
blacklight_version:
|
25
|
+
- ruby: "3.2"
|
26
|
+
rails_version: "7.1.3.4"
|
27
|
+
- ruby: "3.3"
|
28
|
+
rails_version: "7.1.3.4"
|
29
|
+
name: "Blacklight 7"
|
30
|
+
blacklight_version: "7.38.0"
|
31
31
|
env:
|
32
32
|
BLACKLIGHT_VERSION: ${{ matrix.blacklight_version }}
|
33
33
|
steps:
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
34
|
+
- uses: actions/checkout@v4
|
35
|
+
- name: Set up Ruby
|
36
|
+
uses: ruby/setup-ruby@v1
|
37
|
+
with:
|
38
|
+
ruby-version: ${{ matrix.ruby }}
|
39
|
+
bundler: latest
|
40
|
+
- name: Install dependencies
|
41
|
+
run: bundle install
|
42
|
+
env:
|
43
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
44
|
+
- name: Run tests
|
45
|
+
run: bundle exec rake ci
|
46
|
+
env:
|
47
|
+
RAILS_VERSION: ${{ matrix.rails_version }}
|
48
|
+
ENGINE_CART_RAILS_OPTIONS: "--skip-git --skip-listen --skip-spring --skip-keeps --skip-kamal --skip-solid --skip-coffee --skip-test -a propshaft --css=bootstrap"
|
data/README.md
CHANGED
@@ -146,3 +146,10 @@ $ npm publish
|
|
146
146
|
- WRITE TESTS
|
147
147
|
- Switch internal facet management from hack-y Hash to `Blacklight::Hierarchy::FacetGroup` class (already implemented, but not plumbed up)
|
148
148
|
- Clarify when suffix is applied/required/etc.
|
149
|
+
|
150
|
+
## Developing gem
|
151
|
+
- Clone locally `git@github.com:sul-dlss/blacklight-hierarchy.git`
|
152
|
+
- go into project directory `cd blacklight-hierarchy`
|
153
|
+
- install dependencies `bundle install`
|
154
|
+
- Create a test app to develop and test against `bundle exec rake engine_cart:generate
|
155
|
+
- Run tests `bundle exec rspec`
|
@@ -5,6 +5,10 @@ $b-h-opened-icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg
|
|
5
5
|
|
6
6
|
$text-muted: #777 !default;
|
7
7
|
|
8
|
+
:root {
|
9
|
+
--text-muted: #{$text-muted};
|
10
|
+
}
|
11
|
+
|
8
12
|
.facet-hierarchy {
|
9
13
|
list-style-type: none;
|
10
14
|
padding-left: 0;
|
@@ -49,11 +53,11 @@ $text-muted: #777 !default;
|
|
49
53
|
}
|
50
54
|
}
|
51
55
|
|
52
|
-
.twiddle
|
56
|
+
.twiddle > .toggle-handle {
|
53
57
|
background-color: transparent;
|
54
58
|
}
|
55
59
|
|
56
|
-
.twiddle
|
60
|
+
.twiddle > .toggle-handle .toggle-icon {
|
57
61
|
background-position: center;
|
58
62
|
background-repeat: no-repeat;
|
59
63
|
margin-top: 0.25rem;
|
@@ -61,25 +65,26 @@ $text-muted: #777 !default;
|
|
61
65
|
min-width: 1.1rem;
|
62
66
|
}
|
63
67
|
|
64
|
-
.twiddle
|
68
|
+
.twiddle > .toggle-handle .closed {
|
65
69
|
background-image: escape-svg($b-h-closed-icon);
|
66
70
|
display: inline-block;
|
67
71
|
}
|
68
72
|
|
69
|
-
.twiddle
|
73
|
+
.twiddle > .toggle-handle .opened {
|
70
74
|
display: none;
|
71
75
|
}
|
72
76
|
|
73
|
-
.twiddle-open
|
77
|
+
.twiddle-open > .toggle-handle .closed {
|
74
78
|
display: none;
|
75
79
|
}
|
76
80
|
|
77
|
-
.twiddle-open
|
81
|
+
.twiddle-open > .toggle-handle .opened {
|
78
82
|
background-image: escape-svg($b-h-opened-icon);
|
79
83
|
display: inline-block;
|
80
84
|
}
|
81
85
|
|
82
|
-
.h-node,
|
86
|
+
.h-node,
|
87
|
+
.h-leaf {
|
83
88
|
display: flex;
|
84
89
|
flex-wrap: wrap;
|
85
90
|
padding: 3px 0;
|
@@ -90,6 +95,6 @@ $text-muted: #777 !default;
|
|
90
95
|
}
|
91
96
|
|
92
97
|
.remove {
|
93
|
-
color:
|
98
|
+
color: var(--text-muted);
|
94
99
|
}
|
95
100
|
}
|
@@ -28,6 +28,8 @@ module Blacklight
|
|
28
28
|
path = facet_item.value.split(split_regex)
|
29
29
|
loc = tree[facet_field]
|
30
30
|
loc = loc[path.shift] ||= {} while path.length > 0
|
31
|
+
raise(StandardError, "Expected non-empty array after splitting facet value. Original facet value: '#{facet_item.value}'") unless facet_item.value.split(split_regex).present?
|
32
|
+
|
31
33
|
loc[:_] = HierarchicalFacetItem.new(facet_item.value, facet_item.value.split(split_regex).last, facet_item.hits)
|
32
34
|
end
|
33
35
|
end
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = ['lib']
|
20
20
|
|
21
21
|
s.add_dependency 'blacklight', '>= 7.18', '< 9'
|
22
|
-
s.add_dependency 'rails', '>=
|
22
|
+
s.add_dependency 'rails', '>= 7.1', '< 9'
|
23
23
|
s.add_dependency 'deprecation'
|
24
24
|
|
25
25
|
s.add_development_dependency 'rsolr'
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "blacklight-hierarchy",
|
3
|
-
"version": "6.
|
3
|
+
"version": "6.4.0",
|
4
4
|
"description": "[](https://github.com/sul-dlss/blacklight-hierarchy/actions?query=branch%3Amain)",
|
5
5
|
"main": "app/assets/javascripts/blacklight/hierarchy/hierarchy.js",
|
6
6
|
"files": [
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Blacklight::Hierarchy::FacetTree do
|
4
|
+
let(:prefix) { 'lc' }
|
5
|
+
let(:facet_display) { { hierarchy: { 'lc' => [['facet'], ':'] } } }
|
6
|
+
let(:display_facet) do
|
7
|
+
instance_double(Blacklight::Solr::Response::Facets::FacetField, name: 'lc_facet', items:, limit: 1001, sort: :index, offset: 0, prefix: nil)
|
8
|
+
end
|
9
|
+
let(:items) do
|
10
|
+
[
|
11
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: ':', value: ':', hits: 100),
|
12
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works', value: 'A - General Works', hits: 5),
|
13
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works:AC - Collections Works', value: 'A - General Works:AC - Collections Works', hits: 4)
|
14
|
+
]
|
15
|
+
end
|
16
|
+
let(:facet_field) do
|
17
|
+
instance_double(
|
18
|
+
Blacklight::FacetFieldPresenter,
|
19
|
+
display_facet:,
|
20
|
+
key: 'lc_facet',
|
21
|
+
label: 'Classification'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
context 'with only valid items' do
|
25
|
+
let(:items) do
|
26
|
+
[
|
27
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works', value: 'A - General Works', hits: 5),
|
28
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works:AC - Collections Works', value: 'A - General Works:AC - Collections Works', hits: 4)
|
29
|
+
]
|
30
|
+
end
|
31
|
+
it 'creates HierarchicalFacetItems' do
|
32
|
+
facet_tree = described_class.build(prefix:, facet_display:, facet_field:)
|
33
|
+
expect(facet_tree['lc_facet'].size).to eq(1)
|
34
|
+
expect(facet_tree['lc_facet'].keys.first).to eq('A - General Works')
|
35
|
+
expect(facet_tree['lc_facet']['A - General Works'].keys).to match_array([:_, 'AC - Collections Works'])
|
36
|
+
expect(facet_tree['lc_facet']['A - General Works'][:_]).to be_an_instance_of(HierarchicalFacetItem)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
context 'with an invalid item' do
|
42
|
+
let(:items) do
|
43
|
+
[
|
44
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: ':', value: ':', hits: 100),
|
45
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works', value: 'A - General Works', hits: 5),
|
46
|
+
Blacklight::Solr::Response::Facets::FacetItem.new(label: 'A - General Works:AC - Collections Works', value: 'A - General Works:AC - Collections Works', hits: 4)
|
47
|
+
]
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'raises an error' do
|
51
|
+
expect do
|
52
|
+
described_class.build(prefix:, facet_display:, facet_field:)
|
53
|
+
end.to raise_error(StandardError, "Expected non-empty array after splitting facet value. Original facet value: ':'")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-hierarchy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael B. Klein
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: blacklight
|
@@ -36,20 +35,20 @@ dependencies:
|
|
36
35
|
requirements:
|
37
36
|
- - ">="
|
38
37
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
38
|
+
version: '7.1'
|
40
39
|
- - "<"
|
41
40
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
41
|
+
version: '9'
|
43
42
|
type: :runtime
|
44
43
|
prerelease: false
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
46
45
|
requirements:
|
47
46
|
- - ">="
|
48
47
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
48
|
+
version: '7.1'
|
50
49
|
- - "<"
|
51
50
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
51
|
+
version: '9'
|
53
52
|
- !ruby/object:Gem::Dependency
|
54
53
|
name: deprecation
|
55
54
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,6 +140,7 @@ executables: []
|
|
141
140
|
extensions: []
|
142
141
|
extra_rdoc_files: []
|
143
142
|
files:
|
143
|
+
- ".github/dependabot.yml"
|
144
144
|
- ".github/workflows/ruby.yml"
|
145
145
|
- ".gitignore"
|
146
146
|
- ".rspec"
|
@@ -179,13 +179,13 @@ files:
|
|
179
179
|
- package.json
|
180
180
|
- spec/features/basic_spec.rb
|
181
181
|
- spec/helpers/hierarchy_helper_spec.rb
|
182
|
+
- spec/models/blacklight/hierarchy/facet_tree_spec.rb
|
182
183
|
- spec/spec_helper.rb
|
183
184
|
- spec/test_app_templates/Gemfile.extra
|
184
185
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
185
186
|
homepage: https://github.com/sul-dlss/blacklight-hierarchy
|
186
187
|
licenses: []
|
187
188
|
metadata: {}
|
188
|
-
post_install_message:
|
189
189
|
rdoc_options: []
|
190
190
|
require_paths:
|
191
191
|
- lib
|
@@ -200,13 +200,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
200
|
- !ruby/object:Gem::Version
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
|
-
rubygems_version: 3.
|
204
|
-
signing_key:
|
203
|
+
rubygems_version: 3.6.3
|
205
204
|
specification_version: 4
|
206
205
|
summary: Hierarchical Facets for Blacklight
|
207
206
|
test_files:
|
208
207
|
- spec/features/basic_spec.rb
|
209
208
|
- spec/helpers/hierarchy_helper_spec.rb
|
209
|
+
- spec/models/blacklight/hierarchy/facet_tree_spec.rb
|
210
210
|
- spec/spec_helper.rb
|
211
211
|
- spec/test_app_templates/Gemfile.extra
|
212
212
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|