blacklight 5.19.2 → 6.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/.hound.yml +2 -0
  4. data/.jshintrc +67 -0
  5. data/.rubocop_hound.yml +4 -0
  6. data/.travis.yml +11 -8
  7. data/Gemfile +11 -21
  8. data/Rakefile +1 -0
  9. data/VERSION +1 -1
  10. data/app/assets/javascripts/blacklight/blacklight.js +1 -0
  11. data/app/assets/javascripts/blacklight/core.js +5 -19
  12. data/app/assets/javascripts/blacklight/facet_load.js +23 -0
  13. data/app/assets/stylesheets/blacklight/_balanced_list.scss +18 -0
  14. data/app/assets/stylesheets/blacklight/_blacklight_base.scss +5 -1
  15. data/app/assets/stylesheets/blacklight/_bookmark.scss +14 -6
  16. data/app/assets/stylesheets/blacklight/_constraints.scss +52 -0
  17. data/app/assets/stylesheets/blacklight/_controls.scss +61 -0
  18. data/app/assets/stylesheets/blacklight/_facets.scss +31 -4
  19. data/app/assets/stylesheets/blacklight/_header.scss +17 -3
  20. data/app/assets/stylesheets/blacklight/_pagination.scss +21 -0
  21. data/app/assets/stylesheets/blacklight/_search_results.scss +28 -0
  22. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -3
  23. data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
  24. data/app/controllers/concerns/blacklight/catalog.rb +3 -45
  25. data/app/controllers/concerns/blacklight/controller.rb +29 -18
  26. data/app/controllers/concerns/blacklight/default_component_configuration.rb +4 -3
  27. data/app/controllers/concerns/blacklight/facet.rb +1 -0
  28. data/app/controllers/concerns/blacklight/request_builders.rb +4 -107
  29. data/app/controllers/concerns/blacklight/search_fields.rb +1 -1
  30. data/app/controllers/concerns/blacklight/search_helper.rb +8 -160
  31. data/app/controllers/saved_searches_controller.rb +1 -1
  32. data/app/controllers/search_history_controller.rb +18 -1
  33. data/app/helpers/blacklight/blacklight_helper_behavior.rb +17 -85
  34. data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -48
  35. data/app/helpers/blacklight/component_helper_behavior.rb +9 -2
  36. data/app/helpers/blacklight/configuration_helper_behavior.rb +3 -43
  37. data/app/helpers/blacklight/facets_helper_behavior.rb +10 -6
  38. data/app/helpers/blacklight/layout_helper_behavior.rb +0 -8
  39. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -10
  40. data/app/helpers/blacklight/render_partials_helper.rb +1 -3
  41. data/app/helpers/blacklight/url_helper_behavior.rb +15 -187
  42. data/{lib → app/models}/blacklight/abstract_repository.rb +0 -15
  43. data/{lib → app/models}/blacklight/configuration.rb +22 -59
  44. data/app/models/blacklight/configuration/context.rb +47 -0
  45. data/{lib → app/models}/blacklight/configuration/facet_field.rb +1 -0
  46. data/{lib → app/models}/blacklight/configuration/field.rb +0 -0
  47. data/{lib → app/models}/blacklight/configuration/fields.rb +2 -6
  48. data/{lib → app/models}/blacklight/configuration/search_field.rb +0 -0
  49. data/{lib → app/models}/blacklight/configuration/solr_field.rb +0 -0
  50. data/{lib → app/models}/blacklight/configuration/sort_field.rb +0 -0
  51. data/{lib → app/models}/blacklight/configuration/tool_config.rb +0 -0
  52. data/app/models/blacklight/configuration/view_config.rb +9 -0
  53. data/app/models/blacklight/facet_paginator.rb +14 -28
  54. data/{lib → app/models}/blacklight/search_builder.rb +16 -24
  55. data/app/models/blacklight/solr/facet_paginator.rb +6 -2
  56. data/{lib → app/models}/blacklight/solr/repository.rb +0 -21
  57. data/{lib → app/models}/blacklight/solr/request.rb +0 -0
  58. data/{lib → app/models}/blacklight/solr/response.rb +9 -8
  59. data/{lib → app/models}/blacklight/solr/response/facets.rb +37 -29
  60. data/{lib → app/models}/blacklight/solr/response/group.rb +0 -0
  61. data/{lib → app/models}/blacklight/solr/response/group_response.rb +0 -0
  62. data/{lib → app/models}/blacklight/solr/response/more_like_this.rb +0 -0
  63. data/{lib → app/models}/blacklight/solr/response/pagination_methods.rb +0 -0
  64. data/{lib → app/models}/blacklight/solr/response/response.rb +0 -0
  65. data/{lib → app/models}/blacklight/solr/response/spelling.rb +2 -1
  66. data/{lib → app/models}/blacklight/solr/search_builder.rb +0 -0
  67. data/app/models/concerns/blacklight/document.rb +11 -27
  68. data/app/models/concerns/blacklight/document/active_model_shim.rb +8 -0
  69. data/app/models/concerns/blacklight/solr/document.rb +8 -3
  70. data/{lib → app/models/concerns}/blacklight/solr/search_builder_behavior.rb +21 -33
  71. data/app/models/concerns/blacklight/user.rb +0 -9
  72. data/app/models/record_mailer.rb +0 -1
  73. data/app/presenters/blacklight/document_presenter.rb +23 -13
  74. data/app/views/blacklight/nav/_saved_searches.html.erb +1 -1
  75. data/app/views/blacklight/nav/_search_history.html.erb +1 -1
  76. data/app/views/bookmarks/_tools.html.erb +1 -2
  77. data/app/views/bookmarks/index.html.erb +2 -2
  78. data/app/views/catalog/_document_default.atom.builder +4 -2
  79. data/app/views/catalog/_facet_index_navigation.html.erb +9 -0
  80. data/app/views/catalog/_facet_layout.html.erb +2 -3
  81. data/app/views/catalog/_facet_pagination.html.erb +19 -21
  82. data/app/views/catalog/_facets.html.erb +2 -3
  83. data/app/views/catalog/_home_text.html.erb +2 -3
  84. data/app/views/catalog/_index_header_default.html.erb +2 -2
  85. data/app/views/catalog/_per_page_widget.html.erb +1 -1
  86. data/app/views/catalog/_search_form.html.erb +21 -18
  87. data/app/views/catalog/_sort_widget.html.erb +1 -1
  88. data/app/views/catalog/_zero_results.html.erb +2 -2
  89. data/app/views/catalog/facet.html.erb +3 -0
  90. data/app/views/catalog/index.atom.builder +1 -1
  91. data/app/views/layouts/blacklight.html.erb +2 -2
  92. data/app/views/saved_searches/index.html.erb +6 -7
  93. data/app/views/search_history/index.html.erb +5 -5
  94. data/app/views/shared/_header_navbar.html.erb +2 -2
  95. data/blacklight.gemspec +5 -5
  96. data/config/locales/blacklight.de.yml +1 -4
  97. data/config/locales/blacklight.en.yml +2 -7
  98. data/config/locales/blacklight.es.yml +1 -4
  99. data/config/locales/blacklight.fr.yml +1 -4
  100. data/config/locales/blacklight.it.yml +1 -4
  101. data/config/locales/blacklight.pt-BR.yml +1 -4
  102. data/config/routes.rb +9 -0
  103. data/db/migrate/20140202020201_create_searches.rb +1 -1
  104. data/db/migrate/20140202020202_create_bookmarks.rb +1 -1
  105. data/lib/blacklight.rb +5 -82
  106. data/lib/blacklight/engine.rb +0 -5
  107. data/lib/blacklight/parameters.rb +13 -0
  108. data/lib/blacklight/path.rb +143 -0
  109. data/lib/blacklight/routes.rb +3 -134
  110. data/lib/blacklight/routes/exportable.rb +25 -0
  111. data/lib/blacklight/routes/searchable.rb +20 -0
  112. data/lib/blacklight/solr.rb +1 -9
  113. data/lib/blacklight/utils.rb +2 -44
  114. data/lib/generators/blacklight/controller_generator.rb +7 -4
  115. data/lib/generators/blacklight/install_generator.rb +16 -9
  116. data/lib/generators/blacklight/models_generator.rb +18 -0
  117. data/lib/generators/blacklight/templates/catalog_controller.rb +85 -91
  118. data/lib/generators/blacklight/test_support_generator.rb +22 -15
  119. data/solr/conf/_rest_managed.json +3 -0
  120. data/solr/conf/admin-extra.html +31 -0
  121. data/solr/conf/elevate.xml +36 -0
  122. data/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  123. data/solr/conf/protwords.txt +21 -0
  124. data/solr/conf/schema.xml +621 -0
  125. data/solr/conf/scripts.conf +24 -0
  126. data/solr/conf/solrconfig.xml +391 -0
  127. data/solr/conf/spellings.txt +2 -0
  128. data/solr/conf/stopwords.txt +58 -0
  129. data/solr/conf/stopwords_en.txt +58 -0
  130. data/solr/conf/synonyms.txt +31 -0
  131. data/solr/conf/xslt/example.xsl +132 -0
  132. data/solr/conf/xslt/example_atom.xsl +67 -0
  133. data/solr/conf/xslt/example_rss.xsl +66 -0
  134. data/solr/conf/xslt/luke.xsl +337 -0
  135. data/solr/sample_solr_documents.yml +1 -0
  136. data/spec/controllers/blacklight/base_spec.rb +17 -0
  137. data/spec/controllers/blacklight/search_helper_spec.rb +25 -297
  138. data/spec/controllers/catalog_controller_spec.rb +7 -6
  139. data/spec/controllers/saved_searches_controller_spec.rb +1 -0
  140. data/spec/controllers/search_history_controller_spec.rb +1 -0
  141. data/spec/features/alternate_controller_spec.rb +10 -10
  142. data/spec/features/bookmarks_spec.rb +8 -22
  143. data/spec/features/facets_spec.rb +27 -7
  144. data/spec/features/record_view_spec.rb +4 -13
  145. data/spec/features/search_formats_spec.rb +1 -26
  146. data/spec/features/sitelinks_search_box.rb +1 -1
  147. data/spec/helpers/blacklight_helper_spec.rb +8 -38
  148. data/spec/helpers/catalog_helper_spec.rb +0 -8
  149. data/spec/helpers/configuration_helper_spec.rb +0 -25
  150. data/spec/helpers/facets_helper_spec.rb +12 -11
  151. data/spec/helpers/hash_as_hidden_fields_spec.rb +7 -7
  152. data/spec/helpers/layout_helper_spec.rb +0 -7
  153. data/spec/helpers/render_constraints_helper_spec.rb +4 -2
  154. data/spec/helpers/url_helper_spec.rb +13 -254
  155. data/spec/lib/blacklight/parameters_spec.rb +22 -0
  156. data/spec/lib/blacklight/path_spec.rb +254 -0
  157. data/spec/lib/blacklight_spec.rb +6 -2
  158. data/spec/models/blacklight/configuration/context_spec.rb +33 -0
  159. data/spec/models/blacklight/document/active_model_shim_spec.rb +33 -0
  160. data/spec/models/blacklight/document_spec.rb +29 -1
  161. data/spec/models/blacklight/facet_paginator_spec.rb +14 -13
  162. data/spec/models/blacklight/search_builder_spec.rb +17 -23
  163. data/spec/models/blacklight/solr/facet_paginator_spec.rb +11 -1
  164. data/spec/models/blacklight/solr/response/facets_spec.rb +19 -25
  165. data/spec/models/blacklight/solr/response/group_response_spec.rb +5 -5
  166. data/spec/models/blacklight/solr/response_spec.rb +0 -11
  167. data/spec/models/blacklight/solr/search_builder_spec.rb +49 -57
  168. data/spec/presenters/document_presenter_spec.rb +15 -42
  169. data/spec/routing/catalog_routing_spec.rb +7 -11
  170. data/spec/spec_helper.rb +4 -42
  171. data/spec/support/controller_level_helpers.rb +17 -0
  172. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -2
  173. data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
  174. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +40 -0
  175. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -1
  176. data/spec/views/catalog/_facets.html.erb_spec.rb +2 -2
  177. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -1
  178. data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
  179. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
  180. data/tasks/blacklight.rake +25 -30
  181. metadata +93 -71
  182. data/app/assets/stylesheets/blacklight/_catalog.scss +0 -229
  183. data/app/controllers/concerns/blacklight/search_history.rb +0 -31
  184. data/app/views/catalog/_refworks_form.html.erb +0 -6
  185. data/lib/blacklight/configuration/view_config.rb +0 -71
  186. data/lib/blacklight/rails/routes.rb +0 -29
  187. data/lib/blacklight/solr_helper.rb +0 -9
  188. data/lib/generators/blacklight/templates/config/initializers/blacklight_initializer.rb +0 -9
  189. data/spec/helpers/component_helper_spec.rb +0 -19
  190. data/spec/lib/blacklight/routes_spec.rb +0 -25
  191. data/spec/lib/blacklight/solr_helper_spec.rb +0 -12
  192. data/spec/routing/routes_spec.rb +0 -20
  193. data/spec/views/catalog/_document_action.html.erb_spec.rb +0 -21
