actionview 4.1.13 → 6.1.3.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.
- checksums.yaml +5 -5
- data/CHANGELOG.md +181 -359
- data/MIT-LICENSE +1 -1
- data/README.rdoc +12 -6
- data/lib/action_view/base.rb +115 -43
- data/lib/action_view/buffers.rb +22 -4
- data/lib/action_view/cache_expiry.rb +52 -0
- data/lib/action_view/context.rb +8 -12
- data/lib/action_view/dependency_tracker.rb +61 -21
- data/lib/action_view/digestor.rb +89 -84
- data/lib/action_view/flows.rb +12 -13
- data/lib/action_view/gem_version.rb +6 -4
- data/lib/action_view/helpers/active_model_helper.rb +16 -11
- data/lib/action_view/helpers/asset_tag_helper.rb +311 -105
- data/lib/action_view/helpers/asset_url_helper.rb +197 -80
- data/lib/action_view/helpers/atom_feed_helper.rb +20 -17
- data/lib/action_view/helpers/cache_helper.rb +109 -45
- data/lib/action_view/helpers/capture_helper.rb +20 -22
- data/lib/action_view/helpers/controller_helper.rb +15 -4
- data/lib/action_view/helpers/csp_helper.rb +26 -0
- data/lib/action_view/helpers/csrf_helper.rb +8 -6
- data/lib/action_view/helpers/date_helper.rb +245 -140
- data/lib/action_view/helpers/debug_helper.rb +14 -17
- data/lib/action_view/helpers/form_helper.rb +875 -148
- data/lib/action_view/helpers/form_options_helper.rb +128 -82
- data/lib/action_view/helpers/form_tag_helper.rb +253 -91
- data/lib/action_view/helpers/javascript_helper.rb +37 -15
- data/lib/action_view/helpers/number_helper.rb +100 -77
- data/lib/action_view/helpers/output_safety_helper.rb +42 -10
- data/lib/action_view/helpers/rendering_helper.rb +26 -15
- data/lib/action_view/helpers/sanitize_helper.rb +79 -164
- data/lib/action_view/helpers/tag_helper.rb +277 -64
- data/lib/action_view/helpers/tags/base.rb +143 -92
- data/lib/action_view/helpers/tags/check_box.rb +20 -19
- data/lib/action_view/helpers/tags/checkable.rb +4 -2
- data/lib/action_view/helpers/tags/collection_check_boxes.rb +12 -30
- data/lib/action_view/helpers/tags/collection_helpers.rb +69 -36
- data/lib/action_view/helpers/tags/collection_radio_buttons.rb +6 -12
- data/lib/action_view/helpers/tags/collection_select.rb +4 -2
- data/lib/action_view/helpers/tags/color_field.rb +4 -3
- data/lib/action_view/helpers/tags/date_field.rb +3 -2
- data/lib/action_view/helpers/tags/date_select.rb +38 -37
- data/lib/action_view/helpers/tags/datetime_field.rb +14 -5
- data/lib/action_view/helpers/tags/datetime_local_field.rb +3 -2
- data/lib/action_view/helpers/tags/datetime_select.rb +2 -0
- data/lib/action_view/helpers/tags/email_field.rb +2 -0
- data/lib/action_view/helpers/tags/file_field.rb +2 -0
- data/lib/action_view/helpers/tags/grouped_collection_select.rb +4 -2
- data/lib/action_view/helpers/tags/hidden_field.rb +2 -0
- data/lib/action_view/helpers/tags/label.rb +41 -22
- data/lib/action_view/helpers/tags/month_field.rb +3 -2
- data/lib/action_view/helpers/tags/number_field.rb +2 -0
- data/lib/action_view/helpers/tags/password_field.rb +3 -1
- data/lib/action_view/helpers/tags/placeholderable.rb +24 -0
- data/lib/action_view/helpers/tags/radio_button.rb +7 -6
- data/lib/action_view/helpers/tags/range_field.rb +2 -0
- data/lib/action_view/helpers/tags/search_field.rb +3 -0
- data/lib/action_view/helpers/tags/select.rb +11 -10
- data/lib/action_view/helpers/tags/tel_field.rb +2 -0
- data/lib/action_view/helpers/tags/text_area.rb +7 -1
- data/lib/action_view/helpers/tags/text_field.rb +11 -7
- data/lib/action_view/helpers/tags/time_field.rb +3 -2
- data/lib/action_view/helpers/tags/time_select.rb +2 -0
- data/lib/action_view/helpers/tags/time_zone_select.rb +3 -1
- data/lib/action_view/helpers/tags/translator.rb +39 -0
- data/lib/action_view/helpers/tags/url_field.rb +2 -0
- data/lib/action_view/helpers/tags/week_field.rb +3 -2
- data/lib/action_view/helpers/tags.rb +4 -1
- data/lib/action_view/helpers/text_helper.rb +80 -45
- data/lib/action_view/helpers/translation_helper.rb +148 -67
- data/lib/action_view/helpers/url_helper.rb +289 -147
- data/lib/action_view/helpers.rb +5 -3
- data/lib/action_view/layouts.rb +68 -63
- data/lib/action_view/log_subscriber.rb +80 -13
- data/lib/action_view/lookup_context.rb +137 -92
- data/lib/action_view/model_naming.rb +4 -2
- data/lib/action_view/path_set.rb +30 -16
- data/lib/action_view/railtie.rb +62 -13
- data/lib/action_view/record_identifier.rb +53 -26
- data/lib/action_view/renderer/abstract_renderer.rb +152 -13
- data/lib/action_view/renderer/collection_renderer.rb +196 -0
- data/lib/action_view/renderer/object_renderer.rb +34 -0
- data/lib/action_view/renderer/partial_renderer/collection_caching.rb +102 -0
- data/lib/action_view/renderer/partial_renderer.rb +61 -261
- data/lib/action_view/renderer/renderer.rb +67 -6
- data/lib/action_view/renderer/streaming_template_renderer.rb +58 -54
- data/lib/action_view/renderer/template_renderer.rb +83 -75
- data/lib/action_view/rendering.rb +73 -46
- data/lib/action_view/routing_url_for.rb +54 -17
- data/lib/action_view/tasks/cache_digests.rake +25 -0
- data/lib/action_view/template/error.rb +44 -29
- data/lib/action_view/template/handlers/builder.rb +12 -13
- data/lib/action_view/template/handlers/erb/erubi.rb +89 -0
- data/lib/action_view/template/handlers/erb.rb +23 -89
- data/lib/action_view/template/handlers/html.rb +11 -0
- data/lib/action_view/template/handlers/raw.rb +4 -4
- data/lib/action_view/template/handlers.rb +22 -9
- data/lib/action_view/template/html.rb +10 -11
- data/lib/action_view/template/inline.rb +22 -0
- data/lib/action_view/template/raw_file.rb +25 -0
- data/lib/action_view/template/renderable.rb +24 -0
- data/lib/action_view/template/resolver.rb +267 -181
- data/lib/action_view/template/sources/file.rb +17 -0
- data/lib/action_view/template/sources.rb +13 -0
- data/lib/action_view/template/text.rb +8 -10
- data/lib/action_view/template/types.rb +18 -18
- data/lib/action_view/template.rb +109 -99
- data/lib/action_view/test_case.rb +73 -53
- data/lib/action_view/testing/resolvers.rb +24 -33
- data/lib/action_view/unbound_template.rb +31 -0
- data/lib/action_view/version.rb +3 -1
- data/lib/action_view/view_paths.rb +74 -44
- data/lib/action_view.rb +14 -9
- data/lib/assets/compiled/rails-ujs.js +746 -0
- metadata +71 -26
- data/lib/action_view/helpers/record_tag_helper.rb +0 -108
- data/lib/action_view/tasks/dependencies.rake +0 -23
- data/lib/action_view/vendor/html-scanner/html/document.rb +0 -68
- data/lib/action_view/vendor/html-scanner/html/node.rb +0 -532
- data/lib/action_view/vendor/html-scanner/html/sanitizer.rb +0 -188
- data/lib/action_view/vendor/html-scanner/html/selector.rb +0 -830
- data/lib/action_view/vendor/html-scanner/html/tokenizer.rb +0 -107
- data/lib/action_view/vendor/html-scanner/html/version.rb +0 -11
- data/lib/action_view/vendor/html-scanner.rb +0 -20
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_view/helpers/tags/collection_helpers"
|
2
4
|
|
3
5
|
module ActionView
|
4
6
|
module Helpers
|
@@ -7,26 +9,18 @@ module ActionView
|
|
7
9
|
include CollectionHelpers
|
8
10
|
|
9
11
|
class RadioButtonBuilder < Builder # :nodoc:
|
10
|
-
def radio_button(extra_html_options={})
|
12
|
+
def radio_button(extra_html_options = {})
|
11
13
|
html_options = extra_html_options.merge(@input_html_options)
|
14
|
+
html_options[:skip_default_ids] = false
|
12
15
|
@template_object.radio_button(@object_name, @method_name, @value, html_options)
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
16
19
|
def render(&block)
|
17
|
-
|
18
|
-
builder = instantiate_builder(RadioButtonBuilder, item, value, text, default_html_options)
|
19
|
-
|
20
|
-
if block_given?
|
21
|
-
@template_object.capture(builder, &block)
|
22
|
-
else
|
23
|
-
render_component(builder)
|
24
|
-
end
|
25
|
-
end
|
20
|
+
render_collection_for(RadioButtonBuilder, &block)
|
26
21
|
end
|
27
22
|
|
28
23
|
private
|
29
|
-
|
30
24
|
def render_component(builder)
|
31
25
|
builder.radio_button + builder.label
|
32
26
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -13,8 +15,8 @@ module ActionView
|
|
13
15
|
|
14
16
|
def render
|
15
17
|
option_tags_options = {
|
16
|
-
:
|
17
|
-
:
|
18
|
+
selected: @options.fetch(:selected) { value },
|
19
|
+
disabled: @options[:disabled]
|
18
20
|
}
|
19
21
|
|
20
22
|
select_content_tag(
|
@@ -1,19 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class ColorField < TextField # :nodoc:
|
5
7
|
def render
|
6
8
|
options = @options.stringify_keys
|
7
|
-
options["value"] ||= validate_color_string(value
|
9
|
+
options["value"] ||= validate_color_string(value)
|
8
10
|
@options = options
|
9
11
|
super
|
10
12
|
end
|
11
13
|
|
12
14
|
private
|
13
|
-
|
14
15
|
def validate_color_string(string)
|
15
16
|
regex = /#[0-9a-fA-F]{6}/
|
16
|
-
if regex.match(string)
|
17
|
+
if regex.match?(string)
|
17
18
|
string.downcase
|
18
19
|
else
|
19
20
|
"#000000"
|
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class DateField < DatetimeField # :nodoc:
|
5
7
|
private
|
6
|
-
|
7
8
|
def format_date(value)
|
8
|
-
value
|
9
|
+
value&.strftime("%Y-%m-%d")
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/time/calculations"
|
2
4
|
|
3
5
|
module ActionView
|
4
6
|
module Helpers
|
@@ -11,61 +13,60 @@ module ActionView
|
|
11
13
|
end
|
12
14
|
|
13
15
|
def render
|
14
|
-
error_wrapping(datetime_selector(@options, @html_options).
|
16
|
+
error_wrapping(datetime_selector(@options, @html_options).public_send("select_#{select_type}").html_safe)
|
15
17
|
end
|
16
18
|
|
17
19
|
class << self
|
18
20
|
def select_type
|
19
|
-
@select_type ||=
|
21
|
+
@select_type ||= name.split("::").last.sub("Select", "").downcase
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
26
|
+
def select_type
|
27
|
+
self.class.select_type
|
28
|
+
end
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
30
|
+
def datetime_selector(options, html_options)
|
31
|
+
datetime = options.fetch(:selected) { value || default_datetime(options) }
|
32
|
+
@auto_index ||= nil
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
options = options.dup
|
35
|
+
options[:field_name] = @method_name
|
36
|
+
options[:include_position] = true
|
37
|
+
options[:prefix] ||= @object_name
|
38
|
+
options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
options[:include_position] = true
|
36
|
-
options[:prefix] ||= @object_name
|
37
|
-
options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
|
40
|
+
DateTimeSelector.new(datetime, options, html_options)
|
41
|
+
end
|
38
42
|
|
39
|
-
|
40
|
-
|
43
|
+
def default_datetime(options)
|
44
|
+
return if options[:include_blank] || options[:prompt]
|
41
45
|
|
42
|
-
|
43
|
-
|
46
|
+
case options[:default]
|
47
|
+
when nil
|
48
|
+
Time.current
|
49
|
+
when Date, Time
|
50
|
+
options[:default]
|
51
|
+
else
|
52
|
+
default = options[:default].dup
|
44
53
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
when Date, Time
|
49
|
-
options[:default]
|
50
|
-
else
|
51
|
-
default = options[:default].dup
|
54
|
+
# Rename :minute and :second to :min and :sec
|
55
|
+
default[:min] ||= default[:minute]
|
56
|
+
default[:sec] ||= default[:second]
|
52
57
|
|
53
|
-
|
54
|
-
default[:min] ||= default[:minute]
|
55
|
-
default[:sec] ||= default[:second]
|
58
|
+
time = Time.current
|
56
59
|
|
57
|
-
|
60
|
+
[:year, :month, :day, :hour, :min, :sec].each do |key|
|
61
|
+
default[key] ||= time.public_send(key)
|
62
|
+
end
|
58
63
|
|
59
|
-
|
60
|
-
|
64
|
+
Time.utc(
|
65
|
+
default[:year], default[:month], default[:day],
|
66
|
+
default[:hour], default[:min], default[:sec]
|
67
|
+
)
|
61
68
|
end
|
62
|
-
|
63
|
-
Time.utc(
|
64
|
-
default[:year], default[:month], default[:day],
|
65
|
-
default[:hour], default[:min], default[:sec]
|
66
|
-
)
|
67
69
|
end
|
68
|
-
end
|
69
70
|
end
|
70
71
|
end
|
71
72
|
end
|
@@ -1,20 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class DatetimeField < TextField # :nodoc:
|
5
7
|
def render
|
6
8
|
options = @options.stringify_keys
|
7
|
-
options["value"] ||= format_date(value
|
8
|
-
options["min"] = format_date(options["min"])
|
9
|
-
options["max"] = format_date(options["max"])
|
9
|
+
options["value"] ||= format_date(value)
|
10
|
+
options["min"] = format_date(datetime_value(options["min"]))
|
11
|
+
options["max"] = format_date(datetime_value(options["max"]))
|
10
12
|
@options = options
|
11
13
|
super
|
12
14
|
end
|
13
15
|
|
14
16
|
private
|
15
|
-
|
16
17
|
def format_date(value)
|
17
|
-
|
18
|
+
raise NotImplementedError
|
19
|
+
end
|
20
|
+
|
21
|
+
def datetime_value(value)
|
22
|
+
if value.is_a? String
|
23
|
+
DateTime.parse(value) rescue nil
|
24
|
+
else
|
25
|
+
value
|
26
|
+
end
|
18
27
|
end
|
19
28
|
end
|
20
29
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -9,9 +11,8 @@ module ActionView
|
|
9
11
|
end
|
10
12
|
|
11
13
|
private
|
12
|
-
|
13
14
|
def format_date(value)
|
14
|
-
value
|
15
|
+
value&.strftime("%Y-%m-%dT%T")
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
@@ -15,8 +17,8 @@ module ActionView
|
|
15
17
|
|
16
18
|
def render
|
17
19
|
option_tags_options = {
|
18
|
-
:
|
19
|
-
:
|
20
|
+
selected: @options.fetch(:selected) { value },
|
21
|
+
disabled: @options[:disabled]
|
20
22
|
}
|
21
23
|
|
22
24
|
select_content_tag(
|
@@ -1,7 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class Label < Base # :nodoc:
|
7
|
+
class LabelBuilder # :nodoc:
|
8
|
+
attr_reader :object
|
9
|
+
|
10
|
+
def initialize(template_object, object_name, method_name, object, tag_value)
|
11
|
+
@template_object = template_object
|
12
|
+
@object_name = object_name
|
13
|
+
@method_name = method_name
|
14
|
+
@object = object
|
15
|
+
@tag_value = tag_value
|
16
|
+
end
|
17
|
+
|
18
|
+
def translation
|
19
|
+
method_and_value = @tag_value.present? ? "#{@method_name}.#{@tag_value}" : @method_name
|
20
|
+
|
21
|
+
content ||= Translator
|
22
|
+
.new(object, @object_name, method_and_value, scope: "helpers.label")
|
23
|
+
.translate
|
24
|
+
content ||= @method_name.humanize
|
25
|
+
|
26
|
+
content
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
translation
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
5
34
|
def initialize(object_name, method_name, template_object, content_or_options = nil, options = nil)
|
6
35
|
options ||= {}
|
7
36
|
|
@@ -32,33 +61,23 @@ module ActionView
|
|
32
61
|
options.delete("namespace")
|
33
62
|
options["for"] = name_and_id["id"] unless options.key?("for")
|
34
63
|
|
35
|
-
|
36
|
-
content = @template_object.capture(&block)
|
37
|
-
else
|
38
|
-
content = if @content.blank?
|
39
|
-
@object_name.gsub!(/\[(.*)_attributes\]\[\d+\]/, '.\1')
|
40
|
-
method_and_value = tag_value.present? ? "#{@method_name}.#{tag_value}" : @method_name
|
41
|
-
|
42
|
-
if object.respond_to?(:to_model)
|
43
|
-
key = object.class.model_name.i18n_key
|
44
|
-
i18n_default = ["#{key}.#{method_and_value}".to_sym, ""]
|
45
|
-
end
|
46
|
-
|
47
|
-
i18n_default ||= ""
|
48
|
-
I18n.t("#{@object_name}.#{method_and_value}", :default => i18n_default, :scope => "helpers.label").presence
|
49
|
-
else
|
50
|
-
@content.to_s
|
51
|
-
end
|
64
|
+
builder = LabelBuilder.new(@template_object, @object_name, @method_name, @object, tag_value)
|
52
65
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
66
|
+
content = if block_given?
|
67
|
+
@template_object.capture(builder, &block)
|
68
|
+
elsif @content.present?
|
69
|
+
@content.to_s
|
70
|
+
else
|
71
|
+
render_component(builder)
|
58
72
|
end
|
59
73
|
|
60
74
|
label_tag(name_and_id["id"], content, options)
|
61
75
|
end
|
76
|
+
|
77
|
+
private
|
78
|
+
def render_component(builder)
|
79
|
+
builder.translation
|
80
|
+
end
|
62
81
|
end
|
63
82
|
end
|
64
83
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class MonthField < DatetimeField # :nodoc:
|
5
7
|
private
|
6
|
-
|
7
8
|
def format_date(value)
|
8
|
-
value
|
9
|
+
value&.strftime("%Y-%m")
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionView
|
2
4
|
module Helpers
|
3
5
|
module Tags # :nodoc:
|
4
6
|
class PasswordField < TextField # :nodoc:
|
5
7
|
def render
|
6
|
-
@options = {:
|
8
|
+
@options = { value: nil }.merge!(@options)
|
7
9
|
super
|
8
10
|
end
|
9
11
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
module Helpers
|
5
|
+
module Tags # :nodoc:
|
6
|
+
module Placeholderable # :nodoc:
|
7
|
+
def initialize(*)
|
8
|
+
super
|
9
|
+
|
10
|
+
if tag_value = @options[:placeholder]
|
11
|
+
placeholder = tag_value if tag_value.is_a?(String)
|
12
|
+
method_and_value = tag_value.is_a?(TrueClass) ? @method_name : "#{@method_name}.#{tag_value}"
|
13
|
+
|
14
|
+
placeholder ||= Tags::Translator
|
15
|
+
.new(object, @object_name, method_and_value, scope: "helpers.placeholder")
|
16
|
+
.translate
|
17
|
+
placeholder ||= @method_name.humanize
|
18
|
+
@options[:placeholder] = placeholder
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|