Profilseite: Kommentare der Person
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m41s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m32s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m11s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m30s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m30s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m3s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m41s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m32s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m11s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m55s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m30s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m39s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m30s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m3s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
53df8918f6
commit
8a59023569
118 changed files with 620 additions and 438 deletions
31
plugins-core/news/resources/js/profile-panels/Comments.vue
Normal file
31
plugins-core/news/resources/js/profile-panels/Comments.vue
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<script setup>
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { CornerDownRight, MessageCircle } from '@lucide/vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
|
||||
/**
|
||||
* Profilseite: Kommentare der Person zu Neuigkeiten.
|
||||
*/
|
||||
defineProps({
|
||||
total: { type: Number, required: true },
|
||||
comments: { type: Array, required: true },
|
||||
});
|
||||
|
||||
const dateFormat = new Intl.DateTimeFormat('de-DE', { day: 'numeric', month: 'long', year: 'numeric' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel :title="`Kommentare (${total})`">
|
||||
<ol class="-my-1 divide-y">
|
||||
<li v-for="comment in comments" :key="comment.id" class="py-3">
|
||||
<p class="flex items-center gap-1.5 text-xs text-muted-foreground">
|
||||
<component :is="comment.is_reply ? CornerDownRight : MessageCircle" class="size-3.5 shrink-0" />
|
||||
<span>{{ comment.is_reply ? 'Antwort' : 'Kommentar' }} am {{ dateFormat.format(new Date(comment.created_at)) }} zu</span>
|
||||
</p>
|
||||
<Link :href="comment.post.url" class="mt-0.5 block text-sm font-medium text-brand-text hover:underline">{{ comment.post.title }}</Link>
|
||||
<p class="mt-1 text-sm leading-relaxed break-words text-foreground/80">„{{ comment.excerpt }}“</p>
|
||||
</li>
|
||||
</ol>
|
||||
<p v-if="total > comments.length" class="mt-2 border-t pt-3 text-xs text-muted-foreground">Die neuesten {{ comments.length }} von {{ total }} Kommentaren.</p>
|
||||
</Panel>
|
||||
</template>
|
||||
|
|
@ -11,6 +11,7 @@ use App\Pagebuilder\Blocks;
|
|||
use App\Pagebuilder\BlockType;
|
||||
use App\Pagebuilder\Field;
|
||||
use App\Plugins\Plugin;
|
||||
use App\Profile\ProfilePanels;
|
||||
use App\Search\GlobalSearch;
|
||||
use App\Support\Abilities;
|
||||
use App\Support\Navigation;
|
||||
|
|
@ -18,8 +19,10 @@ use Illuminate\Database\Eloquent\Collection;
|
|||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
use Inhaus\Plugins\News\Http\Resources\NewsPostResource;
|
||||
use Inhaus\Plugins\News\Models\NewsCategory;
|
||||
use Inhaus\Plugins\News\Models\NewsComment;
|
||||
use Inhaus\Plugins\News\Models\NewsPost;
|
||||
use Inhaus\Plugins\News\Policies\NewsCategoryPolicy;
|
||||
use Inhaus\Plugins\News\Policies\NewsPostPolicy;
|
||||
|
|
@ -43,6 +46,28 @@ class NewsPlugin extends Plugin
|
|||
Gate::policy(NewsPost::class, NewsPostPolicy::class);
|
||||
|
||||
$this->registerWidgets($this->app->make(Widgets::class));
|
||||
|
||||
// Profilseite: Kommentare der Person – nur zu Beiträgen, die die betrachtende Person sehen darf
|
||||
$this->app->make(ProfilePanels::class)->add('news.comments', 'news::Comments', 20, function (User $person, User $viewer) {
|
||||
$query = NewsComment::query()->where('user_id', $person->id)
|
||||
->whereHas('post', fn ($post) => $post->published()->visibleTo($viewer));
|
||||
$total = (clone $query)->count();
|
||||
|
||||
if ($total === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'total' => $total,
|
||||
'comments' => $query->with('post:id,title,slug')->latest()->limit(8)->get()->map(fn (NewsComment $comment) => [
|
||||
'id' => $comment->id,
|
||||
'excerpt' => Str::limit($comment->body, 180),
|
||||
'is_reply' => $comment->parent_id !== null,
|
||||
'created_at' => $comment->created_at?->toIso8601String(),
|
||||
'post' => ['title' => $comment->post->title, 'url' => route('news.show', $comment->post).'#kommentar-'.$comment->id],
|
||||
])->all(),
|
||||
];
|
||||
});
|
||||
$this->registerMediaUsages($this->app->make(MediaUsages::class));
|
||||
|
||||
$this->app->make(Editorial::class)->add(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue