blacklight 6.0.0.pre3 → 6.0.0.pre4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/VERSION +1 -1
  4. data/app/controllers/bookmarks_controller.rb +0 -1
  5. data/app/controllers/catalog_controller.rb +0 -1
  6. data/app/controllers/concerns/blacklight/base.rb +0 -1
  7. data/app/controllers/concerns/blacklight/bookmarks.rb +0 -1
  8. data/app/controllers/concerns/blacklight/catalog.rb +6 -38
  9. data/app/controllers/concerns/blacklight/controller.rb +0 -2
  10. data/app/controllers/concerns/blacklight/search_fields.rb +0 -1
  11. data/app/controllers/concerns/blacklight/search_helper.rb +0 -5
  12. data/app/{models → controllers}/concerns/blacklight/token_based_user.rb +6 -10
  13. data/app/controllers/saved_searches_controller.rb +0 -1
  14. data/app/controllers/search_history_controller.rb +0 -1
  15. data/app/helpers/blacklight/blacklight_helper_behavior.rb +0 -4
  16. data/app/helpers/blacklight/catalog_helper_behavior.rb +3 -2
  17. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +0 -1
  18. data/app/helpers/blacklight/layout_helper_behavior.rb +8 -0
  19. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -1
  20. data/app/helpers/blacklight/render_partials_helper.rb +1 -6
  21. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +0 -1
  22. data/app/helpers/blacklight/url_helper_behavior.rb +1 -6
  23. data/app/models/blacklight/solr/facet_paginator.rb +0 -1
  24. data/app/models/bookmark.rb +0 -1
  25. data/app/models/concerns/blacklight/configurable.rb +0 -1
  26. data/app/models/concerns/blacklight/document/cache_key.rb +0 -1
  27. data/app/models/concerns/blacklight/document/email.rb +0 -1
  28. data/app/models/concerns/blacklight/document/sms.rb +0 -1
  29. data/app/models/concerns/blacklight/solr/document.rb +0 -7
  30. data/app/models/concerns/blacklight/user.rb +0 -1
  31. data/app/models/record_mailer.rb +0 -1
  32. data/app/models/search.rb +0 -6
  33. data/app/presenters/blacklight/document_presenter.rb +3 -17
  34. data/app/presenters/blacklight/json_presenter.rb +41 -0
  35. data/app/views/catalog/_document.html.erb +1 -1
  36. data/app/views/catalog/_document_default.atom.builder +2 -4
  37. data/app/views/catalog/facet.json.jbuilder +3 -0
  38. data/app/views/catalog/index.atom.builder +1 -1
  39. data/app/views/catalog/index.json.jbuilder +6 -0
  40. data/app/views/layouts/blacklight.html.erb +1 -1
  41. data/app/views/shared/_header_navbar.html.erb +2 -2
  42. data/blacklight.gemspec +9 -4
  43. data/db/migrate/20140202020201_create_searches.rb +1 -2
  44. data/db/migrate/20140202020202_create_bookmarks.rb +1 -2
  45. data/db/migrate/20140320000000_add_polymorphic_type_to_bookmarks.rb +0 -1
  46. data/lib/blacklight.rb +0 -10
  47. data/lib/blacklight/configuration.rb +0 -1
  48. data/lib/blacklight/engine.rb +0 -8
  49. data/lib/blacklight/exceptions.rb +0 -1
  50. data/lib/blacklight/routes.rb +0 -1
  51. data/lib/blacklight/version.rb +0 -1
  52. data/lib/generators/blacklight/assets_generator.rb +0 -1
  53. data/lib/generators/blacklight/install_generator.rb +8 -14
  54. data/lib/generators/blacklight/solr4_generator.rb +27 -0
  55. data/lib/generators/blacklight/solr5_generator.rb +21 -0
  56. data/lib/generators/blacklight/templates/alternate_controller.rb +0 -1
  57. data/lib/generators/blacklight/templates/catalog_controller.rb +3 -4
  58. data/lib/generators/blacklight/templates/solr_document.rb +0 -1
  59. data/lib/generators/blacklight/test_support_generator.rb +0 -1
  60. data/lib/railties/blacklight.rake +0 -7
  61. data/provision.sh +11 -1
  62. data/spec/controllers/blacklight/search_helper_spec.rb +0 -1
  63. data/spec/controllers/bookmarks_controller_spec.rb +26 -1
  64. data/spec/controllers/catalog_controller_spec.rb +8 -35
  65. data/spec/features/facets_spec.rb +0 -1
  66. data/spec/features/record_view_spec.rb +0 -1
  67. data/spec/features/search_context_spec.rb +0 -2
  68. data/spec/features/search_formats_spec.rb +0 -2
  69. data/spec/features/search_pagination_spec.rb +0 -2
  70. data/spec/features/search_results_spec.rb +0 -2
  71. data/spec/features/search_spec.rb +0 -2
  72. data/spec/helpers/blacklight_helper_spec.rb +3 -12
  73. data/spec/helpers/catalog_helper_spec.rb +8 -0
  74. data/spec/helpers/layout_helper_spec.rb +7 -0
  75. data/spec/helpers/url_helper_spec.rb +0 -7
  76. data/spec/lib/tasks/blacklight_task_spec.rb +0 -1
  77. data/spec/models/record_mailer_spec.rb +1 -3
  78. data/spec/models/search_spec.rb +1 -2
  79. data/spec/models/solr_document_spec.rb +22 -24
  80. data/spec/presenters/document_presenter_spec.rb +28 -6
  81. data/spec/spec_helper.rb +0 -1
  82. data/spec/views/catalog/_document.html.erb_spec.rb +20 -3
  83. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
  84. data/spec/views/catalog/facet.json.jbuilder_spec.rb +9 -0
  85. data/spec/views/catalog/index.json.jbuilder_spec.rb +30 -0
  86. metadata +15 -15
  87. data/app/models/concerns/blacklight/solr/document/dublin_core.rb +0 -7
  88. data/app/models/concerns/blacklight/solr/document/email.rb +0 -7
  89. data/app/models/concerns/blacklight/solr/document/export.rb +0 -7
  90. data/app/models/concerns/blacklight/solr/document/extensions.rb +0 -8
  91. data/app/models/concerns/blacklight/solr/document/schema_org.rb +0 -7
  92. data/app/models/concerns/blacklight/solr/document/sms.rb +0 -7
  93. data/app/views/catalog/email_sent.html.erb +0 -2
  94. data/app/views/catalog/sms_sent.html.erb +0 -2
  95. data/lib/blacklight/configuration/solr_field.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ff860357fb3d2118c70ca7e8f1c4dc36bc496f4
