blacklight 5.13.0 → 5.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +16 -0
  3. data/.rubocop_hound.yml +1063 -0
  4. data/.rubocop_todo.yml +253 -0
  5. data/.travis.yml +7 -9
  6. data/Rakefile +1 -1
  7. data/VERSION +1 -1
  8. data/app/helpers/blacklight/blacklight_helper_behavior.rb +9 -13
  9. data/app/helpers/blacklight/catalog_helper_behavior.rb +14 -3
  10. data/app/helpers/blacklight/configuration_helper_behavior.rb +1 -1
  11. data/app/helpers/blacklight/facets_helper_behavior.rb +13 -13
  12. data/app/helpers/blacklight/render_partials_helper.rb +3 -0
  13. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +3 -5
  14. data/app/helpers/blacklight/url_helper_behavior.rb +1 -1
  15. data/app/helpers/blacklight_configuration_helper.rb +1 -1
  16. data/app/helpers/blacklight_url_helper.rb +1 -1
  17. data/app/helpers/component_helper.rb +1 -1
  18. data/app/models/bookmark.rb +1 -1
  19. data/app/models/search.rb +2 -2
  20. data/app/views/catalog/_bookmark_control.html.erb +1 -1
  21. data/app/views/catalog/_document_default.atom.builder +2 -2
  22. data/app/views/catalog/_document_default.rss.builder +3 -3
  23. data/blacklight.gemspec +1 -1
  24. data/lib/blacklight.rb +10 -10
  25. data/lib/blacklight/bookmarks.rb +11 -10
  26. data/lib/blacklight/catalog.rb +7 -15
  27. data/lib/blacklight/catalog/component_configuration.rb +1 -1
  28. data/lib/blacklight/catalog/search_context.rb +1 -1
  29. data/lib/blacklight/configuration.rb +3 -3
  30. data/lib/blacklight/configuration/tool_config.rb +1 -1
  31. data/lib/blacklight/configuration/view_config.rb +1 -1
  32. data/lib/blacklight/controller.rb +0 -1
  33. data/lib/blacklight/document/active_model_shim.rb +1 -1
  34. data/lib/blacklight/document/dublin_core.rb +11 -6
  35. data/lib/blacklight/document/export.rb +5 -13
  36. data/lib/blacklight/document/schema_org.rb +1 -1
  37. data/lib/blacklight/document/semantic_fields.rb +9 -13
  38. data/lib/blacklight/document_presenter.rb +2 -2
  39. data/lib/blacklight/engine.rb +11 -0
  40. data/lib/blacklight/exceptions.rb +2 -2
  41. data/lib/blacklight/solr/document.rb +1 -2
  42. data/lib/blacklight/solr/document/more_like_this.rb +1 -1
  43. data/lib/blacklight/solr/document/schema_org.rb +1 -1
  44. data/lib/blacklight/solr/facet_paginator.rb +8 -5
  45. data/lib/blacklight/solr/request.rb +2 -3
  46. data/lib/blacklight/solr/search_builder_behavior.rb +14 -7
  47. data/lib/blacklight/solr_repository.rb +3 -3
  48. data/lib/blacklight/solr_response.rb +1 -1
  49. data/lib/blacklight/solr_response/group.rb +1 -1
  50. data/lib/blacklight/solr_response/group_response.rb +1 -1
  51. data/lib/blacklight/solr_response/more_like_this.rb +1 -1
  52. data/lib/blacklight/solr_response/pagination_methods.rb +1 -1
  53. data/lib/blacklight/solr_response/spelling.rb +1 -3
  54. data/lib/blacklight/token_based_user.rb +1 -3
  55. data/lib/blacklight/user.rb +1 -1
  56. data/lib/generators/blacklight/assets_generator.rb +22 -7
  57. data/lib/railties/blacklight.rake +5 -5
  58. data/spec/controllers/bookmarks_controller_spec.rb +1 -1
  59. data/spec/helpers/catalog_helper_spec.rb +3 -3
  60. data/spec/lib/blacklight/solr_response/facets_spec.rb +2 -2
  61. data/spec/lib/blacklight/solr_response/group_response_spec.rb +1 -1
  62. data/spec/lib/blacklight/solr_response/group_spec.rb +1 -1
  63. metadata +5 -2