@@ -11,7 +11,7 @@
11
11
  # [:label]
12
12
  # "Title", # user-displayable label, optional, if not supplied :key.titlecase will be used
13
13
  # [:qt]
14
- # "search", # Solr qt param, request handler, usually can be left blank; defaults to blacklight_config[:default_solr_params][:qt] if not specified.
14
+ # "search", # Solr qt param, request handler, usually can be left blank; defaults to nil if not explicitly specified
15
15
  # [:solr_parameters]
16
16
  # {:qf => "something"} # optional hash of additional parameters to pass to solr for searches on this field.
17
17
  # [:solr_local_parameters]
@@ -46,59 +46,14 @@
46
46
 
47
47
  module Blacklight::SearchHelper
48
48
  extend ActiveSupport::Concern
49
- extend Deprecation
50
- self.deprecation_horizon = 'blacklight 6.0'
51
-
52
49
  include Blacklight::RequestBuilders
53
50
 
54
- ##
55
- # Execute a solr query
56
- # @see [Blacklight::SolrRepository#send_and_receive]
57
- # @return [Blacklight::Solr::Response] the solr response object
58
- def find *args
59
- request_params = args.extract_options!
60
- path = args.first || blacklight_config.solr_path
61
-
62
- request_params[:qt] ||= blacklight_config.qt
63
-
64
- repository.send_and_receive path, request_params
65
- end
66
- deprecation_deprecate :find
67
-
68
- # returns a params hash for finding a single solr document (CatalogController #show action)
69
- def solr_doc_params(id=nil)
70
- default_solr_doc_params(id)
71
- end
72
- deprecation_deprecate :solr_doc_params
73
-
74
- # a solr query method
75
- # given a user query, return a solr response containing both result docs and facets
76
- # - mixes in the Blacklight::Solr::SpellingSuggestions module
77
- # - the response will have a spelling_suggestions method
78
- # Returns a two-element array (aka duple) with first the solr response object,
79
- # and second an array of SolrDocuments representing the response.docs
80
- def get_search_results(user_params = params || {}, extra_controller_params = {})
81
- query = search_builder.with(user_params).merge(extra_controller_params)
82
- response = repository.search(query)
83
-
84
- case
85
- when (response.grouped? && grouped_key_for_results)
86
- [response.group(grouped_key_for_results), []]
87
- when (response.grouped? && response.grouped.length == 1)
88
- [response.grouped.first, []]
89
- else
90
- [response, response.documents]
91
- end
92
- end
93
- deprecation_deprecate get_search_results: :search_results
94
-
95
51
  # a solr query method
