blacklight 7.10.0 → 7.11.1
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 +56 -7
- data/.rubocop_todo.yml +113 -98
- data/.travis.yml +0 -2
- data/Gemfile +0 -7
- data/README.md +1 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight/blacklight.js +1 -2
- data/app/components/blacklight/document/bookmark_component.html.erb +16 -0
- data/app/components/blacklight/document/bookmark_component.rb +19 -0
- data/app/components/blacklight/document/citation_component.html.erb +9 -0
- data/app/components/blacklight/document/citation_component.rb +24 -0
- data/app/components/blacklight/document/more_like_this_component.html.erb +12 -0
- data/app/components/blacklight/document/more_like_this_component.rb +21 -0
- data/app/components/blacklight/document_component.html.erb +29 -0
- data/app/components/blacklight/document_component.rb +121 -0
- data/app/components/blacklight/document_metadata_component.html.erb +5 -0
- data/app/components/blacklight/document_metadata_component.rb +21 -0
- data/app/components/blacklight/facet_item_component.rb +6 -6
- data/app/components/blacklight/metadata_field_component.html.erb +8 -0
- data/app/components/blacklight/metadata_field_component.rb +31 -0
- data/app/components/blacklight/metadata_field_layout_component.html.erb +2 -0
- data/app/components/blacklight/metadata_field_layout_component.rb +16 -0
- data/app/components/blacklight/response/facet_group_component.html.erb +25 -0
- data/app/components/blacklight/response/facet_group_component.rb +19 -0
- data/app/components/blacklight/response/pagination_component.html.erb +3 -0
- data/app/components/blacklight/response/pagination_component.rb +17 -0
- data/app/components/blacklight/response/sort_component.html.erb +6 -0
- data/app/components/blacklight/response/sort_component.rb +16 -0
- data/app/components/blacklight/response/spellcheck_component.html.erb +7 -0
- data/app/components/blacklight/response/spellcheck_component.rb +20 -0
- data/app/components/blacklight/search_bar_component.html.erb +29 -0
- data/app/components/blacklight/search_bar_component.rb +45 -0
- data/app/components/blacklight/search_context_component.html.erb +10 -0
- data/app/components/blacklight/search_context_component.rb +30 -0
- data/app/components/blacklight/system/dropdown_component.html.erb +12 -0
- data/app/components/blacklight/system/dropdown_component.rb +42 -0
- data/app/components/blacklight/system/modal_component.html.erb +25 -0
- data/app/components/blacklight/system/modal_component.rb +9 -0
- data/app/controllers/concerns/blacklight/catalog.rb +5 -4
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +2 -2
- data/app/controllers/concerns/blacklight/searchable.rb +11 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -3
- data/app/helpers/blacklight/catalog_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/component_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/configuration_helper_behavior.rb +6 -0
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -1
- data/app/helpers/blacklight/icon_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +7 -10
- data/app/helpers/blacklight/url_helper_behavior.rb +3 -3
- data/app/javascript/blacklight/search_context.js +0 -1
- data/app/models/blacklight/icon.rb +1 -0
- data/app/models/concerns/blacklight/document.rb +1 -0
- data/app/models/record_mailer.rb +1 -1
- data/app/presenters/blacklight/document_presenter.rb +7 -1
- data/app/presenters/blacklight/field_presenter.rb +1 -0
- data/app/presenters/blacklight/rendering/microdata.rb +1 -1
- data/app/services/blacklight/field_retriever.rb +1 -0
- data/app/services/blacklight/search_service.rb +1 -0
- data/app/views/catalog/_bookmark_control.html.erb +1 -36
- data/app/views/catalog/_citation.html.erb +4 -25
- data/app/views/catalog/_did_you_mean.html.erb +1 -5
- data/app/views/catalog/_document.atom.builder +3 -3
- data/app/views/catalog/_document.html.erb +5 -5
- data/app/views/catalog/_facet_group.html.erb +5 -19
- data/app/views/catalog/_index.html.erb +1 -10
- data/app/views/catalog/_paginate_compact.html.erb +6 -6
- data/app/views/catalog/_per_page_widget.html.erb +9 -12
- data/app/views/catalog/_previous_next_doc.html.erb +1 -12
- data/app/views/catalog/_results_pagination.html.erb +1 -3
- data/app/views/catalog/_search_form.html.erb +6 -27
- data/app/views/catalog/_show.html.erb +6 -8
- data/app/views/catalog/_show_main_content.html.erb +19 -13
- data/app/views/catalog/_show_sidebar.html.erb +1 -11
- data/app/views/catalog/_sort_widget.html.erb +5 -12
- data/app/views/catalog/email.html.erb +7 -7
- data/app/views/catalog/email_success.html.erb +5 -12
- data/app/views/catalog/facet.html.erb +14 -17
- data/app/views/catalog/index.atom.builder +0 -1
- data/app/views/catalog/sms.html.erb +7 -7
- data/app/views/catalog/sms_success.html.erb +5 -12
- data/blacklight.gemspec +3 -2
- data/config/i18n-tasks.yml +3 -0
- data/config/locales/blacklight.ar.yml +2 -0
- data/config/locales/blacklight.de.yml +2 -0
- data/config/locales/blacklight.en.yml +2 -0
- data/config/locales/blacklight.es.yml +4 -2
- data/config/locales/blacklight.fr.yml +2 -0
- data/config/locales/blacklight.hu.yml +2 -0
- data/config/locales/blacklight.it.yml +2 -0
- data/config/locales/blacklight.nl.yml +2 -0
- data/config/locales/blacklight.pt-BR.yml +2 -0
- data/config/locales/blacklight.sq.yml +2 -0
- data/config/locales/blacklight.zh.yml +2 -0
- data/lib/blacklight.rb +10 -0
- data/lib/blacklight/configuration.rb +8 -3
- data/lib/blacklight/configuration/fields.rb +5 -7
- data/lib/blacklight/engine.rb +1 -1
- data/lib/blacklight/nested_open_struct_with_hash_access.rb +1 -0
- data/lib/blacklight/search_state.rb +21 -7
- data/lib/blacklight/solr/response.rb +1 -0
- data/lib/blacklight/solr/response/facets.rb +9 -8
- data/lib/generators/blacklight/models_generator.rb +2 -0
- data/lib/generators/blacklight/templates/config/blacklight.yml +1 -0
- data/lib/railties/blacklight.rake +18 -13
- data/package.json +1 -1
- data/spec/components/blacklight/constraint_layout_component_spec.rb +1 -0
- data/spec/components/blacklight/document_component_spec.rb +129 -0
- data/spec/components/blacklight/document_metadata_component_spec.rb +0 -0
- data/spec/components/blacklight/metadata_field_component_spec.rb +41 -0
- data/spec/controllers/blacklight/search_fields_spec.rb +2 -2
- data/spec/controllers/catalog_controller_spec.rb +20 -0
- data/spec/features/search_context_spec.rb +12 -2
- data/spec/features/search_filters_spec.rb +4 -0
- data/spec/features/search_results_spec.rb +1 -0
- data/spec/features/sitelinks_search_box.rb +1 -0
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +3 -0
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +1 -0
- data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +14 -1
- data/spec/helpers/catalog_helper_spec.rb +1 -4
- data/spec/lib/blacklight/search_state_spec.rb +32 -0
- data/spec/models/blacklight/configuration_spec.rb +5 -0
- data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
- data/spec/models/blacklight/document/email_spec.rb +2 -0
- data/spec/models/blacklight/document/sms_spec.rb +2 -0
- data/spec/models/blacklight/facet_paginator_spec.rb +3 -0
- data/spec/models/blacklight/icon_spec.rb +6 -0
- data/spec/models/blacklight/solr/document_spec.rb +10 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +1 -1
- data/spec/models/blacklight/solr/response/group_response_spec.rb +2 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +10 -0
- data/spec/models/record_mailer_spec.rb +9 -0
- data/spec/models/search_spec.rb +1 -0
- data/spec/presenters/blacklight/show_presenter_spec.rb +8 -0
- data/spec/routing/catalog_routing_spec.rb +4 -0
- data/spec/services/blacklight/search_service_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/views/catalog/_document.html.erb_spec.rb +13 -11
- data/spec/views/catalog/_facet_group.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_previous_next_doc.html.erb_spec.rb +4 -0
- data/spec/views/catalog/index.atom.builder_spec.rb +40 -3
- data/spec/views/catalog/show.html.erb_spec.rb +14 -0
- data/tasks/blacklight.rake +7 -7
- metadata +56 -6
data/.travis.yml
CHANGED
|
@@ -15,8 +15,6 @@ matrix:
|
|
|
15
15
|
env: "RAILS_VERSION=5.2.4.2"
|
|
16
16
|
- rvm: 2.5.7
|
|
17
17
|
env: "RAILS_VERSION=5.2.4.2 BLACKLIGHT_API_TEST=true ENGINE_CART_RAILS_OPTIONS=\"--api --skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-action-cable --skip-coffee --skip-test\""
|
|
18
|
-
- rvm: 2.4.9
|
|
19
|
-
env: "RAILS_VERSION=5.2.4.2"
|
|
20
18
|
- rvm: jruby-9.2.8.0
|
|
21
19
|
env: "RAILS_VERSION=5.2.4.2 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
|
|
22
20
|
allow_failures:
|
data/Gemfile
CHANGED
|
@@ -39,13 +39,6 @@ else
|
|
|
39
39
|
gem 'webpacker', '~> 4.0'
|
|
40
40
|
when /^5.[12]/
|
|
41
41
|
gem 'sass-rails', '~> 5.0'
|
|
42
|
-
when /^4.2/
|
|
43
|
-
gem 'responders', '~> 2.0'
|
|
44
|
-
gem 'sass-rails', '>= 5.0'
|
|
45
|
-
gem 'coffee-rails', '~> 4.1.0'
|
|
46
|
-
gem 'json', '~> 1.8'
|
|
47
|
-
when /^4.[01]/
|
|
48
|
-
gem 'sass-rails', '< 5.0'
|
|
49
42
|
end
|
|
50
43
|
end
|
|
51
44
|
# END ENGINE_CART BLOCK
|
data/README.md
CHANGED
|
@@ -29,6 +29,7 @@ rails generate blacklight:install
|
|
|
29
29
|
* [Project Homepage](http://projectblacklight.org)
|
|
30
30
|
* [Developer Documentation](https://github.com/projectblacklight/blacklight/wiki)
|
|
31
31
|
* [Quickstart Guide](https://github.com/projectblacklight/blacklight/wiki/Quickstart)
|
|
32
|
+
* [Testing and Developing Blacklight](https://github.com/projectblacklight/blacklight/wiki/Testing-and-Developing-Blacklight)
|
|
32
33
|
* [Issue Tracker](https://github.com/projectblacklight/blacklight/issues)
|
|
33
34
|
* [Support](https://github.com/projectblacklight/blacklight/wiki/Support)
|
|
34
35
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
7.
|
|
1
|
+
7.11.1
|
|
@@ -297,7 +297,7 @@ Blacklight.onLoad(function () {
|
|
|
297
297
|
|
|
298
298
|
<div class="modal-body">
|
|
299
299
|
<p>Some message</p>
|
|
300
|
-
<%= link_to "This result will still be within modal", some_link, data: {
|
|
300
|
+
<%= link_to "This result will still be within modal", some_link, data: { blacklight_modal: "preserve" } %>
|
|
301
301
|
</div>
|
|
302
302
|
|
|
303
303
|
|
|
@@ -488,7 +488,6 @@ Blacklight.handleSearchContextMethod = function (event) {
|
|
|
488
488
|
form.querySelector('[type="submit"]').click();
|
|
489
489
|
event.preventDefault();
|
|
490
490
|
event.stopPropagation();
|
|
491
|
-
event.stopImmediatePropagation();
|
|
492
491
|
};
|
|
493
492
|
|
|
494
493
|
Blacklight.onLoad(function () {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<%-
|
|
2
|
+
# the data-doc-id attribute is used by our JS that converts to a checkbox/label.
|
|
3
|
+
-%>
|
|
4
|
+
<%= form_tag(@bookmark_path,
|
|
5
|
+
method: bookmarked? ? :delete : :put,
|
|
6
|
+
class: "bookmark-toggle",
|
|
7
|
+
data: {
|
|
8
|
+
'doc-id' => @document.id,
|
|
9
|
+
present: t('blacklight.search.bookmarks.present'),
|
|
10
|
+
absent: t('blacklight.search.bookmarks.absent'),
|
|
11
|
+
inprogress: t('blacklight.search.bookmarks.inprogress')
|
|
12
|
+
}) do %>
|
|
13
|
+
<%= submit_tag(t(bookmarked? ? 'remove.button' : 'add.button', scope: 'blacklight.bookmarks'),
|
|
14
|
+
id: "bookmark_toggle_#{@document.id.to_s.parameterize}",
|
|
15
|
+
class: "bookmark-#{bookmarked? ? 'remove' : 'add'} btn btn-outline-secondary") %>
|
|
16
|
+
<% end %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module Document
|
|
5
|
+
class BookmarkComponent < ::ViewComponent::Base
|
|
6
|
+
def initialize(document:, checked: nil, bookmark_path: nil)
|
|
7
|
+
@document = document
|
|
8
|
+
@checked = checked
|
|
9
|
+
@bookmark_path = bookmark_path
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def bookmarked?
|
|
13
|
+
return @checked unless @checked.nil?
|
|
14
|
+
|
|
15
|
+
@view_context.bookmarked? @document
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<h1 class="modal-title"><%= title %></h1>
|
|
3
|
+
|
|
4
|
+
<%= @formats.each do |i18n_key, citation_method| %>
|
|
5
|
+
<h2><%= t(i18n_key) %></h2>
|
|
6
|
+
<%= @document.send(citation_method).html_safe %>
|
|
7
|
+
<% unless @formats.keys.last === i18n_key %><br/><br/><% end %>
|
|
8
|
+
<% end %>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module Document
|
|
5
|
+
class CitationComponent < ::ViewComponent::Base
|
|
6
|
+
DEFAULT_FORMATS = {
|
|
7
|
+
'blacklight.citation.mla': :export_as_mla_citation_txt,
|
|
8
|
+
'blacklight.citation.apa': :export_as_apa_citation_txt,
|
|
9
|
+
'blacklight.citation.chicago': :export_as_chicago_citation_txt
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
with_collection_parameter :document
|
|
13
|
+
|
|
14
|
+
def initialize(document:, formats: DEFAULT_FORMATS)
|
|
15
|
+
@document = document
|
|
16
|
+
@formats = formats.select { |_k, v| @document.respond_to?(v) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def title
|
|
20
|
+
@view_context.document_heading(@document)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<div class="card">
|
|
2
|
+
<div class="card-header">More Like This</div>
|
|
3
|
+
<div class="card-body">
|
|
4
|
+
<ul>
|
|
5
|
+
<%= @document.more_like_this.each do |document| %>
|
|
6
|
+
<li class="more_like_this_document">
|
|
7
|
+
<span class="mlt_title"><%= link_to_document document %></span>
|
|
8
|
+
</li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module Document
|
|
5
|
+
class MoreLikeThisComponent < ::ViewComponent::Base
|
|
6
|
+
with_collection_parameter :document
|
|
7
|
+
|
|
8
|
+
def initialize(document:)
|
|
9
|
+
@document = document
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def render?
|
|
13
|
+
@document.more_like_this.present?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def link_to_document(*args)
|
|
17
|
+
@view_context.link_to_document(*args)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<%= content_tag @component,
|
|
2
|
+
id: @id,
|
|
3
|
+
data: {
|
|
4
|
+
'document-id': @document.id.to_s.parameterize,
|
|
5
|
+
'document-counter': @counter,
|
|
6
|
+
},
|
|
7
|
+
itemscope: true,
|
|
8
|
+
itemtype: @document.itemtype,
|
|
9
|
+
class: classes.flatten.join(' ') do %>
|
|
10
|
+
<%= header %>
|
|
11
|
+
<% if body.present? %>
|
|
12
|
+
<%= body %>
|
|
13
|
+
<% else %>
|
|
14
|
+
<div class="document-main-section">
|
|
15
|
+
<header class="documentHeader row">
|
|
16
|
+
<%= content_tag @title_component, class: 'index_title document-title-heading' do %>
|
|
17
|
+
<%= before_title %><%= title %><%= after_title %>
|
|
18
|
+
<% end %>
|
|
19
|
+
<%= actions %>
|
|
20
|
+
</header>
|
|
21
|
+
|
|
22
|
+
<%= content %>
|
|
23
|
+
<%= metadata %>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<%= thumbnail %>
|
|
27
|
+
<% end %>
|
|
28
|
+
<%= footer %>
|
|
29
|
+
<% end %>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
class DocumentComponent < ::ViewComponent::Base
|
|
5
|
+
# Available content areas; some have defaults provided by
|
|
6
|
+
# the accessors below.
|
|
7
|
+
with_content_areas :header, :body, :footer,
|
|
8
|
+
:before_title, :title, :after_title,
|
|
9
|
+
:actions, :metadata, :thumbnail,
|
|
10
|
+
:partials
|
|
11
|
+
with_collection_parameter :document
|
|
12
|
+
|
|
13
|
+
# rubocop:disable Metrics/ParameterLists
|
|
14
|
+
# @param document [Blacklight::Document]
|
|
15
|
+
# @param presenter [Blacklight::DocumentPresenter]
|
|
16
|
+
# @param id [String] HTML id for the root element
|
|
17
|
+
# @param classes [Array, String] additional HTML classes for the root element
|
|
18
|
+
# @param component [Symbol, String] HTML tag type to use for the root element
|
|
19
|
+
# @param title_component [Symbol, String] HTML tag type to use for the title element
|
|
20
|
+
# @param metadata_component [Blacklight::DocumentMetadataComponent]
|
|
21
|
+
# @param counter [Number, nil]
|
|
22
|
+
# @param show [Boolean] are we showing only a single document (vs a list of search results); used for backwards-compatibility
|
|
23
|
+
def initialize(document: nil, presenter: nil, id: nil, classes: [], component: :article, title_component: :h4, metadata_component: Blacklight::DocumentMetadataComponent, counter: nil, show: false)
|
|
24
|
+
if presenter.nil? && document.nil?
|
|
25
|
+
raise ArgumentError, 'missing keyword: :document or :presenter'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
@document = document || presenter&.document
|
|
29
|
+
@presenter = presenter
|
|
30
|
+
|
|
31
|
+
@component = component
|
|
32
|
+
@title_component = title_component
|
|
33
|
+
@id = id || ('document' if show)
|
|
34
|
+
@classes = classes
|
|
35
|
+
|
|
36
|
+
@metadata_component = metadata_component
|
|
37
|
+
|
|
38
|
+
@counter = counter
|
|
39
|
+
|
|
40
|
+
@show = show
|
|
41
|
+
end
|
|
42
|
+
# rubocop:enable Metrics/ParameterLists
|
|
43
|
+
|
|
44
|
+
# HTML classes to apply to the root element
|
|
45
|
+
def classes
|
|
46
|
+
[
|
|
47
|
+
@classes,
|
|
48
|
+
@view_context.render_document_class(@document),
|
|
49
|
+
'document',
|
|
50
|
+
("document-position-#{@counter}" if @counter)
|
|
51
|
+
].compact.flatten
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Content for the document title area; should be an inline element
|
|
55
|
+
def title
|
|
56
|
+
@title || begin
|
|
57
|
+
if show?
|
|
58
|
+
content_tag('span', presenter.heading, itemprop: "name")
|
|
59
|
+
else
|
|
60
|
+
@view_context.link_to_document @document, counter: @counter, itemprop: 'name'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Content for the document actions area
|
|
66
|
+
def actions
|
|
67
|
+
return if @show
|
|
68
|
+
|
|
69
|
+
@actions || begin
|
|
70
|
+
@view_context.render_index_doc_actions @document, wrapping_class: "index-document-functions col-sm-3 col-lg-2"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Content for the document thumbnail area
|
|
75
|
+
def thumbnail
|
|
76
|
+
return if @show
|
|
77
|
+
|
|
78
|
+
@thumbnail || begin
|
|
79
|
+
return unless presenter.thumbnail.exists?
|
|
80
|
+
|
|
81
|
+
content_tag :div, class: "document-thumbnail" do
|
|
82
|
+
presenter.thumbnail.thumbnail_tag({ alt: '' }, 'aria-hidden': true, tabindex: -1, counter: @counter)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Content for the document metadata area
|
|
88
|
+
def metadata
|
|
89
|
+
@metadata || @view_context.render(@metadata_component.new(fields: presenter.field_presenters, show: show?))
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Content that goes before the document title (e.g. the counter)
|
|
93
|
+
def before_title
|
|
94
|
+
@before_title || counter
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
private
|
|
98
|
+
|
|
99
|
+
def counter
|
|
100
|
+
return unless @counter
|
|
101
|
+
|
|
102
|
+
content_tag :span, class: 'document-counter' do
|
|
103
|
+
t('blacklight.search.documents.counter', counter: @counter)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def presenter
|
|
108
|
+
@presenter ||= begin
|
|
109
|
+
if show?
|
|
110
|
+
@view_context.presenter(@document)
|
|
111
|
+
else
|
|
112
|
+
@view_context.index_presenter(@document)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def show?
|
|
118
|
+
@show
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
class DocumentMetadataComponent < ::ViewComponent::Base
|
|
5
|
+
with_collection_parameter :fields
|
|
6
|
+
|
|
7
|
+
# @param fields [Enumerable<Blacklight::FieldPresenter>] Document field presenters
|
|
8
|
+
def initialize(fields:, show: false)
|
|
9
|
+
@fields = fields
|
|
10
|
+
@show = show
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def render?
|
|
14
|
+
@fields.any?
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def field_component(field)
|
|
18
|
+
field.try(:component) || Blacklight::MetadataFieldComponent
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -73,7 +73,7 @@ module Blacklight
|
|
|
73
73
|
# @return [String]
|
|
74
74
|
# @private
|
|
75
75
|
def render_facet_value
|
|
76
|
-
|
|
76
|
+
tag.span(class: "facet-label") do
|
|
77
77
|
link_to_unless(@suppress_link, @label, @href, class: "facet-select")
|
|
78
78
|
end + render_facet_count
|
|
79
79
|
end
|
|
@@ -85,12 +85,12 @@ module Blacklight
|
|
|
85
85
|
# @param [String] item
|
|
86
86
|
# @private
|
|
87
87
|
def render_selected_facet_value
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
tag.span(class: "facet-label") do
|
|
89
|
+
tag.span(@label, class: "selected") +
|
|
90
90
|
# remove link
|
|
91
91
|
link_to(@href, class: "remove") do
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
tag.span('✖', class: "remove-icon") +
|
|
93
|
+
tag.span('[remove]', class: 'sr-only')
|
|
94
94
|
end
|
|
95
95
|
end + render_facet_count(classes: ["selected"])
|
|
96
96
|
end
|
|
@@ -108,7 +108,7 @@ module Blacklight
|
|
|
108
108
|
return @view_context.render_facet_count(@hits, options) unless @view_context.method(:render_facet_count).owner == Blacklight::FacetsHelperBehavior || explicit_component_configuration?
|
|
109
109
|
|
|
110
110
|
classes = (options[:classes] || []) << "facet-count"
|
|
111
|
-
|
|
111
|
+
tag.span(t('blacklight.search.facets.count', number: number_with_delimiter(@hits)), class: classes)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
private
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
class MetadataFieldComponent < ::ViewComponent::Base
|
|
5
|
+
with_collection_parameter :field
|
|
6
|
+
|
|
7
|
+
# @param field [Blacklight::FieldPresenter]
|
|
8
|
+
# @param layout [Blacklight::MetadataFieldLayoutComponent] alternate layout component to use
|
|
9
|
+
# @param show [Boolean] are we showing only a single document (vs a list of search results); used for backwards-compatibility
|
|
10
|
+
def initialize(field:, layout: nil, show: false)
|
|
11
|
+
@field = field
|
|
12
|
+
@layout = layout || Blacklight::MetadataFieldLayoutComponent
|
|
13
|
+
@show = show
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @private
|
|
17
|
+
def label
|
|
18
|
+
Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
|
|
19
|
+
if @show
|
|
20
|
+
@view_context.render_document_show_field_label @field.document, label: @field.label('show'), field: @field.key
|
|
21
|
+
else
|
|
22
|
+
@view_context.render_index_field_label @field.document, label: @field.label, field: @field.key
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def render?
|
|
28
|
+
@field.render_field?
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
class MetadataFieldLayoutComponent < ::ViewComponent::Base
|
|
5
|
+
with_collection_parameter :field
|
|
6
|
+
with_content_areas :label, :value
|
|
7
|
+
|
|
8
|
+
# @param field [Blacklight::FieldPresenter]
|
|
9
|
+
def initialize(field:, label_class: 'col-md-3', value_class: 'col-md-9')
|
|
10
|
+
@field = field
|
|
11
|
+
@key = @field.key.parameterize
|
|
12
|
+
@label_class = label_class
|
|
13
|
+
@value_class = value_class
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<% # main container for facets/limits menu -%>
|
|
2
|
+
<%= content_tag :div, id: @id, class: 'facets sidenav facets-toggleable-md' do %>
|
|
3
|
+
<div class="facets-header">
|
|
4
|
+
<%= content_tag :h2, @title, class: 'facets-heading' if @title %>
|
|
5
|
+
|
|
6
|
+
<%= content_tag :button,
|
|
7
|
+
class:'navbar-toggler navbar-toggler-right',
|
|
8
|
+
type: 'button',
|
|
9
|
+
data: {
|
|
10
|
+
toggle: 'collapse',
|
|
11
|
+
target: "##{@panel_id}",
|
|
12
|
+
},
|
|
13
|
+
aria: {
|
|
14
|
+
controls: @panel_id,
|
|
15
|
+
expanded: 'false',
|
|
16
|
+
label: t('blacklight.search.facets.group.toggle'),
|
|
17
|
+
} do %>
|
|
18
|
+
<span class="navbar-toggler-icon"></span>
|
|
19
|
+
<% end %>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<%= content_tag :div, id: @panel_id, class: 'facets-collapse collapse' do %>
|
|
23
|
+
<%= @view_context.render_facet_partials @fields, response: @response %>
|
|
24
|
+
<% end %>
|
|
25
|
+
<% end %>
|