blacklight 4.9.0 → 5.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +22 -12
  4. data/Gemfile +3 -40
  5. data/LICENSE +1 -2
  6. data/README.md +1 -2
  7. data/Rakefile +0 -4
  8. data/VERSION +1 -1
  9. data/app/assets/images/blacklight/logo.png +0 -0
  10. data/app/assets/javascripts/blacklight/ajax_modal.js +190 -0
  11. data/app/assets/javascripts/blacklight/blacklight.js +7 -17
  12. data/app/assets/javascripts/blacklight/checkbox_submit.js +1 -1
  13. data/app/assets/stylesheets/blacklight/{_blacklight_base.scss → _blacklight_base.css.scss} +0 -21
  14. data/app/assets/stylesheets/blacklight/_bookmark.css.scss +4 -0
  15. data/app/assets/stylesheets/blacklight/_catalog.css.scss +192 -0
  16. data/app/assets/stylesheets/blacklight/_facets.css.scss +141 -0
  17. data/app/assets/stylesheets/blacklight/{_group.scss → _group.css.scss} +1 -1
  18. data/app/assets/stylesheets/blacklight/_header.css.scss +44 -0
  19. data/app/assets/stylesheets/blacklight/_layout.css.scss +5 -0
  20. data/app/assets/stylesheets/blacklight/{_modal.scss → _modal.css.scss} +7 -7
  21. data/app/assets/stylesheets/blacklight/_search_history.css.scss +20 -0
  22. data/app/assets/stylesheets/blacklight/{blacklight.scss → blacklight.css.scss} +0 -0
  23. data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +14 -0
  24. data/app/controllers/bookmarks_controller.rb +0 -4
  25. data/app/controllers/feedback_controller.rb +0 -4
  26. data/app/helpers/blacklight/blacklight_helper_behavior.rb +45 -155
  27. data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -41
  28. data/app/helpers/blacklight/facets_helper_behavior.rb +20 -43
  29. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +2 -9
  30. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -14
  31. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +6 -6
  32. data/app/views/_flash_msg.html.erb +9 -2
  33. data/app/views/_user_util_links.html.erb +29 -15
  34. data/app/views/bookmarks/_tools.html.erb +4 -7
  35. data/app/views/bookmarks/index.html.erb +3 -2
  36. data/app/views/catalog/_citation.html.erb +1 -1
  37. data/app/views/catalog/_constraints.html.erb +1 -1
  38. data/app/views/catalog/_constraints_element.html.erb +12 -8
  39. data/app/views/catalog/_did_you_mean.html.erb +2 -2
  40. data/app/views/catalog/_document_header.html.erb +3 -3
  41. data/app/views/catalog/_email_form.html.erb +10 -10
  42. data/app/views/catalog/_facet_layout.html.erb +11 -3
  43. data/app/views/catalog/_facet_limit.html.erb +7 -7
  44. data/app/views/catalog/_facet_pagination.html.erb +8 -7
  45. data/app/views/catalog/_facet_pivot.html.erb +3 -1
  46. data/app/views/catalog/_facets.html.erb +12 -9
  47. data/app/views/catalog/_paginate_compact.html.erb +1 -7
  48. data/app/views/catalog/_per_page_widget.html.erb +5 -8
  49. data/app/views/catalog/_previous_next_doc.html.erb +11 -9
  50. data/app/views/catalog/_refworks_form.html.erb +3 -4
  51. data/app/views/catalog/_results_pagination.html.erb +1 -1
  52. data/app/views/catalog/_search_form.html.erb +16 -14
  53. data/app/views/catalog/_show_sidebar.html.erb +7 -9
  54. data/app/views/catalog/_show_tools.html.erb +13 -7
  55. data/app/views/catalog/_sms_form.html.erb +8 -8
  56. data/app/views/catalog/_sort_and_per_page.html.erb +4 -6
  57. data/app/views/catalog/_sort_widget.html.erb +5 -6
  58. data/app/views/catalog/email.html.erb +1 -1
  59. data/app/views/catalog/facet.html.erb +2 -8
  60. data/app/views/catalog/index.html.erb +11 -6
  61. data/app/views/catalog/show.html.erb +5 -5
  62. data/app/views/catalog/sms.html.erb +1 -1
  63. data/app/views/catalog/sms_sent.html.erb +1 -1
  64. data/app/views/feedback/complete.html.erb +2 -2
  65. data/app/views/feedback/show.html.erb +1 -1
  66. data/app/views/kaminari/blacklight/_paginator.html.erb +1 -1
  67. data/app/views/kaminari/blacklight_compact/_paginator.html.erb +25 -5
  68. data/app/views/layouts/blacklight.html.erb +23 -23
  69. data/app/views/saved_searches/index.html.erb +2 -2
  70. data/app/views/search_history/index.html.erb +5 -7
  71. data/app/views/shared/_header_navbar.html.erb +23 -23
  72. data/blacklight.gemspec +10 -13
  73. data/config/locales/blacklight.en.yml +1 -12
  74. data/config/locales/blacklight.fr.yml +1 -12
  75. data/gemfiles/rails3.gemfile +21 -0
  76. data/gemfiles/rails4.gemfile +20 -0
  77. data/lib/blacklight.rb +0 -8
  78. data/lib/blacklight/base.rb +0 -2
  79. data/lib/blacklight/catalog.rb +6 -32
  80. data/lib/blacklight/catalog/search_context.rb +8 -48
  81. data/lib/blacklight/configurable.rb +2 -1
  82. data/lib/blacklight/configuration.rb +1 -2
  83. data/lib/blacklight/configuration/facet_field.rb +0 -2
  84. data/lib/blacklight/engine.rb +3 -3
  85. data/lib/blacklight/legacy_controller_methods.rb +1 -64
  86. data/lib/blacklight/rails/routes.rb +17 -0
  87. data/lib/blacklight/routes.rb +46 -40
  88. data/lib/blacklight/solr.rb +1 -0
  89. data/lib/blacklight/solr/document.rb +21 -42
  90. data/lib/blacklight/solr/facet_paginator.rb +30 -54
  91. data/lib/blacklight/solr/request.rb +45 -0
  92. data/lib/blacklight/solr_helper.rb +16 -53
  93. data/lib/blacklight/solr_response.rb +0 -6
  94. data/lib/blacklight/user.rb +2 -7
  95. data/lib/blacklight/utils.rb +1 -9
  96. data/lib/generators/blacklight/assets_generator.rb +0 -14
  97. data/lib/generators/blacklight/blacklight_generator.rb +17 -14
  98. data/lib/generators/blacklight/templates/blacklight.css.scss +3 -0
  99. data/lib/generators/blacklight/templates/catalog_controller.rb +4 -1
  100. data/lib/railties/blacklight.rake +3 -1
  101. data/solr/sample_solr_documents.yml +641 -0
  102. data/spec/controllers/application_controller_spec.rb +5 -21
  103. data/spec/controllers/bookmarks_controller_spec.rb +11 -11
  104. data/spec/controllers/catalog_controller_spec.rb +122 -119
  105. data/spec/controllers/search_history_controller_spec.rb +8 -8
  106. data/spec/features/alternate_controller_spec.rb +5 -5
  107. data/spec/features/facets_spec.rb +9 -0
  108. data/spec/features/record_view_spec.rb +1 -1
  109. data/spec/features/search_filters_spec.rb +97 -41
  110. data/spec/features/search_results_spec.rb +14 -17
  111. data/spec/features/search_sort_spec.rb +1 -1
  112. data/spec/helpers/blacklight_helper_spec.rb +170 -285
  113. data/spec/helpers/catalog_helper_spec.rb +57 -96
  114. data/spec/helpers/facets_helper_spec.rb +130 -152
  115. data/spec/helpers/hash_as_hidden_fields_spec.rb +9 -15
  116. data/spec/helpers/render_constraints_helper_spec.rb +5 -5
  117. data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
  118. data/spec/lib/blacklight/routes_spec.rb +25 -0
  119. data/spec/lib/blacklight/solr/request_spec.rb +37 -0
  120. data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
  121. data/spec/lib/blacklight_configurable_spec.rb +16 -16
  122. data/spec/lib/blacklight_configuration_spec.rb +132 -132
  123. data/spec/lib/blacklight_email_spec.rb +4 -4
  124. data/spec/lib/blacklight_sms_spec.rb +4 -4
  125. data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
  126. data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
  127. data/spec/lib/blacklight_solr_document_spec.rb +36 -36
  128. data/spec/lib/blacklight_solr_response_spec.rb +43 -48
  129. data/spec/lib/blacklight_spec.rb +6 -14
  130. data/spec/lib/blacklight_user_spec.rb +5 -9
  131. data/spec/lib/facet_paginator_spec.rb +59 -51
  132. data/spec/lib/search_fields_spec.rb +13 -13
  133. data/spec/lib/solr_helper_spec.rb +258 -304
  134. data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
  135. data/spec/lib/utils_spec.rb +16 -46
  136. data/spec/models/bookmark_spec.rb +6 -7
  137. data/spec/models/record_mailer_spec.rb +16 -16
  138. data/spec/models/search_spec.rb +8 -8
  139. data/spec/models/solr_document_spec.rb +6 -77
  140. data/spec/routing/catalog_routing_spec.rb +16 -10
  141. data/spec/spec_helper.rb +7 -7
  142. data/spec/support/assert_difference.rb +2 -2
  143. data/spec/support/features.rb +0 -11
  144. data/spec/support/features/session_helpers.rb +3 -3
  145. data/spec/support/include_text.rb +2 -2
  146. data/spec/test_app_templates/Gemfile.extra +10 -2
  147. data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -18
  148. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +13 -13
  149. data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
  150. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
  151. data/spec/views/catalog/_facets.html.erb_spec.rb +13 -14
  152. data/spec/views/catalog/_index_default.erb_spec.rb +21 -21
  153. data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
  154. data/spec/views/catalog/_show_default.erb_spec.rb +21 -21
  155. data/spec/views/catalog/_show_sidebar.erb_spec.rb +7 -7
  156. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
  157. data/spec/views/catalog/index.atom.builder_spec.rb +29 -29
  158. data/spec/views/catalog/index.html.erb_spec.rb +6 -7
  159. data/tasks/blacklight.rake +8 -2
  160. metadata +84 -180
  161. data/app/assets/javascripts/blacklight/css_dropdowns.js +0 -10
  162. data/app/assets/javascripts/blacklight/facet_expand_contract.js +0 -41
  163. data/app/assets/javascripts/blacklight/lightbox_dialog.js +0 -70
  164. data/app/assets/javascripts/blacklight/select_submit.js +0 -27
  165. data/app/assets/javascripts/blacklight/zebra_stripe.js +0 -13
  166. data/app/assets/javascripts/improved-modal/bootstrap-modal.js +0 -355
  167. data/app/assets/javascripts/improved-modal/bootstrap-modalmanager.js +0 -370
  168. data/app/assets/stylesheets/blacklight/_bookmark.scss +0 -33
  169. data/app/assets/stylesheets/blacklight/_catalog.scss +0 -255
  170. data/app/assets/stylesheets/blacklight/_dropdown.scss +0 -57
  171. data/app/assets/stylesheets/blacklight/_facets.scss +0 -197
  172. data/app/assets/stylesheets/blacklight/_footer.scss +0 -0
  173. data/app/assets/stylesheets/blacklight/_header.scss +0 -53
  174. data/app/assets/stylesheets/blacklight/_layout.scss +0 -10
  175. data/app/assets/stylesheets/blacklight/_mixins.scss +0 -0
  176. data/app/assets/stylesheets/blacklight/_print.scss +0 -0
  177. data/app/assets/stylesheets/blacklight/_responsive.scss +0 -3
  178. data/app/assets/stylesheets/blacklight/_search_history.scss +0 -42
  179. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -49
  180. data/app/assets/stylesheets/blacklight/responsive_partials/_catalog.scss +0 -5
  181. data/app/assets/stylesheets/blacklight/responsive_partials/_facets.scss +0 -37
  182. data/app/assets/stylesheets/blacklight/responsive_partials/_header.scss +0 -30
  183. data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +0 -217
  184. data/app/helpers/blacklight/html_head_helper_behavior.rb +0 -118
  185. data/app/helpers/html_head_helper.rb +0 -3
  186. data/app/views/catalog/_bookmark_form.html.erb +0 -7
  187. data/app/views/catalog/_marc_view.html.erb +0 -32
  188. data/app/views/catalog/librarian_view.html.erb +0 -10
  189. data/config/routes.rb +0 -17
  190. data/doc/Atom-Responses.md +0 -90
  191. data/doc/Blacklight-3.0-Release-Notes-And-Upgrade-Guide.md +0 -107
  192. data/doc/Blacklight-3.2-Release-Notes-and-Upgrade-Guide.md +0 -191
  193. data/doc/Blacklight-3.3-release-notes-and-upgrade-guide.md +0 -37
  194. data/doc/Blacklight-3.4-release-notes-and-upgrade-guide.md +0 -27
  195. data/doc/Blacklight-3.5-release-notes-and-upgrade-guide.md +0 -44
  196. data/doc/Blacklight-3.6-release-notes-and-upgrade-guide.md +0 -25
  197. data/doc/Blacklight-3.7-release-notes-and-upgrade-guide.md +0 -80
  198. data/doc/Blacklight-3.8-release-notes-and-upgrade-guide.md +0 -11
  199. data/doc/Blacklight-4.0-release-notes-and-upgrade-guide.md +0 -135
  200. data/doc/Blacklight-4.1-release-notes-and-upgrade-guide.md +0 -17
  201. data/doc/Blacklight-4.2-release-notes-and-upgrade-guide.md +0 -25
  202. data/doc/Blacklight-4.3-release-notes-and-upgrade-guide.md +0 -21
  203. data/doc/Blacklight-4.4-release-notes-and-upgrade-guide.md +0 -41
  204. data/doc/Blacklight-Add-ons.md +0 -28
  205. data/doc/Blacklight-configuration.md +0 -411
  206. data/doc/Blacklight-on-Heroku.md +0 -135
  207. data/doc/Code4Lib-2014.md +0 -48
  208. data/doc/Community-principles.md +0 -44
  209. data/doc/Configuring-and-Customizing-Blacklight.md +0 -271
  210. data/doc/Configuring-rails-routes.md +0 -13
  211. data/doc/Contributing-to-Blacklight.md +0 -25
  212. data/doc/Examples.md +0 -94
  213. data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
  214. data/doc/FAQs.md +0 -1
  215. data/doc/Home.md +0 -80
  216. data/doc/How-to-release-a-version.md +0 -29
  217. data/doc/Indexing-your-data-into-solr.md +0 -32
  218. data/doc/Integration-with-Rails-Footnotes.md +0 -20
  219. data/doc/Internationalization.md +0 -32
  220. data/doc/JSON-API.md +0 -17
  221. data/doc/Pagination.md +0 -51
  222. data/doc/Providing-your-own-view-templates.md +0 -109
  223. data/doc/Quickstart.md +0 -115
  224. data/doc/README_SOLR.md +0 -245
  225. data/doc/Release-Notes-And-Upgrade-Guides.md +0 -20
  226. data/doc/Roadmap.md +0 -43
  227. data/doc/Sunspot-for-indexing.md +0 -46
  228. data/doc/Theming.md +0 -64
  229. data/doc/User-Authentication.md +0 -60
  230. data/doc/testing.md +0 -57
  231. data/lib/SolrMarc.jar +0 -0
  232. data/lib/blacklight/mash.rb +0 -19
  233. data/lib/blacklight/solr/document/marc.rb +0 -71
  234. data/lib/blacklight/solr/document/marc_export.rb +0 -590
  235. data/lib/generators/blacklight/marc_generator.rb +0 -66
  236. data/lib/generators/blacklight/templates/blacklight.scss +0 -4
  237. data/lib/generators/blacklight/templates/config/SolrMarc/config-test.properties +0 -37
  238. data/lib/generators/blacklight/templates/config/SolrMarc/config.properties +0 -37
  239. data/lib/generators/blacklight/templates/config/SolrMarc/index.properties +0 -97
  240. data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/dewey.bsh +0 -47
  241. data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/format.bsh +0 -126
  242. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/README_MAPS +0 -1
  243. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/callnumber_map.properties +0 -407
  244. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/composition_era_map.properties +0 -56
  245. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/country_map.properties +0 -379
  246. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/format_map.properties +0 -50
  247. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/instrument_map.properties +0 -101
  248. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/language_map.properties +0 -490
  249. data/lib/railties/solr_marc.rake +0 -162
  250. data/spec/data/test_data.utf8.mrc +0 -1
  251. data/spec/features/librarian_view_spec.rb +0 -13
  252. data/spec/helpers/html_head_helper_spec.rb +0 -164
  253. data/spec/lib/blacklight_solr_document_marc_spec.rb +0 -89
  254. data/spec/lib/marc_export_spec.rb +0 -746
  255. data/spec/lib/tasks/solr_marc_task_spec.rb +0 -60
  256. data/spec/requests/alternate_controller_spec.rb +0 -16
  257. data/spec/routing/routes_spec.rb +0 -20
  258. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  259. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +0 -49
  260. data/test_support/data/test_data.utf8.mrc +0 -1
