turbo-rails 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c9c9d12f7b7318bb4e2eede2cb11e8c7f8ca2eb623d21d7c71c27005422f7a
|
4
|
+
data.tar.gz: e2df4c5dc7d36d4c960dfeff36318e1ed36f0b94e386ce151bda33ecf8826131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40dac08e7447ab44a6d6924d60e8bc8c6d5fff7f88bc8f7ba00c54f957b9559e0d0202cb5ece9165fa571c81b9edd49cd83afc0d75f274c16fb44b193ade9578
|
7
|
+
data.tar.gz: bf61cb90835e8aee3aca8c13728a91b488dae4cb903f3bede52f5991279c3587f9c3dd1eee8b04b450721d65f37d9687e69ad07a690a28d0e5d412932095ccbd
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module Turbo::IncludesHelper
|
2
|
+
# DEPRECATED: Just use <tt>javascript_include_tag "turbo", type: "module"</tt> directly if using Turbo alone, or
|
3
|
+
# javascript_include_tag "turbo", type: "module-shim" if together with Stimulus and importmaps.
|
2
4
|
def turbo_include_tags
|
3
5
|
javascript_include_tag("turbo", type: "module")
|
4
6
|
end
|
@@ -51,18 +51,23 @@ module Turbo::Broadcastable
|
|
51
51
|
# belongs_to :board
|
52
52
|
# broadcasts_to ->(message) { [ message.board, :messages ] }, inserts_by: :prepend, target: "board_messages"
|
53
53
|
# end
|
54
|
-
def broadcasts_to(stream, inserts_by: :append, target:
|
54
|
+
def broadcasts_to(stream, inserts_by: :append, target: broadcast_target_default)
|
55
55
|
after_create_commit -> { broadcast_action_later_to stream.try(:call, self) || send(stream), action: inserts_by, target: target }
|
56
56
|
after_update_commit -> { broadcast_replace_later_to stream.try(:call, self) || send(stream) }
|
57
57
|
after_destroy_commit -> { broadcast_remove_to stream.try(:call, self) || send(stream) }
|
58
58
|
end
|
59
59
|
|
60
60
|
# Same as <tt>#broadcasts_to</tt>, but the designated stream is automatically set to the current model.
|
61
|
-
def broadcasts(inserts_by: :append, target:
|
61
|
+
def broadcasts(inserts_by: :append, target: broadcast_target_default)
|
62
62
|
after_create_commit -> { broadcast_action_later action: inserts_by, target: target }
|
63
63
|
after_update_commit -> { broadcast_replace_later }
|
64
64
|
after_destroy_commit -> { broadcast_remove }
|
65
65
|
end
|
66
|
+
|
67
|
+
# All default targets will use the return of this method. Overwrite if you want something else than <tt>model_name.plural</tt>.
|
68
|
+
def broadcast_target_default
|
69
|
+
model_name.plural
|
70
|
+
end
|
66
71
|
end
|
67
72
|
|
68
73
|
# Remove this broadcastable model from the dom for subscribers of the stream name identified by the passed streamables.
|
@@ -223,7 +228,7 @@ module Turbo::Broadcastable
|
|
223
228
|
|
224
229
|
private
|
225
230
|
def broadcast_target_default
|
226
|
-
|
231
|
+
self.class.broadcast_target_default
|
227
232
|
end
|
228
233
|
|
229
234
|
def broadcast_rendering_with_defaults(options)
|
@@ -4,11 +4,21 @@ if APPLICATION_LAYOUT_PATH.exist?
|
|
4
4
|
say "Yield head in application layout for cache helper"
|
5
5
|
insert_into_file APPLICATION_LAYOUT_PATH.to_s, "\n <%= yield :head %>", before: /\s*<\/head>/
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
if APPLICATION_LAYOUT_PATH.read =~ /stimulus/
|
8
|
+
say "Add Turbo include tags in application layout"
|
9
|
+
insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n <%= javascript_include_tag "turbo", type: "module-shim" %>), after: /<%= stimulus_include_tags %>/
|
10
|
+
else
|
11
|
+
say "Add Turbo include tags in application layout"
|
12
|
+
insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n <%= javascript_include_tag "turbo", type: "module" %>), before: /\s*<\/head>/
|
13
|
+
end
|
9
14
|
else
|
10
15
|
say "Default application.html.erb is missing!", :red
|
11
|
-
|
16
|
+
|
17
|
+
if APPLICATION_LAYOUT_PATH.read =~ /stimulus/
|
18
|
+
say %( Add <%= javascript_include_tag("turbo", type: "module-shim") %> and <%= yield :head %> within the <head> tag after Stimulus includes in your custom layout.)
|
19
|
+
else
|
20
|
+
say %( Add <%= javascript_include_tag("turbo", type: "module") %> and <%= yield :head %> within the <head> tag in your custom layout.)
|
21
|
+
end
|
12
22
|
end
|
13
23
|
|
14
24
|
say "Enable redis in bundle"
|
data/lib/turbo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbo-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stephenson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-01-
|
13
|
+
date: 2021-01-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|