actionview 5.2.4.1 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionview might be problematic. Click here for more details.

Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +193 -79
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -2
  5. data/lib/action_view.rb +3 -2
  6. data/lib/action_view/base.rb +107 -10
  7. data/lib/action_view/buffers.rb +15 -0
  8. data/lib/action_view/cache_expiry.rb +54 -0
  9. data/lib/action_view/context.rb +5 -9
  10. data/lib/action_view/digestor.rb +12 -20
  11. data/lib/action_view/gem_version.rb +4 -4
  12. data/lib/action_view/helpers.rb +0 -2
  13. data/lib/action_view/helpers/asset_tag_helper.rb +7 -30
  14. data/lib/action_view/helpers/asset_url_helper.rb +4 -3
  15. data/lib/action_view/helpers/cache_helper.rb +18 -10
  16. data/lib/action_view/helpers/capture_helper.rb +4 -0
  17. data/lib/action_view/helpers/csp_helper.rb +4 -2
  18. data/lib/action_view/helpers/csrf_helper.rb +1 -1
  19. data/lib/action_view/helpers/date_helper.rb +69 -25
  20. data/lib/action_view/helpers/form_helper.rb +238 -6
  21. data/lib/action_view/helpers/form_options_helper.rb +27 -18
  22. data/lib/action_view/helpers/form_tag_helper.rb +12 -9
  23. data/lib/action_view/helpers/javascript_helper.rb +9 -8
  24. data/lib/action_view/helpers/number_helper.rb +5 -0
  25. data/lib/action_view/helpers/output_safety_helper.rb +1 -1
  26. data/lib/action_view/helpers/rendering_helper.rb +6 -4
  27. data/lib/action_view/helpers/sanitize_helper.rb +12 -18
  28. data/lib/action_view/helpers/tag_helper.rb +7 -6
  29. data/lib/action_view/helpers/tags/base.rb +9 -5
  30. data/lib/action_view/helpers/tags/color_field.rb +1 -1
  31. data/lib/action_view/helpers/tags/translator.rb +1 -6
  32. data/lib/action_view/helpers/text_helper.rb +3 -3
  33. data/lib/action_view/helpers/translation_helper.rb +16 -12
  34. data/lib/action_view/helpers/url_helper.rb +14 -14
  35. data/lib/action_view/layouts.rb +5 -5
  36. data/lib/action_view/log_subscriber.rb +6 -6
  37. data/lib/action_view/lookup_context.rb +73 -31
  38. data/lib/action_view/path_set.rb +5 -10
  39. data/lib/action_view/railtie.rb +24 -1
  40. data/lib/action_view/record_identifier.rb +2 -2
  41. data/lib/action_view/renderer/abstract_renderer.rb +56 -3
  42. data/lib/action_view/renderer/partial_renderer.rb +66 -55
  43. data/lib/action_view/renderer/partial_renderer/collection_caching.rb +62 -16
  44. data/lib/action_view/renderer/renderer.rb +16 -4
  45. data/lib/action_view/renderer/streaming_template_renderer.rb +5 -5
  46. data/lib/action_view/renderer/template_renderer.rb +24 -18
  47. data/lib/action_view/rendering.rb +51 -31
  48. data/lib/action_view/routing_url_for.rb +12 -11
  49. data/lib/action_view/template.rb +102 -70
  50. data/lib/action_view/template/error.rb +21 -1
  51. data/lib/action_view/template/handlers.rb +27 -1
  52. data/lib/action_view/template/handlers/builder.rb +2 -2
  53. data/lib/action_view/template/handlers/erb.rb +17 -7
  54. data/lib/action_view/template/handlers/erb/erubi.rb +7 -3
  55. data/lib/action_view/template/handlers/html.rb +1 -1
  56. data/lib/action_view/template/handlers/raw.rb +2 -2
  57. data/lib/action_view/template/html.rb +14 -5
  58. data/lib/action_view/template/inline.rb +22 -0
  59. data/lib/action_view/template/raw_file.rb +28 -0
  60. data/lib/action_view/template/resolver.rb +136 -133
  61. data/lib/action_view/template/sources.rb +13 -0
  62. data/lib/action_view/template/sources/file.rb +17 -0
  63. data/lib/action_view/template/text.rb +5 -3
  64. data/lib/action_view/test_case.rb +1 -1
  65. data/lib/action_view/testing/resolvers.rb +33 -20
  66. data/lib/action_view/unbound_template.rb +32 -0
  67. data/lib/action_view/view_paths.rb +25 -1
  68. data/lib/assets/compiled/rails-ujs.js +29 -3
  69. metadata +25 -17
  70. data/lib/action_view/helpers/record_tag_helper.rb +0 -23
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ class Template
5
+ module Sources
6
+ extend ActiveSupport::Autoload
7
+
8
+ eager_autoload do
9
+ autoload :File
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ class Template
5
+ module Sources
6
+ class File
7
+ def initialize(filename)
8
+ @filename = filename
9
+ end
10
+
11
+ def to_s
12
+ ::File.binread @filename
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -8,7 +8,6 @@ module ActionView #:nodoc:
8
8
 
