blacklight 5.9.4 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/VERSION +1 -1
  4. data/app/assets/stylesheets/blacklight/_facets.scss +11 -10
  5. data/app/helpers/blacklight/blacklight_helper_behavior.rb +14 -14
  6. data/app/helpers/blacklight/configuration_helper_behavior.rb +16 -10
  7. data/app/helpers/blacklight/facets_helper_behavior.rb +15 -14
  8. data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
  9. data/app/models/bookmark.rb +1 -4
  10. data/app/models/search.rb +3 -6
  11. data/app/views/catalog/_facet_layout.html.erb +2 -2
  12. data/app/views/catalog/_facet_limit.html.erb +5 -3
  13. data/app/views/catalog/_facet_pivot.html.erb +4 -4
  14. data/app/views/catalog/_home_text.html.erb +8 -48
  15. data/app/views/catalog/_index_default.html.erb +3 -3
  16. data/app/views/catalog/_show_default.html.erb +3 -3
  17. data/app/views/catalog/_sms_form.html.erb +1 -1
  18. data/app/views/catalog/facet.html.erb +1 -1
  19. data/blacklight.gemspec +1 -1
  20. data/config/jetty.yml +0 -3
  21. data/config/locales/blacklight.de.yml +2 -0
  22. data/config/locales/blacklight.en.yml +2 -0
  23. data/config/locales/blacklight.es.yml +2 -0
  24. data/config/locales/blacklight.fr.yml +2 -0
  25. data/config/locales/blacklight.pt-BR.yml +2 -0
  26. data/lib/blacklight.rb +70 -26
  27. data/lib/blacklight/abstract_repository.rb +29 -0
  28. data/lib/blacklight/base.rb +7 -7
  29. data/lib/blacklight/bookmarks.rb +5 -5
  30. data/lib/blacklight/catalog.rb +34 -19
  31. data/lib/blacklight/catalog/search_context.rb +1 -1
  32. data/lib/blacklight/configuration.rb +112 -46
  33. data/lib/blacklight/configuration/facet_field.rb +9 -7
  34. data/lib/blacklight/configuration/field.rb +27 -0
  35. data/lib/blacklight/configuration/fields.rb +25 -20
  36. data/lib/blacklight/configuration/search_field.rb +6 -8
  37. data/lib/blacklight/configuration/solr_field.rb +3 -18
  38. data/lib/blacklight/configuration/sort_field.rb +6 -7
  39. data/lib/blacklight/document.rb +156 -0
  40. data/lib/blacklight/document/dublin_core.rb +41 -0
  41. data/lib/blacklight/document/email.rb +16 -0
  42. data/lib/blacklight/document/export.rb +107 -0
  43. data/lib/blacklight/document/extensions.rb +56 -0
  44. data/lib/blacklight/document/schema_org.rb +7 -0
  45. data/lib/blacklight/document/semantic_fields.rb +51 -0
  46. data/lib/blacklight/document/sms.rb +14 -0
  47. data/lib/blacklight/document_presenter.rb +3 -3
  48. data/lib/blacklight/exceptions.rb +9 -2
  49. data/lib/blacklight/facet.rb +21 -16
  50. data/lib/blacklight/request_builders.rb +60 -284
  51. data/lib/blacklight/routes.rb +1 -1
  52. data/lib/blacklight/search_builder.rb +130 -0
  53. data/lib/blacklight/search_helper.rb +316 -0
  54. data/lib/blacklight/solr.rb +1 -0
  55. data/lib/blacklight/solr/document.rb +4 -187
  56. data/lib/blacklight/solr/document/dublin_core.rb +3 -37
  57. data/lib/blacklight/solr/document/email.rb +4 -13
  58. data/lib/blacklight/solr/document/export.rb +3 -103
  59. data/lib/blacklight/solr/document/extensions.rb +4 -52
  60. data/lib/blacklight/solr/document/more_like_this.rb +1 -1
  61. data/lib/blacklight/solr/document/schema_org.rb +4 -4
  62. data/lib/blacklight/solr/document/sms.rb +4 -11
  63. data/lib/blacklight/solr/facet_paginator.rb +2 -2
  64. data/lib/blacklight/solr/search_builder.rb +264 -0
  65. data/lib/blacklight/solr_helper.rb +6 -261
  66. data/lib/blacklight/solr_repository.rb +30 -24
  67. data/lib/blacklight/solr_response.rb +3 -3
  68. data/lib/blacklight/user.rb +1 -2
  69. data/lib/blacklight/utils.rb +0 -23
  70. data/lib/generators/blacklight/controller_generator.rb +38 -0
  71. data/lib/generators/blacklight/document_generator.rb +20 -0
  72. data/lib/generators/blacklight/install_generator.rb +38 -39
  73. data/lib/generators/blacklight/models_generator.rb +2 -62
  74. data/lib/generators/blacklight/templates/catalog_controller.rb +3 -4
  75. data/lib/generators/blacklight/templates/config/{solr.yml → blacklight.yml} +3 -0
  76. data/lib/generators/blacklight/templates/config/jetty.yml +0 -3
  77. data/lib/generators/blacklight/templates/solr_document.rb +6 -6
  78. data/lib/generators/blacklight/test_support_generator.rb +1 -6
  79. data/lib/generators/blacklight/user_generator.rb +59 -0
  80. data/lib/railties/blacklight.rake +16 -7
  81. data/spec/controllers/catalog_controller_spec.rb +9 -15
  82. data/spec/features/facets_spec.rb +8 -0
  83. data/spec/helpers/configuration_helper_spec.rb +6 -13
  84. data/spec/helpers/facets_helper_spec.rb +3 -2
  85. data/spec/lib/blacklight/configuration_spec.rb +11 -38
  86. data/spec/lib/blacklight/{solr/document → document}/dublin_core_spec.rb +4 -4
  87. data/spec/lib/blacklight/{solr/document → document}/email_spec.rb +2 -2
  88. data/spec/lib/blacklight/{solr/document → document}/sms_spec.rb +2 -2
  89. data/spec/lib/blacklight/search_builder_spec.rb +145 -0
  90. data/spec/lib/blacklight/search_helper_spec.rb +775 -0
  91. data/spec/lib/blacklight/solr/document/more_like_this_spec.rb +1 -1
  92. data/spec/lib/blacklight/solr/search_builder_spec.rb +561 -0
  93. data/spec/lib/blacklight/solr_helper_spec.rb +5 -1291
  94. data/spec/lib/blacklight/solr_repository_spec.rb +13 -13
  95. data/spec/models/record_mailer_spec.rb +2 -2
  96. data/spec/spec_helper.rb +1 -0
  97. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -1
  98. data/spec/views/catalog/_constraints.html.erb_spec.rb +1 -1
  99. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +2 -2
  100. data/spec/views/catalog/index.atom.builder_spec.rb +1 -1
  101. data/tasks/blacklight.rake +1 -1
  102. data/template.demo.rb +1 -1
  103. metadata +33 -45
  104. data/doc/Adding-new-document-actions.md +0 -94
  105. data/doc/Atom-Responses.md +0 -90
  106. data/doc/Blacklight-Add-ons.md +0 -23
  107. data/doc/Blacklight-configuration.md +0 -411
  108. data/doc/Blacklight-on-Heroku.md +0 -100
  109. data/doc/Blacklight-out-of-the-box.md +0 -47
  110. data/doc/Bookmarks.md +0 -1
  111. data/doc/Code4Lib-2014.md +0 -94
  112. data/doc/Configuration---Facet-Fields.md +0 -130
  113. data/doc/Configuration---Results-View.md +0 -224
  114. data/doc/Configuration---Solr-fields.md +0 -106
  115. data/doc/Configuring-and-Customizing-Blacklight.md +0 -257
  116. data/doc/Configuring-rails-routes.md +0 -13
  117. data/doc/Contributing-to-Blacklight.md +0 -43
  118. data/doc/Examples.md +0 -120
  119. data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
  120. data/doc/Home.md +0 -100
  121. data/doc/How-to-release-a-version.md +0 -45
  122. data/doc/Indexing-your-data-into-solr.md +0 -36
  123. data/doc/Internationalization.md +0 -32
  124. data/doc/JSON-API.md +0 -83
  125. data/doc/Pagination.md +0 -52
  126. data/doc/Providing-your-own-view-templates.md +0 -69
  127. data/doc/Quickstart.md +0 -153
  128. data/doc/README_SOLR.md +0 -245
  129. data/doc/Saved-Searches.md +0 -5
  130. data/doc/Solr-Configuration.md +0 -154
  131. data/doc/Sunspot-for-indexing.md +0 -46
  132. data/doc/Support.md +0 -33
  133. data/doc/Theming.md +0 -62
  134. data/doc/Understanding-Rails-and-Blacklight.md +0 -75
  135. data/doc/User-Authentication.md +0 -60
  136. data/doc/_Sidebar.md +0 -9
  137. data/doc/testing.md +0 -58
