Files
SkinbaseNova/resources/views/forum/thread/show.blade.php
Gregor Klevze dc51d65440 feat: forum rich-text editor, emoji picker, mentions, discover nav, feed, uploads, profile
Forum:
- TipTap WYSIWYG editor with full toolbar
- @emoji-mart/react emoji picker (consistent with tweets)
- @mention autocomplete with user search API
- Fix PHP 8.4 parse errors in Blade templates
- Fix thread data display (paginator items)
- Align forum page widths to max-w-5xl

Discover:
- Extract shared _nav.blade.php partial
- Add missing nav links to for-you page
- Add Following link for authenticated users

Feed/Posts:
- Post model, controllers, policies, migrations
- Feed page components (PostComposer, FeedCard, etc)
- Post reactions, comments, saves, reports, sharing
- Scheduled publishing support
- Link preview controller

Profile:
- Profile page components (ProfileHero, ProfileTabs)
- Profile API controller

Uploads:
- Upload wizard enhancements
- Scheduled publish picker
- Studio status bar and readiness checklist
2026-03-03 09:48:31 +01:00

86 lines
3.6 KiB
PHP

@extends('layouts.nova')
@php
use App\Support\ForumPostContent;
use App\Support\AvatarUrl;
use Illuminate\Support\Facades\Gate;
$filesBaseUrl = rtrim((string) config('cdn.files_url', ''), '/');
$serializePost = function ($post) use ($filesBaseUrl) {
$user = $post->user ?? null;
return [
'id' => $post->id,
'user_id' => $post->user_id,
'content' => $post->content,
'rendered_content' => ForumPostContent::render($post->content),
'created_at' => $post->created_at?->toIso8601String(),
'edited_at' => $post->edited_at?->toIso8601String(),
'is_edited' => (bool) $post->is_edited,
'can_edit' => auth()->check() && (
(int) $post->user_id === (int) auth()->id() || Gate::allows('moderate-forum')
),
'current_user_id' => auth()->id(),
'user' => $user ? [
'id' => $user->id,
'name' => $user->name,
'avatar_url' => AvatarUrl::forUser((int) $user->id, $user->profile?->avatar_hash ?? null),
'role' => $user->role ?? 'member',
] : null,
'attachments' => collect($post->attachments ?? [])->map(fn ($a) => [
'id' => $a->id,
'mime_type' => $a->mime_type,
'url' => $filesBaseUrl !== '' ? $filesBaseUrl . '/' . ltrim($a->file_path, '/') : '/' . ltrim($a->file_path, '/'),
'file_size' => $a->file_size,
'width' => $a->width,
'height' => $a->height,
])->values()->all(),
];
};
$serializedOp = isset($opPost) && $opPost ? $serializePost($opPost) : null;
$serializedPosts = collect($posts->items())->map($serializePost)->values()->all();
$paginationData = [
'current_page' => $posts->currentPage(),
'last_page' => $posts->lastPage(),
'per_page' => $posts->perPage(),
'total' => $posts->total(),
];
@endphp
@section('content')
<div id="forum-thread-root"></div>
@php
$forumThreadProps = json_encode([
'thread' => [
'id' => $thread->id,
'title' => $thread->title,
'slug' => $thread->slug,
'views' => (int) ($thread->views ?? 0),
'is_pinned' => (bool) $thread->is_pinned,
'is_locked' => (bool) $thread->is_locked,
'created_at' => $thread->created_at?->toIso8601String(),
],
'category' => ['id' => $category->id ?? null, 'name' => $category->name ?? '', 'slug' => $category->slug ?? ''],
'author' => ['name' => $author->name ?? 'Unknown'],
'opPost' => $serializedOp,
'posts' => $serializedPosts,
'pagination' => $paginationData,
'replyCount' => (int) ($reply_count ?? 0),
'sort' => $sort ?? 'asc',
'quotedPost' => $quoted_post ? ['user' => ['name' => data_get($quoted_post, 'user.name', 'Anonymous')]] : null,
'replyPrefill' => $reply_prefill ?? '',
'isAuthenticated' => auth()->check(),
'canModerate' => Gate::allows('moderate-forum'),
'csrfToken' => csrf_token(),
'status' => session('status'),
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE);
@endphp
<script type="application/json" id="forum-thread-props">{!! $forumThreadProps !!}</script>
@endsection
@push('scripts')
@vite(['resources/js/entry-forum.jsx'])
@endpush