hotwire-spark 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/lib/hotwire/spark/default_options.rb +2 -2
- data/lib/hotwire/spark/middleware.rb +7 -2
- data/lib/hotwire/spark/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ec47d67c54c6bd3dae46dd9f5b28f287a45eee3a25001a16a2868c6d10ac83b
|
4
|
+
data.tar.gz: 0a68d8c3317f9dd97b2415f507ea34a9611b763f47ff5a465daa26b1b666ca56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af9ee7d3995fa2c9ff37a7399842feec7fbe875058aa9cc083f649df0f1a03c83daff92221bcb48346ea03a60dfb7b69bdd4f6cd5d90a2ce3d0687a9eac0417f
|
7
|
+
data.tar.gz: 762eea1538b421acf5f6f77638fdbfe1e1fec44517e95cc4828b6e60596dad09466d78d7e855c9996ae4561be6d63599e18597c0ec6dd90747ca3ed4087071bd
|
data/README.md
CHANGED
@@ -62,14 +62,14 @@ config.hotwire.spark.html_paths += %w[ lib ]
|
|
62
62
|
|
63
63
|
### Monitored paths
|
64
64
|
|
65
|
-
| Name | Description
|
66
|
-
|
67
|
-
| `html_paths` | Paths where file changes trigger a content refresh. By default: `app/controllers`, `app/helpers`, `app/models`, `app/views`. |
|
68
|
-
| `html_extensions` | The extensions to monitor for HTML content changes. By default: `rb`, `erb`.
|
69
|
-
| `css_paths` | Paths where file changes trigger a CSS refresh. By default: `app/assets/stylesheets` or `app/assets/builds` if exists.
|
70
|
-
| `css_extensions` | The extensions to monitor for CSS changes. By default: `css`.
|
71
|
-
| `stimulus_paths` | Paths where file changes trigger a Stimulus controller refresh. By default: `app/javascript/controllers`.
|
72
|
-
| `stimulus_extensions` | The extensions to monitor for Stimulus changes. By default: `js`.
|
65
|
+
| Name | Description |
|
66
|
+
|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
|
67
|
+
| `html_paths` | Paths where file changes trigger a content refresh. By default: `app/controllers`, `app/helpers`, `app/assets/images`, `app/models`, `app/views`. |
|
68
|
+
| `html_extensions` | The extensions to monitor for HTML content changes. By default: `rb`, `erb`, `png`, `jpg`, `jpeg`, `webp`, `svg`. |
|
69
|
+
| `css_paths` | Paths where file changes trigger a CSS refresh. By default: `app/assets/stylesheets` or `app/assets/builds` if exists. |
|
70
|
+
| `css_extensions` | The extensions to monitor for CSS changes. By default: `css`. |
|
71
|
+
| `stimulus_paths` | Paths where file changes trigger a Stimulus controller refresh. By default: `app/javascript/controllers`. |
|
72
|
+
| `stimulus_extensions` | The extensions to monitor for Stimulus changes. By default: `js`. |
|
73
73
|
|
74
74
|
## License
|
75
75
|
|
@@ -15,8 +15,8 @@ class Hotwire::Spark::DefaultOptions
|
|
15
15
|
enabled: Rails.env.development?,
|
16
16
|
css_paths: File.directory?("app/assets/builds") ? %w[ app/assets/builds ] : %w[ app/assets/stylesheets ],
|
17
17
|
css_extensions: %w[ css ],
|
18
|
-
html_paths: %w[ app/controllers app/helpers app/models app/views ],
|
19
|
-
html_extensions: %w[ rb erb ],
|
18
|
+
html_paths: %w[ app/controllers app/helpers app/assets/images app/models app/views ],
|
19
|
+
html_extensions: %w[ rb erb png jpg jpeg webp svg ],
|
20
20
|
stimulus_paths: %w[ app/javascript/controllers ],
|
21
21
|
stimulus_extensions: %w[ js ],
|
22
22
|
html_reload_method: :morph
|
@@ -6,8 +6,9 @@ class Hotwire::Spark::Middleware
|
|
6
6
|
def call(env)
|
7
7
|
status, headers, response = @app.call(env)
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
@request = ActionDispatch::Request.new(env)
|
10
|
+
|
11
|
+
if interceptable_request? && html_response?(headers)
|
11
12
|
html = html_from(response)
|
12
13
|
html = inject_javascript(html)
|
13
14
|
html = inject_options(html)
|
@@ -19,6 +20,10 @@ class Hotwire::Spark::Middleware
|
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
23
|
+
def interceptable_request?
|
24
|
+
@request.controller_instance.present?
|
25
|
+
end
|
26
|
+
|
22
27
|
def html_response?(headers)
|
23
28
|
headers["Content-Type"]&.include?("text/html")
|
24
29
|
end
|