96
52
  # @param [Hash,HashWithIndifferentAccess] user_params ({}) the user provided parameters (e.g. query, facets, sort, etc)
97
- # @param [List<Symbol] processor_chain a list of filter methods to run
98
53
  # @yield [search_builder] optional block yields configured SearchBuilder, caller can modify or create new SearchBuilder to be used. Block should return SearchBuilder to be used.
99
54
  # @return [Blacklight::Solr::Response] the solr response object
100
- def search_results(user_params, search_params_logic)
101
- builder = search_builder(search_params_logic).with(user_params)
55
+ def search_results(user_params)
56
+ builder = search_builder.with(user_params)
102
57
  builder.page(user_params[:page]) if user_params[:page]
103
58
  builder.rows(user_params[:per_page] || user_params[:rows]) if user_params[:per_page] or user_params[:rows]
104
59
 
@@ -118,16 +73,6 @@ module Blacklight::SearchHelper
118
73
  end
119
74
  end
120
75
 
121
- # a solr query method
122
- # @param [Hash,HashWithIndifferentAccess] user_params ({}) the user provided parameters (e.g. query, facets, sort, etc)
123
- # @param [Hash,HashWithIndifferentAccess] extra_controller_params ({}) extra parameters to add to the search
124
- # @return [Blacklight::Solr::Response] the solr response object
125
- def query_solr(user_params = params || {}, extra_controller_params = {})
126
- query = search_builder.with(user_params).merge(extra_controller_params)
127
- repository.search(query)
128
- end
129
- deprecation_deprecate :query_solr
130
-
131
76
  # retrieve a document, given the doc id