4
- data.tar.gz: 645e95ebad1081be628cd2c1f24f302b711fc2b1
3
+ metadata.gz: de33efb7e9513e4348986f8e64b4f2cfec107802
4
+ data.tar.gz: 74ac4159ee1072f93f3f54b8115e14d501d68773
5
5
  SHA512:
6
- metadata.gz: c48d40732144a83f9708e0b12a1f6b29a603e667df94e2f7c79aeef0e86a58444241d2a63c32cd68e3835cad52716d7bf53f0a22a115416c0bb716153b1a4a3c
7
- data.tar.gz: 0fb793e45aa4bb028cecc280a37f3c8a602b9d54d6fc70ebf52376edb16653bfe1492ec7f11703e4ee141efd9d4445e13dab39d2ec79220089a83cb2dac740f8
6
+ metadata.gz: f23fb77ae90ed8cbb00a6461643a4e3da47771ce25d02a717944722fe239b8d045d73206305e499d2b282f7cd6913eff624707c91adfba2721f83cd6ac37d1f9
7
+ data.tar.gz: 4c752134df04876f6bcc9831fe03071df4a7976657a5a15780226a02bc76d1b4ca5d77ab59d5b0f6c5e9cc67f8475ff0478a4f45643fd70312e414e51ff480b8
data/README.md CHANGED
@@ -34,11 +34,11 @@ rails generate blacklight:install
34
34
 
35
35
  ## Dependencies
36
36
 
37
- * ruby v1.9.3 or higher
37
+ * ruby v2.0 or higher
38
38
  * git
39
39
  * access to a command prompt on the machine to install
40
40
 