@@ -0,0 +1,253 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-04-13 15:13:47 -0700 using RuboCop version 0.30.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 19
9
+ # Configuration parameters: AlignWith, SupportedStyles.
10
+ Lint/EndAlignment:
11
+ Enabled: false
12
+
13
+ # Offense count: 37
14
+ # Cop supports --auto-correct.
15
+ Lint/UnusedBlockArgument:
16
+ Enabled: false
17
+
18
+ # Offense count: 25
19
+ # Cop supports --auto-correct.
20
+ Lint/UnusedMethodArgument:
21
+ Enabled: false
22
+
23
+ # Offense count: 5
24
+ Lint/UselessAssignment:
25
+ Enabled: false
26
+
27
+ # Offense count: 2
28
+ # Cop supports --auto-correct.
29
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
30
+ Style/AccessModifierIndentation:
31
+ Enabled: false
32
+
33
+ # Offense count: 9
34
+ # Cop supports --auto-correct.
35
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
36
+ Style/AlignParameters:
37
+ Enabled: false
38
+
39
+ # Offense count: 87
40
+ # Cop supports --auto-correct.
41
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
42
+ Style/AndOr:
43
+ Enabled: false
44
+
45
+ # Offense count: 3
46
+ # Cop supports --auto-correct.
47
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
48
+ Style/BracesAroundHashParameters:
49
+ Enabled: false
50
+
51
+ # Offense count: 25
52
+ # Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
53
+ Style/CaseIndentation:
54
+ Enabled: false
55
+
56
+ # Offense count: 5
57
+ # Cop supports --auto-correct.
58
+ Style/ClosingParenthesisIndentation:
59
+ Enabled: false
60
+
61
+ # Offense count: 19
62
+ # Cop supports --auto-correct.
63
+ # Configuration parameters: PreferredMethods.
64
+ Style/CollectionMethods:
65
+ Enabled: false
66
+
67
+ # Offense count: 7
68
+ # Cop supports --auto-correct.
69
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
70
+ Style/DotPosition:
71
+ Enabled: false
72
+
73
+ # Offense count: 24
74
+ # Cop supports --auto-correct.
75
+ Style/ElseAlignment:
76
+ Enabled: false
77
+
78
+ # Offense count: 19
79
+ # Cop supports --auto-correct.
80
+ Style/EmptyLines:
81
+ Enabled: false
82
+
83
+ # Offense count: 13
84
+ # Cop supports --auto-correct.
85
+ Style/EmptyLinesAroundAccessModifier:
86
+ Enabled: false
87
+
88
+ # Offense count: 4
89
+ # Cop supports --auto-correct.
90
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
91
+ Style/EmptyLinesAroundBlockBody:
92
+ Enabled: false
93
+
94
+ # Offense count: 22
95
+ # Cop supports --auto-correct.
96
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
97
+ Style/EmptyLinesAroundClassBody:
98
+ Enabled: false
99
+
100
+ # Offense count: 15
101
+ # Cop supports --auto-correct.
102
+ Style/EmptyLinesAroundMethodBody:
103
+ Enabled: false
104
+
105
+ # Offense count: 35
106
+ # Cop supports --auto-correct.
107
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
108
+ Style/EmptyLinesAroundModuleBody:
109
+ Enabled: false
110
+
111
+ # Offense count: 99
112
+ # Cop supports --auto-correct.
113
+ Style/ExtraSpacing:
114
+ Enabled: false
115
+
116
+ # Offense count: 161
117
+ # Cop supports --auto-correct.
118
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
119
+ Style/HashSyntax:
120
+ Enabled: false
121
+
122
+ # Offense count: 4
123
+ # Cop supports --auto-correct.
124
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
125
+ Style/IndentHash:
126
+ Enabled: false
127
+
128
+ # Offense count: 61
129
+ # Cop supports --auto-correct.
130
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
131
+ Style/IndentationConsistency:
132
+ Enabled: false
133
+
134
+ # Offense count: 27
135
+ # Cop supports --auto-correct.
136
+ # Configuration parameters: Width.
137
+ Style/IndentationWidth:
138
+ Enabled: false
139
+
140
+ # Offense count: 13
141
+ # Cop supports --auto-correct.
142
+ Style/LeadingCommentSpace:
143
+ Enabled: false
144
+
145
+ # Offense count: 177
146
+ # Cop supports --auto-correct.
147
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
148
+ Style/MethodDefParentheses:
149
+ Enabled: false
150
+
151
+ # Offense count: 3
152
+ # Cop supports --auto-correct.
153
+ Style/MultilineBlockLayout:
154
+ Enabled: false
155
+
156
+ # Offense count: 36
157
+ # Cop supports --auto-correct.
158
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
159
+ Style/MultilineOperationIndentation:
160
+ Enabled: false
161
+
162
+ # Offense count: 3
163
+ # Cop supports --auto-correct.
164
+ # Configuration parameters: AllowSafeAssignment.
165
+ Style/ParenthesesAroundCondition:
166
+ Enabled: false
167
+
168
+ # Offense count: 6
169
+ # Cop supports --auto-correct.
170
+ # Configuration parameters: AllowMultipleReturnValues.
171
+ Style/RedundantReturn:
172
+ Enabled: false
173
+
174
+ # Offense count: 44
175
+ # Cop supports --auto-correct.
176
+ Style/RedundantSelf:
177
+ Enabled: false
178
+
179
+ # Offense count: 1
180
+ Style/RescueModifier:
181
+ Enabled: false
182
+
183
+ # Offense count: 10
184
+ # Cop supports --auto-correct.
185
+ Style/SingleSpaceBeforeFirstArg:
186
+ Enabled: false
187
+
188
+ # Offense count: 30
189
+ # Cop supports --auto-correct.
190
+ Style/SpaceAfterComma:
191
+ Enabled: false
192
+
193
+ # Offense count: 3
194
+ # Cop supports --auto-correct.
195
+ # Configuration parameters: EnforcedStyleInsidePipes, SupportedStyles.
196
+ Style/SpaceAroundBlockParameters:
197
+ Enabled: false
198
+
199
+ # Offense count: 42
200
+ # Cop supports --auto-correct.
201
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
202
+ Style/SpaceAroundEqualsInParameterDefault:
203
+ Enabled: false
204
+
205
+ # Offense count: 24
206
+ # Cop supports --auto-correct.
207
+ # Configuration parameters: MultiSpaceAllowedForOperators.
208
+ Style/SpaceAroundOperators:
209
+ Enabled: false
210
+
211
+ # Offense count: 2
212
+ # Cop supports --auto-correct.
213
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
214
+ Style/SpaceBeforeBlockBraces:
215
+ Enabled: false
216
+
217
+ # Offense count: 16
218
+ # Cop supports --auto-correct.
219
+ Style/SpaceBeforeComma:
220
+ Enabled: false
221
+
222
+ # Offense count: 12
223
+ # Cop supports --auto-correct.
224
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
225
+ Style/SpaceInsideBlockBraces:
226
+ Enabled: false
227
+
228
+ # Offense count: 14
229
+ # Cop supports --auto-correct.
230
+ Style/SpaceInsideBrackets:
231
+ Enabled: false
232
+
233
+ # Offense count: 32
234
+ # Cop supports --auto-correct.
235
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
236
+ Style/SpaceInsideHashLiteralBraces:
237
+ Enabled: false
238
+
239
+ # Offense count: 29
240
+ # Cop supports --auto-correct.
241
+ Style/SpaceInsideParens:
242
+ Enabled: false
243
+
244
+ # Offense count: 7
245
+ # Cop supports --auto-correct.
246
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
247
+ Style/StringLiteralsInInterpolation:
248
+ Enabled: false
249
+
250
+ # Offense count: 347
251
+ # Cop supports --auto-correct.
252
+ Style/TrailingWhitespace:
253
+ Enabled: false
@@ -5,28 +5,26 @@ notifications:
5
5
  email: false
