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
@@ -6,23 +6,25 @@ module Blacklight::Controller
|
|
6
6
|
|
7
7
|
included do
|
8
8
|
include Blacklight::SearchFields
|
9
|
-
helper Blacklight::SearchFields
|
9
|
+
helper Blacklight::SearchFields if respond_to? :helper
|
10
10
|
|
11
11
|
include ActiveSupport::Callbacks
|
12
12
|
|
13
13
|
# now in application.rb file under config.filter_parameters
|
14
14
|
# filter_parameter_logging :password, :password_confirmation
|
15
|
-
helper_method :current_user_session, :current_user, :current_or_guest_user
|
16
|
-
after_action :discard_flash_if_xhr
|
17
15
|
|
18
16
|
# handle basic authorization exception with #access_denied
|
19
17
|
rescue_from Blacklight::Exceptions::AccessDenied, with: :access_denied
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
if respond_to? :helper_method
|
20
|
+
helper_method :current_user_session, :current_user, :current_or_guest_user
|
21
|
+
|
22
|
+
# extra head content
|
23
|
+
helper_method :has_user_authentication_provider?
|
24
|
+
helper_method :blacklight_config, :blacklight_configuration_context
|
25
|
+
helper_method :search_action_url, :search_action_path, :search_facet_path
|
26
|
+
helper_method :search_state
|
27
|
+
end
|
26
28
|
|
27
29
|
# Which class to use for the search state. You can subclass SearchState if you
|
28
30
|
# want to override any of the methods (e.g. SearchState#url_for_document)
|
@@ -38,8 +40,6 @@ module Blacklight::Controller
|
|
38
40
|
|
39
41
|
define_callbacks :logging_in_user
|
40
42
|
set_callback :logging_in_user, :before, :transfer_guest_user_actions_to_current_user
|
41
|
-
|
42
|
-
layout :determine_layout
|
43
43
|
end
|
44
44
|
|
45
45
|
def default_catalog_controller
|
@@ -95,7 +95,7 @@ module Blacklight::Controller
|
|
95
95
|
|
96
96
|
# Returns a list of Searches from the ids in the user's history.
|
97
97
|
def searches_from_history
|
98
|
-
session[:history].blank? ? Search.none : Search.where(id: session[:history]).order("updated_at desc")
|
98
|
+
session[:history].blank? ? ::Search.none : ::Search.where(id: session[:history]).order("updated_at desc")
|
99
99
|
end
|
100
100
|
|
101
101
|
# Should be provided by authentication provider
|
@@ -114,13 +114,6 @@ module Blacklight::Controller
|
|
114
114
|
end
|
115
115
|
alias blacklight_current_or_guest_user current_or_guest_user
|
116
116
|
|
117
|
-
##
|
118
|
-
# We discard flash messages generated by the xhr requests to avoid
|
119
|
-
# confusing UX.
|
120
|
-
def discard_flash_if_xhr
|
121
|
-
flash.discard if request.xhr?
|
122
|
-
end
|
123
|
-
|
124
117
|
##
|
125
118
|
#
|
126
119
|
#
|
@@ -136,6 +129,7 @@ module Blacklight::Controller
|
|
136
129
|
# When a user logs in, transfer any saved searches or bookmarks to the current_user
|
137
130
|
def transfer_guest_user_actions_to_current_user
|
138
131
|
return unless respond_to?(:current_user) && respond_to?(:guest_user) && current_user && guest_user
|
132
|
+
|
139
133
|
current_user_searches = current_user.searches.pluck(:query_params)
|
140
134
|
current_user_bookmarks = current_user.bookmarks.pluck(:document_id)
|
141
135
|
|
@@ -16,10 +16,13 @@ module Blacklight
|
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
|
+
# @param fields [Array<String>] a list of facet field names
|
20
|
+
# @return [Array<Solr::Response::Facets::FacetField>]
|
19
21
|
def facets_from_request(fields = facet_field_names)
|
20
22
|
fields.map { |field| facet_by_field_name(field) }.compact
|
21
23
|
end
|
22
24
|
|
25
|
+
# @return [Array<String>] a list of the facet field names from the configuration
|
23
26
|
def facet_field_names
|
24
27
|
blacklight_config.facet_fields.values.map(&:field)
|
25
28
|
end
|
@@ -2,10 +2,12 @@
|
|
2
2
|
module Blacklight::SearchContext
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
# The following code is executed when someone includes
|
5
|
+
# The following code is executed when someone includes Blacklight::Catalog::SearchSession in their
|
6
6
|
# own controller.
|
7
7
|
included do
|
8
|
-
|
8
|
+
if respond_to? :helper_method
|
9
|
+
helper_method :current_search_session, :search_session
|
10
|
+
end
|
9
11
|
end
|
10
12
|
|
11
13
|
module ClassMethods
|
@@ -72,6 +74,7 @@ module Blacklight::SearchContext
|
|
72
74
|
def agent_is_crawler?
|
73
75
|
crawler_proc = blacklight_config.crawler_detector
|
74
76
|
return false if crawler_proc.nil? || current_user.present?
|
77
|
+
|
75
78
|
crawler_proc.call(request)
|
76
79
|
end
|
77
80
|
|
@@ -82,7 +85,7 @@ module Blacklight::SearchContext
|
|
82
85
|
|
83
86
|
saved_search = searches_from_history.find { |x| x.query_params == params_copy }
|
84
87
|
|
85
|
-
saved_search
|
88
|
+
saved_search || Search.create(query_params: params_copy).tap do |s|
|
86
89
|
add_to_search_history(s)
|
87
90
|
end
|
88
91
|
end
|
@@ -115,5 +118,6 @@ module Blacklight::SearchContext
|
|
115
118
|
end
|
116
119
|
rescue Blacklight::Exceptions::InvalidRequest => e
|
117
120
|
logger.warn "Unable to setup next and previous documents: #{e}"
|
121
|
+
nil
|
118
122
|
end
|
119
123
|
end
|
@@ -21,12 +21,7 @@ module Blacklight
|
|
21
21
|
flash[:error] = I18n.t('blacklight.search_history.clear.failure')
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
redirect_back fallback_location: blacklight.search_history_path
|
26
|
-
else
|
27
|
-
# Deprecated in Rails 5.0
|
28
|
-
redirect_to :back
|
29
|
-
end
|
24
|
+
redirect_back fallback_location: blacklight.search_history_path
|
30
25
|
end
|
31
26
|
end
|
32
27
|
end
|
@@ -3,7 +3,9 @@ module Blacklight::TokenBasedUser
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
|
6
|
+
if respond_to? :helper_method
|
7
|
+
helper_method :encrypt_user_id
|
8
|
+
end
|
7
9
|
|
8
10
|
rescue_from Blacklight::Exceptions::ExpiredSessionToken do
|
9
11
|
head :unauthorized
|
@@ -42,6 +42,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
42
42
|
# @option options [Array<String>] :exclude array of format shortnames to not include in the output
|
43
43
|
def render_link_rel_alternates(document = @document, options = {})
|
44
44
|
return if document.nil?
|
45
|
+
|
45
46
|
presenter(document).link_rel_alternates(options)
|
46
47
|
end
|
47
48
|
|
@@ -85,6 +86,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
85
86
|
# @param [Blacklight::Configuration::Field] field_config
|
86
87
|
# @return [Boolean]
|
87
88
|
def should_render_index_field? document, field_config
|
89
|
+
Deprecation.warn self, "should_render_index_field? is deprecated and will be removed in Blacklight 8. Use IndexPresenter#render_field? instead."
|
88
90
|
should_render_field?(field_config, document) && document_has_value?(document, field_config)
|
89
91
|
end
|
90
92
|
|
@@ -95,6 +97,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
95
97
|
# @param [Blacklight::Configuration::Field] field_config
|
96
98
|
# @return [Boolean]
|
97
99
|
def should_render_show_field? document, field_config
|
100
|
+
Deprecation.warn self, "should_render_show_field? is deprecated and will be removed in Blacklight 8. Use ShowPresenter#render_field? instead."
|
98
101
|
should_render_field?(field_config, document) && document_has_value?(document, field_config)
|
99
102
|
end
|
100
103
|
|
@@ -105,6 +108,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
105
108
|
# @param [Blacklight::Configuration::Field] field_config
|
106
109
|
# @return [Boolean]
|
107
110
|
def document_has_value? document, field_config
|
111
|
+
Deprecation.warn self, "document_has_value? is deprecated and will be removed in Blacklight 8. Use DocumentPresenter#has_value? instead."
|
108
112
|
document.has?(field_config.field) ||
|
109
113
|
(document.has_highlight_field? field_config.field if field_config.highlight) ||
|
110
114
|
field_config.accessor
|
@@ -218,7 +222,7 @@ module Blacklight::BlacklightHelperBehavior
|
|
218
222
|
def document_index_view_type query_params = params
|
219
223
|
view_param = query_params[:view]
|
220
224
|
view_param ||= session[:preferred_view]
|
221
|
-
if view_param && document_index_views.
|
225
|
+
if view_param && document_index_views.key?(view_param.to_sym)
|
222
226
|
view_param.to_sym
|
223
227
|
else
|
224
228
|
default_document_index_view_type
|
@@ -6,6 +6,7 @@ module Blacklight::ConfigurationHelperBehavior
|
|
6
6
|
# @param [SolrDocument] document
|
7
7
|
# @return [Array<Blacklight::Configuration::Field>]
|
8
8
|
def index_fields _document = nil
|
9
|
+
Deprecation.warn(self, "index_fields is deprecated and will be removed in Blacklight 8. Use IndexPresenter#fields instead")
|
9
10
|
blacklight_config.index_fields
|
10
11
|
end
|
11
12
|
|
@@ -27,8 +28,9 @@ module Blacklight::ConfigurationHelperBehavior
|
|
27
28
|
end.compact
|
28
29
|
end
|
29
30
|
|
30
|
-
# used in the catalog/_show
|
31
|
+
# used in the catalog/_show partial
|
31
32
|
def document_show_fields _document = nil
|
33
|
+
Deprecation.warn(self, "document_show_fields is deprecated and will be removed in Blacklight 8. Use ShowPresenter#fields instead")
|
32
34
|
blacklight_config.show_fields
|
33
35
|
end
|
34
36
|
|
@@ -53,7 +55,7 @@ module Blacklight::ConfigurationHelperBehavior
|
|
53
55
|
##
|
54
56
|
# Look up the label for the index field
|
55
57
|
def index_field_label document, field
|
56
|
-
field_config =
|
58
|
+
field_config = blacklight_config.index_fields_for(document)[field]
|
57
59
|
field_config ||= Blacklight::Configuration::NullField.new(key: field)
|
58
60
|
|
59
61
|
field_config.display_label('index')
|
@@ -62,7 +64,7 @@ module Blacklight::ConfigurationHelperBehavior
|
|
62
64
|
##
|
63
65
|
# Look up the label for the show field
|
64
66
|
def document_show_field_label document, field
|
65
|
-
field_config =
|
67
|
+
field_config = blacklight_config.show_fields_for(document)[field]
|
66
68
|
field_config ||= Blacklight::Configuration::NullField.new(key: field)
|
67
69
|
|
68
70
|
field_config.display_label('show')
|
@@ -8,7 +8,7 @@ module Blacklight::FacetsHelperBehavior
|
|
8
8
|
# @param [Array<String>] fields
|
9
9
|
# @return [Boolean]
|
10
10
|
def has_facet_values? fields = facet_field_names
|
11
|
-
facets_from_request(fields).any? { |display_facet|
|
11
|
+
facets_from_request(fields).any? { |display_facet| should_render_facet?(display_facet) }
|
12
12
|
end
|
13
13
|
|
14
14
|
##
|
@@ -36,13 +36,15 @@ module Blacklight::FacetsHelperBehavior
|
|
36
36
|
# @option options [Hash] :locals locals to pass to the partial
|
37
37
|
# @return [String]
|
38
38
|
def render_facet_limit(display_facet, options = {})
|
39
|
-
|
39
|
+
field_config = facet_configuration_for_field(display_facet.name)
|
40
|
+
return unless should_render_facet?(display_facet, field_config)
|
41
|
+
|
40
42
|
options = options.dup
|
41
43
|
options[:partial] ||= facet_partial_name(display_facet)
|
42
44
|
options[:layout] ||= "facet_layout" unless options.key?(:layout)
|
43
45
|
options[:locals] ||= {}
|
44
46
|
options[:locals][:field_name] ||= display_facet.name
|
45
|
-
options[:locals][:facet_field] ||=
|
47
|
+
options[:locals][:facet_field] ||= field_config
|
46
48
|
options[:locals][:display_facet] ||= display_facet
|
47
49
|
|
48
50
|
render(options)
|
@@ -72,12 +74,14 @@ module Blacklight::FacetsHelperBehavior
|
|
72
74
|
# By default, only render facets with items.
|
73
75
|
#
|
74
76
|
# @param [Blacklight::Solr::Response::Facets::FacetField] display_facet
|
77
|
+
# @param [Blacklight::Configuration::FacetField] facet_config
|
75
78
|
# @return [Boolean]
|
76
|
-
def should_render_facet? display_facet
|
79
|
+
def should_render_facet? display_facet, facet_config = nil
|
80
|
+
return false if display_facet.items.blank?
|
81
|
+
|
77
82
|
# display when show is nil or true
|
78
|
-
facet_config
|
79
|
-
|
80
|
-
display && display_facet.items.present?
|
83
|
+
facet_config ||= facet_configuration_for_field(display_facet.name)
|
84
|
+
should_render_field?(facet_config, display_facet)
|
81
85
|
end
|
82
86
|
|
83
87
|
##
|
@@ -103,7 +107,7 @@ module Blacklight::FacetsHelperBehavior
|
|
103
107
|
config = facet_configuration_for_field(display_facet.name)
|
104
108
|
name = config.try(:partial)
|
105
109
|
name ||= "facet_pivot" if config.pivot
|
106
|
-
name
|
110
|
+
name || "facet_limit"
|
107
111
|
end
|
108
112
|
|
109
113
|
##
|
@@ -183,8 +187,8 @@ module Blacklight::FacetsHelperBehavior
|
|
183
187
|
# Check if the query parameters have the given facet field with the
|
184
188
|
# given value.
|
185
189
|
#
|
186
|
-
# @param [
|
187
|
-
# @param [
|
190
|
+
# @param [String] field
|
191
|
+
# @param [String] item facet value
|
188
192
|
# @return [Boolean]
|
189
193
|
def facet_in_params?(field, item)
|
190
194
|
value = facet_value_for_facet_item(item)
|
@@ -221,8 +225,7 @@ module Blacklight::FacetsHelperBehavior
|
|
221
225
|
facet_config.query[value][:label]
|
222
226
|
elsif facet_config.date
|
223
227
|
localization_options = facet_config.date == true ? {} : facet_config.date
|
224
|
-
|
225
|
-
l(value.to_datetime, localization_options)
|
228
|
+
l(Time.zone.parse(value), localization_options)
|
226
229
|
else
|
227
230
|
value
|
228
231
|
end
|
@@ -65,6 +65,7 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
65
65
|
# @return [String]
|
66
66
|
def render_constraints_filters(localized_params = params)
|
67
67
|
return "".html_safe unless localized_params[:f]
|
68
|
+
|
68
69
|
path = controller.search_state_class.new(localized_params, blacklight_config, controller)
|
69
70
|
content = []
|
70
71
|
localized_params[:f].each_pair do |facet, values|
|
@@ -85,6 +86,7 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
85
86
|
|
86
87
|
safe_join(Array(values).map do |val|
|
87
88
|
next if val.blank? # skip empty string
|
89
|
+
|
88
90
|
render_constraint_element(facet_field_label(facet_config.key),
|
89
91
|
facet_display_value(facet, val),
|
90
92
|
remove: search_action_path(path.remove_facet_params(facet, val)),
|
@@ -132,8 +132,8 @@ module Blacklight::RenderPartialsHelperBehavior
|
|
132
132
|
def type_field_to_partial_name(_document, display_type)
|
133
133
|
# using "_" as sep. to more closely follow the views file naming conventions
|
134
134
|
# parameterize uses "-" as the default sep. which throws errors
|
135
|
-
underscore = '_'
|
136
|
-
Array(display_type).join(' '
|
135
|
+
underscore = '_'
|
136
|
+
Array(display_type).join(' ').tr('-', underscore).parameterize(separator: underscore)
|
137
137
|
end
|
138
138
|
|
139
139
|
##
|
@@ -52,6 +52,7 @@ module Blacklight::SearchHistoryConstraintsHelperBehavior
|
|
52
52
|
# Render the name of the facet
|
53
53
|
def render_filter_name name
|
54
54
|
return "".html_safe if name.blank?
|
55
|
+
|
55
56
|
content_tag(:span,
|
56
57
|
t('blacklight.search.filters.label', label: name),
|
57
58
|
class: 'filter-name')
|
@@ -6,20 +6,34 @@ module Blacklight::UrlHelperBehavior
|
|
6
6
|
search_state.url_for_document(doc, options)
|
7
7
|
end
|
8
8
|
|
9
|
-
#
|
10
|
-
# Use the catalog_path RESTful route to create a link to the show page for a specific item.
|
9
|
+
# Uses the catalog_path route to create a link to the show page for an item.
|
11
10
|
# catalog_path accepts a hash. The solr query params are stored in the session,
|
12
11
|
# so we only need the +counter+ param here. We also need to know if we are viewing to document as part of search results.
|
13
12
|
# TODO: move this to the IndexPresenter
|
13
|
+
# @param doc [SolrDocument] the document
|
14
|
+
# @param field_or_opts [Hash, String] either a string to render as the link text or options
|
15
|
+
# @param opts [Hash] the options to create the link with
|
16
|
+
# @option opts [Number] :counter (nil) the count to set in the session (for paging through a query result)
|
17
|
+
# @example Passing in an image
|
18
|
+
# link_to_document(doc, '<img src="thumbnail.png">', counter: 3) #=> "<a href=\"catalog/123\" data-tracker-href=\"/catalog/123/track?counter=3&search_id=999\"><img src="thumbnail.png"></a>
|
19
|
+
# @example With the default document link field
|
20
|
+
# link_to_document(doc, counter: 3) #=> "<a href=\"catalog/123\" data-tracker-href=\"/catalog/123/track?counter=3&search_id=999\">My Title</a>
|
14
21
|
def link_to_document(doc, field_or_opts = nil, opts = { counter: nil })
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
label = case field_or_opts
|
23
|
+
when NilClass
|
24
|
+
index_presenter(doc).label document_show_link_field(doc), opts
|
25
|
+
when Hash
|
26
|
+
opts = field_or_opts
|
27
|
+
index_presenter(doc).label document_show_link_field(doc), opts
|
28
|
+
when Proc, Symbol
|
29
|
+
Deprecation.warn(self, "passing a #{field_or_opts.class} to link_to_document is deprecated and will be removed in Blacklight 8")
|
30
|
+
Deprecation.silence(Blacklight::IndexPresenter) do
|
31
|
+
index_presenter(doc).label field_or_opts, opts
|
32
|
+
end
|
33
|
+
else # String
|
34
|
+
field_or_opts
|
35
|
+
end
|
20
36
|
|
21
|
-
field ||= document_show_link_field(doc)
|
22
|
-
label = index_presenter(doc).label field, opts
|
23
37
|
link_to label, url_for_document(doc), document_link_params(doc, opts)
|
24
38
|
end
|
25
39
|
|
@@ -67,13 +81,14 @@ module Blacklight::UrlHelperBehavior
|
|
67
81
|
##
|
68
82
|
# Get the URL for tracking search sessions across pages using polymorphic routing
|
69
83
|
def session_tracking_path document, params = {}
|
70
|
-
return if document.nil?
|
84
|
+
return if document.nil? || controller_name == 'bookmarks'
|
71
85
|
|
72
|
-
if respond_to?(controller_tracking_method)
|
73
|
-
|
74
|
-
else
|
75
|
-
blacklight.track_search_context_path(params.merge(id: document))
|
86
|
+
if main_app.respond_to?(controller_tracking_method)
|
87
|
+
return main_app.public_send(controller_tracking_method, params.merge(id: document))
|
76
88
|
end
|
89
|
+
|
90
|
+
raise "Unable to find #{controller_tracking_method} route helper. " \
|
91
|
+
"Did you add `concerns :searchable` routing mixin to your `config/routes.rb`?"
|
77
92
|
end
|
78
93
|
|
79
94
|
def controller_tracking_method
|
@@ -18,11 +18,11 @@
|
|
18
18
|
|
19
19
|
Pass in options for your class name and labels:
|
20
20
|
$("form.something").blCheckboxSubmit({
|
21
|
-
checked_label: "Selected",
|
22
|
-
unchecked_label: "Select",
|
23
|
-
progress_label: "Saving...",
|
24
21
|
//cssClass is added to elements added, plus used for id base
|
25
22
|
cssClass: "toggle_my_kinda_form",
|
23
|
+
error: function() {
|
24
|
+
#optional callback
|
25
|
+
},
|
26
26
|
success: function(after_success_check_state) {
|
27
27
|
#optional callback
|
28
28
|
}
|
@@ -47,7 +47,7 @@
|
|
47
47
|
var uniqueId = form.attr('data-doc-id') || Math.random();
|
48
48
|
// if form is currently using method delete to change state,
|
49
49
|
// then checkbox is currently checked
|
50
|
-
var checked = (form.find('input[name=_method][value=delete]').
|
50
|
+
var checked = (form.find('input[name=_method][value=delete]').length != 0);
|
51
51
|
|
52
52
|
var checkbox = $('<input type="checkbox">')
|
53
53
|
.addClass( options.cssClass )
|
@@ -94,10 +94,9 @@
|
|
94
94
|
type: form.attr('method').toUpperCase(),
|
95
95
|
data: form.serialize(),
|
96
96
|
error: function() {
|
97
|
-
alert('Error');
|
98
|
-
updateStateFor(checked);
|
99
97
|
label.removeAttr('disabled');
|
100
98
|
checkbox.removeAttr('disabled');
|
99
|
+
options.error.call();
|
101
100
|
},
|
102
101
|
success: function(data, status, xhr) {
|
103
102
|
//if app isn't running at all, xhr annoyingly
|
@@ -109,10 +108,9 @@
|
|
109
108
|
checkbox.removeAttr('disabled');
|
110
109
|
options.success.call(form, checked, xhr.responseJSON);
|
111
110
|
} else {
|
112
|
-
alert('Error');
|
113
|
-
updateStateFor(checked);
|
114
111
|
label.removeAttr('disabled');
|
115
112
|
checkbox.removeAttr('disabled');
|
113
|
+
options.error.call();
|
116
114
|
}
|
117
115
|
}
|
118
116
|
});
|
@@ -128,6 +126,9 @@
|
|
128
126
|
$.fn.blCheckboxSubmit.defaults = {
|
129
127
|
//cssClass is added to elements added, plus used for id base
|
130
128
|
cssClass: 'blCheckboxSubmit',
|
129
|
+
error: function() {
|
130
|
+
alert("Error");
|
131
|
+
},
|
131
132
|
success: function() {} //callback
|
132
133
|
};
|
133
134
|
})(jQuery);
|