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.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -8
  3. data/Gemfile +11 -2
  4. data/VERSION +1 -1
  5. data/app/assets/stylesheets/blacklight/_facets.scss +1 -10
  6. data/app/controllers/bookmarks_controller.rb +1 -0
  7. data/app/controllers/catalog_controller.rb +1 -0
  8. data/app/controllers/concerns/blacklight/base.rb +1 -0
  9. data/app/controllers/concerns/blacklight/bookmarks.rb +13 -1
  10. data/app/controllers/concerns/blacklight/catalog.rb +7 -1
  11. data/app/controllers/concerns/blacklight/controller.rb +7 -6
  12. data/app/controllers/concerns/blacklight/default_component_configuration.rb +1 -0
  13. data/app/controllers/concerns/blacklight/facet.rb +1 -0
  14. data/app/controllers/concerns/blacklight/request_builders.rb +1 -0
  15. data/app/controllers/concerns/blacklight/search_context.rb +8 -12
  16. data/app/controllers/concerns/blacklight/search_fields.rb +1 -0
  17. data/app/controllers/concerns/blacklight/search_helper.rb +2 -1
  18. data/app/controllers/concerns/blacklight/search_history.rb +32 -0
  19. data/app/controllers/concerns/blacklight/suggest.rb +1 -0
  20. data/app/controllers/concerns/blacklight/suggest_search.rb +1 -0
  21. data/app/controllers/concerns/blacklight/token_based_user.rb +1 -0
  22. data/app/controllers/saved_searches_controller.rb +20 -9
  23. data/app/controllers/search_history_controller.rb +2 -18
  24. data/app/controllers/suggest_controller.rb +1 -0
  25. data/app/helpers/blacklight/blacklight_helper_behavior.rb +1 -0
  26. data/app/helpers/blacklight/catalog_helper_behavior.rb +15 -1
  27. data/app/helpers/blacklight/component_helper_behavior.rb +1 -0
  28. data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -0
  29. data/app/helpers/blacklight/deprecated_url_helper_behavior.rb +1 -0
  30. data/app/helpers/blacklight/facets_helper_behavior.rb +1 -0
  31. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +1 -0
  32. data/app/helpers/blacklight/layout_helper_behavior.rb +1 -0
  33. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -6
  34. data/app/helpers/blacklight/render_partials_helper.rb +15 -4
  35. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +1 -0
  36. data/app/helpers/blacklight/suggest_helper_behavior.rb +1 -0
  37. data/app/helpers/blacklight/url_helper_behavior.rb +6 -6
  38. data/app/helpers/blacklight_configuration_helper.rb +1 -0
  39. data/app/helpers/blacklight_helper.rb +1 -0
  40. data/app/helpers/blacklight_url_helper.rb +1 -0
  41. data/app/helpers/catalog_helper.rb +1 -0
  42. data/app/helpers/component_helper.rb +1 -0
  43. data/app/helpers/facets_helper.rb +1 -0
  44. data/app/helpers/hash_as_hidden_fields_helper.rb +1 -0
  45. data/app/helpers/layout_helper.rb +1 -0
  46. data/app/helpers/render_constraints_helper.rb +1 -0
  47. data/app/helpers/search_history_constraints_helper.rb +1 -0
  48. data/app/helpers/suggest_helper.rb +1 -0
  49. data/app/models/blacklight/facet_paginator.rb +6 -2
  50. data/app/models/blacklight/solr/facet_paginator.rb +1 -0
  51. data/app/models/bookmark.rb +1 -0
  52. data/app/models/concerns/blacklight/configurable.rb +1 -0
  53. data/app/models/concerns/blacklight/document.rb +1 -0
  54. data/app/models/concerns/blacklight/document/active_model_shim.rb +1 -0
  55. data/app/models/concerns/blacklight/document/cache_key.rb +1 -0
  56. data/app/models/concerns/blacklight/document/dublin_core.rb +1 -0
  57. data/app/models/concerns/blacklight/document/email.rb +1 -0
  58. data/app/models/concerns/blacklight/document/export.rb +1 -0
  59. data/app/models/concerns/blacklight/document/extensions.rb +1 -0
  60. data/app/models/concerns/blacklight/document/schema_org.rb +1 -0
  61. data/app/models/concerns/blacklight/document/semantic_fields.rb +1 -0
  62. data/app/models/concerns/blacklight/document/sms.rb +1 -0
  63. data/app/models/concerns/blacklight/solr/document.rb +1 -0
  64. data/app/models/concerns/blacklight/solr/document/more_like_this.rb +1 -0
  65. data/app/models/concerns/blacklight/suggest/response.rb +1 -0
  66. data/app/models/concerns/blacklight/user.rb +1 -0
  67. data/app/models/record_mailer.rb +1 -0
  68. data/app/models/search.rb +4 -1
  69. data/app/models/solr_document.rb +1 -0
  70. data/app/presenters/blacklight/document_presenter.rb +17 -1
  71. data/app/presenters/blacklight/json_presenter.rb +1 -0
  72. data/app/views/bookmarks/_tools.html.erb +1 -1
  73. data/app/views/catalog/_facet_index_navigation.html.erb +2 -2
  74. data/app/views/catalog/_facet_pagination.html.erb +4 -4
  75. data/app/views/catalog/_search_results.html.erb +3 -5
  76. data/app/views/catalog/_view_type_group.html.erb +1 -1
  77. data/app/views/catalog/index.atom.builder +7 -7
  78. data/app/views/catalog/index.json.jbuilder +0 -1
  79. data/app/views/catalog/index.rss.builder +1 -4
  80. data/config/locales/blacklight.de.yml +0 -2
  81. data/config/locales/blacklight.es.yml +0 -2
  82. data/config/locales/blacklight.it.yml +0 -2
  83. data/config/locales/blacklight.pt-BR.yml +0 -6
  84. data/config/routes.rb +1 -0
  85. data/db/migrate/20140202020201_create_searches.rb +1 -0
  86. data/db/migrate/20140202020202_create_bookmarks.rb +1 -0
  87. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +1 -0
  88. data/lib/blacklight.rb +3 -1
  89. data/lib/blacklight/abstract_repository.rb +1 -0
  90. data/lib/blacklight/configuration.rb +1 -0
  91. data/lib/blacklight/configuration/context.rb +1 -0
  92. data/lib/blacklight/configuration/facet_field.rb +1 -0
  93. data/lib/blacklight/configuration/field.rb +1 -0
  94. data/lib/blacklight/configuration/fields.rb +1 -0
  95. data/lib/blacklight/configuration/search_field.rb +1 -0
  96. data/lib/blacklight/configuration/sort_field.rb +1 -0
  97. data/lib/blacklight/configuration/tool_config.rb +1 -0
  98. data/lib/blacklight/configuration/view_config.rb +1 -0
  99. data/lib/blacklight/engine.rb +1 -0
  100. data/lib/blacklight/exceptions.rb +1 -0
  101. data/lib/blacklight/parameters.rb +4 -4
  102. data/lib/blacklight/routes.rb +1 -0
  103. data/lib/blacklight/routes/exportable.rb +1 -0
  104. data/lib/blacklight/routes/searchable.rb +1 -0
  105. data/lib/blacklight/search_builder.rb +1 -0
  106. data/lib/blacklight/search_state.rb +22 -5
  107. data/lib/blacklight/solr.rb +1 -0
  108. data/lib/blacklight/solr/repository.rb +1 -0
  109. data/lib/blacklight/solr/request.rb +1 -0
  110. data/lib/blacklight/solr/response.rb +7 -1
  111. data/lib/blacklight/solr/response/facets.rb +1 -0
  112. data/lib/blacklight/solr/response/group.rb +1 -0
  113. data/lib/blacklight/solr/response/group_response.rb +1 -0
  114. data/lib/blacklight/solr/response/more_like_this.rb +1 -0
  115. data/lib/blacklight/solr/response/pagination_methods.rb +1 -0
  116. data/lib/blacklight/solr/response/response.rb +1 -0
  117. data/lib/blacklight/solr/response/spelling.rb +1 -0
  118. data/lib/blacklight/solr/search_builder_behavior.rb +19 -14
  119. data/lib/blacklight/utils.rb +1 -0
  120. data/lib/blacklight/version.rb +1 -0
  121. data/lib/generators/blacklight/assets_generator.rb +1 -0
  122. data/lib/generators/blacklight/controller_generator.rb +1 -0
  123. data/lib/generators/blacklight/document_generator.rb +1 -0
  124. data/lib/generators/blacklight/install_generator.rb +1 -0
  125. data/lib/generators/blacklight/models_generator.rb +1 -0
  126. data/lib/generators/blacklight/search_builder_generator.rb +1 -0
  127. data/lib/generators/blacklight/solr4_generator.rb +1 -0
  128. data/lib/generators/blacklight/solr5_generator.rb +2 -2
  129. data/lib/generators/blacklight/templates/alternate_controller.rb +1 -0
  130. data/lib/generators/blacklight/templates/catalog_controller.rb +1 -0
  131. data/lib/generators/blacklight/templates/search_builder.rb +1 -0
  132. data/lib/generators/blacklight/templates/solr_document.rb +1 -0
  133. data/lib/generators/blacklight/test_support_generator.rb +1 -0
  134. data/lib/generators/blacklight/user_generator.rb +10 -6
  135. data/lib/railties/blacklight.rake +3 -3
  136. data/spec/controllers/alternate_controller_spec.rb +1 -0
  137. data/spec/controllers/application_controller_spec.rb +1 -0
  138. data/spec/controllers/blacklight/base_spec.rb +5 -3
  139. data/spec/controllers/blacklight/catalog/component_configuration_spec.rb +1 -0
  140. data/spec/controllers/blacklight/facet_spec.rb +1 -0
  141. data/spec/controllers/blacklight/search_fields_spec.rb +1 -0
  142. data/spec/controllers/blacklight/search_helper_spec.rb +1 -0
  143. data/spec/controllers/blacklight/suggest_search_spec.rb +1 -0
  144. data/spec/controllers/bookmarks_controller_spec.rb +1 -0
  145. data/spec/controllers/catalog_controller_spec.rb +17 -14
  146. data/spec/controllers/saved_searches_controller_spec.rb +1 -0
  147. data/spec/controllers/search_history_controller_spec.rb +1 -0
  148. data/spec/controllers/suggest_controller_spec.rb +1 -0
  149. data/spec/features/alternate_controller_spec.rb +1 -0
  150. data/spec/features/bookmarks_spec.rb +1 -0
  151. data/spec/features/did_you_mean_spec.rb +1 -0
  152. data/spec/features/facets_spec.rb +1 -0
  153. data/spec/features/record_view_spec.rb +1 -0
  154. data/spec/features/saved_searches_spec.rb +1 -0
  155. data/spec/features/search_context_spec.rb +1 -0
  156. data/spec/features/search_filters_spec.rb +2 -1
  157. data/spec/features/search_formats_spec.rb +1 -0
  158. data/spec/features/search_history_spec.rb +1 -0
  159. data/spec/features/search_pagination_spec.rb +1 -0
  160. data/spec/features/search_results_spec.rb +1 -0
  161. data/spec/features/search_sort_spec.rb +1 -0
  162. data/spec/features/search_spec.rb +1 -0
  163. data/spec/features/sitelinks_search_box.rb +1 -0
  164. data/spec/helpers/blacklight_helper_spec.rb +3 -2
  165. data/spec/helpers/catalog_helper_spec.rb +11 -16
  166. data/spec/helpers/configuration_helper_spec.rb +1 -0
  167. data/spec/helpers/deprecated_url_helper_behavior_spec.rb +18 -9
  168. data/spec/helpers/facets_helper_spec.rb +1 -0
  169. data/spec/helpers/hash_as_hidden_fields_spec.rb +1 -0
  170. data/spec/helpers/layout_helper_spec.rb +1 -0
  171. data/spec/helpers/render_constraints_helper_spec.rb +18 -8
  172. data/spec/helpers/search_history_constraints_helper_spec.rb +1 -0
  173. data/spec/helpers/suggest_helper_spec.rb +1 -0
  174. data/spec/helpers/url_helper_spec.rb +72 -68
  175. data/spec/lib/blacklight/parameters_spec.rb +3 -2
  176. data/spec/lib/blacklight/search_state_spec.rb +44 -32
  177. data/spec/lib/blacklight/utils_spec.rb +1 -0
  178. data/spec/lib/blacklight_spec.rb +11 -3
  179. data/spec/lib/tasks/blacklight_task_spec.rb +1 -0
  180. data/spec/models/blacklight/configurable_spec.rb +1 -0
  181. data/spec/models/blacklight/configuration/context_spec.rb +1 -0
  182. data/spec/models/blacklight/configuration_spec.rb +1 -0
  183. data/spec/models/blacklight/document/active_model_shim_spec.rb +1 -0
  184. data/spec/models/blacklight/document/cache_key_spec.rb +1 -0
  185. data/spec/models/blacklight/document/dublin_core_spec.rb +1 -0
  186. data/spec/models/blacklight/document/email_spec.rb +1 -0
  187. data/spec/models/blacklight/document/sms_spec.rb +1 -0
  188. data/spec/models/blacklight/document_spec.rb +1 -0
  189. data/spec/models/blacklight/facet_paginator_spec.rb +21 -8
  190. data/spec/models/blacklight/search_builder_spec.rb +1 -0
  191. data/spec/models/blacklight/solr/document/more_like_this_spec.rb +1 -0
  192. data/spec/models/blacklight/solr/document_spec.rb +1 -0
  193. data/spec/models/blacklight/solr/facet_paginator_spec.rb +1 -0
  194. data/spec/models/blacklight/solr/repository_spec.rb +1 -0
  195. data/spec/models/blacklight/solr/request_spec.rb +1 -0
  196. data/spec/models/blacklight/solr/response/facets_spec.rb +1 -0
  197. data/spec/models/blacklight/solr/response/group_response_spec.rb +1 -0
  198. data/spec/models/blacklight/solr/response/group_spec.rb +1 -0
  199. data/spec/models/blacklight/solr/response_spec.rb +1 -0
  200. data/spec/models/blacklight/solr/search_builder_spec.rb +21 -30
  201. data/spec/models/blacklight/suggest/response_spec.rb +1 -0
  202. data/spec/models/blacklight/user_spec.rb +1 -0
  203. data/spec/models/bookmark_spec.rb +4 -3
  204. data/spec/models/record_mailer_spec.rb +1 -0
  205. data/spec/models/search_spec.rb +22 -38
  206. data/spec/models/solr_document_spec.rb +1 -0
  207. data/spec/presenters/document_presenter_spec.rb +7 -3
  208. data/spec/routing/catalog_routing_spec.rb +1 -0
  209. data/spec/spec_helper.rb +1 -0
  210. data/spec/support/controller_level_helpers.rb +2 -1
  211. data/spec/support/features.rb +1 -0
  212. data/spec/support/features/session_helpers.rb +1 -0
  213. data/spec/test_app_templates/Gemfile.extra +14 -0
  214. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -0
  215. data/spec/views/_user_util_links.html.erb_spec.rb +1 -0
  216. data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -0
  217. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +1 -0
  218. data/spec/views/catalog/_document.html.erb_spec.rb +1 -0
  219. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -0
  220. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +4 -1
  221. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -0
  222. data/spec/views/catalog/_facets.html.erb_spec.rb +1 -0
  223. data/spec/views/catalog/_index_default.erb_spec.rb +1 -0
  224. data/spec/views/catalog/_index_header_default.html.erb_spec.rb +1 -0
  225. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -0
  226. data/spec/views/catalog/_search_header.erb_spec.rb +1 -0
  227. data/spec/views/catalog/_show_default.erb_spec.rb +1 -0
  228. data/spec/views/catalog/_show_sidebar.erb_spec.rb +1 -0
  229. data/spec/views/catalog/_show_tools.html.erb_spec.rb +1 -0
  230. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +1 -0
  231. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +1 -0
  232. data/spec/views/catalog/_view_type_group.html.erb_spec.rb +1 -0
  233. data/spec/views/catalog/facet.html.erb_spec.rb +1 -0
  234. data/spec/views/catalog/facet.json.jbuilder_spec.rb +1 -0
  235. data/spec/views/catalog/index.atom.builder_spec.rb +19 -27
  236. data/spec/views/catalog/index.html.erb_spec.rb +1 -0
  237. data/spec/views/catalog/index.json.jbuilder_spec.rb +1 -0
  238. data/spec/views/catalog/opensearch.xml.builder_spec.rb +1 -0
  239. data/spec/views/catalog/show.html.erb_spec.rb +1 -0
  240. data/template.demo.rb +1 -0
  241. metadata +7 -5
  242. data/app/views/catalog/show.refworks.erb +0 -1
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class SolrDocument
2
3
 