@@ -0,0 +1,17 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ # example
4
+ # blacklight_for :catalog
5
+ # blacklight_for :catalog, :dashboard
6
+ # blacklight_for :catalog, except: [ :saved_searches, :feedback ]
7
+ # blacklight_for :catalog, only: [ :saved_searches, :solr_document ]
8
+ # blacklight_for :catalog, constraints: {id: /[0-9]+/ }
9
+ def blacklight_for(*resources)
10
+ options = resources.extract_options!
11
+ resources.map!(&:to_sym)
12
+
13
+ Blacklight::Routes.new(self, options.merge(resources: resources)).draw
14
+
15
+ end
16
+ end
17
+ end
@@ -1,40 +1,32 @@
1
1
  # -*- encoding : utf-8 -*-
2
+ require 'deprecation'
2
3
  module Blacklight
3
4
  class Routes
5
+ extend Deprecation
4
6
 
5
- # adds as class and instance level accessors, default_route_sets
6
- # returns an array of symbols for method names that define routes.
7
- # Order is important:. (e.g. /catalog/email precedes /catalog/:id)
8
- #
9
- # Add-ons that want to add routes into default routing might
10
- # monkey-patch Blacklight::Routes, say:
11
- #
12
- # module MyWidget::Routes
13
- # extend ActiveSupport::Concern
14
- # included do |klass|
15
- # klass.default_route_sets += [:widget_routing]
16
- # end
17
- # def widget_routing(primary_resource)
18
- # get "#{primary_resource}/widget", "#{primary_resource}#widget"
19
- # end
20
- # end
21
- # Blacklight::Routes.send(:include, MyWidget::Routes)
22
- class_attribute :default_route_sets
23
- self.default_route_sets = [:bookmarks, :search_history, :saved_searches, :catalog, :solr_document, :feedback]
7
+ attr_reader :resources
24
8
 
