phlex-rails 1.2.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/phlex/component/component_generator.rb +1 -1
  3. data/lib/generators/phlex/install/install_generator.rb +31 -37
  4. data/lib/generators/phlex/view/view_generator.rb +1 -1
  5. data/lib/phlex/rails/buffered.rb +6 -7
  6. data/lib/phlex/rails/csv.rb +3 -3
  7. data/lib/phlex/rails/engine.rb +0 -1
  8. data/lib/phlex/rails/{html/method_missing.rb → helper_finder.rb} +2 -2
  9. data/lib/phlex/rails/helper_macros.rb +2 -12
  10. data/lib/phlex/rails/helpers/notice.rb +8 -0
  11. data/lib/phlex/rails/helpers/routes.rb +1 -0
  12. data/lib/phlex/rails/helpers/tag.rb +2 -2
  13. data/lib/phlex/rails/helpers/translate.rb +2 -2
  14. data/lib/phlex/rails/helpers/turbo_stream.rb +1 -1
  15. data/lib/phlex/rails/helpers.rb +11 -56
  16. data/lib/phlex/rails/html.rb +0 -2
  17. data/lib/phlex/rails/layout.rb +7 -7
  18. data/lib/phlex/rails/sgml.rb +35 -53
  19. data/lib/phlex/rails/streaming.rb +11 -9
  20. data/lib/phlex/rails/testing.rb +18 -0
  21. data/lib/phlex/rails/unbuffered.rb +50 -0
  22. data/lib/phlex/rails/version.rb +1 -1
  23. data/lib/phlex/rails.rb +6 -7
  24. metadata +13 -31
  25. data/.editorconfig +0 -13
  26. data/.rubocop.yml +0 -15
  27. data/.ruby-version +0 -1
  28. data/.yardopts +0 -1
  29. data/Appraisals +0 -11
  30. data/CHANGELOG.md +0 -38
  31. data/CODE_OF_CONDUCT.md +0 -84
  32. data/Gemfile +0 -17
  33. data/SECURITY.md +0 -5
  34. data/config.ru +0 -9
  35. data/lib/generators/phlex/component/USAGE +0 -8
  36. data/lib/generators/phlex/component/templates/component.rb.erb +0 -9
  37. data/lib/generators/phlex/install/USAGE +0 -8
  38. data/lib/generators/phlex/install/templates/application_component.rb +0 -12
  39. data/lib/generators/phlex/install/templates/application_layout.rb +0 -24
  40. data/lib/generators/phlex/install/templates/application_view.rb +0 -9
  41. data/lib/generators/phlex/view/USAGE +0 -8
  42. data/lib/generators/phlex/view/templates/view.rb.erb +0 -9
  43. data/lib/phlex/rails/unbuffered_overrides.rb +0 -30
  44. data/lib/phlex/testing/rails/view_helper.rb +0 -19
  45. data/phlex_logo.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93b219be78b50160aa9712bfec6ff25b59c33f512087cda4ee027a1f0f39ff05
4
- data.tar.gz: 55c366bb60dc4f5bb343317e9c948642fb5121d9e3ec65372392c2b5a751fe81
3
+ metadata.gz: eba6c0a4545578f13da48e443ca0751b5549eefd6cb9b2f866d0cfe436f5451b
4
+ data.tar.gz: 21695f056968e79c6f692328d2666b9933fbf63ef3def64a46eced386019faaa
5
5
  SHA512:
6
- metadata.gz: 65519c2590bff066155afb33418089c948a4fb7dbdceb9cdfbaac5a2d88a4fa2a86432b19ba9b6f42af8578d84e7469bde1cd66137f572ca84d691031f91de27
7
- data.tar.gz: cc3773ccad8dc3bfcc4a3267cc1c78189560e93d0bff31e1930d4cafb036724483f17e4923dc13acbcf3d50b2baa7d92da7f6f694205066bfc3860668983c5bc
6
+ metadata.gz: cece72abf570509143731193eaf0052c4a724ee294bf022b041751dc36e832e139cb808db3eb1ffd3d77a8fb41bc22c4013ad1824b86bc3fe3455a28c41d8c3a
7
+ data.tar.gz: afa2c05f30141978622fb6f964d426742e2ce772bfb3c0752b470f6e44217ac7f00f6800d975f6305a4b1cd498ed98ff613fbdb8a3202c02b155554791a81ff2
@@ -5,7 +5,7 @@ module Phlex::Generators
5
5
  source_root File.expand_path("templates", __dir__)
6
6
 
7
7
  def create_view
8
- @path = File.join("app/views/components", class_path, "#{file_name}_component.rb")
8
+ @path = File.join("app/components", class_path, "#{file_name}.rb")
9
9
  template "component.rb.erb", @path
10
10
  end
11
11
  end
@@ -5,56 +5,50 @@ module Phlex::Generators
5
5
  source_root File.expand_path("templates", __dir__)
6
6
 
7
7
  APPLICATION_CONFIGURATION_PATH = Rails.root.join("config/application.rb")
8
- TAILWIND_CONFIGURATION_PATH = Rails.root.join("tailwind.config.js")
9
8
 
10
- def autoload_components
11
- return unless APPLICATION_CONFIGURATION_PATH.exist?
12
-
13
- inject_into_class(
14
- APPLICATION_CONFIGURATION_PATH,
15
- "Application",
16
- %( config.autoload_paths << "\#{root}/app/views/components"\n)
17
- )
9
+ def configure_tailwind
10
+ if tailwind_configuration_path
11
+ insert_into_file tailwind_configuration_path, after: "content: [" do
12
+ "\n './app/views/**/*.rb', // Phlex views" \
13
+ "\n './app/components/**/*.rb', // Phlex components" \
14
+ end
15
+ end
18
16
  end
19
17
 
20
- def autoload_layouts
21
- return unless APPLICATION_CONFIGURATION_PATH.exist?
22
-
23
- inject_into_class(
24
- APPLICATION_CONFIGURATION_PATH,
25
- "Application",
26
- %( config.autoload_paths << "\#{root}/app/views/layouts"\n)
27
- )
18
+ def create_application_component
19
+ template "base_component.rb.erb", Rails.root.join("app/components/base.rb")
28
20
  end