3
4
  include Blacklight::Solr::Document
@@ -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).collect { |x| x.respond_to?(:force_encoding) ? x.force_encoding("UTF-8") : x }
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,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class JsonPresenter
3
4
  include Blacklight::Facet
@@ -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', params.except(@pagination.request_keys[:prefix])), data: { ajax_modal: "preserve" }, class: ['btn btn-default btn-xs', ('disabled' unless @pagination.prefix.present?)].join(' ') %>
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', params.merge(@pagination.request_keys[:prefix] => letter)), data: { ajax_modal: "preserve" }) %></li>
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: params, param_name: blacklight_config.facet_paginator_class.request_keys[:page], class: 'btn btn-link', data: { ajax_modal: "preserve" } do %>
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: params, param_name: blacklight_config.facet_paginator_class.request_keys[:page], class: 'btn btn-link', data: { ajax_modal: "preserve" } do %>
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
- <%= link_to_unless(@pagination.sort == 'count', t('blacklight.search.facets.sort.count'), @pagination.params_for_resort_url('count', params), class: "sort_change numeric btn btn-default", data: {ajax_modal: "preserve"}) %>
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', params), class: "sort_change az btn btn-default", data: { ajax_modal: "preserve" }) %>
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
- <%= auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => t('blacklight.search.rss_feed') ) %>
9
- <%= auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => t('blacklight.search.atom_feed') ) %>
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(params.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 %>
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(params.merge(:only_path => false))
13
- xml.link "rel" => "alternate", "href" => url_for(params.merge(:only_path => false, :format => "html")), "type" => "text/html"
14
- xml.id url_for(params.merge(:only_path => false, :format => "html", :content_format => nil, "type" => "text/html"))
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(params.merge(:only_path => false, :page => @response.next_page.to_s))
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(params.merge(:only_path => false, :page => @response.prev_page.to_s))
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(params.merge(:only_path => false, :page => "1")))
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(params.merge(:only_path => false, :page => @response.total_pages.to_s)))
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
@@ -3,4 +3,3 @@ json.response do
3
3
  json.facets @presenter.search_facets_as_json