@@ -1,10 +1,10 @@
1
1
  <%# default partial to display solr document fields in catalog index view -%>
2
2
  <dl class="document-metadata dl-horizontal dl-invert">
3
3
 
4
- <% index_fields(document).each do |solr_fname, field| -%>
4
+ <% index_fields(document).each do |field_name, field| -%>
5
5
  <% if should_render_index_field? document, field %>
6
- <dt class="blacklight-<%= solr_fname.parameterize %>"><%= render_index_field_label document, :field => solr_fname %></dt>
7
- <dd class="blacklight-<%= solr_fname.parameterize %>"><%= render_index_field_value document, :field => solr_fname %></dd>
6
+ <dt class="blacklight-<%= field_name.parameterize %>"><%= render_index_field_label document, field: field_name %></dt>
7
+ <dd class="blacklight-<%= field_name.parameterize %>"><%= render_index_field_value document, field: field_name %></dd>
8
8
  <% end -%>
9
9
  <% end -%>
10
10
 
@@ -1,9 +1,9 @@
1
1
  <%# default partial to display solr document fields in catalog show view -%>
2
2
  <dl class="dl-horizontal dl-invert">
3
- <% document_show_fields(document).each do |solr_fname, field| -%>
3
+ <% document_show_fields(document).each do |field_name, field| -%>
4
4
  <% if should_render_show_field? document, field %>
