plutonium 0.23.4 → 0.23.5
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/app/assets/plutonium.css +2 -2
- data/config/initializers/sqlite_json_alias.rb +1 -1
- data/docs/.vitepress/config.ts +60 -19
- data/docs/guide/cursor-rules.md +75 -0
- data/docs/guide/deep-dive/authorization.md +189 -0
- data/docs/guide/{getting-started → deep-dive}/resources.md +137 -0
- data/docs/guide/getting-started/{installation.md → 01-installation.md} +0 -105
- data/docs/guide/index.md +28 -0
- data/docs/guide/introduction/02-core-concepts.md +440 -0
- data/docs/guide/tutorial/01-project-setup.md +75 -0
- data/docs/guide/tutorial/02-creating-a-feature-package.md +45 -0
- data/docs/guide/tutorial/03-defining-resources.md +90 -0
- data/docs/guide/tutorial/04-creating-a-portal.md +101 -0
- data/docs/guide/tutorial/05-customizing-the-ui.md +128 -0
- data/docs/guide/tutorial/06-adding-custom-actions.md +101 -0
- data/docs/guide/tutorial/07-implementing-authorization.md +90 -0
- data/docs/index.md +24 -31
- data/docs/modules/action.md +190 -0
- data/docs/modules/authentication.md +236 -0
- data/docs/modules/configuration.md +599 -0
- data/docs/modules/controller.md +398 -0
- data/docs/modules/core.md +316 -0
- data/docs/modules/definition.md +876 -0
- data/docs/modules/display.md +759 -0
- data/docs/modules/form.md +605 -0
- data/docs/modules/generator.md +288 -0
- data/docs/modules/index.md +167 -0
- data/docs/modules/interaction.md +470 -0
- data/docs/modules/package.md +151 -0
- data/docs/modules/policy.md +176 -0
- data/docs/modules/portal.md +710 -0
- data/docs/modules/query.md +287 -0
- data/docs/modules/resource_record.md +618 -0
- data/docs/modules/routing.md +641 -0
- data/docs/modules/table.md +293 -0
- data/docs/modules/ui.md +631 -0
- data/docs/public/plutonium.mdc +667 -0
- data/lib/generators/pu/core/assets/assets_generator.rb +0 -5
- data/lib/plutonium/ui/display/resource.rb +7 -2
- data/lib/plutonium/ui/table/resource.rb +8 -3
- data/lib/plutonium/version.rb +1 -1
- metadata +36 -9
- data/docs/guide/getting-started/authorization.md +0 -296
- data/docs/guide/getting-started/core-concepts.md +0 -432
- data/docs/guide/getting-started/index.md +0 -21
- data/docs/guide/tutorial.md +0 -401
- /data/docs/guide/{what-is-plutonium.md → introduction/01-what-is-plutonium.md} +0 -0
@@ -0,0 +1,288 @@
|
|
1
|
+
---
|
2
|
+
title: Generator Module
|
3
|
+
---
|
4
|
+
|
5
|
+
# Generator Module
|
6
|
+
|
7
|
+
The Generator module provides comprehensive code generation and scaffolding capabilities for Plutonium applications. It offers a suite of Rails generators that automate the creation of packages, resources, authentication setups, and other common development patterns.
|
8
|
+
|
9
|
+
::: tip
|
10
|
+
The Generator module is located in `lib/generators/pu/`.
|
11
|
+
:::
|
12
|
+
|
13
|
+
## Overview
|
14
|
+
|
15
|
+
- **Code Scaffolding**: Automated generation of models, controllers, policies, and definitions.
|
16
|
+
- **Package Creation**: Portal and feature package generators with proper structure.
|
17
|
+
- **Resource Management**: Complete resource scaffolding with CRUD operations.
|
18
|
+
- **Authentication Setup**: Rodauth integration with multi-account support.
|
19
|
+
- **Interactive CLI**: TTY-powered interactive prompts for generator options.
|
20
|
+
|
21
|
+
## Core Generators
|
22
|
+
|
23
|
+
### Installation Generator (`pu:core:install`)
|
24
|
+
|
25
|
+
Sets up the base requirements for a Plutonium application.
|
26
|
+
|
27
|
+
::: code-group
|
28
|
+
```bash [Command]
|
29
|
+
rails generate pu:core:install
|
30
|
+
```
|
31
|
+
```text [Generated Structure]
|
32
|
+
config/
|
33
|
+
├── packages.rb # Package loading configuration
|
34
|
+
└── initializers/
|
35
|
+
└── plutonium.rb # Plutonium configuration
|
36
|
+
|
37
|
+
packages/ # Package directory
|
38
|
+
└── .keep
|
39
|
+
|
40
|
+
app/
|
41
|
+
├── controllers/
|
42
|
+
│ ├── application_controller.rb # Enhanced with Plutonium
|
43
|
+
│ ├── plutonium_controller.rb # Base Plutonium controller
|
44
|
+
│ └── resource_controller.rb # Resource CRUD controller
|
45
|
+
└── models/
|
46
|
+
└── application_record.rb # Enhanced with Plutonium::Resource::Record
|
47
|
+
|
48
|
+
app/views/
|
49
|
+
└── layouts/
|
50
|
+
└── resource.html.erb # Ejected layout for customization
|
51
|
+
```
|
52
|
+
:::
|
53
|
+
|
54
|
+
### Package Generators
|
55
|
+
|
56
|
+
#### Portal Generator (`pu:pkg:portal`)
|
57
|
+
|
58
|
+
Creates a complete portal package, which acts as a user-facing entry point to your application, often with its own authentication.
|
59
|
+
|
60
|
+
::: code-group
|
61
|
+
```bash [Command]
|
62
|
+
# Creates an "admin" portal with authentication
|
63
|
+
rails generate pu:pkg:portal admin
|
64
|
+
|
65
|
+
# Creates a "customer" portal with public access
|
66
|
+
rails generate pu:pkg:portal customer --public
|
67
|
+
```
|
68
|
+
```text [Generated Structure]
|
69
|
+
packages/admin_portal/
|
70
|
+
├── lib/
|
71
|
+
│ └── engine.rb # Portal engine with entity scoping
|
72
|
+
├── config/
|
73
|
+
│ └── routes.rb # Portal-specific routes
|
74
|
+
└── app/
|
75
|
+
├── controllers/
|
76
|
+
│ └── admin_portal/
|
77
|
+
│ ├── concerns/controller.rb # Portal controller concern
|
78
|
+
│ ├── plutonium_controller.rb
|
79
|
+
│ ├── resource_controller.rb
|
80
|
+
│ └── dashboard_controller.rb
|
81
|
+
├── policies/
|
82
|
+
│ └── admin_portal/
|
83
|
+
└── definitions/
|
84
|
+
└── admin_portal/
|
85
|
+
```
|
86
|
+
```ruby [Authentication Integration]
|
87
|
+
# Automatic Rodauth integration is added to the controller concern
|
88
|
+
# packages/admin_portal/app/controllers/admin_portal/concerns/controller.rb
|
89
|
+
|
90
|
+
module AdminPortal
|
91
|
+
module Concerns
|
92
|
+
module Controller
|
93
|
+
extend ActiveSupport::Concern
|
94
|
+
include Plutonium::Portal::Controller
|
95
|
+
# Generated based on generator selection (e.g., :admin)
|
96
|
+
include Plutonium::Auth::Rodauth(:admin)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
```
|
101
|
+
:::
|
102
|
+
|
103
|
+
#### Package Generator (`pu:pkg:package`)
|
104
|
+
|
105
|
+
Creates a standard feature package for encapsulating domain logic.
|
106
|
+
|
107
|
+
::: code-group
|
108
|
+
```bash [Command]
|
109
|
+
rails generate pu:pkg:package blogging
|
110
|
+
```
|
111
|
+
```text [Generated Structure]
|
112
|
+
packages/blogging/
|
113
|
+
├── lib/
|
114
|
+
│ └── engine.rb # Package engine
|
115
|
+
└── app/
|
116
|
+
├── models/
|
117
|
+
│ └── blogging/
|
118
|
+
├── controllers/
|
119
|
+
│ └── blogging/
|
120
|
+
├── policies/
|
121
|
+
│ └── blogging/
|
122
|
+
├── definitions/
|
123
|
+
│ └── blogging/
|
124
|
+
└── interactions/
|
125
|
+
└── blogging/
|
126
|
+
```
|
127
|
+
:::
|
128
|
+
|
129
|
+
### Resource Generators
|
130
|
+
|
131
|
+
#### Scaffold Generator (`pu:res:scaffold`)
|
132
|
+
|
133
|
+
Creates a complete resource with a model, controller, policy, and definition, including full CRUD operations.
|
134
|
+
|
135
|
+
::: code-group
|
136
|
+
```bash [Command]
|
137
|
+
# Generate a new resource with attributes, placing it in the 'blogging' package
|
138
|
+
rails generate pu:res:scaffold Post title:string content:text author:references published:boolean --dest=blogging
|
139
|
+
```
|
140
|
+
```ruby [Generated Model]
|
141
|
+
# packages/blogging/app/models/blogging/post.rb
|
142
|
+
class Blogging::Post < Blogging::ResourceRecord
|
143
|
+
belongs_to :author, class_name: 'UserManagement::User'
|
144
|
+
|
145
|
+
validates :title, presence: true
|
146
|
+
validates :content, presence: true
|
147
|
+
end
|
148
|
+
```
|
149
|
+
```ruby [Generated Policy]
|
150
|
+
# packages/blogging/app/policies/blogging/post_policy.rb
|
151
|
+
class Blogging::PostPolicy < Blogging B::ResourcePolicy
|
152
|
+
def create?
|
153
|
+
user.present?
|
154
|
+
end
|
155
|
+
|
156
|
+
def update?
|
157
|
+
user == record.author
|
158
|
+
end
|
159
|
+
end
|
160
|
+
```
|
161
|
+
```ruby [Generated Definition]
|
162
|
+
# packages/blogging/app/definitions/blogging/post_definition.rb
|
163
|
+
class Blogging::PostDefinition < Blogging::ResourceDefinition
|
164
|
+
# Display configuration
|
165
|
+
display :title, :author, :published, :created_at
|
166
|
+
|
167
|
+
# Search configuration
|
168
|
+
search :title, :content
|
169
|
+
|
170
|
+
# Filter configuration
|
171
|
+
filter :published, with: :boolean
|
172
|
+
filter :author, with: :select
|
173
|
+
end
|
174
|
+
```
|
175
|
+
:::
|
176
|
+
|
177
|
+
### Authentication Generators
|
178
|
+
|
179
|
+
#### Rodauth Account Generator (`pu:rodauth:account`)
|
180
|
+
|
181
|
+
Generates the necessary files for a Rodauth authentication setup for a given account type.
|
182
|
+
|
183
|
+
::: code-group
|
184
|
+
```bash [Command]
|
185
|
+
# Generate a 'user' account with common features
|
186
|
+
rails generate pu:rodauth:account user --features login logout create-account verify-account reset-password remember
|
187
|
+
```
|
188
|
+
```text [Generated Structure]
|
189
|
+
app/
|
190
|
+
├── controllers/
|
191
|
+
│ └── rodauth/
|
192
|
+
│ └── user_controller.rb
|
193
|
+
├── mailers/
|
194
|
+
│ └── user_mailer.rb
|
195
|
+
├── models/
|
196
|
+
│ └── user.rb
|
197
|
+
└── rodauth/
|
198
|
+
├── user_rodauth.rb
|
199
|
+
└── user_rodauth_plugin.rb
|
200
|
+
db/
|
201
|
+
└── migrate/
|
202
|
+
└── ..._create_users.rb
|
203
|
+
```
|
204
|
+
:::
|
205
|
+
|
206
|
+
#### Rodauth Admin Generator (`pu:rodauth:admin`)
|
207
|
+
|
208
|
+
A specialized generator for creating a secure admin account with enhanced features like MFA and audit logging.
|
209
|
+
|
210
|
+
::: code-group
|
211
|
+
```bash [Command]
|
212
|
+
rails generate pu:rodauth:admin admin
|
213
|
+
```
|
214
|
+
```ruby [Generated Plugin]
|
215
|
+
# app/rodauth/admin_rodauth_plugin.rb
|
216
|
+
class AdminRodauthPlugin < RodauthPlugin
|
217
|
+
configure do
|
218
|
+
enable :login, :logout, :remember,
|
219
|
+
:otp, :recovery_codes, :lockout,
|
220
|
+
:active_sessions, :audit_logging,
|
221
|
+
:password_grace_period, :internal_request
|
222
|
+
|
223
|
+
# ... and other secure defaults
|
224
|
+
end
|
225
|
+
end
|
226
|
+
```
|
227
|
+
:::
|
228
|
+
|
229
|
+
### Ejection Generators
|
230
|
+
|
231
|
+
#### Layout Ejection (`pu:eject:layout`)
|
232
|
+
|
233
|
+
Ejects Plutonium layouts for customization:
|
234
|
+
|
235
|
+
```bash
|
236
|
+
rails generate pu:eject:layout --dest=admin_portal
|
237
|
+
```
|
238
|
+
|
239
|
+
#### Shell Ejection (`pu:eject:shell`)
|
240
|
+
|
241
|
+
Ejects shell components and assets:
|
242
|
+
|
243
|
+
```bash
|
244
|
+
rails generate pu:eject:shell --dest=admin_portal
|
245
|
+
```
|
246
|
+
|
247
|
+
## Generator Configuration
|
248
|
+
|
249
|
+
### Interactive Mode
|
250
|
+
|
251
|
+
Many generators support interactive prompts:
|
252
|
+
|
253
|
+
```bash
|
254
|
+
# Interactive package selection
|
255
|
+
rails generate pu:res:scaffold Post title:string
|
256
|
+
# Prompts: "Select destination feature: [blogging, user_management, main_app]"
|
257
|
+
|
258
|
+
# Non-interactive mode
|
259
|
+
rails generate pu:res:scaffold Post title:string --dest=blogging
|
260
|
+
```
|
261
|
+
|
262
|
+
## Development Workflow Integration
|
263
|
+
|
264
|
+
### IDE Integration
|
265
|
+
|
266
|
+
Add generator shortcuts to your IDE:
|
267
|
+
|
268
|
+
```json
|
269
|
+
// .vscode/tasks.json
|
270
|
+
{
|
271
|
+
"tasks": [
|
272
|
+
{
|
273
|
+
"label": "Generate Resource",
|
274
|
+
"type": "shell",
|
275
|
+
"command": "rails generate pu:res:scaffold ${input:resourceName}",
|
276
|
+
"group": "build"
|
277
|
+
},
|
278
|
+
{
|
279
|
+
"label": "Generate Portal",
|
280
|
+
"type": "shell",
|
281
|
+
"command": "rails generate pu:pkg:portal ${input:portalName}",
|
282
|
+
"group": "build"
|
283
|
+
}
|
284
|
+
]
|
285
|
+
}
|
286
|
+
```
|
287
|
+
|
288
|
+
The Generator module provides a comprehensive foundation for rapid application development with Plutonium, automating repetitive tasks while maintaining flexibility and customization options.
|
@@ -0,0 +1,167 @@
|
|
1
|
+
---
|
2
|
+
title: Plutonium Modules
|
3
|
+
---
|
4
|
+
|
5
|
+
# Plutonium Modules
|
6
|
+
|
7
|
+
Plutonium is built as a collection of focused, interconnected modules that extend Rails with powerful conventions and capabilities. Each module tackles a specific aspect of application development—from managing data and business logic to creating beautiful user interfaces.
|
8
|
+
|
9
|
+
This modular design means you can learn and use only what you need, while still benefiting from the seamless integration across the entire framework.
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
## Architecture Modules
|
14
|
+
The foundational components that structure and organize your Plutonium application.
|
15
|
+
|
16
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
17
|
+
<div class="card">
|
18
|
+
<a href="./core" class="block p-4">
|
19
|
+
<h3 class="font-bold">Core Module</h3>
|
20
|
+
<p class="text-sm">The foundation that powers everything—base controllers, essential utilities, and framework integration points.</p>
|
21
|
+
</a>
|
22
|
+
</div>
|
23
|
+
<div class="card">
|
24
|
+
<a href="./controller" class="block p-4">
|
25
|
+
<h3 class="font-bold">Controller Module</h3>
|
26
|
+
<p class="text-sm">Smart HTTP request handling with built-in CRUD operations, authorization, and multi-tenancy support.</p>
|
27
|
+
</a>
|
28
|
+
</div>
|
29
|
+
<div class="card">
|
30
|
+
<a href="./routing" class="block p-4">
|
31
|
+
<h3 class="font-bold">Routing Module</h3>
|
32
|
+
<p class="text-sm">Intelligent resource routing that automatically creates nested routes, handles entity scoping, and manages interactive actions.</p>
|
33
|
+
</a>
|
34
|
+
</div>
|
35
|
+
<div class="card">
|
36
|
+
<a href="./package" class="block p-4">
|
37
|
+
<h3 class="font-bold">Package Module</h3>
|
38
|
+
<p class="text-sm">Organize your application into self-contained, reusable packages using enhanced Rails Engines.</p>
|
39
|
+
</a>
|
40
|
+
</div>
|
41
|
+
<div class="card">
|
42
|
+
<a href="./portal" class="block p-4">
|
43
|
+
<h3 class="font-bold">Portal Module</h3>
|
44
|
+
<p class="text-sm">Create distinct application interfaces for different user types while managing multi-tenancy and access control.</p>
|
45
|
+
</a>
|
46
|
+
</div>
|
47
|
+
<div class="card">
|
48
|
+
<a href="./authentication" class="block p-4">
|
49
|
+
<h3 class="font-bold">Authentication Module</h3>
|
50
|
+
<p class="text-sm">Secure, flexible authentication powered by Rodauth with support for multiple account types and strategies.</p>
|
51
|
+
</a>
|
52
|
+
</div>
|
53
|
+
<div class="card">
|
54
|
+
<a href="./configuration" class="block p-4">
|
55
|
+
<h3 class="font-bold">Configuration Module</h3>
|
56
|
+
<p class="text-sm">Centralized configuration management for customizing every aspect of your Plutonium application.</p>
|
57
|
+
</a>
|
58
|
+
</div>
|
59
|
+
</div>
|
60
|
+
|
61
|
+
## Business Logic Modules
|
62
|
+
The tools for defining your application's data structures, business rules, and operations.
|
63
|
+
|
64
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
65
|
+
<div class="card">
|
66
|
+
<a href="./resource_record" class="block p-4">
|
67
|
+
<h3 class="font-bold">Resource Record Module</h3>
|
68
|
+
<p class="text-sm">The heart of your application—define models, their behavior, and how they interact with the world.</p>
|
69
|
+
</a>
|
70
|
+
</div>
|
71
|
+
<div class="card">
|
72
|
+
<a href="./interaction" class="block p-4">
|
73
|
+
<h3 class="font-bold">Interaction Module</h3>
|
74
|
+
<p class="text-sm">Encapsulate complex business logic into clean, testable, and reusable service objects.</p>
|
75
|
+
</a>
|
76
|
+
</div>
|
77
|
+
<div class="card">
|
78
|
+
<a href="./action" class="block p-4">
|
79
|
+
<h3 class="font-bold">Action Module</h3>
|
80
|
+
<p class="text-sm">Define custom operations that users can perform on resources, with automatic UI generation and routing.</p>
|
81
|
+
</a>
|
82
|
+
</div>
|
83
|
+
<div class="card">
|
84
|
+
<a href="./query" class="block p-4">
|
85
|
+
<h3 class="font-bold">Query Module</h3>
|
86
|
+
<p class="text-sm">Powerful, declarative data querying with built-in filtering, searching, and sorting capabilities.</p>
|
87
|
+
</a>
|
88
|
+
</div>
|
89
|
+
<div class="card">
|
90
|
+
<a href="./policy" class="block p-4">
|
91
|
+
<h3 class="font-bold">Policy Module</h3>
|
92
|
+
<p class="text-sm">Comprehensive authorization and access control built on the robust Action Policy framework.</p>
|
93
|
+
</a>
|
94
|
+
</div>
|
95
|
+
</div>
|
96
|
+
|
97
|
+
## User Interface Modules
|
98
|
+
Everything you need to create beautiful, consistent, and functional user interfaces.
|
99
|
+
|
100
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
101
|
+
<div class="card">
|
102
|
+
<a href="./ui" class="block p-4">
|
103
|
+
<h3 class="font-bold">UI Module</h3>
|
104
|
+
<p class="text-sm">The foundation for all UI components, providing core rendering logic and display patterns.</p>
|
105
|
+
</a>
|
106
|
+
</div>
|
107
|
+
<div class="card">
|
108
|
+
<a href="./display" class="block p-4">
|
109
|
+
<h3 class="font-bold">Display Module</h3>
|
110
|
+
<p class="text-sm">Rich components for presenting data in various formats—from simple text to complex visualizations.</p>
|
111
|
+
</a>
|
112
|
+
</div>
|
113
|
+
<div class="card">
|
114
|
+
<a href="./form" class="block p-4">
|
115
|
+
<h3 class="font-bold">Form Module</h3>
|
116
|
+
<p class="text-sm">Powerful form builder with automatic field generation, validation handling, and complex input types.</p>
|
117
|
+
</a>
|
118
|
+
</div>
|
119
|
+
<div class="card">
|
120
|
+
<a href="./table" class="block p-4">
|
121
|
+
<h3 class="font-bold">Table Module</h3>
|
122
|
+
<p class="text-sm">Feature-rich data tables with sorting, filtering, pagination, and bulk operations out of the box.</p>
|
123
|
+
</a>
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
|
127
|
+
## Development & Tooling Modules
|
128
|
+
Accelerate your development workflow with powerful generators and utilities.
|
129
|
+
|
130
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
131
|
+
<div class="card">
|
132
|
+
<a href="./generator" class="block p-4">
|
133
|
+
<h3 class="font-bold">Generator Module</h3>
|
134
|
+
<p class="text-sm">Comprehensive code generators for scaffolding every component of your Plutonium application.</p>
|
135
|
+
</a>
|
136
|
+
</div>
|
137
|
+
<div class="card">
|
138
|
+
<a href="./helper" class="block p-4">
|
139
|
+
<h3 class="font-bold">Helper Module</h3>
|
140
|
+
<p class="text-sm">A rich collection of view helpers and utilities that simplify template development and UI creation.</p>
|
141
|
+
</a>
|
142
|
+
</div>
|
143
|
+
</div>
|
144
|
+
|
145
|
+
## Coming Soon
|
146
|
+
These modules are actively being developed and will be available in future releases.
|
147
|
+
|
148
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
149
|
+
<div class="card">
|
150
|
+
<div class="p-4">
|
151
|
+
<h3 class="font-bold">Testing Module <span class="text-xs font-mono text-gray-400">In Development</span></h3>
|
152
|
+
<p class="text-sm">Comprehensive testing utilities and patterns specifically designed for Plutonium applications.</p>
|
153
|
+
</div>
|
154
|
+
</div>
|
155
|
+
<div class="card">
|
156
|
+
<div class="p-4">
|
157
|
+
<h3 class="font-bold">Asset Module <span class="text-xs font-mono text-gray-400">In Development</span></h3>
|
158
|
+
<p class="text-sm">Advanced tools for managing assets, dependencies, and the modern JavaScript/CSS pipeline.</p>
|
159
|
+
</div>
|
160
|
+
</div>
|
161
|
+
<div class="card">
|
162
|
+
<div class="p-4">
|
163
|
+
<h3 class="font-bold">Theme Module <span class="text-xs font-mono text-gray-400">In Development</span></h3>
|
164
|
+
<p class="text-sm">A comprehensive theming system for deep customization of your application's look and feel.</p>
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
</div>
|