turbo-rails 0.6.0 → 0.7.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 +2 -2
- data/lib/install/turbo_with_asset_pipeline.rb +3 -24
- data/lib/install/turbo_with_webpacker.rb +0 -2
- data/lib/turbo/engine.rb +8 -0
- data/lib/turbo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d791adac758f16b877d9d7c1ed0706e9bb684ba6238f94c3a1de0dcc424b85d4
|
4
|
+
data.tar.gz: 9a60a2a70b4b732687220f2cd209454b02a963a450af1ce07ff49708ad8bf0cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c76c8475cb8509f86208a3553e6561d6dcaec91198d226aa2c23a6b9d45c0615db36cab291b77b82001330c46de12923c817250aa93d2ba9e28bc37b5fbd4b1
|
7
|
+
data.tar.gz: c78eb044de3328bb08edb26f552716df709913c640676ff1156ee878e956cc3d860f9a1f82fbe5889491182092563a83708dda4721db1747769b927fac1956a7
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ The JavaScript for Turbo can either be run through the asset pipeline, which is
|
|
38
38
|
2. Run `./bin/bundle install`
|
39
39
|
3. Run `./bin/rails turbo:install`
|
40
40
|
|
41
|
-
Running `turbo:install` will install through NPM if Webpacker is installed in the application. Otherwise the asset pipeline version is used.
|
41
|
+
Running `turbo:install` will install through NPM if Webpacker is installed in the application. Otherwise the asset pipeline version is used. To use the asset pipeline version, you must have `importmap-rails` installed first and listed higher in the Gemfile.
|
42
42
|
|
43
43
|
If you're using Webpack and need to use the cable consumer, you can import [`cable`](https://github.com/hotwired/turbo-rails/blob/main/app/javascript/turbo/cable.js) (`import { cable } from "@hotwired/turbo-rails"`), but ensure that your application actually *uses* the members it `import`s when using this style (see [turbo-rails#48](https://github.com/hotwired/turbo-rails/issues/48)).
|
44
44
|
|
@@ -62,7 +62,7 @@ Turbo can coexist with Rails UJS, but you need to take a series of upgrade steps
|
|
62
62
|
|
63
63
|
* To run the Rails tests: `bundle exec rake`.
|
64
64
|
* To install dependencies: `bundle install`
|
65
|
-
* To prepare the test database: `cd
|
65
|
+
* To prepare the test database: `cd test/dummy; RAILS_ENV=test ./bin/rails db:migrate`
|
66
66
|
* To compile the JavaScript for the asset pipeline: `yarn build`
|
67
67
|
|
68
68
|
|
@@ -1,27 +1,8 @@
|
|
1
|
-
|
2
|
-
IMPORTMAP_PATH = Rails.root.join("app/assets/javascripts/importmap.json.erb")
|
1
|
+
APP_JS_ROOT = Rails.root.join("app/assets/javascripts")
|
3
2
|
CABLE_CONFIG_PATH = Rails.root.join("config/cable.yml")
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
insert_into_file APPLICATION_LAYOUT_PATH.to_s, "\n <%= yield :head %>", before: /\s*<\/head>/
|
8
|
-
|
9
|
-
if APPLICATION_LAYOUT_PATH.read =~ /stimulus/
|
10
|
-
say "Add Turbo include tags in application layout"
|
11
|
-
insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n <%= javascript_include_tag "turbo", type: "module-shim" %>), after: /<%= stimulus_include_tags %>/
|
12
|
-
|
13
|
-
if IMPORTMAP_PATH.exist?
|
14
|
-
say "Add Turbo to importmap"
|
15
|
-
insert_into_file IMPORTMAP_PATH, %( "turbo": "<%= asset_path "turbo" %>",\n), after: / "imports": {\s*\n/
|
16
|
-
end
|
17
|
-
else
|
18
|
-
say "Add Turbo include tags in application layout"
|
19
|
-
insert_into_file APPLICATION_LAYOUT_PATH.to_s, %(\n <%= javascript_include_tag "turbo", type: "module" %>), before: /\s*<\/head>/
|
20
|
-
end
|
21
|
-
else
|
22
|
-
say "Default application.html.erb is missing!", :red
|
23
|
-
say %( Add <%= javascript_include_tag("turbo", type: "module-shim") %> and <%= yield :head %> within the <head> tag after Stimulus includes in your custom layout.)
|
24
|
-
end
|
4
|
+
say "Import turbo-rails in existing app/assets/javascripts/application.js"
|
5
|
+
append_to_file APP_JS_ROOT.join("application.js"), %(import "@hotwired/turbo-rails"\n)
|
25
6
|
|
26
7
|
if CABLE_CONFIG_PATH.exist?
|
27
8
|
say "Enable redis in bundle"
|
@@ -32,5 +13,3 @@ if CABLE_CONFIG_PATH.exist?
|
|
32
13
|
else
|
33
14
|
say 'ActionCable config file (config/cable.yml) is missing. Uncomment "gem \'redis\'" in your Gemfile and create config/cable.yml to use the Turbo Streams broadcast feature.'
|
34
15
|
end
|
35
|
-
|
36
|
-
say "Turbo successfully installed ⚡️", :green
|
@@ -25,5 +25,3 @@ if CABLE_CONFIG_PATH.exist?
|
|
25
25
|
else
|
26
26
|
say 'ActionCable config file (config/cable.yml) is missing. Uncomment "gem \'redis\'" in your Gemfile and create config/cable.yml to use the Turbo Streams broadcast feature.'
|
27
27
|
end
|
28
|
-
|
29
|
-
say "Turbo successfully installed ⚡️", :green
|
data/lib/turbo/engine.rb
CHANGED
@@ -26,6 +26,14 @@ module Turbo
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
initializer "turbo.importmap" do
|
30
|
+
if Rails.application.config.respond_to?(:importmap)
|
31
|
+
Rails.application.config.importmap.paths.tap do |paths|
|
32
|
+
paths.asset "@hotwired/turbo-rails", path: "turbo"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
initializer "turbo.helpers", before: :load_config_initializers do
|
30
38
|
ActiveSupport.on_load(:action_controller_base) do
|
31
39
|
include Turbo::Streams::TurboStreamsTagBuilder, Turbo::Frames::FrameRequest, Turbo::Native::Navigation
|
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.
|
4
|
+
version: 0.7.0
|
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-
|
13
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|