29
21
 
30
- def autoload_views
31
- return unless APPLICATION_CONFIGURATION_PATH.exist?
32
-
33
- inject_into_class(
34
- APPLICATION_CONFIGURATION_PATH,
35
- "Application",
36
- %( config.autoload_paths << "\#{root}/app/views"\n)
37
- )
22
+ def create_application_view
23
+ template "base_view.rb.erb", Rails.root.join("app/views/base.rb")
38
24
  end
39
25
 
40
- def configure_tailwind
41
- return unless TAILWIND_CONFIGURATION_PATH.exist?
42
-
43
- insert_into_file TAILWIND_CONFIGURATION_PATH, after: "content: [" do
44
- "\n './app/views/**/*.rb'," \
45
- end
26
+ def create_hello_component
27
+ template "hello_component.rb.erb", Rails.root.join("app/components/hello.rb")
46
28
  end
47
29
 
48
- def create_application_component
49
- template "application_component.rb", Rails.root.join("app/views/components/application_component.rb")
30
+ def create_initializer
31
+ template "phlex.rb.erb", Rails.root.join("config/initializers/phlex.rb")
50
32
  end
51
33
 
52
- def create_application_layout
53
- template "application_layout.rb", Rails.root.join("app/views/layouts/application_layout.rb")
34
+ private
35
+
36
+ def tailwind_configuration_path
37
+ if tailwind_configuration_files.any?
38
+ Pathname.new(
39
+ tailwind_configuration_files.first,
40
+ )
41
+ end
54
42
  end
55
43
 
56
- def create_application_view
57
- template "application_view.rb", Rails.root.join("app/views/application_view.rb")
44
+ def tailwind_configuration_files
45
+ Dir.glob(
46
+ [
47
+ "#{Rails.root}/tailwind.config.js",
48
+ "#{Rails.root}/app/**/tailwind.config.js",
49
+ "#{Rails.root}/config/**/tailwind.config.js",
50
+ ],
51
+ )
58
52
  end
59
53
  end
60
54
  end
@@ -5,7 +5,7 @@ module Phlex::Generators
5
5
  source_root File.expand_path("templates", __dir__)
6
6
 
7
7
  def create_view
8
- @path = File.join("app/views", class_path, "#{file_name}_view.rb")
8
+ @path = File.join("app/views", class_path, "#{file_name}.rb")
9
9
  template "view.rb.erb", @path
10
10
  end
11
11
  end
@@ -30,7 +30,7 @@ module Phlex::Rails
30
30
 
31
31
  case output
32
32
  when ::ActiveSupport::SafeBuffer
33
- @view.instance_variable_get(:@_context).target << output
33
+ @view.instance_variable_get(:@_context).buffer << output
34
34
  end
35
35
 
36
36
  nil
@@ -48,16 +48,15 @@ module Phlex::Rails
48
48
  @object.respond_to?(...)
49
49
  end
50
50
 
51
- def method_missing(*args, **kwargs, &block)
51
+ def method_missing(*, **, &block)
52
52
  output = if block
53
- @object.public_send(*args, **kwargs) { @view.capture(&block) }
53
+ @object.public_send(*, **) { |*a| @view.capture(*a, &block) }
54
54
  else
55
- @object.public_send(*args, **kwargs)
55
+ @object.public_send(*, **)
56
56
  end
57
57
 
58
- case output
59
- when ::ActiveSupport::SafeBuffer
60
- @view.instance_variable_get(:@_context).target << output
58
+ if ::ActiveSupport::SafeBuffer === output
59
+ @view.instance_variable_get(:@_context).buffer << output
61
60
  end
62
61
 
63
62
  nil
@@ -4,11 +4,11 @@ module Phlex
4
4
  module Rails
5
5
  module CSV
6
6
  module Overrides
7
- def each_item(&block)
8
- return super unless collection.is_a?(ActiveRecord::Relation)
7
+ def each_item(&)
8
+ return super unless ActiveRecord::Relation === collection
9
9
  return super unless collection.arel.orders.empty?
10
10
 
11
- collection.find_each(&block)
11
+ collection.find_each(&)
12
12
  end
13
13
  end
14
14
  end
@@ -4,7 +4,6 @@ require "rails/engine"
4
4
 
5
5
  module Phlex
6
6
  module Rails
7
- # @api private
8
7
  class Engine < ::Rails::Engine
9
8
  end
10
9
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Phlex::Rails::HTML::MethodMissing
3
+ module Phlex::Rails::HelperFinder
4
4
  def method_missing(name, *args, **kwargs, &block)
5
5
  return super unless helpers.respond_to?(name)
6
6
 
@@ -8,6 +8,6 @@ module Phlex::Rails::HTML::MethodMissing
8
8
  module_name = Phlex::Rails::Helpers.constants.find { |mod| mod.to_s.underscore.gsub("domid", "dom_id") == const_name }
9
9
  return super unless module_name
10
10
 
11
- raise NoMethodError, "Try including `Phlex::Rails::Helpers::#{module_name}` in #{self.class.name}."
11
+ raise NoMethodError.new("Try including `Phlex::Rails::Helpers::#{module_name}` in #{self.class.name}.")
12
12
  end
13
13
  end
@@ -16,12 +16,7 @@ module Phlex::Rails::HelperMacros
16
16
  helpers.#{method_name}(*args, **kwargs)
17
17
  end
18
18
 
19
- case output
20
- when ActiveSupport::SafeBuffer
21
- @_context.target << output
22
- end
23
-
24
- nil
19
+ raw(output)
25
20
  end
26
21
  RUBY
27
22
  end
@@ -63,12 +58,7 @@ module Phlex::Rails::HelperMacros
63
58
  helpers.#{method_name}(*args, **kwargs)
64
59
  end
65
60
 
66
- case output
67
- when ActiveSupport::SafeBuffer
68
- @_context.target << output
69
- end
70
-
71
- nil
61
+ raw(output)
72
62
  end
73
63
  RUBY
