blacklight 7.0.0.rc1 → 7.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +30 -18
- data/.rubocop_todo.yml +308 -67
- data/.solr_wrapper.yml +8 -1
- data/.travis.yml +15 -13
- data/Gemfile +2 -0
- data/README.md +2 -2
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/Vagrantfile +2 -0
- data/app/assets/javascripts/blacklight/blacklight.js +17 -17
- data/app/assets/stylesheets/blacklight/_blacklight_base.scss +17 -16
- data/app/assets/stylesheets/blacklight/_facets.scss +2 -13
- data/app/assets/stylesheets/blacklight/_icons.scss +8 -2
- data/app/assets/stylesheets/blacklight/_search_form.scss +7 -0
- data/app/assets/stylesheets/blacklight/blacklight.scss +1 -1
- data/app/builders/blacklight/action_builder.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +19 -13
- data/app/controllers/concerns/blacklight/catalog.rb +19 -7
- data/app/controllers/concerns/blacklight/controller.rb +12 -18
- data/app/controllers/concerns/blacklight/facet.rb +3 -0
- data/app/controllers/concerns/blacklight/search_context.rb +7 -3
- data/app/controllers/concerns/blacklight/search_history.rb +1 -6
- data/app/controllers/concerns/blacklight/token_based_user.rb +3 -1
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +5 -1
- data/app/helpers/blacklight/configuration_helper_behavior.rb +5 -3
- data/app/helpers/blacklight/facets_helper_behavior.rb +15 -12
- data/app/helpers/blacklight/icon_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -0
- data/app/helpers/blacklight/render_partials_helper_behavior.rb +2 -2
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +29 -14
- data/app/javascript/blacklight/checkbox_submit.js +9 -8
- data/app/javascript/blacklight/core.js +8 -6
- data/app/javascript/blacklight/modal.js +1 -3
- data/app/javascript/blacklight/search_context.js +0 -1
- data/app/models/blacklight/icon.rb +3 -0
- data/app/models/blacklight/suggest_search.rb +3 -14
- data/app/models/bookmark.rb +1 -1
- data/app/models/concerns/blacklight/document.rb +3 -1
- data/app/models/concerns/blacklight/solr/document.rb +1 -0
- data/app/models/concerns/blacklight/suggest/response.rb +5 -3
- data/app/models/concerns/blacklight/user.rb +1 -0
- data/app/models/search.rb +1 -0
- data/app/presenters/blacklight/document_presenter.rb +38 -0
- data/app/presenters/blacklight/field_presenter.rb +2 -0
- data/app/presenters/blacklight/index_presenter.rb +13 -5
- data/app/presenters/blacklight/json_presenter.rb +5 -12
- data/app/presenters/blacklight/link_alternate_presenter.rb +2 -0
- data/app/presenters/blacklight/rendering/abstract_step.rb +2 -0
- data/app/presenters/blacklight/rendering/helper_method.rb +2 -0
- data/app/presenters/blacklight/rendering/join.rb +2 -0
- data/app/presenters/blacklight/rendering/link_to_facet.rb +4 -0
- data/app/presenters/blacklight/rendering/microdata.rb +3 -0
- data/app/presenters/blacklight/rendering/pipeline.rb +2 -0
- data/app/presenters/blacklight/rendering/terminator.rb +2 -0
- data/app/presenters/blacklight/search_bar_presenter.rb +2 -0
- data/app/presenters/blacklight/show_presenter.rb +8 -5
- data/app/presenters/blacklight/thumbnail_presenter.rb +2 -0
- data/app/services/blacklight/document_factory.rb +2 -0
- data/app/services/blacklight/field_retriever.rb +2 -0
- data/app/services/blacklight/search_service.rb +7 -9
- data/app/values/blacklight/types.rb +3 -0
- data/app/views/bookmarks/index.html.erb +12 -13
- data/app/views/catalog/_citation.html.erb +4 -4
- data/app/views/catalog/_constraints.html.erb +2 -0
- data/app/views/catalog/_did_you_mean.html.erb +1 -1
- data/app/views/catalog/_document.atom.builder +17 -16
- data/app/views/catalog/_document.rss.builder +2 -0
- data/app/views/catalog/_facet_index_navigation.html.erb +5 -4
- data/app/views/catalog/_facet_layout.html.erb +3 -5
- data/app/views/catalog/_facets.html.erb +5 -4
- data/app/views/catalog/_field.json.jbuilder +10 -0
- data/app/views/catalog/_group.html.erb +1 -1
- data/app/views/catalog/_home_text.html.erb +5 -5
- data/app/views/catalog/_index.html.erb +5 -7
- data/app/views/catalog/_index_header.html.erb +1 -1
- data/app/views/catalog/_per_page_widget.html.erb +1 -1
- data/app/views/catalog/_results_pagination.html.erb +2 -2
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/catalog/_search_results.html.erb +2 -2
- data/app/views/catalog/_show.html.erb +3 -5
- data/app/views/catalog/_show_more_like_this.html.erb +1 -1
- data/app/views/catalog/_show_sidebar.html.erb +1 -1
- data/app/views/catalog/_show_tools.html.erb +1 -1
- data/app/views/catalog/_sort_widget.html.erb +1 -1
- data/app/views/catalog/_zero_results.html.erb +1 -1
- data/app/views/catalog/citation.js.erb +1 -1
- data/app/views/catalog/facet.html.erb +5 -4
- data/app/views/catalog/facet.json.jbuilder +2 -0
- data/app/views/catalog/index.atom.builder +4 -2
- data/app/views/catalog/index.json.jbuilder +29 -10
- data/app/views/catalog/index.rss.builder +2 -0
- data/app/views/catalog/opensearch.xml.builder +3 -1
- data/app/views/catalog/show.json.jbuilder +21 -0
- data/app/views/kaminari/blacklight/_first_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_last_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_next_page.html.erb +3 -3
- data/app/views/kaminari/blacklight/_page.html.erb +4 -2
- data/app/views/kaminari/blacklight/_prev_page.html.erb +2 -2
- data/app/views/layouts/blacklight.html.erb +4 -4
- data/app/views/layouts/blacklight/base.html.erb +1 -9
- data/app/views/search_history/index.html.erb +3 -3
- data/app/views/shared/_header_navbar.html.erb +1 -1
- data/app/views/shared/_modal.html.erb +2 -2
- data/blacklight.gemspec +7 -6
- data/config/i18n-tasks.yml +17 -0
- data/config/locales/blacklight.de.yml +72 -57
- data/config/locales/blacklight.en.yml +11 -1
- data/config/locales/blacklight.es.yml +15 -1
- data/config/locales/blacklight.fr.yml +17 -8
- data/config/locales/blacklight.hu.yml +3 -1
- data/config/locales/blacklight.it.yml +16 -1
- data/config/locales/blacklight.nl.yml +3 -1
- data/config/locales/blacklight.pt-BR.yml +19 -2
- data/config/locales/blacklight.sq.yml +3 -1
- data/config/locales/blacklight.zh.yml +3 -1
- data/config/routes.rb +0 -1
- data/lib/blacklight.rb +3 -0
- data/lib/blacklight/abstract_repository.rb +12 -0
- data/lib/blacklight/configuration.rb +21 -3
- data/lib/blacklight/configuration/context.rb +11 -0
- data/lib/blacklight/configuration/fields.rb +31 -26
- data/lib/blacklight/configuration/null_field.rb +2 -0
- data/lib/blacklight/engine.rb +4 -1
- data/lib/blacklight/routes/exportable.rb +1 -3
- data/lib/blacklight/routes/searchable.rb +2 -3
- data/lib/blacklight/runtime_registry.rb +2 -0
- data/lib/blacklight/search_builder.rb +2 -0
- data/lib/blacklight/search_state.rb +2 -0
- data/lib/blacklight/solr/repository.rb +34 -0
- data/lib/blacklight/solr/response/spelling.rb +1 -0
- data/lib/generators/blacklight/assets_generator.rb +10 -9
- data/lib/generators/blacklight/controller_generator.rb +1 -1
- data/lib/generators/blacklight/install_generator.rb +7 -14
- data/lib/generators/blacklight/solr_generator.rb +8 -0
- data/lib/generators/blacklight/templates/alternate_controller.rb +4 -4
- data/lib/generators/blacklight/templates/catalog_controller.rb +7 -1
- data/lib/generators/blacklight/templates/solr/conf/schema.xml +20 -22
- data/lib/generators/blacklight/user_generator.rb +2 -0
- data/lib/railties/blacklight.rake +9 -13
- data/package-lock.json +544 -406
- data/package.json +3 -2
- data/spec/controllers/alternate_controller_spec.rb +4 -3
- data/spec/controllers/application_controller_spec.rb +0 -4
- data/spec/controllers/blacklight/base_spec.rb +5 -2
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +4 -4
- data/spec/controllers/blacklight/facet_spec.rb +0 -1
- data/spec/controllers/blacklight/search_fields_spec.rb +25 -22
- data/spec/controllers/bookmarks_controller_spec.rb +45 -10
- data/spec/controllers/catalog_controller_spec.rb +206 -138
- data/spec/controllers/search_history_controller_spec.rb +4 -4
- data/spec/features/alternate_controller_spec.rb +3 -3
- data/spec/features/autocomplete_spec.rb +2 -0
- data/spec/features/did_you_mean_spec.rb +4 -3
- data/spec/features/facets_spec.rb +7 -7
- data/spec/features/record_view_spec.rb +11 -12
- data/spec/features/search_context_spec.rb +4 -5
- data/spec/features/search_crawler_spec.rb +3 -5
- data/spec/features/search_filters_spec.rb +44 -44
- data/spec/features/search_history_spec.rb +5 -3
- data/spec/features/search_pagination_spec.rb +3 -1
- data/spec/features/search_results_spec.rb +11 -8
- data/spec/features/search_spec.rb +3 -3
- data/spec/features/sitelinks_search_box.rb +4 -4
- data/spec/helpers/blacklight/configuration_helper_behavior_spec.rb +30 -30
- data/spec/helpers/blacklight/facets_helper_behavior_spec.rb +65 -59
- data/spec/helpers/blacklight/hash_as_hidden_fields_behavior_spec.rb +1 -1
- data/spec/helpers/blacklight/icon_helper_behavior_spec.rb +2 -0
- data/spec/helpers/blacklight/render_constraints_helper_behavior_spec.rb +8 -3
- data/spec/helpers/blacklight/render_partials_helper_behavior_spec.rb +16 -4
- data/spec/helpers/blacklight/search_history_constraints_helper_behavior_spec.rb +21 -22
- data/spec/helpers/blacklight/suggest_helper_behavior_spec.rb +6 -1
- data/spec/helpers/blacklight/url_helper_behavior_spec.rb +49 -43
- data/spec/helpers/blacklight_helper_spec.rb +28 -12
- data/spec/helpers/catalog_helper_spec.rb +50 -47
- data/spec/i18n_spec.rb +18 -0
- data/spec/integration/generators/blacklight/solr_generator_spec.rb +18 -10
- data/spec/lib/blacklight/configuration/facet_field_spec.rb +2 -0
- data/spec/lib/blacklight/configuration/field_spec.rb +3 -0
- data/spec/lib/blacklight/open_struct_with_hash_access_spec.rb +15 -20
- data/spec/lib/blacklight/parameters_spec.rb +3 -1
- data/spec/lib/blacklight/search_state_spec.rb +51 -34
- data/spec/lib/blacklight_spec.rb +13 -14
- data/spec/lib/tasks/blacklight_task_spec.rb +3 -5
- data/spec/models/blacklight/configurable_spec.rb +11 -13
- data/spec/models/blacklight/configuration/context_spec.rb +9 -10
- data/spec/models/blacklight/configuration_spec.rb +103 -91
- data/spec/models/blacklight/document/active_model_shim_spec.rb +5 -6
- data/spec/models/blacklight/document/cache_key_spec.rb +9 -2
- data/spec/models/blacklight/document/dublin_core_spec.rb +16 -19
- data/spec/models/blacklight/document/email_spec.rb +9 -9
- data/spec/models/blacklight/document/sms_spec.rb +9 -9
- data/spec/models/blacklight/document_spec.rb +9 -8
- data/spec/models/blacklight/facet_paginator_spec.rb +40 -30
- data/spec/models/blacklight/icon_spec.rb +12 -2
- data/spec/models/blacklight/search_builder_spec.rb +12 -3
- data/spec/models/blacklight/solr/document_spec.rb +216 -219
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +6 -4
- data/spec/models/blacklight/solr/repository_spec.rb +37 -34
- data/spec/models/blacklight/solr/request_spec.rb +17 -18
- data/spec/models/blacklight/solr/response/facets_spec.rb +58 -58
- data/spec/models/blacklight/solr/response/group_response_spec.rb +16 -22
- data/spec/models/blacklight/solr/response/group_spec.rb +18 -25
- data/spec/models/blacklight/solr/response_spec.rb +48 -50
- data/spec/models/blacklight/solr/search_builder_spec.rb +120 -121
- data/spec/models/blacklight/suggest/response_spec.rb +6 -4
- data/spec/models/blacklight/suggest_search_spec.rb +9 -16
- data/spec/models/blacklight/user_spec.rb +9 -11
- data/spec/models/bookmark_spec.rb +6 -5
- data/spec/models/record_mailer_spec.rb +22 -20
- data/spec/models/search_spec.rb +18 -17
- data/spec/models/solr_document_spec.rb +6 -2
- data/spec/presenters/blacklight/document_presenter_spec.rb +86 -0
- data/spec/presenters/blacklight/index_presenter_spec.rb +186 -0
- data/spec/presenters/blacklight/json_presenter_spec.rb +59 -0
- data/spec/presenters/blacklight/link_alternate_presenter_spec.rb +3 -0
- data/spec/presenters/blacklight/search_bar_presenter_spec.rb +7 -0
- data/spec/presenters/{show_presenter_spec.rb → blacklight/show_presenter_spec.rb} +138 -91
- data/spec/presenters/pipeline_spec.rb +15 -8
- data/spec/presenters/thumbnail_presenter_spec.rb +5 -2
- data/spec/routing/catalog_routing_spec.rb +12 -14
- data/spec/services/blacklight/search_service_spec.rb +112 -70
- data/spec/spec_helper.rb +6 -2
- data/spec/support/features.rb +1 -1
- data/spec/support/features/session_helpers.rb +4 -4
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -13
- data/spec/views/catalog/_constraints.html.erb_spec.rb +2 -3
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +9 -5
- data/spec/views/catalog/_document.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -4
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_facets.html.erb_spec.rb +8 -10
- data/spec/views/catalog/_index.html.erb_spec.rb +13 -14
- data/spec/views/catalog/_index_header.html.erb_spec.rb +5 -8
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +3 -3
- data/spec/views/catalog/_show.html.erb_spec.rb +12 -13
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +4 -7
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +2 -2
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +0 -1
- data/spec/views/catalog/_sort_widget.html.erb_spec.rb +3 -1
- data/spec/views/catalog/_thumbnail.html.erb_spec.rb +6 -8
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +7 -9
- data/spec/views/catalog/email_success.html.erb_spec.rb +0 -1
- data/spec/views/catalog/facet.html.erb_spec.rb +3 -2
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +3 -2
- data/spec/views/catalog/index.atom.builder_spec.rb +9 -4
- data/spec/views/catalog/index.html.erb_spec.rb +2 -1
- data/spec/views/catalog/index.json.jbuilder_spec.rb +84 -36
- data/spec/views/catalog/show.html.erb_spec.rb +6 -6
- data/spec/views/catalog/show.json.jbuilder_spec.rb +40 -0
- data/spec/views/catalog/sms_success.html.erb_spec.rb +0 -1
- data/spec/views/shared/_user_util_links.html.erb_spec.rb +1 -4
- data/tasks/blacklight.rake +6 -4
- data/template.demo.rb +2 -0
- metadata +50 -24
- data/app/javascript/blacklight/autofocus.js +0 -20
- data/spec/presenters/index_presenter_spec.rb +0 -150
@@ -19,21 +19,23 @@ Blacklight = function() {
|
|
19
19
|
listeners.push('turbolinks:load');
|
20
20
|
} else {
|
21
21
|
// Turbolinks < 5
|
22
|
-
listeners.push('page:load', '
|
22
|
+
listeners.push('page:load', 'DOMContentLoaded');
|
23
23
|
}
|
24
24
|
} else {
|
25
|
-
listeners.push('
|
25
|
+
listeners.push('DOMContentLoaded');
|
26
26
|
}
|
27
27
|
|
28
|
-
return listeners
|
28
|
+
return listeners;
|
29
29
|
}
|
30
30
|
};
|
31
31
|
}();
|
32
32
|
|
33
33
|
// turbolinks triggers page:load events on page transition
|
34
34
|
// If app isn't using turbolinks, this event will never be triggered, no prob.
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
Blacklight.listeners().forEach(function(listener) {
|
36
|
+
document.addEventListener(listener, function() {
|
37
|
+
Blacklight.activate()
|
38
|
+
})
|
39
|
+
})
|
38
40
|
|
39
41
|
$('.no-js').removeClass('no-js').addClass('js');
|
@@ -1,5 +1,3 @@
|
|
1
|
-
//= require blacklight/core
|
2
|
-
|
3
1
|
/*
|
4
2
|
The blacklight modal plugin can display some interactions inside a Bootstrap
|
5
3
|
modal window, including some multi-page interactions.
|
@@ -119,7 +117,7 @@ Blacklight.modal.receiveAjax = function (contents) {
|
|
119
117
|
// code modelled off of JQuery ajax.load. https://github.com/jquery/jquery/blob/master/src/ajax/load.js?source=c#L62
|
120
118
|
var container = $('<div>').
|
121
119
|
append( jQuery.parseHTML(contents) ).find( Blacklight.modal.containerSelector ).first();
|
122
|
-
if (container.
|
120
|
+
if (container.length !== 0) {
|
123
121
|
contents = container.html();
|
124
122
|
}
|
125
123
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Blacklight
|
2
4
|
class Icon
|
3
5
|
attr_reader :icon_name
|
@@ -35,6 +37,7 @@ module Blacklight
|
|
35
37
|
# @return [String]
|
36
38
|
def file_source
|
37
39
|
raise Blacklight::Exceptions::IconNotFound, "Could not find #{path}" if file.blank?
|
40
|
+
|
38
41
|
file.source.force_encoding('UTF-8')
|
39
42
|
end
|
40
43
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Blacklight
|
3
4
|
class SuggestSearch
|
4
5
|
attr_reader :request_params, :repository
|
5
6
|
|
6
7
|
##
|
7
8
|
# @param [Hash] params
|
9
|
+
# @param [Blacklight::AbstractRepository] repository
|
8
10
|
def initialize(params, repository)
|
9
11
|
@request_params = { q: params[:q] }
|
10
12
|
@repository = repository
|
@@ -15,20 +17,7 @@ module Blacklight
|
|
15
17
|
# Blacklight::Suggest::Response
|
16
18
|
# @return [Blacklight::Suggest::Response]
|
17
19
|
def suggestions
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
##
|
22
|
-
# Query the suggest handler using RSolr::Client::send_and_receive
|
23
|
-
# @return [RSolr::HashWithResponse]
|
24
|
-
def suggest_results
|
25
|
-
repository.connection.send_and_receive(suggest_handler_path, params: request_params)
|
26
|
-
end
|
27
|
-
|
28
|
-
##
|
29
|
-
# @return [String]
|
30
|
-
def suggest_handler_path
|
31
|
-
repository.blacklight_config.autocomplete_path
|
20
|
+
repository.suggestions(request_params)
|
32
21
|
end
|
33
22
|
end
|
34
23
|
end
|
data/app/models/bookmark.rb
CHANGED
@@ -2,17 +2,19 @@
|
|
2
2
|
module Blacklight
|
3
3
|
module Suggest
|
4
4
|
class Response
|
5
|
-
attr_reader :response, :request_params, :suggest_path
|
5
|
+
attr_reader :response, :request_params, :suggest_path, :suggester_name
|
6
6
|
|
7
7
|
##
|
8
8
|
# Creates a suggest response
|
9
9
|
# @param [RSolr::HashWithResponse] response
|
10
10
|
# @param [Hash] request_params
|
11
11
|
# @param [String] suggest_path
|
12
|
-
|
12
|
+
# @param [String] suggester_name
|
13
|
+
def initialize(response, request_params, suggest_path, suggester_name)
|
13
14
|
@response = response
|
14
15
|
@request_params = request_params
|
15
16
|
@suggest_path = suggest_path
|
17
|
+
@suggester_name = suggester_name
|
16
18
|
end
|
17
19
|
|
18
20
|
##
|
@@ -20,7 +22,7 @@ module Blacklight
|
|
20
22
|
# present
|
21
23
|
# @return [Array]
|
22
24
|
def suggestions
|
23
|
-
response.try(:[], suggest_path).try(:[],
|
25
|
+
(response.try(:[], suggest_path).try(:[], suggester_name).try(:[], request_params[:q]).try(:[], 'suggestions') || []).uniq
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -6,6 +6,7 @@ module Blacklight::User
|
|
6
6
|
# is injected into the hosting application through ActiveRecord::Base extend
|
7
7
|
def self.included(base)
|
8
8
|
return unless base.respond_to? :has_many
|
9
|
+
|
9
10
|
base.send :has_many, :bookmarks, dependent: :destroy, as: :user
|
10
11
|
base.send :has_many, :searches, dependent: :destroy, as: :user
|
11
12
|
end
|
data/app/models/search.rb
CHANGED
@@ -14,6 +14,7 @@ class Search < ApplicationRecord
|
|
14
14
|
def self.delete_old_searches(days_old)
|
15
15
|
raise ArgumentError, 'days_old is expected to be a number' unless days_old.is_a?(Numeric)
|
16
16
|
raise ArgumentError, 'days_old is expected to be greater than 0' if days_old <= 0
|
17
|
+
|
17
18
|
where(['created_at < ? AND user_id IS NULL', Time.zone.today - days_old]).destroy_all
|
18
19
|
end
|
19
20
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Blacklight
|
4
|
+
# An abstract class that the view presenters for SolrDocuments descend from
|
5
|
+
class DocumentPresenter
|
6
|
+
attr_reader :document, :configuration, :view_context
|
7
|
+
|
8
|
+
# @return [Hash<String,Configuration::Field>] all the fields for this index view that should be rendered
|
9
|
+
def fields_to_render
|
10
|
+
fields.select do |_name, field_config|
|
11
|
+
# rubocop:disable Style/PreferredHashMethods
|
12
|
+
render_field?(field_config) && has_value?(field_config)
|
13
|
+
# rubocop:enable Style/PreferredHashMethods
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
##
|
20
|
+
# Check to see if the given field should be rendered in this context
|
21
|
+
# @param [Blacklight::Configuration::Field] field_config
|
22
|
+
# @return [Boolean]
|
23
|
+
def render_field?(field_config)
|
24
|
+
view_context.should_render_field?(field_config, document)
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Check if a document has (or, might have, in the case of accessor methods) a value for
|
29
|
+
# the given solr field
|
30
|
+
# @param [Blacklight::Configuration::Field] field_config
|
31
|
+
# @return [Boolean]
|
32
|
+
def has_value? field_config
|
33
|
+
document.has?(field_config.field) ||
|
34
|
+
(document.has_highlight_field? field_config.field if field_config.highlight) ||
|
35
|
+
field_config.accessor
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Blacklight
|
3
|
-
class IndexPresenter
|
3
|
+
class IndexPresenter < DocumentPresenter
|
4
4
|
class_attribute :thumbnail_presenter
|
5
5
|
self.thumbnail_presenter = ThumbnailPresenter
|
6
6
|
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :view_config
|
8
8
|
|
9
9
|
# @param [SolrDocument] document
|
10
10
|
# @param [ActionView::Base] view_context scope for linking and generating urls
|
@@ -29,8 +29,12 @@ module Blacklight
|
|
29
29
|
config = field_config(field_or_string_or_proc)
|
30
30
|
document[field_or_string_or_proc]
|
31
31
|
when Proc
|
32
|
+
Deprecation.warn(self, "calling IndexPresenter.label with a Proc is deprecated. " \
|
33
|
+
"First argument must be a symbol. This will be removed in Blacklight 8")
|
32
34
|
field_or_string_or_proc.call(document, opts)
|
33
35
|
when String
|
36
|
+
Deprecation.warn(self, "calling IndexPresenter.label with a String is deprecated. " \
|
37
|
+
"First argument must be a symbol. This will be removed in Blacklight 8")
|
34
38
|
field_or_string_or_proc
|
35
39
|
end
|
36
40
|
|
@@ -43,12 +47,11 @@ module Blacklight
|
|
43
47
|
#
|
44
48
|
# Allow an extention point where information in the document
|
45
49
|
# may drive the value of the field
|
46
|
-
# @param [
|
50
|
+
# @param [Configuration::Field] field
|
47
51
|
# @param [Hash] options
|
48
52
|
# @option options [String] :value
|
49
53
|
def field_value field, options = {}
|
50
|
-
|
51
|
-
field_values(field_config, options)
|
54
|
+
field_values(field, options)
|
52
55
|
end
|
53
56
|
|
54
57
|
def thumbnail
|
@@ -57,6 +60,11 @@ module Blacklight
|
|
57
60
|
|
58
61
|
private
|
59
62
|
|
63
|
+
# @return [Hash<String,Configuration::Field>] all the fields for this index view
|
64
|
+
def fields
|
65
|
+
configuration.index_fields_for(document)
|
66
|
+
end
|
67
|
+
|
60
68
|
##
|
61
69
|
# Get the value for a document's field, and prepare to render it.
|
62
70
|
# - highlight_field
|
@@ -4,10 +4,9 @@ module Blacklight
|
|
4
4
|
include Blacklight::Facet
|
5
5
|
|
6
6
|
# @param [Solr::Response] response raw solr response.
|
7
|
-
# @param [
|
8
|
-
def initialize(response,
|
7
|
+
# @param [Configuration] blacklight_config the configuration
|
8
|
+
def initialize(response, blacklight_config)
|
9
9
|
@response = response
|
10
|
-
@facets = facets
|
11
10
|
@blacklight_config = blacklight_config
|
12
11
|
end
|
13
12
|
|
@@ -17,15 +16,9 @@ module Blacklight
|
|
17
16
|
@response.documents
|
18
17
|
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
f.delete "options"
|
24
|
-
f["label"] = facet_configuration_for_field(f["name"]).label
|
25
|
-
f["items"] = f["items"].as_json.each do |i|
|
26
|
-
i['label'] ||= i['value']
|
27
|
-
end
|
28
|
-
end
|
19
|
+
# @return [Array<Blacklight::Solr::Response::Facets::FacetField>]
|
20
|
+
def search_facets
|
21
|
+
facets_from_request.select { |display_facet| display_facet.items.present? }
|
29
22
|
end
|
30
23
|
|
31
24
|
# extract the pagination info from the response object
|
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Blacklight
|
2
4
|
module Rendering
|
3
5
|
class LinkToFacet < AbstractStep
|
4
6
|
extend Deprecation
|
5
7
|
def render
|
6
8
|
return next_step(values) unless config.link_to_facet
|
9
|
+
|
7
10
|
next_step(render_link)
|
8
11
|
end
|
9
12
|
|
@@ -16,6 +19,7 @@ module Blacklight
|
|
16
19
|
|
17
20
|
def link_field
|
18
21
|
return config.key if config.link_to_facet == true
|
22
|
+
|
19
23
|
config.link_to_facet
|
20
24
|
end
|
21
25
|
|
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Blacklight
|
2
4
|
module Rendering
|
3
5
|
class Microdata < AbstractStep
|
4
6
|
include ActionView::Helpers::TagHelper
|
5
7
|
def render
|
6
8
|
return next_step(values) unless config.itemprop
|
9
|
+
|
7
10
|
next_step(values.map { |x| itemprop(x, config.itemprop) })
|
8
11
|
end
|
9
12
|
|
@@ -1,8 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Blacklight
|
3
|
-
class ShowPresenter
|
4
|
-
attr_reader :document, :configuration, :view_context
|
5
|
-
|
3
|
+
class ShowPresenter < DocumentPresenter
|
6
4
|
# @param [SolrDocument] document
|
7
5
|
# @param [ActionView::Base] view_context scope for linking and generating urls
|
8
6
|
# @param [Blacklight::Configuration] configuration
|
@@ -58,15 +56,20 @@ module Blacklight
|
|
58
56
|
#
|
59
57
|
# Allow an extention point where information in the document
|
60
58
|
# may drive the value of the field
|
61
|
-
# @param [
|
59
|
+
# @param [Configuration::Field] field
|
62
60
|
# @param [Hash] options
|
63
61
|
# @option options [String] :value
|
64
62
|
def field_value field, options = {}
|
65
|
-
field_values(
|
63
|
+
field_values(field, options)
|
66
64
|
end
|
67
65
|
|
68
66
|
private
|
69
67
|
|
68
|
+
# @return [Hash<String,Configuration::Field>]
|
69
|
+
def fields
|
70
|
+
configuration.show_fields_for(document)
|
71
|
+
end
|
72
|
+
|
70
73
|
##
|
71
74
|
# Get the value for a document's field, and prepare to render it.
|
72
75
|
# - highlight_field
|
@@ -6,6 +6,7 @@ module Blacklight
|
|
6
6
|
|
7
7
|
# @param [SolrDocument] document
|
8
8
|
# @param [ActionView::Base] view_context scope for linking and generating urls
|
9
|
+
# as well as for invoking "thumbnail_method"
|
9
10
|
# @param [Blacklight::Configuration::ViewConfig] view_config
|
10
11
|
def initialize(document, view_context, view_config)
|
11
12
|
@document = document
|
@@ -33,6 +34,7 @@ module Blacklight
|
|
33
34
|
def thumbnail_tag image_options = {}, url_options = {}
|
34
35
|
value = thumbnail_value(image_options)
|
35
36
|
return value if value.nil? || url_options[:suppress_link]
|
37
|
+
|
36
38
|
view_context.link_to_document document, value, url_options
|
37
39
|
end
|
38
40
|
|