Skip to content
Open
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
30 changes: 26 additions & 4 deletions src/App/templates/partial/left-menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
</div>
</div>
{% if data is defined %}
{% if data is defined and data is iterable %}
<div class="card border-0 shadow-sm rounded-3 my-2">
<div class="card-body p-3">
<h6 class="fw-bold text-uppercase text-muted small px-1 mb-2">Recent Articles</h6>
Expand All @@ -23,8 +23,8 @@
class="list-group-item list-group-item-action border-0 px-1 py-2 rounded">
<p class="mb-1 small fw-semibold text-dark lh-sm">{{ article.title }}</p>
<span class="text-muted" >
<i class="bi bi-calendar3 me-1"></i>{{ article.postDate|date('M d, Y') }}
</span>
<i class="bi bi-calendar3 me-1"></i>{{ article.postDate|date('M d, Y') }}
</span>
</a>
{% else %}
<p class="text-muted small mb-0">No recent articles.</p>
Expand Down Expand Up @@ -52,9 +52,31 @@
See all categories <i class="bi bi-arrow-right fs-7"></i>
</a>
</div>
</div>
</div>
{% if posts is defined and posts is iterable %}
<div class="card border-0 shadow-sm rounded-3 my-2">
<div class="card-body p-3">
<h6 class="fw-bold text-uppercase text-muted small px-1 mb-2">Recent Articles</h6>

<div class="list-group list-group-flush">

{% for post in posts %}
<a href="{{ url('page::blog-resource', {categorySlug: post.category.slug, slug: post.slug}) }}"
class="list-group-item list-group-item-action border-0 px-1 py-2 rounded">
<p class="mb-1 small fw-semibold text-dark lh-sm">{{ post.title }}</p>
<span class="text-muted">
<i class="bi bi-calendar3 me-1"></i>{{ post.postDate|date('M d, Y') }}
</span>
</a>
{% else %}
<p class="text-muted small mb-0">No recent articles.</p>
{% endfor %}

</div>
</div>
</div>
{% endif %}

</div>
</div>
</aside>
3 changes: 2 additions & 1 deletion src/Blog/src/Handler/GetCategoryResourceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Light\Blog\Handler;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\HtmlResponse;
use Light\Blog\Repository\CategoryRepository;
use Mezzio\Template\TemplateRendererInterface;
Expand All @@ -26,7 +27,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$meta = $category;

if (! $category) {
return new HtmlResponse('Category not found', 404);
return new HtmlResponse('Category not found', StatusCodeInterface::STATUS_NOT_FOUND);
}
Comment on lines 29 to 31

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just asking (if you have specs telling otherwise, you don't need to change anything).

Wouldn't it be better to apply here the same logic that you did in the post handler?
I mean: if the category was not found, then show the 404 Not Found page with other category/post suggestions?

$categories = $this->categoryRepository->getCategories();
$categoryArticles = $this->categoryRepository->getCategoryPost($category);
Expand Down
3 changes: 2 additions & 1 deletion src/Blog/src/Handler/GetPostResourceHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Light\Blog\Handler;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\HtmlResponse;
use Light\Blog\Repository\CategoryRepository;
use Light\Blog\Repository\PostRepository;
Expand Down Expand Up @@ -58,7 +59,7 @@ private function notFound(?string $categorySlug): HtmlResponse
$this->template->render('error::404', [
'categories' => $categories,
]),
404
StatusCodeInterface::STATUS_NOT_FOUND
);
}
}
16 changes: 16 additions & 0 deletions src/Blog/src/Repository/PostRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,20 @@ public function getArticleByAuthor(Author $author, array $params): DoctrinePagin

return new DoctrinePaginator($qb->getQuery());
}

/**
* @return array<int, Post>
*/
public function getRecentPosts(int $limit = 5): array
{
$qb = $this->getQueryBuilder()
->select('articles')
->from(Post::class, 'articles')
->where('articles.status = :published')
->setParameter('published', PostStatusEnum::Published)
->orderBy('articles.postDate', 'DESC')
->setMaxResults($limit);

return $qb->getQuery()->getResult();
}
}
41 changes: 0 additions & 41 deletions src/Blog/templates/page/category-resource/architecture.html.twig

This file was deleted.

41 changes: 0 additions & 41 deletions src/Blog/templates/page/category-resource/default.html.twig

This file was deleted.

41 changes: 0 additions & 41 deletions src/Blog/templates/page/category-resource/dotkernel.html.twig

This file was deleted.

140 changes: 104 additions & 36 deletions src/Blog/templates/page/contact.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,114 @@
{% block page_title %}<h1>Contact Us</h1>{% endblock %}

{% block content %}
<div class="row g-4 py-3 justify-content-center">
<div class="col-12 col-md-6 col-lg-6">
<div class="card h-100 border-0 shadow-sm text-center p-4">
<div class="mb-3">
<i class="fab fa-github fa-3x text-primary"></i>
<div class="row g-4 py-3">