74
64
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Phlex::Rails::Helpers::Notice
4
+ extend Phlex::Rails::HelperMacros
5
+
6
+ # @!method notice(...)
7
+ register_value_helper :notice
8
+ end
@@ -5,6 +5,7 @@ module Phlex::Rails::Helpers
5
5
  module Routes
6
6
  # This must be included first because it defines `url_options` rather than delegating it to the view context.
7
7
  include Rails.application.routes.url_helpers
8
+ include Rails.application.routes.mounted_helpers
8
9
 
9
10
  include URLOptions
10
11
  include DefaultURLOptions
@@ -10,11 +10,11 @@ module Phlex::Rails::Helpers::Tag
10
10
 
11
11
  case result
12
12
  when ActiveSupport::SafeBuffer
13
- @_context.target << result
13
+ @_context.buffer << result
14
14
  when ActionView::Helpers::TagHelper::TagBuilder
15
15
  Phlex::Rails::Buffered.new(
16
16
  result,
17
- view: self
17
+ view: self,
18
18
  )
19
19
  end
20
20
  end
@@ -15,10 +15,10 @@ module Phlex::Rails::Helpers::Translate
15
15
  base.extend(ClassMethods)
16
16
  end
17
17
 
18
- def translate(key, **options)
18
+ def translate(key, **)
19
19
  key = "#{self.class.translation_path}#{key}" if key.start_with?(".")
20
20
 
21
- helpers.t(key, **options)
21
+ helpers.t(key, **)
22
22
  end
23
23
 
24
24
  alias_method :t, :translate
@@ -8,7 +8,7 @@ module Phlex::Rails::Helpers::TurboStream
8
8
  def turbo_stream(...)
9
9
  Phlex::Rails::Buffered.new(
10
10
  helpers.turbo_stream(...),
11
- view: self
11
+ view: self,
12
12
  )
13
13
  end
14
14
  end
@@ -12,8 +12,6 @@ module Phlex::Rails::Helpers
12
12
  autoload :BuildTagValues, "phlex/rails/helpers/build_tag_values"
13
13
  autoload :ButtonTag, "phlex/rails/helpers/button_tag"
14
14
  autoload :ButtonTo, "phlex/rails/helpers/button_to"
15
- autoload :CSPMetaTag, "phlex/rails/helpers/csp_meta_tag"
16
- autoload :CSRFMetaTags, "phlex/rails/helpers/csrf_meta_tags"
17
15
  autoload :CheckBox, "phlex/rails/helpers/check_box"
18
16
  autoload :CheckBoxTag, "phlex/rails/helpers/check_box_tag"
19
17
  autoload :ClassNames, "phlex/rails/helpers/class_names"
@@ -29,11 +27,11 @@ module Phlex::Rails::Helpers
29
27
  autoload :ContentTag, "phlex/rails/helpers/content_tag"
30
28
  autoload :ControllerName, "phlex/rails/helpers/controller_name"
31
29
  autoload :ControllerPath, "phlex/rails/helpers/controller_path"
30
+ autoload :CSPMetaTag, "phlex/rails/helpers/csp_meta_tag"
31
+ autoload :CSRFMetaTags, "phlex/rails/helpers/csrf_meta_tags"
32
32
  autoload :CurrentCycle, "phlex/rails/helpers/current_cycle"
33
33
  autoload :CurrentPage, "phlex/rails/helpers/current_page"
34
34
  autoload :Cycle, "phlex/rails/helpers/cycle"
35
- autoload :DOMClass, "phlex/rails/helpers/dom_class"
36
- autoload :DOMID, "phlex/rails/helpers/dom_id"
37
35
  autoload :DateField, "phlex/rails/helpers/date_field"
38
36
  autoload :DateFieldTag, "phlex/rails/helpers/date_field_tag"
39
37
  autoload :DateSelect, "phlex/rails/helpers/date_select"
@@ -46,6 +44,8 @@ module Phlex::Rails::Helpers
46
44
  autoload :DefaultURLOptions, "phlex/rails/helpers/default_url_options"
47
45
  autoload :DistanceOfTimeInWords, "phlex/rails/helpers/distance_of_time_in_words"
48
46
  autoload :DistanceOfTimeInWordsToNow, "phlex/rails/helpers/distance_of_time_in_words_to_now"
47
+ autoload :DOMClass, "phlex/rails/helpers/dom_class"
48
+ autoload :DOMID, "phlex/rails/helpers/dom_id"
49
49
  autoload :EmailField, "phlex/rails/helpers/email_field"
50
50
  autoload :EmailFieldTag, "phlex/rails/helpers/email_field_tag"
51
51
  autoload :ErrorMessage, "phlex/rails/helpers/error_message"
@@ -55,8 +55,8 @@ module Phlex::Rails::Helpers
55
55
  autoload :FaviconLinkTag, "phlex/rails/helpers/favicon_link_tag"
56
56
  autoload :FieldID, "phlex/rails/helpers/field_id"
57
57
  autoload :FieldName, "phlex/rails/helpers/field_name"
58
- autoload :FieldSetTag, "phlex/rails/helpers/field_set_tag"
59
58
  autoload :Fields, "phlex/rails/helpers/fields"
59
+ autoload :FieldSetTag, "phlex/rails/helpers/field_set_tag"
60
60
  autoload :FieldsFor, "phlex/rails/helpers/fields_for"
61
61
  autoload :FileField, "phlex/rails/helpers/file_field"
62
62
  autoload :FileFieldTag, "phlex/rails/helpers/file_field_tag"
@@ -75,8 +75,8 @@ module Phlex::Rails::Helpers
75
75
  autoload :ImageSubmitTag, "phlex/rails/helpers/image_submit_tag"
76
76
  autoload :ImageTag, "phlex/rails/helpers/image_tag"
77
77
  autoload :ImageURL, "phlex/rails/helpers/image_url"
78
- autoload :JavascriptImportModuleTag, "phlex/rails/helpers/javascript_import_module_tag"
79
78
  autoload :JavascriptImportmapTags, "phlex/rails/helpers/javascript_importmap_tags"
