feat(controller): add post lists controller

This commit is contained in:
2024-08-03 10:47:43 +02:00
parent 58f43f096a
commit a99f6244b4
32 changed files with 8956 additions and 447 deletions

View File

@@ -2,16 +2,20 @@
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
<title>{% block title %}Post App{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}
{% block javascripts %}
{% block importmap %}{{ importmap('app') }}{% endblock %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
</head>
<body>
{% block body %}{% endblock %}
{% include 'header.html.twig' %}
<div class="container container-lg">
{% block body %}{% endblock %}
</div>
</body>
</html>

View File

@@ -0,0 +1,5 @@
<div class="container">
<header class="d-flex justify-content-center py-3">
<h1>{{ 'List App' | trans }}</h1>
</header>
</div>

View File

@@ -0,0 +1,36 @@
{% extends 'base.html.twig' %}
{% block body %}
{% for post in posts %}
<div class="card t-post-detail">
<div class="card-header">
<a class="t-detail-a" href="{{ path('detail_post', {postId: post.id}) }}">#{{ post.id }} - <span class="t-post-title">{{ post.title|u.truncate(80, '...', true)}}</span></a>
</div>
<div class="card-body">
<p class="card-text t-post-body">
{{ post.body|u.truncate(80, '...', true) }}
</p>
</div>
</div>
{% endfor %}
<nav aria-label="Page navigation">
<ul class="pagination t-pagination">
{% if not page.firstPageVisible %}
<li class="page-item t-page-item"><a class="page-link t-page-link" href="{{ path('page_list', {page: 1}) }}">1&mldr;</a></li>
{% endif %}
{% for i in page.visiblePages %}
<li class="page-item {% if i == page.currentPage %}active{% endif %} t-page-item">
{% if i == page.currentPage %}
<span class="page-link">{{ i }}</span>
{% else %}
<a class="page-link t-page-link" href="{{ path('page_list', {page: i}) }}">{{ i }}</a>
{% endif %}
</li>
{% endfor %}
{% if not page.lastPageVisible %}
<li class="page-item t-page-item"><a class="page-link t-page-link" href="{{ path('page_list', {page: page.lastPage}) }}">&mldr;{{ page.lastPage }}</a></li>
{% endif %}
</ul>
</nav>
{% endblock %}