{{ include('@partial/left-menu.html.twig') }}

<main class="col-lg-9 col-md-8">

<div class="row g-4">
<div class="col-12 col-md-6">
<div class="card h-100 border-0 shadow-sm text-center p-4">
<div class="mb-3">
<i class="fab fa-github fa-3x text-primary"></i>
</div>
<h2 class="h4 fw-semibold mb-2">GitHub</h2>
<p class="text-muted mb-4">
Browse our repositories, open issues, or contribute to the DotKernel ecosystem.
</p>
<a href="https://github.com/dotkernel"
target="_blank"
rel="noopener noreferrer"
class="btn btn-primary rounded-pill px-4 mt-auto">
Visit GitHub
</a>
</div>
</div>

<div class="col-12 col-md-6">
<div class="card h-100 border-0 shadow-sm text-center p-4">
<div class="mb-3">
<i class="fas fa-book fa-3x text-primary"></i>
</div>
<h2 class="h4 fw-semibold mb-2">Documentation</h2>
<p class="text-muted mb-4">
Read the guides, references, and best practices for building with DotKernel.
</p>
<a href="https://docs.dotkernel.org/"
target="_blank"
rel="noopener noreferrer"
class="btn btn-primary rounded-pill px-4 mt-auto">
Read the Docs
</a>
</div>
</div>
<h2 class="h4 fw-semibold mb-2">GitHub</h2>
<p class="text-muted mb-4">
Browse our repositories, open issues, or contribute to the DotKernel ecosystem.
</p>
<a href="https://github.com/dotkernel"
target="_blank"
rel="noopener noreferrer"
class="btn btn-primary rounded-pill px-4 mt-auto">
Visit GitHub
</a>
</div>
</div>
<div class="col-12 col-md-6 col-lg-6">
<div class="card h-100 border-0 shadow-sm text-center p-4">
<div class="mb-3">
<i class="fas fa-book fa-3x text-primary"></i>

<div class="card border-0 shadow-sm mt-4">
<div class="card-body p-4">
<h3 class="h5 fw-bold mb-3">Our Approach</h3>
<p class="text-muted mb-0">
Dotkernel is a Headless Platform for building modern web applications.
The Dotkernel Headless Platform is made up of Open Source components aimed at businesses that need custom solutions.
</p>
</div>
<h2 class="h4 fw-semibold mb-2">Documentation</h2>
<p class="text-muted mb-4">
Read the guides, references, and best practices for building with DotKernel.
</p>
<a href="https://docs.dotkernel.org/"
target="_blank"
rel="noopener noreferrer"
class="btn btn-primary rounded-pill px-4 mt-auto">
Read the Docs
</a>
</div>
</div>
<hr>
<h3>Our Approach</h3>
<p>
Dotkernel is a Headless Platform for building modern web applications.

The Dotkernel Headless Platform is made up of Open Source components aimed at businesses that need custom solutions.</p>
{% if posts is defined and posts|length > 0 %}
<div class="card border-0 shadow-sm mt-4">
<div class="card-body p-4">
<h3 class="h5 fw-bold mb-3">Latest posts</h3>

<div id="postsCarousel" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner">
{% for post in posts %}
<div class="carousel-item {% if loop.first %}active{% endif %}">
<span class="text-muted small">
<i class="bi bi-calendar3 me-1"></i>{{ post.postDate|date('M d, Y') }}
</span>
<h4 class="h5 fw-semibold mt-2 mb-2">{{ post.title }}</h4>
{% if post.excerpt is defined %}
<p class="text-muted mb-3">{{ post.excerpt }}</p>
{% endif %}
<a href="{{ url('page::blog-resource', {categorySlug: post.category.slug, slug: post.slug}) }}"
class="btn btn-primary btn-sm rounded-pill px-3">
Read more
</a>
</div>
{% endfor %}
</div>

{% if posts|length > 1 %}
<div class="d-flex justify-content-between align-items-center mt-4">
<button class="btn btn-outline-secondary btn-sm rounded-circle" type="button"
data-bs-target="#postsCarousel" data-bs-slide="prev">
<i class="fas fa-chevron-left"></i>
<span class="visually-hidden">Previous</span>
</button>

<div class="carousel-indicators position-relative m-0">
{% for post in posts %}
<button type="button" data-bs-target="#postsCarousel" data-bs-slide-to="{{ loop.index0 }}"
class="{% if loop.first %}active{% endif %} bg-primary rounded-circle"
style="width: 8px; height: 8px;"
aria-current="{% if loop.first %}true{% endif %}"
aria-label="Slide {{ loop.index }}"></button>
{% endfor %}
</div>

<button class="btn btn-outline-secondary btn-sm rounded-circle" type="button"
data-bs-target="#postsCarousel" data-bs-slide="next">
<i class="fas fa-chevron-right"></i>
<span class="visually-hidden">Next</span>
</button>
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}

</main>
</div>
{% endblock %}
Loading