-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6c231f
commit e09f370
Showing
15 changed files
with
24,367 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace App\Http\Resources; | ||
|
||
use App\Models\Book; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
/** @mixin Book */ | ||
class BookResource extends JsonResource | ||
{ | ||
/** | ||
* Transform the resource into an array. | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function toArray(Request $request): array | ||
{ | ||
return array_merge( | ||
[ | ||
"authors" => $this->authors | ||
->map(fn($author) => $author->name) | ||
->implode(", "), | ||
|
||
"formats" => $this->formats | ||
->mapWithKeys(fn($format) => [ | ||
$format->format => "/content/$this->path/$format->name." . strtolower($format->format) | ||
]) | ||
->toArray(), | ||
|
||
"tags" => $this->tags | ||
->map(fn($tag) => "#" . $tag->name) | ||
->take(5) | ||
->implode(", "), | ||
|
||
"title" => $this->title, | ||
"cover" => "/content/$this->path/cover.jpg", | ||
], | ||
$this->serieses->first() !== null ? | ||
["series" => "Book $this->series_index of " . $this->serieses->first()->name] | ||
: [] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Http\Views; | ||
|
||
use App\Http\Resources\BookResource; | ||
use App\Interfaces\ViewProvider; | ||
use App\Models\Book; | ||
use Illuminate\Http\Request; | ||
|
||
class BookViewProvider extends ViewProvider | ||
{ | ||
protected ?string $view = "books"; | ||
|
||
public function toArray(Request $request): array | ||
{ | ||
return [ | ||
"title" => "All books", | ||
"books" => BookResource::collection(Book::all())->toArray($request) | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\BelongsToMany; | ||
|
||
/** | ||
* | ||
* | ||
* @property int $id | ||
* @property \Illuminate\Support\Carbon|null $created_at | ||
* @property \Illuminate\Support\Carbon|null $updated_at | ||
* @property string $name | ||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Book> $books | ||
* @property-read int|null $books_count | ||
* @method static \Illuminate\Database\Eloquent\Builder|Shelf newModelQuery() | ||
* @method static \Illuminate\Database\Eloquent\Builder|Shelf newQuery() | ||
* @method static \Illuminate\Database\Eloquent\Builder|Shelf query() | ||
* @method static \Illuminate\Database\Eloquent\Builder|Shelf whereCreatedAt($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Shelf whereId($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Shelf whereName($value) | ||
* @method static \Illuminate\Database\Eloquent\Builder|Shelf whereUpdatedAt($value) | ||
* @mixin \Eloquent | ||
*/ | ||
class Shelf extends Model | ||
{ | ||
protected $table = "calibuh_shelves"; | ||
|
||
public function books(): BelongsToMany | ||
{ | ||
return $this->belongsToMany(Book::class, "calibuh_shelves_books", "shelf_id", "book_id"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\View\Component; | ||
|
||
class Book extends Component | ||
{ | ||
/** | ||
* Create a new component instance. | ||
*/ | ||
public function __construct( | ||
public array $book, | ||
) {} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
*/ | ||
public function render(): View|Closure|string | ||
{ | ||
return view("components.book"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\View\Component; | ||
|
||
class Footer extends Component | ||
{ | ||
/** | ||
* Create a new component instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
*/ | ||
public function render(): View|Closure|string | ||
{ | ||
return view('components.footer'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\View\Component; | ||
|
||
class Header extends Component | ||
{ | ||
/** | ||
* Create a new component instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
*/ | ||
public function render(): View|Closure|string | ||
{ | ||
return view("components.header"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\View\Components; | ||
|
||
use Closure; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\View\Component; | ||
|
||
class Page extends Component | ||
{ | ||
/** | ||
* Create a new component instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Get the view / contents that represent the component. | ||
*/ | ||
public function render(): View|Closure|string | ||
{ | ||
return view("components.page"); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
database/migrations/2024_07_19_152252_create_shelves_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?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("calibuh_shelves", function (Blueprint $table) { | ||
$table->id(); | ||
$table->timestamps(); | ||
$table->string("name"); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists("calibuh_shelves"); | ||
} | ||
}; |
27 changes: 27 additions & 0 deletions
27
database/migrations/2024_07_19_152823_create_shelves_relation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?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("calibuh_shelves_books", function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId("book_id")->constrained(table: "books"); | ||
$table->foreignId("shelf_id")->constrained(table: "calibuh_shelves"); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists("calibuh_shelves_books"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<div | ||
class="bg-card rounded-lg overflow-hidden shadow-lg hover:shadow-xl transition-shadow grid grid-cols-1" | ||
style="grid-template-rows: 8fr 2fr"> | ||
<a href="#"> | ||
<img | ||
loading="lazy" | ||
src="{{ $book["cover"] }}" | ||
alt="{{ $book["title"] }}" | ||
width="150" | ||
height="200" | ||
class="w-full h-[200px] object-cover" | ||
/> | ||
<div class="p-4"> | ||
<h3 class="text-lg font-bold mb-1 text-card-foreground">{{ $book["title"] }}</h3> | ||
@if(array_key_exists("series", $book)) | ||
<h4 class="text-base text-card-foreground">{{ $book["series"] }}</h4> | ||
@endif | ||
|
||
<p class="text-muted-foreground">{{ $book["authors"] }}</p> | ||
|
||
@if ($book["tags"]) | ||
<hr class="mt-2 mb-2"/> | ||
|
||
<p class="text-blue-700 text-muted-foreground">{{ $book["tags"] }}</p> | ||
@endif | ||
</div> | ||
</a> | ||
<div class="p-4 border-t grid grid-rows-{{ count($book["formats"]) }} grid-cols-1"> | ||
@foreach($book["formats"] as $format=>$url) | ||
<a | ||
href="{{ $url }}" | ||
class="inline-flex items-center gap-2 text-sm font-medium text-primary hover:underline" | ||
> | ||
<svg | ||
class="w-4 h-4" | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
stroke="currentColor" | ||
> | ||
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/> | ||
<polyline points="7 10 12 15 17 10"/> | ||
<line x1="12" x2="12" y1="15" y2="3"/> | ||
</svg> | ||
Download {{ $format }} | ||
</a> | ||
@endforeach | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<footer class="bg-muted border-t mt-8 py-6"> | ||
<div class="container mx-auto px-4 md:px-6 lg:px-8 flex flex-col md:flex-row items-center justify-between"> | ||
<p class="text-muted-foreground text-sm">© 2024 Oskar Manhart. All rights reserved.</p> | ||
<nav class="flex items-center gap-4 mt-4 md:mt-0"> | ||
<a href="#" class="text-muted-foreground hover:underline text-sm"> | ||
Privacy | ||
</a> | ||
<a href="#" class="text-muted-foreground hover:underline text-sm"> | ||
Terms | ||
</a> | ||
<a href="#" class="text-muted-foreground hover:underline text-sm"> | ||
Contact | ||
</a> | ||
</nav> | ||
</div> | ||
</footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<header class="bg-primary text-primary-foreground border-b shadow-sm sticky top-0 z-40"> | ||
<div class="ml-0 container mx-auto px-4 py-3 md:px-6 lg:px-8 flex items-center justify-between"> | ||
<a href="/" class="flex items-center gap-2 font-bold text-lg"> | ||
<svg | ||
class="w-6 h-6" | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
stroke="currentColor" | ||
> | ||
<path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"/> | ||
</svg> | ||
calibuh | ||
</a> | ||
|
||
<nav class="flex items-center gap-4"> | ||
<a href="/serieses" class="text-primary-foreground hover:underline"> | ||
Serieses | ||
</a> | ||
<a href="/shelves" class="text-primary-foreground hover:underline"> | ||
Shelves | ||
</a> | ||
</nav> | ||
|
||
<div class="relative flex-1 max-w-md"> | ||
<div class="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"></div> | ||
<input | ||
type="search" | ||
placeholder="Search books..." | ||
class="w-full rounded-lg bg-primary-foreground pl-8" | ||
/> | ||
</div> | ||
</div> | ||
</header> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html class="w-full h-full" lang="{{ str_replace("_", "-", app()->getLocale()) }}"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<title>calibuh</title> | ||
|
||
@vite("resources/css/app.css") | ||
</head> | ||
<body class="w-full h-full flex flex-col"> | ||
<x-header></x-header> | ||
|
||
<main class="mt-8 px-4 md:px-6 lg:px-8 flex-grow"> | ||
{{ $slot }} | ||
</main> | ||
|
||
<x-footer></x-footer> | ||
</body> | ||
</html> |