actionview 5.2.4.rc1 → 6.0.0.rc2

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 +182 -77
  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 +8 -17
  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 +23 -15
  22. data/lib/action_view/helpers/form_tag_helper.rb +12 -11
  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 +3 -3
  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 -52
  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 +12 -11
  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 +27 -4
  69. metadata +19 -14
  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!
@@ -8,36 +8,37 @@ module ActionView #:nodoc:
8
8
  # useful for testing extensions that have no way of knowing what the file
9
9
  # system will look like at runtime.
10
10
  class FixtureResolver < PathResolver
11
- attr_reader :hash
12
-
13
11
  def initialize(hash = {}, pattern = nil)
14
12
  super(pattern)
15
13
  @hash = hash
16
14
  end
17
15
 
16
+ def data
17
+ @hash
18
+ end
19
+
18
20
  def to_s
19
21
  @hash.keys.join(", ")
20
22
  end
21
23
 
22
24
  private
23
25
 
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("|") << "|)"
26
+ def query(path, exts, _, locals, cache:)
27
+ query = +""
28
+ EXTENSIONS.each do |ext, prefix|
29
+ query << "(" << exts[ext].map { |e| e && Regexp.escape("#{prefix}#{e}") }.join("|") << "|)"
28
30
  end
29
31
  query = /^(#{Regexp.escape(path)})#{query}$/
30
32
 
31
33
  templates = []
32
- @hash.each do |_path, array|
33
- source, updated_at = array
34
+ @hash.each do |_path, source|
34
35
  next unless query.match?(_path)
35
36
  handler, format, variant = extract_handler_and_format_and_variant(_path)
36
37
  templates << Template.new(source, _path, handler,
37
38
  virtual_path: path.virtual,
38
39
  format: format,
39
40
  variant: variant,
40
- updated_at: updated_at
41
+ locals: locals
41
42
  )
42
43
  end
43
44
 
@@ -46,9 +47,9 @@ module ActionView #:nodoc:
46
47
  end
47
48
 
48
49
  class NullResolver < PathResolver
49
- def query(path, exts, _, _)
50
+ def query(path, exts, _, locals, cache:)
50
51
  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)]
52
+ [ActionView::Template.new("Template generated by Null Resolver", path.virtual, handler, virtual_path: path.virtual, format: format, variant: variant, locals: locals)]
52
53
  end
53
54
  end
54
55
  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
@@ -2,7 +2,7 @@
2
2
  Unobtrusive JavaScript
3
3
  https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts
4
4
  Released under the MIT license
5
- */;
5
+ */
6
6
 
7
7
  (function() {
8
8
  var context = this;
@@ -370,6 +370,10 @@ Released under the MIT license
370
370
  }
371
371
  };
372
372
 
373
+ Rails.confirm = function(message, element) {
374
+ return confirm(message);
375
+ };
376
+
373
377
  allowAction = function(element) {
374
378
  var answer, callback, message;
375
379
  message = element.getAttribute('data-confirm');
@@ -379,7 +383,7 @@ Released under the MIT license
379
383
  answer = false;
380
384
  if (fire(element, 'confirm')) {
381
385
  try {
382
- answer = confirm(message);
386
+ answer = Rails.confirm(message, element);
383
387
  } catch (error) {}
384
388
  callback = fire(element, 'confirm:complete', [answer]);
385
389
  }
@@ -388,7 +392,7 @@ Released under the MIT license
388
392
 
389
393
  }).call(this);
