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,20 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class SearchHistoryController < ApplicationController
2
- include Blacklight::Configurable
3
-
4
- copy_blacklight_config_from(CatalogController)
5
-
6
- def index
7
- @searches = searches_from_history
8
- end
9
-
10
-
11
- #TODO we may want to remove unsaved (those without user_id) items from the database when removed from history
12
- def clear
13
- if session[:history].clear
14
- flash[:notice] = I18n.t('blacklight.search_history.clear.success')
15
- else
16
- flash[:error] = I18n.t('blacklight.search_history.clear.failure')
17
- end
18
- redirect_to :back
19
- end
3
+ include Blacklight::SearchHistory
20
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class SuggestController < ApplicationController
2
3
  include Blacklight::Suggest
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Methods added to this helper will be available to all templates in the hosting application
2
3
  module Blacklight::BlacklightHelperBehavior
3
4
  include BlacklightUrlHelper
@@ -1,5 +1,14 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::CatalogHelperBehavior
2
3
 
4
+ def rss_feed_link_tag
5
+ auto_discovery_link_tag(:rss, feed_link_url('rss'), title: t('blacklight.search.rss_feed'))
6
+ end
7
+
8
+ def atom_feed_link_tag
9
+ auto_discovery_link_tag(:atom, feed_link_url('atom'), title: t('blacklight.search.atom_feed'))
10
+ end
11
+
3
12
  ##
4
13
  # Override the Kaminari page_entries_info helper with our own, blacklight-aware
5
14
  # implementation.
@@ -257,10 +266,15 @@ module Blacklight::CatalogHelperBehavior
257
266
  end
258
267
 
259
268
  if params['f'].present?
260
- constraints += params['f'].collect{ |key, value| render_search_to_page_title_filter(key, value) } unless params['f'].blank?
269
+ constraints += params['f'].to_unsafe_h.collect { |key, value| render_search_to_page_title_filter(key, value) }
261
270
  end
262
271
 
263
272
  constraints.join(' / ')
264
273
  end
265
274
 
275
+ private
276
+
277
+ def feed_link_url(format)
278
+ url_for search_state.to_h.merge(format: format)
279
+ end
266
280
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module ComponentHelperBehavior
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::ConfigurationHelperBehavior
2
3
 
3
4
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module DeprecatedUrlHelperBehavior
3
4
  extend Deprecation
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::FacetsHelperBehavior
2
3
  include Blacklight::Facet
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Rails Helper methods to take a hash and turn it to form <input type="hidden">
2
3
  # fields, works with hash nested with other hashes and arrays, standard rails
3
4
  # serialization style. Oddly while Hash#to_query will do this for a URL
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Methods added to this helper will be available to all templates in the hosting
2
3
  # application
3
4
  module Blacklight
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # All methods in here are 'api' that may be over-ridden by plugins and local
2
3
  # code, so method signatures and semantics should not be changed casually.
3
4
  # implementations can be of course.
@@ -17,17 +18,17 @@ module Blacklight::RenderConstraintsHelperBehavior
17
18
 
18
19
  ##
19
20
  # Render the actual constraints, not including header or footer
20
- # info.
21
- #
21
+ # info.
22
+ #
22
23
  # @param [Hash] query parameters
23
24
  # @return [String]
24
25
  def render_constraints(localized_params = params)
25
26
  render_constraints_query(localized_params) + render_constraints_filters(localized_params)
26
27
  end
27
-
28
+
28
29
  ##
29
30
  # Render the query constraints
30
- #
31
+ #
31
32
  # @param [Hash] query parameters
32
33
  # @return [String]
33
34
  def render_constraints_query(localized_params = params)
@@ -35,10 +36,12 @@ module Blacklight::RenderConstraintsHelperBehavior
35
36
  scope = localized_params.delete(:route_set) || self
36
37
  return "".html_safe if localized_params[:q].blank?
37
38
 