79
+ autoload :JavascriptImportModuleTag, "phlex/rails/helpers/javascript_import_module_tag"
80
80
  autoload :JavascriptIncludeTag, "phlex/rails/helpers/javascript_include_tag"
81
81
  autoload :JavascriptPath, "phlex/rails/helpers/javascript_path"
82
82
  autoload :JavascriptTag, "phlex/rails/helpers/javascript_tag"
@@ -93,6 +93,7 @@ module Phlex::Rails::Helpers
93
93
  autoload :MailTo, "phlex/rails/helpers/mail_to"
94
94
  autoload :MonthField, "phlex/rails/helpers/month_field"
95
95
  autoload :MonthFieldTag, "phlex/rails/helpers/month_field_tag"
96
+ autoload :Notice, "phlex/rails/helpers/notice"
96
97
  autoload :NumberField, "phlex/rails/helpers/number_field"
97
98
  autoload :NumberFieldTag, "phlex/rails/helpers/number_field_tag"
98
99
  autoload :NumberToCurrency, "phlex/rails/helpers/number_to_currency"
@@ -130,7 +131,6 @@ module Phlex::Rails::Helpers
130
131
  autoload :ResetCycle, "phlex/rails/helpers/reset_cycle"
131
132
  autoload :RichTextArea, "phlex/rails/helpers/rich_text_area"
132
133
  autoload :Routes, "phlex/rails/helpers/routes"
133
- autoload :SMSTo, "phlex/rails/helpers/sms_to"
134
134
  autoload :Sanitize, "phlex/rails/helpers/sanitize"
135
135
  autoload :SanitizeCSS, "phlex/rails/helpers/sanitize_css"
136
136
  autoload :SearchField, "phlex/rails/helpers/search_field"
@@ -147,6 +147,7 @@ module Phlex::Rails::Helpers
147
147
  autoload :SelectTime, "phlex/rails/helpers/select_time"
148
148
  autoload :SelectYear, "phlex/rails/helpers/select_year"
149
149
  autoload :SimpleFormat, "phlex/rails/helpers/simple_format"
150
+ autoload :SMSTo, "phlex/rails/helpers/sms_to"
150
151
  autoload :StripLinks, "phlex/rails/helpers/strip_links"
151
152
  autoload :StripTags, "phlex/rails/helpers/strip_tags"
152
153
  autoload :StylesheetLinkTag, "phlex/rails/helpers/stylesheet_link_tag"
@@ -173,9 +174,9 @@ module Phlex::Rails::Helpers
173
174
  autoload :Truncate, "phlex/rails/helpers/truncate"
174
175
  autoload :TurboFrameTag, "phlex/rails/helpers/turbo_frame_tag"
175
176
  autoload :TurboIncludeTags, "phlex/rails/helpers/turbo_include_tags"
177
+ autoload :TurboRefreshesWith, "phlex/rails/helpers/turbo_refreshes_with"
176
178
  autoload :TurboRefreshMethodTag, "phlex/rails/helpers/turbo_refresh_method_tag"
177
179
  autoload :TurboRefreshScrollTag, "phlex/rails/helpers/turbo_refresh_scroll_tag"
178
- autoload :TurboRefreshesWith, "phlex/rails/helpers/turbo_refreshes_with"
179
180
  autoload :TurboStream, "phlex/rails/helpers/turbo_stream"
180
181
  autoload :TurboStreamFrom, "phlex/rails/helpers/turbo_stream_from"
181
182
  autoload :URLField, "phlex/rails/helpers/url_field"
@@ -193,56 +194,10 @@ module Phlex::Rails::Helpers
193
194
  autoload :VideoPath, "phlex/rails/helpers/video_path"
194
195
  autoload :VideoTag, "phlex/rails/helpers/video_tag"
195
196
  autoload :VideoURL, "phlex/rails/helpers/video_url"
196
- autoload :WeekField, "phlex/rails/helpers/week_field"
197
- autoload :WeekFieldTag, "phlex/rails/helpers/week_field_tag"
198
197
  autoload :WeekdayOptionsForSelect, "phlex/rails/helpers/weekday_options_for_select"
199
198
  autoload :WeekdaySelect, "phlex/rails/helpers/weekday_select"
199
+ autoload :WeekField, "phlex/rails/helpers/week_field"
200
+ autoload :WeekFieldTag, "phlex/rails/helpers/week_field_tag"
200
201
  autoload :WithOutputBuffer, "phlex/rails/helpers/with_output_buffer"
201
202
  autoload :WordWrap, "phlex/rails/helpers/word_wrap"
202
-
203
- DEPRECATED = {
204
- Checkbox: :CheckBox,
205
- CheckboxTag: :CheckBoxTag,
206
- CollectionCheckboxes: :CollectionCheckBoxes,
207
- DateTimeField: :DatetimeField,
208
- PathToJavaScript: :PathToJavascript,
209
- DateTimeFieldTag: :DatetimeFieldTag,
210
- DateTimeLocalField: :DatetimeLocalField,
211
- DateTimeLocalFieldTag: :DatetimeLocalFieldTag,
212
- DateTimeSelect: :DatetimeSelect,
213
- JavaScriptImportModuleTag: :JavascriptImportModuleTag,
214
- JavaScriptImportMapTags: :JavascriptImportmapTags,
215
- JavaScriptIncludeTag: :JavascriptIncludeTag,
216
- JavaScriptPath: :JavascriptPath,
217
- JavaScriptTag: :JavascriptTag,
218
- JavaScriptURL: :JavascriptURL,
219
- LinkIf: :LinkToIf,
220
- PathToStyleSheet: :PathToStylesheet,
221
- SanitizeCss: :SanitizeCSS,
222
- SelectDateTime: :SelectDatetime,
223
- StyleSheetLinkTag: :StylesheetLinkTag,
224
- StyleSheetPath: :StylesheetPath,
225
- StyleSheetURL: :StylesheetURL,
226
- URLToJavaScript: :URLToJavascript,
227
- URLToStyleSheet: :URLToStylesheet
228
- }
229
-
230
- def self.const_missing(name)
231
- if (helper_module_name = DEPRECATED[name])
232
- message = "`Phlex::Rails::Helpers::#{name}` is deprecated. Please use `Phlex::Rails::Helpers::#{helper_module_name}` instead."
233
-
234
- if name.to_s.downcase == helper_module_name.to_s.downcase
235
- message << " Note the casing of the module name has changed to match the helper method."
236
- end
237
-
238
- Phlex::Rails::Deprecation.warn(message)
239
-
240
- helper_module = const_get(helper_module_name)
241
- const_set(name, helper_module)
242
-
243
- helper_module
244
- else
245
- super
246
- end
247
- end
248
203
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Phlex::Rails::HTML
4
- autoload :MethodMissing, "phlex/rails/html/method_missing"
5
-
6
4
  module Format