5
- <dt class="blacklight-<%= solr_fname.parameterize %>"><%= render_document_show_field_label document, :field => solr_fname %></dt>
6
- <dd class="blacklight-<%= solr_fname.parameterize %>"><%= render_document_show_field_value document, :field => solr_fname %></dd>
5
+ <dt class="blacklight-<%= field_name.parameterize %>"><%= render_document_show_field_label document, field: field_name %></dt>
6
+ <dd class="blacklight-<%= field_name.parameterize %>"><%= render_document_show_field_value document, field: field_name %></dd>
7
7
  <% end -%>
8
8
  <% end -%>
9
9
  </dl>
@@ -19,7 +19,7 @@
19
19
 
20
20
  </div>
21
21
  <% @documents.each do |doc| %>
22
- <%=hidden_field_tag "id[]", doc.id %>
22
+ <%=hidden_field_tag "id[]", doc.get(:id)%>
23
23
  <% end %>
24
24
  </div>
25
25
  <div class="modal-footer">
@@ -4,7 +4,7 @@
4
4
 
5
5
  <div class="modal-header">
6
6
  <button type="button" class="ajax-modal-close close" data-dismiss="modal" aria-hidden="true">×</button>
7
- <h3 class="modal-title"><%= facet_field_label(@facet.field) %></h3>
7
+ <h3 class="modal-title"><%= facet_field_label(@facet.key) %></h3>
8
8
  </div>
9
9
  <div class="modal-body">
10
10
  <div class="facet_extended_list">
