Compare commits

...

7 Commits

Author SHA1 Message Date
85b5c6eb91 - Ajout Entity Avis
- Déplacement js dans le dossier public
2025-02-13 23:12:57 +01:00
da9e7057bc - Ajout d'une image par défaut lorsqu'il n'y en a aucune. 2025-02-13 22:33:27 +01:00
918c6fe6dc - Ajout de la favicon 2025-01-30 16:22:16 +01:00
e624949fc3 - Ajout de la favicon 2025-01-30 16:21:36 +01:00
b0bd392ce3 -Ajout des colonnes catégories et edition 2025-01-30 15:37:44 +01:00
51c3be30db Merge remote-tracking branch 'origin/develop' into develop 2025-01-30 15:34:52 +01:00
c93bfd585e - Le pseudo et le mail est maintenant unique. 2025-01-30 15:30:49 +01:00
12 changed files with 221 additions and 54 deletions

View File

@ -1,28 +0,0 @@
document.addEventListener('DOMContentLoaded', () => {
const datas = {{ datas | tojson }};
datas.items.forEach((book, index) => {
const openModalBtn = document.getElementById(`openModalBtn-${index + 1}`);
const closeModalSvg = document.getElementById(`closeModalSvg-${index + 1}`);
const closeModalBtn = document.getElementById(`closeModalBtn-${index + 1}`);
const modal = document.getElementById(`myModal-${index + 1}`);
if (openModalBtn) {
openModalBtn.addEventListener('click', () => {
modal.classList.remove('hidden');
});
}
if (closeModalSvg) {
closeModalSvg.addEventListener('click', () => {
modal.classList.add('hidden');
});
}
if (closeModalBtn) {
closeModalBtn.addEventListener('click', () => {
modal.classList.add('hidden');
});
}
});
});

View File

@ -19,6 +19,7 @@
"symfony/runtime": "7.0.*",
"symfony/security-bundle": "7.0.*",
"symfony/twig-bundle": "7.0.*",
"symfony/validator": "7.0.*",
"symfony/webpack-encore-bundle": "^2.2",
"symfony/yaml": "7.0.*",
"twig/extra-bundle": "^2.12|^3.0",