7
5
  def format
8
6
  :html
@@ -14,11 +14,12 @@ module Phlex::Rails
14
14
  include Helpers::JavascriptImportModuleTag
15
15
  include Helpers::TurboRefreshMethodTag
16
16
  include Helpers::TurboRefreshScrollTag
17
+ include Helpers::TurboRefreshesWith
17
18
 
18
19
  # @api private
19
20
  module Interface
20
- def render(view_context, _locals, &block)
21
- new.render(view_context, &block)
21
+ def render(view_context, _locals, &)
22
+ new.render(view_context, &)
22
23
  end
23
24
 
24
25
  def identifier
@@ -38,18 +39,17 @@ module Phlex::Rails
38
39
 
39
40
  def self.included(klass)
40
41
  unless klass < Phlex::HTML
41
- raise Phlex::ArgumentError,
42
- "👋 #{name} should only be included into Phlex::HTML classes."
42
+ raise Phlex::ArgumentError.new("👋 #{name} should only be included into Phlex::HTML classes.")
43
43
  end
44
44
 
45
45
  klass.extend(Interface)
46
46
  end
47
47
 
48
- def render(view_context, *args, **kwargs, &block)
48
+ def render(view_context = nil, *args, **kwargs, &block)
49
49
  if @_context
50
50
  super
51
51
  else
52
- call(view_context: view_context) do |yielded|
52
+ call(view_context:) do |yielded|
53
53
  case yielded
54
54
  when Symbol
55
55
  output = view_context.view_flow.get(yielded)
@@ -57,7 +57,7 @@ module Phlex::Rails
57
57
  output = view_context.capture(&block)
58
58
  end
59
59
 
60
- unsafe_raw output
60
+ raw output
61
61
  end
62
62
  end
63
63
  end
@@ -11,7 +11,7 @@ module Phlex
11
11
 
12
12
  module Overrides
13
13
  def helpers
14
- if defined?(ViewComponent::Base) && @_view_context.is_a?(ViewComponent::Base)
14
+ if defined?(ViewComponent::Base) && ViewComponent::Base === @_view_context
15
15
  @_view_context.helpers
16
16
  else
17
17
  @_view_context
@@ -22,80 +22,62 @@ module Phlex
22
22
  renderable = args[0]
23
23
 
24
24
  case renderable
25
- when Phlex::SGML, Proc, Method
25
+ when Phlex::SGML, Proc, Method, String
26
26
  return super
27
27
  when Class
28
28
  return super if renderable < Phlex::SGML
29
29
  when Enumerable
30
- return super unless renderable.is_a?(ActiveRecord::Relation)
31
- else
32
- if block
33
- @_context.target << @_view_context.render(*args, **kwargs) { capture(&block) }
34
- else
35
- @_context.target << @_view_context.render(*args, **kwargs)
30
+ return super unless ActiveRecord::Relation === renderable
31
+ when nil
32
+ partial = kwargs.delete(:partial)
33
+
34
+ if partial # this is a hack to get around https://github.com/rails/rails/issues/51015
35
+ return raw(
36
+ @_view_context.render(partial, **kwargs) do |*yielded_args|
37
+ capture(*yielded_args, &block)
38
+ end,
39
+ )
36
40
  end
37
41
  end
38
42
 
39
- nil
43
+ output = if block
44
+ @_view_context.render(*args, **kwargs) do |*yielded_args|
45
+ if yielded_args.length == 1 && defined?(ViewComponent::Base) && ViewComponent::Base === yielded_args[0]
46
+ capture(Phlex::Rails::Buffered.new(yielded_args[0], view: self), &block)
47
+ else
48
+ capture(*yielded_args, &block)
49
+ end
50
+ end
51
+ else
52
+ @_view_context.render(*args, **kwargs)
53
+ end
54
+
55
+ raw(output)
40
56
  end
41
57
 
42
- def render_in(view_context, &block)
58
+ def render_in(view_context, &erb)
43
59
  fragments = if view_context.request && (fragment_header = view_context.request.headers["X-Fragment"])
44
60
  fragment_header.split
45
61
  end
46
62
 
47
- if block_given?
48
- call(view_context: view_context, fragments: fragments) do |*args|
49
- original_length = @_context.target.bytesize
50
-
51
- if args.length == 1 && Phlex::SGML === args[0] && !block.source_location&.[](0)&.end_with?(".rb")
52
- output = view_context.capture(
53
- args[0].unbuffered, &block
54
- )
63
+ if erb
64
+ call(view_context:, fragments:) { |*args|
65
+ if args.length == 1 && Phlex::SGML === args[0] && !erb.source_location&.[](0)&.end_with?(".rb")
66
+ unbuffered = Phlex::Rails::Unbuffered.new(args[0])
67
+ raw(helpers.capture(unbuffered, &erb))
55
68
  else
56
- output = view_context.capture(*args, &block)
69
+ raw(helpers.capture(*args, &erb))
57
70
  end
58
-
59
- unchanged = (original_length == @_context.target.bytesize)
60
-
61
- if unchanged
62
- case output
63
- when ActiveSupport::SafeBuffer
64
- @_context.target << output
65
- end
66
- end
67
- end.html_safe
71
+ }.html_safe
68
72
  else
69
- call(view_context: view_context, fragments: fragments).html_safe
73
+ call(view_context:, fragments:).html_safe
70
74
  end
71
75
  end
72
76
 
73
- def capture
77
+ def capture(...)
74
78
  super&.html_safe
