inertia-rage 0.0.1 → 1.0.0
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/CHANGELOG.md +1 -1
- data/README.md +12 -1
- data/lib/inertia/inertia.rb +4 -1
- data/lib/inertia/{controller_helpers.rb → rage_controller/inertia.rb} +8 -12
- data/lib/inertia/rage_extension.rb +0 -6
- data/lib/inertia/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: b02bfd40eee71d4f47b7aa88f120895a078d8f08adfef18002172e9ce7e5a988
|
|
4
|
+
data.tar.gz: de0d2658ebc07bcbdfed14aa6d9fe2cc17ca1f8f35f1b17d49a9a28f34c788a1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f0add134abde83e42eb7a9137654b25a3b8f94d8bbb2f5e81b22b5fe2ee7d99c66cb8df059a4e2085d2752d064ffdb4a69af1c299844ff60474f3e3224d77bb0
|
|
7
|
+
data.tar.gz: ce8bcfa86c0a2eba062f04755b005ebfee024f4c6075373a109996f8e862d5b99132ef6692e8cae95475f1b49fd9f1c31657441f5f46c66a5c34d4bf012fb32d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -8,6 +8,8 @@ This gem handles Inertia page responses, provides flexible prop types, and integ
|
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
11
|
+
### Server-side setup
|
|
12
|
+
|
|
11
13
|
Create a Rage app and add the gem:
|
|
12
14
|
|
|
13
15
|
```
|
|
@@ -15,6 +17,15 @@ rage new my-app -d postgresql
|
|
|
15
17
|
bundle add inertia-rage
|
|
16
18
|
```
|
|
17
19
|
|
|
20
|
+
Update the parent controller in your `ApplicationController` from `RageController::API` to `RageController::Inertia` to get access to CSRF protection and redirect helpers:
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
class ApplicationController < RageController::Inertia
|
|
24
|
+
end
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Client-side setup
|
|
28
|
+
|
|
18
29
|
Create a frontend project in any directory within your project's root or `app` folder:
|
|
19
30
|
|
|
20
31
|
```
|
|
@@ -202,7 +213,7 @@ See the [API documentation](https://inertia-api.rage-rb.dev/Inertia/Configuratio
|
|
|
202
213
|
## Learn More
|
|
203
214
|
|
|
204
215
|
- [Props API Reference](https://inertia-api.rage-rb.dev/Inertia)
|
|
205
|
-
- [Controller API Reference](https://inertia-api.rage-rb.dev/Inertia/ControllerHelpers.html)
|
|
216
|
+
- [Controller API Reference](https://inertia-api.rage-rb.dev/Inertia/ControllerHelpers.html) TODO
|
|
206
217
|
- [Configuration API Reference](https://inertia-api.rage-rb.dev/Inertia/Configuration.html)
|
|
207
218
|
|
|
208
219
|
## Contributing
|
data/lib/inertia/inertia.rb
CHANGED
|
@@ -7,7 +7,6 @@ require_relative "frontend"
|
|
|
7
7
|
require_relative "renderer"
|
|
8
8
|
require_relative "request_context"
|
|
9
9
|
require_relative "protocol_builder"
|
|
10
|
-
require_relative "controller_helpers"
|
|
11
10
|
require_relative "configuration"
|
|
12
11
|
require_relative "middleware/version"
|
|
13
12
|
require_relative "middleware/assets"
|
|
@@ -85,3 +84,7 @@ module Inertia
|
|
|
85
84
|
|
|
86
85
|
autoload :ViteDevServer, "inertia/vite_dev_server"
|
|
87
86
|
end
|
|
87
|
+
|
|
88
|
+
module RageController
|
|
89
|
+
autoload :Inertia, "inertia/rage_controller/inertia"
|
|
90
|
+
end
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require "uri"
|
|
4
4
|
|
|
5
|
-
module
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module ControllerHelpers
|
|
9
|
-
module ClassMethods
|
|
5
|
+
module RageController
|
|
6
|
+
class Inertia < RageController::API
|
|
7
|
+
class << self
|
|
10
8
|
# Shares data with all Inertia responses in a controller.
|
|
11
9
|
#
|
|
12
10
|
# This method registers a before_action that evaluates the given block
|
|
@@ -22,7 +20,7 @@ module Inertia
|
|
|
22
20
|
# @yieldreturn [Hash] the data to merge into the shared props
|
|
23
21
|
#
|
|
24
22
|
# @example Share data for all actions
|
|
25
|
-
# class ApplicationController < RageController::
|
|
23
|
+
# class ApplicationController < RageController::Inertia
|
|
26
24
|
# inertia_share do
|
|
27
25
|
# { current_user: current_user&.as_json }
|
|
28
26
|
# end
|
|
@@ -57,6 +55,10 @@ module Inertia
|
|
|
57
55
|
end
|
|
58
56
|
end
|
|
59
57
|
|
|
58
|
+
# @private
|
|
59
|
+
attr_accessor :inertia_shared_data
|
|
60
|
+
before_action :protect_from_csrf
|
|
61
|
+
|
|
60
62
|
# Redirects the client to the specified location.
|
|
61
63
|
#
|
|
62
64
|
# @param location [String] the URL to redirect to
|
|
@@ -114,12 +116,6 @@ module Inertia
|
|
|
114
116
|
end
|
|
115
117
|
end
|
|
116
118
|
|
|
117
|
-
# @private
|
|
118
|
-
def self.included(klass)
|
|
119
|
-
klass.before_action :protect_from_csrf
|
|
120
|
-
klass.attr_accessor :inertia_shared_data
|
|
121
|
-
end
|
|
122
|
-
|
|
123
119
|
private
|
|
124
120
|
|
|
125
121
|
# Appends additional request information to the log payload.
|
|
@@ -30,12 +30,6 @@ module Inertia
|
|
|
30
30
|
config.middleware.use Middleware::Version
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
# Include ControllerHelpers to add support for `redirect_to` and other Inertia-specific methods
|
|
34
|
-
initializer "inertia.rage.controller_helpers" do
|
|
35
|
-
RageController::API.include ControllerHelpers
|
|
36
|
-
RageController::API.extend ControllerHelpers::ClassMethods
|
|
37
|
-
end
|
|
38
|
-
|
|
39
33
|
# Prebuild frontend assets before launching the server in production
|
|
40
34
|
before_server_start do
|
|
41
35
|
if Inertia.config.build_on_start?
|
data/lib/inertia/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inertia-rage
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Roman Samoilov
|
|
@@ -38,13 +38,13 @@ files:
|
|
|
38
38
|
- Rakefile
|
|
39
39
|
- lib/inertia-rage.rb
|
|
40
40
|
- lib/inertia/configuration.rb
|
|
41
|
-
- lib/inertia/controller_helpers.rb
|
|
42
41
|
- lib/inertia/frontend.rb
|
|
43
42
|
- lib/inertia/inertia.rb
|
|
44
43
|
- lib/inertia/middleware/assets.rb
|
|
45
44
|
- lib/inertia/middleware/version.rb
|
|
46
45
|
- lib/inertia/props.rb
|
|
47
46
|
- lib/inertia/protocol_builder.rb
|
|
47
|
+
- lib/inertia/rage_controller/inertia.rb
|
|
48
48
|
- lib/inertia/rage_extension.rb
|
|
49
49
|
- lib/inertia/renderer.rb
|
|
50
50
|
- lib/inertia/request_context.rb
|