Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions src/App/src/Fixture/articles_cleaned.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -541,7 +541,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -555,7 +555,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -569,7 +569,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -583,7 +583,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -597,7 +597,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": true,
"opengraph_img": null,
Expand All @@ -611,7 +611,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": true,
"opengraph_img": null,
Expand All @@ -625,7 +625,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -639,7 +639,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -653,7 +653,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -681,7 +681,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": true,
"opengraph_img": null,
Expand Down Expand Up @@ -709,7 +709,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -723,7 +723,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -762,7 +762,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -883,7 +883,7 @@
"post_status": "publish",
"author": {
"display_name": "SergiuB",
"github": ""
"github": "kakapiciu"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -1461,7 +1461,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -1500,7 +1500,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -1624,7 +1624,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -1695,7 +1695,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -1882,7 +1882,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -1925,7 +1925,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -1983,7 +1983,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -2014,7 +2014,7 @@
"post_status": "publish",
"author": {
"display_name": "Gabi DJ",
"github": ""
"github": "gabidj/gabidj"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -2056,7 +2056,7 @@
"post_status": "publish",
"author": {
"display_name": "kakapiciu",
"github": "sergiu@rospace.com"
"github": "kakapiciu"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -2070,7 +2070,7 @@
"post_status": "publish",
"author": {
"display_name": "kakapiciu",
"github": "sergiu@rospace.com"
"github": "kakapiciu"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -2434,7 +2434,7 @@
"post_status": "publish",
"author": {
"display_name": "n3vrax",
"github": ""
"github": "n3vrax"
},
"isObsolete": false,
"opengraph_img": null,
Expand All @@ -2448,7 +2448,7 @@
"post_status": "publish",
"author": {
"display_name": "n3vrax",
"github": ""
"github": "n3vrax"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down Expand Up @@ -2525,7 +2525,7 @@
"post_status": "publish",
"author": {
"display_name": "kakapiciu",
"github": "sergiu@rospace.com"
"github": "kakapiciu"
},
"isObsolete": false,
"opengraph_img": null,
Expand Down
11 changes: 11 additions & 0 deletions src/App/templates/error/404.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
{% endfor %}
</div>
{% endif %}

{% if authors is defined and authors|length > 0 %}
<div class="d-flex flex-wrap gap-2 mt-4">
{% for author in authors %}
<a href="{{ url('page::author-resource', {slug: author.slug}) }}"
class="badge bg-primary-subtle text-primary text-uppercase fw-bold text-decoration-none px-3 py-2 rounded-pill">
{{ author.name }}
</a>
{% endfor %}
</div>
{% endif %}
</div>
</section>
{% endblock %}
19 changes: 17 additions & 2 deletions src/Blog/src/Handler/GetAuthorResourceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace Light\Blog\Handler;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\HtmlResponse;
use Light\App\Helper\Paginator;
use Light\Blog\Entity\Author;
use Light\Blog\Repository\AuthorRepository;
use Light\Blog\Repository\CategoryRepository;
use Light\Blog\Repository\PostRepository;
Expand All @@ -28,10 +30,10 @@ public function handle(ServerRequestInterface $request): ResponseInterface
{
$authorSlug = $request->getAttribute('slug');
$author = $this->authorRepository->getAuthorResource($authorSlug);
$categories = $this->categoryRepository->getCategories();
if (! $author) {
return new HtmlResponse('Author not found', 404);
return $this->notFound($this->authorRepository->getAuthorsWithPublishedPosts());
}
$categories = $this->categoryRepository->getCategories();

$queryParams = $request->getQueryParams();
$params = Paginator::getParams($queryParams, 'posts.postDate');
Expand All @@ -49,4 +51,17 @@ public function handle(ServerRequestInterface $request): ResponseInterface
])
);
}

/**
* @param Author[] $authors
*/
private function notFound(array $authors): HtmlResponse
{
return new HtmlResponse(
$this->template->render('error::404', [
'authors' => $authors,
]),
StatusCodeInterface::STATUS_NOT_FOUND
);
}
}
Loading