Implement creator studio and upload updates

This commit is contained in:
2026-04-04 10:12:02 +02:00
parent 1da7d3bf88
commit 0b216b7ecd
15107 changed files with 31206 additions and 626514 deletions

View File

@@ -18,6 +18,7 @@ class ArtworkResource extends JsonResource
$lg = ThumbnailPresenter::present($this->resource, 'lg');
$xl = ThumbnailPresenter::present($this->resource, 'xl');
$sq = ThumbnailPresenter::present($this->resource, 'sq');
$screenshots = $this->resolveScreenshotAssets();
$canonicalSlug = \Illuminate\Support\Str::slug((string) ($this->slug ?: $this->title));
if ($canonicalSlug === '') {
@@ -119,6 +120,7 @@ class ArtworkResource extends JsonResource
'srcset' => ThumbnailPresenter::srcsetForArtwork($this->resource),
'mime_type' => 'image/webp',
],
'screenshots' => $screenshots,
'user' => [
'id' => (int) ($this->user?->id ?? 0),
'name' => html_entity_decode((string) ($this->user?->name ?? ''), ENT_QUOTES | ENT_HTML5, 'UTF-8'),
@@ -173,6 +175,48 @@ class ArtworkResource extends JsonResource
];
}
private function resolveScreenshotAssets(): array
{
if (! Schema::hasTable('artwork_files')) {
return [];
}
return DB::table('artwork_files')
->where('artwork_id', (int) $this->id)
->where('variant', 'like', 'shot%')
->orderBy('variant')
->get(['variant', 'path', 'mime', 'size'])
->map(function ($row, int $index): array {
$path = (string) ($row->path ?? '');
$url = $this->objectUrl($path);
return [
'id' => (string) ($row->variant ?? ('shot' . ($index + 1))),
'variant' => (string) ($row->variant ?? ''),
'label' => 'Screenshot ' . ($index + 1),
'url' => $url,
'thumb_url' => $url,
'mime_type' => (string) ($row->mime ?? 'image/jpeg'),
'size' => (int) ($row->size ?? 0),
];
})
->filter(fn (array $item): bool => $item['url'] !== null)
->values()
->all();
}
private function objectUrl(string $path): ?string
{
$trimmedPath = trim($path, '/');
if ($trimmedPath === '') {
return null;
}
$base = rtrim((string) config('cdn.files_url', 'https://files.skinbase.org'), '/');
return $base . '/' . $trimmedPath;
}
private function renderDescriptionHtml(): string
{
$rawDescription = (string) ($this->description ?? '');