some progress

This commit is contained in:
2025-09-20 16:47:41 +03:00
parent e650f3c1b2
commit 2228469bcb
65 changed files with 3382 additions and 311 deletions
+9 -2
View File
@@ -9,6 +9,11 @@
## Open Text Summaries API
### Sitemap
- Endpoint: GET /sitemap.xml
- Description: Returns an XML sitemap including homepage, static pages (/about, /privacy, /terms, /contact), index pages (/books, /categories), and all book detail pages.
- How to submit to Google: In Google Search Console, add your property (domain) and submit the sitemap URL, e.g., https://your-domain.com/sitemap.xml
This API lets you ingest Books (with optional Category and Summary) in a create-or-update (upsert) fashion. It is designed so your client can safely resend the same data without creating duplicates.
- Method and route: POST /api/ingest/books
@@ -61,7 +66,8 @@ Accepted request shapes
Field reference
- Book
- title (string, required)
- author (string, required)
- author (string, required if `authors` not provided)
- authors (array<string>, optional; preferred. If provided, `author` may be omitted. The first name is also stored in the legacy `author` field for backward compatibility.)
- slug (string, optional; defaults to slugified title)
- description (string, optional)
- publication_date (YYYY-MM-DD string, optional)
@@ -148,7 +154,8 @@ Status: 422
}
Notes
- This endpoint performs minimal validation: each item must have title and author. Other fields are optional.
- Authors are normalized to a separate `authors` table and linked via a pivot. You may send `author` (string) or `authors` (array). If `authors` is provided, the first name is also saved to the legacy `author` column on books for compatibility.
- This endpoint performs minimal validation: each item must have title and author/authors. Other fields are optional.
- Slugs are derived from names/titles if not provided, using Laravel's Str::slug.
- There is no pagination or retrieval endpoint here; this endpoint is for ingestion only.
- No authentication/rate limiting is configured by default; add it before exposing this API to untrusted clients.
+46 -5
View File
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
use App\Models\Book;
use App\Models\Category;
use App\Models\Summary;
use App\Models\Author;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\DB;
@@ -42,11 +43,13 @@ class IngestController extends Controller
// Basic validation (minimal to satisfy requirement)
$title = $item['title'] ?? null;
$author = $item['author'] ?? null;
if (!$title || !$author) {
$authorsArr = $item['authors'] ?? null; // optional array of names
$hasAuthorInfo = $author || (is_array($authorsArr) && count($authorsArr) > 0);
if (!$title || !$hasAuthorInfo) {
$results[] = [
'index' => $index,
'status' => 'error',
'message' => 'title and author are required.',
'message' => 'title and author/authors are required.',
];
continue;
}
@@ -95,19 +98,22 @@ class IngestController extends Controller
$bookSlug = Str::slug($item['title']);
}
// Determine a primary author name for backward-compatible matching
$primaryAuthorName = $item['author'] ?? (is_array($item['authors'] ?? null) && count($item['authors']) > 0 ? ($item['authors'][0] ?? null) : null);
$bookQuery = Book::query();
if ($bookSlug) {
$bookQuery->where('slug', $bookSlug);
} else {
// Fallback: match by title+author
$bookQuery->where('title', $item['title'])->where('author', $item['author']);
// Fallback: match by title+author (string). If authors[] provided, use first one.
$bookQuery->where('title', $item['title'])->where('author', $primaryAuthorName);
}
$book = $bookQuery->first();
$bookData = [
'title' => $item['title'] ?? ($book->title ?? null),
'slug' => $bookSlug ?? ($book->slug ?? null),
'author' => $item['author'] ?? ($book->author ?? null),
'author' => $primaryAuthorName ?? ($book->author ?? null),
'description' => $item['description'] ?? ($book->description ?? null),
'publication_date' => $item['publication_date'] ?? ($book->publication_date ?? null),
'cover_image' => $item['cover_image'] ?? ($book->cover_image ?? null),
@@ -126,6 +132,41 @@ class IngestController extends Controller
$bookStatus = 'created';
}
// Handle authors upsert and pivot sync
$names = [];
if (!empty($item['author'])) {
$names[] = $item['author'];
}
if (!empty($item['authors']) && is_array($item['authors'])) {
$names = array_merge($names, $item['authors']);
}
$names = array_values(array_unique(array_filter(array_map(function ($n) { return is_string($n) ? trim($n) : null; }, $names))));
if (count($names) > 0) {
$authorIds = [];
foreach ($names as $name) {
$slug = Str::slug($name);
$author = Author::where('slug', $slug)->first();
if (!$author) {
$author = Author::where('name', $name)->first();
}
if ($author) {
// ensure slug and name are up to date
$author->fill([
'name' => $name,
'slug' => $author->slug ?: $slug,
])->save();
} else {
$author = Author::create([
'name' => $name,
'slug' => $slug,
]);
}
$authorIds[] = $author->id;
}
// Replace current authors with provided set
$book->authors()->sync($authorIds);
}
// Handle summary upsert
$summaryData = $item['summary'] ?? null;
$summaryResult = null;
@@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
}
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
$this->middleware('auth')->only('logout');
}
}
@@ -0,0 +1,72 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/home';
}
@@ -0,0 +1,41 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'resend');
}
}
+140 -7
View File
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Book;
use App\Models\Category;
use App\Models\Author;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
@@ -12,10 +13,67 @@ class BookController extends Controller
/**
* Display a listing of the resource.
*/
public function index()
public function index(Request $request)
{
$books = Book::with('category')->get();
return view('books.index', compact('books'));
$query = Book::query()->with(['category', 'authors', 'summary'])->orderByDesc('created_at');
// Text search
if ($search = trim((string) $request->get('q'))) {
$query->where(function ($q) use ($search) {
$q->where('title', 'like', "%{$search}%")
->orWhere('description', 'like', "%{$search}%");
});
}
// Category filter (by id or slug)
if ($cat = $request->get('category')) {
if (is_numeric($cat)) {
$query->where('category_id', (int) $cat);
} else {
$query->whereHas('category', function ($q) use ($cat) {
$q->where('slug', $cat)->orWhere('name', 'like', "%{$cat}%");
});
}
}
// Author filter (by id, slug, or name)
if ($author = $request->get('author')) {
$query->whereHas('authors', function ($q) use ($author) {
if (is_numeric($author)) {
$q->where('authors.id', (int) $author);
} else {
$q->where('authors.slug', $author)
->orWhere('authors.name', 'like', "%{$author}%");
}
});
}
// Publication date range
if ($from = $request->get('date_from')) {
$query->whereDate('publication_date', '>=', $from);
}
if ($to = $request->get('date_to')) {
$query->whereDate('publication_date', '<=', $to);
}
$books = $query->paginate(12)->withQueryString();
// For filter dropdowns
$categories = Category::orderBy('name')->get();
$authors = Author::orderBy('name')->get();
return view('books.index', [
'books' => $books,
'categories' => $categories,
'authors' => $authors,
'filters' => [
'q' => $request->get('q'),
'category' => $request->get('category'),
'author' => $request->get('author'),
'date_from' => $request->get('date_from'),
'date_to' => $request->get('date_to'),
],
]);
}
/**
@@ -41,9 +99,18 @@ class BookController extends Controller
'category_id' => 'required|exists:categories,id',
]);
Book::create([
// Generate a unique slug for the title
$baseSlug = Str::slug($request->title);
$slug = $baseSlug;
$i = 2;
while (Book::where('slug', $slug)->exists()) {
$slug = $baseSlug . '-' . $i;
$i++;
}
$book = Book::create([
'title' => $request->title,
'slug' => Str::slug($request->title),
'slug' => $slug,
'author' => $request->author,
'description' => $request->description,
'publication_date' => $request->publication_date,
@@ -51,6 +118,22 @@ class BookController extends Controller
'category_id' => $request->category_id,
]);
// Normalize author: link to authors table via pivot
if (!empty($request->author)) {
$name = trim($request->author);
$slug = Str::slug($name);
$author = Author::where('slug', $slug)->first();
if (!$author) {
$author = Author::where('name', $name)->first();
}
if ($author) {
$author->fill(['name' => $name, 'slug' => $author->slug ?: $slug])->save();
} else {
$author = Author::create(['name' => $name, 'slug' => $slug]);
}
$book->authors()->sync([$author->id]);
}
return redirect()->route('books.index')
->with('success', 'Book created successfully.');
}
@@ -60,7 +143,17 @@ class BookController extends Controller
*/
public function show(Book $book)
{
return view('books.show', compact('book'));
$book->load(['summary', 'category', 'authors', 'reviews.user']);
$avgRating = (float) round($book->reviews()->avg('rating') ?? 0, 1);
$reviewsCount = (int) $book->reviews()->count();
$userReview = auth()->check() ? $book->reviews()->where('user_id', auth()->id())->first() : null;
return view('books.show', [
'book' => $book,
'avgRating' => $avgRating,
'reviewsCount' => $reviewsCount,
'userReview' => $userReview,
]);
}
/**
@@ -86,9 +179,30 @@ class BookController extends Controller
'category_id' => 'required|exists:categories,id',
]);
// If title changed, compute a unique slug (preserving current slug if still matching)
$baseSlug = Str::slug($request->title);
$slug = $baseSlug;
if ($book->slug !== $baseSlug) {
$i = 2;
while (Book::where('slug', $slug)->where('id', '!=', $book->id)->exists()) {
$slug = $baseSlug . '-' . $i;
$i++;
}
} else {
// Ensure no collision with other records even if same base
if (Book::where('slug', $baseSlug)->where('id', '!=', $book->id)->exists()) {
$i = 2;
$slug = $baseSlug . '-' . $i;
while (Book::where('slug', $slug)->where('id', '!=', $book->id)->exists()) {
$i++;
$slug = $baseSlug . '-' . $i;
}
}
}
$book->update([
'title' => $request->title,
'slug' => Str::slug($request->title),
'slug' => $slug,
'author' => $request->author,
'description' => $request->description,
'publication_date' => $request->publication_date,
@@ -96,6 +210,25 @@ class BookController extends Controller
'category_id' => $request->category_id,
]);
// Normalize author: sync pivot to the single provided author
if (!empty($request->author)) {
$name = trim($request->author);
$slug = Str::slug($name);
$author = Author::where('slug', $slug)->first();
if (!$author) {
$author = Author::where('name', $name)->first();
}
if ($author) {
$author->fill(['name' => $name, 'slug' => $author->slug ?: $slug])->save();
} else {
$author = Author::create(['name' => $name, 'slug' => $slug]);
}
$book->authors()->sync([$author->id]);
} else {
// If author field is cleared, detach all author links
$book->authors()->detach();
}
return redirect()->route('books.index')
->with('success', 'Book updated successfully.');
}
@@ -0,0 +1,39 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
class ContactController extends Controller
{
/** Show the contact form */
public function show()
{
return view('static.contact');
}
/** Handle contact form submission and send email */
public function send(Request $request)
{
$data = $request->validate([
'name' => 'required|string|max:255',
'email' => 'required|email',
'message' => 'required|string|max:5000',
]);
$to = 'mike@opentextsummaries.com';
$subject = 'Contact form message from ' . $data['name'];
$body = "Name: {$data['name']}\nEmail: {$data['email']}\n\nMessage:\n{$data['message']}";
// Send using simple raw email (will go to log in local env per .env)
Mail::raw($body, function ($message) use ($to, $subject, $data) {
$message->to($to)
->subject($subject)
->replyTo($data['email'], $data['name']);
});
return back()->with('success', 'Thank you! Your message has been sent.');
}
}
+6 -2
View File
@@ -2,7 +2,11 @@
namespace App\Http\Controllers;
abstract class Controller
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
//
use AuthorizesRequests, ValidatesRequests;
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\SummaryReport;
use App\Models\SummaryRequest;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the user dashboard with stats.
*/
public function index(Request $request)
{
$user = $request->user();
// Aggregate counts
$readlistCount = $user->readlistBooks()->count();
$readlistWithSummaryCount = $user->readlistBooks()->whereHas('summary')->count();
$reviewsCount = $user->reviews()->count();
$reportsCount = SummaryReport::where('user_id', $user->id)->count();
$requestsCount = SummaryRequest::where('user_id', $user->id)->count();
// Recent activity
$latestReadlist = $user->readlistBooks()->with(['authors', 'summary'])->orderByPivot('created_at', 'desc')->limit(5)->get();
$latestReviews = $user->reviews()->with('book')->latest()->limit(5)->get();
$latestRequests = SummaryRequest::where('user_id', $user->id)->latest()->limit(5)->get();
return view('home', compact(
'readlistCount',
'readlistWithSummaryCount',
'reviewsCount',
'reportsCount',
'requestsCount',
'latestReadlist',
'latestReviews',
'latestRequests'
));
}
}
@@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers;
use App\Models\Book;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class ReadlistController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Display the user's readlist.
*/
public function index(Request $request)
{
$user = $request->user();
$books = $user->readlistBooks()->with(['category', 'authors', 'summary'])->orderByPivot('created_at', 'desc')->paginate(12);
return view('readlist.index', [
'books' => $books,
]);
}
/**
* Add a book to the readlist.
*/
public function store(Request $request, Book $book)
{
$user = $request->user();
$user->readlistBooks()->syncWithoutDetaching([$book->id]);
if ($request->wantsJson()) {
return response()->json(['status' => 'added']);
}
return back()->with('success', 'Book added to your readlist.');
}
/**
* Remove a book from the readlist.
*/
public function destroy(Request $request, Book $book)
{
$user = $request->user();
$user->readlistBooks()->detach($book->id);
if ($request->wantsJson()) {
return response()->json(['status' => 'removed']);
}
return back()->with('success', 'Book removed from your readlist.');
}
}
@@ -0,0 +1,62 @@
<?php
namespace App\Http\Controllers;
use App\Models\Book;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\URL;
class SitemapController extends Controller
{
/**
* Generate the XML sitemap.
*/
public function index(): Response
{
$urls = [];
// Static and index pages
$urls[] = [URL::to('/'), now()];
$urls[] = [URL::to('/about'), null];
$urls[] = [URL::to('/privacy'), null];
$urls[] = [URL::to('/terms'), null];
$urls[] = [URL::to('/contact'), null];
$urls[] = [URL::to('/books'), now()];
$urls[] = [URL::to('/categories'), now()];
// Individual book pages
Book::select(['slug', 'updated_at'])->orderBy('updated_at', 'desc')->chunk(500, function ($books) use (&$urls) {
foreach ($books as $book) {
$urls[] = [URL::to('/books/' . $book->slug), optional($book->updated_at)];
}
});
$xml = $this->buildXml($urls);
return response($xml, 200)->header('Content-Type', 'application/xml');
}
/**
* Build a basic XML sitemap string.
*
* @param array<int, array{0:string,1:\DateTimeInterface|null}> $urls
*/
protected function buildXml(array $urls): string
{
$xmlHeader = '<?xml version="1.0" encoding="UTF-8"?>';
$urlsetOpen = '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$urlsetClose = '</urlset>';
$body = '';
foreach ($urls as [$loc, $lastmod]) {
$body .= "\n <url>\n";
$body .= ' <loc>' . e($loc) . "</loc>\n";
if ($lastmod) {
$body .= ' <lastmod>' . $lastmod->format('c') . "</lastmod>\n";
}
$body .= " </url>";
}
return $xmlHeader . "\n" . $urlsetOpen . $body . "\n" . $urlsetClose . "\n";
}
}
@@ -0,0 +1,24 @@
<?php
namespace App\Http\Controllers;
class StaticPageController extends Controller
{
/** Show the About page. */
public function about()
{
return view('static.about');
}
/** Show the Privacy Policy page. */
public function privacy()
{
return view('static.privacy');
}
/** Show the Terms of Service page. */
public function terms()
{
return view('static.terms');
}
}
@@ -0,0 +1,51 @@
<?php
namespace App\Http\Controllers;
use App\Models\Book;
use App\Models\SummaryReport;
use Illuminate\Http\Request;
class SummaryReportController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Store a newly created summary report in storage.
*/
public function store(Request $request, Book $book)
{
$validated = $request->validate([
'reason' => 'required|string|max:100',
'details' => 'nullable|string|max:5000',
]);
// Try to prevent duplicate reports from the same user for the same book
$report = SummaryReport::firstOrCreate(
[
'user_id' => $request->user()->id,
'book_id' => $book->id,
],
[
'summary_id' => optional($book->summary)->id,
'reason' => $validated['reason'],
'details' => $validated['details'] ?? null,
'status' => 'open',
]
);
if (!$report->wasRecentlyCreated) {
// If already exists, update reason/details in case user adds more context
$report->update([
'reason' => $validated['reason'],
'details' => $validated['details'] ?? $report->details,
'summary_id' => optional($book->summary)->id,
]);
}
return back()->with('success', 'Thanks! Your report has been submitted. We will review it soon.');
}
}
@@ -0,0 +1,91 @@
<?php
namespace App\Http\Controllers;
use App\Models\SummaryRequest;
use Illuminate\Http\Request;
class SummaryRequestController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/** List the current user's requests */
public function index(Request $request)
{
$requests = SummaryRequest::where('user_id', $request->user()->id)
->orderByDesc('created_at')
->paginate(12);
return view('requests.index', [
'requests' => $requests,
]);
}
/** Show the create form */
public function create(Request $request)
{
$prefill = [
'gutenberg' => $request->query('gutenberg'),
'title' => $request->query('title'),
];
return view('requests.create', $prefill);
}
/** Store the request */
public function store(Request $request)
{
$data = $request->validate([
'gutenberg' => 'required|string|max:255', // can be URL or ID
'title' => 'nullable|string|max:255',
'notes' => 'nullable|string|max:2000',
]);
$gutenbergId = $this->parseGutenbergId($data['gutenberg']);
if (!$gutenbergId) {
return back()->withErrors(['gutenberg' => 'Please provide a valid Project Gutenberg URL or numeric ID.'])->withInput();
}
$requestModel = SummaryRequest::firstOrCreate([
'user_id' => $request->user()->id,
'gutenberg_id' => $gutenbergId,
], [
'title' => $data['title'] ?? null,
'notes' => $data['notes'] ?? null,
'status' => 'pending',
]);
// If already exists, update title/notes to latest provided
if (!$requestModel->wasRecentlyCreated) {
$requestModel->update([
'title' => $data['title'] ?? $requestModel->title,
'notes' => $data['notes'] ?? $requestModel->notes,
]);
}
return redirect()->route('requests.index')->with('success', 'Your summary request has been submitted. We will process it soon.');
}
private function parseGutenbergId(string $input): ?int
{
$input = trim($input);
// If pure number
if (ctype_digit($input)) {
return (int) $input;
}
// Try to extract from URL
$patterns = [
'/gutenberg\.org\/(?:ebooks|etext)\/(\d+)/i', // https://www.gutenberg.org/ebooks/1342
'/gutenberg\.org\/(?:files)\/(\d+)\//i', // https://www.gutenberg.org/files/1342/1342-h/1342-h.htm
];
foreach ($patterns as $pattern) {
if (preg_match($pattern, $input, $m)) {
return (int) $m[1];
}
}
return null;
}
}
@@ -0,0 +1,55 @@
<?php
namespace App\Http\Controllers;
use App\Models\Book;
use App\Models\SummaryReview;
use Illuminate\Http\Request;
class SummaryReviewController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
/**
* Store or update a user's review for a book summary.
*/
public function store(Request $request, Book $book)
{
$data = $request->validate([
'rating' => 'required|integer|min:1|max:5',
'comment' => 'nullable|string|max:2000',
]);
$review = SummaryReview::updateOrCreate(
[
'user_id' => $request->user()->id,
'book_id' => $book->id,
],
[
'summary_id' => optional($book->summary)->id,
'rating' => $data['rating'],
'comment' => $data['comment'] ?? null,
]
);
return back()->with('success', $review->wasRecentlyCreated ? 'Thanks for your review!' : 'Your review has been updated.');
}
/**
* Remove the specified review from storage.
*/
public function destroy(Request $request, SummaryReview $review)
{
$this->authorizeAction($request, $review);
$review->delete();
return back()->with('success', 'Your review has been deleted.');
}
protected function authorizeAction(Request $request, SummaryReview $review): void
{
abort_unless($review->user_id === $request->user()->id, 403, 'Unauthorized');
}
}
@@ -0,0 +1,57 @@
<?php
namespace App\Http\Middleware;
use App\Services\GoatCounterService;
use Closure;
use Illuminate\Http\Request;
class GoatCounterMiddleware
{
protected GoatCounterService $goatCounter;
public function __construct(GoatCounterService $goatCounter)
{
$this->goatCounter = $goatCounter;
}
/**
* Handle an incoming request.
*/
public function handle(Request $request, Closure $next)
{
$response = $next($request);
// Only track "real" HTML page requests:
if (
$request->isMethod('GET') &&
!$request->ajax() &&
$this->isTrackable($request)
) {
$this->goatCounter->trackPageview(
'/' . ltrim($request->path(), '/'),
$request->route()?->getName() ?? ucfirst(str_replace('/', ' ', $request->path())),
$request->headers->get('referer')
);
}
return $response;
}
protected function isTrackable(Request $request): bool
{
$path = $request->path();
// Ignore file extensions (css, js, images, fonts, etc.)
if (preg_match('/\.(css|js|png|jpe?g|gif|svg|ico|woff2?|ttf|map)$/i', $path)) {
return false;
}
// Optionally skip API routes
if ($request->is('api/*')) {
return false;
}
return true;
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Author extends Model
{
protected $fillable = [
'name',
'slug',
'bio',
];
/**
* The books that belong to the author.
*/
public function books()
{
return $this->belongsToMany(Book::class, 'author_book')->withTimestamps();
}
}
+40
View File
@@ -16,6 +16,14 @@ class Book extends Model
'category_id',
];
/**
* Use slug for route model binding and URL generation.
*/
public function getRouteKeyName(): string
{
return 'slug';
}
/**
* Get the category that owns the book.
*/
@@ -31,4 +39,36 @@ class Book extends Model
{
return $this->hasOne(Summary::class);
}
/**
* The authors that belong to the book.
*/
public function authors()
{
return $this->belongsToMany(Author::class, 'author_book')->withTimestamps();
}
/**
* Users who saved this book to their readlist.
*/
public function savedByUsers()
{
return $this->belongsToMany(User::class, 'readlist_items')->withTimestamps();
}
/**
* Reports submitted for this book's summary.
*/
public function reports()
{
return $this->hasMany(SummaryReport::class);
}
/**
* Reviews left by users for this book's summary.
*/
public function reviews()
{
return $this->hasMany(SummaryReview::class);
}
}
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SummaryReport extends Model
{
protected $fillable = [
'user_id',
'book_id',
'summary_id',
'reason',
'details',
'status',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function book()
{
return $this->belongsTo(Book::class);
}
public function summary()
{
return $this->belongsTo(Summary::class);
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SummaryRequest extends Model
{
protected $fillable = [
'user_id',
'gutenberg_id',
'title',
'notes',
'status',
];
public function user()
{
return $this->belongsTo(User::class);
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SummaryReview extends Model
{
protected $fillable = [
'user_id',
'book_id',
'summary_id',
'rating',
'comment',
];
public function user()
{
return $this->belongsTo(User::class);
}
public function book()
{
return $this->belongsTo(Book::class);
}
public function summary()
{
return $this->belongsTo(Summary::class);
}
}
+16
View File
@@ -45,4 +45,20 @@ class User extends Authenticatable
'password' => 'hashed',
];
}
/**
* Books saved by the user in their readlist.
*/
public function readlistBooks()
{
return $this->belongsToMany(Book::class, 'readlist_items')->withTimestamps();
}
/**
* Reviews authored by the user.
*/
public function reviews()
{
return $this->hasMany(SummaryReview::class);
}
}
+60
View File
@@ -0,0 +1,60 @@
<?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
class GoatCounterService
{
protected string $endpoint;
protected string $token;
public function __construct()
{
$this->endpoint = 'http://gc.c0rrup7.net/api/v0/count';
$this->token = '13nus05lo9d441ihqhk5d3w15s1hoi0h9pr013j1jwqyebgma8un'; // store in config/services.php
}
/**
* Track a single pageview
*/
public function trackPageview(string $path, string $title = null, string $referrer = null): array
{
return $this->sendHits([[
'path' => $path,
'title' => $title,
'ref' => $referrer,
]]);
}
/**
* Track a custom event
*/
public function trackEvent(string $event, string $title = null, string $referrer = null): array
{
return $this->sendHits([[
'event' => $event,
'title' => $title,
'ref' => $referrer,
]]);
}
/**
* Send multiple hits in one request
*/
public function sendHits(array $hits): array
{
$response = Http::withToken($this->token)
->acceptJson()
->asJson()
->post($this->endpoint, [
'no_sessions' => true, // don’t start session cookies from backend
'hits' => $hits,
]);
return [
'status' => $response->status(),
'response' => $response->json(),
];
}
}
+2 -1
View File
@@ -1,5 +1,6 @@
<?php
use App\Http\Middleware\GoatCounterMiddleware;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
@@ -12,7 +13,7 @@ return Application::configure(basePath: dirname(__DIR__))
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
//
$middleware->append(GoatCounterMiddleware::class);
})
->withExceptions(function (Exceptions $exceptions): void {
//
+2 -1
View File
@@ -11,7 +11,8 @@
"require": {
"php": "^8.2",
"laravel/framework": "^12.0",
"laravel/tinker": "^2.10.1"
"laravel/tinker": "^2.10.1",
"laravel/ui": "^4.6"
},
"require-dev": {
"fakerphp/faker": "^1.23",
Generated
+64 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "cd40520ddd6242a873530a735cb961c4",
"content-hash": "95cfaf5da898358678b4502356676f79",
"packages": [
{
"name": "brick/math",
@@ -1458,6 +1458,69 @@
},
"time": "2025-01-27T14:24:01+00:00"
},
{
"name": "laravel/ui",
"version": "v4.6.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/ui.git",
"reference": "7d6ffa38d79f19c9b3e70a751a9af845e8f41d88"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/ui/zipball/7d6ffa38d79f19c9b3e70a751a9af845e8f41d88",
"reference": "7d6ffa38d79f19c9b3e70a751a9af845e8f41d88",
"shasum": ""
},
"require": {
"illuminate/console": "^9.21|^10.0|^11.0|^12.0",
"illuminate/filesystem": "^9.21|^10.0|^11.0|^12.0",
"illuminate/support": "^9.21|^10.0|^11.0|^12.0",
"illuminate/validation": "^9.21|^10.0|^11.0|^12.0",
"php": "^8.0",
"symfony/console": "^6.0|^7.0"
},
"require-dev": {
"orchestra/testbench": "^7.35|^8.15|^9.0|^10.0",
"phpunit/phpunit": "^9.3|^10.4|^11.5"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Laravel\\Ui\\UiServiceProvider"
]
},
"branch-alias": {
"dev-master": "4.x-dev"
}
},
"autoload": {
"psr-4": {
"Laravel\\Ui\\": "src/",
"Illuminate\\Foundation\\Auth\\": "auth-backend/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Laravel UI utilities and presets.",
"keywords": [
"laravel",
"ui"
],
"support": {
"source": "https://github.com/laravel/ui/tree/v4.6.1"
},
"time": "2025-01-28T15:15:29+00:00"
},
{
"name": "league/commonmark",
"version": "2.7.1",
+4 -1
View File
@@ -34,5 +34,8 @@ return [
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
],
],
'goatcounter' => [
'url' => env('GOATCOUNTER_URL', 'http://gc.c0rrup7.net'),
'token' => env('GOATCOUNTER_TOKEN', '13nus05lo9d441ihqhk5d3w15s1hoi0h9pr013j1jwqyebgma8un'),
]
];
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('authors', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->text('bio')->nullable();
$table->timestamps();
});
Schema::create('author_book', function (Blueprint $table) {
$table->id();
$table->foreignId('author_id')->constrained()->onDelete('cascade');
$table->foreignId('book_id')->constrained()->onDelete('cascade');
$table->timestamps();
$table->unique(['author_id', 'book_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('author_book');
Schema::dropIfExists('authors');
}
};
@@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('readlist_items', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('book_id')->constrained()->cascadeOnDelete();
$table->timestamps();
$table->unique(['user_id', 'book_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('readlist_items');
}
};
@@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('summary_reports', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('book_id')->constrained()->cascadeOnDelete();
$table->foreignId('summary_id')->nullable()->constrained()->nullOnDelete();
$table->string('reason'); // e.g., inaccurate, incomplete, offensive, other
$table->text('details')->nullable();
$table->string('status')->default('open'); // open, reviewed, resolved
$table->timestamps();
$table->unique(['user_id', 'book_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('summary_reports');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('summary_requests', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->unsignedBigInteger('gutenberg_id');
$table->string('title')->nullable();
$table->text('notes')->nullable();
$table->string('status')->default('pending'); // pending, processing, completed, failed, rejected
$table->timestamps();
$table->unique(['user_id', 'gutenberg_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('summary_requests');
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('summary_reviews', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('book_id')->constrained()->cascadeOnDelete();
$table->foreignId('summary_id')->nullable()->constrained()->nullOnDelete();
$table->unsignedTinyInteger('rating'); // 1-5
$table->text('comment')->nullable();
$table->timestamps();
$table->unique(['user_id', 'book_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('summary_reviews');
}
};
+531
View File
@@ -5,10 +5,13 @@
"packages": {
"": {
"devDependencies": {
"@popperjs/core": "^2.11.6",
"@tailwindcss/vite": "^4.0.0",
"axios": "^1.11.0",
"bootstrap": "^5.2.3",
"concurrently": "^9.0.1",
"laravel-vite-plugin": "^2.0.0",
"sass": "^1.56.1",
"tailwindcss": "^4.0.0",
"vite": "^7.0.4"
}
@@ -518,6 +521,341 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@parcel/watcher": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz",
"integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"dependencies": {
"detect-libc": "^1.0.3",
"is-glob": "^4.0.3",
"micromatch": "^4.0.5",
"node-addon-api": "^7.0.0"
},
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
},
"optionalDependencies": {
"@parcel/watcher-android-arm64": "2.5.1",
"@parcel/watcher-darwin-arm64": "2.5.1",
"@parcel/watcher-darwin-x64": "2.5.1",
"@parcel/watcher-freebsd-x64": "2.5.1",
"@parcel/watcher-linux-arm-glibc": "2.5.1",
"@parcel/watcher-linux-arm-musl": "2.5.1",
"@parcel/watcher-linux-arm64-glibc": "2.5.1",
"@parcel/watcher-linux-arm64-musl": "2.5.1",
"@parcel/watcher-linux-x64-glibc": "2.5.1",
"@parcel/watcher-linux-x64-musl": "2.5.1",
"@parcel/watcher-win32-arm64": "2.5.1",
"@parcel/watcher-win32-ia32": "2.5.1",
"@parcel/watcher-win32-x64": "2.5.1"
}
},
"node_modules/@parcel/watcher-android-arm64": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz",
"integrity": "sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-darwin-arm64": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz",
"integrity": "sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-darwin-x64": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz",
"integrity": "sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-freebsd-x64": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz",
"integrity": "sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-linux-arm-glibc": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz",
"integrity": "sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-linux-arm-musl": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz",
"integrity": "sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-linux-arm64-glibc": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz",
"integrity": "sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-linux-arm64-musl": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz",
"integrity": "sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-linux-x64-glibc": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz",
"integrity": "sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-linux-x64-musl": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz",
"integrity": "sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-win32-arm64": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz",
"integrity": "sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-win32-ia32": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz",
"integrity": "sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher-win32-x64": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz",
"integrity": "sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/parcel"
}
},
"node_modules/@parcel/watcher/node_modules/detect-libc": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==",
"dev": true,
"license": "Apache-2.0",
"optional": true,
"bin": {
"detect-libc": "bin/detect-libc.js"
},
"engines": {
"node": ">=0.10"
}
},
"node_modules/@popperjs/core": {
"version": "2.11.8",
"resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz",
"integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==",
"dev": true,
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/popperjs"
}
},
"node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.50.1",
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.50.1.tgz",
@@ -1141,6 +1479,40 @@
"proxy-from-env": "^1.1.0"
}
},
"node_modules/bootstrap": {
"version": "5.3.8",
"resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.8.tgz",
"integrity": "sha512-HP1SZDqaLDPwsNiqRqi5NcP0SSXciX2s9E+RyqJIIqGo+vJeN5AJVM98CXmW/Wux0nQ5L7jeWUdplCEf0Ee+tg==",
"dev": true,
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/twbs"
},
{
"type": "opencollective",
"url": "https://opencollective.com/bootstrap"
}
],
"license": "MIT",
"peerDependencies": {
"@popperjs/core": "^2.11.8"
}
},
"node_modules/braces": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"fill-range": "^7.1.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
@@ -1185,6 +1557,22 @@
"node": ">=8"
}
},
"node_modules/chokidar": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
"dev": true,
"license": "MIT",
"dependencies": {
"readdirp": "^4.0.1"
},
"engines": {
"node": ">= 14.16.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/chownr": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
@@ -1443,6 +1831,20 @@
}
}
},
"node_modules/fill-range": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"to-regex-range": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/follow-redirects": {
"version": "1.15.11",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz",
@@ -1627,6 +2029,24 @@
"node": ">= 0.4"
}
},
"node_modules/immutable": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.3.tgz",
"integrity": "sha512-+chQdDfvscSF1SJqv2gn4SRO2ZyS3xL3r7IW/wWEEzrzLisnOlKiQu5ytC/BVNcS15C39WT2Hg/bjKjDMcu+zg==",
"dev": true,
"license": "MIT"
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
"dev": true,
"license": "MIT",
"optional": true,
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
@@ -1637,6 +2057,31 @@
"node": ">=8"
}
},
"node_modules/is-glob": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"is-extglob": "^2.1.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"license": "MIT",
"optional": true,
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/jiti": {
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/jiti/-/jiti-2.5.1.tgz",
@@ -1926,6 +2371,35 @@
"node": ">= 0.4"
}
},
"node_modules/micromatch": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"braces": "^3.0.3",
"picomatch": "^2.3.1"
},
"engines": {
"node": ">=8.6"
}
},
"node_modules/micromatch/node_modules/picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true,
"license": "MIT",
"optional": true,
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
@@ -2007,6 +2481,14 @@
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/node-addon-api": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz",
"integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==",
"dev": true,
"license": "MIT",
"optional": true
},
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
@@ -2063,6 +2545,20 @@
"dev": true,
"license": "MIT"
},
"node_modules/readdirp": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 14.18.0"
},
"funding": {
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@@ -2124,6 +2620,27 @@
"tslib": "^2.1.0"
}
},
"node_modules/sass": {
"version": "1.92.1",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.92.1.tgz",
"integrity": "sha512-ffmsdbwqb3XeyR8jJR6KelIXARM9bFQe8A6Q3W4Klmwy5Ckd5gz7jgUNHo4UOqutU5Sk1DtKLbpDP0nLCg1xqQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"chokidar": "^4.0.0",
"immutable": "^5.0.2",
"source-map-js": ">=0.6.2 <2.0.0"
},
"bin": {
"sass": "sass.js"
},
"engines": {
"node": ">=14.0.0"
},
"optionalDependencies": {
"@parcel/watcher": "^2.4.1"
}
},
"node_modules/shell-quote": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz",
@@ -2247,6 +2764,20 @@
"url": "https://github.com/sponsors/SuperchupuDev"
}
},
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"is-number": "^7.0.0"
},
"engines": {
"node": ">=8.0"
}
},
"node_modules/tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz",
+3
View File
@@ -7,10 +7,13 @@
"dev": "vite"
},
"devDependencies": {
"@popperjs/core": "^2.11.6",
"@tailwindcss/vite": "^4.0.0",
"axios": "^1.11.0",
"bootstrap": "^5.2.3",
"concurrently": "^9.0.1",
"laravel-vite-plugin": "^2.0.0",
"sass": "^1.56.1",
"tailwindcss": "^4.0.0",
"vite": "^7.0.4"
}
+1 -11
View File
@@ -1,11 +1 @@
@import 'tailwindcss';
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';
@source '../**/*.blade.php';
@source '../**/*.js';
@theme {
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
'Segoe UI Symbol', 'Noto Color Emoji';
}
@import "tailwindcss";
+30
View File
@@ -1,4 +1,34 @@
import 'bootstrap';
/**
* We'll load the axios HTTP library which allows us to easily issue requests
* to our Laravel back-end. This library automatically handles sending the
* CSRF token as a header based on the value of the "XSRF" token cookie.
*/
import axios from 'axios';
window.axios = axios;
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
/**
* Echo exposes an expressive API for subscribing to channels and listening
* for events that are broadcast by Laravel. Echo and event broadcasting
* allows your team to easily build robust real-time web applications.
*/
// import Echo from 'laravel-echo';
// import Pusher from 'pusher-js';
// window.Pusher = Pusher;
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: import.meta.env.VITE_PUSHER_APP_KEY,
// cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1',
// wsHost: import.meta.env.VITE_PUSHER_HOST ?? `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
// wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
// wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
// forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
// enabledTransports: ['ws', 'wss'],
// });
+7
View File
@@ -0,0 +1,7 @@
// Body
$body-bg: #f8fafc;
// Typography
$font-family-sans-serif: 'Nunito', sans-serif;
$font-size-base: 0.9rem;
$line-height-base: 1.6;
+8
View File
@@ -0,0 +1,8 @@
// Fonts
@import url('https://fonts.bunny.net/css?family=Nunito');
// Variables
@import 'variables';
// Bootstrap
@import 'bootstrap/scss/bootstrap';
+54
View File
@@ -0,0 +1,54 @@
@extends('layouts.app')
@section('content')
<div class="max-w-md mx-auto">
<div class="bg-white rounded-xl shadow-md border border-gray-100">
<div class="px-6 py-4 border-b border-gray-100">
<h2 class="text-lg font-semibold">{{ __('Login') }}</h2>
</div>
<div class="p-6">
<form method="POST" action="{{ route('login') }}" class="space-y-5">
@csrf
<div>
<label for="email" class="block text-sm font-medium text-gray-700">{{ __('Email Address') }}</label>
<input id="email" type="email" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus
class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 shadow-sm @error('email') border-red-500 focus:border-red-500 focus:ring-red-500 @enderror">
@error('email')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-700">{{ __('Password') }}</label>
<input id="password" type="password" name="password" required autocomplete="current-password"
class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 shadow-sm @error('password') border-red-500 focus:border-red-500 focus:ring-red-500 @enderror">
@error('password')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div class="flex items-center justify-between">
<label class="inline-flex items-center">
<input type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}
class="rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
<span class="ml-2 text-sm text-gray-700">{{ __('Remember Me') }}</span>
</label>
@if (Route::has('password.request'))
<a class="text-sm text-indigo-600 hover:text-indigo-700" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
<div>
<button type="submit" class="w-full inline-flex justify-center items-center px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-md shadow-sm transition-colors">
{{ __('Login') }}
</button>
</div>
</form>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,49 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Confirm Password') }}</div>
<div class="card-body">
{{ __('Please confirm your password before continuing.') }}
<form method="POST" action="{{ route('password.confirm') }}">
@csrf
<div class="row mb-3">
<label for="password" class="col-md-4 col-form-label text-md-end">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="current-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-0">
<div class="col-md-8 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Confirm Password') }}
</button>
@if (Route::has('password.request'))
<a class="btn btn-link" href="{{ route('password.request') }}">
{{ __('Forgot Your Password?') }}
</a>
@endif
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,47 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Reset Password') }}</div>
<div class="card-body">
@if (session('status'))
<div class="alert alert-success" role="alert">
{{ session('status') }}
</div>
@endif
<form method="POST" action="{{ route('password.email') }}">
@csrf
<div class="row mb-3">
<label for="email" class="col-md-4 col-form-label text-md-end">{{ __('Email Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Send Password Reset Link') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
@@ -0,0 +1,65 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Reset Password') }}</div>
<div class="card-body">
<form method="POST" action="{{ route('password.update') }}">
@csrf
<input type="hidden" name="token" value="{{ $token }}">
<div class="row mb-3">
<label for="email" class="col-md-4 col-form-label text-md-end">{{ __('Email Address') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ $email ?? old('email') }}" required autocomplete="email" autofocus>
@error('email')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="password" class="col-md-4 col-form-label text-md-end">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">
@error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="row mb-3">
<label for="password-confirm" class="col-md-4 col-form-label text-md-end">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
</div>
</div>
<div class="row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Reset Password') }}
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
+55
View File
@@ -0,0 +1,55 @@
@extends('layouts.app')
@section('content')
<div class="max-w-md mx-auto">
<div class="bg-white rounded-xl shadow-md border border-gray-100">
<div class="px-6 py-4 border-b border-gray-100">
<h2 class="text-lg font-semibold">{{ __('Register') }}</h2>
</div>
<div class="p-6">
<form method="POST" action="{{ route('register') }}" class="space-y-5">
@csrf
<div>
<label for="name" class="block text-sm font-medium text-gray-700">{{ __('Name') }}</label>
<input id="name" type="text" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus
class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 shadow-sm @error('name') border-red-500 focus:border-red-500 focus:ring-red-500 @enderror">
@error('name')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label for="email" class="block text-sm font-medium text-gray-700">{{ __('Email Address') }}</label>
<input id="email" type="email" name="email" value="{{ old('email') }}" required autocomplete="email"
class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 shadow-sm @error('email') border-red-500 focus:border-red-500 focus:ring-red-500 @enderror">
@error('email')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label for="password" class="block text-sm font-medium text-gray-700">{{ __('Password') }}</label>
<input id="password" type="password" name="password" required autocomplete="new-password"
class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 shadow-sm @error('password') border-red-500 focus:border-red-500 focus:ring-red-500 @enderror">
@error('password')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label for="password-confirm" class="block text-sm font-medium text-gray-700">{{ __('Confirm Password') }}</label>
<input id="password-confirm" type="password" name="password_confirmation" required autocomplete="new-password"
class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 shadow-sm">
</div>
<div>
<button type="submit" class="w-full inline-flex justify-center items-center px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white font-medium rounded-md shadow-sm transition-colors">
{{ __('Register') }}
</button>
</div>
</form>
</div>
</div>
</div>
@endsection
+28
View File
@@ -0,0 +1,28 @@
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">{{ __('Verify Your Email Address') }}</div>
<div class="card-body">
@if (session('resent'))
<div class="alert alert-success" role="alert">
{{ __('A fresh verification link has been sent to your email address.') }}
</div>
@endif
{{ __('Before proceeding, please check your email for a verification link.') }}
{{ __('If you did not receive the email') }},
<form class="d-inline" method="POST" action="{{ route('verification.resend') }}">
@csrf
<button type="submit" class="btn btn-link p-0 m-0 align-baseline">{{ __('click here to request another') }}</button>.
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
+97
View File
@@ -0,0 +1,97 @@
@extends('layouts.app')
@section('content')
<h1 class="text-3xl font-bold text-indigo-700 mb-6">All Books</h1>
<form method="GET" action="{{ route('books.index') }}" class="bg-white rounded-lg shadow p-4 mb-6">
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700">Search</label>
<input type="text" name="q" value="{{ $filters['q'] ?? '' }}" placeholder="Title or description..." class="mt-1 w-full border-gray-300 rounded-md" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Category</label>
<select name="category" class="mt-1 w-full border-gray-300 rounded-md">
<option value="">All</option>
@foreach($categories as $cat)
<option value="{{ $cat->slug }}" {{ ($filters['category'] ?? '') == $cat->slug || ($filters['category'] ?? '') == (string)$cat->id ? 'selected' : '' }}>{{ $cat->name }}</option>
@endforeach
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700">Author</label>
<select name="author" class="mt-1 w-full border-gray-300 rounded-md">
<option value="">All</option>
@foreach($authors as $auth)
<option value="{{ $auth->slug }}" {{ ($filters['author'] ?? '') == $auth->slug || ($filters['author'] ?? '') == (string)$auth->id ? 'selected' : '' }}>{{ $auth->name }}</option>
@endforeach
</select>
</div>
<div class="grid grid-cols-2 gap-2">
<div>
<label class="block text-sm font-medium text-gray-700">From</label>
<input type="date" name="date_from" value="{{ $filters['date_from'] ?? '' }}" class="mt-1 w-full border-gray-300 rounded-md" />
</div>
<div>
<label class="block text-sm font-medium text-gray-700">To</label>
<input type="date" name="date_to" value="{{ $filters['date_to'] ?? '' }}" class="mt-1 w-full border-gray-300 rounded-md" />
</div>
</div>
</div>
<div class="mt-4 flex items-center gap-3">
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-md">Filter</button>
<a href="{{ route('books.index') }}" class="px-4 py-2 bg-gray-100 text-gray-800 rounded-md">Reset</a>
</div>
</form>
@if($books->count() === 0)
<div class="bg-white rounded-lg shadow p-6 text-center text-gray-600">No books found.</div>
@else
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
@foreach($books as $book)
<div class="bg-white rounded-lg shadow overflow-hidden">
@if($book->cover_image)
<img src="{{ $book->cover_image }}" alt="{{ $book->title }} cover" class="w-full h-48 object-cover" />
@else
<div class="w-full h-48 bg-gray-200 flex items-center justify-center text-gray-500">No Cover</div>
@endif
<div class="p-4">
<h2 class="text-lg font-semibold"><a href="{{ route('books.show', $book) }}" class="hover:underline">{{ $book->title }}</a></h2>
<p class="text-sm text-gray-600">
@if($book->authors && $book->authors->count())
{{ $book->authors->pluck('name')->join(', ') }}
@elseif($book->author)
{{ $book->author }}
@endif
</p>
@if($book->category)
<p class="text-xs text-gray-500 mt-1">Category: {{ $book->category->name }}</p>
@endif
@auth
<div class="mt-3">
@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="px-3 py-2 text-sm 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="px-3 py-2 text-sm bg-red-50 text-red-700 hover:bg-red-100 rounded-md">Remove</button>
</form>
@endif
</div>
@endauth
</div>
</div>
@endforeach
</div>
<div class="mt-6">
{{ $books->links() }}
</div>
@endif
@endsection
+184
View File
@@ -0,0 +1,184 @@
@extends('layouts.app')
@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">
<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
+38 -47
View File
@@ -1,49 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create Category - Open Text Summaries</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100">
<div class="container mx-auto px-4 py-8">
<div class="mb-6">
<h1 class="text-3xl font-bold text-indigo-700">Create New Category</h1>
</div>
@extends('layouts.app')
<div class="bg-white shadow-md rounded-lg p-6">
<form action="{{ route('categories.store') }}" method="POST">
@csrf
<div class="mb-4">
<label for="name" class="block text-gray-700 text-sm font-bold mb-2">Name:</label>
<input type="text" name="name" id="name" value="{{ old('name') }}"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('name') border-red-500 @enderror">
@error('name')
<p class="text-red-500 text-xs italic mt-1">{{ $message }}</p>
@enderror
</div>
<div class="mb-6">
<label for="description" class="block text-gray-700 text-sm font-bold mb-2">Description:</label>
<textarea name="description" id="description" rows="4"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('description') border-red-500 @enderror">{{ old('description') }}</textarea>
@error('description')
<p class="text-red-500 text-xs italic mt-1">{{ $message }}</p>
@enderror
</div>
<div class="flex items-center justify-between">
<button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
Create Category
</button>
<a href="{{ route('categories.index') }}" class="text-indigo-600 hover:text-indigo-800">
Cancel
</a>
</div>
</form>
</div>
@section('content')
<div class="mb-6">
<h1 class="text-3xl font-bold text-indigo-700">Create New Category</h1>
</div>
</body>
</html>
<div class="bg-white shadow-md rounded-lg p-6">
<form action="{{ route('categories.store') }}" method="POST">
@csrf
<div class="mb-4">
<label for="name" class="block text-gray-700 text-sm font-bold mb-2">Name:</label>
<input type="text" name="name" id="name" value="{{ old('name') }}"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('name') border-red-500 @enderror">
@error('name')
<p class="text-red-500 text-xs italic mt-1">{{ $message }}</p>
@enderror
</div>
<div class="mb-6">
<label for="description" class="block text-gray-700 text-sm font-bold mb-2">Description:</label>
<textarea name="description" id="description" rows="4"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('description') border-red-500 @enderror">{{ old('description') }}</textarea>
@error('description')
<p class="text-red-500 text-xs italic mt-1">{{ $message }}</p>
@enderror
</div>
<div class="flex items-center justify-between">
<button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
Create Category
</button>
<a href="{{ route('categories.index') }}" class="text-indigo-600 hover:text-indigo-800">
Cancel
</a>
</div>
</form>
</div>
@endsection
+39 -48
View File
@@ -1,50 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Category - Open Text Summaries</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100">
<div class="container mx-auto px-4 py-8">
<div class="mb-6">
<h1 class="text-3xl font-bold text-indigo-700">Edit Category</h1>
</div>
@extends('layouts.app')
<div class="bg-white shadow-md rounded-lg p-6">
<form action="{{ route('categories.update', $category) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-4">
<label for="name" class="block text-gray-700 text-sm font-bold mb-2">Name:</label>
<input type="text" name="name" id="name" value="{{ old('name', $category->name) }}"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('name') border-red-500 @enderror">
@error('name')
<p class="text-red-500 text-xs italic mt-1">{{ $message }}</p>
@enderror
</div>
<div class="mb-6">
<label for="description" class="block text-gray-700 text-sm font-bold mb-2">Description:</label>
<textarea name="description" id="description" rows="4"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('description') border-red-500 @enderror">{{ old('description', $category->description) }}</textarea>
@error('description')
<p class="text-red-500 text-xs italic mt-1">{{ $message }}</p>
@enderror
</div>
<div class="flex items-center justify-between">
<button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
Update Category
</button>
<a href="{{ route('categories.index') }}" class="text-indigo-600 hover:text-indigo-800">
Cancel
</a>
</div>
</form>
</div>
@section('content')
<div class="mb-6">
<h1 class="text-3xl font-bold text-indigo-700">Edit Category</h1>
</div>
</body>
</html>
<div class="bg-white shadow-md rounded-lg p-6">
<form action="{{ route('categories.update', $category) }}" method="POST">
@csrf
@method('PUT')
<div class="mb-4">
<label for="name" class="block text-gray-700 text-sm font-bold mb-2">Name:</label>
<input type="text" name="name" id="name" value="{{ old('name', $category->name) }}"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('name') border-red-500 @enderror">
@error('name')
<p class="text-red-500 text-xs italic mt-1">{{ $message }}</p>
@enderror
</div>
<div class="mb-6">
<label for="description" class="block text-gray-700 text-sm font-bold mb-2">Description:</label>
<textarea name="description" id="description" rows="4"
class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline @error('description') border-red-500 @enderror">{{ old('description', $category->description) }}</textarea>
@error('description')
<p class="text-red-500 text-xs italic mt-1">{{ $message }}</p>
@enderror
</div>
<div class="flex items-center justify-between">
<button type="submit" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">
Update Category
</button>
<a href="{{ route('categories.index') }}" class="text-indigo-600 hover:text-indigo-800">
Cancel
</a>
</div>
</form>
</div>
@endsection
+63 -72
View File
@@ -1,74 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Categories - Open Text Summaries</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100">
<div class="container mx-auto px-4 py-8">
<div class="flex justify-between items-center mb-6">
<h1 class="text-3xl font-bold text-indigo-700">Categories</h1>
<a href="{{ route('categories.create') }}" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded">
Add New Category
</a>
</div>
@extends('layouts.app')
@if (session('success'))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4" role="alert">
<span class="block sm:inline">{{ session('success') }}</span>
</div>
@endif
<div class="bg-white shadow-md rounded-lg overflow-hidden">
<table class="min-w-full bg-white">
<thead class="bg-gray-100 text-gray-600 uppercase text-sm leading-normal">
<tr>
<th class="py-3 px-6 text-left">Name</th>
<th class="py-3 px-6 text-left">Description</th>
<th class="py-3 px-6 text-center">Actions</th>
</tr>
</thead>
<tbody class="text-gray-600 text-sm">
@forelse ($categories as $category)
<tr class="border-b border-gray-200 hover:bg-gray-50">
<td class="py-3 px-6 text-left">
<div class="font-medium">{{ $category->name }}</div>
</td>
<td class="py-3 px-6 text-left">
<div>{{ Str::limit($category->description, 100) }}</div>
</td>
<td class="py-3 px-6 text-center">
<div class="flex justify-center">
<a href="{{ route('categories.show', $category) }}" class="text-blue-500 hover:text-blue-700 mx-1">
View
</a>
<a href="{{ route('categories.edit', $category) }}" class="text-yellow-500 hover:text-yellow-700 mx-1">
Edit
</a>
<form action="{{ route('categories.destroy', $category) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="text-red-500 hover:text-red-700 mx-1" onclick="return confirm('Are you sure you want to delete this category?')">
Delete
</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="3" class="py-3 px-6 text-center">No categories found</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="mt-6">
<a href="/" class="text-indigo-600 hover:text-indigo-800">Back to Home</a>
</div>
@section('content')
<div class="flex justify-between items-center mb-6">
<h1 class="text-3xl font-bold text-indigo-700">Categories</h1>
<a href="{{ route('categories.create') }}" class="bg-indigo-600 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded">
Add New Category
</a>
</div>
</body>
</html>
@if (session('success'))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded relative mb-4" role="alert">
<span class="block sm:inline">{{ session('success') }}</span>
</div>
@endif
<div class="bg-white shadow-md rounded-lg overflow-hidden">
<table class="min-w-full bg-white">
<thead class="bg-gray-100 text-gray-600 uppercase text-sm leading-normal">
<tr>
<th class="py-3 px-6 text-left">Name</th>
<th class="py-3 px-6 text-left">Description</th>
<th class="py-3 px-6 text-center">Actions</th>
</tr>
</thead>
<tbody class="text-gray-600 text-sm">
@forelse ($categories as $category)
<tr class="border-b border-gray-200 hover:bg-gray-50">
<td class="py-3 px-6 text-left">
<div class="font-medium">{{ $category->name }}</div>
</td>
<td class="py-3 px-6 text-left">
<div>{{ Str::limit($category->description, 100) }}</div>
</td>
<td class="py-3 px-6 text-center">
<div class="flex justify-center">
<a href="{{ route('categories.show', $category) }}" class="text-blue-500 hover:text-blue-700 mx-1">
View
</a>
<a href="{{ route('categories.edit', $category) }}" class="text-yellow-500 hover:text-yellow-700 mx-1">
Edit
</a>
<form action="{{ route('categories.destroy', $category) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="text-red-500 hover:text-red-700 mx-1" onclick="return confirm('Are you sure you want to delete this category?')">
Delete
</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="3" class="py-3 px-6 text-center">No categories found</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div class="mt-6">
<a href="/" class="text-indigo-600 hover:text-indigo-800">Back to Home</a>
</div>
@endsection
+50 -59
View File
@@ -1,65 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ $category->name }} - Open Text Summaries</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100">
<div class="container mx-auto px-4 py-8">
<div class="mb-6">
<h1 class="text-3xl font-bold text-indigo-700">{{ $category->name }}</h1>
@extends('layouts.app')
@section('content')
<div class="mb-6">
<h1 class="text-3xl font-bold text-indigo-700">{{ $category->name }}</h1>
</div>
<div class="bg-white shadow-md rounded-lg p-6 mb-6">
<h2 class="text-xl font-semibold mb-4">Category Details</h2>
<div class="mb-4">
<p class="text-gray-700"><span class="font-semibold">Name:</span> {{ $category->name }}</p>
</div>
<div class="bg-white shadow-md rounded-lg p-6 mb-6">
<h2 class="text-xl font-semibold mb-4">Category Details</h2>
<div class="mb-4">
<p class="text-gray-700"><span class="font-semibold">Name:</span> {{ $category->name }}</p>
</div>
<div class="mb-4">
<p class="text-gray-700"><span class="font-semibold">Description:</span></p>
<p class="text-gray-700 mt-2">{{ $category->description }}</p>
</div>
<div class="flex mt-6">
<a href="{{ route('categories.edit', $category) }}" class="bg-yellow-500 hover:bg-yellow-600 text-white font-bold py-2 px-4 rounded mr-2">
Edit
</a>
<form action="{{ route('categories.destroy', $category) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded" onclick="return confirm('Are you sure you want to delete this category?')">
Delete
</button>
</form>
</div>
<div class="mb-4">
<p class="text-gray-700"><span class="font-semibold">Description:</span></p>
<p class="text-gray-700 mt-2">{{ $category->description }}</p>
</div>
<div class="bg-white shadow-md rounded-lg p-6">
<h2 class="text-xl font-semibold mb-4">Books in this Category</h2>
@if($category->books->count() > 0)
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
@foreach($category->books as $book)
<div class="border rounded-lg p-4 hover:shadow-md transition-shadow">
<h3 class="font-bold text-lg mb-1">{{ $book->title }}</h3>
<p class="text-gray-600 text-sm mb-2">By {{ $book->author }}</p>
<p class="text-gray-700 mb-3">{{ Str::limit($book->description, 100) }}</p>
<a href="{{ route('books.show', $book) }}" class="text-indigo-600 hover:text-indigo-800">View Details →</a>
</div>
@endforeach
</div>
@else
<p class="text-gray-700">No books found in this category.</p>
@endif
</div>
<div class="mt-6">
<a href="{{ route('categories.index') }}" class="text-indigo-600 hover:text-indigo-800">Back to Categories</a>
<div class="flex mt-6">
<a href="{{ route('categories.edit', $category) }}" class="bg-yellow-500 hover:bg-yellow-600 text-white font-bold py-2 px-4 rounded mr-2">
Edit
</a>
<form action="{{ route('categories.destroy', $category) }}" method="POST" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded" onclick="return confirm('Are you sure you want to delete this category?')">
Delete
</button>
</form>
</div>
</div>
</body>
</html>
<div class="bg-white shadow-md rounded-lg p-6">
<h2 class="text-xl font-semibold mb-4">Books in this Category</h2>
@if($category->books->count() > 0)
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
@foreach($category->books as $book)
<div class="border rounded-lg p-4 hover:shadow-md transition-shadow">
<h3 class="font-bold text-lg mb-1">{{ $book->title }}</h3>
<p class="text-gray-600 text-sm mb-2">By {{ $book->author }}</p>
<p class="text-gray-700 mb-3">{{ Str::limit($book->description, 100) }}</p>
<a href="{{ route('books.show', $book) }}" class="text-indigo-600 hover:text-indigo-800">View Details →</a>
</div>
@endforeach
</div>
@else
<p class="text-gray-700">No books found in this category.</p>
@endif
</div>
<div class="mt-6">
<a href="{{ route('categories.index') }}" class="text-indigo-600 hover:text-indigo-800">Back to Categories</a>
</div>
@endsection
+127
View File
@@ -0,0 +1,127 @@
@extends('layouts.app')
@section('content')
<div>
<div class="mb-6">
<h1 class="text-3xl font-bold text-indigo-700">Dashboard</h1>
<p class="text-gray-600 mt-1">Welcome back, {{ auth()->user()->name }}. Here are your reading stats.</p>
</div>
@if (session('status'))
<div class="bg-green-50 text-green-800 border border-green-200 rounded-md px-4 py-2 mb-4">
{{ session('status') }}
</div>
@endif
<!-- Stat cards -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-4 mb-8">
<div class="bg-white rounded-xl border border-gray-100 shadow p-5">
<div class="text-sm text-gray-500">Readlist items</div>
<div class="mt-2 text-3xl font-bold text-gray-800">{{ $readlistCount ?? 0 }}</div>
</div>
<div class="bg-white rounded-xl border border-gray-100 shadow p-5">
<div class="text-sm text-gray-500">Summaries in Readlist</div>
<div class="mt-2 text-3xl font-bold text-gray-800">{{ $readlistWithSummaryCount ?? 0 }}</div>
</div>
<div class="bg-white rounded-xl border border-gray-100 shadow p-5">
<div class="text-sm text-gray-500">Reviews written</div>
<div class="mt-2 text-3xl font-bold text-gray-800">{{ $reviewsCount ?? 0 }}</div>
</div>
<div class="bg-white rounded-xl border border-gray-100 shadow p-5">
<div class="text-sm text-gray-500">Reports submitted</div>
<div class="mt-2 text-3xl font-bold text-gray-800">{{ $reportsCount ?? 0 }}</div>
</div>
<div class="bg-white rounded-xl border border-gray-100 shadow p-5">
<div class="text-sm text-gray-500">Summary requests</div>
<div class="mt-2 text-3xl font-bold text-gray-800">{{ $requestsCount ?? 0 }}</div>
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Recent Readlist -->
<div class="bg-white rounded-xl border border-gray-100 shadow overflow-hidden">
<div class="px-5 py-4 border-b border-gray-100 flex items-center justify-between">
<h2 class="text-lg font-semibold">Recently added to Readlist</h2>
<a class="text-sm text-indigo-600 hover:underline" href="{{ route('readlist.index') }}">View all</a>
</div>
<div class="divide-y divide-gray-100">
@forelse(($latestReadlist ?? []) as $book)
<a href="{{ route('books.show', $book) }}" class="flex items-center gap-4 px-5 py-3 hover:bg-gray-50">
@if($book->cover_image)
<img src="{{ $book->cover_image }}" alt="{{ $book->title }} cover" class="w-10 h-14 object-cover rounded">
@else
<div class="w-10 h-14 bg-gray-200 rounded"></div>
@endif
<div class="min-w-0">
<div class="font-medium text-gray-800 truncate">{{ $book->title }}</div>
<div class="text-xs text-gray-500 truncate">
@if($book->authors && $book->authors->count())
{{ $book->authors->pluck('name')->join(', ') }}
@elseif($book->author)
{{ $book->author }}
@endif
@if($book->summary)
<span class="ml-2 inline-block px-2 py-0.5 text-[10px] bg-green-50 text-green-700 rounded">Has summary</span>
@endif
</div>
</div>
</a>
@empty
<div class="px-5 py-6 text-gray-600">No items yet. <a href="{{ route('books.index') }}" class="text-indigo-600 hover:underline">Browse books</a>.</div>
@endforelse
</div>
</div>
<!-- Your Reviews -->
<div class="bg-white rounded-xl border border-gray-100 shadow overflow-hidden">
<div class="px-5 py-4 border-b border-gray-100 flex items-center justify-between">
<h2 class="text-lg font-semibold">Your latest reviews</h2>
</div>
<div class="divide-y divide-gray-100">
@forelse(($latestReviews ?? []) as $review)
<a href="{{ route('books.show', $review->book) }}" class="block px-5 py-3 hover:bg-gray-50">
<div class="flex items-center justify-between">
<div class="font-medium text-gray-800">{{ $review->book->title }}</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)
<div class="mt-1 text-sm text-gray-600 line-clamp-2">{{ $review->comment }}</div>
@endif
<div class="mt-1 text-xs text-gray-500">{{ $review->created_at->diffForHumans() }}</div>
</a>
@empty
<div class="px-5 py-6 text-gray-600">You haven't left any reviews yet.</div>
@endforelse
</div>
</div>
<!-- Summary Requests -->
<div class="bg-white rounded-xl border border-gray-100 shadow overflow-hidden">
<div class="px-5 py-4 border-b border-gray-100 flex items-center justify-between">
<h2 class="text-lg font-semibold">Your summary requests</h2>
<a class="text-sm text-indigo-600 hover:underline" href="{{ route('requests.index') }}">All requests</a>
</div>
<div class="divide-y divide-gray-100">
@forelse(($latestRequests ?? []) as $r)
<div class="px-5 py-3">
<div class="flex items-center justify-between">
<div>
<div class="font-medium text-gray-800">Gutenberg #{{ $r->gutenberg_id }}</div>
<div class="text-sm text-gray-600">{{ $r->title ?? '—' }}</div>
</div>
<span class="inline-flex items-center px-2 py-1 rounded text-xs {{ $r->status === 'pending' ? 'bg-yellow-50 text-yellow-800' : ($r->status === 'completed' ? 'bg-green-50 text-green-800' : 'bg-gray-100 text-gray-700') }}">{{ ucfirst($r->status) }}</span>
</div>
<div class="mt-1 text-xs text-gray-500">{{ $r->created_at->diffForHumans() }}</div>
</div>
@empty
<div class="px-5 py-6 text-gray-600">No requests yet. <a href="{{ route('requests.create') }}" class="text-indigo-600 hover:underline">Request a summary</a>.</div>
@endforelse
</div>
</div>
</div>
</div>
@endsection
+127
View File
@@ -0,0 +1,127 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-D5Z2BTSK43"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-D5Z2BTSK43');
</script>
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'OpenTextSummaries') }}</title>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=instrument-sans:400,500,600|playfair-display:700" rel="stylesheet" />
<!-- Tailwind CSS (CDN) to ensure modern styling regardless of Vite build) -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Vite (JS and any additional assets) -->
@if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot')))
@vite(['resources/css/app.css', 'resources/js/app.js'])
@endif
</head>
<body class="bg-gray-50 text-gray-900 min-h-screen">
<div id="app" class="flex flex-col min-h-screen">
<!-- Header -->
<header class="bg-white/80 backdrop-blur border-b border-gray-100">
<div class="container mx-auto px-4">
<div class="flex items-center justify-between py-4">
<a href="{{ url('/') }}" class="flex items-center gap-2">
<svg class="w-8 h-8 text-indigo-600" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 6.25278V19.2528M12 6.25278C10.8321 5.47686 9.24649 5 7.5 5C5.75351 5 4.16789 5.47686 3 6.25278V19.2528C4.16789 18.4769 5.75351 18 7.5 18C9.24649 18 10.8321 18.4769 12 19.2528M12 6.25278C13.1679 5.47686 14.7535 5 16.5 5C18.2465 5 19.8321 5.47686 21 6.25278V19.2528C19.8321 18.4769 18.2465 18 16.5 18C14.7535 18 13.1679 18.4769 12 19.2528" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span class="text-xl font-bold text-indigo-700">{{ config('app.name', 'OpenTextSummaries') }}</span>
</a>
<nav class="flex items-center gap-6">
<a href="{{ route('books.index') }}" class="text-sm font-medium text-gray-700 hover:text-indigo-600">All Books</a>
@auth
<a href="{{ route('readlist.index') }}" class="text-sm font-medium text-gray-700 hover:text-indigo-600">Readlist</a>
<a href="{{ route('requests.create') }}" class="text-sm font-medium text-gray-700 hover:text-indigo-600">Request Summary</a>
@endauth
@guest
@if (Route::has('login'))
<a href="{{ route('login') }}" class="text-sm font-medium text-gray-700 hover:text-indigo-600">Login</a>
@endif
@if (Route::has('register'))
<a href="{{ route('register') }}" class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-lg text-sm font-semibold shadow-sm transition-colors">Register</a>
@endif
@else
<div class="relative" x-data="{ open:false }">
<button @click="open=!open" class="flex items-center gap-2 text-sm font-medium text-gray-700 hover:text-indigo-600">
<span>{{ Auth::user()->name }}</span>
<svg class="w-4 h-4" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 10.94l3.71-3.71a.75.75 0 111.06 1.06l-4.24 4.24a.75.75 0 01-1.06 0L5.21 8.29a.75.75 0 01.02-1.08z" clip-rule="evenodd" /></svg>
</button>
<div x-show="open" @click.outside="open=false" class="absolute right-0 mt-2 w-40 bg-white border border-gray-100 rounded-lg shadow-lg py-1 z-10">
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-50" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">Logout</a>
</div>
</div>
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="hidden">
@csrf
</form>
@endguest
</nav>
</div>
</div>
</header>
<!-- Main content -->
<main class="flex-1 py-8">
<div class="container mx-auto px-4">
@yield('content')
</div>
</main>
<!-- Footer -->
<footer class="bg-white border-t border-gray-100 py-8">
<div class="container mx-auto px-4 flex flex-col md:flex-row items-center justify-between gap-4">
<div class="flex items-center gap-2 text-gray-700">
<svg class="w-6 h-6 text-indigo-600" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 6.25278V19.2528M12 6.25278C10.8321 5.47686 9.24649 5 7.5 5C5.75351 5 4.16789 5.47686 3 6.25278V19.2528C4.16789 18.4769 5.75351 18 7.5 18C9.24649 18 10.8321 18.4769 12 19.2528M12 6.25278C13.1679 5.47686 14.7535 5 16.5 5C18.2465 5 19.8321 5.47686 21 6.25278V19.2528C19.8321 18.4769 18.2465 18 16.5 18C14.7535 18 13.1679 18.4769 12 19.2528" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span class="font-semibold">{{ config('app.name', 'OpenTextSummaries') }}</span>
</div>
<div class="flex items-center gap-6 text-sm">
<a href="{{ route('about') }}" class="text-gray-600 hover:text-indigo-600">About</a>
<a href="{{ route('contact.show') }}" class="text-gray-600 hover:text-indigo-600">Contact</a>
<a href="{{ route('privacy') }}" class="text-gray-600 hover:text-indigo-600">Privacy</a>
<a href="{{ route('terms') }}" class="text-gray-600 hover:text-indigo-600">Terms</a>
</div>
<p class="text-sm text-gray-500">&copy; {{ date('Y') }} {{ config('app.name', 'OpenTextSummaries') }}. All rights reserved.</p>
</div>
</footer>
</div>
<!-- Small Alpine-like dropdown (uses minimal inline Alpine substitute) -->
<script>
// Minimal dropdown handler for the user menu without adding full Alpine dependency.
document.addEventListener('click', (e) => {
document.querySelectorAll('[x-data] [x-show]')?.forEach(menu => {
if (!menu.parentElement.contains(e.target)) {
menu.style.display = 'none';
}
});
});
document.querySelectorAll('[x-data] button')?.forEach(btn => {
btn.addEventListener('click', (e) => {
const menu = btn.parentElement.querySelector('[x-show]');
if (menu) {
e.stopPropagation();
menu.style.display = (menu.style.display === 'block') ? 'none' : 'block';
}
});
});
</script>
</body>
</html>
+49
View File
@@ -0,0 +1,49 @@
@extends('layouts.app')
@section('content')
<div class="flex items-center justify-between mb-6">
<h1 class="text-3xl font-bold text-indigo-700">My Readlist</h1>
</div>
@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($books->count() === 0)
<div class="bg-white rounded-lg shadow p-6 text-center text-gray-600">
Your readlist is empty. Browse <a class="text-indigo-600 hover:underline" href="{{ route('books.index') }}">all books</a> to add some.
</div>
@else
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
@foreach($books as $book)
<div class="bg-white rounded-lg shadow overflow-hidden">
@if($book->cover_image)
<img src="{{ $book->cover_image }}" alt="{{ $book->title }} cover" class="w-full h-48 object-cover" />
@else
<div class="w-full h-48 bg-gray-200 flex items-center justify-center text-gray-500">No Cover</div>
@endif
<div class="p-4">
<h2 class="text-lg font-semibold"><a href="{{ route('books.show', $book) }}" class="hover:underline">{{ $book->title }}</a></h2>
<p class="text-sm text-gray-600">
@if($book->authors && $book->authors->count())
{{ $book->authors->pluck('name')->join(', ') }}
@elseif($book->author)
{{ $book->author }}
@endif
</p>
<form action="{{ route('readlist.destroy', $book) }}" method="POST" class="mt-4">
@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">Remove</button>
</form>
</div>
</div>
@endforeach
</div>
<div class="mt-6">
{{ $books->links() }}
</div>
@endif
@endsection
+51
View File
@@ -0,0 +1,51 @@
@extends('layouts.app')
@section('content')
<div class="max-w-2xl mx-auto">
<h1 class="text-3xl font-bold text-indigo-700 mb-4">Request a Book Summary</h1>
<div class="bg-white rounded-xl shadow p-6">
@if ($errors->any())
<div class="mb-4 rounded-md bg-red-50 border border-red-200 text-red-800 p-3">
<ul class="list-disc list-inside text-sm">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form action="{{ route('requests.store') }}" method="POST" class="space-y-4">
@csrf
<div>
<label class="block text-sm font-medium text-gray-700" for="gutenberg">Project Gutenberg URL or ID</label>
<input id="gutenberg" name="gutenberg" type="text" value="{{ old('gutenberg', $gutenberg ?? '') }}" required class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 @error('gutenberg') border-red-500 focus:border-red-500 focus:ring-red-500 @enderror" placeholder="e.g. https://www.gutenberg.org/ebooks/1342 or 1342">
<p class="mt-1 text-xs text-gray-500">Paste the Project Gutenberg URL for the book you want summarized, or just its numeric ID.</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700" for="title">Book title (optional)</label>
<input id="title" name="title" type="text" value="{{ old('title', $title ?? '') }}" class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700" for="notes">Notes (optional)</label>
<textarea id="notes" name="notes" rows="4" class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500">{{ old('notes') }}</textarea>
<p class="mt-1 text-xs text-gray-500">Add any context or what you are most interested in (themes, characters, key insights, etc.).</p>
</div>
<div>
<button type="submit" class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-md">Submit request</button>
<a href="{{ route('requests.index') }}" class="ml-3 text-indigo-600 hover:underline">My requests</a>
</div>
</form>
<div class="mt-6 p-4 bg-indigo-50 border border-indigo-100 rounded-lg">
<p class="text-sm text-indigo-900">
Books featured on this site are sourced from <a href="https://www.gutenberg.org/" class="text-indigo-700 underline" target="_blank" rel="noopener">Project Gutenberg</a> and are part of the public domain. Summaries are generated using AI and may contain inaccuracies.
</p>
</div>
</div>
</div>
@endsection
+58
View File
@@ -0,0 +1,58 @@
@extends('layouts.app')
@section('content')
<div class="max-w-4xl mx-auto">
<div class="flex items-center justify-between mb-6">
<h1 class="text-3xl font-bold text-indigo-700">My Summary Requests</h1>
<a href="{{ route('requests.create') }}" class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-md">New request</a>
</div>
@if (session('success'))
<div class="mb-4 rounded-md bg-green-50 border border-green-200 text-green-800 p-3">
{{ session('success') }}
</div>
@endif
@if($requests->count() === 0)
<div class="bg-white rounded-lg shadow p-6 text-center text-gray-600">
You haven't requested any summaries yet.
</div>
@else
<div class="bg-white rounded-lg shadow overflow-hidden">
<table class="min-w-full">
<thead class="bg-gray-50">
<tr class="text-left text-sm text-gray-600">
<th class="px-4 py-3">Gutenberg ID</th>
<th class="px-4 py-3">Title</th>
<th class="px-4 py-3">Status</th>
<th class="px-4 py-3">Requested</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@foreach($requests as $r)
<tr class="text-sm">
<td class="px-4 py-3">
<a href="https://www.gutenberg.org/ebooks/{{ $r->gutenberg_id }}" target="_blank" rel="noopener" class="text-indigo-600 hover:underline">{{ $r->gutenberg_id }}</a>
</td>
<td class="px-4 py-3">{{ $r->title ?? '—' }}</td>
<td class="px-4 py-3">
<span class="inline-flex items-center px-2 py-1 rounded text-xs {{ $r->status === 'pending' ? 'bg-yellow-50 text-yellow-800' : ($r->status === 'completed' ? 'bg-green-50 text-green-800' : 'bg-gray-100 text-gray-700') }}">{{ ucfirst($r->status) }}</span>
</td>
<td class="px-4 py-3 text-gray-500">{{ $r->created_at->diffForHumans() }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="mt-4">
{{ $requests->links() }}
</div>
@endif
<div class="mt-6 p-4 bg-indigo-50 border border-indigo-100 rounded-lg">
<p class="text-sm text-indigo-900">
Books featured on this site are sourced from <a href="https://www.gutenberg.org/" class="text-indigo-700 underline" target="_blank" rel="noopener">Project Gutenberg</a> and are part of the public domain. Summaries are generated using AI and may contain inaccuracies.
</p>
</div>
</div>
@endsection
+17
View File
@@ -0,0 +1,17 @@
@extends('layouts.app')
@section('content')
<div class="max-w-3xl mx-auto">
<h1 class="text-3xl font-bold text-indigo-700 mb-4">About</h1>
<div class="prose max-w-none bg-white rounded-xl shadow p-6">
<p>Welcome to {{ config('app.name', 'OpenTextSummaries') }} — a place to quickly learn from books through concise summaries.</p>
<p class="mt-4 text-gray-700">Our mission is to make knowledge accessible by providing brief, readable takeaways from great works.</p>
<div class="mt-6 p-4 bg-indigo-50 border border-indigo-100 rounded-lg">
<p class="text-sm text-indigo-900">
Books featured on this site are sourced from <a href="https://www.gutenberg.org/" class="text-indigo-700 underline" target="_blank" rel="noopener">Project Gutenberg</a> and are part of the public domain. Summaries are generated using AI and may contain inaccuracies.
</p>
</div>
</div>
</div>
@endsection
+52
View File
@@ -0,0 +1,52 @@
@extends('layouts.app')
@section('content')
<div class="max-w-xl mx-auto">
<h1 class="text-3xl font-bold text-indigo-700 mb-4">Contact</h1>
<div class="bg-white rounded-xl shadow p-6">
@if (session('success'))
<div class="mb-4 rounded-md bg-green-50 border border-green-200 text-green-800 p-3">
{{ session('success') }}
</div>
@endif
<form action="{{ route('contact.send') }}" method="POST" class="space-y-4">
@csrf
<div>
<label class="block text-sm font-medium text-gray-700" for="name">Your name</label>
<input id="name" name="name" type="text" value="{{ old('name') }}" required class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 @error('name') border-red-500 focus:border-red-500 focus:ring-red-500 @enderror">
@error('name')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label class="block text-sm font-medium text-gray-700" for="email">Your email</label>
<input id="email" name="email" type="email" value="{{ old('email') }}" required class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 @error('email') border-red-500 focus:border-red-500 focus:ring-red-500 @enderror">
@error('email')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<label class="block text-sm font-medium text-gray-700" for="message">Message</label>
<textarea id="message" name="message" rows="6" required class="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 @error('message') border-red-500 focus:border-red-500 focus:ring-red-500 @enderror">{{ old('message') }}</textarea>
@error('message')
<p class="mt-1 text-sm text-red-600">{{ $message }}</p>
@enderror
</div>
<div>
<button type="submit" class="px-4 py-2 bg-indigo-600 hover:bg-indigo-700 text-white rounded-md">Send</button>
</div>
</form>
<div class="mt-6 p-4 bg-indigo-50 border border-indigo-100 rounded-lg">
<p class="text-sm text-indigo-900">
Books featured on this site are sourced from <a href="https://www.gutenberg.org/" class="text-indigo-700 underline" target="_blank" rel="noopener">Project Gutenberg</a> and are part of the public domain. Summaries are generated using AI and may contain inaccuracies.
</p>
</div>
</div>
</div>
@endsection
+17
View File
@@ -0,0 +1,17 @@
@extends('layouts.app')
@section('content')
<div class="max-w-3xl mx-auto">
<h1 class="text-3xl font-bold text-indigo-700 mb-4">Privacy Policy</h1>
<div class="prose max-w-none bg-white rounded-xl shadow p-6">
<p>Your privacy matters to us. We collect only the information necessary to provide and improve our services, such as account details you voluntarily provide.</p>
<p class="mt-2">We do not sell your personal information. For questions, please contact us via the contact page.</p>
<div class="mt-6 p-4 bg-indigo-50 border border-indigo-100 rounded-lg">
<p class="text-sm text-indigo-900">
Books featured on this site are sourced from <a href="https://www.gutenberg.org/" class="text-indigo-700 underline" target="_blank" rel="noopener">Project Gutenberg</a> and are part of the public domain. Summaries are generated using AI and may contain inaccuracies.
</p>
</div>
</div>
</div>
@endsection
+17
View File
@@ -0,0 +1,17 @@
@extends('layouts.app')
@section('content')
<div class="max-w-3xl mx-auto">
<h1 class="text-3xl font-bold text-indigo-700 mb-4">Terms of Service</h1>
<div class="prose max-w-none bg-white rounded-xl shadow p-6">
<p>By using {{ config('app.name', 'OpenTextSummaries') }}, you agree to use the service responsibly and abide by applicable laws. We provide content "as is" without warranties of any kind.</p>
<p class="mt-2">We may update these terms from time to time. Continued use of the site constitutes acceptance of the revised terms.</p>
<div class="mt-6 p-4 bg-indigo-50 border border-indigo-100 rounded-lg">
<p class="text-sm text-indigo-900">
Books featured on this site are sourced from <a href="https://www.gutenberg.org/" class="text-indigo-700 underline" target="_blank" rel="noopener">Project Gutenberg</a> and are part of the public domain. Summaries are generated using AI and may contain inaccuracies.
</p>
</div>
</div>
</div>
@endsection
+58 -50
View File
@@ -4,12 +4,26 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-D5Z2BTSK43"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-D5Z2BTSK43');
</script>
<title>{{ config('app.name', 'Open Text Summaries') }}</title>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=instrument-sans:400,500,600|playfair-display:700" rel="stylesheet" />
<!-- Tailwind CSS (CDN) to ensure styling even without a build) -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Styles / Scripts -->
@if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot')))
@vite(['resources/css/app.css', 'resources/js/app.js'])
@@ -74,53 +88,47 @@
</section>
<section id="featured" class="max-w-6xl mx-auto mb-20">
<h3 class="text-3xl font-bold text-center text-indigo-700 dark:text-indigo-400 mb-10">Featured Summaries</h3>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
<!-- Book 1 -->
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-md overflow-hidden transition-transform duration-300 hover:shadow-lg hover:-translate-y-1">
<div class="h-48 bg-indigo-100 dark:bg-indigo-900 flex items-center justify-center">
<svg class="w-24 h-24 text-indigo-500 dark:text-indigo-400" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 6.25278V19.2528M12 6.25278C10.8321 5.47686 9.24649 5 7.5 5C5.75351 5 4.16789 5.47686 3 6.25278V19.2528C4.16789 18.4769 5.75351 18 7.5 18C9.24649 18 10.8321 18.4769 12 19.2528M12 6.25278C13.1679 5.47686 14.7535 5 16.5 5C18.2465 5 19.8321 5.47686 21 6.25278V19.2528C19.8321 18.4769 18.2465 18 16.5 18C14.7535 18 13.1679 18.4769 12 19.2528" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<div class="p-6">
<h4 class="text-xl font-bold text-gray-800 dark:text-white mb-2">Atomic Habits</h4>
<p class="text-sm text-gray-600 dark:text-gray-300 mb-3">James Clear</p>
<p class="text-gray-600 dark:text-gray-400 mb-4">Learn how tiny changes can lead to remarkable results through the power of atomic habits.</p>
<a href="#" class="text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:hover:text-indigo-300 font-medium">Read Summary →</a>
</div>
</div>
<!-- Book 2 -->
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-md overflow-hidden transition-transform duration-300 hover:shadow-lg hover:-translate-y-1">
<div class="h-48 bg-indigo-100 dark:bg-indigo-900 flex items-center justify-center">
<svg class="w-24 h-24 text-indigo-500 dark:text-indigo-400" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 6.25278V19.2528M12 6.25278C10.8321 5.47686 9.24649 5 7.5 5C5.75351 5 4.16789 5.47686 3 6.25278V19.2528C4.16789 18.4769 5.75351 18 7.5 18C9.24649 18 10.8321 18.4769 12 19.2528M12 6.25278C13.1679 5.47686 14.7535 5 16.5 5C18.2465 5 19.8321 5.47686 21 6.25278V19.2528C19.8321 18.4769 18.2465 18 16.5 18C14.7535 18 13.1679 18.4769 12 19.2528" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<div class="p-6">
<h4 class="text-xl font-bold text-gray-800 dark:text-white mb-2">Thinking, Fast and Slow</h4>
<p class="text-sm text-gray-600 dark:text-gray-300 mb-3">Daniel Kahneman</p>
<p class="text-gray-600 dark:text-gray-400 mb-4">Explore the two systems that drive the way we think and make decisions.</p>
<a href="#" class="text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:hover:text-indigo-300 font-medium">Read Summary →</a>
</div>
</div>
<!-- Book 3 -->
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-md overflow-hidden transition-transform duration-300 hover:shadow-lg hover:-translate-y-1">
<div class="h-48 bg-indigo-100 dark:bg-indigo-900 flex items-center justify-center">
<svg class="w-24 h-24 text-indigo-500 dark:text-indigo-400" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 6.25278V19.2528M12 6.25278C10.8321 5.47686 9.24649 5 7.5 5C5.75351 5 4.16789 5.47686 3 6.25278V19.2528C4.16789 18.4769 5.75351 18 7.5 18C9.24649 18 10.8321 18.4769 12 19.2528M12 6.25278C13.1679 5.47686 14.7535 5 16.5 5C18.2465 5 19.8321 5.47686 21 6.25278V19.2528C19.8321 18.4769 18.2465 18 16.5 18C14.7535 18 13.1679 18.4769 12 19.2528" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
<div class="p-6">
<h4 class="text-xl font-bold text-gray-800 dark:text-white mb-2">Sapiens</h4>
<p class="text-sm text-gray-600 dark:text-gray-300 mb-3">Yuval Noah Harari</p>
<p class="text-gray-600 dark:text-gray-400 mb-4">A brief history of humankind, from the emergence of Homo sapiens to the present day.</p>
<a href="#" class="text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:hover:text-indigo-300 font-medium">Read Summary →</a>
</div>
</div>
<div class="flex items-center justify-between mb-6">
<h3 class="text-3xl font-bold text-indigo-700 dark:text-indigo-400">Latest Books</h3>
<a href="{{ route('books.index') }}" class="text-indigo-600 dark:text-indigo-400 hover:underline">View all →</a>
</div>
@if(isset($latestBooks) && $latestBooks->count())
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
@foreach($latestBooks as $book)
<div class="bg-white dark:bg-gray-800 rounded-xl shadow-md overflow-hidden transition-transform duration-300 hover:shadow-lg hover:-translate-y-1">
@if($book->cover_image)
<img src="{{ $book->cover_image }}" alt="{{ $book->title }} cover" class="w-full h-48 object-cover" />
@else
<div class="h-48 bg-indigo-100 dark:bg-indigo-900 flex items-center justify-center">
<svg class="w-24 h-24 text-indigo-500 dark:text-indigo-400" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 6.25278V19.2528M12 6.25278C10.8321 5.47686 9.24649 5 7.5 5C5.75351 5 4.16789 5.47686 3 6.25278V19.2528C4.16789 18.4769 5.75351 18 7.5 18C9.24649 18 10.8321 18.4769 12 19.2528M12 6.25278C13.1679 5.47686 14.7535 5 16.5 5C18.2465 5 19.8321 5.47686 21 6.25278V19.2528C19.8321 18.4769 18.2465 18 16.5 18C14.7535 18 13.1679 18.4769 12 19.2528" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</div>
@endif
<div class="p-6">
<h4 class="text-xl font-bold text-gray-800 dark:text-white mb-2">
<a href="{{ route('books.show', $book) }}" class="hover:underline">{{ $book->title }}</a>
</h4>
<p class="text-sm text-gray-600 dark:text-gray-300 mb-3">
@if($book->authors && $book->authors->count())
{{ $book->authors->pluck('name')->join(', ') }}
@elseif($book->author)
{{ $book->author }}
@endif
</p>
@if($book->summary)
<p class="text-gray-600 dark:text-gray-400 mb-4">{{ Str::limit(strip_tags($book->summary->content), 120) }}</p>
@else
<p class="text-gray-600 dark:text-gray-400 mb-4">No summary available yet.</p>
@endif
<a href="{{ route('books.show', $book) }}" class="text-indigo-600 dark:text-indigo-400 hover:text-indigo-800 dark:hover:text-indigo-300 font-medium">Read Summary →</a>
</div>
</div>
@endforeach
</div>
@else
<p class="text-center text-gray-600 dark:text-gray-300">No books available yet. Ingest some via the API!</p>
@endif
</section>
<section id="how-it-works" class="max-w-4xl mx-auto mb-20">
@@ -171,10 +179,10 @@
<span class="ml-2 text-lg font-bold text-gray-800 dark:text-white">OpenTextSummaries</span>
</div>
<div class="flex gap-6">
<a href="#" class="text-gray-600 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400">About</a>
<a href="#" class="text-gray-600 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400">Contact</a>
<a href="#" class="text-gray-600 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400">Privacy</a>
<a href="#" class="text-gray-600 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400">Terms</a>
<a href="{{ route('about') }}" class="text-gray-600 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400">About</a>
<a href="{{ route('contact.show') }}" class="text-gray-600 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400">Contact</a>
<a href="{{ route('privacy') }}" class="text-gray-600 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400">Privacy</a>
<a href="{{ route('terms') }}" class="text-gray-600 dark:text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400">Terms</a>
</div>
</div>
<div class="mt-8 pt-8 border-t border-gray-200 dark:border-gray-800 text-center text-gray-500 dark:text-gray-400">
+61 -1
View File
@@ -4,11 +4,71 @@ use Illuminate\Support\Facades\Route;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\BookController;
use App\Http\Controllers\SummaryController;
use App\Http\Controllers\ReadlistController;
use App\Http\Controllers\StaticPageController;
use App\Http\Controllers\ContactController;
use App\Http\Controllers\SummaryReportController;
use App\Http\Controllers\SummaryRequestController;
use App\Http\Controllers\SummaryReviewController;
use App\Http\Controllers\SitemapController;
use App\Models\Book;
Route::get('/', function () {
return view('welcome');
$latestBooks = Book::with(['category', 'authors', 'summary'])
->orderBy('created_at', 'desc')
->limit(6)
->get();
return view('welcome', compact('latestBooks'));
});
// Static pages
Route::get('/about', [StaticPageController::class, 'about'])->name('about');
Route::get('/privacy', [StaticPageController::class, 'privacy'])->name('privacy');
Route::get('/terms', [StaticPageController::class, 'terms'])->name('terms');
// Contact
Route::get('/contact', [ContactController::class, 'show'])->name('contact.show');
Route::post('/contact', [ContactController::class, 'send'])->name('contact.send');
// Bind the {book} route parameter to resolve by slug or numeric ID (backward compatible)
Route::bind('book', function ($value) {
return App\Models\Book::where('slug', $value)
->orWhere(function ($q) use ($value) {
if (is_numeric($value)) {
$q->where('id', (int) $value);
}
})
->firstOrFail();
});
Route::resource('categories', CategoryController::class);
Route::resource('books', BookController::class);
Route::resource('summaries', SummaryController::class);
// Readlist + Reports + Requests routes
Route::middleware('auth')->group(function () {
Route::get('/readlist', [ReadlistController::class, 'index'])->name('readlist.index');
Route::post('/readlist/{book}', [ReadlistController::class, 'store'])->name('readlist.store');
Route::delete('/readlist/{book}', [ReadlistController::class, 'destroy'])->name('readlist.destroy');
// Summary reports
Route::post('/books/{book}/report', [SummaryReportController::class, 'store'])->name('summary-reports.store');
// Summary requests
Route::get('/requests', [SummaryRequestController::class, 'index'])->name('requests.index');
Route::get('/requests/create', [SummaryRequestController::class, 'create'])->name('requests.create');
Route::post('/requests', [SummaryRequestController::class, 'store'])->name('requests.store');
// Summary reviews
Route::post('/books/{book}/reviews', [SummaryReviewController::class, 'store'])->name('reviews.store');
Route::delete('/reviews/{review}', [SummaryReviewController::class, 'destroy'])->name('reviews.destroy');
});
Auth::routes();
// Dashboard route (alias for /home)
Route::get('/dashboard', [App\Http\Controllers\HomeController::class, 'index'])->name('dashboard');
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
// Sitemap
Route::get('/sitemap.xml', [SitemapController::class, 'index'])->name('sitemap');
+4 -3
View File
@@ -1,13 +1,14 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import tailwindcss from '@tailwindcss/vite';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
input: [
'resources/css/app.css',
'resources/js/app.js',
],
refresh: true,
}),
tailwindcss(),
],
});