Skip to content

Commit dd83e7a

Browse files
committed
Merge branch 'main' into pr/208
2 parents c439848 + b64084e commit dd83e7a

File tree

867 files changed

+41649
-27669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

867 files changed

+41649
-27669
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ To set up your author profile, create a new file in the `content/authors` direct
2020
---
2121
name: Dan Harrin
2222
slug: dan-harrin
23-
avatar: dan-harrin.jpg
2423
github_url: https://github.com/danharrin
2524
twitter_url: https://twitter.com/danjharrin
2625
mastodon_url: https://phpc.social/@danharrin
@@ -30,8 +29,9 @@ sponsor_url: https://github.com/sponsors/danharrin
3029
Your bio should be written in Markdown here. In the future, we may introduce an Author page where people can see your contributions, so feel free to write a little about yourself. Please check the grammar and spelling of this description, preferably using [Grammarly](https://www.grammarly.com). It should be in full sentences.
3130
```
3231

32+
**Important: please upload an avatar to the `content/authors/avatars` directory. The file must be the same name as your slug. It must be square, at least 1000x1000 pixels in size, and preferably a JPEG.**
33+
3334
- The `slug` should match the current filename.
34-
- The `avatar` should be the name of a file in the `content/authors/avatars` directory. Your avatar must be square, at least 1000x1000 pixels in size, and preferably a JPEG.
3535
- The `github_url` should be a link to your GitHub profile.
3636
- The `twitter_url` should be a link to your Twitter profile. It is optional.
3737
- The `mastodon_url` should be a link to your Mastodon profile. It is optional.
@@ -53,12 +53,13 @@ docs_url: https://raw.githubusercontent.com/filamentphp/spatie-laravel-media-lib
5353
github_repository: filamentphp/spatie-laravel-media-library-plugin
5454
has_dark_theme: true
5555
has_translations: true
56-
image: filament-spatie-media-library.jpg
5756
versions: [2, 3]
5857
publish_date: 2023-08-01
5958
---
6059
```
6160

61+
**Important: please upload an image to the `content/plugins/images` directory. The file must be the same name as the plugin's slug. It must fit the 16:9 aspect ratio, at least 2560x1440 pixels in size, and preferably a JPEG. If your image is a screenshot of your plugin, please ensure that it is using a light theme and not a dark theme, to ensure it fits in with the rest of the website.**
62+
6263
Please note: Do not include the word "Filament" in the name of your plugin. This is redundant, as all plugins on the website are for Filament. Please do not include it in the slug or filename either - unless its part of your author name.
6364

6465
- The `slug` should match the current filename.
@@ -70,8 +71,6 @@ Please note: Do not include the word "Filament" in the name of your plugin. This
7071
- The `github_repository` should be the name of the GitHub repository where your plugin is hosted.
7172
- The `has_dark_theme` should be `true` if your plugin supports Tailwind's dark mode, or `false` if not.
7273
- The `has_translations` should be `true` if your plugin supports multiple languages, or `false` if not.
73-
- The `image` should be the name of a file in the `content/plugins/images` directory. The image must fit the 16:9 aspect ratio, at least 2560x1440 pixels in size, and preferably a JPEG. If your image is a screenshot of your plugin, please ensure that it is using a light theme and not a dark theme, to ensure it fits in with the rest of the website.
74-
- The `thumbnail` is optional, and is the name of a file in the `content/plugins/thumbnails directory` directory. The image must fit the 16:9 aspect ratio, at least 2560x1440 pixels in size, and preferably a JPEG. It will be used as a replacement for the `image` any time that the plugin is listed alongside others, and the size is smaller. If you do not provide a `thumbnail`, the `image` will be used instead.
7574
- The `versions` should be an array of Filament major versions that your plugin supports.
7675
- The `publish_date` is the date that you submitted the plugin to the website. It usually should be the date that you submitted the pull request for the plugin.
7776

@@ -144,3 +143,5 @@ error_page 404 /index.php;
144143
## Debugging missing content
145144

146145
If you are working on the website locally, and you notice that some Markdown-based content is missing, it is likely that it has not reached the cache yet. Please run `php artisan clear-orbit-cache` and `php artisan cache:clear`. If images aren't showing up, you probably also need to run `php artisan optimize-images`.
146+
147+
> You need to [install image optimization tools](https://github.com/spatie/image-optimizer#optimization-tools) before you can run `php artisan optimize-images`.

app/Actions/FetchPluginDataFromAnystack.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace App\Actions;
44

55
use App\Models\Plugin;
6-
use function Filament\Support\format_money;
76
use Illuminate\Support\Facades\Http;
87
use Throwable;
98

9+
use function Filament\Support\format_money;
10+
1011
class FetchPluginDataFromAnystack
1112
{
1213
public function __invoke(): void

app/Console/Commands/OptimizeImagesCommand.php

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
namespace App\Console\Commands;
44

55
use Illuminate\Console\Command;
6-
use Intervention\Image\ImageManagerStatic as Image;
6+
use Spatie\Image\Image;
7+
use Spatie\Image\Manipulations;
78
use Throwable;
89

910
class OptimizeImagesCommand extends Command
@@ -36,9 +37,19 @@ public function handle()
3637

3738
foreach ($files as $file) {
3839
try {
39-
Image::make(base_path("content/{$directory}/{$file}"))
40-
->fit(500, 500)
41-
->save(public_path("images/content/{$directory}/{$file}"), quality: 50);
40+
$webpFileName = pathinfo($file, PATHINFO_FILENAME) . '.webp';
41+
42+
if (file_exists(public_path("images/content/{$directory}/{$webpFileName}"))) {
43+
$this->warn("Skipped {$directory}/{$file}, already optimized.");
44+
45+
continue;
46+
}
47+
48+
Image::load(base_path("content/{$directory}/{$file}"))
49+
->fit(Manipulations::FIT_CONTAIN, 500, 500)
50+
->format(Manipulations::FORMAT_WEBP)
51+
->optimize()
52+
->save(public_path("images/content/{$directory}/{$webpFileName}"));
4253

4354
$this->info("Optimized {$directory}/{$file}");
4455
} catch (Throwable $exception) {
@@ -54,9 +65,19 @@ public function handle()
5465

5566
foreach ($files as $file) {
5667
try {
57-
Image::make(base_path("content/{$directory}/{$file}"))
58-
->fit(1920, 1080)
59-
->save(public_path("images/content/{$directory}/{$file}"));
68+
$webpFileName = pathinfo($file, PATHINFO_FILENAME) . '.webp';
69+
70+
if (file_exists(public_path("images/content/{$directory}/{$webpFileName}"))) {
71+
$this->warn("Skipped {$directory}/{$file}, already optimized.");
72+
73+
continue;
74+
}
75+
76+
Image::load(base_path("content/{$directory}/{$file}"))
77+
->fit(Manipulations::FIT_CONTAIN, 1920, 1080)
78+
->format(Manipulations::FORMAT_WEBP)
79+
->optimize()
80+
->save(public_path("images/content/{$directory}/{$webpFileName}"));
6081

6182
$this->info("Optimized {$directory}/{$file}");
6283
} catch (Throwable $exception) {
@@ -72,9 +93,19 @@ public function handle()
7293

7394
foreach ($files as $file) {
7495
try {
75-
Image::make(base_path("content/{$directory}/{$file}"))
76-
->fit(1024, 576)
77-
->save(public_path("images/content/{$directory}/{$file}"), quality: 50);
96+
$webpFileName = pathinfo($file, PATHINFO_FILENAME) . '.webp';
97+
98+
if (file_exists(public_path("images/content/{$directory}/{$webpFileName}"))) {
99+
$this->warn("Skipped {$directory}/{$file}, already optimized.");
100+
101+
continue;
102+
}
103+
104+
Image::load(base_path("content/{$directory}/{$file}"))
105+
->fit(Manipulations::FIT_CONTAIN, 1024, 576)
106+
->format(Manipulations::FORMAT_WEBP)
107+
->optimize()
108+
->save(public_path("images/content/{$directory}/{$webpFileName}"));
78109

79110
$this->info("Optimized {$directory}/{$file}");
80111
} catch (Throwable $exception) {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Models\Plugin;
7+
8+
class PluginController extends Controller
9+
{
10+
public function index()
11+
{
12+
return Plugin::paginate();
13+
}
14+
15+
public function show(Plugin $plugin)
16+
{
17+
return $plugin;
18+
}
19+
}

app/Http/Controllers/Articles/ListArticlesController.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,8 @@ function (): array {
4242
->with(['author'])
4343
->get()
4444
->map(fn (Article $article): array => [
45-
'id' => $article->slug,
46-
'title' => $article->title,
47-
'slug' => $article->slug,
48-
'publish_date' => $article->publish_date->diffForHumans(),
45+
...$article->getDataArray(),
4946
'stars_count' => $stars[$article->getKey()] ?? 0,
50-
'author' => [
51-
'name' => $article->author->name,
52-
'avatar' => $article->author->getAvatarUrl(),
53-
],
54-
'categories' => $article->categories,
55-
'type' => $article->type_slug,
56-
'versions' => $article->versions,
5747
])
5848
->all();
5949
},

app/Http/Controllers/Plugins/ListPluginsController.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,25 +43,8 @@ function (): array {
4343
->with(['author'])
4444
->get()
4545
->map(fn (Plugin $plugin): array => [
46-
'id' => $plugin->slug,
47-
'name' => $plugin->name,
48-
'slug' => $plugin->slug,
49-
'price' => $plugin->getPrice(),
46+
...$plugin->getDataArray(),
5047
'stars_count' => $stars[$plugin->getKey()] ?? 0,
51-
'thumbnail_url' => $plugin->getThumbnailUrl(),
52-
'github_repository' => $plugin->github_repository,
53-
'description' => $plugin->description,
54-
'author' => [
55-
'name' => $plugin->author->name,
56-
'avatar' => $plugin->author->getAvatarUrl(),
57-
],
58-
'features' => [
59-
'dark_theme' => $plugin->has_dark_theme,
60-
'translations' => $plugin->has_translations,
61-
],
62-
'categories' => $plugin->categories,
63-
'versions' => $plugin->versions,
64-
'publish_date' => $plugin->publish_date->format('Y-m-d'),
6548
])
6649
->all();
6750
},

app/Models/Article.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,21 @@ public function scopePublished(Builder $query): Builder
9797
{
9898
return $query->where('publish_date', '<=', now());
9999
}
100+
101+
public function getDataArray(): array
102+
{
103+
return [
104+
'id' => $this->slug,
105+
'title' => $this->title,
106+
'slug' => $this->slug,
107+
'publish_date' => $this->publish_date->diffForHumans(),
108+
'author' => [
109+
'name' => $this->author->name,
110+
'avatar' => $this->author->getAvatarUrl(),
111+
],
112+
'categories' => $this->categories,
113+
'type' => $this->type_slug,
114+
'versions' => $this->versions,
115+
];
116+
}
100117
}

app/Models/Author.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Author extends Model
2222

2323
public static function schema(Blueprint $table)
2424
{
25-
$table->string('avatar');
25+
$table->string('avatar')->nullable();
2626
$table->string('github_url');
2727
$table->string('name');
2828
$table->string('slug');
@@ -48,7 +48,7 @@ public function plugins(): HasMany
4848

4949
public function getAvatarUrl(): string
5050
{
51-
return asset("images/content/authors/avatars/{$this->avatar}");
51+
return asset('images/content/authors/avatars/' . ($this->avatar ?? "{$this->slug}.webp"));
5252
}
5353

5454
public function getStarsCount(): int

app/Models/Plugin.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ public function getStarsCount(): int
135135

136136
public function getImageUrl(): ?string
137137
{
138-
if (blank($this->image)) {
139-
return null;
140-
}
141-
142-
return asset("images/content/plugins/images/{$this->image}");
138+
return asset('images/content/plugins/images/' . ($this->image ?? "{$this->slug}.webp"));
143139
}
144140

145141
public function getThumbnailUrl(): ?string
@@ -195,4 +191,28 @@ public function getDocsCacheKeys(): array
195191
...array_map(fn ($key) => "plugin:{$this->slug}:docs:{$key}", array_keys($this->docs_urls)),
196192
];
197193
}
194+
195+
public function getDataArray(): array
196+
{
197+
return [
198+
'id' => $this->slug,
199+
'name' => $this->name,
200+
'slug' => $this->slug,
201+
'price' => $this->getPrice(),
202+
'thumbnail_url' => $this->getThumbnailUrl(),
203+
'github_repository' => $this->github_repository,
204+
'description' => $this->description,
205+
'author' => [
206+
'name' => $this->author->name,
207+
'avatar' => $this->author->getAvatarUrl(),
208+
],
209+
'features' => [
210+
'dark_theme' => $this->has_dark_theme,
211+
'translations' => $this->has_translations,
212+
],
213+
'categories' => $this->categories,
214+
'versions' => $this->versions,
215+
'publish_date' => $this->publish_date->format('Y-m-d'),
216+
];
217+
}
198218
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"pirsch-analytics/laravel-pirsch": "^0.4.7",
2929
"ryangjchandler/blade-capture-directive": "^0.3.0",
3030
"ryangjchandler/orbit": "^1.2",
31+
"spatie/image": "^2.2",
3132
"spatie/laravel-google-fonts": "^1.2",
3233
"spatie/laravel-image-optimizer": "^1.7",
3334
"spatie/yaml-front-matter": "^2.0",

0 commit comments

Comments
 (0)