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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f500aadbdb233a0f38e68d3ce8d0ae90e6a27b68a5d63a5d96265cbaf82de602
4
- data.tar.gz: d06ee6233d99cdcb0fa02bf413ec433f9a2820e694df1016c588e420e73860ff
3
+ metadata.gz: 798edf56262b9bfe08213c2871fa4fbf9e3efd49e88f6e803264daa700705af1
4
+ data.tar.gz: ebd25511c19d82df27c126e3aac448d33c6470d9e27574d9f6e94b76b74b97e1
5
5
  SHA512:
6
- metadata.gz: 586131a1db61db7ec366d92d8f4c7bca6ccdfb17de6a022b6bb4157455a34e3f386f7c08eda31817dd6bb40bf12e2730dc45c7751df9229cfe785e40f6877406
7
- data.tar.gz: 34b979b70fefb200982490c8f41df44dcd8f0b6804b63c4f691784ec6099a0b4c0b1446c3178512d0a57777ec9c4db8fd7031d0a15861d8f889e5d598343fa1f
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)
@@ -63,7 +63,7 @@ export default defineConfig(withMermaid({
63
63
  {
64
64
  text: "Developer Tools",
65
65
  items: [
66
- { text: "Cursor Rules", link: "/guide/cursor-rules" },
66
+ { text: "Claude Code Guide", link: "/guide/claude-code-guide" },
67
67
  ]
68
68
  }
69
69
  ],
@@ -1,48 +1,47 @@
1
1
  ---
2
- title: Cursor Rules for Plutonium Development
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
- # Cursor Rules for Plutonium Development
9
+ # Claude Code Guide for Plutonium Development
10
10
 
11
- This page provides comprehensive cursor rules for building Plutonium applications effectively. These rules are designed to help AI assistants and developers understand the framework's patterns and best practices.
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 Rules File**: <a :href="withBase('/plutonium.mdc')" target="_blank">📄 plutonium.mdc</a>
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
- mkdir -p .cursor/rules && curl -o .cursor/rules/plutonium.mdc https://radioactive-labs.github.io/plutonium-core/plutonium.mdc
22
+ curl -o CLAUDE.md https://radioactive-labs.github.io/plutonium-core/CLAUDE.md
23
23
  ```
24
24
 
25
25
  ```cmd [Windows]
26
- mkdir .cursor\rules 2>nul & curl -o .cursor\rules\plutonium.mdc https://radioactive-labs.github.io/plutonium-core/plutonium.mdc
26
+ curl -o CLAUDE.md https://radioactive-labs.github.io/plutonium-core/CLAUDE.md
27
27
  ```
28
28
 
29
29
  :::
30
30
 
31
- ## Using These Rules
31
+ ## Using This Guide
32
32
 
33
- Cursor uses Project Rules stored in `.cursor/rules/` directory:
33
+ Claude Code uses CLAUDE.md files for project-specific context:
34
34
 
35
- 1. **Download the rules file**: Right-click the link above and "Save As" to download the `.plutonium.mdc` file
36
- 2. **Open Cursor Settings** Rules Project Rules
37
- 3. **Click "Add new rule"** and give it a name (e.g., "plutonium")
38
- 4. **Copy the downloaded content** into the new rule file
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
- **Legacy Method**: You can also place the downloaded `.plutonium.mdc` file in your project root, but this method is deprecated.
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 cursor rules file contains comprehensive guidelines for:
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
- rails server
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 (`rails s`) and navigate to [http://localhost:3000](http://localhost:3000).
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
 
@@ -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:
@@ -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: :unprocessable_entity)
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: :unprocessable_entity
150
+ render json: { errors: outcome.errors }, status: :unprocessable_content
151
151
  end
152
152
  end
153
153
  end