trusty-cms 4.1.6 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +114 -107
  3. data/INSTALL.md +2 -0
  4. data/app/controllers/admin/pages_controller.rb +1 -1
  5. data/app/controllers/admin/preferences_controller.rb +1 -1
  6. data/app/controllers/admin/resource_controller.rb +1 -1
  7. data/app/controllers/admin/users_controller.rb +1 -1
  8. data/config/environments/development.rb +2 -0
  9. data/lib/generators/extension/USAGE +30 -0
  10. data/lib/generators/extension/extension_generator.rb +97 -0
  11. data/lib/generators/extension/templates/README.md +6 -0
  12. data/lib/generators/extension/templates/RSpecRakefile +109 -0
  13. data/lib/generators/extension/templates/Rakefile +25 -0
  14. data/lib/generators/extension/templates/cucumber.yml +1 -0
  15. data/lib/generators/extension/templates/cucumber_env.rb +11 -0
  16. data/lib/generators/extension/templates/cucumber_paths.rb +22 -0
  17. data/lib/generators/extension/templates/en.yml +3 -0
  18. data/lib/generators/extension/templates/extension.rb +21 -0
  19. data/lib/generators/extension/templates/functional_test.rb +15 -0
  20. data/lib/generators/extension/templates/gemspec.rb +29 -0
  21. data/lib/generators/extension/templates/lib.rb +8 -0
  22. data/lib/generators/extension/templates/migration.rb +9 -0
  23. data/lib/generators/extension/templates/radiant_config.rb +3 -0
  24. data/lib/generators/extension/templates/routes.rb +5 -0
  25. data/lib/generators/extension/templates/spec.opts +6 -0
  26. data/lib/generators/extension/templates/spec_helper.rb +42 -0
  27. data/lib/generators/extension/templates/tasks.rake +47 -0
  28. data/lib/generators/extension/templates/test_helper.rb +26 -0
  29. data/lib/generators/extension_controller/USAGE +36 -0
  30. data/lib/generators/extension_controller/extension_controller_generator.rb +84 -0
  31. data/lib/generators/extension_controller/templates/controller.rb +10 -0
  32. data/lib/generators/extension_controller/templates/controller_spec.rb +23 -0
  33. data/lib/generators/extension_controller/templates/functional_test.rb +11 -0
  34. data/lib/generators/extension_controller/templates/helper.rb +2 -0
  35. data/lib/generators/extension_controller/templates/helper_spec.rb +11 -0
  36. data/lib/generators/extension_controller/templates/helper_test.rb +4 -0
  37. data/lib/generators/extension_controller/templates/view.html.erb +2 -0
  38. data/lib/generators/extension_controller/templates/view_spec.rb +12 -0
  39. data/lib/generators/extension_mailer/USAGE +17 -0
  40. data/lib/generators/extension_mailer/extension_mailer_generator.rb +68 -0
  41. data/lib/generators/extension_mailer/templates/fixture.erb +3 -0
  42. data/lib/generators/extension_mailer/templates/mailer.rb +15 -0
  43. data/lib/generators/extension_mailer/templates/unit_test.rb +21 -0
  44. data/lib/generators/extension_mailer/templates/view.erb +3 -0
  45. data/lib/generators/extension_migration/USAGE +34 -0
  46. data/lib/generators/extension_migration/extension_migration_generator.rb +25 -0
  47. data/lib/generators/extension_migration/templates/migration.rb +11 -0
  48. data/lib/generators/extension_model/USAGE +35 -0
  49. data/lib/generators/extension_model/extension_model_generator.rb +68 -0
  50. data/lib/generators/extension_model/templates/fixtures.yml +19 -0
  51. data/lib/generators/extension_model/templates/migration.rb +16 -0
  52. data/lib/generators/extension_model/templates/model.rb +2 -0
  53. data/lib/generators/extension_model/templates/model_spec.rb +11 -0
  54. data/lib/generators/extension_model/templates/unit_test.rb +8 -0
  55. data/lib/generators/generator_base_extension.rb +18 -0
  56. data/lib/generators/instance/instance_generator.rb +148 -0
  57. data/lib/generators/instance/templates/databases/db2.yml +40 -0
  58. data/lib/generators/instance/templates/databases/mysql.yml +47 -0
  59. data/lib/generators/instance/templates/databases/postgresql.yml +44 -0
  60. data/lib/generators/instance/templates/databases/sqlite3.yml +16 -0
  61. data/lib/generators/instance/templates/databases/sqlserver.yml +21 -0
  62. data/lib/generators/instance/templates/instance_boot.rb +122 -0
  63. data/lib/generators/instance/templates/instance_config.ru +2 -0
  64. data/lib/generators/instance/templates/instance_environment.rb +93 -0
  65. data/lib/generators/instance/templates/instance_gemfile +78 -0
  66. data/lib/generators/instance/templates/instance_generate +6 -0
  67. data/lib/generators/instance/templates/instance_radiant_config.rb +16 -0
  68. data/lib/generators/instance/templates/instance_rakefile +3 -0
  69. data/lib/generators/instance/templates/instance_routes.rb +1 -0
  70. data/lib/generators/language_extension/USAGE +27 -0
  71. data/lib/generators/language_extension/language_extension_generator.rb +71 -0
  72. data/lib/generators/language_extension/templates/README +3 -0
  73. data/lib/generators/language_extension/templates/RSpecRakefile +123 -0
  74. data/lib/generators/language_extension/templates/Rakefile +25 -0
  75. data/lib/generators/language_extension/templates/available_tags.yml +553 -0
  76. data/lib/generators/language_extension/templates/cucumber.yml +1 -0
  77. data/lib/generators/language_extension/templates/cucumber_env.rb +16 -0
  78. data/lib/generators/language_extension/templates/cucumber_paths.rb +14 -0
  79. data/lib/generators/language_extension/templates/extension.rb +12 -0
  80. data/lib/generators/language_extension/templates/functional_test.rb +15 -0
  81. data/lib/generators/language_extension/templates/gemspec.rb +24 -0
  82. data/lib/generators/language_extension/templates/lang.yml +181 -0
  83. data/lib/generators/language_extension/templates/lib.rb +8 -0
  84. data/lib/generators/language_extension/templates/spec.opts +6 -0
  85. data/lib/generators/language_extension/templates/spec_helper.rb +36 -0
  86. data/lib/generators/language_extension/templates/tasks.rake +28 -0
  87. data/lib/generators/language_extension/templates/test_helper.rb +26 -0
  88. data/lib/generators/trusty_cms/USAGE +8 -0
  89. data/lib/generators/trusty_cms/templates/Rakefile.erb +7 -0
  90. data/lib/generators/trusty_cms/templates/application.rb.erb +149 -0
  91. data/lib/generators/trusty_cms/templates/boot.rb.erb +9 -0
  92. data/lib/generators/trusty_cms/templates/config.ru.erb +4 -0
  93. data/lib/generators/trusty_cms/templates/database.yml.erb +28 -0
  94. data/lib/generators/trusty_cms/templates/environment.rb.erb +5 -0
  95. data/lib/generators/trusty_cms/templates/environments/development.rb.erb +24 -0
  96. data/lib/generators/trusty_cms/templates/environments/production.rb.erb +26 -0
  97. data/lib/generators/trusty_cms/templates/environments/test.rb.erb +35 -0
  98. data/lib/generators/trusty_cms/templates/initializers/secret_token.rb.erb +13 -0
  99. data/lib/generators/trusty_cms/templates/initializers/session_store.rb.erb +8 -0
  100. data/lib/generators/trusty_cms/templates/initializers/trusty_cms_config.rb.erb +16 -0
  101. data/lib/generators/trusty_cms/templates/preinitializer.rb.erb +18 -0
  102. data/lib/generators/trusty_cms/templates/routes.rb.erb +0 -0
  103. data/lib/generators/trusty_cms/trusty_cms_generator.rb +32 -0
  104. data/lib/trusty_cms.rb +1 -1
  105. data/lib/trusty_cms/setup.rb +8 -8
  106. data/trusty_cms.gemspec +4 -4
  107. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/base.rb +195 -0
  108. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/check_box.rb +65 -0
  109. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/checkable.rb +18 -0
  110. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_check_boxes.rb +35 -0
  111. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_helpers.rb +118 -0
  112. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_radio_buttons.rb +30 -0
  113. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_select.rb +30 -0
  114. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/color_field.rb +26 -0
  115. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/date_field.rb +14 -0
  116. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/date_select.rb +73 -0
  117. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/datetime_field.rb +31 -0
  118. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/datetime_local_field.rb +20 -0
  119. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/datetime_select.rb +10 -0
  120. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/email_field.rb +10 -0
  121. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/file_field.rb +10 -0
  122. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/grouped_collection_select.rb +31 -0
  123. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/hidden_field.rb +10 -0
  124. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/label.rb +80 -0
  125. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/month_field.rb +14 -0
  126. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/number_field.rb +20 -0
  127. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/password_field.rb +14 -0
  128. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/placeholderable.rb +24 -0
  129. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/radio_button.rb +32 -0
  130. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/range_field.rb +10 -0
  131. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/search_field.rb +27 -0
  132. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/select.rb +42 -0
  133. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/tel_field.rb +10 -0
  134. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/text_area.rb +24 -0
  135. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/text_field.rb +33 -0
  136. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/time_field.rb +14 -0
  137. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/time_select.rb +10 -0
  138. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/time_zone_select.rb +22 -0
  139. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/translator.rb +39 -0
  140. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/url_field.rb +10 -0
  141. data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/week_field.rb +14 -0
  142. data/yarn.lock +3 -3
  143. metadata +296 -71
  144. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +0 -126
  145. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +0 -4
  146. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +0 -56
  147. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +0 -43
  148. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +0 -28
  149. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +0 -36
  150. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +0 -76
  151. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +0 -23
  152. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +0 -87
  153. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +0 -157
  154. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +0 -142
  155. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +0 -81
  156. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +0 -114
  157. data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
  158. data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +0 -114
  159. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +0 -17
  160. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +0 -37
  161. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +0 -34
  162. data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +0 -40
  163. data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +0 -62
  164. data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +0 -60
  165. data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +0 -35
  166. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +0 -97
  167. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +0 -131
  168. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +0 -105
  169. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +0 -80
  170. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +0 -91
  171. data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +0 -93
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class DatetimeLocalField < DatetimeField # :nodoc:
7
+ class << self
8
+ def field_type
9
+ @field_type ||= "datetime-local"
10
+ end
11
+ end
12
+
13
+ private
14
+ def format_date(value)
15
+ value.try(:strftime, "%Y-%m-%dT%T")
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class DatetimeSelect < DateSelect # :nodoc:
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class EmailField < TextField # :nodoc:
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class FileField < TextField # :nodoc:
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class GroupedCollectionSelect < Base # :nodoc:
7
+ def initialize(object_name, method_name, template_object, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
8
+ @collection = collection
9
+ @group_method = group_method
10
+ @group_label_method = group_label_method
11
+ @option_key_method = option_key_method
12
+ @option_value_method = option_value_method
13
+ @html_options = html_options
14
+
15
+ super(object_name, method_name, template_object, options)
16
+ end
17
+
18
+ def render
19
+ option_tags_options = {
20
+ selected: @options.fetch(:selected) { value },
21
+ disabled: @options[:disabled]
22
+ }
23
+
24
+ select_content_tag(
25
+ option_groups_from_collection_for_select(@collection, @group_method, @group_label_method, @option_key_method, @option_value_method, option_tags_options), @options, @html_options
26
+ )
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class HiddenField < TextField # :nodoc:
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
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
+ end
29
+
30
+ def initialize(object_name, method_name, template_object, content_or_options = nil, options = nil)
31
+ options ||= {}
32
+
33
+ content_is_options = content_or_options.is_a?(Hash)
34
+ if content_is_options
35
+ options.merge! content_or_options
36
+ @content = nil
37
+ else
38
+ @content = content_or_options
39
+ end
40
+
41
+ super(object_name, method_name, template_object, options)
42
+ end
43
+
44
+ def render(&block)
45
+ options = @options.stringify_keys
46
+ tag_value = options.delete("value")
47
+ name_and_id = options.dup
48
+
49
+ if name_and_id["for"]
50
+ name_and_id["id"] = name_and_id["for"]
51
+ else
52
+ name_and_id.delete("id")
53
+ end
54
+
55
+ add_default_name_and_id_for_value(tag_value, name_and_id)
56
+ options.delete("index")
57
+ options.delete("namespace")
58
+ options["for"] = name_and_id["id"] unless options.key?("for")
59
+
60
+ builder = LabelBuilder.new(@template_object, @object_name, @method_name, @object, tag_value)
61
+
62
+ content = if block_given?
63
+ @template_object.capture(builder, &block)
64
+ elsif @content.present?
65
+ @content.to_s
66
+ else
67
+ render_component(builder)
68
+ end
69
+
70
+ label_tag(name_and_id["id"], content, options)
71
+ end
72
+
73
+ private
74
+ def render_component(builder)
75
+ builder.translation
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class MonthField < DatetimeField # :nodoc:
7
+ private
8
+ def format_date(value)
9
+ value.try(:strftime, "%Y-%m")
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class NumberField < TextField # :nodoc:
7
+ def render
8
+ options = @options.stringify_keys
9
+
10
+ if range = options.delete("in") || options.delete("within")
11
+ options.update("min" => range.min, "max" => range.max)
12
+ end
13
+
14
+ @options = options
15
+ super
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class PasswordField < TextField # :nodoc:
7
+ def render
8
+ @options = { value: nil }.merge!(@options)
9
+ super
10
+ end
11
+ end
12
+ end
13
+ end
14
+ 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
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view/helpers/tags/checkable"
4
+
5
+ module ActionView
6
+ module Helpers
7
+ module Tags # :nodoc:
8
+ class RadioButton < Base # :nodoc:
9
+ include Checkable
10
+
11
+ def initialize(object_name, method_name, template_object, tag_value, options)
12
+ @tag_value = tag_value
13
+ super(object_name, method_name, template_object, options)
14
+ end
15
+
16
+ def render
17
+ options = @options.stringify_keys
18
+ options["type"] = "radio"
19
+ options["value"] = @tag_value
20
+ options["checked"] = "checked" if input_checked?(options)
21
+ add_default_name_and_id_for_value(@tag_value, options)
22
+ tag("input", options)
23
+ end
24
+
25
+ private
26
+ def checked?(value)
27
+ value.to_s == @tag_value.to_s
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class RangeField < NumberField # :nodoc:
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class SearchField < TextField # :nodoc:
7
+ def render
8
+ options = @options.stringify_keys
9
+
10
+ if options["autosave"]
11
+ if options["autosave"] == true
12
+ options["autosave"] = request.host.split(".").reverse.join(".")
13
+ end
14
+ options["results"] ||= 10
15
+ end
16
+
17
+ if options["onsearch"]
18
+ options["incremental"] = true unless options.has_key?("incremental")
19
+ end
20
+
21
+ @options = options
22
+ super
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class Select < Base # :nodoc:
7
+ def initialize(object_name, method_name, template_object, choices, options, html_options)
8
+ @choices = block_given? ? template_object.capture { yield || "" } : choices
9
+ @choices = @choices.to_a if @choices.is_a?(Range)
10
+
11
+ @html_options = html_options
12
+
13
+ super(object_name, method_name, template_object, options)
14
+ end
15
+
16
+ def render
17
+ option_tags_options = {
18
+ selected: @options.fetch(:selected) { value },
19
+ disabled: @options[:disabled]
20
+ }
21
+
22
+ option_tags = if grouped_choices?
23
+ grouped_options_for_select(@choices, option_tags_options)
24
+ else
25
+ options_for_select(@choices, option_tags_options)
26
+ end
27
+
28
+ select_content_tag(option_tags, @options, @html_options)
29
+ end
30
+
31
+ private
32
+ # Grouped choices look like this:
33
+ #
34
+ # [nil, []]
35
+ # { nil => [] }
36
+ def grouped_choices?
37
+ !@choices.blank? && @choices.first.respond_to?(:last) && Array === @choices.first.last
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module Tags # :nodoc:
6
+ class TelField < TextField # :nodoc:
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view/helpers/tags/placeholderable"
4
+
5
+ module ActionView
6
+ module Helpers
7
+ module Tags # :nodoc:
8
+ class TextArea < Base # :nodoc:
9
+ include Placeholderable
10
+
11
+ def render
12
+ options = @options.stringify_keys
13
+ add_default_name_and_id(options)
14
+
15
+ if size = options.delete("size")
16
+ options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
17
+ end
18
+
19
+ content_tag("textarea", options.delete("value") { value_before_type_cast }, options)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view/helpers/tags/placeholderable"
4
+
5
+ module ActionView
6
+ module Helpers
7
+ module Tags # :nodoc:
8
+ class TextField < Base # :nodoc:
9
+ include Placeholderable
10
+
11
+ def render
12
+ options = @options.stringify_keys
13
+ options["size"] = options["maxlength"] unless options.key?("size")
14
+ options["type"] ||= field_type
15
+ options["value"] = options.fetch("value") { value_before_type_cast } unless field_type == "file"
16
+ add_default_name_and_id(options)
17
+ tag("input", options)
18
+ end
19
+
20
+ class << self
21
+ def field_type
22
+ @field_type ||= name.split("::").last.sub("Field", "").downcase
23
+ end
24
+ end
25
+
26
+ private
27
+ def field_type
28
+ self.class.field_type
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end