41
- In addition, you must have the Bundler and Rails 4.0 gems installed. Other gem dependencies are defined in the blacklight.gemspec file and will be automatically loaded by Bundler.
41
+ In addition, you must have the Bundler and Rails 4.1 (or greater) gems installed. Other gem dependencies are defined in the blacklight.gemspec file and will be automatically loaded by Bundler.
42
42
 
43
43
  ## Configuring Apache Solr
44
44
  You'll also want some information about how Blacklight expects [Apache Solr](http://lucene.apache.org/solr ) to run, which you can find in [README_SOLR](https://github.com/projectblacklight/blacklight/wiki/README_SOLR)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.0.0.pre3
1
+ 6.0.0.pre4
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class BookmarksController < CatalogController
3
2
 
4
3
  include Blacklight::Bookmarks
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class CatalogController < ApplicationController
3
2
 
4
3
  include Blacklight::Catalog
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight::Base
3
2
  extend ActiveSupport::Concern
4
3
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # note that while this is mostly restful routing, the #update and #destroy actions
3
2
  # take the Solr document ID as the :id, NOT the id of the actual Bookmark action.
4
3
  module Blacklight::Bookmarks
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight::Catalog
3
2
  extend ActiveSupport::Concern
4
3
 
@@ -13,7 +12,7 @@ module Blacklight::Catalog
13
12
 
14
13
  helper Blacklight::Facet
15
14
 
16
- # When an action raises Blacklight::Exceptions::RecordNotFound, handle
15
+ # When an action raises Blacklight::Exceptions::RecordNotFound, handle
17
16
  # the exception appropriately.
18
17
  rescue_from Blacklight::Exceptions::RecordNotFound, with: :invalid_document_id_error
19
18
 
@@ -29,9 +28,11 @@ module Blacklight::Catalog
29
28
  format.rss { render :layout => false }
30
29
  format.atom { render :layout => false }
31
30
  format.json do
32
- render json: render_search_results_as_json
31
+ @presenter = Blacklight::JsonPresenter.new(@response,
32
+ @document_list,
33
+ facets_from_request,
34
+ blacklight_config)
33
35
  end
34
-
35
36
  additional_response_formats(format)
36
37
  document_export_formats(format)
37
38
  end
@@ -76,7 +77,7 @@ module Blacklight::Catalog
76
77
  respond_to do |format|
77
78
  # Draw the facet selector for users who have javascript disabled:
78
79
  format.html
79
- format.json { render json: render_facet_list_as_json }
80
+ format.json
80
81
 
81
82
  # Draw the partial for the "more" facet modal window:
82
83
  format.js { render :layout => false }
@@ -184,26 +185,6 @@ module Blacklight::Catalog
184
185
  render text: @response.documents.map { |x| x.export_as(format_name) if x.exports_as? format_name }.compact.join("\n"), layout: false
185
186
  end
186
187
 
187
- # override this method to change the JSON response from #index
188
- def render_search_results_as_json
189
- {response: {docs: @document_list, facets: search_facets_as_json, pages: pagination_info(@response)}}
190
- end
191
-
192
- def search_facets_as_json
193
- facets_from_request.as_json.each do |f|
194
- f.delete "options"
195
- f["label"] = facet_configuration_for_field(f["name"]).label
196
- f["items"] = f["items"].as_json.each do |i|
197
- i['label'] ||= i['value']
198
- end
199
- end
200
- end
201
-
202
- # override this method to change the JSON response from #facet
203
- def render_facet_list_as_json
204
- {response: {facets: @pagination }}
205
- end
206
-
207
188
  # Overrides the Blacklight::Controller provided #search_action_url.
208
189
  # By default, any search action from a Blacklight::Catalog controller
209
190
  # should use the current controller when constructing the route.
@@ -211,19 +192,6 @@ module Blacklight::Catalog
211
192
  url_for(options.merge(:action => 'index'))
212
193
  end
213
194
 
214
- # extract the pagination info from the response object
215
- def pagination_info response
216
- h = {}
217
-
218
- [:current_page, :next_page, :prev_page, :total_pages,
219
- :limit_value, :offset_value, :total_count,
220
- :first_page?, :last_page?].each do |k|
221
- h[k] = response.send(k)
222
- end
223
-
224
- h
225
- end
226
-
227
195
  # Email Action (this will render the appropriate view on GET requests and process the form and send the email on POST requests)
228
196
  def email_action documents