132
77
  # @return [Blacklight::Solr::Response, Blacklight::SolrDocument] the solr response object and the first document
133
78
  def fetch(id=nil, extra_controller_params={})
@@ -142,23 +87,6 @@ module Blacklight::SearchHelper
142
87
  end
143
88
  end
144
89
 
145
- alias_method :get_solr_response_for_doc_id, :fetch
146
- deprecation_deprecate get_solr_response_for_doc_id: "use fetch(id) instead"
147
-
148
- # given a field name and array of values, get the matching SOLR documents
149
- # @return [Blacklight::Solr::Response, Array<Blacklight::SolrDocument>] the solr response object and a list of solr documents
150
- def get_solr_response_for_field_values(field, values, extra_controller_params = {})
151
- query = Deprecation.silence(Blacklight::RequestBuilders) do
152
- search_builder.with(params).merge(extra_controller_params).merge(solr_documents_by_field_values_params(field, values))
153
- end
154
-
155
- solr_response = repository.search(query)
156
-
157
-
158
- [solr_response, solr_response.documents]
159
- end
160
- deprecation_deprecate :get_solr_response_for_field_values
161
-
162
90
  ##
163
91
  # Get the solr response when retrieving only a single facet field
164
92
  # @return [Blacklight::Solr::Response] the solr response
