blacklight 5.19.2 → 6.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/.hound.yml +2 -0
  4. data/.jshintrc +67 -0
  5. data/.rubocop_hound.yml +4 -0
  6. data/.travis.yml +11 -8
  7. data/Gemfile +11 -21
  8. data/Rakefile +1 -0
  9. data/VERSION +1 -1
  10. data/app/assets/javascripts/blacklight/blacklight.js +1 -0
  11. data/app/assets/javascripts/blacklight/core.js +5 -19
  12. data/app/assets/javascripts/blacklight/facet_load.js +23 -0
  13. data/app/assets/stylesheets/blacklight/_balanced_list.scss +18 -0
  14. data/app/assets/stylesheets/blacklight/_blacklight_base.scss +5 -1
  15. data/app/assets/stylesheets/blacklight/_bookmark.scss +14 -6
  16. data/app/assets/stylesheets/blacklight/_constraints.scss +52 -0
  17. data/app/assets/stylesheets/blacklight/_controls.scss +61 -0
  18. data/app/assets/stylesheets/blacklight/_facets.scss +31 -4
  19. data/app/assets/stylesheets/blacklight/_header.scss +17 -3
  20. data/app/assets/stylesheets/blacklight/_pagination.scss +21 -0
  21. data/app/assets/stylesheets/blacklight/_search_results.scss +28 -0
  22. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -3
  23. data/app/controllers/concerns/blacklight/bookmarks.rb +1 -1
  24. data/app/controllers/concerns/blacklight/catalog.rb +3 -45
  25. data/app/controllers/concerns/blacklight/controller.rb +29 -18
  26. data/app/controllers/concerns/blacklight/default_component_configuration.rb +4 -3
  27. data/app/controllers/concerns/blacklight/facet.rb +1 -0
  28. data/app/controllers/concerns/blacklight/request_builders.rb +4 -107
  29. data/app/controllers/concerns/blacklight/search_fields.rb +1 -1
  30. data/app/controllers/concerns/blacklight/search_helper.rb +8 -160
  31. data/app/controllers/saved_searches_controller.rb +1 -1
  32. data/app/controllers/search_history_controller.rb +18 -1
  33. data/app/helpers/blacklight/blacklight_helper_behavior.rb +17 -85
  34. data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -48
  35. data/app/helpers/blacklight/component_helper_behavior.rb +9 -2
  36. data/app/helpers/blacklight/configuration_helper_behavior.rb +3 -43
  37. data/app/helpers/blacklight/facets_helper_behavior.rb +10 -6
  38. data/app/helpers/blacklight/layout_helper_behavior.rb +0 -8
  39. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -10
  40. data/app/helpers/blacklight/render_partials_helper.rb +1 -3
  41. data/app/helpers/blacklight/url_helper_behavior.rb +15 -187
  42. data/{lib → app/models}/blacklight/abstract_repository.rb +0 -15
  43. data/{lib → app/models}/blacklight/configuration.rb +22 -59
  44. data/app/models/blacklight/configuration/context.rb +47 -0
  45. data/{lib → app/models}/blacklight/configuration/facet_field.rb +1 -0
  46. data/{lib → app/models}/blacklight/configuration/field.rb +0 -0
  47. data/{lib → app/models}/blacklight/configuration/fields.rb +2 -6
  48. data/{lib → app/models}/blacklight/configuration/search_field.rb +0 -0
  49. data/{lib → app/models}/blacklight/configuration/solr_field.rb +0 -0
  50. data/{lib → app/models}/blacklight/configuration/sort_field.rb +0 -0
  51. data/{lib → app/models}/blacklight/configuration/tool_config.rb +0 -0
  52. data/app/models/blacklight/configuration/view_config.rb +9 -0
  53. data/app/models/blacklight/facet_paginator.rb +14 -28
  54. data/{lib → app/models}/blacklight/search_builder.rb +16 -24
  55. data/app/models/blacklight/solr/facet_paginator.rb +6 -2
  56. data/{lib → app/models}/blacklight/solr/repository.rb +0 -21
  57. data/{lib → app/models}/blacklight/solr/request.rb +0 -0
  58. data/{lib → app/models}/blacklight/solr/response.rb +9 -8
  59. data/{lib → app/models}/blacklight/solr/response/facets.rb +37 -29
  60. data/{lib → app/models}/blacklight/solr/response/group.rb +0 -0
  61. data/{lib → app/models}/blacklight/solr/response/group_response.rb +0 -0
  62. data/{lib → app/models}/blacklight/solr/response/more_like_this.rb +0 -0
  63. data/{lib → app/models}/blacklight/solr/response/pagination_methods.rb +0 -0
  64. data/{lib → app/models}/blacklight/solr/response/response.rb +0 -0
  65. data/{lib → app/models}/blacklight/solr/response/spelling.rb +2 -1
  66. data/{lib → app/models}/blacklight/solr/search_builder.rb +0 -0
  67. data/app/models/concerns/blacklight/document.rb +11 -27
  68. data/app/models/concerns/blacklight/document/active_model_shim.rb +8 -0
  69. data/app/models/concerns/blacklight/solr/document.rb +8 -3
  70. data/{lib → app/models/concerns}/blacklight/solr/search_builder_behavior.rb +21 -33
  71. data/app/models/concerns/blacklight/user.rb +0 -9
  72. data/app/models/record_mailer.rb +0 -1
  73. data/app/presenters/blacklight/document_presenter.rb +23 -13
  74. data/app/views/blacklight/nav/_saved_searches.html.erb +1 -1
  75. data/app/views/blacklight/nav/_search_history.html.erb +1 -1
  76. data/app/views/bookmarks/_tools.html.erb +1 -2
  77. data/app/views/bookmarks/index.html.erb +2 -2
  78. data/app/views/catalog/_document_default.atom.builder +4 -2
  79. data/app/views/catalog/_facet_index_navigation.html.erb +9 -0
  80. data/app/views/catalog/_facet_layout.html.erb +2 -3
  81. data/app/views/catalog/_facet_pagination.html.erb +19 -21
  82. data/app/views/catalog/_facets.html.erb +2 -3
  83. data/app/views/catalog/_home_text.html.erb +2 -3
  84. data/app/views/catalog/_index_header_default.html.erb +2 -2
  85. data/app/views/catalog/_per_page_widget.html.erb +1 -1
  86. data/app/views/catalog/_search_form.html.erb +21 -18
  87. data/app/views/catalog/_sort_widget.html.erb +1 -1
  88. data/app/views/catalog/_zero_results.html.erb +2 -2
  89. data/app/views/catalog/facet.html.erb +3 -0
  90. data/app/views/catalog/index.atom.builder +1 -1
  91. data/app/views/layouts/blacklight.html.erb +2 -2
  92. data/app/views/saved_searches/index.html.erb +6 -7
  93. data/app/views/search_history/index.html.erb +5 -5
  94. data/app/views/shared/_header_navbar.html.erb +2 -2
  95. data/blacklight.gemspec +5 -5
  96. data/config/locales/blacklight.de.yml +1 -4
  97. data/config/locales/blacklight.en.yml +2 -7
  98. data/config/locales/blacklight.es.yml +1 -4
  99. data/config/locales/blacklight.fr.yml +1 -4
  100. data/config/locales/blacklight.it.yml +1 -4
  101. data/config/locales/blacklight.pt-BR.yml +1 -4
  102. data/config/routes.rb +9 -0
  103. data/db/migrate/20140202020201_create_searches.rb +1 -1
  104. data/db/migrate/20140202020202_create_bookmarks.rb +1 -1
  105. data/lib/blacklight.rb +5 -82
  106. data/lib/blacklight/engine.rb +0 -5
  107. data/lib/blacklight/parameters.rb +13 -0
  108. data/lib/blacklight/path.rb +143 -0
  109. data/lib/blacklight/routes.rb +3 -134
  110. data/lib/blacklight/routes/exportable.rb +25 -0
  111. data/lib/blacklight/routes/searchable.rb +20 -0
  112. data/lib/blacklight/solr.rb +1 -9
  113. data/lib/blacklight/utils.rb +2 -44
  114. data/lib/generators/blacklight/controller_generator.rb +7 -4
  115. data/lib/generators/blacklight/install_generator.rb +16 -9
  116. data/lib/generators/blacklight/models_generator.rb +18 -0
  117. data/lib/generators/blacklight/templates/catalog_controller.rb +85 -91
  118. data/lib/generators/blacklight/test_support_generator.rb +22 -15
  119. data/solr/conf/_rest_managed.json +3 -0
  120. data/solr/conf/admin-extra.html +31 -0
  121. data/solr/conf/elevate.xml +36 -0
  122. data/solr/conf/mapping-ISOLatin1Accent.txt +246 -0
  123. data/solr/conf/protwords.txt +21 -0
  124. data/solr/conf/schema.xml +621 -0
  125. data/solr/conf/scripts.conf +24 -0
  126. data/solr/conf/solrconfig.xml +391 -0
  127. data/solr/conf/spellings.txt +2 -0
  128. data/solr/conf/stopwords.txt +58 -0
  129. data/solr/conf/stopwords_en.txt +58 -0
  130. data/solr/conf/synonyms.txt +31 -0
  131. data/solr/conf/xslt/example.xsl +132 -0
  132. data/solr/conf/xslt/example_atom.xsl +67 -0
  133. data/solr/conf/xslt/example_rss.xsl +66 -0
  134. data/solr/conf/xslt/luke.xsl +337 -0
  135. data/solr/sample_solr_documents.yml +1 -0
  136. data/spec/controllers/blacklight/base_spec.rb +17 -0
  137. data/spec/controllers/blacklight/search_helper_spec.rb +25 -297
  138. data/spec/controllers/catalog_controller_spec.rb +7 -6
  139. data/spec/controllers/saved_searches_controller_spec.rb +1 -0
  140. data/spec/controllers/search_history_controller_spec.rb +1 -0
  141. data/spec/features/alternate_controller_spec.rb +10 -10
  142. data/spec/features/bookmarks_spec.rb +8 -22
  143. data/spec/features/facets_spec.rb +27 -7
  144. data/spec/features/record_view_spec.rb +4 -13
  145. data/spec/features/search_formats_spec.rb +1 -26
  146. data/spec/features/sitelinks_search_box.rb +1 -1
  147. data/spec/helpers/blacklight_helper_spec.rb +8 -38
  148. data/spec/helpers/catalog_helper_spec.rb +0 -8
  149. data/spec/helpers/configuration_helper_spec.rb +0 -25
  150. data/spec/helpers/facets_helper_spec.rb +12 -11
  151. data/spec/helpers/hash_as_hidden_fields_spec.rb +7 -7
  152. data/spec/helpers/layout_helper_spec.rb +0 -7
  153. data/spec/helpers/render_constraints_helper_spec.rb +4 -2
  154. data/spec/helpers/url_helper_spec.rb +13 -254
  155. data/spec/lib/blacklight/parameters_spec.rb +22 -0
  156. data/spec/lib/blacklight/path_spec.rb +254 -0
  157. data/spec/lib/blacklight_spec.rb +6 -2
  158. data/spec/models/blacklight/configuration/context_spec.rb +33 -0
  159. data/spec/models/blacklight/document/active_model_shim_spec.rb +33 -0
  160. data/spec/models/blacklight/document_spec.rb +29 -1
  161. data/spec/models/blacklight/facet_paginator_spec.rb +14 -13
  162. data/spec/models/blacklight/search_builder_spec.rb +17 -23
  163. data/spec/models/blacklight/solr/facet_paginator_spec.rb +11 -1
  164. data/spec/models/blacklight/solr/response/facets_spec.rb +19 -25
  165. data/spec/models/blacklight/solr/response/group_response_spec.rb +5 -5
  166. data/spec/models/blacklight/solr/response_spec.rb +0 -11
  167. data/spec/models/blacklight/solr/search_builder_spec.rb +49 -57
  168. data/spec/presenters/document_presenter_spec.rb +15 -42
  169. data/spec/routing/catalog_routing_spec.rb +7 -11
  170. data/spec/spec_helper.rb +4 -42
  171. data/spec/support/controller_level_helpers.rb +17 -0
  172. data/spec/test_app_templates/lib/generators/test_app_generator.rb +1 -2
  173. data/spec/views/_user_util_links.html.erb_spec.rb +1 -1
  174. data/spec/views/catalog/_facet_index_navigation.html.erb_spec.rb +40 -0
  175. data/spec/views/catalog/_facet_layout.html.erb_spec.rb +1 -1
  176. data/spec/views/catalog/_facets.html.erb_spec.rb +2 -2
  177. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +1 -1
  178. data/spec/views/catalog/_show_tools.html.erb_spec.rb +8 -8
  179. data/spec/views/catalog/_sort_and_per_page.html.erb_spec.rb +2 -2
  180. data/tasks/blacklight.rake +25 -30
  181. metadata +93 -71
  182. data/app/assets/stylesheets/blacklight/_catalog.scss +0 -229
  183. data/app/controllers/concerns/blacklight/search_history.rb +0 -31
  184. data/app/views/catalog/_refworks_form.html.erb +0 -6
  185. data/lib/blacklight/configuration/view_config.rb +0 -71
  186. data/lib/blacklight/rails/routes.rb +0 -29
  187. data/lib/blacklight/solr_helper.rb +0 -9
  188. data/lib/generators/blacklight/templates/config/initializers/blacklight_initializer.rb +0 -9
  189. data/spec/helpers/component_helper_spec.rb +0 -19
  190. data/spec/lib/blacklight/routes_spec.rb +0 -25
  191. data/spec/lib/blacklight/solr_helper_spec.rb +0 -12
  192. data/spec/routing/routes_spec.rb +0 -20
  193. data/spec/views/catalog/_document_action.html.erb_spec.rb +0 -21