390
394
  (function() {
391
- var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, enableLinkElement, formElements, getData, matches, setData, stopEverything;
395
+ var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, enableLinkElement, formElements, getData, isXhrRedirect, matches, setData, stopEverything;
392
396
 
393
397
  matches = Rails.matches, getData = Rails.getData, setData = Rails.setData, stopEverything = Rails.stopEverything, formElements = Rails.formElements;
394
398
 
@@ -402,7 +406,14 @@ Released under the MIT license
402
406
 
403
407
  Rails.enableElement = function(e) {
404
408
  var element;
405
- element = e instanceof Event ? e.target : e;
409
+ if (e instanceof Event) {
410
+ if (isXhrRedirect(e)) {
411
+ return;
412
+ }
413
+ element = e.target;
414
+ } else {
415
+ element = e;
416
+ }
406
417
  if (matches(element, Rails.linkDisableSelector)) {
407
418
  return enableLinkElement(element);
408
419
  } else if (matches(element, Rails.buttonDisableSelector) || matches(element, Rails.formEnableSelector)) {
@@ -426,6 +437,9 @@ Released under the MIT license
426
437
 
427
438
  disableLinkElement = function(element) {
428
439
  var replacement;
440
+ if (getData(element, 'ujs:disabled')) {
441
+ return;
442
+ }
429
443
  replacement = element.getAttribute('data-disable-with');
430
444
  if (replacement != null) {
431
445
  setData(element, 'ujs:enable-with', element.innerHTML);
@@ -452,6 +466,9 @@ Released under the MIT license
452
466
 
453
467
  disableFormElement = function(element) {
454
468
  var replacement;
469
+ if (getData(element, 'ujs:disabled')) {
470
+ return;
471
+ }
455
472
  replacement = element.getAttribute('data-disable-with');
456
473
  if (replacement != null) {
457
474
  if (matches(element, 'button')) {
@@ -485,6 +502,12 @@ Released under the MIT license
485
502
  return setData(element, 'ujs:disabled', null);
486
503
  };
487
504
 
505
+ isXhrRedirect = function(event) {
506
+ var ref, xhr;
507
+ xhr = (ref = event.detail) != null ? ref[0] : void 0;
508
+ return (xhr != null ? xhr.getResponseHeader("X-Xhr-Redirect") : void 0) != null;
509
+ };
510
+
488
511
  }).call(this);
489
512
  (function() {
490
513
  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.rc1
4
+ version: 6.0.0.rc2
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-11-23 00:00:00.000000000 Z
11
+ date: 2019-07-22 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.rc1
19
+ version: 6.0.0.rc2
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.rc1
26
+ version: 6.0.0.rc2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  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.rc1
95
+ version: 6.0.0.rc2
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.rc1
102
+ version: 6.0.0.rc2
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.rc1
109
+ version: 6.0.0.rc2
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.rc1
116
+ version: 6.0.0.rc2
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,25 @@ 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.rc1/actionview
234
- changelog_uri: https://github.com/rails/rails/blob/v5.2.4.rc1/actionview/CHANGELOG.md
238
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.0.rc2/actionview
239
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.0.rc2/actionview/CHANGELOG.md
235
240
  post_install_message:
236
241
  rdoc_options: []
237
242
  require_paths:
@@ -240,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
245
  requirements:
241
246
  - - ">="
242
247
  - !ruby/object:Gem::Version
243
- version: 2.2.2
248
+ version: 2.5.0
244
249
  required_rubygems_version: !ruby/object:Gem::Requirement
245
250
  requirements:
246
251
  - - ">"
@@ -248,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
253
  version: 1.3.1
249
254
  requirements:
250
255
  - none
251
- rubygems_version: 3.0.3
256
+ rubygems_version: 3.0.1
252
257
  signing_key:
253
258
  specification_version: 4
254
259
  summary: Rendering framework putting the V in MVC (part of Rails).
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActionView
4
- module Helpers #:nodoc:
5
- module RecordTagHelper
6
- def div_for(*) # :nodoc:
7
- raise NoMethodError, "The `div_for` method has been removed from " \
8
- "Rails. To continue using it, add the `record_tag_helper` gem to " \
9
- "your Gemfile:\n" \
10
- " gem 'record_tag_helper', '~> 1.0'\n" \
11
- "Consult the Rails upgrade guide for details."
12
- end
13
-
14
- def content_tag_for(*) # :nodoc:
15
- raise NoMethodError, "The `content_tag_for` method has been removed from " \
16
- "Rails. To continue using it, add the `record_tag_helper` gem to " \
17
- "your Gemfile:\n" \
18
- " gem 'record_tag_helper', '~> 1.0'\n" \
19
- "Consult the Rails upgrade guide for details."
20
- end
21
- end
22
- end
23
- end