25
9
  def initialize(router, options)
26
10
  @router = router
27
11
  @options = options
12
+ @resources = options.fetch(:resources, [:catalog])
28
13
  end
29
14
 
30
15
  def draw
31
16
  route_sets.each do |r|
32
- self.send(r)
17
+ self.send(r, primary_resource)
18
+ end
19
+ resources.each do |r|
20
+ self.map_resource(r)
33
21
  end
34
22
  end
35
23
 
36
24
  protected
37
25
 
26
+ def primary_resource
27
+ resources.first
28
+ end
29
+
38
30
  def add_routes &blk
39
31
  @router.instance_exec(@options, &blk)
40
32
  end
@@ -43,15 +35,20 @@ module Blacklight
43
35
  (@options[:only] || default_route_sets) - (@options[:except] || [])
44
36
  end
45
37
 
38
+ def default_route_sets
39
+ # Order is important here. (e.g. /catalog/email precedes /catalog/:id)
40
+ [:bookmarks, :search_history, :saved_searches, :export, :solr_document, :feedback]
41
+ end
42
+
46
43
  module RouteSets
47
- def bookmarks
44
+ def bookmarks(_)
48
45
  add_routes do |options|
49
46
  delete "bookmarks/clear", :to => "bookmarks#clear", :as => "clear_bookmarks"