@@ -167,40 +95,6 @@ module Blacklight::SearchHelper
167
95
  repository.search(query.merge(extra_controller_params))
168
96
  end
169
97
 
170
- # a solr query method
171
- # used to paginate through a single facet field's values
172
- # /catalog/facet/language_facet
173
- def get_facet_pagination(facet_field, user_params=params || {}, extra_controller_params={})
174
- # Make the solr call
175
- response = get_facet_field_response(facet_field, user_params, extra_controller_params)
176
-
177
- limit = response.params[:"f.#{facet_field}.facet.limit"].to_s.to_i - 1
178
-
179
- # Actually create the paginator!
180
- # NOTE: The sniffing of the proper sort from the solr response is not
181
- # currently tested for, tricky to figure out how to test, since the
182
- # default setup we test against doesn't use this feature.
183
- Blacklight::Solr::FacetPaginator.new(response.aggregations[facet_field].items,
184
- :offset => response.params[:"f.#{facet_field}.facet.offset"],
185
- :limit => limit,
186
- :sort => response.params[:"f.#{facet_field}.facet.sort"] || response.params["facet.sort"]
187
- )
188
- end
189
- deprecation_deprecate :get_facet_pagination
190
-
191
- # a solr query method
192
- # this is used when selecting a search result: we have a query and a
193
- # position in the search results and possibly some facets
194
- # Pass in an index where 1 is the first document in the list, and
195
- # the Blacklight app-level request params that define the search.
196
- # @return [Blacklight::SolrDocument, nil] the found document or nil if not found
197
- def get_single_doc_via_search(index, request_params)
198
- query = search_builder.with(request_params).start(index - 1).rows(1).merge(fl: "*")
199
- response = repository.search(query)
200
- response.documents.first
201
- end
202
- deprecation_deprecate :get_single_doc_via_search
203
-
204
98
  # Get the previous and next document from a search result
205
99
  # @return [Blacklight::Solr::Response, Array<Blacklight::SolrDocument>] the solr response and a list of the first and last document
206
100
  def get_previous_and_next_documents_for_search(index, request_params, extra_controller_params={})
@@ -247,32 +141,16 @@ module Blacklight::SearchHelper
247
141
  @repository ||= repository_class.new(blacklight_config)
248
142
  end
249
143
 
250
- def solr_repository
251
- repository
252
- end
253
- deprecation_deprecate solr_repository: :repository
254
-
255
- def blacklight_solr
256
- repository.connection
257
- end
258
- deprecation_deprecate blacklight_solr: "use repository.connection instead"
259
-
260
144
  private
261
145
 
262
146
  ##
263
147
  # Retrieve a set of documents by id