@@ -0,0 +1,25 @@
1
+ module Blacklight
2
+ module Routes
3
+ class Exportable
4
+ def initialize(defaults = {})
5
+ @defaults = defaults
6
+ end
7
+
8
+ def call(mapper, options = {})
9
+ options = @defaults.merge(options)
10
+
11
+ mapper.member do
12
+ mapper.match 'email', via: [:get, :post]
13
+ mapper.match 'sms', via: [:get, :post]
14
+ mapper.get 'citation'
15
+ end
16
+
17
+ mapper.collection do
18
+ mapper.match 'email', via: [:get, :post]
19
+ mapper.match 'sms', via: [:get, :post]
20
+ mapper.get 'citation'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ module Blacklight
2
+ module Routes
3
+ class Searchable
4
+ def initialize(defaults = {})
5
+ @defaults = defaults
6
+ end
7
+
8
+ def call(mapper, options = {})
9
+ options = @defaults.merge(options)
10
+
11
+ mapper.match '/', action: 'index', as: 'search', via: [:get, :post]
12
+
13
+ mapper.post ":id/track", action: 'track', as: 'track'
14
+
15
+ mapper.get "opensearch"
16
+ mapper.get "facet/:id", action: 'facet', as: 'facet'
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,12 +1,4 @@
1
1
  module Blacklight