6
6
 
7
7
  rvm:
8
- - 2.2.1
8
+ - 2.2.2
9
9
 
10
10
  matrix:
11
11
  include:
12
- - rvm: 2.2.1
12
+ - rvm: 2.2.2
13
13
  env: "RAILS_VERSION=4.0.12"
14
- - rvm: 2.2.1
14
+ - rvm: 2.2.2
15
15
  env: "RAILS_VERSION=4.1.9"
16
- - rvm: 2.1.5
17
- env: "RAILS_VERSION=4.2.0"
18
- - rvm: 2.1.5
16
+ - rvm: 2.1.6
19
17
  env: "RAILS_VERSION=4.2.1"
20
18
  - rvm: jruby
21
- env: "RAILS_VERSION=4.2.0 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
19
+ env: "RAILS_VERSION=4.2.1 JRUBY_OPTS=\"-J-Xms512m -J-Xmx1024m\""
22
20
  - rvm: 1.9.3
23
- env: "RAILS_VERSION=4.2.0"
21
+ env: "RAILS_VERSION=4.2.1"
24
22
 
25
23
  before_install:
26
24
  - gem install bundler
27
25
 
28
26
  env:
29
- - "RAILS_VERSION=4.2.0"
27
+ - "RAILS_VERSION=4.2.1"
30
28
 