50
47
  resources :bookmarks
51
48
  end
52
49
  end
53
50
 
54
- def search_history
51
+ def search_history(_)
55
52
  add_routes do |options|
56
53
  get "search_history", :to => "search_history#index", :as => "search_history"
57
54
  delete "search_history/clear", :to => "search_history#clear", :as => "clear_search_history"
@@ -59,7 +56,7 @@ module Blacklight
59
56
  end
60
57
 
61
58
 
62
- def saved_searches
59
+ def saved_searches(_)
63
60
  add_routes do |options|
64
61
  delete "saved_searches/clear", :to => "saved_searches#clear", :as => "clear_saved_searches"
65
62
  get "saved_searches", :to => "saved_searches#index", :as => "saved_searches"
@@ -69,36 +66,45 @@ module Blacklight
69
66
  end
70
67
  end
71
68
 
72
- def catalog
73
- add_routes do |options|
74
- # Catalog stuff.
75
- get 'catalog/opensearch', :as => "opensearch_catalog"
76
- get 'catalog/citation', :as => "citation_catalog"
77
- get 'catalog/email', :as => "email_catalog"
78
- post 'catalog/email'
79
- get 'catalog/sms', :as => "sms_catalog"
80
- get 'catalog/endnote', :as => "endnote_catalog"
81
- get "catalog/facet/:id", :to => 'catalog#facet', :as => 'catalog_facet'
82
-
69
+ def catalog(_=nil)
70
+ Deprecation.warn(Blacklight::Routes, "Blacklight::Routes.catalog is deprecated and will be removed in Blacklight 6.0. Use Blacklight::Routes.map_resource(:catalog) instead.")
71
+ map_resource(:catalog)
72
+ end
83
73
 