2
2
  module Solr
3
- require File.join(Blacklight::Engine.config.root, 'app', 'models', 'concerns', 'blacklight', 'document')
4
- require File.join(Blacklight::Engine.config.root, 'app', 'models', 'concerns', 'blacklight', 'solr', 'document')
5
-
6
- autoload :Repository, 'blacklight/solr/repository'
7
- autoload :Request, 'blacklight/solr/request'
8
- autoload :Response, 'blacklight/solr/response'
9
- autoload :SearchBuilder, 'blacklight/solr/search_builder'
10
- autoload :SearchBuilderBehavior, 'blacklight/solr/search_builder_behavior'
11
3
  end
12
- end
4
+ end
@@ -3,19 +3,7 @@ module Blacklight
3
3
 
4
4
  module Utils
5
5
  def self.needs_attr_accessible?
6
- if rails_3?
7
- !strong_parameters_enabled?
8
- else
9
- protected_attributes_enabled?
10
- end
11
- end
12
-
13
- def self.rails_3?
14
- Rails::VERSION::MAJOR == 3
15
- end
16
-
17
- def self.strong_parameters_enabled?
18
- defined?(ActionController::StrongParameters)
6
+ protected_attributes_enabled?
19
7
  end
20
8
 
21
9
  def self.protected_attributes_enabled?