data/blacklight.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency "rails", ">= 3.2.6", "< 5"
21
21
  s.add_dependency "nokogiri", "~>1.6" # XML Parser
22
22
  s.add_dependency "kaminari", "~> 0.13" # the pagination (page 1,2,3, etc..) of our search results
23
- s.add_dependency "rsolr", "~> 1.0.6" # Library for interacting with rSolr.
23
+ s.add_dependency "rsolr", "~> 1.0.11" # Library for interacting with rSolr.
24
24
  s.add_dependency "bootstrap-sass", "~> 3.2"
25
25
  s.add_dependency "deprecation"
26
26
 
data/config/jetty.yml CHANGED
@@ -1,13 +1,10 @@
1
1
  development:
2
2
  startup_wait: 15
3
3
  jetty_port: 8983
4
- java_version: ">= 1.7"
5
4
  test:
6
5
  startup_wait: 60
7
6
  jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
8
7
  <%= ENV['TEST_JETTY_PATH'] ? "jetty_home: " + ENV['TEST_JETTY_PATH'] : '' %>
9
- java_version: ">= 1.7"
10
8
  production:
11
9
  startup_wait: 15
12
10
  jetty_port: 8983
13
- java_version: ">= 1.7"
@@ -183,7 +183,9 @@ de:
183
183
  count: 'Numerisch ordnen'
184
184
  index: 'A-Z Ordnen'
185
185
  count: '%{number}'
186
+ # i18n key 'more' is deprecated and will be removed in Blacklight 6.0
186
187
  more: 'mehr »'
188
+ more_html: 'mehr <span class="sr-only">%{field_name}</span> »'
187
189
  selected:
188
190
  remove: '[entfernen]'
189
191
  group:
@@ -183,7 +183,9 @@ en:
183
183
  count: 'Numerical Sort'
184
184
  index: 'A-Z Sort'
185
185
  count: '%{number}'
186
+ # i18n key 'more' is deprecated and will be removed in Blacklight 6.0
186
187
  more: 'more »'
188
+ more_html: 'more <span class="sr-only">%{field_name}</span> »'
187
189
  selected:
188
190
  remove: '[remove]'
189
191
  group:
@@ -183,7 +183,9 @@ es:
183
183
  count: 'Ordenación numérica'
184
184
  index: 'Ordenación A-Z'
185
185
  count: '%{number}'
186
+ # i18n key 'more' is deprecated and will be removed in Blacklight 6.0
186
187
  more: 'más »'
188
+ more_html: 'más <span class="sr-only">%{field_name}</span> »'
187
189
  selected:
188
190
  remove: '[borrar]'
189
191
  group:
@@ -199,7 +199,9 @@ fr:
199
199
  count: 'Du + au - fréquent'
200
200
  index: 'Tri de A à Z'
201
201
  count: '%{number}'
202
+ # i18n key 'more' is deprecated and will be removed in Blacklight 6.0
202
203
  more: 'plus »'
204
+ more_html: 'plus <span class="sr-only">%{field_name}</span> »'
203
205
  selected:
204
206
  remove: '[ X ]'
205
207
  group:
@@ -203,7 +203,9 @@ pt-BR:
203
203
  count: 'Ordenar por Número'
204
204
  index: 'Ordem Alfabética A-Z'
205
205
  count: '%{number}'
206
+ # i18n key 'more' is deprecated and will be removed in Blacklight 6.0
206
207
  more: 'mais »'
208
+ more_html: 'mais <span class="sr-only">%{field_name}</span> »'
207
209
  selected:
208
210
  remove: '[remover]'
209
211
  filters:
data/lib/blacklight.rb CHANGED
@@ -1,21 +1,21 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require 'kaminari'
3
- require 'rsolr'
4
3
  require 'deprecation'
5
- require 'blacklight/utils'
6
-
7
4
  module Blacklight
8
-
9
5
  autoload :Configurable, 'blacklight/configurable'
10
6
  autoload :Configuration, 'blacklight/configuration'