84
- get "catalog", :to => 'catalog#index', :as => 'catalog_index'
74
+ def map_resource(key)
75
+ add_routes do |options|
76
+ get "#{key}/facet/:id", :to => "#{key}#facet", :as => "#{key}_facet"
77
+ get "#{key}", :to => "#{key}#index", :as => "#{key}_index"
78
+ end
79
+ end
85
80
 
86
- get 'catalog/:id/librarian_view', :to => "catalog#librarian_view", :as => "librarian_view_catalog"
81
+ def export(primary_resource)
82
+ add_routes do |options|
83
+ get "#{primary_resource}/opensearch", :as => "opensearch_#{primary_resource}"
84
+ get "#{primary_resource}/citation", :as => "citation_#{primary_resource}"
85
+ get "#{primary_resource}/email", :as => "email_#{primary_resource}"
86
+ post "#{primary_resource}/email"
87
+ get "#{primary_resource}/sms", :as => "sms_#{primary_resource}"
88
+ get "#{primary_resource}/endnote", :as => "endnote_#{primary_resource}"
87
89
  end
88
90
  end
89
91
 
90
- def solr_document
92
+ def solr_document(primary_resource)
91
93
  add_routes do |options|
92
- resources :solr_document, :path => 'catalog', :controller => 'catalog', :only => [:show, :update]
94
+
95
+ args = {only: [:show, :update]}
96
+ args[:constraints] = options[:constraints] if options[:constraints]
97
+
98
+ resources :solr_document, args.merge(path: primary_resource, controller: primary_resource)
93
99
 