@@ -28,20 +16,6 @@ module Blacklight
28
16
  class OpenStructWithHashAccess < OpenStruct
29
17
  delegate :keys, :each, :map, :has_key?, :key?, :include?, :empty?, :length, :delete, :delete_if, :keep_if, :clear, :reject!, :select!, :replace, :fetch, :to_json, :as_json, to: :to_h
30
18
 
31
- if ::RUBY_VERSION < '2.0'
32
- def []=(key, value)
33
- send "#{key}=", value
34
- end
35
-
36
- def [](key)
37
- send key
38
- end
39
-
40
- def respond_to? method, *args
41
- super(method, *args) || has_key?(method.to_sym)
42
- end
43
- end
44
-
45
19
  ##
46
20
  # Expose the internal hash
47
21
  # @return [Hash]
@@ -133,8 +107,6 @@ module Blacklight
133
107
  def []=(key, value)
134
108
  if value.is_a? Hash
135
109
  send "#{key}=", nested_class.new(value)
136
- elsif ::RUBY_VERSION < '2.0'
137
- send "#{key}=", value
138
110
  else
139
111
  super
140
112
  end
@@ -181,21 +153,7 @@ module Blacklight
181
153
  # @return [OpenStructWithHashAccess] a new instance of an OpenStructWithHashAccess
182
154
  def merge! other_hash
183
155
  @table.merge!(nested_class, (other_hash if other_hash.is_a? Hash) || other_hash.to_h)