264
- # @overload fetch_many(ids, extra_controller_params)
265
- # @overload fetch_many(ids, user_params, extra_controller_params)
266
- def fetch_many(ids=[], *args)
267
- if args.length == 1
268
- Deprecation.warn(Blacklight::SearchHelper, "fetch_many with 2 arguments is deprecated")
269
- user_params = params
270
- extra_controller_params = args.first || {}
271
- else
272
- user_params, extra_controller_params = args
273
- user_params ||= params
274
- extra_controller_params ||= {}
275
- end
148
+ # @param [Array] ids
149
+ # @param [HashWithIndifferentAccess] user_params
150
+ # @param [HashWithIndifferentAccess] extra_controller_params
151
+ def fetch_many(ids, user_params, extra_controller_params)
152
+ user_params ||= params
153
+ extra_controller_params ||= {}
276
154
 
277
155
  query = search_builder.
278
156
  with(user_params).
@@ -284,38 +162,8 @@ module Blacklight::SearchHelper
284
162
  [solr_response, solr_response.documents]
285
163
  end
286
164
 
287
- alias_method :get_solr_response_for_document_ids, :fetch_many
288
- deprecation_deprecate get_solr_response_for_document_ids: "use fetch(ids) instead"
289
-
290
165
  def fetch_one(id, extra_controller_params)
291
- old_solr_doc_params = Deprecation.silence(Blacklight::SearchHelper) do
292
- solr_doc_params(id)
293
- end
294
-
295
- if default_solr_doc_params(id) != old_solr_doc_params
296
- Deprecation.warn Blacklight::SearchHelper, "The #solr_doc_params method is deprecated. Instead, you should provide a custom SolrRepository implementation for the additional behavior you're offering. The current behavior will be removed in Blacklight 6.0"
297
- extra_controller_params = extra_controller_params.merge(old_solr_doc_params)
298
- end
299
-
300
166
  solr_response = repository.find id, extra_controller_params
301
167
  [solr_response, solr_response.documents.first]
302
168
  end
303
-
304
- ##
305
- # @deprecated
306
- def default_solr_doc_params(id=nil)
307
- id ||= params[:id]
308
-
309
- # add our document id to the document_unique_id_param query parameter
310
- p = blacklight_config.default_document_solr_params.merge({
311
- # this assumes the request handler will map the unique id param
312
- # to the unique key field using either solr local params, the
313
- # real-time get handler, etc.
314
- blacklight_config.document_unique_id_param => id
315
- })
316
-
317
- p[:qt] ||= blacklight_config.document_solr_request_handler
318
-
319
- p
320
- end
321
169
  end
@@ -42,7 +42,7 @@ class SavedSearchesController < ApplicationController
42
42
  else
43
43
  flash[:error] = I18n.t('blacklight.saved_searches.clear.failure')
44
44
  end
45
- redirect_to :action => "index"
45
+ redirect_to blacklight.saved_searches_url
46
46
  end
47
47
 
48
48
 
@@ -1,4 +1,21 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  class SearchHistoryController < ApplicationController
3
- include Blacklight::SearchHistory
3
+ include Blacklight::Configurable
4
+
5
+ copy_blacklight_config_from(CatalogController)
6
+
7
+ def index
8
+ @searches = searches_from_history
9
+ end
10
+
11
+
12
+ #TODO we may want to remove unsaved (those without user_id) items from the database when removed from history
13
+ def clear
14
+ if session[:history].clear
15
+ flash[:notice] = I18n.t('blacklight.search_history.clear.success')
16
+ else
17
+ flash[:error] = I18n.t('blacklight.search_history.clear.failure')
18
+ end
19
+ redirect_to :back
20
+ end
4
21
  end
@@ -10,13 +10,12 @@ module Blacklight::BlacklightHelperBehavior
10
10
  include RenderConstraintsHelper
11
11
  include RenderPartialsHelper
12
12
  include FacetsHelper
13
- extend Deprecation
14
13
 
15
14
  ##
16
15
  # Get the name of this application, from either:
17
16
  # - the Rails configuration
18
17
  # - an i18n string (key: blacklight.application_name; preferred)
19
- #
18
+ #
20
19
  # @return [String] the application name
21
20
  def application_name
22
21
  return Rails.application.config.application_name if Rails.application.config.respond_to? :application_name
@@ -42,14 +41,14 @@ module Blacklight::BlacklightHelperBehavior
42
41
  # @params [Hash] options
43
42
  # @option options [Boolean] :unique ensures only one link is output for every
44
43
  # content type, e.g. as required by atom