94
100
  # :show and :update are for backwards-compatibility with catalog_url named routes
95
- resources :catalog, :only => [:show, :update]
101
+ resources primary_resource, args
96
102
  end
97
103
  end
98
104
 
99
105
 
100
106
  # Feedback
101
- def feedback
107
+ def feedback(_)
102
108
  add_routes do |options|
103
109
  get "feedback", :to => "feedback#show"
104
110
  get "feedback/complete", :to => "feedback#complete"
@@ -4,5 +4,6 @@ module Blacklight::Solr
4
4
  autoload :Facets, 'blacklight/solr/facets'
5
5
  autoload :FacetPaginator, 'blacklight/solr/facet_paginator'
6
6
  autoload :Document, 'blacklight/solr/document'
7
+ autoload :Request, 'blacklight/solr/request'
7
8
 
8
9
  end
@@ -16,11 +16,6 @@ require 'rsolr'
16
16
  #
17
17
 
18
18
  module Blacklight::Solr::Document
19
- extend Deprecation
20
- self.deprecation_horizon = 'Blacklight 5.x'
21
-
22
- autoload :Marc, 'blacklight/solr/document/marc'
23
- autoload :MarcExport, 'blacklight/solr/document/marc_export'
24
19
  autoload :DublinCore, 'blacklight/solr/document/dublin_core'
25
20
  autoload :Email, 'blacklight/solr/document/email'
26
21
  autoload :Sms, 'blacklight/solr/document/sms'
@@ -35,7 +30,7 @@ module Blacklight::Solr::Document
35
30
  included do
36
31
  extend ActiveModel::Naming
37
32
  include Blacklight::Solr::Document::Extensions
38
- end
33
+ end
39
34
 
40
35
  attr_reader :solr_response
41
36
 
@@ -59,7 +54,7 @@ module Blacklight::Solr::Document
59
54
  # Helper method to check if value/multi-values exist for a given key.
60
55
  # The value can be a string, or a RegExp
61
56
  # Multiple "values" can be given; only one needs to match.
62
- #
57
+ #
63
58
  # Example:
64
59
  # doc.has?(:location_facet)
65
60
  # doc.has?(:location_facet, 'Clemons')
@@ -83,7 +78,7 @@ module Blacklight::Solr::Document
83
78
 
84
79
  def has_highlight_field? k
85
80
  return false if @solr_response['highlighting'].blank? or @solr_response['highlighting'][self.id].blank?
86
-
81
+
87
82
  @solr_response['highlighting'][self.id].key? k.to_s
88
83
  end
89
84
 
@@ -128,66 +123,50 @@ module Blacklight::Solr::Document
128
123
  'catalog/document'
129
124
  end
130
125
 
131
-
126
+
132
127
  # Returns a hash keyed by semantic tokens (see ExtendableClassMethods#semantic_fields), value is an array of
133
128
  # strings. (Array to handle multi-value fields). If no value(s)
134
- # available, empty array is returned.
129
+ # available, empty array is returned.
135
130
  #
136
131
  # Default implementation here uses ExtendableClassMethods#semantic_fields
137
- # to just take values from Solr stored fields.
132
+ # to just take values from Solr stored fields.
138
133
  # Extensions can over-ride this method to provide better/different lookup,
