plutonium 0.33.0 → 0.34.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.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/# Plutonium: The pre-alpha demo.md +4 -2
  3. data/.claude/skills/assets/SKILL.md +416 -0
  4. data/.claude/skills/connect-resource/SKILL.md +112 -0
  5. data/.claude/skills/controller/SKILL.md +302 -0
  6. data/.claude/skills/create-resource/SKILL.md +240 -0
  7. data/.claude/skills/definition/SKILL.md +218 -0
  8. data/.claude/skills/definition-actions/SKILL.md +386 -0
  9. data/.claude/skills/definition-fields/SKILL.md +474 -0
  10. data/.claude/skills/definition-query/SKILL.md +334 -0
  11. data/.claude/skills/forms/SKILL.md +439 -0
  12. data/.claude/skills/installation/SKILL.md +300 -0
  13. data/.claude/skills/interaction/SKILL.md +382 -0
  14. data/.claude/skills/model/SKILL.md +267 -0
  15. data/.claude/skills/model-features/SKILL.md +286 -0
  16. data/.claude/skills/nested-resources/SKILL.md +274 -0
  17. data/.claude/skills/package/SKILL.md +191 -0
  18. data/.claude/skills/policy/SKILL.md +352 -0
  19. data/.claude/skills/portal/SKILL.md +400 -0
  20. data/.claude/skills/resource/SKILL.md +281 -0
  21. data/.claude/skills/rodauth/SKILL.md +452 -0
  22. data/.claude/skills/views/SKILL.md +563 -0
  23. data/Appraisals +46 -4
  24. data/CHANGELOG.md +36 -0
  25. data/app/assets/plutonium.css +2 -2
  26. data/config/brakeman.ignore +239 -0
  27. data/config/initializers/action_policy.rb +1 -1
  28. data/docs/.vitepress/config.ts +132 -47
  29. data/docs/concepts/architecture.md +226 -0
  30. data/docs/concepts/auto-detection.md +254 -0
  31. data/docs/concepts/index.md +61 -0
  32. data/docs/concepts/packages-portals.md +304 -0
  33. data/docs/concepts/resources.md +224 -0
  34. data/docs/cookbook/blog.md +412 -0
  35. data/docs/cookbook/index.md +289 -0
  36. data/docs/cookbook/saas.md +481 -0
  37. data/docs/getting-started/index.md +56 -0
  38. data/docs/getting-started/installation.md +146 -0
  39. data/docs/getting-started/tutorial/01-setup.md +118 -0
  40. data/docs/getting-started/tutorial/02-first-resource.md +180 -0
  41. data/docs/getting-started/tutorial/03-authentication.md +246 -0
  42. data/docs/getting-started/tutorial/04-authorization.md +170 -0
  43. data/docs/getting-started/tutorial/05-custom-actions.md +202 -0
  44. data/docs/getting-started/tutorial/06-nested-resources.md +147 -0
  45. data/docs/getting-started/tutorial/07-customizing-ui.md +254 -0
  46. data/docs/getting-started/tutorial/index.md +64 -0
  47. data/docs/guides/adding-resources.md +420 -0
  48. data/docs/guides/authentication.md +551 -0
  49. data/docs/guides/authorization.md +468 -0
  50. data/docs/guides/creating-packages.md +380 -0
  51. data/docs/guides/custom-actions.md +523 -0
  52. data/docs/guides/index.md +45 -0
  53. data/docs/guides/multi-tenancy.md +302 -0
  54. data/docs/guides/nested-resources.md +411 -0
  55. data/docs/guides/search-filtering.md +266 -0
  56. data/docs/guides/theming.md +321 -0
  57. data/docs/index.md +67 -26
  58. data/docs/public/CLAUDE.md +64 -21
  59. data/docs/reference/assets/index.md +496 -0
  60. data/docs/reference/controller/index.md +363 -0
  61. data/docs/reference/definition/actions.md +400 -0
  62. data/docs/reference/definition/fields.md +350 -0
  63. data/docs/reference/definition/index.md +252 -0
  64. data/docs/reference/definition/query.md +342 -0
  65. data/docs/reference/generators/index.md +469 -0
  66. data/docs/reference/index.md +49 -0
  67. data/docs/reference/interaction/index.md +445 -0
  68. data/docs/reference/model/features.md +248 -0
  69. data/docs/reference/model/index.md +219 -0
  70. data/docs/reference/policy/index.md +385 -0
  71. data/docs/reference/portal/index.md +382 -0
  72. data/docs/reference/views/forms.md +396 -0
  73. data/docs/reference/views/index.md +479 -0
  74. data/gemfiles/rails_7.gemfile +9 -2
  75. data/gemfiles/rails_7.gemfile.lock +146 -111
  76. data/gemfiles/rails_8.0.gemfile +20 -0
  77. data/gemfiles/rails_8.0.gemfile.lock +417 -0
  78. data/gemfiles/rails_8.1.gemfile +20 -0
  79. data/gemfiles/rails_8.1.gemfile.lock +419 -0
  80. data/lib/generators/pu/gem/dotenv/templates/.env +2 -0
  81. data/lib/generators/pu/gem/dotenv/templates/config/initializers/001_ensure_required_env.rb +3 -1
  82. data/lib/generators/pu/lib/plutonium_generators/model_generator_base.rb +13 -16
  83. data/lib/generators/pu/pkg/portal/USAGE +65 -0
  84. data/lib/generators/pu/pkg/portal/portal_generator.rb +22 -9
  85. data/lib/generators/pu/res/conn/USAGE +71 -0
  86. data/lib/generators/pu/res/model/USAGE +106 -110
  87. data/lib/generators/pu/res/model/templates/model.rb.tt +6 -2
  88. data/lib/generators/pu/res/scaffold/USAGE +85 -0
  89. data/lib/generators/pu/rodauth/install_generator.rb +2 -6
  90. data/lib/generators/pu/rodauth/templates/config/initializers/url_options.rb +17 -0
  91. data/lib/generators/pu/skills/sync/USAGE +14 -0
  92. data/lib/generators/pu/skills/sync/sync_generator.rb +66 -0
  93. data/lib/plutonium/action_policy/sti_policy_lookup.rb +1 -1
  94. data/lib/plutonium/core/controller.rb +2 -2
  95. data/lib/plutonium/interaction/base.rb +1 -0
  96. data/lib/plutonium/package/engine.rb +2 -2
  97. data/lib/plutonium/query/adhoc_block.rb +6 -2
  98. data/lib/plutonium/query/model_scope.rb +1 -1
  99. data/lib/plutonium/railtie.rb +4 -0
  100. data/lib/plutonium/resource/controllers/crud_actions/index_action.rb +1 -1
  101. data/lib/plutonium/resource/controllers/crud_actions.rb +21 -18
  102. data/lib/plutonium/resource/controllers/interactive_actions.rb +21 -25
  103. data/lib/plutonium/resource/query_object.rb +38 -8
  104. data/lib/plutonium/ui/table/components/scopes_bar.rb +39 -34
  105. data/lib/plutonium/version.rb +1 -1
  106. data/lib/tasks/release.rake +19 -4
  107. data/package.json +1 -1
  108. metadata +76 -39
  109. data/brakeman.ignore +0 -28
  110. data/docs/api-examples.md +0 -49
  111. data/docs/guide/claude-code-guide.md +0 -74
  112. data/docs/guide/deep-dive/authorization.md +0 -189
  113. data/docs/guide/deep-dive/multitenancy.md +0 -256
  114. data/docs/guide/deep-dive/resources.md +0 -390
  115. data/docs/guide/getting-started/01-installation.md +0 -165
  116. data/docs/guide/index.md +0 -28
  117. data/docs/guide/introduction/01-what-is-plutonium.md +0 -211
  118. data/docs/guide/introduction/02-core-concepts.md +0 -440
  119. data/docs/guide/tutorial/01-project-setup.md +0 -75
  120. data/docs/guide/tutorial/02-creating-a-feature-package.md +0 -45
  121. data/docs/guide/tutorial/03-defining-resources.md +0 -90
  122. data/docs/guide/tutorial/04-creating-a-portal.md +0 -101
  123. data/docs/guide/tutorial/05-customizing-the-ui.md +0 -128
  124. data/docs/guide/tutorial/06-adding-custom-actions.md +0 -101
  125. data/docs/guide/tutorial/07-implementing-authorization.md +0 -90
  126. data/docs/markdown-examples.md +0 -85
  127. data/docs/modules/action.md +0 -244
  128. data/docs/modules/authentication.md +0 -236
  129. data/docs/modules/configuration.md +0 -599
  130. data/docs/modules/controller.md +0 -443
  131. data/docs/modules/core.md +0 -316
  132. data/docs/modules/definition.md +0 -1308
  133. data/docs/modules/display.md +0 -759
  134. data/docs/modules/form.md +0 -495
  135. data/docs/modules/generator.md +0 -400
  136. data/docs/modules/index.md +0 -167
  137. data/docs/modules/interaction.md +0 -642
  138. data/docs/modules/package.md +0 -151
  139. data/docs/modules/policy.md +0 -176
  140. data/docs/modules/portal.md +0 -710
  141. data/docs/modules/query.md +0 -297
  142. data/docs/modules/resource_record.md +0 -618
  143. data/docs/modules/routing.md +0 -690
  144. data/docs/modules/table.md +0 -301
  145. data/docs/modules/ui.md +0 -631
