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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module Response
|
|
5
|
+
class FacetGroupComponent < ::ViewComponent::Base
|
|
6
|
+
def initialize(response:, fields: [], title: nil, id: nil)
|
|
7
|
+
@response = response
|
|
8
|
+
@fields = fields
|
|
9
|
+
@title = title
|
|
10
|
+
@id = id ? "facets-#{id}" : 'facets'
|
|
11
|
+
@panel_id = id ? "facet-panel-#{id}-collapse" : 'facet-panel-collapse'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def render?
|
|
15
|
+
@view_context.has_facet_values?(@fields, @response)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module Response
|
|
5
|
+
class PaginationComponent < ::ViewComponent::Base
|
|
6
|
+
def initialize(response:, html: {}, **pagination_args)
|
|
7
|
+
@response = response
|
|
8
|
+
@html_attr = { aria: { label: t('views.pagination.aria.container_label') } }.merge(html)
|
|
9
|
+
@pagination_args = { outer_window: 2, theme: 'blacklight' }.merge(pagination_args)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def pagination
|
|
13
|
+
@view_context.paginate @response, **@pagination_args
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module Response
|
|
5
|
+
class SortComponent < ViewComponent::Base
|
|
6
|
+
def initialize(param: 'sort', choices: {}, search_state:, id: 'sort-dropdown', classes: [], selected: nil)
|
|
7
|
+
@param = param
|
|
8
|
+
@choices = choices
|
|
9
|
+
@search_state = search_state
|
|
10
|
+
@id = id
|
|
11
|
+
@classes = classes
|
|
12
|
+
@selected = selected
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module Response
|
|
5
|
+
class SpellcheckComponent < ViewComponent::Base
|
|
6
|
+
def initialize(response:, options: nil)
|
|
7
|
+
@response = response
|
|
8
|
+
@options = options || @response&.spelling&.words
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def link_to_query(query)
|
|
12
|
+
@view_context.link_to_query(query)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def render?
|
|
16
|
+
@options.any? && @view_context.should_show_spellcheck_suggestions?(@response)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', 'aria-label' => t('blacklight.search.form.submit') do %>
|
|
2
|
+
<%= render_hash_as_hidden_fields(@params) %>
|
|
3
|
+
<% if @search_fields.length > 1 %>
|
|
4
|
+
<label for="search_field" class="sr-only"><%= t('blacklight.search.form.search_field.label') %></label>
|
|
5
|
+
<% end %>
|
|
6
|
+
<div class="input-group">
|
|
7
|
+
<% if @search_fields.length > 1 %>
|
|
8
|
+
<%= select_tag(:search_field,
|
|
9
|
+
options_for_select(@search_fields, h(@search_field)),
|
|
10
|
+
title: t('blacklight.search.form.search_field.title'),
|
|
11
|
+
id: "#{@prefix}search_field",
|
|
12
|
+
class: "custom-select search-field") %>
|
|
13
|
+
<% elsif @search_fields.length == 1 %>
|
|
14
|
+
<%= hidden_field_tag :search_field, @search_fields.first.last %>
|
|
15
|
+
<% end %>
|
|
16
|
+
|
|
17
|
+
<label for="<%= @prefix %>q" class="sr-only"><%= t('blacklight.search.form.search.label') %></label>
|
|
18
|
+
<%= text_field_tag :q, @q, placeholder: t('blacklight.search.form.search.placeholder'), class: "search-q q form-control rounded-#{@search_fields.length > 1 ? '0' : 'left'}", id: "#{@prefix}q", autocomplete: @autocomplete_path.present? ? "off" : "", autofocus: @autofocus, data: { autocomplete_enabled: @autocomplete_path.present?, autocomplete_path: @autocomplete_path } %>
|
|
19
|
+
|
|
20
|
+
<%= content %>
|
|
21
|
+
|
|
22
|
+
<span class="input-group-append">
|
|
23
|
+
<button type="submit" class="btn btn-primary search-btn" id="<%= @prefix %>search">
|
|
24
|
+
<span class="submit-search-text"><%= t('blacklight.search.form.submit') %></span>
|
|
25
|
+
<%= blacklight_icon :search, aria_hidden: true %>
|
|
26
|
+
</button>
|
|
27
|
+
</span>
|
|
28
|
+
</div>
|
|
29
|
+
<% end %>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
class SearchBarComponent < ::ViewComponent::Base
|
|
5
|
+
# rubocop:disable Metrics/ParameterLists
|
|
6
|
+
def initialize(url:, params:, classes: ['search-query-form'], presenter: nil, prefix: '', method: 'GET', q: nil, search_field: nil, search_fields: [], autocomplete_path: nil, autofocus: nil)
|
|
7
|
+
@url = url
|
|
8
|
+
@q = q || params[:q]
|
|
9
|
+
@search_field = search_field || params[:search_field]
|
|
10
|
+
@params = params.except(:q, :search_field, :utf8, :page)
|
|
11
|
+
@prefix = prefix
|
|
12
|
+
@classes = classes
|
|
13
|
+
@presenter = presenter
|
|
14
|
+
@method = method
|
|
15
|
+
@autocomplete_path = autocomplete_path
|
|
16
|
+
@autofocus = autofocus
|
|
17
|
+
@search_fields = search_fields
|
|
18
|
+
end
|
|
19
|
+
# rubocop:enable Metrics/ParameterLists
|
|
20
|
+
|
|
21
|
+
def autocomplete_path
|
|
22
|
+
return nil unless presenter.autocomplete_enabled?
|
|
23
|
+
|
|
24
|
+
@autocomplete_path
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def autofocus
|
|
28
|
+
if @autofocus.nil?
|
|
29
|
+
presenter.autofocus?
|
|
30
|
+
else
|
|
31
|
+
@autofocus
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def presenter
|
|
38
|
+
@presenter ||= blacklight_config.index.search_bar_presenter_class.new(controller, blacklight_config)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def blacklight_config
|
|
42
|
+
@view_context.blacklight_config
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
class SearchContextComponent < ::ViewComponent::Base
|
|
5
|
+
with_collection_parameter :search_context
|
|
6
|
+
|
|
7
|
+
def initialize(search_context:, search_session:)
|
|
8
|
+
@search_context = search_context
|
|
9
|
+
@search_session = search_session
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def render?
|
|
13
|
+
@search_context.present? && (@search_context[:prev] || @search_context[:next])
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def item_page_entry_info
|
|
17
|
+
Deprecation.silence(Blacklight::CatalogHelperBehavior) do
|
|
18
|
+
@view_context.item_page_entry_info
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def link_to_previous_document(*args)
|
|
23
|
+
@view_context.link_to_previous_document(*args)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def link_to_next_document(*args)
|
|
27
|
+
@view_context.link_to_next_document(*args)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<%= content_tag :div, id: @id, class: @classes.join(' ') do %>
|
|
2
|
+
<button type="button" class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
|
|
3
|
+
<%= t(:button_label_html, default: :label_html, scope: "blacklight.search.#{@param}", @interpolation => label_for_value(@selected)) %> <span class="caret"></span>
|
|
4
|
+
</button>
|
|
5
|
+
|
|
6
|
+
<div class="dropdown-menu" role="menu">
|
|
7
|
+
<%- @choices.each do |option| %>
|
|
8
|
+
<% text, value = option_text_and_value(option) %>
|
|
9
|
+
<%= link_to(text, url_for(@search_state.params_for_search(@param => value)), class: 'dropdown-item', role: 'menuitem') %>
|
|
10
|
+
<%- end -%>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Blacklight
|
|
4
|
+
module System
|
|
5
|
+
class DropdownComponent < ViewComponent::Base
|
|
6
|
+
# rubocop:disable Metrics/ParameterLists
|
|
7
|
+
def initialize(param:, choices:, search_state:, id: nil, classes: [], default: nil, selected: nil, interpolation: :field)
|
|
8
|
+
@param = param
|
|
9
|
+
@choices = choices
|
|
10
|
+
@search_state = search_state
|
|
11
|
+
@id = id
|
|
12
|
+
@classes = classes.concat(['btn-group', "#{param.to_s.parameterize}-dropdown"])
|
|
13
|
+
@selected = selected || default || option_text_and_value(@choices.first)&.first
|
|
14
|
+
@interpolation = interpolation
|
|
15
|
+
end
|
|
16
|
+
# rubocop:enable Metrics/ParameterLists
|
|
17
|
+
|
|
18
|
+
def render?
|
|
19
|
+
@choices.many?
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# rubocop:disable Style/CaseEquality
|
|
23
|
+
# This method is from Rails to mirror how it handles native dropdowns
|
|
24
|
+
def option_text_and_value(option)
|
|
25
|
+
# Options are [text, value] pairs or strings used for both.
|
|
26
|
+
if !option.is_a?(String) && option.respond_to?(:first) && option.respond_to?(:last)
|
|
27
|
+
option = option.reject { |e| Hash === e } if Array === option
|
|
28
|
+
[option.first, option.last]
|
|
29
|
+
else
|
|
30
|
+
[option, option]
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
# rubocop:enable Style/CaseEquality
|
|
34
|
+
|
|
35
|
+
def label_for_value(value)
|
|
36
|
+
choice = @choices.find { |option| option_text_and_value(option).last == value }
|
|
37
|
+
|
|
38
|
+
choice && option_text_and_value(choice).first
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<div data-blacklight-modal="container">
|
|
2
|
+
<%= prefix %>
|
|
3
|
+
|
|
4
|
+
<div class="modal-header">
|
|
5
|
+
<%= header || (capture do %>
|
|
6
|
+
<h1 class="modal-title"><%= title %></h1>
|
|
7
|
+
<% end) %>
|
|
8
|
+
|
|
9
|
+
<button type="button" class="blacklight-modal-close close" data-dismiss="modal" aria-label="<%= t('blacklight.modal.close') %>">
|
|
10
|
+
<span aria-hidden="true">×</span>
|
|
11
|
+
</button>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<%= body || (capture do %>
|
|
15
|
+
<div class="modal-body">
|
|
16
|
+
<%= content %>
|
|
17
|
+
</div>
|
|
18
|
+
<% end) %>
|
|
19
|
+
|
|
20
|
+
<% if footer.present? %>
|
|
21
|
+
<div class="modal-footer">
|
|
22
|
+
<%= footer %>
|
|
23
|
+
</div>
|
|
24
|
+
<% end %>
|
|
25
|
+
</div>
|
|
@@ -67,13 +67,14 @@ module Blacklight::Catalog
|
|
|
67
67
|
search_session['counter'] = params[:counter]
|
|
68
68
|
search_session['id'] = params[:search_id]
|
|
69
69
|
search_session['per_page'] = params[:per_page]
|
|
70
|
+
search_session['document_id'] = params[:document_id]
|
|
70
71
|
|
|
71
72
|
if params[:redirect] && (params[:redirect].starts_with?('/') || params[:redirect] =~ URI::DEFAULT_PARSER.make_regexp)
|
|
72
73
|
uri = URI.parse(params[:redirect])
|
|
73
74
|
path = uri.query ? "#{uri.path}?#{uri.query}" : uri.path
|
|
74
|
-
redirect_to path, status:
|
|
75
|
+
redirect_to path, status: :see_other
|
|
75
76
|
else
|
|
76
|
-
redirect_to({ action: :show, id: params[:id] }, status:
|
|
77
|
+
redirect_to({ action: :show, id: params[:id] }, status: :see_other)
|
|
77
78
|
end
|
|
78
79
|
end
|
|
79
80
|
|
|
@@ -184,7 +185,7 @@ module Blacklight::Catalog
|
|
|
184
185
|
# @note Make sure your format has a well known mime-type or is registered in config/initializers/mime_types.rb
|
|
185
186
|
# @example
|
|
186
187
|
# config.index.respond_to.txt = Proc.new { render plain: "A list of docs." }
|
|
187
|
-
def additional_response_formats
|
|
188
|
+
def additional_response_formats(format)
|
|
188
189
|
blacklight_config.index.respond_to.each do |key, config|
|
|
189
190
|
format.send key do
|
|
190
191
|
case config
|
|
@@ -214,7 +215,7 @@ module Blacklight::Catalog
|
|
|
214
215
|
|
|
215
216
|
##
|
|
216
217
|
# Try to render a response from the document export formats available
|
|
217
|
-
def document_export_formats
|
|
218
|
+
def document_export_formats(format)
|
|
218
219
|
format.any do
|
|
219
220
|
format_name = params.fetch(:format, '').to_sym
|
|
220
221
|
if @response.export_formats.include? format_name
|
|
@@ -24,7 +24,7 @@ module Blacklight
|
|
|
24
24
|
|
|
25
25
|
module ClassMethods
|
|
26
26
|
# YARD will include inline disabling as docs, cannot do multiline inside @!macro. AND this must be separate from doc block.
|
|
27
|
-
# rubocop:disable
|
|
27
|
+
# rubocop:disable Layout/LineLength
|
|
28
28
|
|
|
29
29
|
# @!macro partial_if_unless
|
|
30
30
|
# @param name [String] the name of the document partial
|
|
@@ -41,7 +41,7 @@ module Blacklight
|
|
|
41
41
|
blacklight_config.add_show_tools_partial(name, opts)
|
|
42
42
|
ActionBuilder.new(self, name, opts).build
|
|
43
43
|
end
|
|
44
|
-
# rubocop:enable
|
|
44
|
+
# rubocop:enable Layout/LineLength
|
|
45
45
|
|
|
46
46
|
deprecation_deprecate add_show_tools_partial: 'use blacklight_config.add_show_tools_partial instead'
|
|
47
47
|
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The Searchable module can be included onto classes that need to initialize a SearchService.
|
|
4
|
+
# There are three dependencies you must provide on the including class. Typically these
|
|
5
|
+
# would be provided by Blacklight::Controller
|
|
6
|
+
# 1. search_state
|
|
7
|
+
# 2. blacklight_config
|
|
8
|
+
# 3. search_service_class
|
|
9
|
+
#
|
|
10
|
+
# Additionally, the including class may override the search_service_context method to provide
|
|
11
|
+
# further context to the SearchService. For example you could override this to provide the
|
|
12
|
+
# currently signed in user.
|
|
2
13
|
module Blacklight::Searchable
|
|
3
14
|
# @return [Blacklight::SearchService]
|
|
4
15
|
def search_service
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
# Methods added to this helper will be available to all templates in the hosting application
|
|
3
3
|
module Blacklight::BlacklightHelperBehavior
|
|
4
|
+
extend Deprecation
|
|
5
|
+
|
|
4
6
|
include Blacklight::UrlHelperBehavior
|
|
5
7
|
include Blacklight::HashAsHiddenFieldsHelperBehavior
|
|
6
8
|
include Blacklight::LayoutHelperBehavior
|
|
@@ -148,9 +150,12 @@ module Blacklight::BlacklightHelperBehavior
|
|
|
148
150
|
document = args.first
|
|
149
151
|
|
|
150
152
|
field = options[:field]
|
|
151
|
-
label =
|
|
153
|
+
label = Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
|
|
154
|
+
options[:label] || index_field_label(document, field)
|
|
155
|
+
end
|
|
152
156
|
html_escape t(:"blacklight.search.index.#{document_index_view_type}.label", default: :'blacklight.search.index.label', label: label)
|
|
153
157
|
end
|
|
158
|
+
deprecation_deprecate render_index_field_label: 'Use Blacklight::MetadataFieldComponent instead'
|
|
154
159
|
|
|
155
160
|
##
|
|
156
161
|
# Render the show field label for a document
|
|
@@ -170,10 +175,13 @@ module Blacklight::BlacklightHelperBehavior
|
|
|
170
175
|
document = args.first
|
|
171
176
|
|
|
172
177
|
field = options[:field]
|
|
173
|
-
label =
|
|
178
|
+
label = Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
|
|
179
|
+
options[:label] || document_show_field_label(document, field)
|
|
180
|
+
end
|
|
174
181
|
|
|
175
182
|
t(:'blacklight.search.show.label', label: label)
|
|
176
183
|
end
|
|
184
|
+
deprecation_deprecate render_document_show_field_label: 'Use Blacklight::MetadataFieldComponent instead'
|
|
177
185
|
|
|
178
186
|
##
|
|
179
187
|
# Get the value of the document's "title" field, or a placeholder
|
|
@@ -252,8 +260,11 @@ module Blacklight::BlacklightHelperBehavior
|
|
|
252
260
|
##
|
|
253
261
|
# Should we render a grouped response (because the response
|
|
254
262
|
# contains a grouped response instead of the normal response)
|
|
263
|
+
#
|
|
264
|
+
# Default to false if there's no response object available (sometimes the case
|
|
265
|
+
# for tests, but might happen in other circumstances too..)
|
|
255
266
|
def render_grouped_response? response = @response
|
|
256
|
-
response
|
|
267
|
+
response&.grouped?
|
|
257
268
|
end
|
|
258
269
|
|
|
259
270
|
##
|
|
@@ -103,6 +103,7 @@ module Blacklight::CatalogHelperBehavior
|
|
|
103
103
|
total: number_with_delimiter(search_session['total']),
|
|
104
104
|
count: search_session['total'].to_i).html_safe
|
|
105
105
|
end
|
|
106
|
+
deprecation_deprecate item_page_entry_info: 'Use Blacklight::SearchContextComponent methods instead'
|
|
106
107
|
|
|
107
108
|
##
|
|
108
109
|
# Look up search field user-displayable label
|
|
@@ -38,7 +38,7 @@ module Blacklight
|
|
|
38
38
|
def render_index_doc_actions(document, options = {})
|
|
39
39
|
wrapping_class = options.delete(:wrapping_class) || "index-document-functions"
|
|
40
40
|
rendered = render_filtered_partials(blacklight_config.view_config(document_index_view_type).document_actions, { document: document }.merge(options))
|
|
41
|
-
|
|
41
|
+
tag.div(rendered, class: wrapping_class) if rendered.present?
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
##
|
|
@@ -51,7 +51,7 @@ module Blacklight
|
|
|
51
51
|
def render_results_collection_tools(options = {})
|
|
52
52
|
wrapping_class = options.delete(:wrapping_class) || "search-widgets"
|
|
53
53
|
rendered = render_filtered_partials(blacklight_config.view_config(document_index_view_type).collection_actions, options)
|
|
54
|
-
|
|
54
|
+
tag.div(rendered, class: wrapping_class) if rendered.present?
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
##
|