11
7
  autoload :SearchFields, 'blacklight/search_fields'
12
-
13
- autoload :Solr, 'blacklight/solr'
14
-
15
- autoload :SolrHelper, 'blacklight/solr_helper'
16
- autoload :SolrRepository, 'blacklight/solr_repository'
17
- autoload :RequestBuilders, 'blacklight/request_builders'
8
+ autoload :SearchBuilder, 'blacklight/search_builder'
18
9
 
10
+ autoload :Document, 'blacklight/document'
11
+ autoload :Solr, 'blacklight/solr'
12
+
13
+ autoload :SearchHelper, 'blacklight/search_helper'
14
+ autoload :SolrHelper, 'blacklight/solr_helper'
15
+ autoload :AbstractRepository, 'blacklight/abstract_repository'
16
+ autoload :SolrRepository, 'blacklight/solr_repository'
17
+ autoload :RequestBuilders, 'blacklight/request_builders'
18
+
19
19
  autoload :Exceptions, 'blacklight/exceptions'
20
20
 
21
21
  autoload :User, 'blacklight/user'
@@ -23,17 +23,19 @@ module Blacklight
23
23
  autoload :Controller, 'blacklight/controller'
24
24
  autoload :Base, 'blacklight/base'
25
25
  autoload :Catalog, 'blacklight/catalog'
26
- autoload :TokenBasedUser, 'blacklight/token_based_user'
26
+ autoload :TokenBasedUser, 'blacklight/token_based_user'
27
27
  autoload :Bookmarks, 'blacklight/bookmarks'
28
28
  autoload :DocumentPresenter, 'blacklight/document_presenter'
29
29
 
30
30
  autoload :Routes, 'blacklight/routes'
31
-
31
+
32
+ autoload :OpenStructWithHashAccess, 'blacklight/utils'
32
33
  autoload :SolrResponse, 'blacklight/solr_response'
33
34
  autoload :Facet, 'blacklight/facet'
34
35
 
35
36
  extend SearchFields
36
-
37
+ extend Deprecation
38
+
37
39
  require 'blacklight/version'
38
40
  require 'blacklight/engine' if defined?(Rails)
39
41
 
@@ -45,26 +47,74 @@ module Blacklight
45
47
  # other services (e.g. refworks callback urls)
46
48
  mattr_accessor :secret_key
47
49
  @@secret_key = nil
48
-
50
+
51
+ # @deprecated
49
52
  def self.solr_file
50
53
  "#{::Rails.root.to_s}/config/solr.yml"
51
54
  end
52
-
55
+
56
+ def self.blacklight_config_file
57
+ "#{::Rails.root.to_s}/config/blacklight.yml"
58
+ end
59
+
53
60
  def self.add_routes(router, options = {})
54
61
  Blacklight::Routes.new(router, options).draw
55
62
  end
56
63
 
57
64
  def self.solr
58
- @solr ||= RSolr.connect(Blacklight.solr_config)
65
+ Deprecation.warn Blacklight, "Blacklight.solr is deprecated and will be removed in 6.0.0. Use Blacklight.default_index.connection instead", caller
66
+ default_index.connection
67
+ end
68
+
69
+ def self.default_index
70
+ @default_index ||= Blacklight::SolrRepository.new(Blacklight::Configuration.new)
59
71
  end
60
72
 
61
73
  def self.solr_config
62
- @solr_config ||= begin
63
- raise "The #{::Rails.env} environment settings were not found in the solr.yml config" unless solr_yml[::Rails.env]
64
- solr_yml[::Rails.env].symbolize_keys
74
+ Deprecation.warn Blacklight, "Blacklight.solr_config is deprecated and will be removed in 6.0.0. Use Blacklight.connection_config instead", caller
75
+ connection_config
76
+ end
77
+
78
+ def self.connection_config
79
+ @connection_config ||= begin
80
+ raise "The #{::Rails.env} environment settings were not found in the blacklight.yml config" unless blacklight_yml[::Rails.env]
81
+ blacklight_yml[::Rails.env].symbolize_keys
65
82
  end