data/docs/modules/core.md DELETED
@@ -1,316 +0,0 @@
1
- ---
2
- title: Core Module
3
- ---
4
-
5
- # Core Module
6
-
7
- The Core module (`Plutonium::Core::Controller`) provides the foundational controller functionality that all Plutonium applications depend on. It's a lean, focused module that handles essential framework integration, URL generation, and controller bootstrapping.
8
-
9
- ::: tip
10
- The Core module is automatically included when you use `Plutonium::Resource::Controller` or `Plutonium::Portal::Controller`. You typically don't include it directly.
11
- :::
12
-
13
- ## What the Core Module Provides
14
-
15
- The Core module includes three essential controller concerns:
16
-
17
- - **Bootable**: Package and engine detection with automatic view path configuration
18
- - **EntityScoping**: Multi-tenancy support with entity-based scoping
19
- - **Authorizable**: ActionPolicy integration for authorization
20
-
21
- ## Core Controller Features
22
-
23
- ### Smart URL Generation
24
-
25
- The Core module provides intelligent URL generation that works with Plutonium's package system and entity scoping:
26
-
27
- ```ruby
28
- # Generate URLs for resources with proper routing context
29
- resource_url_for(@user) # => "/users/1"
30
- resource_url_for(@user, action: :edit) # => "/users/1/edit"
31
- resource_url_for(User) # => "/users"
32
-
33
- # Handle nested resources and packages
34
- resource_url_for(@user, Post) # => "/users/1/posts"
35
- resource_url_for(@post, parent: @user) # => "/users/1/posts/1"
36
-
37
- # Build URL arguments for complex routing scenarios
38
- args = resource_url_args_for(@user, Post)
39
- # => {controller: "/users/posts", user_id: 1}
40
- ```
41
-
42
- ### Enhanced Flash Messages
43
-
44
- Extends Rails' default flash types with additional semantic types:
45
-
46
- ```ruby
47
- # Available flash types: :notice, :alert, :success, :warning, :error
48
- redirect_to posts_path, success: "Post created successfully!"
49
- redirect_to posts_path, warning: "Post saved with warnings"
50
- redirect_to posts_path, error: "Failed to save post"
51
- ```
52
-
53
- ### Helper Methods
54
-
55
- The Core module provides several helper methods available in controllers and views:
56
-
57
- ```ruby
58
- # Page title management
59
- set_page_title("Dashboard")
60
- make_page_title("Users") # => "Users | App Name"
61
-
62
- # Package and engine information
63
- current_package # => AdminPortal (if in a package)
64
- current_engine # => AdminPortal::Engine
65
-
66
- # Resource registry access
67
- registered_resources # => Array of registered resource classes
68
-
69
- # Application branding
70
- app_name # => Your application name
71
- ```
72
-
73
- ## Package Integration (Bootable)
74
-
75
- The Bootable concern automatically detects which package and engine a controller belongs to:
76
-
77
- ```ruby
78
- # In packages/admin_portal/app/controllers/users_controller.rb
79
- class UsersController < ResourceController
80
- # Automatically detects:
81
- # current_package => AdminPortal
82
- # current_engine => AdminPortal::Engine
83
-
84
- # View paths automatically configured:
85
- # - packages/admin_portal/app/views (prepended)
86
- # - app/views (Rails default)
87
- end
88
- ```
89
-
90
- ### Automatic View Path Configuration
91
-
92
- Each package gets its own view path automatically prepended:
93
-
94
- ```ruby
95
- # For AdminPortal::UsersController
96
- # View lookup order:
97
- # 1. packages/admin_portal/app/views/users/
98
- # 2. packages/admin_portal/app/views/
99
- # 3. app/views/users/
100
- # 4. app/views/
101
- ```
102
-
103
- ## Entity Scoping (Multi-tenancy)
104
-
105
- The EntityScoping concern provides multi-tenancy support when configured:
106
-
107
- ```ruby
108
- # In your engine configuration
109
- class AdminPortal::Engine < Rails::Engine
110
- include Plutonium::Portal
111
-
112
- # Enable entity scoping
113
- scope_to_entity Organization, strategy: :path
114
- end
115
- ```
116
-
117
- ### Available Scoping Methods
118
-
119
- When entity scoping is enabled:
120
-
121
- ```ruby
122
- # Check if scoped to an entity
123
- scoped_to_entity? # => true/false
124
-
125
- # Get current scoped entity
126
- current_scoped_entity # => #<Organization id: 1>
127
-
128
- # Get scoping configuration
129
- scoped_entity_strategy # => :path
130
- scoped_entity_param_key # => :organization_id
131
- scoped_entity_class # => Organization
132
- ```
133
-
134
- ### Entity Scoping Strategies
135
-
136
- **Path Strategy** (most common):
137
- ```ruby
138
- # URLs include entity parameter: /organizations/1/users
139
- scope_to_entity Organization, strategy: :path
140
- ```
141
-
142
- **Custom Strategy**:
143
- ```ruby
144
- # Define your own scoping method
145
- scope_to_entity Organization, strategy: :current_organization
146
-
147
- private
148
-
149
- def current_organization
150
- current_user.organization
151
- end
152
- ```
153
-
154
- ## Authorization Integration (Authorizable)
155
-
156
- The Authorizable concern integrates ActionPolicy for authorization:
157
-
158
- ```ruby
159
- # Authorization is automatically configured with:
160
- authorize :user, through: :current_user
161
- authorize :entity_scope, through: :entity_scope_for_authorize
162
-
163
- # Helper methods available:
164
- policy_for(@user) # Get policy for record
165
- authorized_resource_scope(User) # Get authorized scope
166
- ```
167
-
168
- ### Authorization Context
169
-
170
- The Core module provides entity scoping context for authorization:
171
-
172
- ```ruby
173
- # In your policies, you can access:
174
- class UserPolicy < ApplicationPolicy
175
- def index?
176
- # entity_scope is automatically available
177
- user.admin? || entity_scope == user.organization
178
- end
179
- end
180
- ```
181
-
182
- ## Framework Integration
183
-
184
- ### ActiveStorage Integration
185
-
186
- Automatically configures ActiveStorage URL options:
187
-
188
- ```ruby
189
- # Configured in before_action
190
- ActiveStorage::Current.url_options = {
191
- protocol: request.protocol,
192
- host: request.host,
193
- port: request.port
194
- }
195
- ```
196
-
197
- ### Layout Configuration
198
-
199
- Sets up dynamic layout selection:
200
-
201
- ```ruby
202
- # Automatically uses 'resource' layout unless in Turbo Frame
203
- layout -> { turbo_frame_request? ? false : "resource" }
204
- ```
205
-
206
- ### Helper Integration
207
-
208
- Includes all Plutonium helpers:
209
-
210
- ```ruby
211
- helper Plutonium::Helpers
212
- # Includes: ApplicationHelper, AttachmentHelper, ContentHelper,
213
- # DisplayHelper, TableHelper, TurboHelper, etc.
214
- ```
215
-
216
- ## Usage Patterns
217
-
218
- ### Basic Controller Setup
219
-
220
- The Core module is typically used through other Plutonium modules:
221
-
222
- ```ruby
223
- # For resource controllers
224
- class UsersController < ResourceController
225
- include Plutonium::Resource::Controller
226
- # Core module included automatically
227
- end
228
-
229
- # For portal controllers
230
- class DashboardController < ResourceController
231
- include Plutonium::Portal::Controller
232
- # Core module included automatically
233
- end
234
- ```
235
-
236
- ### Direct Usage (Advanced)
237
-
238
- If you need just the core functionality:
239
-
240
- ```ruby
241
- class CustomController < ApplicationController
242
- include Plutonium::Core::Controller
243
-
244
- def index
245
- set_page_title("Custom Page")
246
- # Core functionality available
247
- end
248
- end
249
- ```
250
-
251
- ## Configuration
252
-
253
- The Core module respects Plutonium's main configuration:
254
-
255
- ```ruby
256
- # config/initializers/plutonium.rb
257
- Plutonium.configure do |config|
258
- config.load_defaults 1.0
259
-
260
- # These affect Core module behavior:
261
- config.development = Rails.env.development?
262
- config.cache_discovery = !Rails.env.development?
263
- end
264
- ```
265
-
266
- ## Best Practices
267
-
268
- ### URL Generation
269
-
270
- Always use `resource_url_for` instead of Rails' `url_for` for Plutonium resources:
271
-
272
- ```ruby
273
- # ✅ Good - respects packages and entity scoping
274
- resource_url_for(@user)
275
-
276
- # ❌ Avoid - doesn't understand Plutonium routing
277
- user_url(@user)
278
- ```
279
-
280
- ### Page Titles
281
-
282
- Set page titles in controller actions for consistent branding:
283
-
284
- ```ruby
285
- def show
286
- set_page_title(resource_record!.to_label)
287
- # Automatically becomes "User Name | App Name"
288
- end
289
- ```
290
-
291
- ### Package Organization
292
-
293
- Let the Bootable concern handle package detection automatically:
294
-
295
- ```ruby
296
- # ✅ Good - automatic detection
297
- class AdminPortal::UsersController < ResourceController
298
- # Package and engine automatically detected
299
- end
300
-
301
- # ❌ Avoid - manual configuration
302
- class UsersController < ResourceController
303
- def current_package
304
- AdminPortal # Don't override unless necessary
305
- end
306
- end
307
- ```
308
-
309
- ## Integration with Other Modules
310
-
311
- - **[Resource Record](./resource_record.md)** - Builds on Core for full CRUD functionality
312
- - **[Portal](./portal.md)** - Uses Core for multi-tenant portal applications
313
- - **[Routing](./routing.md)** - Works with Core's URL generation methods
314
- - **[Authorization](/guide/deep-dive/authorization.md)** - Integrates with Core's authorization system
315
-
316
- The Core module provides a solid, focused foundation that other Plutonium modules build upon, handling the essential plumbing that makes the framework's conventions work seamlessly.