139
134
  # but extensions should call super and modify hash returned, to avoid
140
- # unintentionally erasing values provided by other extensions.
135
+ # unintentionally erasing values provided by other extensions.
141
136
  def to_semantic_values
142
137
  unless @semantic_value_hash
143
- @semantic_value_hash = Hash.new([]) # default to empty array
138
+ @semantic_value_hash = Hash.new([]) # default to empty array
144
139
  self.class.field_semantics.each_pair do |key, solr_field|
145
140
  value = self[solr_field]
146
141
  # Make single and multi-values all arrays, so clients
147
142
  # don't have to know.
148
143
  unless value.nil?
149
- value = [value] unless value.kind_of?(Array)
144
+ value = [value] unless value.kind_of?(Array)
150
145
  @semantic_value_hash[key] = value
151
146
  end
152
147
  end
153
148
  end
154
149
  return @semantic_value_hash
155
150
  end
156
-
157
- def to_model
158
- self
159
- end
160
-
161
- def persisted?
162
- true
163
- end
164
-
165
-
151
+
152
+
166
153
  # Certain class-level methods needed for the document-specific
167
154
  # extendability architecture
168
155
  module ClassMethods
169
156
 
170
157
  attr_writer :unique_key
171
158
  def unique_key
172
- # XXX Blacklight.config[:unique_key] should be deprecated soon
173
- if Blacklight.respond_to?(:config) and Blacklight.config[:unique_key]
174
- Deprecation.warn(self, "Setting the unique key using Blacklight.config[:unique_key] has been deprecated. Use the SolrDocument.unique_key= setter instead")
175
- @unique_key ||= Blacklight.config[:unique_key]
176
- end
177
- @unique_key ||= 'id'
178
-
179
- @unique_key
159
+ @unique_key ||= 'id'
180
160
  end
181
161
 
182
162
  def connection
183
- Deprecation.warn(self, "Document.connection is deprecated and will be removed in Blacklight 5.0")
184
- @connection ||= Blacklight.solr
163
+ @connection ||= Blacklight.solr
185
164
  end
186
-
165
+
187
166
  # Returns array of hashes of registered extensions. Each hash
188
167
  # has a :module_obj key and a :condition_proc key. Usually this
189
168
  # method is only used internally in #apply_extensions, but if you
190
-
169
+
191
170
  # Class-level method for accessing/setting semantic mappings
192
171
  # for solr stored fields. Can be set by local app, key is
193
172
  # a symbol for a semantic, value is a solr _stored_ field.
@@ -197,13 +176,13 @@ module Blacklight::Solr::Document
197
176
  #
198
177
  # Currently documented semantic tokens, not all may be
199
178
  # used by core BL, but some may be used by plugins present
200
- # or future.
201
- # :title, :author, :year, :language => User-presentable strings.
179
+ # or future.
180
+ # :title, :author, :year, :language => User-presentable strings.
202
181
  def field_semantics
203
182
  @field_semantics ||= {}
204
- end
183
+ end
205
184
  end
206
-
207
-
208
-
185
+
186
+
187
+
209
188
  end
@@ -12,10 +12,6 @@ module Blacklight::Solr
12
12
  # so we cannot know how many "pages" there are.
13
13
  #
14
14
  class FacetPaginator
15
- extend Deprecation
16
-
17
- self.deprecation_horizon = 'blacklight version 6.0.0'
18
-
19
15
  # What request keys will we use for the parameters need. Need to
20
16
  # make sure they do NOT conflict with catalog/index request params,
21
17
  # and need to make them accessible in a list so we can easily
@@ -25,7 +21,7 @@ module Blacklight::Solr
25
21
  class << self; attr_accessor :request_keys end # create a class method
26
22
  def request_keys ; self.class.request_keys ; end # shortcut
27
23
 
28
- attr_reader :total_count, :items, :offset, :limit, :sort
24
+ attr_reader :total, :items, :offset, :limit, :sort
29
25
 
30
26
  # all_facet_values is a list of facet value objects returned by solr,
31
27
  # asking solr for n+1 facet values.
@@ -37,74 +33,54 @@ module Blacklight::Solr
37
33
  def initialize(all_facet_values, arguments)
38
34
  # to_s.to_i will conveniently default to 0 if nil
39
35
  @offset = arguments[:offset].to_s.to_i
40
- @limit = arguments[:limit].to_s.to_i
36
+ @limit = arguments[:limit].to_s.to_i if arguments[:limit]
41
37
  # count is solr's default
42
38
  @sort = arguments[:sort] || "count"