184
- end
185
-
186
- ##
187
- # Override #method_missing from OpenStruct to ensure the default_proc logic
188
- # gets triggered.
189
- def method_missing(mid, *args)
190
- len = args.length
191
-
192
- if len == 0
193
- new_ostruct_member(mid)
194
- @table[mid]
195
- else
196
- super
197
- end
198
- end
156
+ end
199
157
 
200
158
  private
201
159
  def set_default_proc!
@@ -29,10 +29,13 @@ module Blacklight
29
29
  end
30
30
 
31
31
  def inject_blacklight_routes
32
- # These will end up in routes.rb file in reverse order
33
- # we add em, since each is added at the top of file.
34
- # we want "root" to be FIRST for optimal url generation.
35
- route("blacklight_for :#{controller_name}")
32
+ route <<-EOF
33
+ concern :searchable, Blacklight::Routes::Searchable.new
34
+
35
+ resource :catalog, only: [:index], as: 'catalog', path: '/catalog', controller: 'catalog' do
36
+ concerns :searchable
37
+ end
38
+ EOF
36
39
  end
37
40
  end
38
41
  end
@@ -16,10 +16,11 @@ module Blacklight
16
16
  This generator makes the following changes to your application:
17
17
  1. Generates blacklight:models
18
18
  2. Adds rsolr to the Gemfile
19
- 3. Creates a number of public assets, including images, stylesheets, and javascript
20
- 4. Injects behavior into your user application_controller.rb
21
- 5. Adds example configurations for dealing with MARC-like data
22
- 6. Adds Blacklight routes to your ./config/routes.rb
19
+ 3. Adds globalid to the Gemfile
20
+ 4. Creates a number of public assets, including images, stylesheets, and javascript
21
+ 5. Injects behavior into your user application_controller.rb
22
+ 6. Adds example configurations for dealing with MARC-like data
23
+ 7. Adds Blacklight routes to your ./config/routes.rb
23
24
 
24
25
  Thank you for Installing Blacklight.