9
9
  def initialize(string)
10
10
  @string = string.to_s
11
- @type = Types[:text]
12
11
  end
13
12
 
14
13
  def identifier
@@ -25,9 +24,12 @@ module ActionView #:nodoc:
25
24
  to_str
26
25
  end
27
26
 
28
- def formats
29
- [@type.ref]
27
+ def format
28
+ :text
30
29
  end
30
+
31
+ def formats; Array(format); end
32
+ deprecate :formats
31
33
  end
32
34
  end
33
35
  end
@@ -107,7 +107,7 @@ module ActionView
107
107
  # empty string ensures buffer has UTF-8 encoding as
108
108
  # new without arguments returns ASCII-8BIT encoded buffer like String#new
109
109
  @output_buffer = ActiveSupport::SafeBuffer.new ""
110
- @rendered = "".dup
110
+ @rendered = +""
111
111
 
112
112
  make_test_case_available_to_view!
113
113
  say_no_to_protect_against_forgery!
@@ -7,12 +7,19 @@ module ActionView #:nodoc:
7
7
  # file system. This is used internally by Rails' own test suite, and is
8
8
  # useful for testing extensions that have no way of knowing what the file
9
9
  # system will look like at runtime.
10
- class FixtureResolver < PathResolver
11
- attr_reader :hash
12
-
10
+ class FixtureResolver < OptimizedFileSystemResolver
13
11
  def initialize(hash = {}, pattern = nil)
14
- super(pattern)
12
+ super("")
13
+ if pattern
14
+ ActiveSupport::Deprecation.warn "Specifying a custom path for #{self.class} is deprecated. Implement a custom Resolver subclass instead."
15
+ @pattern = pattern
16
+ end
15
17
  @hash = hash
18
+ @path = ""
19
+ end
20
+
21
+ def data
22
+ @hash
16
23
  end
17
24
 
18
25
  def to_s
@@ -21,34 +28,40 @@ module ActionView #:nodoc:
21
28
 
22
29
  private
23
30
 
