diff --git a/public/css/components/post.css b/public/css/components/post.css new file mode 100644 index 0000000..7c0bada --- /dev/null +++ b/public/css/components/post.css @@ -0,0 +1,56 @@ +:root { + font-family: "Helvetica", 'Courier New', Courier, monospace; +} + +#post-wrapper { + width: 70%; + background-color: #f2f2f7; + margin: 0 auto; + border: 3px solid black; + border-radius: 1rem; + padding: 20px; + margin-top: 25vh; +} + +#post-info { + display: flex; + flex-direction: row; + align-items: center; + gap: 10px; +} + +h1 { + font-size: 3em; +} + +p { + white-space: pre-wrap; + font-size: 1.2em; +} + +#comments { + h2 { + font-size: 30px; + } +} + +hr { + color: black; +} + +html { + --s: 257px; + /* control the size */ + --c1: #38476b; + --c2: #bda3b6; + + --_c: var(--c1) calc(100% - var(--s)/2) 99%, #0000; + --_g: var(--s), #0000 calc(99% - var(--s)/2), var(--_c); + background: + radial-gradient(var(--s) at 100% var(--_g)), + radial-gradient(calc(var(--s)/4) at 50% calc(100%/3), var(--_c)) var(--s) 0, + radial-gradient(var(--s) at 0% var(--_g)) 0 calc(3*var(--s)) var(--c2); + background-size: + calc(2*var(--s)) calc(9*var(--s)/4), + calc(2*var(--s)) calc(3*var(--s)/4); +} diff --git a/src/Controller/PostController.php b/src/Controller/PostController.php index 62d8d7a..7548d15 100644 --- a/src/Controller/PostController.php +++ b/src/Controller/PostController.php @@ -7,7 +7,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Attribute\Route; use Doctrine\ORM\EntityManagerInterface; use App\Entity\Post; -use App\Entity\Profil; use App\Form\Type\PostType; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -32,20 +31,22 @@ class PostController extends AbstractController ]); } - #[Route('/post/{id}', + #[Route( + '/post/{id}', name: 'display post', methods: ['GET'], - requirements: ['id' => '\d+'])] + requirements: ['id' => '\d+'] + )] public function getPost(int $id): Response { $post = $this->em->getRepository(Post::class)->find($id); if (!$post) { - # Error 404 page } - # Return twig - return new Response(); + return $this->render('post/post.html.twig', [ + 'post' => $post + ]); } #[Route('/post/new/', name: 'add_post', methods: ['GET', 'POST'])] @@ -59,14 +60,7 @@ class PostController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $form = $form->getData(); - $user = $this->getUser(); - - $profil = new Profil(); - $profil->setId(11); - $profil->setName("coucou"); - - $post->setProfil($user); $this->em->persist($post); @@ -78,16 +72,13 @@ class PostController extends AbstractController return $this->render('post/new.html.twig', [ 'form' => $form, ]); - - # Handle error on data - } #[Route('/post/{id}', name: 'remove_post', methods: ['DELETE'])] public function removePost(int $id): Response { - $postRef = $this->em->getReference('Post', $id); - $this->em->remove($postRef); + $post = $this->em->getRepository(Post::class)->find($id); + $this->em->remove($post); $this->em->flush(); return new Response(); diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 2b47b0d..3028b08 100644 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -33,7 +33,6 @@ class RegistrationController extends AbstractController $entityManager->persist($user); $entityManager->flush(); - return $security->login($user, 'form_login', 'main'); } diff --git a/templates/post/post.html.twig b/templates/post/post.html.twig new file mode 100644 index 0000000..8d4b20b --- /dev/null +++ b/templates/post/post.html.twig @@ -0,0 +1,25 @@ + + +{{ post.title }} + +{% block body %} +
+
+
+ + {{ post.profil.name }} + {# - {{ post.dateCreated }} #} + - Il y a 3 jours +
+ +

{{ post.title }}

+

{{ post.text }}

+
+ +
+ +
+

Comments

+
+
+{% endblock %}