Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ database:
use_dns_when_possible: true
composer_version: "2"
web_environment: []
web_extra_exposed_ports:
- name: vite
container_port: 5173
http_port: 5172
https_port: 5173
corepack_enable: false
web_extra_exposed_ports:
- name: vite
container_port: 5173
http_port: 5172
https_port: 5173

# Key features of DDEV's config.yaml:

Expand Down
4 changes: 3 additions & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

abstract class Controller
{
//
use AuthorizesRequests;
}
9 changes: 8 additions & 1 deletion app/Http/Controllers/ScanController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Actions\CreateScanAction;
use App\Http\Requests\Scan\StoreScanRequest;
use App\Http\Resources\ScanDetailsResource;
use App\Http\Resources\ScanOverviewResource;
use App\Jobs\ProcessScanJob;
use App\Models\Scan;
Expand Down Expand Up @@ -59,8 +60,14 @@ public function store(StoreScanRequest $request, CreateScanAction $action): Redi

public function show(Scan $scan): Response
{
$this->authorize('view', $scan);

return Inertia::render('scans/show', [
'scan' => $scan,
'scan' => ScanDetailsResource::make($scan),
'breadcrumbs' => [
['title' => 'Scans', 'href' => route('scans.index')],
['title' => 'Scan Results', 'href' => route('scans.show', ['scan' => $scan])],
],
]);
}

Expand Down
47 changes: 47 additions & 0 deletions app/Http/Resources/ScanDetailsResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace App\Http\Resources;

use App\Models\Scan;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/**
* @mixin Scan
*/
class ScanDetailsResource extends JsonResource
{
public static $wrap;

/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'uuid' => $this->getUuid(),
'url' => $this->url,
'status' => $this->status,
'createdAt' => $this->created_at,
'scores' => [
'clarity' => $this->clarity_score,
'consistency' => $this->consistency_score,
'seo' => $this->seo_score,
'tone' => $this->tone_score,
],
'analysis' => [
'clarity' => $this->clarity_analysis,
'consistency' => $this->consistency_analysis,
'seo' => $this->seo_analysis,
'tone' => $this->tone_analysis,
],
'suggestions' => [
'headlines' => $this->suggested_headlines ?? [],
'ctas' => $this->suggested_ctas ?? [],
'hierarchy' => $this->suggested_content_hierarchy ?? [],
],
];
}
}
16 changes: 16 additions & 0 deletions app/Policies/ScanPolicy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\Scan;
use App\Models\User;

class ScanPolicy
{
public function view(User $user, Scan $scan): bool
{
return $scan->user_id === $user->getKey();
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"spatie/browsershot": "^5.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.16",
"driftingly/rector-laravel": "^2.0",
"fakerphp/faker": "^1.23",
"larastan/larastan": "^3.7",
Expand Down
160 changes: 159 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions resources/js/components/heading.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { cn } from '@/lib/utils';

interface HeadingProps {
title: string;
description?: string;
level?: 'h1' | 'h2';
containerClasses?: string;
}

export default function Heading({ title, description, level = 'h2' }: HeadingProps) {
export default function Heading({ title, description, level = 'h2', containerClasses = 'mb-4' }: HeadingProps) {
return (
<div className="mb-8 space-y-0.5">
<div className={cn('space-y-0.5', containerClasses)}>
{level === 'h1' ? (
<h1 className="text-2xl font-bold tracking-tight">{title}</h1>
) : (
Expand Down
26 changes: 26 additions & 0 deletions resources/js/pages/scans/partials/CTASuggestions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
interface CTASuggestionsProps {
ctas: string[];
}

export default function CTASuggestions({ ctas }: CTASuggestionsProps) {
return (
<div className="space-y-4">
<h4 className="text-sm font-medium">CTA Suggestions</h4>

{ctas.length > 0 && (
<ul className="list-disc space-y-4 pl-6">
{ctas.map((cta, index) => (
<li
key={`cta-${index}`}
className="text-muted-foreground"
>
{cta}
</li>
))}
</ul>
)}

{ctas.length === 0 && <p className="text-muted-foreground">No CTA suggestions were provided.</p>}
</div>
);
}
26 changes: 26 additions & 0 deletions resources/js/pages/scans/partials/HeadlineSuggestions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
interface HeadlineSuggestionsProps {
headlines: string[];
}

export default function HeadlineSuggestions({ headlines }: HeadlineSuggestionsProps) {
return (
<div className="space-y-4">
<h4 className="text-sm font-medium">Headline Suggestions</h4>

{headlines.length > 0 && (
<ul className="list-disc space-y-4 pl-6">
{headlines.map((headline, index) => (
<li
key={`headline-${index}`}
className="text-muted-foreground"
>
{headline}
</li>
))}
</ul>
)}

{headlines.length === 0 && <p className="text-muted-foreground">No headline suggestions were provided.</p>}
</div>
);
}
Loading
Loading