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.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +22 -12
- data/Gemfile +3 -40
- data/LICENSE +1 -2
- data/README.md +1 -2
- data/Rakefile +0 -4
- data/VERSION +1 -1
- data/app/assets/images/blacklight/logo.png +0 -0
- data/app/assets/javascripts/blacklight/ajax_modal.js +190 -0
- data/app/assets/javascripts/blacklight/blacklight.js +7 -17
- data/app/assets/javascripts/blacklight/checkbox_submit.js +1 -1
- data/app/assets/stylesheets/blacklight/{_blacklight_base.scss → _blacklight_base.css.scss} +0 -21
- data/app/assets/stylesheets/blacklight/_bookmark.css.scss +4 -0
- data/app/assets/stylesheets/blacklight/_catalog.css.scss +192 -0
- data/app/assets/stylesheets/blacklight/_facets.css.scss +141 -0
- data/app/assets/stylesheets/blacklight/{_group.scss → _group.css.scss} +1 -1
- data/app/assets/stylesheets/blacklight/_header.css.scss +44 -0
- data/app/assets/stylesheets/blacklight/_layout.css.scss +5 -0
- data/app/assets/stylesheets/blacklight/{_modal.scss → _modal.css.scss} +7 -7
- data/app/assets/stylesheets/blacklight/_search_history.css.scss +20 -0
- data/app/assets/stylesheets/blacklight/{blacklight.scss → blacklight.css.scss} +0 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +14 -0
- data/app/controllers/bookmarks_controller.rb +0 -4
- data/app/controllers/feedback_controller.rb +0 -4
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +45 -155
- data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -41
- data/app/helpers/blacklight/facets_helper_behavior.rb +20 -43
- data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +2 -9
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -14
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +6 -6
- data/app/views/_flash_msg.html.erb +9 -2
- data/app/views/_user_util_links.html.erb +29 -15
- data/app/views/bookmarks/_tools.html.erb +4 -7
- data/app/views/bookmarks/index.html.erb +3 -2
- data/app/views/catalog/_citation.html.erb +1 -1
- data/app/views/catalog/_constraints.html.erb +1 -1
- data/app/views/catalog/_constraints_element.html.erb +12 -8
- data/app/views/catalog/_did_you_mean.html.erb +2 -2
- data/app/views/catalog/_document_header.html.erb +3 -3
- data/app/views/catalog/_email_form.html.erb +10 -10
- data/app/views/catalog/_facet_layout.html.erb +11 -3
- data/app/views/catalog/_facet_limit.html.erb +7 -7
- data/app/views/catalog/_facet_pagination.html.erb +8 -7
- data/app/views/catalog/_facet_pivot.html.erb +3 -1
- data/app/views/catalog/_facets.html.erb +12 -9
- data/app/views/catalog/_paginate_compact.html.erb +1 -7
- data/app/views/catalog/_per_page_widget.html.erb +5 -8
- data/app/views/catalog/_previous_next_doc.html.erb +11 -9
- data/app/views/catalog/_refworks_form.html.erb +3 -4
- data/app/views/catalog/_results_pagination.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +16 -14
- data/app/views/catalog/_show_sidebar.html.erb +7 -9
- data/app/views/catalog/_show_tools.html.erb +13 -7
- data/app/views/catalog/_sms_form.html.erb +8 -8
- data/app/views/catalog/_sort_and_per_page.html.erb +4 -6
- data/app/views/catalog/_sort_widget.html.erb +5 -6
- data/app/views/catalog/email.html.erb +1 -1
- data/app/views/catalog/facet.html.erb +2 -8
- data/app/views/catalog/index.html.erb +11 -6
- data/app/views/catalog/show.html.erb +5 -5
- data/app/views/catalog/sms.html.erb +1 -1
- data/app/views/catalog/sms_sent.html.erb +1 -1
- data/app/views/feedback/complete.html.erb +2 -2
- data/app/views/feedback/show.html.erb +1 -1
- data/app/views/kaminari/blacklight/_paginator.html.erb +1 -1
- data/app/views/kaminari/blacklight_compact/_paginator.html.erb +25 -5
- data/app/views/layouts/blacklight.html.erb +23 -23
- data/app/views/saved_searches/index.html.erb +2 -2
- data/app/views/search_history/index.html.erb +5 -7
- data/app/views/shared/_header_navbar.html.erb +23 -23
- data/blacklight.gemspec +10 -13
- data/config/locales/blacklight.en.yml +1 -12
- data/config/locales/blacklight.fr.yml +1 -12
- data/gemfiles/rails3.gemfile +21 -0
- data/gemfiles/rails4.gemfile +20 -0
- data/lib/blacklight.rb +0 -8
- data/lib/blacklight/base.rb +0 -2
- data/lib/blacklight/catalog.rb +6 -32
- data/lib/blacklight/catalog/search_context.rb +8 -48
- data/lib/blacklight/configurable.rb +2 -1
- data/lib/blacklight/configuration.rb +1 -2
- data/lib/blacklight/configuration/facet_field.rb +0 -2
- data/lib/blacklight/engine.rb +3 -3
- data/lib/blacklight/legacy_controller_methods.rb +1 -64
- data/lib/blacklight/rails/routes.rb +17 -0
- data/lib/blacklight/routes.rb +46 -40
- data/lib/blacklight/solr.rb +1 -0
- data/lib/blacklight/solr/document.rb +21 -42
- data/lib/blacklight/solr/facet_paginator.rb +30 -54
- data/lib/blacklight/solr/request.rb +45 -0
- data/lib/blacklight/solr_helper.rb +16 -53
- data/lib/blacklight/solr_response.rb +0 -6
- data/lib/blacklight/user.rb +2 -7
- data/lib/blacklight/utils.rb +1 -9
- data/lib/generators/blacklight/assets_generator.rb +0 -14
- data/lib/generators/blacklight/blacklight_generator.rb +17 -14
- data/lib/generators/blacklight/templates/blacklight.css.scss +3 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +4 -1
- data/lib/railties/blacklight.rake +3 -1
- data/solr/sample_solr_documents.yml +641 -0
- data/spec/controllers/application_controller_spec.rb +5 -21
- data/spec/controllers/bookmarks_controller_spec.rb +11 -11
- data/spec/controllers/catalog_controller_spec.rb +122 -119
- data/spec/controllers/search_history_controller_spec.rb +8 -8
- data/spec/features/alternate_controller_spec.rb +5 -5
- data/spec/features/facets_spec.rb +9 -0
- data/spec/features/record_view_spec.rb +1 -1
- data/spec/features/search_filters_spec.rb +97 -41
- data/spec/features/search_results_spec.rb +14 -17
- data/spec/features/search_sort_spec.rb +1 -1
- data/spec/helpers/blacklight_helper_spec.rb +170 -285
- data/spec/helpers/catalog_helper_spec.rb +57 -96
- data/spec/helpers/facets_helper_spec.rb +130 -152
- data/spec/helpers/hash_as_hidden_fields_spec.rb +9 -15
- data/spec/helpers/render_constraints_helper_spec.rb +5 -5
- data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
- data/spec/lib/blacklight/routes_spec.rb +25 -0
- data/spec/lib/blacklight/solr/request_spec.rb +37 -0
- data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
- data/spec/lib/blacklight_configurable_spec.rb +16 -16
- data/spec/lib/blacklight_configuration_spec.rb +132 -132
- data/spec/lib/blacklight_email_spec.rb +4 -4
- data/spec/lib/blacklight_sms_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
- data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
- data/spec/lib/blacklight_solr_document_spec.rb +36 -36
- data/spec/lib/blacklight_solr_response_spec.rb +43 -48
- data/spec/lib/blacklight_spec.rb +6 -14
- data/spec/lib/blacklight_user_spec.rb +5 -9
- data/spec/lib/facet_paginator_spec.rb +59 -51
- data/spec/lib/search_fields_spec.rb +13 -13
- data/spec/lib/solr_helper_spec.rb +258 -304
- data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
- data/spec/lib/utils_spec.rb +16 -46
- data/spec/models/bookmark_spec.rb +6 -7
- data/spec/models/record_mailer_spec.rb +16 -16
- data/spec/models/search_spec.rb +8 -8
- data/spec/models/solr_document_spec.rb +6 -77
- data/spec/routing/catalog_routing_spec.rb +16 -10
- data/spec/spec_helper.rb +7 -7
- data/spec/support/assert_difference.rb +2 -2
- data/spec/support/features.rb +0 -11
- data/spec/support/features/session_helpers.rb +3 -3
- data/spec/support/include_text.rb +2 -2
- data/spec/test_app_templates/Gemfile.extra +10 -2
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -18
- data/spec/views/catalog/_constraints_element.html.erb_spec.rb +13 -13
- data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
- data/spec/views/catalog/_facets.html.erb_spec.rb +13 -14
- data/spec/views/catalog/_index_default.erb_spec.rb +21 -21
- data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
- data/spec/views/catalog/_show_default.erb_spec.rb +21 -21
- data/spec/views/catalog/_show_sidebar.erb_spec.rb +7 -7
- data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
- data/spec/views/catalog/index.atom.builder_spec.rb +29 -29
- data/spec/views/catalog/index.html.erb_spec.rb +6 -7
- data/tasks/blacklight.rake +8 -2
- metadata +84 -180
- data/app/assets/javascripts/blacklight/css_dropdowns.js +0 -10
- data/app/assets/javascripts/blacklight/facet_expand_contract.js +0 -41
- data/app/assets/javascripts/blacklight/lightbox_dialog.js +0 -70
- data/app/assets/javascripts/blacklight/select_submit.js +0 -27
- data/app/assets/javascripts/blacklight/zebra_stripe.js +0 -13
- data/app/assets/javascripts/improved-modal/bootstrap-modal.js +0 -355
- data/app/assets/javascripts/improved-modal/bootstrap-modalmanager.js +0 -370
- data/app/assets/stylesheets/blacklight/_bookmark.scss +0 -33
- data/app/assets/stylesheets/blacklight/_catalog.scss +0 -255
- data/app/assets/stylesheets/blacklight/_dropdown.scss +0 -57
- data/app/assets/stylesheets/blacklight/_facets.scss +0 -197
- data/app/assets/stylesheets/blacklight/_footer.scss +0 -0
- data/app/assets/stylesheets/blacklight/_header.scss +0 -53
- data/app/assets/stylesheets/blacklight/_layout.scss +0 -10
- data/app/assets/stylesheets/blacklight/_mixins.scss +0 -0
- data/app/assets/stylesheets/blacklight/_print.scss +0 -0
- data/app/assets/stylesheets/blacklight/_responsive.scss +0 -3
- data/app/assets/stylesheets/blacklight/_search_history.scss +0 -42
- data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -49
- data/app/assets/stylesheets/blacklight/responsive_partials/_catalog.scss +0 -5
- data/app/assets/stylesheets/blacklight/responsive_partials/_facets.scss +0 -37
- data/app/assets/stylesheets/blacklight/responsive_partials/_header.scss +0 -30
- data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +0 -217
- data/app/helpers/blacklight/html_head_helper_behavior.rb +0 -118
- data/app/helpers/html_head_helper.rb +0 -3
- data/app/views/catalog/_bookmark_form.html.erb +0 -7
- data/app/views/catalog/_marc_view.html.erb +0 -32
- data/app/views/catalog/librarian_view.html.erb +0 -10
- data/config/routes.rb +0 -17
- data/doc/Atom-Responses.md +0 -90
- data/doc/Blacklight-3.0-Release-Notes-And-Upgrade-Guide.md +0 -107
- data/doc/Blacklight-3.2-Release-Notes-and-Upgrade-Guide.md +0 -191
- data/doc/Blacklight-3.3-release-notes-and-upgrade-guide.md +0 -37
- data/doc/Blacklight-3.4-release-notes-and-upgrade-guide.md +0 -27
- data/doc/Blacklight-3.5-release-notes-and-upgrade-guide.md +0 -44
- data/doc/Blacklight-3.6-release-notes-and-upgrade-guide.md +0 -25
- data/doc/Blacklight-3.7-release-notes-and-upgrade-guide.md +0 -80
- data/doc/Blacklight-3.8-release-notes-and-upgrade-guide.md +0 -11
- data/doc/Blacklight-4.0-release-notes-and-upgrade-guide.md +0 -135
- data/doc/Blacklight-4.1-release-notes-and-upgrade-guide.md +0 -17
- data/doc/Blacklight-4.2-release-notes-and-upgrade-guide.md +0 -25
- data/doc/Blacklight-4.3-release-notes-and-upgrade-guide.md +0 -21
- data/doc/Blacklight-4.4-release-notes-and-upgrade-guide.md +0 -41
- data/doc/Blacklight-Add-ons.md +0 -28
- data/doc/Blacklight-configuration.md +0 -411
- data/doc/Blacklight-on-Heroku.md +0 -135
- data/doc/Code4Lib-2014.md +0 -48
- data/doc/Community-principles.md +0 -44
- data/doc/Configuring-and-Customizing-Blacklight.md +0 -271
- data/doc/Configuring-rails-routes.md +0 -13
- data/doc/Contributing-to-Blacklight.md +0 -25
- data/doc/Examples.md +0 -94
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
- data/doc/FAQs.md +0 -1
- data/doc/Home.md +0 -80
- data/doc/How-to-release-a-version.md +0 -29
- data/doc/Indexing-your-data-into-solr.md +0 -32
- data/doc/Integration-with-Rails-Footnotes.md +0 -20
- data/doc/Internationalization.md +0 -32
- data/doc/JSON-API.md +0 -17
- data/doc/Pagination.md +0 -51
- data/doc/Providing-your-own-view-templates.md +0 -109
- data/doc/Quickstart.md +0 -115
- data/doc/README_SOLR.md +0 -245
- data/doc/Release-Notes-And-Upgrade-Guides.md +0 -20
- data/doc/Roadmap.md +0 -43
- data/doc/Sunspot-for-indexing.md +0 -46
- data/doc/Theming.md +0 -64
- data/doc/User-Authentication.md +0 -60
- data/doc/testing.md +0 -57
- data/lib/SolrMarc.jar +0 -0
- data/lib/blacklight/mash.rb +0 -19
- data/lib/blacklight/solr/document/marc.rb +0 -71
- data/lib/blacklight/solr/document/marc_export.rb +0 -590
- data/lib/generators/blacklight/marc_generator.rb +0 -66
- data/lib/generators/blacklight/templates/blacklight.scss +0 -4
- data/lib/generators/blacklight/templates/config/SolrMarc/config-test.properties +0 -37
- data/lib/generators/blacklight/templates/config/SolrMarc/config.properties +0 -37
- data/lib/generators/blacklight/templates/config/SolrMarc/index.properties +0 -97
- data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/dewey.bsh +0 -47
- data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/format.bsh +0 -126
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/README_MAPS +0 -1
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/callnumber_map.properties +0 -407
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/composition_era_map.properties +0 -56
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/country_map.properties +0 -379
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/format_map.properties +0 -50
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/instrument_map.properties +0 -101
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/language_map.properties +0 -490
- data/lib/railties/solr_marc.rake +0 -162
- data/spec/data/test_data.utf8.mrc +0 -1
- data/spec/features/librarian_view_spec.rb +0 -13
- data/spec/helpers/html_head_helper_spec.rb +0 -164
- data/spec/lib/blacklight_solr_document_marc_spec.rb +0 -89
- data/spec/lib/marc_export_spec.rb +0 -746
- data/spec/lib/tasks/solr_marc_task_spec.rb +0 -60
- data/spec/requests/alternate_controller_spec.rb +0 -16
- data/spec/routing/routes_spec.rb +0 -20
- data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
- data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +0 -49
- 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
|
data/lib/blacklight/routes.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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"
|
data/lib/blacklight/solr.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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 :
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
62
|
-
|
52
|
+
def current_page
|
53
|
+
1 + @offset/@limit
|
63
54
|
end
|
64
55
|
|
65
|
-
#@deprecated
|
66
56
|
def has_next?
|
67
|
-
|
57
|
+
@has_next
|
68
58
|
end
|
69
|
-
deprecation_deprecate :has_next?
|
70
59
|
|
71
|
-
#@deprecated
|
72
60
|
def has_previous?
|
73
|
-
|
61
|
+
@has_previous
|
74
62
|
end
|
75
|
-
deprecation_deprecate :has_next?
|
76
63
|
|
77
64
|
def last_page?
|
78
|
-
|
65
|
+
!has_next?
|
79
66
|
end
|
80
67
|
|
81
68
|
def first_page?
|
82
|
-
|
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
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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
|