blacklight 6.0.0.pre5 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -8
- data/Gemfile +11 -2
- data/VERSION +1 -1
- data/app/assets/stylesheets/blacklight/_facets.scss +1 -10
- data/app/controllers/bookmarks_controller.rb +1 -0
- data/app/controllers/catalog_controller.rb +1 -0
- data/app/controllers/concerns/blacklight/base.rb +1 -0
- data/app/controllers/concerns/blacklight/bookmarks.rb +13 -1
- data/app/controllers/concerns/blacklight/catalog.rb +7 -1
- data/app/controllers/concerns/blacklight/controller.rb +7 -6
- data/app/controllers/concerns/blacklight/default_component_configuration.rb +1 -0
- data/app/controllers/concerns/blacklight/facet.rb +1 -0
- data/app/controllers/concerns/blacklight/request_builders.rb +1 -0
- data/app/controllers/concerns/blacklight/search_context.rb +8 -12
- data/app/controllers/concerns/blacklight/search_fields.rb +1 -0
- data/app/controllers/concerns/blacklight/search_helper.rb +2 -1
- data/app/controllers/concerns/blacklight/search_history.rb +32 -0
- data/app/controllers/concerns/blacklight/suggest.rb +1 -0
- data/app/controllers/concerns/blacklight/suggest_search.rb +1 -0
- data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
- data/app/controllers/saved_searches_controller.rb +20 -9
- data/app/controllers/search_history_controller.rb +2 -18
- data/app/controllers/suggest_controller.rb +1 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -1
- data/app/helpers/blacklight/component_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -6
- data/app/helpers/blacklight/render_partials_helper.rb +15 -4
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
- data/app/helpers/blacklight/url_helper_behavior.rb +6 -6
- data/app/helpers/blacklight_configuration_helper.rb +1 -0
- data/app/helpers/blacklight_helper.rb +1 -0
- data/app/helpers/blacklight_url_helper.rb +1 -0
- data/app/helpers/catalog_helper.rb +1 -0
- data/app/helpers/component_helper.rb +1 -0
- data/app/helpers/facets_helper.rb +1 -0
- data/app/helpers/hash_as_hidden_fields_helper.rb +1 -0
- data/app/helpers/layout_helper.rb +1 -0
- data/app/helpers/render_constraints_helper.rb +1 -0
- data/app/helpers/search_history_constraints_helper.rb +1 -0
- data/app/helpers/suggest_helper.rb +1 -0
- data/app/models/blacklight/facet_paginator.rb +6 -2
- data/app/models/blacklight/solr/facet_paginator.rb +1 -0
- data/app/models/bookmark.rb +1 -0
- data/app/models/concerns/blacklight/configurable.rb +1 -0
- data/app/models/concerns/blacklight/document.rb +1 -0
- data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
- data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
- data/app/models/concerns/blacklight/document/dublin_core.rb +1 -0
- data/app/models/concerns/blacklight/document/email.rb +1 -0
- data/app/models/concerns/blacklight/document/export.rb +1 -0
- data/app/models/concerns/blacklight/document/extensions.rb +1 -0
- data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
- data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
- data/app/models/concerns/blacklight/document/sms.rb +1 -0
- data/app/models/concerns/blacklight/solr/document.rb +1 -0
- data/app/models/concerns/blacklight/solr/document/more_like_this.rb +1 -0
- data/app/models/concerns/blacklight/suggest/response.rb +1 -0
- data/app/models/concerns/blacklight/user.rb +1 -0
- data/app/models/record_mailer.rb +1 -0
- data/app/models/search.rb +4 -1
- data/app/models/solr_document.rb +1 -0
- data/app/presenters/blacklight/document_presenter.rb +17 -1
- data/app/presenters/blacklight/json_presenter.rb +1 -0
- data/app/views/bookmarks/_tools.html.erb +1 -1
- data/app/views/catalog/_facet_index_navigation.html.erb +2 -2
- data/app/views/catalog/_facet_pagination.html.erb +4 -4
- data/app/views/catalog/_search_results.html.erb +3 -5
- data/app/views/catalog/_view_type_group.html.erb +1 -1
- data/app/views/catalog/index.atom.builder +7 -7
- data/app/views/catalog/index.json.jbuilder +0 -1
- data/app/views/catalog/index.rss.builder +1 -4
- data/config/locales/blacklight.de.yml +0 -2
- data/config/locales/blacklight.es.yml +0 -2
- data/config/locales/blacklight.it.yml +0 -2
- data/config/locales/blacklight.pt-BR.yml +0 -6
- data/config/routes.rb +1 -0
- data/db/migrate/20140202020201_create_searches.rb +1 -0
- data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
- data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
- data/lib/blacklight.rb +3 -1
- data/lib/blacklight/abstract_repository.rb +1 -0
- data/lib/blacklight/configuration.rb +1 -0
- data/lib/blacklight/configuration/context.rb +1 -0
- data/lib/blacklight/configuration/facet_field.rb +1 -0
- data/lib/blacklight/configuration/field.rb +1 -0
- data/lib/blacklight/configuration/fields.rb +1 -0
- data/lib/blacklight/configuration/search_field.rb +1 -0
- data/lib/blacklight/configuration/sort_field.rb +1 -0
- data/lib/blacklight/configuration/tool_config.rb +1 -0
- data/lib/blacklight/configuration/view_config.rb +1 -0
- data/lib/blacklight/engine.rb +1 -0
- data/lib/blacklight/exceptions.rb +1 -0
- data/lib/blacklight/parameters.rb +4 -4
- data/lib/blacklight/routes.rb +1 -0
- data/lib/blacklight/routes/exportable.rb +1 -0
- data/lib/blacklight/routes/searchable.rb +1 -0
- data/lib/blacklight/search_builder.rb +1 -0
- data/lib/blacklight/search_state.rb +22 -5
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/repository.rb +1 -0
- data/lib/blacklight/solr/request.rb +1 -0
- data/lib/blacklight/solr/response.rb +7 -1
- data/lib/blacklight/solr/response/facets.rb +1 -0
- data/lib/blacklight/solr/response/group.rb +1 -0
- data/lib/blacklight/solr/response/group_response.rb +1 -0
- data/lib/blacklight/solr/response/more_like_this.rb +1 -0
- data/lib/blacklight/solr/response/pagination_methods.rb +1 -0
- data/lib/blacklight/solr/response/response.rb +1 -0
- data/lib/blacklight/solr/response/spelling.rb +1 -0
- data/lib/blacklight/solr/search_builder_behavior.rb +19 -14
- data/lib/blacklight/utils.rb +1 -0
- data/lib/blacklight/version.rb +1 -0
- data/lib/generators/blacklight/assets_generator.rb +1 -0
- data/lib/generators/blacklight/controller_generator.rb +1 -0
- data/lib/generators/blacklight/document_generator.rb +1 -0
- data/lib/generators/blacklight/install_generator.rb +1 -0
- data/lib/generators/blacklight/models_generator.rb +1 -0
- data/lib/generators/blacklight/search_builder_generator.rb +1 -0
- data/lib/generators/blacklight/solr4_generator.rb +1 -0
- data/lib/generators/blacklight/solr5_generator.rb +2 -2
- data/lib/generators/blacklight/templates/alternate_controller.rb +1 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +1 -0
- data/lib/generators/blacklight/templates/search_builder.rb +1 -0
- data/lib/generators/blacklight/templates/solr_document.rb +1 -0
- data/lib/generators/blacklight/test_support_generator.rb +1 -0
- data/lib/generators/blacklight/user_generator.rb +10 -6
- data/lib/railties/blacklight.rake +3 -3
- data/spec/controllers/alternate_controller_spec.rb +1 -0
- data/spec/controllers/application_controller_spec.rb +1 -0
- data/spec/controllers/blacklight/base_spec.rb +5 -3
- data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -0
- data/spec/controllers/blacklight/facet_spec.rb +1 -0
- data/spec/controllers/blacklight/search_fields_spec.rb +1 -0
- data/spec/controllers/blacklight/search_helper_spec.rb +1 -0
- data/spec/controllers/blacklight/suggest_search_spec.rb +1 -0
- data/spec/controllers/bookmarks_controller_spec.rb +1 -0
- data/spec/controllers/catalog_controller_spec.rb +17 -14
- data/spec/controllers/saved_searches_controller_spec.rb +1 -0
- data/spec/controllers/search_history_controller_spec.rb +1 -0
- data/spec/controllers/suggest_controller_spec.rb +1 -0
- data/spec/features/alternate_controller_spec.rb +1 -0
- data/spec/features/bookmarks_spec.rb +1 -0
- data/spec/features/did_you_mean_spec.rb +1 -0
- data/spec/features/facets_spec.rb +1 -0
- data/spec/features/record_view_spec.rb +1 -0
- data/spec/features/saved_searches_spec.rb +1 -0
- data/spec/features/search_context_spec.rb +1 -0
- data/spec/features/search_filters_spec.rb +2 -1
- data/spec/features/search_formats_spec.rb +1 -0
- data/spec/features/search_history_spec.rb +1 -0
- data/spec/features/search_pagination_spec.rb +1 -0
- data/spec/features/search_results_spec.rb +1 -0
- data/spec/features/search_sort_spec.rb +1 -0
- data/spec/features/search_spec.rb +1 -0
- data/spec/features/sitelinks_search_box.rb +1 -0
- data/spec/helpers/blacklight_helper_spec.rb +3 -2
- data/spec/helpers/catalog_helper_spec.rb +11 -16
- data/spec/helpers/configuration_helper_spec.rb +1 -0
- data/spec/helpers/deprecated_url_helper_behavior_spec.rb +18 -9
- data/spec/helpers/facets_helper_spec.rb +1 -0
- data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -0
- data/spec/helpers/layout_helper_spec.rb +1 -0
- data/spec/helpers/render_constraints_helper_spec.rb +18 -8
- data/spec/helpers/search_history_constraints_helper_spec.rb +1 -0
- data/spec/helpers/suggest_helper_spec.rb +1 -0
- data/spec/helpers/url_helper_spec.rb +72 -68
- data/spec/lib/blacklight/parameters_spec.rb +3 -2
- data/spec/lib/blacklight/search_state_spec.rb +44 -32
- data/spec/lib/blacklight/utils_spec.rb +1 -0
- data/spec/lib/blacklight_spec.rb +11 -3
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
- data/spec/models/blacklight/configurable_spec.rb +1 -0
- data/spec/models/blacklight/configuration/context_spec.rb +1 -0
- data/spec/models/blacklight/configuration_spec.rb +1 -0
- data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -0
- data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
- data/spec/models/blacklight/document/dublin_core_spec.rb +1 -0
- data/spec/models/blacklight/document/email_spec.rb +1 -0
- data/spec/models/blacklight/document/sms_spec.rb +1 -0
- data/spec/models/blacklight/document_spec.rb +1 -0
- data/spec/models/blacklight/facet_paginator_spec.rb +21 -8
- data/spec/models/blacklight/search_builder_spec.rb +1 -0
- data/spec/models/blacklight/solr/document/more_like_this_spec.rb +1 -0
- data/spec/models/blacklight/solr/document_spec.rb +1 -0
- data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -0
- data/spec/models/blacklight/solr/repository_spec.rb +1 -0
- data/spec/models/blacklight/solr/request_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/facets_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
- data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
- data/spec/models/blacklight/solr/response_spec.rb +1 -0
- data/spec/models/blacklight/solr/search_builder_spec.rb +21 -30
- data/spec/models/blacklight/suggest/response_spec.rb +1 -0
- data/spec/models/blacklight/user_spec.rb +1 -0
- data/spec/models/bookmark_spec.rb +4 -3
- data/spec/models/record_mailer_spec.rb +1 -0
- data/spec/models/search_spec.rb +22 -38
- data/spec/models/solr_document_spec.rb +1 -0
- data/spec/presenters/document_presenter_spec.rb +7 -3
- data/spec/routing/catalog_routing_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/controller_level_helpers.rb +2 -1
- data/spec/support/features.rb +1 -0
- data/spec/support/features/session_helpers.rb +1 -0
- data/spec/test_app_templates/Gemfile.extra +14 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -0
- data/spec/views/_user_util_links.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -1
- data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_facets.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_index_default.erb_spec.rb +1 -0
- data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_default.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
- data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -0
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -0
- data/spec/views/catalog/_view_type_group.html.erb_spec.rb +1 -0
- data/spec/views/catalog/facet.html.erb_spec.rb +1 -0
- data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -0
- data/spec/views/catalog/index.atom.builder_spec.rb +19 -27
- data/spec/views/catalog/index.html.erb_spec.rb +1 -0
- data/spec/views/catalog/index.json.jbuilder_spec.rb +1 -0
- data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -0
- data/spec/views/catalog/show.html.erb_spec.rb +1 -0
- data/template.demo.rb +1 -0
- metadata +7 -5
- data/app/views/catalog/show.refworks.erb +0 -1
data/app/models/solr_document.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Blacklight
|
2
3
|
class DocumentPresenter
|
3
4
|
include ActionView::Helpers::OutputSafetyHelper
|
@@ -81,7 +82,7 @@ module Blacklight
|
|
81
82
|
# @param [Blacklight::Solr::Configuration::Field] solr field configuration
|
82
83
|
# @return [String]
|
83
84
|
def render_field_value value=nil, field_config=nil
|
84
|
-
safe_values = Array(value)
|
85
|
+
safe_values = recode_values(Array(value))
|
85
86
|
|
86
87
|
if field_config and field_config.itemprop
|
87
88
|
safe_values = safe_values.map { |x| content_tag :span, x, :itemprop => field_config.itemprop }
|
@@ -216,5 +217,20 @@ module Blacklight
|
|
216
217
|
def html_escape(*args)
|
217
218
|
ERB::Util.html_escape(*args)
|
218
219
|
end
|
220
|
+
|
221
|
+
private
|
222
|
+
|
223
|
+
# @param [Array<String,Fixnum>] values
|
224
|
+
# @return [Array] an array with all strings converted to UTF-8
|
225
|
+
def recode_values(values)
|
226
|
+
values.collect do |value|
|
227
|
+
if value.respond_to?(:encoding) && value.encoding != Encoding::UTF_8
|
228
|
+
Rails.logger.warn "Found a non utf-8 value in Blacklight::DocumentPresenter. \"#{value}\" Encoding is #{value.encoding}"
|
229
|
+
value.dup.force_encoding('UTF-8')
|
230
|
+
else
|
231
|
+
value
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
219
235
|
end
|
220
236
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<ul class="<%= controller_name %>Tools nav nav-pills">
|
2
|
-
<%= render_show_doc_actions document_list, document: nil, document_list: @document_list, url_opts: Blacklight::Parameters.sanitize(params) do |config, inner| %>
|
2
|
+
<%= render_show_doc_actions document_list, document: nil, document_list: @document_list, url_opts: Blacklight::Parameters.sanitize(params.to_unsafe_h) do |config, inner| %>
|
3
3
|
<li>
|
4
4
|
<%= inner %>
|
5
5
|
</li>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<nav class="alpha-filter">
|
2
|
-
<%= link_to t('blacklight.search.facets.clear'), @pagination.params_for_resort_url('index',
|
2
|
+
<%= link_to t('blacklight.search.facets.clear'), @pagination.params_for_resort_url('index', search_state.to_h.except(@pagination.request_keys[:prefix])), data: { ajax_modal: "preserve" }, class: ['btn btn-default btn-xs', ('disabled' unless @pagination.prefix.present?)].join(' ') %>
|
3
3
|
|
4
4
|
<ol class="pagination pagination-xs">
|
5
5
|
<% @facet.index_range.each do |letter| %>
|
6
|
-
<li class="<%= 'active' if @pagination.prefix == letter %>"><%= link_to(letter, @pagination.params_for_resort_url('index',
|
6
|
+
<li class="<%= 'active' if @pagination.prefix == letter %>"><%= link_to(letter, @pagination.params_for_resort_url('index', search_state.to_h.merge(@pagination.request_keys[:prefix] => letter)), data: { ajax_modal: "preserve" }) %></li>
|
7
7
|
<% end %>
|
8
8
|
</ol>
|
9
9
|
</nav>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
<div class="prev_next_links btn-group pull-left">
|
2
|
-
<%= link_to_previous_page @pagination, raw(t('views.pagination.previous')), params:
|
2
|
+
<%= link_to_previous_page @pagination, raw(t('views.pagination.previous')), params: search_state.to_h, param_name: blacklight_config.facet_paginator_class.request_keys[:page], class: 'btn btn-link', data: { ajax_modal: "preserve" } do %>
|
3
3
|
<span class="disabled btn btn-disabled"><%= raw(t('views.pagination.previous')) %></span>
|
4
4
|
<% end %>
|
5
5
|
|
6
|
-
<%= link_to_next_page @pagination, raw(t('views.pagination.next')), params:
|
6
|
+
<%= link_to_next_page @pagination, raw(t('views.pagination.next')), params: search_state.to_h, param_name: blacklight_config.facet_paginator_class.request_keys[:page], class: 'btn btn-link', data: { ajax_modal: "preserve" } do %>
|
7
7
|
<span class="disabled btn btn-disabled"><%= raw(t('views.pagination.next')) %></span>
|
8
8
|
<% end %>
|
9
9
|
</div>
|
@@ -11,9 +11,9 @@
|
|
11
11
|
<div class="sort_options btn-group pull-right">
|
12
12
|
<% if @pagination.sort == 'index' -%>
|
13
13
|
<span class="active az btn btn-default"><%= t('blacklight.search.facets.sort.index') %></span>
|
14
|
-
<%=
|
14
|
+
<%= link_to(t('blacklight.search.facets.sort.count'), @pagination.params_for_resort_url('count', search_state.to_h), class: "sort_change numeric btn btn-default", data: { ajax_modal: "preserve" }) %>
|
15
15
|
<% elsif @pagination.sort == 'count' -%>
|
16
|
-
<%= link_to(t('blacklight.search.facets.sort.index'), @pagination.params_for_resort_url('index',
|
16
|
+
<%= link_to(t('blacklight.search.facets.sort.index'), @pagination.params_for_resort_url('index', search_state.to_h), class: "sort_change az btn btn-default", data: { ajax_modal: "preserve" }) %>
|
17
17
|
<span class="active numeric btn btn-default"><%= t('blacklight.search.facets.sort.count') %></span>
|
18
18
|
<% end -%>
|
19
19
|
</div>
|
@@ -2,13 +2,11 @@
|
|
2
2
|
|
3
3
|
<% @page_title = t('blacklight.search.page_title.title', :constraints => render_search_to_page_title(params), :application_name => application_name) %>
|
4
4
|
|
5
|
-
|
6
5
|
<% content_for(:head) do -%>
|
7
6
|
<%= render_opensearch_response_metadata %>
|
8
|
-
<%=
|
9
|
-
<%=
|
10
|
-
<% end
|
11
|
-
|
7
|
+
<%= rss_feed_link_tag %>
|
8
|
+
<%= atom_feed_link_tag %>
|
9
|
+
<% end %>
|
12
10
|
|
13
11
|
<%= render 'search_header' %>
|
14
12
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<span class="sr-only"><%= t('blacklight.search.view_title') %></span>
|
4
4
|
<div class="view-type-group btn-group">
|
5
5
|
<% document_index_views.each do |view, config| %>
|
6
|
-
<%= link_to url_for(
|
6
|
+
<%= link_to url_for(search_state.to_h.merge(view: view)), title: view_label(view), class: "btn btn-default view-type-#{ view.to_s.parameterize } #{"active" if document_index_view_type == view}" do %>
|
7
7
|
<%= render_view_type_group_icon view %>
|
8
8
|
<span class="caption"><%= view_label(view) %></span>
|
9
9
|
<% end %>
|
@@ -9,25 +9,25 @@ xml.feed("xmlns" => "http://www.w3.org/2005/Atom",
|
|
9
9
|
# an author is required, so we'll just use the app name
|
10
10
|
xml.author { xml.name application_name }
|
11
11
|
|
12
|
-
xml.link "rel" => "self", "href" => url_for(
|
13
|
-
xml.link "rel" => "alternate", "href" => url_for(
|
14
|
-
xml.id url_for(
|
12
|
+
xml.link "rel" => "self", "href" => url_for(search_state.to_h.merge(only_path: false))
|
13
|
+
xml.link "rel" => "alternate", "href" => url_for(search_state.to_h.merge(:only_path => false, :format => "html")), "type" => "text/html"
|
14
|
+
xml.id url_for(search_state.to_h.merge(:only_path => false, :format => "html", :content_format => nil, "type" => "text/html"))
|
15
15
|
|
16
16
|
# Navigational and context links
|
17
17
|
|
18
18
|
xml.link( "rel" => "next",
|
19
|
-
"href" => url_for(
|
19
|
+
"href" => url_for(search_state.to_h.merge(:only_path => false, :page => @response.next_page.to_s))
|
20
20
|
) if @response.next_page
|
21
21
|
|
22
22
|
xml.link( "rel" => "previous",
|
23
|
-
"href" => url_for(
|
23
|
+
"href" => url_for(search_state.to_h.merge(:only_path => false, :page => @response.prev_page.to_s))
|
24
24
|
) if @response.prev_page
|
25
25
|
|
26
26
|
xml.link( "rel" => "first",
|
27
|
-
"href" => url_for(
|
27
|
+
"href" => url_for(search_state.to_h.merge(:only_path => false, :page => "1")))
|
28
28
|
|
29
29
|
xml.link( "rel" => "last",
|
30
|
-
"href" => url_for(
|
30
|
+
"href" => url_for(search_state.to_h.merge(:only_path => false, :page => @response.total_pages.to_s)))
|
31
31
|
|
32
32
|
# "search" doesn't seem to actually be legal, but is very common, and
|
33
33
|
# used as an example in opensearch docs
|
@@ -1,15 +1,12 @@
|
|
1
1
|
xml.instruct! :xml, :version=>"1.0"
|
2
2
|
xml.rss(:version=>"2.0") {
|
3
|
-
|
4
3
|
xml.channel {
|
5
|
-
|
6
4
|
xml.title(t('blacklight.search.title', :application_name => application_name))
|
7
|
-
xml.link(search_action_url(params))
|
5
|
+
xml.link(search_action_url(params.to_unsafe_h))
|
8
6
|
xml.description(t('blacklight.search.title', :application_name => application_name))
|
9
7
|
xml.language('en-us')
|
10
8
|
@document_list.each_with_index do |document, document_counter|
|
11
9
|
xml << Nokogiri::XML.fragment(render_document_partials(document, blacklight_config.view_config(:rss).partials, document_counter: document_counter))
|
12
10
|
end
|
13
|
-
|
14
11
|
}
|
15
12
|
}
|
@@ -83,11 +83,8 @@ pt-BR:
|
|
83
83
|
tools:
|
84
84
|
title: 'Ferramentas'
|
85
85
|
citation: 'Citar'
|
86
|
-
endnote: 'Exportar para EndNote'
|
87
|
-
refworks: 'Exportar para Refworks'
|
88
86
|
email: 'Email'
|
89
87
|
sms: 'SMS'
|
90
|
-
librarian_view: 'Librarian View'
|
91
88
|
clear: 'Limpar'
|
92
89
|
|
93
90
|
citation:
|
@@ -197,9 +194,6 @@ pt-BR:
|
|
197
194
|
remove:
|
198
195
|
value: 'Remover filtro %{value}'
|
199
196
|
label_value: 'Remover %{label}: %{value}'
|
200
|
-
librarian_view:
|
201
|
-
title: 'Librarian View'
|
202
|
-
leader: 'LEADER %{leader}'
|
203
197
|
start_over: 'refazer busca'
|
204
198
|
show:
|
205
199
|
title: '%{document_title} - %{application_name}'
|
data/config/routes.rb
CHANGED
data/lib/blacklight.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'kaminari'
|
2
3
|
require 'deprecation'
|
3
4
|
require 'blacklight/utils'
|
@@ -39,7 +40,8 @@ module Blacklight
|
|
39
40
|
when /::/
|
40
41
|
connection_config[:adapter].constantize
|
41
42
|
else
|
42
|
-
|
43
|
+
raise "The value for :adapter was not found in the blacklight.yml config" unless connection_config.key? :adapter
|
44
|
+
Blacklight.const_get("#{connection_config.fetch(:adapter)}/Repository".classify)
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
data/lib/blacklight/engine.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Blacklight
|
2
3
|
module Parameters
|
3
4
|
##
|
4
5
|
# Sanitize the search parameters by removing unnecessary parameters
|
5
|
-
# from the provided parameters
|
6
|
+
# from the provided parameters.
|
6
7
|
# @param [Hash] source_params parameters
|
7
8
|
def self.sanitize params
|
8
|
-
params
|
9
|
-
|
10
|
-
.except(:action, :controller, :id, :commit, :utf8)
|
9
|
+
params.reject { |k,v| v.nil? }
|
10
|
+
.except(:action, :controller, :id, :commit, :utf8)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/blacklight/routes.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Blacklight
|
2
3
|
# This class encapsulates the search state as represented by the query
|
3
4
|
# parameters namely: :f, :q, :page, :per_page and, :sort
|
@@ -6,13 +7,28 @@ module Blacklight
|
|
6
7
|
attr_reader :blacklight_config # Must be called blacklight_config, because Blacklight::Facet calls blacklight_config.
|
7
8
|
attr_reader :params
|
8
9
|
|
10
|
+
# @param [ActionController::Parameters] params
|
11
|
+
# @param [Blacklight::Config] blacklight_config
|
9
12
|
def initialize(params, blacklight_config)
|
10
|
-
|
13
|
+
if params.instance_of? Hash
|
14
|
+
# This is an ActionView::TestCase workaround. Will be resolved by
|
15
|
+
# https://github.com/rails/rails/pull/22913 (Rails > 4.2.5)
|
16
|
+
@params = params.with_indifferent_access
|
17
|
+
else
|
18
|
+
# This is the typical (not-ActionView::TestCase) code path.
|
19
|
+
@params = params.to_unsafe_h
|
20
|
+
# In Rails 5 to_unsafe_h returns a HashWithIndifferentAccess, in Rails 4 it returns Hash
|
21
|
+
@params = @params.with_indifferent_access if @params.instance_of? Hash
|
22
|
+
end
|
11
23
|
@blacklight_config = blacklight_config
|
12
24
|
end
|
13
25
|
|
26
|
+
def to_h
|
27
|
+
@params
|
28
|
+
end
|
29
|
+
|
14
30
|
def reset
|
15
|
-
Blacklight::SearchState.new(
|
31
|
+
Blacklight::SearchState.new(ActionController::Parameters.new, blacklight_config)
|
16
32
|
end
|
17
33
|
|
18
34
|
def url_for_document(doc, options = {})
|
@@ -58,7 +74,7 @@ module Blacklight
|
|
58
74
|
# Delete any request params from facet-specific action, needed
|
59
75
|
# to redir to index action properly.
|
60
76
|
request_keys = blacklight_config.facet_paginator_class.request_keys
|
61
|
-
new_params.
|
77
|
+
new_params.extract! *request_keys.values
|
62
78
|
|
63
79
|
new_params
|
64
80
|
end
|
@@ -92,7 +108,7 @@ module Blacklight
|
|
92
108
|
|
93
109
|
# Merge the source params with the params_to_merge hash
|
94
110
|
# @param [Hash] params_to_merge to merge into above
|
95
|
-
# @return the current search parameters after being sanitized by Blacklight::Parameters.sanitize
|
111
|
+
# @return [ActionController::Parameters] the current search parameters after being sanitized by Blacklight::Parameters.sanitize
|
96
112
|
# @yield [params] The merged parameters hash before being sanitized
|
97
113
|
def params_for_search(params_to_merge={}, &block)
|
98
114
|
# params hash we'll return
|
@@ -114,8 +130,9 @@ module Blacklight
|
|
114
130
|
##
|
115
131
|
# Reset any search parameters that store search context
|
116
132
|
# and need to be reset when e.g. constraints change
|
133
|
+
# @return [ActionController::Parameters]
|
117
134
|
def reset_search_params
|
118
|
-
|
135
|
+
Parameters.sanitize(params).except(:page, :counter)
|
119
136
|
end
|
120
137
|
|
121
138
|
# TODO: this code is duplicated in Blacklight::FacetsHelperBehavior
|