45
- # @option options [Array<String>] :exclude array of format shortnames to not include in the output
44
+ # @option options [Array<String>] :exclude array of format shortnames to not include in the output
46
45
  def render_link_rel_alternates(document=@document, options = {})
47
46
  return if document.nil?
48
47
  presenter(document).link_rel_alternates(options)
49
48
  end
50
49
 
51
50
  ##
52
- # Render OpenSearch headers for this search
51
+ # Render OpenSearch headers for this search
53
52
  # @return [String]
54
53
  def render_opensearch_response_metadata
55
54
  render :partial => 'catalog/opensearch_response_metadata'
@@ -79,7 +78,7 @@ module Blacklight::BlacklightHelperBehavior
79
78
 
80
79
  ##
81
80
  # Determine whether to render a given field in the index view.
82
- #
81
+ #
83
82
  # @param [SolrDocument] document
84
83
  # @param [Blacklight::Solr::Configuration::Field] field_config
85
84
  # @return [Boolean]
@@ -96,7 +95,7 @@ module Blacklight::BlacklightHelperBehavior
96
95
  def should_render_show_field? document, field_config
97
96
  should_render_field?(field_config, document) && document_has_value?(document, field_config)
98
97
  end
99
-
98
+
100
99
  ##
101
100
  # Check if a document has (or, might have, in the case of accessor methods) a value for
102
101
  # the given solr field
@@ -130,7 +129,7 @@ module Blacklight::BlacklightHelperBehavior
130
129
  # may drive the value of the field
131
130
  # @param [SolrDocument] doc
132
131
  # @param [Hash] opts
133
- # @options opts [String] :field
132
+ # @options opts [String] :field
134
133
  def render_index_field_label *args
135
134
  options = args.extract_options!
136
135
  document = args.first
@@ -153,7 +152,7 @@ module Blacklight::BlacklightHelperBehavior
153
152
  # may drive the value of the field
154
153
  # @param [SolrDocument] doc
155
154
  # @param [Hash] opts
156
- # @options opts [String] :field
155
+ # @options opts [String] :field
157
156
  # @options opts [String] :value
158
157
  # @overload render_index_field_value(document, field, options)
159
158
  # Allow an extention point where information in the document
@@ -182,7 +181,7 @@ module Blacklight::BlacklightHelperBehavior
182
181
  # may drive the value of the field
183
182
  # @param [SolrDocument] doc
184
183
  # @param [Hash] opts
185
- # @options opts [String] :field
184
+ # @options opts [String] :field
186
185
  def render_document_show_field_label *args
187
186
  options = args.extract_options!
188
187
  document = args.first
@@ -206,7 +205,7 @@ module Blacklight::BlacklightHelperBehavior
206
205
  # may drive the value of the field
207
206
  # @param [SolrDocument] doc
208
207
  # @param [Hash] opts
209
- # @options opts [String] :field
208
+ # @options opts [String] :field
210
209
  # @options opts [String] :value
211
210
  # @overload render_document_show_field_value(document, field, options)
212
211
  # Allow an extention point where information in the document
@@ -249,8 +248,6 @@ module Blacklight::BlacklightHelperBehavior
249
248
 
250
249
  ##
251
250
  # Render the document "heading" (title) in a content tag
252
- # @overload render_document_heading(tag)
253
- # @params [Symbol] tag
254
251
  # @overload render_document_heading(document, options)
255
252
  # @params [SolrDocument] document
256
253
  # @params [Hash] options
@@ -260,17 +257,9 @@ module Blacklight::BlacklightHelperBehavior
260
257
  # @options options [Symbol] :tag
261
258
  def render_document_heading(*args)
262
259
  options = args.extract_options!
263
-
264
- tag_or_document = args.first
265
-
266
- if tag_or_document.is_a? String or tag_or_document.is_a? Symbol
267
- Deprecation.warn(Blacklight::BlacklightHelperBehavior, "#render_document_heading with a tag argument is deprecated; pass e.g. `tag: :h4` instead")
268
- tag = tag_or_document
269
- document = @document
270
- else
271
- tag = options.fetch(:tag, :h4)
272
- document = tag_or_document || @document
273
- end
260
+ document = args.first
261
+ tag = options.fetch(:tag, :h4)
262
+ document = document || @document
274
263
 
275
264
  content_tag(tag, presenter(document).document_heading, itemprop: "name")
276
265
  end