25
26
  """
@@ -36,7 +37,11 @@ module Blacklight
36
37
  end
37
38
 
38
39
  def add_rsolr_gem
39
- gem "rsolr", "~> 1.0"
40
+ gem "rsolr", "~> 1.0.6"
41
+ end
42
+
43
+ def add_globalid_gem
44
+ gem "globalid"
40
45
  end
41
46
 
42
47
  def bundle_install
@@ -96,10 +101,6 @@ EOF
96
101
  copy_file "blacklight.en.yml", "config/locales/blacklight.en.yml"
97
102
  end
98
103
 
99
- def add_blacklight_initializer
100
- template "config/initializers/blacklight_initializer.rb"
101
- end
102
-
103
104
  def generate_blacklight_marc_demo
104
105
  if options[:marc]
105
106
  gem "blacklight-marc", "~> 5.0"
@@ -111,5 +112,11 @@ EOF
111
112
  generate 'blacklight:marc:install'
112
113
  end
113
114
  end
115
+
116
+ def add_routes
117
+ route <<-EOF
118
+ mount Blacklight::Engine => '/'
119
+ EOF
120
+ end
114
121
  end
115
122
  end
@@ -23,6 +23,24 @@ This generator makes the following changes to your application:
23
23
  rake "blacklight:install:migrations"
24
24
  end
25
25
 
26
+ def add_routes
27
+ route <<-EOF
28
+ concern :exportable, Blacklight::Routes::Exportable.new
29
+
30
+ resources :solr_documents, only: [:show], path: '/catalog', controller: 'catalog' do
31
+ concerns :exportable
32
+ end
33
+
34
+ resources :bookmarks do
35
+ concerns :exportable
36
+
37
+ collection do
38
+ delete 'clear'
39
+ end
40
+ end
41
+ EOF
42
+ end
43
+
26
44
 
27
45
  end
28
46
  end
@@ -1,27 +1,17 @@
1
1
  # -*- encoding : utf-8 -*-
2
- class <%= controller_name.classify %>Controller < ApplicationController
2
+ class <%= controller_name.classify %>Controller < ApplicationController
3
3
 
4
4
  include Blacklight::Catalog
5
5
 
6
6
  configure_blacklight do |config|
7
- ## Class for sending and receiving requests from a search index
8
- # config.repository_class = Blacklight::Solr::Repository
9
- #
10
- ## Class for converting Blacklight's url parameters to into request parameters for the search index
11
- # config.search_builder_class = ::SearchBuilder
12
- #
13
- ## Model that maps search index responses to the blacklight response model
14
- # config.response_model = Blacklight::Solr::Response
15
-
16
7
  ## Default parameters to send to solr for all search-like requests. See also SearchBuilder#processed_parameters
17
- config.default_solr_params = {
18
- :qt => 'search',
19
- :rows => 10
8
+ config.default_solr_params = {
9
+ rows: 10
20
10
  }
21
-
11
+
22
12
  # solr path which will be added to solr base url before the other solr params.
23
- #config.solr_path = 'select'
24
-
13
+ #config.solr_path = 'select'
14
+
25
15
  # items to show per page, each number in the array represent another option to choose from.
26
16
  #config.per_page = [10,20,50,100]
27
17
 
@@ -29,11 +19,11 @@ class <%= controller_name.classify %>Controller < ApplicationController
29
19
  ## parameters included in the Blacklight-jetty document requestHandler.
30
20
  #
31
21
  #config.default_document_solr_params = {
32
- # :qt => 'document',
22
+ # qt: 'document',
33
23
  # ## These are hard-coded in the blacklight 'document' requestHandler
34
- # # :fl => '*',
35
- # # :rows => 1
36
- # # :q => '{!raw f=id v=$id}'
24
+ # # fl: '*',
25
+ # # rows: 1
26
+ # # q: '{!term f=id v=$id}'
37
27
  #}
38
28
 
39
29
  # solr field configuration for search results/index views
@@ -51,32 +41,37 @@ class <%= controller_name.classify %>Controller < ApplicationController
51
41
  # * If left unset, then all facet values returned by solr will be displayed.
52
42
  # * If set to an integer, then "f.somefield.facet.limit" will be added to
53
43
  # solr request, with actual solr request being +1 your configured limit --
54
- # you configure the number of items you actually want _displayed_ in a page.
44
+ # you configure the number of items you actually want _displayed_ in a page.
55
45
  # * If set to 'true', then no additional parameters will be sent to solr,
56
46
  # but any 'sniffed' request limit parameters will be used for paging, with
57
- # paging at requested limit -1. Can sniff from facet.limit or
47
+ # paging at requested limit -1. Can sniff from facet.limit or
58
48
  # f.specific_field.facet.limit solr request params. This 'true' config
59
49
  # can be used if you set limits in :default_solr_params, or as defaults
60
50
  # on the solr side in the request handler itself. Request handler defaults
61
51
  # sniffing requires solr requests to be made with "echoParams=all", for
62
- # app code to actually have it echo'd back to see it.
52
+ # app code to actually have it echo'd back to see it.
63
53
  #
64
- # :show may be set to false if you don't want the facet to be drawn in the
54
+ # :show may be set to false if you don't want the facet to be drawn in the
65
55
  # facet bar
66
- config.add_facet_field 'format', :label => 'Format'
67
- config.add_facet_field 'pub_date', :label => 'Publication Year', :single => true
68
- config.add_facet_field 'subject_topic_facet', :label => 'Topic', :limit => 20
69
- config.add_facet_field 'language_facet', :label => 'Language', :limit => true
70
- config.add_facet_field 'lc_1letter_facet', :label => 'Call Number'
71
- config.add_facet_field 'subject_geo_facet', :label => 'Region'
72
- config.add_facet_field 'subject_era_facet', :label => 'Era'
73
-
74
- config.add_facet_field 'example_pivot_field', :label => 'Pivot Field', :pivot => ['format', 'language_facet']
75
-
76
- config.add_facet_field 'example_query_facet_field', :label => 'Publish Date', :query => {
77
- :years_5 => { :label => 'within 5 Years', :fq => "pub_date:[#{Time.zone.now.year - 5 } TO *]" },
78
- :years_10 => { :label => 'within 10 Years', :fq => "pub_date:[#{Time.zone.now.year - 10 } TO *]" },
79
- :years_25 => { :label => 'within 25 Years', :fq => "pub_date:[#{Time.zone.now.year - 25 } TO *]" }
56
+ #
57
+ # set :index_range to true if you want the facet pagination view to have facet prefix-based navigation
58
+ # (useful when user clicks "more" on a large facet and wants to navigate alphabetically across a large set of results)
59
+ # :index_range can be an array or range of prefixes that will be used to create the navigation (note: It is case sensitive when searching values)
60
+
61
+ config.add_facet_field 'format', label: 'Format'
62
+ config.add_facet_field 'pub_date', label: 'Publication Year', single: true
63
+ config.add_facet_field 'subject_topic_facet', label: 'Topic', limit: 20, index_range: 'A'..'Z'
64
+ config.add_facet_field 'language_facet', label: 'Language', limit: true
65
+ config.add_facet_field 'lc_1letter_facet', label: 'Call Number'
66
+ config.add_facet_field 'subject_geo_facet', label: 'Region'
67
+ config.add_facet_field 'subject_era_facet', label: 'Era'
68
+
69
+ config.add_facet_field 'example_pivot_field', label: 'Pivot Field', :pivot => ['format', 'language_facet']
70
+
71
+ config.add_facet_field 'example_query_facet_field', label: 'Publish Date', :query => {
72
+ :years_5 => { label: 'within 5 Years', fq: "pub_date:[#{Time.now.year - 5 } TO *]" },
73
+ :years_10 => { label: 'within 10 Years', fq: "pub_date:[#{Time.now.year - 10 } TO *]" },
74
+ :years_25 => { label: 'within 25 Years', fq: "pub_date:[#{Time.now.year - 25 } TO *]" }
80
75
  }
81
76
 
82
77
 
@@ -86,33 +81,33 @@ class <%= controller_name.classify %>Controller < ApplicationController
86
81
  config.add_facet_fields_to_solr_request!
87
82
 
88
83
  # solr fields to be displayed in the index (search results) view
89
- # The ordering of the field names is the order of the display
90
- config.add_index_field 'title_display', :label => 'Title'
91
- config.add_index_field 'title_vern_display', :label => 'Title'
92
- config.add_index_field 'author_display', :label => 'Author'
93
- config.add_index_field 'author_vern_display', :label => 'Author'
94
- config.add_index_field 'format', :label => 'Format'
95
- config.add_index_field 'language_facet', :label => 'Language'
96
- config.add_index_field 'published_display', :label => 'Published'
97
- config.add_index_field 'published_vern_display', :label => 'Published'
98
- config.add_index_field 'lc_callnum_display', :label => 'Call number'
84
+ # The ordering of the field names is the order of the display
85
+ config.add_index_field 'title_display', label: 'Title'
86
+ config.add_index_field 'title_vern_display', label: 'Title'
87
+ config.add_index_field 'author_display', label: 'Author'
88
+ config.add_index_field 'author_vern_display', label: 'Author'
89
+ config.add_index_field 'format', label: 'Format'
90
+ config.add_index_field 'language_facet', label: 'Language'
91
+ config.add_index_field 'published_display', label: 'Published'
92
+ config.add_index_field 'published_vern_display', label: 'Published'
93
+ config.add_index_field 'lc_callnum_display', label: 'Call number'
99
94
 
100
95
  # solr fields to be displayed in the show (single result) view
101
- # The ordering of the field names is the order of the display
102
- config.add_show_field 'title_display', :label => 'Title'
103
- config.add_show_field 'title_vern_display', :label => 'Title'
104
- config.add_show_field 'subtitle_display', :label => 'Subtitle'
105
- config.add_show_field 'subtitle_vern_display', :label => 'Subtitle'
106
- config.add_show_field 'author_display', :label => 'Author'
107
- config.add_show_field 'author_vern_display', :label => 'Author'
108
- config.add_show_field 'format', :label => 'Format'
109
- config.add_show_field 'url_fulltext_display', :label => 'URL'
110
- config.add_show_field 'url_suppl_display', :label => 'More Information'
111
- config.add_show_field 'language_facet', :label => 'Language'
112
- config.add_show_field 'published_display', :label => 'Published'
113
- config.add_show_field 'published_vern_display', :label => 'Published'
114
- config.add_show_field 'lc_callnum_display', :label => 'Call number'
115
- config.add_show_field 'isbn_t', :label => 'ISBN'
96
+ # The ordering of the field names is the order of the display
97
+ config.add_show_field 'title_display', label: 'Title'
98
+ config.add_show_field 'title_vern_display', label: 'Title'
99
+ config.add_show_field 'subtitle_display', label: 'Subtitle'
100
+ config.add_show_field 'subtitle_vern_display', label: 'Subtitle'
101
+ config.add_show_field 'author_display', label: 'Author'
102
+ config.add_show_field 'author_vern_display', label: 'Author'
103
+ config.add_show_field 'format', label: 'Format'
104
+ config.add_show_field 'url_fulltext_display', label: 'URL'
105
+ config.add_show_field 'url_suppl_display', label: 'More Information'
106
+ config.add_show_field 'language_facet', label: 'Language'
107
+ config.add_show_field 'published_display', label: 'Published'
108
+ config.add_show_field 'published_vern_display', label: 'Published'
109
+ config.add_show_field 'lc_callnum_display', label: 'Call number'
110
+ config.add_show_field 'isbn_t', label: 'ISBN'
116
111
 
117
112
  # "fielded" search configuration. Used by pulldown among other places.
118
113
  # For supported keys in hash, see rdoc for Blacklight::SearchFields
@@ -126,50 +121,50 @@ class <%= controller_name.classify %>Controller < ApplicationController
126
121
  # The :key is what will be used to identify this BL search field internally,
127
122
  # as well as in URLs -- so changing it after deployment may break bookmarked
128
123
  # urls. A display label will be automatically calculated from the :key,
129
- # or can be specified manually to be different.
124
+ # or can be specified manually to be different.
130
125
 
131
126
  # This one uses all the defaults set by the solr request handler. Which
132
127
  # solr request handler? The one set in config[:default_solr_parameters][:qt],
133
- # since we aren't specifying it otherwise.
134
-
135
- config.add_search_field 'all_fields', :label => 'All Fields'
136
-
128
+ # since we aren't specifying it otherwise.
129
+
130
+ config.add_search_field 'all_fields', label: 'All Fields'
131
+
137
132
 
138
133
  # Now we see how to over-ride Solr request handler defaults, in this
139
134
  # case for a BL "search field", which is really a dismax aggregate
140
- # of Solr search fields.
141
-
135
+ # of Solr search fields.
136
+
142
137
  config.add_search_field('title') do |field|
143
- # solr_parameters hash are sent to Solr as ordinary url query params.
138
+ # solr_parameters hash are sent to Solr as ordinary url query params.
144
139
  field.solr_parameters = { :'spellcheck.dictionary' => 'title' }
145
140
 
146
141
  # :solr_local_parameters will be sent using Solr LocalParams
147
142
  # syntax, as eg {! qf=$title_qf }. This is neccesary to use
148
143
  # Solr parameter de-referencing like $title_qf.
149
144
  # See: http://wiki.apache.org/solr/LocalParams
150
- field.solr_local_parameters = {
151
- :qf => '$title_qf',
152
- :pf => '$title_pf'
145
+ field.solr_local_parameters = {
146
+ qf: '$title_qf',
147
+ pf: '$title_pf'
153
148
  }
154
149
  end
155
-
150
+
156
151
  config.add_search_field('author') do |field|
157
152
  field.solr_parameters = { :'spellcheck.dictionary' => 'author' }
158
- field.solr_local_parameters = {
159
- :qf => '$author_qf',
160
- :pf => '$author_pf'
153
+ field.solr_local_parameters = {
154
+ qf: '$author_qf',
155
+ pf: '$author_pf'
161
156
  }
162
157
  end
163
-
158
+
164
159
  # Specifying a :qt only to show it's possible, and so our internal automated
165
- # tests can test it. In this case it's the same as
166
- # config[:default_solr_parameters][:qt], so isn't actually neccesary.
160
+ # tests can test it. In this case it's the same as
161
+ # config[:default_solr_parameters][:qt], so isn't actually neccesary.
167
162
  config.add_search_field('subject') do |field|
168
163
  field.solr_parameters = { :'spellcheck.dictionary' => 'subject' }
169
164
  field.qt = 'search'
170
- field.solr_local_parameters = {
171
- :qf => '$subject_qf',
172
- :pf => '$subject_pf'
165
+ field.solr_local_parameters = {
166
+ qf: '$subject_qf',
167
+ pf: '$subject_pf'
173
168
  }
174
169
  end
175
170
 
@@ -177,14 +172,13 @@ class <%= controller_name.classify %>Controller < ApplicationController
177
172
  # label in pulldown is followed by the name of the SOLR field to sort by and
178
173
  # whether the sort is ascending or descending (it must be asc or desc
179
174
  # except in the relevancy case).
180
- config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', :label => 'relevance'
181
- config.add_sort_field 'pub_date_sort desc, title_sort asc', :label => 'year'
182
- config.add_sort_field 'author_sort asc, title_sort asc', :label => 'author'
183
- config.add_sort_field 'title_sort asc, pub_date_sort desc', :label => 'title'
175
+ config.add_sort_field 'score desc, pub_date_sort desc, title_sort asc', label: 'relevance'
176
+ config.add_sort_field 'pub_date_sort desc, title_sort asc', label: 'year'
177
+ config.add_sort_field 'author_sort asc, title_sort asc', label: 'author'
178
+ config.add_sort_field 'title_sort asc, pub_date_sort desc', label: 'title'
184
179
 
185
- # If there are more than this many search results, no spelling ("did you
180
+ # If there are more than this many search results, no spelling ("did you
186
181
  # mean") suggestion is offered.
187
182
  config.spell_max = 5
188
183
  end
189
-
190
- end
184
+ end