229
197
  mail = RecordMailer.email_record(documents, {:to => params[:to], :message => params[:message]}, url_options)
@@ -1,5 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
- #
3
1
  # Filters added to this controller apply to all controllers in the hosting application
4
2
  # as this module is mixed-in to the application controller in the hosting app on installation.
5
3
  module Blacklight::Controller
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  ##
3
2
  # Module to deal with accessing (and setting some defaults) in an array of
4
3
  # hashes that describe Blacklight search fields. Requires the base class this
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # SearchHelper is a controller layer mixin. It is in the controller scope: request params, session etc.
3
2
  #
4
3
  # NOTE: Be careful when creating variables here as they may be overriding something that already exists.
@@ -79,10 +78,6 @@ module Blacklight::SearchHelper
79
78
  if id.is_a? Array
80
79
  fetch_many(id, params, extra_controller_params)
81
80
  else
82
- if id.nil?
83
- Deprecation.warn Blacklight::SearchHelper, "Calling #fetch without an explicit id argument is deprecated and will be removed in Blacklight 6.0"
84
- id ||= params[:id]
85
- end
86
81
  fetch_one(id, extra_controller_params)
87
82
  end
88
83
  end
@@ -36,21 +36,17 @@ module Blacklight::TokenBasedUser
36
36
 
37
37
  # Used for #export action with encrypted user_id, available
38
38
  # as a helper method for views.
39
- def encrypt_user_id(user_id)
40
- message_encryptor.encrypt_and_sign([user_id, Time.zone.now])
39
+ def encrypt_user_id(user_id, current_time = nil)
40
+ current_time ||= Time.zone.now
41
+ message_encryptor.encrypt_and_sign([user_id, current_time])
41
42
  end
42
43
 
43
- ##
44
- # This method provides Rails 3 compatibility to our message encryptor.
45
- # When we drop support for Rails 3, we can just use the AS::KeyGenerator
46
- # directly instead of this helper.
47
- def export_secret_token salt
48
- OpenSSL::PKCS5.pbkdf2_hmac_sha1(Blacklight.secret_key, salt, 1000, 64)
44
+ def export_secret_token
45
+ ActiveSupport::KeyGenerator.new(Rails.application.secrets.secret_key_base).generate_key('encrypted user session key')
49
46
  end
50
47
 
51
48
  def message_encryptor
52
- derived_secret = export_secret_token("encrypted user session key")
53
- ActiveSupport::MessageEncryptor.new(derived_secret)
49
+ ActiveSupport::MessageEncryptor.new(export_secret_token)
54
50
  end
55
51
 
56
52
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class SavedSearchesController < ApplicationController
3
2
  include Blacklight::Configurable
4
3
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class SearchHistoryController < ApplicationController
3
2
  include Blacklight::Configurable
4
3
 
@@ -1,8 +1,4 @@
1
- # -*- encoding : utf-8 -*-
2
- # -*- coding: utf-8 -*-
3
- #
4
1
  # Methods added to this helper will be available to all templates in the hosting application
5
- #
6
2
  module Blacklight::BlacklightHelperBehavior
7
3
  include BlacklightUrlHelper
8
4
  include BlacklightConfigurationHelper
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight::CatalogHelperBehavior
3
2
 
4
3
  ##
@@ -179,7 +178,9 @@ module Blacklight::CatalogHelperBehavior
179
178
  value = if blacklight_config.view_config(document_index_view_type).thumbnail_method
180
179
  send(blacklight_config.view_config(document_index_view_type).thumbnail_method, document, image_options)
181
180
  elsif blacklight_config.view_config(document_index_view_type).thumbnail_field
182
- image_tag thumbnail_url(document), image_options
181
+ url = thumbnail_url(document)
182
+
183
+ image_tag url, image_options if url.present?
183
184
  end
184
185
 
185
186
  if value
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # Rails Helper methods to take a hash and turn it to form <input type="hidden">
3
2
  # fields, works with hash nested with other hashes and arrays, standard rails
4
3
  # serialization style. Oddly while Hash#to_query will do this for a URL
@@ -30,5 +30,13 @@ module Blacklight
30
30
  def sidebar_classes
31
31
  'col-md-3 col-sm-4'
32
32
  end