39
+ options = localized_params.merge(:q=>nil, :action=>'index')
40
+ options.permit!
38
41
  render_constraint_element(constraint_query_label(localized_params),
39
42
  localized_params[:q],
40
- :classes => ["query"],
41
- :remove => scope.url_for(localized_params.merge(:q=>nil, :action=>'index')))
43
+ classes: ["query"],
44
+ remove: scope.url_for(options))
42
45
  end
43
46
 
44
47
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::RenderPartialsHelper
2
3
  ##
3
4
  # Render the document index view
@@ -102,10 +103,20 @@ module Blacklight::RenderPartialsHelper
102
103
  # @example
103
104
  # type_field_to_partial_name(['a book-article'])
104
105
  # => 'a_book_article'
105
- def type_field_to_partial_name(document, display_type)
106
- # using "_" as sep. to more closely follow the views file naming conventions
107
- # parameterize uses "-" as the default sep. which throws errors
108
- Array(display_type).join(" ").tr("-", "_").parameterize("_")
106
+ if Rails.version >= '5.0.0'
107
+ def type_field_to_partial_name(document, display_type)
108
+ # using "_" as sep. to more closely follow the views file naming conventions
109
+ # parameterize uses "-" as the default sep. which throws errors
110
+ underscore = '_'.freeze
111
+ Array(display_type).join(' '.freeze).tr('-'.freeze, underscore).parameterize(separator: underscore)
112
+ end
113
+ else
114
+ def type_field_to_partial_name(document, display_type)
115
+ # using "_" as sep. to more closely follow the views file naming conventions
116
+ # parameterize uses "-" as the default sep. which throws errors
117
+ underscore = '_'.freeze
118
+ Array(display_type).join(' '.freeze).tr('-'.freeze, underscore).parameterize(underscore)
119
+ end
109
120
  end
110
121
 
111
122
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # All methods in here are 'api' that may be over-ridden by plugins and local
2
3
  # code, so method signatures and semantics should not be changed casually.
3
4
  # implementations can be of course.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module SuggestHelperBehavior
3
4
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  # URL helper methods
3
4
  module Blacklight::UrlHelperBehavior
@@ -90,10 +91,9 @@ module Blacklight::UrlHelperBehavior
90
91
 
91
92
  # create link to query (e.g. spelling suggestion)
92
93
  def link_to_query(query)
93
- p = params.except(:page, :action)
94
- p[:q]=query
95
- link_url = search_action_path(p)
96
- link_to(query, link_url)
94
+ p = search_state.to_h.except(:page, :action)
95
+ p[:q] = query
96
+ link_to(query, search_action_path(p))
97
97
  end
98
98
 
99
99
  ##
@@ -113,8 +113,8 @@ module Blacklight::UrlHelperBehavior
113
113
  # link_back_to_catalog(label: 'Back to Search', route_set: my_engine)
114
114
  def link_back_to_catalog(opts={:label=>nil})
115
115
  scope = opts.delete(:route_set) || self
116
- query_params = current_search_session.try(:query_params) || {}
117
-
116
+ query_params = current_search_session.try(:query_params) || ActionController::Parameters.new
117
+
118
118
  if search_session['counter']
119
119
  per_page = (search_session['per_page'] || default_per_page).to_i
120
120
  counter = search_session['counter'].to_i
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module BlacklightConfigurationHelper
2
3
  include Blacklight::ConfigurationHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module BlacklightHelper
2
3
  include Blacklight::BlacklightHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module BlacklightUrlHelper
2
3
  include Blacklight::UrlHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module CatalogHelper
2
3
  include Blacklight::CatalogHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ComponentHelper
2
3
  include Blacklight::ComponentHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module FacetsHelper
2
3
  include Blacklight::FacetsHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module HashAsHiddenFieldsHelper
2
3
  include Blacklight::HashAsHiddenFieldsHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module LayoutHelper
2
3
  include Blacklight::LayoutHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module RenderConstraintsHelper
2
3
  include Blacklight::RenderConstraintsHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SearchHistoryConstraintsHelper