24
- def query(path, exts, _, _)
25
- query = "".dup
26
- EXTENSIONS.each_key do |ext|
27
- query << "(" << exts[ext].map { |e| e && Regexp.escape(".#{e}") }.join("|") << "|)"
28
- end
29
- query = /^(#{Regexp.escape(path)})#{query}$/
31
+ def query(path, exts, _, locals, cache:)
32
+ regex = build_regex(path, exts)
30
33
 
31
- templates = []
32
- @hash.each do |_path, array|
33
- source, updated_at = array
34
- next unless query.match?(_path)
34
+ @hash.select do |_path, _|
35
+ ("/" + _path).match?(regex)
36
+ end.map do |_path, source|
35
37
  handler, format, variant = extract_handler_and_format_and_variant(_path)
36
- templates << Template.new(source, _path, handler,
38
+
39
+ Template.new(source, _path, handler,
37
40
  virtual_path: path.virtual,
38
41
  format: format,
39
42
  variant: variant,
40
- updated_at: updated_at
43
+ locals: locals
41
44
  )
45
+ end.sort_by do |t|
46
+ match = ("/" + t.identifier).match(regex)
47
+ EXTENSIONS.keys.reverse.map do |ext|
48
+ if ext == :variants && exts[ext] == :any
49
+ match[ext].nil? ? 0 : 1
50
+ elsif match[ext].nil?
51
+ exts[ext].length
52
+ else
53
+ found = match[ext].to_sym
54
+ exts[ext].index(found)
55
+ end
56
+ end
42
57
  end
43
-
44
- templates.sort_by { |t| -t.identifier.match(/^#{query}$/).captures.reject(&:blank?).size }
45
58
  end
46
59
  end
47
60
 
48
61
  class NullResolver < PathResolver
49
- def query(path, exts, _, _)
62
+ def query(path, exts, _, locals, cache:)
50
63
  handler, format, variant = extract_handler_and_format_and_variant(path)
51
- [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant)]
64
+ [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant, locals: locals)]
52
65
  end
53
66
  end
54
67
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "concurrent/map"
4
+
5
+ module ActionView
6
+ class UnboundTemplate
7
+ def initialize(source, identifer, handler, options)
8
+ @source = source
9
+ @identifer = identifer
10
+ @handler = handler
11
+ @options = options
12
+
13
+ @templates = Concurrent::Map.new(initial_capacity: 2)
14
+ end
15
+
16
+ def bind_locals(locals)
17
+ @templates[locals] ||= build_template(locals)
18
+ end
19
+
20
+ private
21
+
22
+ def build_template(locals)
23
+ options = @options.merge(locals: locals)
24
+ Template.new(
25
+ @source,
26
+ @identifer,
27
+ @handler,
28
+ options
29
+ )
30
+ end
31
+ end
32
+ end
@@ -5,13 +5,21 @@ module ActionView
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- class_attribute :_view_paths, default: ActionView::PathSet.new.freeze
8
+ ViewPaths.set_view_paths(self, ActionView::PathSet.new.freeze)
9
9
  end
10
10
 
11
11
  delegate :template_exists?, :any_templates?, :view_paths, :formats, :formats=,
12
12
  :locale, :locale=, to: :lookup_context
13
13
 
14
14
  module ClassMethods
15
+ def _view_paths
16
+ ViewPaths.get_view_paths(self)
17
+ end
18
+
19
+ def _view_paths=(paths)
20
+ ViewPaths.set_view_paths(self, paths)
21
+ end
22
+
15
23
  def _prefixes # :nodoc:
16
24
  @_prefixes ||= begin
17
25
  return local_prefixes if superclass.abstract?
@@ -29,6 +37,22 @@ module ActionView
29
37
  end
30
38
  end
31
39
 
40
+ # :stopdoc:
41
+ @all_view_paths = {}
42
+
43
+ def self.get_view_paths(klass)
44
+ @all_view_paths[klass] || get_view_paths(klass.superclass)
45
+ end
46
+
47
+ def self.set_view_paths(klass, paths)
48
+ @all_view_paths[klass] = paths
49
+ end
50
+
51
+ def self.all_view_paths
52
+ @all_view_paths.values.uniq
53
+ end
54
+ # :startdoc:
55
+
32
56
  # The prefixes used in render "foo" shortcuts.
33
57
  def _prefixes # :nodoc:
34
58
  self.class._prefixes
@@ -320,6 +320,9 @@ Released under the MIT license
320
320
  if (!input.name || input.disabled) {
321
321
  return;
322
322
  }
323
+ if (matches(input, 'fieldset[disabled] *')) {
324
+ return;
325
+ }
323
326
  if (matches(input, 'select')) {
324
327
  return toArray(input.options).forEach(function(option) {
325
328
  if (option.selected) {
@@ -370,6 +373,10 @@ Released under the MIT license
370
373
  }
371
374
  };
372
375
 
376
+ Rails.confirm = function(message, element) {
377
+ return confirm(message);
378
+ };
379
+
373
380
  allowAction = function(element) {
374
381
  var answer, callback, message;
375
382
  message = element.getAttribute('data-confirm');
@@ -379,7 +386,7 @@ Released under the MIT license
379
386
  answer = false;
380
387
  if (fire(element, 'confirm')) {
381
388
  try {
382
- answer = confirm(message);
389
+ answer = Rails.confirm(message, element);
383
390
  } catch (error) {}
384
391
  callback = fire(element, 'confirm:complete', [answer]);
385
392
  }
@@ -388,7 +395,7 @@ Released under the MIT license
388
395
 
389
396
  }).call(this);
390
397
  (function() {
391
- var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, enableLinkElement, formElements, getData, matches, setData, stopEverything;
398
+ var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, enableLinkElement, formElements, getData, isXhrRedirect, matches, setData, stopEverything;
392
399
 
393
400
  matches = Rails.matches, getData = Rails.getData, setData = Rails.setData, stopEverything = Rails.stopEverything, formElements = Rails.formElements;
394
401
 
@@ -402,7 +409,14 @@ Released under the MIT license
402
409
 
403
410
  Rails.enableElement = function(e) {
404
411
  var element;
405
- element = e instanceof Event ? e.target : e;
412
+ if (e instanceof Event) {
413
+ if (isXhrRedirect(e)) {
414
+ return;
415
+ }
416
+ element = e.target;
417
+ } else {
418
+ element = e;
419
+ }
406
420
  if (matches(element, Rails.linkDisableSelector)) {
407
421
  return enableLinkElement(element);
408
422
  } else if (matches(element, Rails.buttonDisableSelector) || matches(element, Rails.formEnableSelector)) {
@@ -426,6 +440,9 @@ Released under the MIT license
426
440
 
427
441
  disableLinkElement = function(element) {
428
442
  var replacement;
443
+ if (getData(element, 'ujs:disabled')) {
444
+ return;
445
+ }
429
446
  replacement = element.getAttribute('data-disable-with');
430
447
  if (replacement != null) {
431
448
  setData(element, 'ujs:enable-with', element.innerHTML);
@@ -452,6 +469,9 @@ Released under the MIT license
452
469
 
453
470
  disableFormElement = function(element) {
454
471
  var replacement;
472
+ if (getData(element, 'ujs:disabled')) {
473
+ return;
474
+ }
455
475
  replacement = element.getAttribute('data-disable-with');
456
476
  if (replacement != null) {
457
477
  if (matches(element, 'button')) {
@@ -485,6 +505,12 @@ Released under the MIT license
485
505
  return setData(element, 'ujs:disabled', null);
486
506
  };
487
507
 
508
+ isXhrRedirect = function(event) {
509
+ var ref, xhr;
510
+ xhr = (ref = event.detail) != null ? ref[0] : void 0;
511
+ return (xhr != null ? xhr.getResponseHeader("X-Xhr-Redirect") : void 0) != null;
512
+ };
513
+
488
514
  }).call(this);
489
515
  (function() {
490
516
  var stopEverything;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.4.1
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-18 00:00:00.000000000 Z
11
+ date: 2019-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.4.1
19
+ version: 6.0.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.4.1
26
+ version: 6.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,20 +58,20 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: '1.1'
62
62
  - - ">="
63
63
  - !ruby/object:Gem::Version
64
- version: 1.0.3
64
+ version: 1.2.0
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: '1.0'
71
+ version: '1.1'
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 1.0.3
74
+ version: 1.2.0
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rails-dom-testing
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 5.2.4.1
95
+ version: 6.0.1
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 5.2.4.1
102
+ version: 6.0.1
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: activemodel
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 5.2.4.1
109
+ version: 6.0.1
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 5.2.4.1
116
+ version: 6.0.1
117
117
  description: Simple, battle-tested conventions and helpers for building web pages.
118
118
  email: david@loudthinking.com
119
119
  executables: []
@@ -126,6 +126,7 @@ files:
126
126
  - lib/action_view.rb
127
127
  - lib/action_view/base.rb
128
128
  - lib/action_view/buffers.rb
129
+ - lib/action_view/cache_expiry.rb
129
130
  - lib/action_view/context.rb
130
131
  - lib/action_view/dependency_tracker.rb
131
132
  - lib/action_view/digestor.rb
@@ -149,7 +150,6 @@ files:
149
150
  - lib/action_view/helpers/javascript_helper.rb
150
151
  - lib/action_view/helpers/number_helper.rb
151
152
  - lib/action_view/helpers/output_safety_helper.rb
152
- - lib/action_view/helpers/record_tag_helper.rb
153
153
  - lib/action_view/helpers/rendering_helper.rb
154
154
  - lib/action_view/helpers/sanitize_helper.rb
155
155
  - lib/action_view/helpers/tag_helper.rb
@@ -218,20 +218,28 @@ files:
218
218
  - lib/action_view/template/handlers/html.rb
219
219
  - lib/action_view/template/handlers/raw.rb
220
220
  - lib/action_view/template/html.rb
221
+ - lib/action_view/template/inline.rb
222
+ - lib/action_view/template/raw_file.rb
221
223
  - lib/action_view/template/resolver.rb
224
+ - lib/action_view/template/sources.rb
225
+ - lib/action_view/template/sources/file.rb
222
226
  - lib/action_view/template/text.rb
223
227
  - lib/action_view/template/types.rb
224
228
  - lib/action_view/test_case.rb
225
229
  - lib/action_view/testing/resolvers.rb
230
+ - lib/action_view/unbound_template.rb
226
231
  - lib/action_view/version.rb
227
232
  - lib/action_view/view_paths.rb
228
233
  - lib/assets/compiled/rails-ujs.js
229
- homepage: http://rubyonrails.org
234
+ homepage: https://rubyonrails.org
230
235
  licenses:
231
236
  - MIT
232
237
  metadata:
233
- source_code_uri: https://github.com/rails/rails/tree/v5.2.4.1/actionview
234
- changelog_uri: https://github.com/rails/rails/blob/v5.2.4.1/actionview/CHANGELOG.md
238
+ bug_tracker_uri: https://github.com/rails/rails/issues
239
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.1/actionview/CHANGELOG.md
240
+ documentation_uri: https://api.rubyonrails.org/v6.0.1/
241
+ mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
242
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.1/actionview
235
243
  post_install_message:
236
244
  rdoc_options: []
237
245
  require_paths:
@@ -240,7 +248,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
248
  requirements:
241
249
  - - ">="
242
250
  - !ruby/object:Gem::Version
243
- version: 2.2.2
251
+ version: 2.5.0
244
252
  required_rubygems_version: !ruby/object:Gem::Requirement
245
253
  requirements:
246
254
  - - ">="