@@ -284,7 +273,7 @@ module Blacklight::BlacklightHelperBehavior
284
273
  # Rendering:
285
274
  # - helper_method
286
275
  # - link_to_search
287
- # TODO : maybe this should be merged with render_field_value, and the ugly signature
276
+ # TODO : maybe this should be merged with render_field_value, and the ugly signature
288
277
  # simplified by pushing some of this logic into the "model"
289
278
  # @param [SolrDocument] document
290
279
  # @param [String] field name
@@ -294,36 +283,9 @@ module Blacklight::BlacklightHelperBehavior
294
283
  presenter(document).get_field_values field, field_config, options
295
284
  end
296
285
 
297
- ##
298
- # Render a value (or array of values) from a field
299
- #
300
- # @deprecated Use DocumentPresenter instead
301
- # @param [String] value or list of values to display
302
- # @param [Blacklight::Solr::Configuration::Field] solr field configuration
303
- # @return [String]
304
- def render_field_value value=nil, field_config=nil
305
- safe_values = Array(value).collect { |x| x.respond_to?(:force_encoding) ? x.force_encoding("UTF-8") : x }
306
-
307
- if field_config and field_config.itemprop
308
- safe_values = safe_values.map { |x| content_tag :span, x, :itemprop => field_config.itemprop }
309
- end
310
-
311
- safe_join(safe_values, (field_config.separator if field_config) || field_value_separator)
312
- end
313
- deprecation_deprecate render_field_value: "use DocumentPresenter.render_field_value instead"
314
-
315
- ##
316
- # Default separator to use in #render_field_value
317
- #
318
- # @return [String]
319
- def field_value_separator
320
- ', '
321
- end
322
- deprecation_deprecate field_value_separator: "use DocumentPresenter.field_value_separator instead"
323
-
324
286
  ##
325
287
  # Get the current "view type" (and ensure it is a valid type)
326
- #
288
+ #
327
289
  # @param [Hash] the query parameters to check
328
290
  # @return [Symbol]
329
291
  def document_index_view_type query_params=params
@@ -336,24 +298,6 @@ module Blacklight::BlacklightHelperBehavior
336
298
  end
337
299
  end
338
300
 
339
- ##
340
- # Render the document index heading
341
- #
342
- # @param [SolrDocument] doc
343
- # @param [Hash] opts (deprecated)
344
- # @option opts [Symbol] :label Render the given field from the document
345
- # @option opts [Proc] :label Evaluate the given proc
346
- # @option opts [String] :label Render the given string
347
- # @param [Symbol, Proc, String] field Render the given field or evaluate the proc or render the given string
348
- def render_document_index_label doc, field, opts = {}
349
- if field.is_a? Hash
350
- Deprecation.warn self, "Calling render_document_index_label with a hash is deprecated"
351
- field = field[:label]
352
- end
353
- presenter(doc).render_document_index_label field, opts
354
- end
355
- deprecation_deprecate render_document_index_label: "use presenter(doc).render_document_index_label instead"
356
-
357
301
  ##
358
302
  # Render a partial of an arbitrary format inside a
359
303
  # template of a different format. (e.g. render an HTML
@@ -372,24 +316,12 @@ module Blacklight::BlacklightHelperBehavior
372
316
  end
373
317
 
374
318
  ##
375
- # Should we render a grouped response (because the response
376
- # contains a grouped response instead of the normal response)
319
+ # Should we render a grouped response (because the response
320
+ # contains a grouped response instead of the normal response)
377
321
  def render_grouped_response? response = @response
378
322
  return response.grouped?
379
323
  end
380
324
 
381
- ##
382
- # Determine whether to render the bookmarks control
383
- def render_bookmarks_control?
384
- has_user_authentication_provider? and current_or_guest_user.present?
385
- end
386
-
387
- ##
388
- # Determine whether to render the saved searches link
389
- def render_saved_searches?
390
- has_user_authentication_provider? and current_user
391
- end
392
-
393
325
  ##
394
326
  # Returns a document presenter for the given document
395
327
  def presenter(document)
@@ -401,7 +333,7 @@ module Blacklight::BlacklightHelperBehavior
401
333
  def presenter_class
402
334
  blacklight_config.document_presenter_class
403
335
  end
404
-
336
+
405
337
  ##
406
338
  # Open Search discovery tag for HTML <head> links
407
339
  def opensearch_description_tag title, href