31
29
  notifications:
32
30
  irc: "irc.freenode.org#blacklight"
data/Rakefile CHANGED
@@ -11,4 +11,4 @@ Bundler::GemHelper.install_tasks
11
11
 
12
12
  load "tasks/blacklight.rake"
13
13
 
14
- task :default => [:ci]
14
+ task :default => [:ci]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.13.0
1
+ 5.13.1
@@ -45,23 +45,19 @@ module Blacklight::BlacklightHelperBehavior
45
45
  # content type, e.g. as required by atom
46
46
  # @option options [Array<String>] :exclude array of format shortnames to not include in the output
47
47
  def render_link_rel_alternates(document=@document, options = {})
48
- options = {:unique => false, :exclude => []}.merge(options)
48
+ return if document.nil?
49
49
 
50
- return nil if document.nil?
50
+ options = { unique: false, exclude: [] }.merge(options)
51
51
 
52
52
  seen = Set.new
53
53
 
54
- html = ""
55
- document.export_formats.each_pair do |format, spec|
56
- unless( options[:exclude].include?(format) ||
57
- (options[:unique] && seen.include?(spec[:content_type]))
58
- )
59
- html << tag(:link, {:rel=>"alternate", :title=>format, :type => spec[:content_type], :href=> polymorphic_url(document, :format => format)}) << "\n"
54
+ safe_join(document.export_formats.map do |format, spec|
55
+ next if options[:exclude].include?(format) || (options[:unique] && seen.include?(spec[:content_type]))
60
56
 
61
- seen.add(spec[:content_type]) if options[:unique]
62
- end
63
- end
64
- return html.html_safe
57
+ seen.add(spec[:content_type])
58
+
59
+ tag(:link, rel: "alternate", title: format, type: spec[:content_type], href: polymorphic_url(document, format: format))
60
+ end.compact, "\n")
65
61
  end
66
62
 
67
63
  ##
@@ -362,7 +358,7 @@ module Blacklight::BlacklightHelperBehavior
362
358
  # @option opts [String] :label Render the given string
363
359
  # @param [Symbol, Proc, String] field Render the given field or evaluate the proc or render the given string
364
360
  def render_document_index_label doc, field, opts = {}
365
- if field.kind_of? Hash
361
+ if field.is_a? Hash
366
362
  Deprecation.warn self, "Calling render_document_index_label with a hash is deprecated"
367
363
  field = field[:label]
368
364
  end
@@ -1,5 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Blacklight::CatalogHelperBehavior
3
+ extend Deprecation
4
+ self.deprecation_horizon = "Blacklight 6.x"
3
5
 
4
6
  ##
5
7
  # Override the Kaminari page_entries_info helper with our own, blacklight-aware