66
83
  end
67
84
 
85
+ def self.blacklight_yml
86
+ require 'erb'
87
+ require 'yaml'
88
+
89
+ return @blacklight_yml if @blacklight_yml
90
+ unless File.exists?(blacklight_config_file)
91
+ if File.exists?(solr_file)
92
+ Deprecation.warn Blacklight, "Configuration is now done via blacklight.yml. Suppport for solr.yml will be removed in blacklight 6.0.0"
93
+ return solr_yml
94
+ else
95
+ raise "You are missing a configuration file: #{blacklight_config_file}. Have you run \"rails generate blacklight:install\"?"
96
+ end
97
+ end
98
+
99
+ begin
100
+ blacklight_erb = ERB.new(IO.read(blacklight_config_file)).result(binding)
101
+ rescue Exception => e
102
+ raise("#{blacklight_config_file} was found, but could not be parsed with ERB. \n#{$!.inspect}")
103
+ end
104
+
105
+ begin
106
+ @blacklight_yml = YAML::load(blacklight_erb)
107
+ rescue StandardError => e
108
+ raise("#{blacklight_config_file} was found, but could not be parsed.\n")
109
+ end
110
+
111
+ if @blacklight_yml.nil? || !@blacklight_yml.is_a?(Hash)
112
+ raise("#{blacklight_config_file} was found, but was blank or malformed.\n")
113
+ end
114
+
115
+ return @blacklight_yml
116
+ end
117
+
68
118
  def self.solr_yml
69
119
  require 'erb'
70
120
  require 'yaml'
@@ -94,13 +144,7 @@ module Blacklight
94
144
  end
95
145
 
96
146
  def self.logger
97
- @logger ||= begin
98
- ::Rails.logger if defined? Rails and Rails.respond_to? :logger
99
- end
100
- end
101
-
102
- def self.logger= logger
103
- @logger = logger
147
+ ::Rails.logger
104
148
  end
105
149
 
106
150
  #############
@@ -0,0 +1,29 @@
1
+ module Blacklight
2
+ class AbstractRepository
3
+ attr_accessor :blacklight_config
4
+ attr_writer :connection
5
+
6
+ # ActiveSupport::Benchmarkable requires a logger method
7
+ attr_accessor :logger
8
+
9
+ include ActiveSupport::Benchmarkable
10
+
11
+ def initialize blacklight_config
12
+ @blacklight_config = blacklight_config
13
+ end
14
+
15
+ def connection
16
+ @connection ||= build_connection
17
+ end
18
+
19
+
20
+ protected
21
+ def connection_config
22
+ @connection_config ||= Blacklight.connection_config
23
+ end
24
+
25
+ def logger
26
+ @logger ||= Rails.logger if defined? Rails
27
+ end
28
+ end
29
+ end
@@ -1,23 +1,23 @@
1
1
  # -*- encoding : utf-8 -*-
2
- module Blacklight::Base
2
+ module Blacklight::Base
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  include Blacklight::Configurable
6
- include Blacklight::SolrHelper
6
+ include Blacklight::SearchHelper
7
7
 
8
8
  include Blacklight::Catalog::SearchContext
9
9
 
10
- included do
11
- # When RSolr::RequestError is raised, the rsolr_request_error method is executed.
10
+ included do
11
+ # When Blacklight::Exceptions::InvalidRequest is raised, the rsolr_request_error method is executed.
12
12
  # The index action will more than likely throw this one.
13
13
  # Example, when the standard query parser is used, and a user submits a "bad" query.
14
- rescue_from RSolr::Error::Http, :with => :rsolr_request_error if respond_to? :rescue_from
14
+ rescue_from Blacklight::Exceptions::InvalidRequest, with: :handle_request_error if respond_to? :rescue_from
15
15
  end
16
16
 
17
17
  protected
18
18
 
