221 lines
12 KiB
PHP
221 lines
12 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('page_title')
|
|
{{ $book->title }}
|
|
by
|
|
@if($book->authors && $book->authors->count())
|
|
{{ $book->authors->pluck('name')->join(', ') }}
|
|
@elseif($book->author)
|
|
{{ $book->author }}
|
|
@endif
|
|
- Summary by OpenTextSummaries
|
|
@endsection
|
|
|
|
@section('meta_description')
|
|
@php
|
|
$raw = '';
|
|
if ($book->summary && $book->summary->content) {
|
|
$raw = strip_tags($book->summary->content);
|
|
} elseif (!empty($book->description)) {
|
|
$raw = strip_tags($book->description);
|
|
} else {
|
|
$authorNames = '';
|
|
if ($book->authors && $book->authors->count()) {
|
|
$authorNames = $book->authors->pluck('name')->join(', ');
|
|
} elseif (!empty($book->author)) {
|
|
$authorNames = $book->author;
|
|
}
|
|
$raw = trim($book->title . ($authorNames ? ' by ' . $authorNames : '') . ' — summary and key insights.');
|
|
}
|
|
$desc = \Illuminate\Support\Str::limit(preg_replace('/\s+/', ' ', $raw), 160, '…');
|
|
@endphp
|
|
{{ $desc }}
|
|
@endsection
|
|
|
|
@section('content')
|
|
<article class="bg-white rounded-lg shadow overflow-hidden">
|
|
<div class="md:flex">
|
|
@if($book->cover_image)
|
|
<img src="{{ $book->cover_image }}" alt="{{ $book->title }} cover" class="w-full md:w-1/3 h-64 md:h-auto object-cover">
|
|
@endif
|
|
<div class="p-6 md:w-2/3">
|
|
<h1 class="text-3xl font-bold text-indigo-700">{{ $book->title }}</h1>
|
|
<p class="mt-1 text-gray-700">
|
|
@if($book->authors && $book->authors->count())
|
|
{{ $book->authors->pluck('name')->join(', ') }}
|
|
@elseif($book->author)
|
|
{{ $book->author }}
|
|
@endif
|
|
</p>
|
|
@if($book->category)
|
|
<p class="text-sm text-gray-500 mt-1">Category: {{ $book->category->name }}</p>
|
|
@endif
|
|
@if($book->publication_date)
|
|
<p class="text-sm text-gray-500">Published: {{ $book->publication_date }}</p>
|
|
@endif
|
|
@if($book->description)
|
|
<div class="mt-4 prose max-w-none">{!! nl2br(e($book->description)) !!}</div>
|
|
@endif
|
|
|
|
@auth
|
|
<div class="mt-4">
|
|
@php($inReadlist = auth()->user()->readlistBooks()->where('book_id', $book->id)->exists())
|
|
@if(!$inReadlist)
|
|
<form action="{{ route('readlist.store', $book) }}" method="POST">
|
|
@csrf
|
|
<button type="submit" class="inline-flex items-center px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-md">Add to Readlist</button>
|
|
</form>
|
|
@else
|
|
<form action="{{ route('readlist.destroy', $book) }}" method="POST">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="inline-flex items-center px-4 py-2 bg-red-50 text-red-700 hover:bg-red-100 rounded-md">Remove from Readlist</button>
|
|
</form>
|
|
@endif
|
|
</div>
|
|
@endauth
|
|
</div>
|
|
</div>
|
|
<div class="p-6 border-t">
|
|
<div class="mb-4">
|
|
@if (session('success'))
|
|
<div class="bg-green-50 text-green-800 border border-green-200 rounded-md px-4 py-2 mb-4">
|
|
{{ session('success') }}
|
|
</div>
|
|
@endif
|
|
@if ($errors->any())
|
|
<div class="bg-red-50 text-red-800 border border-red-200 rounded-md px-4 py-2 mb-4">
|
|
<ul class="list-disc list-inside">
|
|
@foreach ($errors->all() as $error)
|
|
<li>{{ $error }}</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
<h2 class="text-2xl font-semibold mb-3">Summary</h2>
|
|
@if($book->summary)
|
|
<div class="prose max-w-none">
|
|
{!! nl2br(e($book->summary->content)) !!}
|
|
</div>
|
|
@if($book->summary->key_insights)
|
|
<h3 class="text-xl font-semibold mt-6">Key insights</h3>
|
|
<p class="mt-2">{!! nl2br(e($book->summary->key_insights)) !!}</p>
|
|
@endif
|
|
@else
|
|
<p class="text-gray-600">No summary available for this book yet.</p>
|
|
@auth
|
|
<div class="mt-3">
|
|
<a href="{{ route('requests.create') }}" class="inline-flex items-center px-3 py-2 text-sm bg-indigo-600 hover:bg-indigo-700 text-white rounded-md">Request a summary</a>
|
|
</div>
|
|
@else
|
|
<p class="text-sm text-gray-600 mt-2">Want one? <a href="{{ route('login') }}" class="text-indigo-600 hover:underline">Log in</a> to request a summary.</p>
|
|
@endauth
|
|
@endif
|
|
|
|
<div class="mt-8 pt-6 border-t">
|
|
@include('layouts.donate_widget')
|
|
</div>
|
|
|
|
<div class="mt-8 pt-6 border-t">
|
|
<h3 class="text-lg font-semibold mb-2">Is this summary inaccurate?</h3>
|
|
@auth
|
|
<form action="{{ route('summary-reports.store', $book) }}" method="POST" class="space-y-3">
|
|
@csrf
|
|
<div>
|
|
<label for="reason" class="block text-sm font-medium text-gray-700">Reason</label>
|
|
<select id="reason" name="reason" class="mt-1 block w-full border-gray-300 rounded-md">
|
|
<option value="inaccurate">Inaccurate information</option>
|
|
<option value="incomplete">Incomplete or missing key points</option>
|
|
<option value="offensive">Offensive or inappropriate</option>
|
|
<option value="other">Other</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label for="details" class="block text-sm font-medium text-gray-700">Details (optional)</label>
|
|
<textarea id="details" name="details" rows="3" placeholder="Please describe what's wrong..." class="mt-1 block w-full border-gray-300 rounded-md">{{ old('details') }}</textarea>
|
|
</div>
|
|
<button type="submit" class="inline-flex items-center px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-md">Report issue</button>
|
|
</form>
|
|
@else
|
|
<p class="text-sm text-gray-600">Please <a href="{{ route('login') }}" class="text-indigo-600 hover:underline">log in</a> to report issues with this summary.</p>
|
|
@endauth
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Reviews Section -->
|
|
<div class="p-6 border-t">
|
|
<h2 class="text-2xl font-semibold mb-4">Reviews</h2>
|
|
|
|
<div class="mb-6 flex items-center gap-3">
|
|
<div class="flex items-center">
|
|
@for($i=1;$i<=5;$i++)
|
|
<svg class="w-5 h-5 {{ $i <= round($avgRating) ? 'text-yellow-400' : 'text-gray-300' }}" fill="currentColor" viewBox="0 0 20 20">
|
|
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.803 2.036a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.803-2.036a1 1 0 00-1.176 0l-2.803 2.036c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81H7.03a1 1 0 00.95-.69l1.07-3.292z"/>
|
|
</svg>
|
|
@endfor
|
|
</div>
|
|
<div class="text-gray-600 text-sm">{{ $avgRating > 0 ? number_format($avgRating, 1) : 'No ratings yet' }} @if($reviewsCount) • {{ $reviewsCount }} {{ Str::plural('review', $reviewsCount) }} @endif</div>
|
|
</div>
|
|
|
|
@auth
|
|
<div class="mb-6 bg-gray-50 border border-gray-200 rounded-lg p-4">
|
|
<h3 class="text-lg font-semibold mb-2">{{ $userReview ? 'Update your review' : 'Leave a review' }}</h3>
|
|
<form action="{{ route('reviews.store', $book) }}" method="POST" class="space-y-3">
|
|
@csrf
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700">Rating</label>
|
|
<select name="rating" class="mt-1 block w-32 border-gray-300 rounded-md">
|
|
@for($i=5;$i>=1;$i--)
|
|
<option value="{{ $i }}" {{ old('rating', optional($userReview)->rating) == $i ? 'selected' : '' }}>{{ $i }} star{{ $i>1?'s':'' }}</option>
|
|
@endfor
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700">Comment (optional)</label>
|
|
<textarea name="comment" rows="3" class="mt-1 block w-full border-gray-300 rounded-md" placeholder="Share your thoughts...">{{ old('comment', optional($userReview)->comment) }}</textarea>
|
|
</div>
|
|
<div class="flex items-center gap-3">
|
|
<button type="submit" class="inline-flex items-center px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-md">{{ $userReview ? 'Update Review' : 'Submit Review' }}</button>
|
|
</div>
|
|
</form>
|
|
@if($userReview)
|
|
<form action="{{ route('reviews.destroy', $userReview) }}" method="POST" class="mt-3" onsubmit="return confirm('Delete your review?')">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="px-3 py-2 text-sm bg-red-50 text-red-700 hover:bg-red-100 rounded-md">Delete your review</button>
|
|
</form>
|
|
@endif
|
|
</div>
|
|
@else
|
|
<p class="text-sm text-gray-600 mb-6">Please <a href="{{ route('login') }}" class="text-indigo-600 hover:underline">log in</a> to leave a review.</p>
|
|
@endauth
|
|
|
|
@if($book->reviews->count())
|
|
<ul class="space-y-4">
|
|
@foreach($book->reviews->sortByDesc('created_at') as $review)
|
|
<li class="border border-gray-100 rounded-lg p-4">
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex items-center gap-2">
|
|
<span class="text-sm font-semibold">{{ $review->user->name }}</span>
|
|
<span class="text-xs text-gray-500">• {{ $review->created_at->diffForHumans() }}</span>
|
|
</div>
|
|
<div class="flex items-center">
|
|
@for($i=1;$i<=5;$i++)
|
|
<svg class="w-4 h-4 {{ $i <= $review->rating ? 'text-yellow-400' : 'text-gray-300' }}" fill="currentColor" viewBox="0 0 20 20"><path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.803 2.036a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.803-2.036a1 1 0 00-1.176 0l-2.803 2.036c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81H7.03a1 1 0 00.95-.69l1.07-3.292z"/></svg>
|
|
@endfor
|
|
</div>
|
|
</div>
|
|
@if($review->comment)
|
|
<p class="mt-2 text-gray-700">{{ $review->comment }}</p>
|
|
@endif
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
@else
|
|
<p class="text-gray-600">No reviews yet. Be the first to review this summary.</p>
|
|
@endif
|
|
</div>
|
|
</article>
|
|
@endsection
|