blacklight 8.0.0.beta5 → 8.0.0.beta6
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/.gitignore +1 -0
- data/Gemfile +0 -4
- data/README.md +1 -1
- data/Rakefile +18 -0
- data/VERSION +1 -1
- data/app/assets/config/blacklight/manifest.js +3 -0
- data/app/assets/stylesheets/blacklight/_facets.scss +32 -5
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +1 -1
- data/app/components/blacklight/document_component.rb +21 -2
- data/app/components/blacklight/response/facet_group_component.html.erb +2 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +0 -5
- data/app/javascript/blacklight/bookmark_toggle.js +8 -15
- data/app/javascript/blacklight/button_focus.js +10 -10
- data/app/javascript/blacklight/index.js +5 -5
- data/app/javascript/blacklight/modal.js +6 -11
- data/app/javascript/blacklight/search_context.js +51 -57
- data/app/models/concerns/blacklight/document.rb +11 -0
- data/app/views/catalog/_document.html.erb +2 -2
- data/app/views/layouts/blacklight/base.html.erb +4 -4
- data/blacklight.gemspec +1 -1
- data/config/importmap.rb +1 -1
- data/config/locales/blacklight.ar.yml +209 -226
- data/config/locales/blacklight.de.yml +197 -209
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +196 -209
- data/config/locales/blacklight.fr.yml +196 -213
- data/config/locales/blacklight.hu.yml +193 -206
- data/config/locales/blacklight.it.yml +197 -209
- data/config/locales/blacklight.nl.yml +193 -206
- data/config/locales/blacklight.pt-BR.yml +195 -209
- data/config/locales/blacklight.sq.yml +193 -206
- data/config/locales/blacklight.zh.yml +194 -207
- data/lib/blacklight/configuration/view_config.rb +0 -4
- data/lib/blacklight/engine.rb +6 -7
- data/lib/generators/blacklight/assets/importmap_generator.rb +9 -2
- data/lib/generators/blacklight/assets/propshaft_generator.rb +11 -2
- data/lib/generators/blacklight/assets/sprockets_generator.rb +2 -0
- data/package.json +7 -4
- data/rollup.config.js +11 -1
- data/spec/features/sitelinks_search_box_spec.rb +13 -0
- data/spec/models/blacklight/icon_spec.rb +0 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/support/view_component_test_helpers.rb +21 -0
- data/spec/test_app_templates/Gemfile.extra +4 -0
- data/spec/views/catalog/_document.html.erb_spec.rb +21 -0
- data/tasks/blacklight.rake +1 -1
- metadata +7 -10
- data/app/assets/javascripts/blacklight/blacklight.esm.js +0 -390
- data/app/assets/javascripts/blacklight/blacklight.esm.js.map +0 -1
- data/app/assets/javascripts/blacklight/blacklight.js +0 -398
- data/app/assets/javascripts/blacklight/blacklight.js.map +0 -1
- data/spec/features/sitelinks_search_box.rb +0 -13
- data/spec/support/view_component_capybara_test_helpers.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccd45650da142937ce72464e061e05ed63793c553e0d0676d139010dd218cb44
|
4
|
+
data.tar.gz: 5221c9746cf8c4168444c57ca18062be9a6cb95743a58ea53040056ccf8bdee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dc2e36331089bcd0404a3a34c3a8bf71d6fa103c19a65f7e94620e14ac41a5f8ccfe8c1b750a305bbb7db051c323a7410b693a137579073f776e65debd76c5b
|
7
|
+
data.tar.gz: fb238384ea2c98c6e442b6706c473766118e83e860d3d4509e45b4cd50e993e22da8f67b29d61b4f4a40e6a9502cb8b07f822129ff9f3348f6c5c40cd210ee66
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -60,7 +60,7 @@ components in the gem are changed, this bundle should be rebuild with the
|
|
60
60
|
following steps:
|
61
61
|
1. [Install npm](https://www.npmjs.com/get-npm)
|
62
62
|
1. run `npm install` to download dependencies
|
63
|
-
1. run `npm run
|
63
|
+
1. run `npm run prepare` to build the bundle
|
64
64
|
1. run `npm publish` to push the javascript package to https://npmjs.org/package/blacklight-frontend
|
65
65
|
|
66
66
|
## Using the javascript
|
data/Rakefile
CHANGED
@@ -10,6 +10,24 @@ end
|
|
10
10
|
|
11
11
|
Bundler::GemHelper.install_tasks
|
12
12
|
|
13
|
+
# Hook up our NPM tasks to the standard uild and release tasks
|
14
|
+
Rake::Task['build'].enhance(['build:npm'])
|
15
|
+
Rake::Task['release'].enhance(['release:npm'])
|
16
|
+
|
17
|
+
# rubocop:disable Rails/RakeEnvironment
|
18
|
+
desc 'build javascript assets'
|
19
|
+
task 'build:npm' do
|
20
|
+
sh 'npm install'
|
21
|
+
sh 'npm run prepare'
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Publish javascript assets to npm\n" \
|
25
|
+
"To prevent publishing in NPM use e.g. `npm_push=no rake release`"
|
26
|
+
task 'release:npm' do
|
27
|
+
sh 'npm publish' unless %w[n no nil false off 0].include?(ENV["npm_push"].to_s.downcase)
|
28
|
+
end
|
29
|
+
# rubocop:enable Rails/RakeEnvironment
|
30
|
+
|
13
31
|
load "tasks/blacklight.rake"
|
14
32
|
load "lib/railties/blacklight.rake"
|
15
33
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
8.0.0.
|
1
|
+
8.0.0.beta6
|
@@ -1,16 +1,36 @@
|
|
1
1
|
.sidenav {
|
2
|
+
--bl-facets-smallish-padding: .25rem;
|
3
|
+
--bl-facets-smallish-border: var(--bs-border-width) solid var(--bs-border-color);
|
4
|
+
--bl-facets-smallish-margin-bottom: #{$spacer};
|
5
|
+
--bl-facets-smallish-border-radius: #{$border-radius};
|
6
|
+
|
2
7
|
.navbar-toggler {
|
3
|
-
|
8
|
+
--bs-navbar-toggler-padding-x: #{$navbar-toggler-padding-x};
|
9
|
+
--bs-navbar-toggler-padding-y: #{$navbar-toggler-padding-y};
|
10
|
+
--bs-navbar-toggler-border-color: #{$navbar-light-toggler-border-color};
|
11
|
+
--bs-navbar-toggler-border-radius: #{$navbar-toggler-border-radius};
|
4
12
|
color: $navbar-light-active-color;
|
5
13
|
|
6
14
|
&:hover,
|
7
15
|
&:focus {
|
8
16
|
color: $navbar-light-active-color;
|
9
17
|
}
|
10
|
-
}
|
11
18
|
|
12
|
-
|
13
|
-
|
19
|
+
[data-hide-label] {
|
20
|
+
display: inline;
|
21
|
+
}
|
22
|
+
[data-show-label] {
|
23
|
+
display: none;
|
24
|
+
}
|
25
|
+
|
26
|
+
&[aria-expanded="false"] {
|
27
|
+
[data-hide-label] {
|
28
|
+
display: none;
|
29
|
+
}
|
30
|
+
[data-show-label] {
|
31
|
+
display: inline;
|
32
|
+
}
|
33
|
+
}
|
14
34
|
}
|
15
35
|
}
|
16
36
|
|
@@ -19,9 +39,16 @@
|
|
19
39
|
$next: breakpoint-next($breakpoint, $grid-breakpoints);
|
20
40
|
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
|
21
41
|
|
42
|
+
|
22
43
|
&#{$infix} {
|
23
|
-
@include media-breakpoint-
|
44
|
+
@include media-breakpoint-down($next) {
|
45
|
+
border: var(--bl-facets-smallish-border);
|
46
|
+
padding: var(--bl-facets-smallish-padding);
|
47
|
+
margin-bottom: var(--bl-facets-smallish-margin-bottom);
|
48
|
+
border-radius: var(--bl-facets-smallish-border-radius);
|
24
49
|
|
50
|
+
}
|
51
|
+
@include media-breakpoint-up($next) {
|
25
52
|
// scss-lint:disable ImportantRule
|
26
53
|
.facets-collapse {
|
27
54
|
display: block !important;
|
@@ -3,7 +3,23 @@
|
|
3
3
|
require 'view_component/version'
|
4
4
|
|
5
5
|
module Blacklight
|
6
|
+
##
|
7
|
+
# A component for rendering a single document
|
8
|
+
#
|
9
|
+
# @note when subclassing this component, you must explicitly specify the collection parameter
|
10
|
+
# as `document` and handle the `document` parameter in your initializer.
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# class MyDocumentComponent < Blacklight::DocumentComponent
|
14
|
+
# with_collection_parameter :document
|
15
|
+
#
|
16
|
+
# def initialize(document:, **kwargs)
|
17
|
+
# super(document: document, **kwargs)
|
18
|
+
# end
|
19
|
+
# end
|
6
20
|
class DocumentComponent < Blacklight::Component
|
21
|
+
with_collection_parameter :document
|
22
|
+
|
7
23
|
# ViewComponent 3 changes iteration counters to begin at 0 rather than 1
|
8
24
|
COLLECTION_INDEX_OFFSET = ViewComponent::VERSION::MAJOR < 3 ? 0 : 1
|
9
25
|
|
@@ -63,6 +79,7 @@ module Blacklight
|
|
63
79
|
|
64
80
|
# rubocop:disable Metrics/ParameterLists
|
65
81
|
# @param document [Blacklight::DocumentPresenter]
|
82
|
+
# @param presenter [Blacklight::DocumentPresenter] alias for document
|
66
83
|
# @param partials [Array, nil] view partial names that should be used to provide content for the `partials` slot
|
67
84
|
# @param id [String] HTML id for the root element
|
68
85
|
# @param classes [Array, String] additional HTML classes for the root element
|
@@ -72,11 +89,13 @@ module Blacklight
|
|
72
89
|
# @param document_counter [Number, nil] provided by ViewComponent collection iteration
|
73
90
|
# @param counter_offset [Number] the offset of the start of the collection counter parameter for the component to the overall result set
|
74
91
|
# @param show [Boolean] are we showing only a single document (vs a list of search results); used for backwards-compatibility
|
75
|
-
def initialize(document: nil, partials: nil,
|
92
|
+
def initialize(document: nil, presenter: nil, partials: nil,
|
76
93
|
id: nil, classes: [], component: :article, title_component: nil,
|
77
94
|
counter: nil, document_counter: nil, counter_offset: 0,
|
78
95
|
show: false, **args)
|
79
|
-
|
96
|
+
Blacklight.deprecation.warn('the `presenter` argument to DocumentComponent#initialize is deprecated; pass the `presenter` in as document instead') if presenter
|
97
|
+
|
98
|
+
@presenter = presenter || document || args[self.class.collection_parameter]
|
80
99
|
@document = @presenter.document
|
81
100
|
@view_partials = partials || []
|
82
101
|
|
@@ -17,7 +17,8 @@
|
|
17
17
|
expanded: 'false',
|
18
18
|
label: t('blacklight.search.facets.group.toggle'),
|
19
19
|
} do %>
|
20
|
-
<span
|
20
|
+
<span data-show-label><%= t('blacklight.search.facets.group.open') %></span>
|
21
|
+
<span data-hide-label><%= t('blacklight.search.facets.group.close') %></span>
|
21
22
|
<% end %>
|
22
23
|
</div>
|
23
24
|
|
@@ -1,19 +1,12 @@
|
|
1
|
-
import
|
2
|
-
import CheckboxSubmit from './checkbox_submit'
|
1
|
+
import CheckboxSubmit from 'blacklight/checkbox_submit'
|
3
2
|
|
4
|
-
const BookmarkToggle = (
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
if (form) new CheckboxSubmit(form).clicked(e);
|
11
|
-
}
|
12
|
-
});
|
13
|
-
};
|
14
|
-
Blacklight.doBookmarkToggleBehavior.selector = 'form.bookmark-toggle';
|
3
|
+
const BookmarkToggle = (e) => {
|
4
|
+
if (e.target.matches('[data-checkboxsubmit-target="checkbox"]')) {
|
5
|
+
const form = e.target.closest('form')
|
6
|
+
if (form) new CheckboxSubmit(form).clicked(e);
|
7
|
+
}
|
8
|
+
};
|
15
9
|
|
16
|
-
|
17
|
-
})()
|
10
|
+
document.addEventListener('click', BookmarkToggle);
|
18
11
|
|
19
12
|
export default BookmarkToggle
|
@@ -1,12 +1,12 @@
|
|
1
|
-
const ButtonFocus = (
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
const ButtonFocus = (e) => {
|
2
|
+
// Button clicks should change focus. As of 10/3/19, Firefox for Mac and
|
3
|
+
// Safari both do not set focus to a button on button click.
|
4
|
+
// See https://zellwk.com/blog/inconsistent-button-behavior/ for background information
|
5
|
+
if (e.target.matches('[data-toggle="collapse"]') || e.target.matches('[data-bs-toggle="collapse"]')) {
|
6
|
+
e.target.focus()
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
document.addEventListener('click', ButtonFocus)
|
11
11
|
|
12
12
|
export default ButtonFocus
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import BookmarkToggle from '
|
2
|
-
import ButtonFocus from '
|
3
|
-
import Modal from '
|
4
|
-
import SearchContext from '
|
5
|
-
import Core from '
|
1
|
+
import BookmarkToggle from 'blacklight/bookmark_toggle'
|
2
|
+
import ButtonFocus from 'blacklight/button_focus'
|
3
|
+
import Modal from 'blacklight/modal'
|
4
|
+
import SearchContext from 'blacklight/search_context'
|
5
|
+
import Core from 'blacklight/core'
|
6
6
|
|
7
7
|
export default {
|
8
8
|
BookmarkToggle,
|
@@ -52,17 +52,10 @@
|
|
52
52
|
can be a turbo-stream that defines some HTML fragementsand where on the page to put them:
|
53
53
|
https://turbo.hotwired.dev/handbook/streams
|
54
54
|
*/
|
55
|
-
import
|
56
|
-
import ModalForm from './modalForm'
|
55
|
+
import ModalForm from 'blacklight/modalForm'
|
57
56
|
|
58
57
|
const Modal = (() => {
|
59
|
-
|
60
|
-
// Create lazily if someone else created first.
|
61
|
-
if (Blacklight.modal === undefined) {
|
62
|
-
Blacklight.modal = {};
|
63
|
-
}
|
64
|
-
|
65
|
-
const modal = Blacklight.modal
|
58
|
+
const modal = {}
|
66
59
|
|
67
60
|
// a Bootstrap modal div that should be already on the page hidden
|
68
61
|
modal.modalSelector = '#blacklight-modal';
|
@@ -147,20 +140,22 @@ const Modal = (() => {
|
|
147
140
|
};
|
148
141
|
|
149
142
|
modal.hide = function (el) {
|
150
|
-
const dom = document.querySelector(
|
143
|
+
const dom = document.querySelector(modal.modalSelector)
|
151
144
|
|
152
145
|
if (!dom.open) return
|
153
146
|
dom.close()
|
154
147
|
}
|
155
148
|
|
156
149
|
modal.show = function(el) {
|
157
|
-
const dom = document.querySelector(
|
150
|
+
const dom = document.querySelector(modal.modalSelector)
|
158
151
|
|
159
152
|
if (dom.open) return
|
160
153
|
dom.showModal()
|
161
154
|
}
|
162
155
|
|
163
156
|
modal.setupModal()
|
157
|
+
|
158
|
+
return modal;
|
164
159
|
})()
|
165
160
|
|
166
161
|
export default Modal
|
@@ -1,59 +1,53 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
//
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
event.preventDefault()
|
54
|
-
};
|
55
|
-
|
56
|
-
Blacklight.doSearchContextBehavior();
|
57
|
-
})()
|
1
|
+
const SearchContext = (e) => {
|
2
|
+
if (e.target.matches('[data-context-href]')) {
|
3
|
+
SearchContext.handleSearchContextMethod.call(e.target, e)
|
4
|
+
}
|
5
|
+
}
|
6
|
+
|
7
|
+
SearchContext.csrfToken = () => document.querySelector('meta[name=csrf-token]')?.content
|
8
|
+
SearchContext.csrfParam = () => document.querySelector('meta[name=csrf-param]')?.content
|
9
|
+
|
10
|
+
// this is the Rails.handleMethod with a couple adjustments, described inline:
|
11
|
+
// first, we're attaching this directly to the event handler, so we can check for meta-keys
|
12
|
+
SearchContext.handleSearchContextMethod = function(event) {
|
13
|
+
const link = this
|
14
|
+
|
15
|
+
// instead of using the normal href, we need to use the context href instead
|
16
|
+
let href = link.getAttribute('data-context-href')
|
17
|
+
let target = link.getAttribute('target')
|
18
|
+
let csrfToken = SearchContext.csrfToken()
|
19
|
+
let csrfParam = SearchContext.csrfParam()
|
20
|
+
let form = document.createElement('form')
|
21
|
+
form.method = 'post'
|
22
|
+
form.action = href
|
23
|
+
|
24
|
+
|
25
|
+
let formContent = `<input name="_method" value="post" type="hidden" />
|
26
|
+
<input name="redirect" value="${link.getAttribute('href')}" type="hidden" />`
|
27
|
+
|
28
|
+
// check for meta keys.. if set, we should open in a new tab
|
29
|
+
if(event.metaKey || event.ctrlKey) {
|
30
|
+
target = '_blank';
|
31
|
+
}
|
32
|
+
|
33
|
+
if (csrfParam !== undefined && csrfToken !== undefined) {
|
34
|
+
formContent += `<input name="${csrfParam}" value="${csrfToken}" type="hidden" />`
|
35
|
+
}
|
36
|
+
|
37
|
+
// Must trigger submit by click on a button, else "submit" event handler won't work!
|
38
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit
|
39
|
+
formContent += '<input type="submit" />'
|
40
|
+
|
41
|
+
if (target) { form.setAttribute('target', target); }
|
42
|
+
|
43
|
+
form.style.display = 'none'
|
44
|
+
form.innerHTML = formContent
|
45
|
+
document.body.appendChild(form)
|
46
|
+
form.querySelector('[type="submit"]').click()
|
47
|
+
|
48
|
+
event.preventDefault()
|
49
|
+
};
|
50
|
+
|
51
|
+
document.addEventListener('click', SearchContext)
|
58
52
|
|
59
53
|
export default SearchContext
|
@@ -31,6 +31,17 @@ module Blacklight::Document
|
|
31
31
|
class_attribute :inspector_fields, default: [:_source]
|
32
32
|
end
|
33
33
|
|
34
|
+
Email = Module.new do
|
35
|
+
def self.included(mod)
|
36
|
+
Blacklight.deprecation.warn("Blacklight::Document::Email is deprecated and will be removed (included in #{mod}).")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
Sms = Module.new do
|
40
|
+
def self.included(mod)
|
41
|
+
Blacklight.deprecation.warn("Blacklight::Document::Sms is deprecated and will be removed (included in #{mod}).")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
34
45
|
attr_reader :response, :_source
|
35
46
|
alias_method :solr_response, :response
|
36
47
|
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<% # container for a single doc -%>
|
2
|
-
<% view_config = local_assigns[:view_config] || blacklight_config.view_config(document_index_view_type) %>
|
3
|
-
<% document_component =
|
2
|
+
<% view_config = local_assigns[:view_config] || blacklight_config.view_config(document_index_view_type, action_name: action_name) %>
|
3
|
+
<% document_component = view_config.document_component -%>
|
4
4
|
<%= render document_component.new(document_component.collection_parameter => document_presenter(document), counter: document_counter_with_offset(document_counter), partials: view_config&.partials) %>
|
@@ -19,16 +19,16 @@
|
|
19
19
|
<%= javascript_importmap_tags %>
|
20
20
|
<% elsif defined? Propshaft %>
|
21
21
|
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
|
22
|
-
<% else %>
|
22
|
+
<% else %>
|
23
23
|
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
|
24
24
|
<%= javascript_include_tag "blacklight/blacklight", type: 'module' %>
|
25
|
+
<script type="module">
|
26
|
+
import githubAutoCompleteElement from 'https://cdn.skypack.dev/@github/auto-complete-element';
|
27
|
+
</script>
|
25
28
|
<% end %>
|
26
29
|
|
27
30
|
<%= csrf_meta_tags %>
|
28
31
|
<%= content_for(:head) %>
|
29
|
-
<script type="module">
|
30
|
-
import githubAutoCompleteElement from 'https://cdn.skypack.dev/@github/auto-complete-element';
|
31
|
-
</script>
|
32
32
|
</head>
|
33
33
|
<body class="<%= render_body_class %>">
|
34
34
|
<nav id="skip-link" role="navigation" aria-label="<%= t('blacklight.skip_links.label') %>">
|
data/blacklight.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
full text and/or metadata.)
|
18
18
|
s.license = "Apache 2.0"
|
19
19
|
|
20
|
-
s.files = `git ls-files -z`.split("\x0")
|
20
|
+
s.files = `git ls-files -z`.split("\x0") + Dir.glob("app/assets/javascript/blacklight/**/*")
|
21
21
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
22
22
|
s.bindir = 'exe'
|
23
23
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
data/config/importmap.rb
CHANGED