33
+
34
+ ##
35
+ # Class used for specifying main layout container classes. Can be
36
+ # overwritten to return 'container-fluid' for Bootstrap full-width layout
37
+ # @return [String]
38
+ def container_classes
39
+ 'container'
40
+ end
33
41
  end
34
42
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # All methods in here are 'api' that may be over-ridden by plugins and local
3
2
  # code, so method signatures and semantics should not be changed casually.
4
3
  # implementations can be of course.
@@ -39,12 +39,7 @@ module Blacklight::RenderPartialsHelper
39
39
  # @param [String] base name for the partial
40
40
  # @param [Hash] locales to pass through to the partials
41
41
  def render_document_partial(doc, base_name, locals = {})
42
- format = if method(:document_partial_name).arity == 1
43
- Deprecation.warn self, "The #document_partial_name with a single argument is deprecated. Update your override to include a second argument for the 'base name'"
44
- document_partial_name(doc)
45
- else
46
- document_partial_name(doc, base_name)
47
- end
42
+ format = document_partial_name(doc, base_name)
48
43
 
49
44
  view_type = document_index_view_type
50
45
  template = cached_view ['show', view_type, base_name, format].join('_') do
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # All methods in here are 'api' that may be over-ridden by plugins and local
3
2
  # code, so method signatures and semantics should not be changed casually.
4
3
  # implementations can be of course.
@@ -12,17 +12,12 @@ module Blacklight::UrlHelperBehavior
12
12
  end
13
13
 
14
14
  # link_to_document(doc, 'VIEW', :counter => 3)
15
- # link_to_document(doc, :label=>'VIEW', :counter => 3)
16
15
  # Use the catalog_path RESTful route to create a link to the show page for a specific item.
17
16
  # catalog_path accepts a HashWithIndifferentAccess object. The solr query params are stored in the session,
18
17
  # so we only need the +counter+ param here. We also need to know if we are viewing to document as part of search results.
19
18
  def link_to_document(doc, field_or_opts = nil, opts={:counter => nil})
20
19
  if field_or_opts.is_a? Hash
21
20
  opts = field_or_opts
22
- if opts[:label]
23
- Deprecation.warn self, "The second argument to link_to_document should now be the label."
24
- field = opts.delete(:label)
25
- end
26
21
  else
27
22
  field = field_or_opts
28
23
  end
@@ -151,7 +146,7 @@ module Blacklight::UrlHelperBehavior
151
146
 
152
147
  # Get url parameters to a search within a grouped result set
153
148
  #
154
- # @param [Blacklight::SolrResponse::Group]
149
+ # @param [Blacklight::Solr::Response::Group]
155
150
  # @return [Hash]
156
151
  def add_group_facet_params_and_redirect group
157
152
  search_state.add_facet_params_and_redirect(group.field, group.key)
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight::Solr
3
2
  # Pagination for facet values -- works by setting the limit to max
4
3
  # displayable. You have to ask Solr for limit+1, to get enough
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Bookmark < ActiveRecord::Base
3
2
 
4
3
  belongs_to :user, polymorphic: true
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight::Configurable
3
2
  extend ActiveSupport::Concern
4
3
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # This module provides the cache key which can be used by rails
3
2
  # caching to determine when to expire a particular object's cache
4
3
  # See http://apidock.com/rails/ActiveRecord/Integration/cache_key
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # This module provides the body of an email export based on the document's semantic values
3
2
  module Blacklight::Document::Email
4
3
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # This module provides the body of an email export based on the document's semantic values
3
2
  module Blacklight::Document::Sms
4
3
 
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'rsolr'
3
2
  ##
4
3
  ##
@@ -16,12 +15,6 @@ require 'rsolr'
16
15
  #
17
16
 
18
17
  module Blacklight::Solr::Document
19
- autoload :SchemaOrg, 'blacklight/solr/document/schema_org'
20
- autoload :DublinCore, 'blacklight/solr/document/dublin_core'
21
- autoload :Email, 'blacklight/solr/document/email'
22
- autoload :Sms, 'blacklight/solr/document/sms'
23
- autoload :Extensions, 'blacklight/solr/document/extensions'
24
- autoload :Export, 'blacklight/solr/document/export'
25
18
  autoload :MoreLikeThis, 'blacklight/solr/document/more_like_this'
