turbo-rails 0.7.11 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -16
- data/app/assets/javascripts/turbo.js +1330 -574
- data/app/assets/javascripts/turbo.min.js +25 -0
- data/app/assets/javascripts/turbo.min.js.map +1 -0
- data/app/channels/turbo/streams/broadcasts.rb +17 -17
- data/app/channels/turbo/streams/stream_name.rb +7 -0
- data/app/channels/turbo/streams_channel.rb +30 -2
- data/app/controllers/turbo/frames/frame_request.rb +5 -1
- data/app/helpers/turbo/drive_helper.rb +16 -3
- data/app/helpers/turbo/frames_helper.rb +14 -2
- data/app/helpers/turbo/streams/action_helper.rb +14 -8
- data/app/helpers/turbo/streams_helper.rb +12 -1
- data/app/javascript/turbo/cable_stream_source_element.js +2 -1
- data/app/javascript/turbo/fetch_requests.js +19 -0
- data/app/javascript/turbo/index.js +4 -0
- data/app/javascript/turbo/snakeize.js +31 -0
- data/app/models/concerns/turbo/broadcastable.rb +67 -26
- data/app/models/turbo/streams/tag_builder.rb +4 -4
- data/lib/install/turbo_needs_redis.rb +12 -1
- data/lib/install/turbo_with_importmap.rb +1 -1
- data/lib/tasks/turbo_tasks.rake +4 -2
- data/lib/turbo/engine.rb +15 -5
- data/lib/turbo/test_assertions.rb +10 -4
- data/lib/turbo/version.rb +1 -1
- metadata +40 -8
data/lib/tasks/turbo_tasks.rake
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
def run_turbo_install_template(path)
|
2
|
-
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb",
|
2
|
+
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb", __dir__)}"
|
3
3
|
end
|
4
4
|
|
5
5
|
def redis_installed?
|
6
|
-
|
6
|
+
Gem.win_platform? ?
|
7
|
+
system('where redis-server > NUL 2>&1') :
|
8
|
+
system('which redis-server > /dev/null')
|
7
9
|
end
|
8
10
|
|
9
11
|
def switch_on_redis_if_available
|
data/lib/turbo/engine.rb
CHANGED
@@ -16,13 +16,21 @@ module Turbo
|
|
16
16
|
#{root}/app/jobs
|
17
17
|
)
|
18
18
|
|
19
|
-
initializer "turbo.no_action_cable" do
|
20
|
-
|
19
|
+
initializer "turbo.no_action_cable", before: :set_eager_load_paths do
|
20
|
+
config.eager_load_paths.delete("#{root}/app/channels") unless defined?(ActionCable)
|
21
21
|
end
|
22
22
|
|
23
|
+
# If you don't want to precompile Turbo's assets (eg. because you're using webpack),
|
24
|
+
# you can do this in an intiailzer:
|
25
|
+
#
|
26
|
+
# config.after_initialize do
|
27
|
+
# config.assets.precompile -= Turbo::Engine::PRECOMPILE_ASSETS
|
28
|
+
# end
|
29
|
+
PRECOMPILE_ASSETS = %w( turbo.js turbo.min.js turbo.min.js.map )
|
30
|
+
|
23
31
|
initializer "turbo.assets" do
|
24
32
|
if Rails.application.config.respond_to?(:assets)
|
25
|
-
Rails.application.config.assets.precompile +=
|
33
|
+
Rails.application.config.assets.precompile += PRECOMPILE_ASSETS
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
@@ -53,8 +61,10 @@ module Turbo
|
|
53
61
|
end
|
54
62
|
|
55
63
|
initializer "turbo.signed_stream_verifier_key" do
|
56
|
-
|
57
|
-
|
64
|
+
config.after_initialize do
|
65
|
+
Turbo.signed_stream_verifier_key = config.turbo.signed_stream_verifier_key ||
|
66
|
+
Rails.application.key_generator.generate_key("turbo/signed_stream_verifier_key")
|
67
|
+
end
|
58
68
|
end
|
59
69
|
|
60
70
|
initializer "turbo.test_assertions" do
|
@@ -7,15 +7,21 @@ module Turbo
|
|
7
7
|
delegate :dom_id, :dom_class, to: ActionView::RecordIdentifier
|
8
8
|
end
|
9
9
|
|
10
|
-
def assert_turbo_stream(action:, target: nil, status: :ok, &block)
|
10
|
+
def assert_turbo_stream(action:, target: nil, targets: nil, status: :ok, &block)
|
11
11
|
assert_response status
|
12
12
|
assert_equal Mime[:turbo_stream], response.media_type
|
13
|
-
|
13
|
+
selector = %(turbo-stream[action="#{action}"])
|
14
|
+
selector << %([target="#{target.respond_to?(:to_key) ? dom_id(target) : target}"]) if target
|
15
|
+
selector << %([targets="#{targets}"]) if targets
|
16
|
+
assert_select selector, count: 1, &block
|
14
17
|
end
|
15
18
|
|
16
|
-
def assert_no_turbo_stream(action:, target: nil)
|
19
|
+
def assert_no_turbo_stream(action:, target: nil, targets: nil)
|
17
20
|
assert_equal Mime[:turbo_stream], response.media_type
|
18
|
-
|
21
|
+
selector = %(turbo-stream[action="#{action}"])
|
22
|
+
selector << %([target="#{target.respond_to?(:to_key) ? dom_id(target) : target}"]) if target
|
23
|
+
selector << %([targets="#{targets}"]) if targets
|
24
|
+
assert_select selector, count: 0
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|
data/lib/turbo/version.rb
CHANGED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
8
8
|
- Javan Mahkmali
|
9
9
|
- David Heinemeier Hansson
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-09-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: activejob
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
@@ -26,7 +26,35 @@ dependencies:
|
|
26
26
|
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: 6.0.0
|
29
|
-
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: actionpack
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 6.0.0
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 6.0.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: railties
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 6.0.0
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 6.0.0
|
57
|
+
description:
|
30
58
|
email: david@loudthinking.com
|
31
59
|
executables: []
|
32
60
|
extensions: []
|
@@ -36,6 +64,8 @@ files:
|
|
36
64
|
- README.md
|
37
65
|
- Rakefile
|
38
66
|
- app/assets/javascripts/turbo.js
|
67
|
+
- app/assets/javascripts/turbo.min.js
|
68
|
+
- app/assets/javascripts/turbo.min.js.map
|
39
69
|
- app/channels/turbo/streams/broadcasts.rb
|
40
70
|
- app/channels/turbo/streams/stream_name.rb
|
41
71
|
- app/channels/turbo/streams_channel.rb
|
@@ -50,7 +80,9 @@ files:
|
|
50
80
|
- app/helpers/turbo/streams_helper.rb
|
51
81
|
- app/javascript/turbo/cable.js
|
52
82
|
- app/javascript/turbo/cable_stream_source_element.js
|
83
|
+
- app/javascript/turbo/fetch_requests.js
|
53
84
|
- app/javascript/turbo/index.js
|
85
|
+
- app/javascript/turbo/snakeize.js
|
54
86
|
- app/jobs/turbo/streams/action_broadcast_job.rb
|
55
87
|
- app/jobs/turbo/streams/broadcast_job.rb
|
56
88
|
- app/models/concerns/turbo/broadcastable.rb
|
@@ -68,7 +100,7 @@ homepage: https://github.com/hotwired/turbo-rails
|
|
68
100
|
licenses:
|
69
101
|
- MIT
|
70
102
|
metadata: {}
|
71
|
-
post_install_message:
|
103
|
+
post_install_message:
|
72
104
|
rdoc_options: []
|
73
105
|
require_paths:
|
74
106
|
- lib
|
@@ -83,8 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
115
|
- !ruby/object:Gem::Version
|
84
116
|
version: '0'
|
85
117
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
87
|
-
signing_key:
|
118
|
+
rubygems_version: 3.3.20
|
119
|
+
signing_key:
|
88
120
|
specification_version: 4
|
89
121
|
summary: The speed of a single-page web application without having to write any JavaScript.
|
90
122
|
test_files: []
|