43
- @total_count = all_facet_values.size
44
- @items = items_for_limit(all_facet_values)
45
- end
46
-
47
- alias_method :total, :total_count
48
-
49
- def prev_page
50
- current_page - 1 unless first_page?
51
- end
52
-
53
- def current_page
54
- if limit == 0 #check for divide by zero
55
- 1
56
- else
57
- @offset / limit + 1
39
+
40
+ total = all_facet_values.size
41
+ if (@limit)
42
+ @items = all_facet_values.slice(0, @limit)
43
+ @has_next = total > @limit
44
+ @has_previous = @offset > 0
45
+ else # nil limit
46
+ @items = all_facet_values
47
+ @has_next = false
48
+ @has_previous = false
58
49
  end
59
50
  end
60
51
 
61
- def next_page
62
- current_page + 1 unless last_page?
52
+ def current_page
53
+ 1 + @offset/@limit
63
54
  end
64
55
 
65
- #@deprecated
66
56
  def has_next?
67
- !last_page?
57
+ @has_next
68
58
  end
69
- deprecation_deprecate :has_next?
70
59
 
71
- #@deprecated
72
60
  def has_previous?
73
- !first_page?
61
+ @has_previous
74
62
  end
75
- deprecation_deprecate :has_next?
76
63
 
77
64
  def last_page?
78
- current_page >= total_pages
65
+ !has_next?
79
66
  end
80
67
 
81
68
  def first_page?
82
- current_page == 1
69
+ !has_previous?
83
70
  end
84
71
 
85
- def total_pages
86
- if limit == 0 #check for divide by zero
87
- 1
88
- else
89
- (total_count.to_f / limit).ceil
90
- end
91
- end
92
-
93
- # Pass in a desired solr facet solr key ('count' or 'index', see
94
- # http://wiki.apache.org/solr/SimpleFacetParameters#facet.limit
95
- # under facet.sort ), and your current request params.
96
- # Get back params suitable to passing to an ActionHelper method for
97
- # creating a url, to resort by that method.
98
- def params_for_resort_url(sort_method, params)
99
- # When resorting, we've got to reset the offset to start at beginning,
100
- # no way to make it make sense otherwise.
101
- params.merge(request_keys[:sort] => sort_method, request_keys[:page] => nil)
102
- end
103
72
 
104
- private
105
- # setting limit to 0 implies no limit
106
- def items_for_limit(values)
107
- limit != 0 ? values.slice(offset, limit) : values
108
- end
73
+ # Pass in a desired solr facet solr key ('count' or 'index', see
74
+ # http://wiki.apache.org/solr/SimpleFacetParameters#facet.limit
75
+ # under facet.sort ), and your current request params.
76
+ # Get back params suitable to passing to an ActionHelper method for
77
+ # creating a url, to resort by that method.
78
+ def params_for_resort_url(sort_method, params)
79
+ # When resorting, we've got to reset the offset to start at beginning,
80
+ # no way to make it make sense otherwise.
81
+ return params.merge(request_keys[:sort] => sort_method, request_keys[:page] => nil)
82
+ end
83
+
109
84
  end
85
+
110
86
  end
@@ -0,0 +1,45 @@
1
+ class Blacklight::Solr::InvalidParameter < ArgumentError; end
2
+
3
+ class Blacklight::Solr::Request < HashWithIndifferentAccess
4
+
5
+ SINGULAR_KEYS = %W{ facet fl q qt rows start spellcheck spellcheck.q sort
6
+ per_page wt hl group defType}
7
+ ARRAY_KEYS = %W{facet.field facet.query facet.pivot fq hl.fl }
8
+
9
+ def initialize(constructor = {})
10
+ if constructor.is_a?(Hash)
11
+ super()
12
+ update(constructor)
13
+ else
14
+ super(constructor)
15
+ end
16
+ ARRAY_KEYS.each do |key|
17
+ self[key] ||= []
18
+ end
19
+ end
20
+
21
+ def append_filter_query(query)
22
+ self['fq'] << query
23
+ end
24
+
25
+ def append_facet_fields(values)
26
+ self['facet.field'] += Array(values)
27
+ end
28
+
29
+ def append_facet_query(values)
30
+ self['facet.query'] += Array(values)
31
+ end
32
+
33
+ def append_facet_pivot(query)
34
+ self['facet.pivot'] << query
35
+ end
36
+
37
+ def append_highlight_field(query)
38
+ self['hl.fl'] << query
39
+ end
40
+
41
+ def to_hash
42
+ reject {|key, value| ARRAY_KEYS.include?(key) && value.empty?}
43
+ end
44
+
45
+ end