75
79
  end
76
80
 
77
- # @api private
78
- def __text__(content)
79
- case content
80
- when ActiveSupport::SafeBuffer
81
- @_context.target << content
82
- else
83
- super
84
- end
85
- end
86
-
87
- # TODO: Re-introduce this when we can figure out how to test it
88
- # def await(task)
89
- # case task
90
- # when ActiveRecord::Relation
91
- # future = task.instance_variable_get(:@future_result)
92
- # flush if future && future.pending?
93
- # task
94
- # else
95
- # super
96
- # end
97
- # end
98
-
99
81
  # Trick ViewComponent into thinking we're a ViewComponent to fix rendering output
100
82
  # @api private
101
83
  def set_original_view_context(view_context)
@@ -7,17 +7,19 @@ module Phlex::Rails::Streaming
7
7
  private
8
8
 
9
9
  def stream(view, last_modified: Time.now.httpdate, filename: nil)
10
- set_stream_headers(last_modified: last_modified)
10
+ __phlex_set_stream_headers__(last_modified:)
11
11
 
12
12
  case view
13
13
  when Phlex::HTML
14
- stream_html(view)
14
+ __phlex_stream_html__(view)
15
15
  when Phlex::CSV
16
- stream_csv(view, filename: filename)
16
+ __phlex_stream_csv__(view, filename:)
17
+ else
18
+ raise Phlex::ArgumentError
17
19
  end
18
20
  end
19
21
 
20
- def set_stream_headers(last_modified:)
22
+ def __phlex_set_stream_headers__(last_modified:)
21
23
  headers.delete("Content-Length")
22
24
 
23
25
  headers["X-Accel-Buffering"] = "no"
@@ -25,16 +27,16 @@ module Phlex::Rails::Streaming
25
27
  headers["Last-Modified"] = last_modified
26
28
  end
27
29
 
28
- def stream_csv(view, filename:)
30
+ def __phlex_stream_csv__(view, filename:)
29
31
  headers["Content-Type"] = "text/csv; charset=utf-8"
30
32
  headers["Content-Disposition"] = "attachment; filename=\"#{filename || view.filename}\""
31
33
 
32
34
  self.response_body = Enumerator.new do |buffer|
33
- view.call(buffer, view_context: view_context)
35
+ view.call(buffer, view_context:)
34
36
  end
35
37
  end
36
38
 
37
- def stream_html(view)
39
+ def __phlex_stream_html__(view)
38
40
  headers["Content-Type"] = "text/html; charset=utf-8"
39
41
 
40
42
  # Ensure we have a session id.
@@ -45,13 +47,13 @@ module Phlex::Rails::Streaming
45
47
  end
46
48
 
47
49
  self.response_body = Enumerator.new do |buffer|
48
- view.call(buffer, view_context: view_context)
50
+ view.call(buffer, view_context:)
49
51
  rescue => e
50
52
  raise(e) if Rails.env.test?
51
53
 
52
54
  debug_middleware = ActionDispatch::DebugExceptions.new(
53
55
  proc { |_env| raise(e) },
54
- response_format: :html
56
+ response_format: :html,
55
57
  )
56
58
 
57
59
  _debug_status, _debug_headers, debug_body = debug_middleware.call(request.env)
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "phlex/rails"
4
+ require "phlex/testing"
5
+
6
+ module Phlex::Testing::RailsContext
7
+ def view_context
8
+ controller.view_context
9
+ end
10
+
11
+ def controller
12
+ @controller ||= ActionView::TestCase::TestController.new
13
+ end
14
+ end
15
+
16
+ Phlex::Testing::SGML.include(
17
+ Phlex::Testing::RailsContext,
18
+ )
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api private
4
+ class Phlex::Rails::Unbuffered
5
+ def initialize(component)
6
+ @component = component
7
+ end
8
+
9
+ def respond_to_missing?(...)
10
+ @component.respond_to?(...)
11
+ end
12
+
13
+ def method_missing(method_name, *, **, &erb)
14
+ if @component.respond_to?(method_name)
15
+ output = @component.capture do
16
+ if erb
17
+ @component.public_send(method_name, *, **) do |*a, **kw|
18
+ @component.raw(
19
+ @component.helpers.capture(
20
+ *a,
21
+ **kw,
22
+ &erb
23
+ ),
24
+ )
25
+ end
26
+ else # no erb block
27
+ @component.public_send(method_name, *, **)
28
+ end
29
+ end
30
+ else
31
+ super
32
+ end
33
+ end
34
+
35
+ def inspect
36
+ "Unbuffered(#{@component.inspect})"
37
+ end
38
+
39
+ def call(...)
40
+ @component.call(...)
41
+ end
42
+
43
+ def send(...)
44
+ @component.__send__(...)
45
+ end
46
+
47
+ def public_send(...)
48
+ @component.public_send(...)
49
+ end
50
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Phlex
4
4
  module Rails
5
- VERSION = "1.2.1"
5
+ VERSION = "2.0.0.beta1"
6
6
  end
7
7
  end
data/lib/phlex/rails.rb CHANGED
@@ -11,16 +11,15 @@ module Phlex
11
11
  autoload :BufferedLabelBuilder, "phlex/rails/buffered_label_builder"
12
12
  autoload :BufferedRadioButtonBuilder, "phlex/rails/buffered_radio_button_builder"
13
13
  autoload :CSV, "phlex/rails/csv"
14
- autoload :HTML, "phlex/rails/html"
14
+ autoload :FragmentFinder, "phlex/rails/fragment_finder"
15
+ autoload :HelperFinder, "phlex/rails/helper_finder"
15
16
  autoload :HelperMacros, "phlex/rails/helper_macros"
16
17
  autoload :Helpers, "phlex/rails/helpers"
18
+ autoload :HTML, "phlex/rails/html"
17
19
  autoload :Layout, "phlex/rails/layout"
18
20
  autoload :SGML, "phlex/rails/sgml"
19
- autoload :UnbufferedOverrides, "phlex/rails/unbuffered_overrides"
20
21
  autoload :Streaming, "phlex/rails/streaming"
