plutonium 0.26.8 → 0.26.9
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/config/initializers/sqlite_alias.rb +3 -2
- data/docs/.vitepress/config.ts +1 -1
- data/docs/guide/{cursor-rules.md → claude-code-guide.md} +14 -15
- data/docs/guide/tutorial/01-project-setup.md +1 -1
- data/docs/guide/tutorial/04-creating-a-portal.md +1 -1
- data/docs/modules/controller.md +45 -0
- data/docs/modules/interaction.md +2 -2
- data/docs/public/CLAUDE.md +535 -0
- data/lib/plutonium/core/controller.rb +2 -0
- data/lib/plutonium/interaction/README.md +1 -1
- data/lib/plutonium/resource/controllers/crud_actions.rb +7 -7
- data/lib/plutonium/resource/controllers/interactive_actions.rb +8 -8
- data/lib/plutonium/version.rb +1 -1
- metadata +4 -4
- data/docs/public/plutonium.mdc +0 -565
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 798edf56262b9bfe08213c2871fa4fbf9e3efd49e88f6e803264daa700705af1
|
4
|
+
data.tar.gz: ebd25511c19d82df27c126e3aac448d33c6470d9e27574d9f6e94b76b74b97e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33ef3085ddf812ba77df3e5fb8b9ba5e9e912d7a1577c66bd6c23627526d745e640bb30ff3c64bc83d07820035f7b36839db1dbe85822a08e02bcb976980e0ae
|
7
|
+
data.tar.gz: d0fd12b7b9e4e3a45942cccd5de1cb1ded0217837d364028f3b4453bdf2af383ce4a68e507491601525cbbf7c25fe99a0541afdba7dfd9dd9e6603b6f9c5cfe7
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# Alias json to jsonb in SQLite migrations
|
2
|
-
ActiveSupport.on_load(:active_record) do
|
3
|
-
next unless ActiveRecord::Base.connection.adapter_name.downcase.include?("sqlite")
|
4
2
|
|
3
|
+
return unless defined?(ActiveRecord::ConnectionAdapters::SQLite3)
|
4
|
+
|
5
|
+
ActiveSupport.on_load(:active_record) do
|
5
6
|
ActiveRecord::ConnectionAdapters::SQLite3::TableDefinition.class_eval do
|
6
7
|
def jsonb(*args, **options)
|
7
8
|
json(*args, **options)
|
data/docs/.vitepress/config.ts
CHANGED
@@ -1,48 +1,47 @@
|
|
1
1
|
---
|
2
|
-
title:
|
2
|
+
title: Claude Code Guide for Plutonium Development
|
3
3
|
---
|
4
4
|
|
5
5
|
<script setup>
|
6
6
|
import { withBase } from 'vitepress'
|
7
7
|
</script>
|
8
8
|
|
9
|
-
#
|
9
|
+
# Claude Code Guide for Plutonium Development
|
10
10
|
|
11
|
-
This page provides comprehensive
|
11
|
+
This page provides comprehensive development guidance for building Plutonium applications effectively. This guide is designed to help AI assistants and developers understand the framework's patterns and best practices.
|
12
12
|
|
13
13
|
## Quick Start
|
14
14
|
|
15
|
-
**Download the
|
15
|
+
**Download the CLAUDE.md File**: <a :href="withBase('/CLAUDE.md')" target="_blank">📄 CLAUDE.md</a>
|
16
16
|
|
17
17
|
**Or download directly from your terminal**:
|
18
18
|
|
19
19
|
::: code-group
|
20
20
|
|
21
21
|
```bash [Unix/Linux/macOS/WSL]
|
22
|
-
|
22
|
+
curl -o CLAUDE.md https://radioactive-labs.github.io/plutonium-core/CLAUDE.md
|
23
23
|
```
|
24
24
|
|
25
25
|
```cmd [Windows]
|
26
|
-
|
26
|
+
curl -o CLAUDE.md https://radioactive-labs.github.io/plutonium-core/CLAUDE.md
|
27
27
|
```
|
28
28
|
|
29
29
|
:::
|
30
30
|
|
31
|
-
## Using
|
31
|
+
## Using This Guide
|
32
32
|
|
33
|
-
|
33
|
+
Claude Code uses CLAUDE.md files for project-specific context:
|
34
34
|
|
35
|
-
1. **Download the
|
36
|
-
2. **
|
37
|
-
3. **
|
38
|
-
4. **
|
39
|
-
5. The rule will be saved as `.cursor/rules/plutonium.mdc`
|
35
|
+
1. **Download the guide**: Right-click the link above and "Save As" to download the `CLAUDE.md` file
|
36
|
+
2. **Place in your project root** as `CLAUDE.md`
|
37
|
+
3. **Claude Code automatically loads** this file for project context
|
38
|
+
4. **Enhance with your own instructions** by adding project-specific details
|
40
39
|
|
41
|
-
|
40
|
+
The guide provides comprehensive patterns and examples for building Plutonium applications with AI assistance.
|
42
41
|
|
43
42
|
## What's Included
|
44
43
|
|
45
|
-
The
|
44
|
+
The CLAUDE.md guide contains comprehensive guidelines for:
|
46
45
|
|
47
46
|
### 🏗️ **Framework Architecture**
|
48
47
|
- Resource-oriented development patterns
|
@@ -63,7 +63,7 @@ plutonium_blog/
|
|
63
63
|
Let's boot up the Rails server to make sure everything is working correctly.
|
64
64
|
|
65
65
|
```bash
|
66
|
-
|
66
|
+
bin/dev
|
67
67
|
```
|
68
68
|
|
69
69
|
Open your web browser and navigate to [http://localhost:3000](http://localhost:3000). You should see the default Rails welcome page.
|
@@ -85,7 +85,7 @@ There's one last step. We need to tell our main Rails application how to handle
|
|
85
85
|
|
86
86
|
## See it in Action!
|
87
87
|
|
88
|
-
Let's check our progress. Start your Rails server (`
|
88
|
+
Let's check our progress. Start your Rails server (`bin/dev`) and navigate to [http://localhost:3000](http://localhost:3000).
|
89
89
|
|
90
90
|
You will be redirected to `/dashboard` and should see the login page.
|
91
91
|
|
data/docs/modules/controller.md
CHANGED
@@ -120,6 +120,7 @@ end
|
|
120
120
|
- **Enhanced Flash Messages**: Extended message types (`:success`, `:warning`, `:error`)
|
121
121
|
- **View Integration**: Automatic view path resolution and layout management
|
122
122
|
- **Resource Management**: Access to registered resources and metadata
|
123
|
+
- **CSRF Protection**: Automatic CSRF protection with smart handling for API requests
|
123
124
|
|
124
125
|
**Essential Methods:**
|
125
126
|
```ruby
|
@@ -385,6 +386,50 @@ resource_url_for(Post, parent: @user) # => "/users/123/nested_posts"
|
|
385
386
|
Plutonium automatically handles different response formats for you.
|
386
387
|
It currently supports HTML, JSON, and Turbo Streams.
|
387
388
|
|
389
|
+
### CSRF Protection
|
390
|
+
|
391
|
+
Plutonium provides intelligent CSRF (Cross-Site Request Forgery) protection that automatically adapts to different request types:
|
392
|
+
|
393
|
+
```ruby
|
394
|
+
# Automatically configured in Plutonium::Core::Controller
|
395
|
+
protect_from_forgery with: :null_session, if: -> { request.headers['Authorization'].present? }
|
396
|
+
```
|
397
|
+
|
398
|
+
**How It Works:**
|
399
|
+
- **Session-based requests** (typical web forms, SPA AJAX calls): Full CSRF protection is enforced
|
400
|
+
- **Token-based requests** (API calls with Authorization headers): CSRF protection is skipped using `:null_session`
|
401
|
+
|
402
|
+
**Security Benefits:**
|
403
|
+
- SPAs using session cookies remain protected against CSRF attacks
|
404
|
+
- API clients using Bearer tokens, Basic auth, or other Authorization headers bypass CSRF (as intended)
|
405
|
+
- No configuration needed - works automatically based on request characteristics
|
406
|
+
|
407
|
+
**Authorization Header Examples:**
|
408
|
+
```http
|
409
|
+
# These requests will skip CSRF protection:
|
410
|
+
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...
|
411
|
+
Authorization: Basic dXNlcjpwYXNzd29yZA==
|
412
|
+
Authorization: ApiKey abc123
|
413
|
+
```
|
414
|
+
|
415
|
+
**For SPA Development:**
|
416
|
+
If your SPA uses session-based authentication, include CSRF tokens in your AJAX requests:
|
417
|
+
|
418
|
+
```javascript
|
419
|
+
// Include CSRF token in meta tags
|
420
|
+
<%= csrf_meta_tags %>
|
421
|
+
|
422
|
+
// Send token in AJAX requests
|
423
|
+
fetch('/api/posts', {
|
424
|
+
method: 'POST',
|
425
|
+
headers: {
|
426
|
+
'Content-Type': 'application/json',
|
427
|
+
'X-CSRF-Token': document.querySelector('[name="csrf-token"]').content
|
428
|
+
},
|
429
|
+
body: JSON.stringify(data)
|
430
|
+
})
|
431
|
+
```
|
432
|
+
|
388
433
|
## Related Modules
|
389
434
|
|
390
435
|
The Controller module works seamlessly with other Plutonium components:
|
data/docs/modules/interaction.md
CHANGED
@@ -119,7 +119,7 @@ Handles controller responses after successful interactions.
|
|
119
119
|
**Render Response**
|
120
120
|
```ruby
|
121
121
|
.with_render_response(:show, locals: { user: user })
|
122
|
-
.with_render_response(:edit, status: :
|
122
|
+
.with_render_response(:edit, status: :unprocessable_content)
|
123
123
|
```
|
124
124
|
|
125
125
|
**File Response**
|
@@ -147,7 +147,7 @@ class ApplicationController < ActionController::Base
|
|
147
147
|
end
|
148
148
|
else
|
149
149
|
outcome.messages.each { |msg, type| flash.now[type || :error] = msg }
|
150
|
-
render json: { errors: outcome.errors }, status: :
|
150
|
+
render json: { errors: outcome.errors }, status: :unprocessable_content
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|