19
- # when solr (RSolr) throws an error (RSolr::RequestError), this method is executed.
20
- def rsolr_request_error(exception)
19
+ # when The index throws an error (Blacklight::Exceptions::InvalidRequest), this method is executed.
20
+ def handle_request_error(exception)
21
21
 
22
22
  if Rails.env.development? || Rails.env.test?
23
23
  raise exception # Rails own code will catch and give usual Rails error page with stack trace
@@ -8,7 +8,7 @@ module Blacklight::Bookmarks
8
8
  ##
9
9
  # Give Bookmarks access to the CatalogController configuration
10
10
  include Blacklight::Configurable
11
- include Blacklight::SolrHelper
11
+ include Blacklight::SearchHelper
12
12
  include Blacklight::TokenBasedUser
13
13
 
14
14
  copy_blacklight_config_from(CatalogController)
@@ -22,7 +22,7 @@ module Blacklight::Bookmarks
22
22
  def action_documents
23
23
  bookmarks = token_or_current_or_guest_user.bookmarks
24
24
  bookmark_ids = bookmarks.collect { |b| b.document_id.to_s }
25
- get_solr_response_for_document_ids(bookmark_ids)
25
+ fetch(bookmark_ids)
26
26
  end
27
27
 
28
28
  def action_success_redirect_path
@@ -39,7 +39,7 @@ module Blacklight::Bookmarks
39
39
  @bookmarks = token_or_current_or_guest_user.bookmarks
40
40
  bookmark_ids = @bookmarks.collect { |b| b.document_id.to_s }
41
41
 
42
- @response, @document_list = get_solr_response_for_document_ids(bookmark_ids)
42
+ @response, @document_list = fetch(bookmark_ids)
43
43
 
44
44
  respond_to do |format|
45
45
  format.html { }
@@ -71,7 +71,7 @@ module Blacklight::Bookmarks
71
71
  if params[:bookmarks]
72
72
  @bookmarks = params[:bookmarks]
73
73
  else