@@ -99,8 +101,8 @@ module Blacklight::CatalogHelperBehavior
99
101
 
100
102
  return if types.blank?
101
103
 
102
- Array(types).map do |t|
103
- document_class_prefix + t.parameterize rescue nil
104
+ Array(types).compact.map do |t|
105
+ "#{document_class_prefix}#{t.try(:parameterize) || t}"
104
106
  end.join(' ')
105
107
  end
106
108
 
@@ -234,9 +236,14 @@ module Blacklight::CatalogHelperBehavior
234
236
  @current_bookmarks ||= current_or_guest_user.bookmarks_for_documents(response.documents).to_a
235
237
  end
236
238
 
237
- def is_bookmarked? document
239
+ ##
240
+ # Check if the document is in the user's bookmarks
241
+ def bookmarked? document
238
242
  current_bookmarks.any? { |x| x.document_id == document.id and x.document_type == document.class }
239
243
  end
244
+
245
+ alias_method :is_bookmarked?, :bookmarked?
246
+ deprecation_deprecate :is_bookmarked?
240
247
 
241
248
  def render_marc_tools
242
249
  return unless defined? Blacklight::Marc
@@ -262,4 +269,8 @@ module Blacklight::CatalogHelperBehavior
262
269
  respond_to? :librarian_view_catalog_path and options[:document] and options[:document].respond_to?(:to_marc)
263
270
  end
264
271
 
272
+ def render_sms_action? config, options = {}
273
+ !sms_mappings.blank?
274
+ end
275
+
265
276
  end
@@ -164,7 +164,7 @@ module Blacklight::ConfigurationHelperBehavior
164
164
  ##
165
165
  # Default sort field
166
166
  def default_sort_field
167
- (active_sort_fields.select { |k,config| config.respond_to? :default and config.default }.first || active_sort_fields.first).try(:last)
167
+ (active_sort_fields.find { |k,config| config.respond_to? :default and config.default } || active_sort_fields.first).try(:last)
168
168
  end
169
169
 
170
170
  ##
@@ -198,17 +198,17 @@ module Blacklight::FacetsHelperBehavior
198
198
  facet_value_for_facet_item(item)
199
199
  end
200
200
 
201
- display_label = case
202
- when facet_config.helper_method
203
- display_label = send facet_config.helper_method, value
204
- when (facet_config.query and facet_config.query[value])
205
- display_label = facet_config.query[value][:label]
206
- when facet_config.date
207
- localization_options = {}
208
- localization_options = facet_config.date unless facet_config.date === true
209
- display_label = l(value.to_datetime, localization_options)
210
- else
211
- value
201
+ case
202
+ when facet_config.helper_method
203
+ send facet_config.helper_method, value
204
+ when (facet_config.query and facet_config.query[value])
205
+ facet_config.query[value][:label]
206
+ when facet_config.date
207
+ localization_options = {}
208
+ localization_options = facet_config.date unless facet_config.date === true
209
+ l(value.to_datetime, localization_options)
210
+ else
211
+ value
212
212
  end
213
213
  end
214
214
 
@@ -220,9 +220,9 @@ module Blacklight::FacetsHelperBehavior
220
220
 
221
221
  def facet_value_for_facet_item item
222
222
  if item.respond_to? :value
223
- value = item.value
223
+ item.value
224
224
  else
225
- value = item
225
+ item
226
226
  end
227
227
  end
228
228
 
@@ -150,6 +150,8 @@ module Blacklight::RenderPartialsHelper
150
150
  end
151
151
 
152
152
  private
153
+
154
+ # rubocop:disable Performance/Detect
153
155
  def find_document_show_template_with_view view_type, base_name, format, locals
154
156
  document_partial_path_templates.each do |str|
155
157
  partial = str % { action_name: base_name, format: format, index_view_type: view_type }
@@ -169,6 +171,7 @@ module Blacklight::RenderPartialsHelper
169
171
  end
170
172
  nil
171
173
  end
174
+ # rubocop:enable Performance/Detect
172
175
 
173
176
  ##
174
177
  # @param [Symbol] page the page type, either :index or :show