2
3
  include Blacklight::SearchHistoryConstraintsHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SuggestHelper
2
3
  include Blacklight::SuggestHelperBehavior
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  # Pagination for facet values -- works by setting the limit to max
3
4
  # displayable. You have to ask Solr for limit+1, to get enough
@@ -28,7 +29,7 @@ module Blacklight
28
29
  # :sort => 'count' or 'index', solr tokens for facet value sorting, default 'count'.
29
30
  def initialize(all_facet_values, arguments = {})
30
31
  # to_s.to_i will conveniently default to 0 if nil
31
- @offset = arguments[:offset].to_s.to_i
32
+ @offset = arguments[:offset].to_s.to_i
32
33
  @limit = arguments[:limit]
33
34
  @sort = arguments[:sort]
34
35
  @prefix = arguments[:prefix]
@@ -50,7 +51,8 @@ module Blacklight
50
51
  end
51
52
 
52
53
  def current_page
53
- if limit == 0 #check for divide by zero
54
+ # A nil limit is unlimited, thus only one page.
55
+ if limit.nil? || limit == 0 #check for divide by zero
54
56
  1
55
57
  else
56
58
  @offset / limit + 1
@@ -81,6 +83,8 @@ module Blacklight
81
83
  # under facet.sort ), and your current request params.
82
84
  # Get back params suitable to passing to an ActionHelper method for
83
85
  # creating a url, to resort by that method.
86
+ # @param [String] sort_method
87
+ # @param [HashWithIndifferentAccess] params
84
88
  def params_for_resort_url(sort_method, params = {})
85
89
  # When resorting, we've got to reset the offset to start at beginning,
86
90
  # no way to make it make sense otherwise.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Solr
2
3
  # Pagination for facet values -- works by setting the limit to max
3
4
  # displayable. You have to ask Solr for limit+1, to get enough
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Bookmark < ActiveRecord::Base
2
3
 
3
4
  belongs_to :user, polymorphic: true
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Configurable
2
3
  extend ActiveSupport::Concern
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ##
2
3
  ##
3
4
  # = Introduction
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_model/conversion'
2
3
 
3
4
  module Blacklight::Document
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This module provides the cache key which can be used by rails
2
3
  # caching to determine when to expire a particular object's cache
3
4
  # See http://apidock.com/rails/ActiveRecord/Integration/cache_key
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'builder'
2
3
 
3
4
  # This module provide Dublin Core export based on the document's semantic values
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This module provides the body of an email export based on the document's semantic values
2
3
  module Blacklight::Document::Email
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # == Transformation conventions
2
3
  # The main use case for extensions is for transforming a Document to another
3
4
  # format. Either to another type of Ruby object, or to an exportable string in
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # = Document Extensions
2
3
  # An Blacklight::Document extension is simply a ruby module which is mixed
3
4
  # in to individual Document instances. The intended use case is for documents
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Document::SchemaOrg
2
3
 
3
4
  def itemtype
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Document
2
3
  module SemanticFields
3
4
  extend ActiveSupport::Concern
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This module provides the body of an email export based on the document's semantic values
2
3
  module Blacklight::Document::Sms
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rsolr'
2
3
  ##
3
4
  ##
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::Solr::Document::MoreLikeThis
2
3
  def more_like_this
3
4
  response.more_like(self).map { |doc| self.class.new(doc, response) }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module Suggest
3
4
  class Response
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::User
2
3
  # This gives us an is_blacklight_user method that can be included in
3
4
  # the containing applications models.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Only works for documents with a #to_marc right now.
2
3
  class RecordMailer < ActionMailer::Base
3
4
  def email_record(documents, details, url_gen_params)
data/app/models/search.rb CHANGED
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  class Search < ActiveRecord::Base
2
3
 
3
- belongs_to :user
4
+ belongs_to_arguments = { optional: true } if Rails.version >= '5.0.0'
5
+
6
+ belongs_to :user, belongs_to_arguments
4
7
 
5
8
  serialize :query_params
6
9