97
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c53910010d80c77569e2b6c0828c9aa2",
"content-hash": "c7a74db8c19635e6115f7567b0077bb0",
"packages": [
{
"name": "doctrine/cache",
@ -5374,6 +5374,101 @@
],
"time": "2023-11-26T15:16:53+00:00"
},
{
"name": "symfony/validator",
"version": "v7.0.10",
"source": {
"type": "git",
"url": "https://github.com/symfony/validator.git",
"reference": "b3e4d838cdae9f2882402c2ad8018a27d469c075"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/validator/zipball/b3e4d838cdae9f2882402c2ad8018a27d469c075",
"reference": "b3e4d838cdae9f2882402c2ad8018a27d469c075",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php83": "^1.27",
"symfony/translation-contracts": "^2.5|^3"
},
"conflict": {
"doctrine/lexer": "<1.1",
"symfony/dependency-injection": "<6.4",
"symfony/doctrine-bridge": "<7.0",
"symfony/expression-language": "<6.4",
"symfony/http-kernel": "<6.4",
"symfony/intl": "<6.4",
"symfony/property-info": "<6.4",
"symfony/translation": "<6.4.3|>=7.0,<7.0.3",
"symfony/yaml": "<6.4"
},
"require-dev": {
"egulias/email-validator": "^2.1.10|^3|^4",
"symfony/cache": "^6.4|^7.0",
"symfony/config": "^6.4|^7.0",
"symfony/console": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/expression-language": "^6.4|^7.0",
"symfony/finder": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0",
"symfony/http-foundation": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/intl": "^6.4|^7.0",
"symfony/mime": "^6.4|^7.0",
"symfony/property-access": "^6.4|^7.0",
"symfony/property-info": "^6.4|^7.0",
"symfony/translation": "^6.4.3|^7.0.3",
"symfony/yaml": "^6.4|^7.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Validator\\": ""
},
"exclude-from-classmap": [
"/Tests/",
"/Resources/bin/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Provides tools to validate values",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/validator/tree/v7.0.10"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-07-26T12:31:22+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v7.0.2",

BIN
public/img/logo-cropped.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -47,6 +47,9 @@ class APISearchController extends AbstractController
$description = $data['description'] ?? '';
$date = $data['date'] ?? '';
$pages = $data['pages'] ?? '';
$edition = $data['edition'] ?? '';
$categorie = $data['categorie'] ?? '';
$favoris = new Favoris();
$user = $this->getUser();
@ -59,6 +62,8 @@ class APISearchController extends AbstractController
$favoris->setPublication($date);
$favoris->setPages($pages);
$favoris->setPublication($date);
$favoris->setEdition($edition);
$favoris->setCategorie($categorie);
$favorisRepository->addFavoris($favoris);

View File

@ -9,16 +9,19 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Routing\Annotation\Route;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class RegistrationController extends AbstractController
{
private $entityManager;
private $passwordHasher;
private $validator;
public function __construct(EntityManagerInterface $entityManager, UserPasswordHasherInterface $passwordHasher)
public function __construct(EntityManagerInterface $entityManager, UserPasswordHasherInterface $passwordHasher, ValidatorInterface $validator)
{
$this->entityManager = $entityManager;
$this->passwordHasher = $passwordHasher;
$this->validator = $validator;
}
#[Route('/registration', name: 'app_registration')]
@ -28,7 +31,18 @@ class RegistrationController extends AbstractController
$form = $this->createForm(RegistrationType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($form->isSubmitted()) {
$existingEmail = $this->entityManager->getRepository(User::class)->findOneBy(['email' => $user->getEmail()]);
$existingPseudo = $this->entityManager->getRepository(User::class)->findOneBy(['pseudo' => $user->getPseudo()]);
if ($existingEmail) {
$form->get('email')->addError(new \Symfony\Component\Form\FormError('Cet email est déjà utilisé.'));
}
if ($existingPseudo) {
$form->get('pseudo')->addError(new \Symfony\Component\Form\FormError('Ce pseudo est déjà pris.'));
}
$plainPassword = $user->getPassword();
$confirmPassword = $form->get('confirmPassword')->getData();
@ -37,14 +51,24 @@ class RegistrationController extends AbstractController
return $this->redirectToRoute('app_registration');
}
$hashedPassword = $this->passwordHasher->hashPassword($user, $plainPassword);
$user->setPassword($hashedPassword);
$errors = $this->validator->validate($user);
if (count($errors) > 0) {
foreach ($errors as $error) {
$form->addError(new \Symfony\Component\Form\FormError($error->getMessage()));
}
}
$this->entityManager->persist($user);
$this->entityManager->flush();
if ($form->isValid()) {
$hashedPassword = $this->passwordHasher->hashPassword($user, $plainPassword);
$user->setPassword($hashedPassword);
$this->addFlash('success', 'Votre compte a été créé avec succès !');
return $this->redirectToRoute('home');
$this->entityManager->persist($user);
$this->entityManager->flush();
$this->addFlash('success', 'Votre compte a été créé avec succès !');
return $this->redirectToRoute('home');
}
}
return $this->render('registration/index.html.twig', [

View File

@ -39,9 +39,13 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Favoris::class)]
private Collection $favoris;
#[ORM\OneToMany(mappedBy: 'id_user', targetEntity: Avis::class)]
private Collection $avis;
public function __construct()
{
$this->favoris = new ArrayCollection();
$this->avis = new ArrayCollection();
}
@ -169,4 +173,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}
/**
* @return Collection<int, Avis>
*/
public function getAvis(): Collection
{
return $this->avis;
}
public function addAvi(Avis $avi): static
{
if (!$this->avis->contains($avi)) {
$this->avis->add($avi);
$avi->setIdUser($this);
}
return $this;
}
public function removeAvi(Avis $avi): static
{
if ($this->avis->removeElement($avi)) {
// set the owning side to null (unless already changed)
if ($avi->getIdUser() === $this) {
$avi->setIdUser(null);
}
}
return $this;
}
}

View File

@ -135,6 +135,18 @@
"templates/base.html.twig"
]
},
"symfony/validator": {
"version": "7.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "7.0",
"ref": "8c1c4e28d26a124b0bb273f537ca8ce443472bfd"
},
"files": [
"config/packages/validator.yaml"
]
},
"symfony/web-profiler-bundle": {
"version": "7.0",
"recipe": {
@ -158,6 +170,7 @@
},
"files": [
"assets/app.js",
"assets/js/modal.js",
"assets/styles/app.css",
"config/packages/webpack_encore.yaml",
"package.json",

View File

@ -24,12 +24,15 @@
{% endif %}
</div>
<div class="flex">
<div class="flex flex-row w-1/4">
{% if book.volumeInfo.imageLinks is defined and book.volumeInfo.imageLinks.smallThumbnail is defined %}
<img src="{{ book.volumeInfo.imageLinks.smallThumbnail }}" class="p-2">
{% endif %}
</div>
<div class="w-9/12">
<div class="flex flex-row w-1/4">
{% if book.volumeInfo.imageLinks is defined and book.volumeInfo.imageLinks.smallThumbnail is defined %}
<img src="{{ book.volumeInfo.imageLinks.smallThumbnail }}" class="p-2 w-[200px] h-[250] object-cover">
{% else %}
<img src="https://fakeimg.pl/550x750?text=no+cover" class="p-2 object-cover">
{% endif %}
</div>
<div class="w-9/12">
{% if book.volumeInfo.publisher is defined %}
<p class="p-2 italic font-bold">Aux éditions :
<span class="font-normal">{{ book.volumeInfo.publisher }}</span>
@ -79,11 +82,13 @@
class="like-button absolute top-2 right-2 w-6 h-6 cursor-pointer transition-colors duration-300"
data-id-google="{{ book.id }}"
data-liked="{{ isLiked ? 'true' : 'false' }}"
data-edition="{{ book.volumeInfo.publisher | default('') }}"
data-categorie="{{ book.volumeInfo.categories is defined ? book.volumeInfo.categories | join(', ') : '' }}"
data-title="{{ book.volumeInfo.title | default('Titre non disponible') }}"
data-authors="{{ book.volumeInfo.authors is defined ? book.volumeInfo.authors | join(', ') : '' }}"
data-images="{{ book.volumeInfo.imageLinks.smallThumbnail is defined ? book.volumeInfo.imageLinks.smallThumbnail : '' }}"
data-description="{{ book.volumeInfo.description | raw | default('Description non disponible') }}"
data-date="{{ book.volumeInfo.publishedDate | default('Date non disponible') }}"
data-description="{{ book.volumeInfo.description is defined and book.volumeInfo.description is not empty ? book.volumeInfo.description | raw : '' }}"
data-date="{{ book.volumeInfo.publishedDate | default('') }}"
data-pages="{{ book.volumeInfo.pageCount | default('0') }}">
<path stroke-linecap="round" stroke-linejoin="round" d="M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12Z"/>
</svg>
@ -190,7 +195,7 @@
<script>
function toggleLike(idGoogle, liked, element, bookDetails) {
const url = liked
const url = liked
? "{{ path('unlike', {'idGoogle': 'PLACEHOLDER'}) }}".replace('PLACEHOLDER', idGoogle)
: "{{ path('like', {'idGoogle': 'PLACEHOLDER'}) }}".replace('PLACEHOLDER', idGoogle);
@ -227,7 +232,9 @@ document.querySelectorAll('.like-button').forEach(button => {
images: this.dataset.images,
description: this.dataset.description,
date: this.dataset.date,
pages: this.dataset.pages
pages: this.dataset.pages,
edition: this.dataset.edition,
categorie: this.dataset.categorie
};
toggleLike(idGoogle, liked, this, bookDetails);
@ -261,6 +268,8 @@ document.querySelectorAll('.like-button').forEach(button => {
{% endfor %}
});
</script>
{% endblock %}

View File

@ -2,9 +2,11 @@
<div id="myModal-{{ loop.index }}" class="fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center hidden z-50">
<div class="relative bg-white p-6 rounded-lg w-1/3 max-h-screen overflow-y-auto">
<div class="flex mx-auto flex-row w-1/4">
<div class="flex flex-row w-1/4">
{% if book.volumeInfo.imageLinks is defined and book.volumeInfo.imageLinks.smallThumbnail is defined %}
<img src="{{ book.volumeInfo.imageLinks.smallThumbnail }}" class="p-2">
<img src="{{ book.volumeInfo.imageLinks.smallThumbnail }}" class="p-2 w-[200px] h-[250] object-cover">
{% else %}
<img src="https://fakeimg.pl/550x750?text=no+cover" class="p-2 object-cover">
{% endif %}
</div>
<svg id="closeModalSvg-{{ loop.index }}" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"

View File

@ -7,7 +7,7 @@
{% block title %}Bienvenue!
{% 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></svg>">
<link rel="icon" href="{{ asset('img/logo-cropped.ico') }}" type="image/x-icon"/>
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}

View File

@ -28,17 +28,29 @@
<div class="mb-4">
{{ form_label(form.pseudo, 'Pseudo', {'label_attr': {'class': 'block text-sm font-medium text-gray-700'}}) }}
<div class="mt-1">
{{ form_widget(form.pseudo, {'attr': {'class': 'w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm'}}) }}
{{ form_widget(form.pseudo, {
'attr': {
'class': form.pseudo.vars.errors|length > 0 ? 'w-full px-3 py-2 border border-red-500 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm' : 'w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm'
}
}) }}
</div>
<div class="text-sm text-red-600 mt-2">
{{ form_errors(form.pseudo) }}
</div>
{{ form_errors(form.pseudo) }}
</div>
<div class="mb-4">
{{ form_label(form.email, 'Email', {'label_attr': {'class': 'block text-sm font-medium text-gray-700'}}) }}
<div class="mt-1">
{{ form_widget(form.email, {'attr': {'class': 'w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm'}}) }}
{{ form_widget(form.email, {
'attr': {
'class': form.email.vars.errors|length > 0 ? 'w-full px-3 py-2 border border-red-500 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm' : 'w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm'
}
}) }}
</div>
<div class="text-sm text-red-600 mt-2">
{{ form_errors(form.email) }}
</div>
{{ form_errors(form.email) }}
</div>
<div class="mb-4">