Add optional Tone field to Sites for AI content generation
- Add tone column to sites table (nullable string) - Add TONES constant to Site model with predefined options: professional, casual, technical, friendly, formal, humorous, conversational, authoritative, inspirational, educational, minimal, detailed - Update Sites Livewire component to edit tone - Update Sites view with tone select dropdown in form - Add tone column to sites table display - Add tone to SiteResource API response AI agents can now read the site's tone and use it when generating content. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -18,6 +18,7 @@ class SiteResource extends JsonResource
|
|||||||
'wp_username' => $this->wp_username,
|
'wp_username' => $this->wp_username,
|
||||||
'wp_app_password' => $this->wp_app_password,
|
'wp_app_password' => $this->wp_app_password,
|
||||||
'api_instructions' => $this->api_instructions,
|
'api_instructions' => $this->api_instructions,
|
||||||
|
'tone' => $this->tone,
|
||||||
'created_at' => $this->created_at,
|
'created_at' => $this->created_at,
|
||||||
'updated_at' => $this->updated_at,
|
'updated_at' => $this->updated_at,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -29,11 +29,14 @@ class Index extends Component
|
|||||||
|
|
||||||
public ?string $apiInstructions = null;
|
public ?string $apiInstructions = null;
|
||||||
|
|
||||||
|
public ?string $tone = null;
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.sites.index', [
|
return view('livewire.sites.index', [
|
||||||
'sites' => Site::orderBy('name')->get(),
|
'sites' => Site::orderBy('name')->get(),
|
||||||
'cmsTypes' => Site::CMS_TYPES,
|
'cmsTypes' => Site::CMS_TYPES,
|
||||||
|
'tones' => Site::TONES,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +57,7 @@ class Index extends Component
|
|||||||
$this->wpUsername = $site->wp_username ?? '';
|
$this->wpUsername = $site->wp_username ?? '';
|
||||||
$this->wpAppPassword = $site->wp_app_password ?? '';
|
$this->wpAppPassword = $site->wp_app_password ?? '';
|
||||||
$this->apiInstructions = $site->api_instructions;
|
$this->apiInstructions = $site->api_instructions;
|
||||||
|
$this->tone = $site->tone;
|
||||||
$this->showForm = true;
|
$this->showForm = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +71,7 @@ class Index extends Component
|
|||||||
'wpUsername' => ['required_if:cmsType,wordpress', 'nullable', 'string', 'max:255'],
|
'wpUsername' => ['required_if:cmsType,wordpress', 'nullable', 'string', 'max:255'],
|
||||||
'wpAppPassword' => ['required_if:cmsType,wordpress', 'nullable', 'string', 'max:255'],
|
'wpAppPassword' => ['required_if:cmsType,wordpress', 'nullable', 'string', 'max:255'],
|
||||||
'apiInstructions' => ['nullable', 'string'],
|
'apiInstructions' => ['nullable', 'string'],
|
||||||
|
'tone' => ['nullable', 'string'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Site::updateOrCreate(['id' => $this->editingId], [
|
Site::updateOrCreate(['id' => $this->editingId], [
|
||||||
@@ -77,6 +82,7 @@ class Index extends Component
|
|||||||
'wp_username' => $validated['cmsType'] === 'wordpress' ? $validated['wpUsername'] : null,
|
'wp_username' => $validated['cmsType'] === 'wordpress' ? $validated['wpUsername'] : null,
|
||||||
'wp_app_password' => $validated['cmsType'] === 'wordpress' ? $validated['wpAppPassword'] : null,
|
'wp_app_password' => $validated['cmsType'] === 'wordpress' ? $validated['wpAppPassword'] : null,
|
||||||
'api_instructions' => $validated['apiInstructions'],
|
'api_instructions' => $validated['apiInstructions'],
|
||||||
|
'tone' => $validated['tone'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->resetForm();
|
$this->resetForm();
|
||||||
@@ -103,6 +109,7 @@ class Index extends Component
|
|||||||
$this->wpUsername = '';
|
$this->wpUsername = '';
|
||||||
$this->wpAppPassword = '';
|
$this->wpAppPassword = '';
|
||||||
$this->apiInstructions = null;
|
$this->apiInstructions = null;
|
||||||
|
$this->tone = null;
|
||||||
$this->resetValidation();
|
$this->resetValidation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ class Site extends Model
|
|||||||
|
|
||||||
public const CMS_TYPES = ['wordpress', 'custom', 'other'];
|
public const CMS_TYPES = ['wordpress', 'custom', 'other'];
|
||||||
|
|
||||||
|
public const TONES = [
|
||||||
|
'professional', 'casual', 'technical', 'friendly',
|
||||||
|
'formal', 'humorous', 'conversational', 'authoritative',
|
||||||
|
'inspirational', 'educational', 'minimal', 'detailed',
|
||||||
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'url',
|
'url',
|
||||||
@@ -19,5 +25,6 @@ class Site extends Model
|
|||||||
'wp_username',
|
'wp_username',
|
||||||
'wp_app_password',
|
'wp_app_password',
|
||||||
'api_instructions',
|
'api_instructions',
|
||||||
|
'tone',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('sites', function (Blueprint $table) {
|
||||||
|
$table->string('tone')->nullable()->after('api_instructions');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('sites', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('tone');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
<th class="p-3">URL</th>
|
<th class="p-3">URL</th>
|
||||||
<th class="p-3">Description</th>
|
<th class="p-3">Description</th>
|
||||||
<th class="p-3">CMS Type</th>
|
<th class="p-3">CMS Type</th>
|
||||||
|
<th class="p-3">Tone</th>
|
||||||
<th class="p-3"></th>
|
<th class="p-3"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -38,6 +39,13 @@
|
|||||||
<div class="text-xs text-gray-500" title="{{ $site->api_instructions }}">Has API instructions</div>
|
<div class="text-xs text-gray-500" title="{{ $site->api_instructions }}">Has API instructions</div>
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
|
<td class="p-3">
|
||||||
|
@if ($site->tone)
|
||||||
|
<span class="text-xs bg-purple-100 text-purple-800 px-2 py-0.5 rounded">{{ $site->tone }}</span>
|
||||||
|
@else
|
||||||
|
<span class="text-gray-400">—</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
<td class="p-3 text-right space-x-2">
|
<td class="p-3 text-right space-x-2">
|
||||||
<button wire:click="edit({{ $site->id }})" class="text-blue-600">Edit</button>
|
<button wire:click="edit({{ $site->id }})" class="text-blue-600">Edit</button>
|
||||||
<button wire:click="delete({{ $site->id }})" wire:confirm="Delete this site?" class="text-red-600">Delete</button>
|
<button wire:click="delete({{ $site->id }})" wire:confirm="Delete this site?" class="text-red-600">Delete</button>
|
||||||
@@ -69,6 +77,20 @@
|
|||||||
<textarea wire:model="description" class="w-full border rounded p-2"></textarea>
|
<textarea wire:model="description" class="w-full border rounded p-2"></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium">Tone (optional for AI)</label>
|
||||||
|
<select wire:model="tone" class="w-full border rounded p-2">
|
||||||
|
<option value="">No tone specified</option>
|
||||||
|
@foreach ($tones as $t)
|
||||||
|
<option value="{{ $t }}">{{ ucfirst($t) }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
<p class="text-xs text-gray-500 mt-1">
|
||||||
|
Writing style for AI-generated content (e.g., professional, casual, technical).
|
||||||
|
</p>
|
||||||
|
@error('tone') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium">CMS Type</label>
|
<label class="block text-sm font-medium">CMS Type</label>
|
||||||
<select wire:model.live="cmsType" class="w-full border rounded p-2">
|
<select wire:model.live="cmsType" class="w-full border rounded p-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user