21
- autoload :FragmentFinder, "phlex/rails/fragment_finder"
22
-
23
- Deprecation = ActiveSupport::Deprecation.new("2.0", "Phlex::Rails")
22
+ autoload :Unbuffered, "phlex/rails/unbuffered"
24
23
  end
25
24
 
26
25
  CSV.extend Phlex::Rails::HelperMacros
@@ -29,10 +28,10 @@ module Phlex
29
28
  SGML.extend Phlex::Rails::SGML::ClassMethods
30
29
  SGML.extend Phlex::Rails::HelperMacros
31
30
  SGML.prepend Phlex::Rails::SGML::Overrides
31
+ SGML.include Phlex::Rails::HelperFinder
32
32
 
33
33
  HTML.extend Phlex::Rails::HTML::Format
34
34
  HTML.include Phlex::Rails::HTML::Format
35
- HTML.include Phlex::Rails::HTML::MethodMissing
36
35
 
37
- Unbuffered.prepend Phlex::Rails::UnbufferedOverrides
36
+ ActiveSupport::SafeBuffer.include(Phlex::SGML::SafeObject)
38
37
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phlex-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Drapper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2024-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: phlex
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.10.0
19
+ version: 2.0.0.beta1
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: 1.10.0
26
+ version: 2.0.0.beta1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: railties
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,35 +44,17 @@ dependencies:
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '8'
47
- description: A high-performance view framework optimised for developer happiness.
47
+ description: A high-performance view framework optimised for fun.
48
48
  email:
49
49
  - joel@drapper.me
50
50
  executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - ".editorconfig"
55
- - ".rubocop.yml"
56
- - ".ruby-version"
57
- - ".yardopts"
58
- - Appraisals
59
- - CHANGELOG.md
60
- - CODE_OF_CONDUCT.md
61
- - Gemfile
62
54
  - LICENSE.txt
63
55
  - README.md
64
- - SECURITY.md
65
- - config.ru
66
- - lib/generators/phlex/component/USAGE
67
56
  - lib/generators/phlex/component/component_generator.rb
68
- - lib/generators/phlex/component/templates/component.rb.erb
69
- - lib/generators/phlex/install/USAGE
70
57
  - lib/generators/phlex/install/install_generator.rb
71
- - lib/generators/phlex/install/templates/application_component.rb
72
- - lib/generators/phlex/install/templates/application_layout.rb
73
- - lib/generators/phlex/install/templates/application_view.rb
74
- - lib/generators/phlex/view/USAGE
75
- - lib/generators/phlex/view/templates/view.rb.erb
76
58
  - lib/generators/phlex/view/view_generator.rb
77
59
  - lib/phlex-rails.rb
78
60
  - lib/phlex/rails.rb
@@ -84,6 +66,7 @@ files:
84
66
  - lib/phlex/rails/csv.rb
85
67
  - lib/phlex/rails/engine.rb
86
68
  - lib/phlex/rails/fragment_finder.rb
69
+ - lib/phlex/rails/helper_finder.rb
87
70
  - lib/phlex/rails/helper_macros.rb
88
71
  - lib/phlex/rails/helpers.rb
89
72
  - lib/phlex/rails/helpers/action_cable_meta_tag.rb
@@ -177,6 +160,7 @@ files:
177
160
  - lib/phlex/rails/helpers/mail_to.rb
178
161
  - lib/phlex/rails/helpers/month_field.rb
179
162
  - lib/phlex/rails/helpers/month_field_tag.rb
163
+ - lib/phlex/rails/helpers/notice.rb
180
164
  - lib/phlex/rails/helpers/number_field.rb
181
165
  - lib/phlex/rails/helpers/number_field_tag.rb
182
166
  - lib/phlex/rails/helpers/number_to_currency.rb
@@ -284,14 +268,12 @@ files:
284
268
  - lib/phlex/rails/helpers/with_output_buffer.rb
285
269
  - lib/phlex/rails/helpers/word_wrap.rb
286
270
  - lib/phlex/rails/html.rb
287
- - lib/phlex/rails/html/method_missing.rb
288
271
  - lib/phlex/rails/layout.rb
289
272
  - lib/phlex/rails/sgml.rb
290
273
  - lib/phlex/rails/streaming.rb
291
- - lib/phlex/rails/unbuffered_overrides.rb
274
+ - lib/phlex/rails/testing.rb
275
+ - lib/phlex/rails/unbuffered.rb
292
276
  - lib/phlex/rails/version.rb
293
- - lib/phlex/testing/rails/view_helper.rb
294
- - phlex_logo.png
295
277
  homepage: https://www.phlex.fun
296
278
  licenses:
297
279
  - MIT
@@ -309,14 +291,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
309
291
  requirements:
310
292
  - - ">="
311
293
  - !ruby/object:Gem::Version
312
- version: '2.7'
294
+ version: 3.3.1
313
295
  required_rubygems_version: !ruby/object:Gem::Requirement
314
296
  requirements:
315
297
  - - ">="
316
298
  - !ruby/object:Gem::Version
317
299
  version: '0'
318
300
  requirements: []
319
- rubygems_version: 3.4.22
301
+ rubygems_version: 3.5.18
320
302
  signing_key:
321
303
  specification_version: 4
322
304
  summary: A Phlex adapter for Rails