26
19
 
27
20
  extend ActiveSupport::Concern
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Blacklight::User
3
2
  # This gives us an is_blacklight_user method that can be included in
4
3
  # the containing applications models.
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  # Only works for documents with a #to_marc right now.
3
2
  class RecordMailer < ActionMailer::Base
4
3
  def email_record(documents, details, url_gen_params)
data/app/models/search.rb CHANGED
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  class Search < ActiveRecord::Base
3
2
 
4
3
  belongs_to :user
@@ -9,11 +8,6 @@ class Search < ActiveRecord::Base
9
8
  attr_accessible :query_params
10
9
  end
11
10
 
12
- unless respond_to?(:none)
13
- # polyfill
14
- scope :none, -> { where(id: nil).where("id IS NOT ?", nil) }
15
- end
16
-
17
11
  # A Search instance is considered a saved search if it has a user_id.
18
12
  def saved?
19
13
  self.user_id?
@@ -99,29 +99,15 @@ module Blacklight
99
99
  options = {}
100
100
  options = field_config.separator_options if field_config && field_config.separator_options
101
101
 
102
- if field_config && field_config.separator
103
- Deprecation.warn(self.class, 'The field configuration #separator is deprecated. Use #separator_options instead')
104
- options[:words_connector] ||= field_config.separator
105
- options[:two_words_connector] ||= field_config.separator
106
- options[:last_word_connector] ||= field_config.separator
107
- end
108
-
109
102
  values.map { |x| html_escape(x) }.to_sentence(options).html_safe
110
103
  end
111
104
 
112
105
  ##
113
106
  # Render the document index heading
114
107
  #
115
- # @param [Hash] opts (Deprecated)
116
- # @option opts [Symbol] :label Render the given field from the document
117
- # @option opts [Proc] :label Evaluate the given proc
118
- # @option opts [String] :label Render the given string
119
108
  # @param [Symbol, Proc, String] field Render the given field or evaluate the proc or render the given string
120
- def render_document_index_label field, opts ={}
121
- if field.is_a? Hash
122
- Deprecation.warn DocumentPresenter, "Calling render_document_index_label with a hash is deprecated"
123
- field = field[:label]
124
- end
109
+ # @param [Hash] opts
110
+ def render_document_index_label(field, opts = {})
125
111
  label = case field
126
112
  when Symbol
127
113
  @document[field]
@@ -211,7 +197,7 @@ module Blacklight
211
197
  # rendering values
212
198
  case
213
199
  when (field_config and field_config.helper_method)
214
- @controller.send(field_config.helper_method, options.merge(:document => @document, :field => field, :value => value))
200
+ @controller.send(field_config.helper_method, options.merge(document: @document, field: field, config: field_config, value: value))
215
201
  when (field_config and field_config.link_to_search)
216
202
  link_field = if field_config.link_to_search === true
217
203
  field_config.key
@@ -0,0 +1,41 @@
1
+ module Blacklight
2
+ class JsonPresenter
3
+ include Blacklight::Facet
4
+
5
+ # @param [Solr::Response] response raw solr response.
6
+ # @param [Array<SolrDocument>] documents a list of documents
7
+ # @param [Array] facets list of facets
8
+ def initialize(response, documents, facets, blacklight_config)
9
+ @response = response
10
+ @documents = documents
11
+ @facets = facets
12
+ @blacklight_config = blacklight_config
13
+ end
14
+
15
+ attr_reader :documents, :blacklight_config
16
+
17
+ def search_facets_as_json
18
+ @facets.as_json.each do |f|
19
+ f.delete "options"
20
+ f["label"] = facet_configuration_for_field(f["name"]).label
21
+ f["items"] = f["items"].as_json.each do |i|
22
+ i['label'] ||= i['value']
23
+ end
24
+ end
25
+ end
26
+
27
+
28
+ # extract the pagination info from the response object
29
+ def pagination_info
30
+ h = {}
31
+
32
+ [:current_page, :next_page, :prev_page, :total_pages,
33
+ :limit_value, :offset_value, :total_count,
34
+ :first_page?, :last_page?].each do |k|
35
+ h[k] = @response.send(k)
36
+ end
37
+
38
+ h
39
+ end
40
+ end
41
+ end