4
4
  json.pages @presenter.pagination_info
5
5
  end
6
-
@@ -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
  }
@@ -84,8 +84,6 @@ de:
84
84
  tools:
85
85
  title: 'Werkzeuge'
86
86
  cite: 'Zitieren'
87
- endnote: 'Export nach EndNote'
88
- refworks: 'Export nach Refworks'
89
87
  email: 'Email'
90
88
  sms: 'SMS dieses'
91
89
  clear: 'Löschen'
@@ -84,8 +84,6 @@ es:
84
84
  tools:
85
85
  title: 'Herramientas'
86
86
  citation: 'Cité'
87
- endnote: 'Exportar a EndNote'
88
- refworks: 'Exportar a Refworks'
89
87
  email: 'Correo electrónico'
90
88
  sms: 'Enviar SMS'
91
89
  clear: 'Borrar'
@@ -84,8 +84,6 @@ it:
84
84
  tools:
85
85
  title: 'Strumenti'
86
86
  citation: 'Cita'
87
- endnote: 'Esporta in EndNote'
88
- refworks: 'Esporta in Refworks'
89
87
  email: 'Invia per e-mail'
90
88
  sms: 'Invia per SMS'
91
89
  clear: 'Cancella'
@@ -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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Blacklight::Engine.routes.draw do
2
3
  get "search_history", :to => "search_history#index", :as => "search_history"