data/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- root = true
2
-
3
- [*]
4
- indent_style = tab
5
- indent_size = 2
6
-
7
- [*.yml]
8
- indent_style = space
9
- indent_size = 2
10
-
11
- [*.erb]
12
- indent_style = space
13
- indent_size = 2
data/.rubocop.yml DELETED
@@ -1,15 +0,0 @@
1
- inherit_from:
2
- - "https://www.goodcop.style/rubocop.yml"
3
- - "https://www.goodcop.style/tabs.yml"
4
-
5
- AllCops:
6
- TargetRubyVersion: 2.7
7
- Exclude:
8
- - "lib/phlex-rails.rb"
9
- SuggestExtensions: false
10
-
11
- Style/MissingRespondToMissing:
12
- Enabled: false
13
-
14
- Style/RescueStandardError:
15
- Enabled: false
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.2.2
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --private --hide-api private --markup markdown --exclude lib/generators
data/Appraisals DELETED
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise "rails-7" do
4
- gem "rails", "~> 7"
5
- end
6
-
7
- if RUBY_VERSION >= "3.1.0"
8
- appraise "rails-edge" do
9
- gem "rails", github: "rails/rails"
10
- end
11
- end
data/CHANGELOG.md DELETED
@@ -1,38 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
-
5
-
6
- # [1.1.1] 2023-11-27
7
-
8
- - Fixed a bug where Phlex would try to capture `nil` when rendered from ActionView without a block.
9
-
10
- ## [1.1.0] 2023-11-24
11
-
12
- - Dropped dependency on `rails` and now only depends on `railties`
13
- - Fix an out of order rendering issue when yielding from a partial rendered with a block delegated from a component’s content block
14
- - Added `flash` helper adapter in `Phlex::Rails::Helpers::Flash`
15
- - Removed experimental form component
16
- - Updated `phlex` dependency to `~> 1.9`
17
-
18
- ## [1.0.0] 2023-04-19
19
-
20
- ### Added
21
-
22
- - Added an adapter for the pluralize view helper.
23
-
24
- ## 0.10.0
25
-
26
- ### Added
27
-
28
- - You can now render procs and lambdas and enumerables of renderables.
29
- - Experimental streaming interface
30
-
31
- ### Fixed
32
-
33
- - Escaped ERB captures
34
- - Use buffered component unless renderin in a template
35
-
36
- ***
37
-
38
- Before this changelog was introduced, changes were logged in the [release notes](https://github.com/phlex-ruby/phlex-rails/releases).
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at joel@drapper.me. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
- git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
-
6
- gemspec
7
-
8
- gem "phlex", github: "phlex-ruby/phlex", branch: "1.10"
9
- gem "rubocop"
10
- gem "solargraph"
11
- gem "view_component"
12
- gem "appraisal", github: "excid3/appraisal", branch: "fix-bundle-env"
13
- gem "yard"
14
-
15
- gem "rails"
16
- gem "puma"
17
- gem "sqlite3"
data/SECURITY.md DELETED
@@ -1,5 +0,0 @@
1
- # Security Policy
2
-
3
- ## Reporting a Vulnerability
4
-
5
- If you found a possible security vulnerability in Phlex, please email security@phlex.fun.
data/config.ru DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubygems"
4
- require "bundler"
5
-
6
- Bundler.require :default, :development
7
-
8
- Combustion.initialize! :all
9
- run Combustion::Application
@@ -1,8 +0,0 @@
1
- Description:
2
- Generates a Phlex component with the given name
3
-
4
- Example:
5
- rails generate phlex:component Sidebar
6
-
7
- This will create:
8
- app/views/components/sidebar_component.rb
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- <% module_namespacing do -%>
4
- class <%= class_name %>Component < ApplicationComponent
5
- def view_template
6
- h1 { "<%= class_name %>" }
7
- p { "Find me in <%= @path %>" }
8
- end
9
- end<% end %>
@@ -1,8 +0,0 @@
1
- Description:
2
- Installs Phlex
3
-
4
- Example:
5
- rails generate phlex:install
6
-
7
- This will create:
8
- app/views/application_view.rb
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ApplicationComponent < Phlex::HTML
4
- include Phlex::Rails::Helpers::Routes
5
-
6
- if Rails.env.development?
7
- def before_template
8
- comment { "Before #{self.class.name}" }
9
- super
10
- end
11
- end
12
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ApplicationLayout < ApplicationView
4
- include Phlex::Rails::Layout
5
-
6
- def view_template(&block)
7
- doctype
8
-
9
- html do
10
- head do
11
- title { "You're awesome" }
12
- meta name: "viewport", content: "width=device-width,initial-scale=1"
13
- csp_meta_tag
14
- csrf_meta_tags
15
- stylesheet_link_tag "application", data_turbo_track: "reload"
16
- javascript_importmap_tags
17
- end
18
-
19
- body do
20
- main(&block)
21
- end
22
- end
23
- end
24
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ApplicationView < ApplicationComponent
4
- # The ApplicationView is an abstract class for all your views.
5
-
6
- # By default, it inherits from `ApplicationComponent`, but you
7
- # can change that to `Phlex::HTML` if you want to keep views and
8
- # components independent.
9
- end
@@ -1,8 +0,0 @@
1
- Description:
2
- Generates a Phlex view with the given name
3
-
4
- Example:
5
- rails generate phlex:view Articles::Index
6
-
7
- This will create:
8
- app/views/articles/index_view.rb
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- <% module_namespacing do -%>
4
- class <%= class_name %>View < ApplicationView
5
- def view_template
6
- h1 { "<%= class_name %>" }
7
- p { "Find me in <%= @path %>" }
8
- end
9
- end<% end %>
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @api private
4
- module Phlex::Rails::UnbufferedOverrides
5
- def method_missing(name, *args, **kwargs, &block)
6
- if @object.respond_to?(name)
7
-
8
- __class__.define_method(name) do |*a, **k, &b|
9
- @object.capture do
10
- if b
11
- @object.public_send(name, *a, **k) do |*aa|
12
- if aa.length == 1 && aa[0].is_a?(Phlex::SGML)
13
- @object.helpers.capture(aa[0].unbuffered, &b)
14
- else
15
- @object.helpers.capture(*aa, &b)
16
- end
17
- end
18
- else
19
- @object.public_send(name, *a, **k)
20
- end
21
- end
22
- end
23
-
24
- # Now we've defined this missing method, we can call it.
25
- __public_send__(name, *args, **kwargs, &block)
26
- else
27
- super
28
- end
29
- end
30
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "phlex/testing/view_helper"
4
-
5
- module Phlex::Testing
6
- module Rails
7
- module ViewHelper
8
- include ::Phlex::Testing::ViewHelper
9
-
10
- def view_context
11
- controller.view_context
12
- end
13
-
14
- def controller
15
- @controller ||= ActionView::TestCase::TestController.new
16
- end
17
- end
18
- end
19
- end
data/phlex_logo.png DELETED
Binary file