74
- @bookmarks = [{ document_id: params[:id], document_type: blacklight_config.solr_document_model.to_s }]
74
+ @bookmarks = [{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]
75
75
  end
76
76
 
77
77
  current_or_guest_user.save! unless current_or_guest_user.persisted?
@@ -96,7 +96,7 @@ module Blacklight::Bookmarks
96
96
  # Beware, :id is the Solr document_id, not the actual Bookmark id.
97
97
  # idempotent, as DELETE is supposed to be.
98
98
  def destroy
99
- bookmark = current_or_guest_user.bookmarks.where(document_id: params[:id], document_type: blacklight_config.solr_document_model).first
99
+ bookmark = current_or_guest_user.bookmarks.where(document_id: params[:id], document_type: blacklight_config.document_model).first
100
100
 
101
101
  success = bookmark && bookmark.delete && bookmark.destroyed?
102
102
 
@@ -2,6 +2,7 @@
2
2
  module Blacklight::Catalog
3
3
  extend ActiveSupport::Concern
4
4
  extend ActiveSupport::Autoload
5
+ extend Deprecation
5
6
 
6
7
  eager_autoload do
7
8
  autoload :ComponentConfiguration
@@ -20,17 +21,19 @@ module Blacklight::Catalog
20
21
  included do
21
22
  helper_method :sms_mappings, :has_search_parameters?
22
23
 
23
- # Whenever an action raises SolrHelper::InvalidSolrID, this block gets executed.
24
- # Hint: the SolrHelper #get_solr_response_for_doc_id method raises this error,
25
- # which is used in the #show action here.
26
- rescue_from Blacklight::Exceptions::InvalidSolrID, :with => :invalid_solr_id_error
24
+ # When an action raises Blacklight::Exceptions::RecordNotFound, handle
25
+ # the exception appropriately.
26
+ rescue_from Blacklight::Exceptions::RecordNotFound, with: :invalid_document_id_error
27
+
28
+ # Deprecated:
29
+ rescue_from Blacklight::Exceptions::InvalidSolrID, with: :invalid_document_id_error
27
30
 
28
31
  record_search_parameters
29
32
  end
30
33
 
31
34
  # get search results from the solr index
32
35
  def index
33
- (@response, @document_list) = get_search_results
36
+ (@response, @document_list) = search_results(params, search_params_logic)
34
37
 
35
38
  respond_to do |format|
36
39
  format.html { store_preferred_view }
@@ -48,21 +51,13 @@ module Blacklight::Catalog
48
51
  # get a single document from the index
49
52
  # to add responses for formats other than html or json see _Blacklight::Document::Export_
50
53
  def show
51
- @response, @document = get_solr_response_for_doc_id params[:id]
54
+ @response, @document = fetch params[:id]
52
55
 
53
56
  respond_to do |format|
54
- format.html {setup_next_and_previous_documents}
55
-
56
- format.json { render json: {response: {document: @document}}}
57
-
58
- # Add all dynamically added (such as by document extensions)
59
- # export formats.
60
- @document.export_formats.each_key do | format_name |
61
- # It's important that the argument to send be a symbol;
62
- # if it's a string, it makes Rails unhappy for unclear reasons.
63
- format.send(format_name.to_sym) { render :text => @document.export_as(format_name), :layout => false }
64
- end
57
+ format.html { setup_next_and_previous_documents }
58
+ format.json { render json: { response: { document: @document } } }
65
59
 
60
+ additional_export_formats(@document, format)
66
61
  end
67
62
  end
68
63
 
@@ -82,7 +77,7 @@ module Blacklight::Catalog
82
77
  # displays values and pagination links for a single facet field
83
78
  def facet
84
79
  @facet = blacklight_config.facet_fields[params[:id]]
85
- @response = get_facet_field_response(@facet.field, params)
80
+ @response = get_facet_field_response(@facet.key, params)
86
81
  @display_facet = @response.facets.first
87
82
 
88
83
  @pagination = facet_paginator(@facet, @display_facet)
@@ -111,7 +106,7 @@ module Blacklight::Catalog
111
106
  end
112
107
 
113
108
  def action_documents
114
- get_solr_response_for_document_ids(params[:id])
109
+ fetch(Array(params[:id]))
115
110
  end
116
111
 
117
112
  def action_success_redirect_path
@@ -171,6 +166,15 @@ module Blacklight::Catalog
171
166
  end
172
167
  end
173
168
 
169
+ ##
170
+ # Render additional export formats for the show action, as provided by
171
+ # the document extension framework. See _Blacklight::Document::Export_
172
+ def additional_export_formats(document, format)
173
+ document.export_formats.each_key do | format_name |
174
+ format.send(format_name.to_sym) { render text: document.export_as(format_name), layout: false }
175
+ end
176
+ end
177
+
174
178
  ##
175
179
  # Try to render a response from the document export formats available
176
180
  def document_export_formats format
@@ -295,10 +299,20 @@ module Blacklight::Catalog
295
299
  flash[:error].blank?
296
300
  end
297
301
 
302
+ ##
298
303
  # when a request for /catalog/BAD_SOLR_ID is made, this method is executed.
299
304
  # Just returns a 404 response, but you can override locally in your own
300
305
  # CatalogController to do something else -- older BL displayed a Catalog#inde
301
306
  # page with a flash message and a 404 status.
307
+ def invalid_document_id_error *args
308
+ Deprecation.silence(Blacklight::Catalog) do
309
+ invalid_solr_id_error *args
310
+ end
311
+ end
312
+
313
+ ##
314
+ # DEPRECATED; this method will be removed in Blacklight 6.0 and the functionality
315
+ # moved to invalid_document_id_error
302
316
  def invalid_solr_id_error(exception)
303
317
  error_info = {
304
318
  "status" => "404",
@@ -321,6 +335,7 @@ module Blacklight::Catalog
321
335
  end
322
336
  end
323
337
  end
338
+ deprecation_deprecate invalid_solr_id_error: :invalid_document_id_error
324
339
 
325
340
  def start_new_search_session?
326
341
  action_name == "index"