3
4
  delete "search_history/clear", :to => "search_history#clear", :as => "clear_search_history"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class CreateSearches < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :searches do |t|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class CreateBookmarks < ActiveRecord::Migration
2
3
  def self.up
3
4
  create_table :bookmarks do |t|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class AddPolymorphicTypeToBookmarks < ActiveRecord::Migration
2
3
  def change
3
4
  add_column(:bookmarks, :document_type, :string)
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
- Blacklight.const_get("#{connection_config[:adapter]}/Repository".classify)
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
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class AbstractRepository
3
4
  attr_accessor :blacklight_config
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  ##
3
4
  # Blacklight::Configuration holds the configuration for a Blacklight::Controller, including
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Configuration
3
4
  class Context
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Configuration::FacetField < Blacklight::Configuration::Field
3
4
  def normalize! blacklight_config = nil
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Configuration::Field < OpenStructWithHashAccess
3
4
  def normalize! blacklight_config = nil
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Configuration
3
4
  # This mixin provides Blacklight::Configuration with generic
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Configuration::SearchField < Blacklight::Configuration::Field
3
4
  def normalize! blacklight_config = nil
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Configuration::SortField < Blacklight::Configuration::Field
3
4
  def normalize! blacklight_config = nil
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Configuration::ToolConfig < OpenStructWithHashAccess
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Blacklight::Configuration
2
3
  class ViewConfig < Blacklight::OpenStructWithHashAccess
3
4
  class Show < ViewConfig
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class Engine < Rails::Engine
3
4
  engine_name "blacklight"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module Exceptions
3
4
 
@@ -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
- .reject { |k,v| v.nil? }
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
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module Routes
3
4
  require 'blacklight/routes/exportable'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module Routes
3
4
  class Exportable
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module Routes
3
4
  class Searchable
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  ##
3
4
  # Blacklight's SearchBuilder converts blacklight request parameters into
@@ -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
- @params = params
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({}, blacklight_config)
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.except! *request_keys.values
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
- ActiveSupport::HashWithIndifferentAccess.new(Parameters.sanitize(params).except(:page, :counter))
135
+ Parameters.sanitize(params).except(:page, :counter)
119
136
  end
120
137
 
121
138
  # TODO: this code is duplicated in Blacklight::FacetsHelperBehavior