From 482a35adf4a301cc9e2b7548b05d9464467671e7 Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Tue, 27 Jan 2026 00:40:41 +0100 Subject: [PATCH] =?UTF-8?q?m=C3=A0j=20avec=2014=20f=C3=A9vrier=20=C3=A0=20?= =?UTF-8?q?latapie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- src/distributions-utils.php | 43 ++++++++++++++++++++++++++----------- src/distributions.php | 7 +++--- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 90f9571..2088a2b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ start: - pnpm dlx serve src + php -S localhost:8000 -t src # Require a password. Not versioned. See Bitwarden. deploy: diff --git a/src/distributions-utils.php b/src/distributions-utils.php index 708a7aa..677fe7c 100644 --- a/src/distributions-utils.php +++ b/src/distributions-utils.php @@ -7,14 +7,16 @@ /** * Charge les distributions depuis le fichier de configuration */ -function chargerDistributions(): array { +function chargerDistributions(): array +{ return require __DIR__ . '/distributions.php'; } /** * Trouve la prochaine distribution */ -function trouverProchaineDistribution(array $distributions): ?array { +function trouverProchaineDistribution(array $distributions): ?array +{ $maintenant = new DateTime(); foreach ($distributions as $distrib) { @@ -30,7 +32,8 @@ function trouverProchaineDistribution(array $distributions): ?array { /** * Vérifie si une distribution est passée */ -function estPassee(array $distribution): bool { +function estPassee(array $distribution): bool +{ $maintenant = new DateTime(); $date = new DateTime($distribution['date']); return $date < $maintenant; @@ -39,7 +42,8 @@ function estPassee(array $distribution): bool { /** * Formate une date de distribution */ -function formaterDate(string $date): string { +function formaterDate(string $date): string +{ $dateObj = new DateTime($date); $formatter = new IntlDateFormatter( 'fr_FR', @@ -62,7 +66,7 @@ function formaterDate(string $date): string { 7 => 'Dimanche' ]; return $joursTraduction[$jourSemaine] . ' ' . $dateObj->format('d') . ' ' . - ucfirst($formatter->format($dateObj)); + ucfirst($formatter->format($dateObj)); } return ucfirst($dateFormatee); @@ -71,7 +75,8 @@ function formaterDate(string $date): string { /** * Formate une date courte (pour le calendrier) */ -function formaterDateCourte(string $date): string { +function formaterDateCourte(string $date): string +{ $dateObj = new DateTime($date); $formatter = new IntlDateFormatter( 'fr_FR', @@ -94,7 +99,7 @@ function formaterDateCourte(string $date): string { 7 => 'Dimanche' ]; return '' . $joursTraduction[$jourSemaine] . ' ' . - $formatter->format($dateObj); + $formatter->format($dateObj); } return $formatter->format($dateObj); @@ -103,7 +108,8 @@ function formaterDateCourte(string $date): string { /** * Formate une date complète avec jour de la semaine */ -function formaterDateComplete(DateTime $date): string { +function formaterDateComplete(DateTime $date): string +{ $formatter = new IntlDateFormatter( 'fr_FR', IntlDateFormatter::FULL, @@ -119,7 +125,8 @@ function formaterDateComplete(DateTime $date): string { /** * Formate une date pour le calendrier */ -function formaterDateCalendrier(DateTime $date): string { +function formaterDateCalendrier(DateTime $date): string +{ $formatter = new IntlDateFormatter( 'fr_FR', IntlDateFormatter::LONG, @@ -135,7 +142,8 @@ function formaterDateCalendrier(DateTime $date): string { /** * Retourne l'info du lieu de distribution */ -function getLieuInfo(string $lieu): array { +function getLieuInfo(?string $lieu): array +{ $lieux = [ 'grange' => [ 'nom' => 'La Grange', @@ -148,6 +156,12 @@ function getLieuInfo(string $lieu): array { 'adresse' => '28 rue Guillaume Berdeil', 'url' => 'https://www.openstreetmap.org/?mlat=43.516927&mlon=1.319663#map=19/43.516927/1.319663', 'description' => 'au Secours Populaire de Frouzins – 28 rue Guillaume Berdeil' + ], + 'latapie' => [ + 'nom' => 'Salle des fêtes Jean Latapie', + 'adresse' => 'Chemin des Mailheaux', + 'url' => 'https://www.openstreetmap.org/way/123574995', + 'description' => 'à la Salle des fêtes Jean Latapie – Chemin des Mailheaux' ] ]; @@ -157,7 +171,8 @@ function getLieuInfo(string $lieu): array { /** * Classe CSS pour le type de distribution */ -function getClasseDistribution(array $distribution, bool $estProchaine): string { +function getClasseDistribution(array $distribution, bool $estProchaine): string +{ if ($estProchaine) { return 'bg-green-500'; } @@ -176,7 +191,8 @@ function getClasseDistribution(array $distribution, bool $estProchaine): string /** * Classe CSS pour le texte */ -function getClasseTexte(array $distribution, bool $estProchaine): string { +function getClasseTexte(array $distribution, bool $estProchaine): string +{ if ($estProchaine) { return 'text-white'; } @@ -195,7 +211,8 @@ function getClasseTexte(array $distribution, bool $estProchaine): string { /** * Label du statut */ -function getLabelStatut(array $distribution, bool $estProchaine): ?string { +function getLabelStatut(array $distribution, bool $estProchaine): ?string +{ if ($estProchaine) { return 'Prochaine'; } diff --git a/src/distributions.php b/src/distributions.php index 3ed3116..2fb39ee 100644 --- a/src/distributions.php +++ b/src/distributions.php @@ -59,10 +59,9 @@ return [ ], [ 'date' => '2026-02-14', - 'lieu' => null, - 'type' => 'annulee', - 'label' => 'Pas de distribution', - 'raison' => 'Salon des vins et producteurs locaux' + 'lieu' => 'latapie', + 'type' => 'special', + 'label' => '🍷 Salon des vins et producteurs locaux 🍷' ], [ 'date' => '2026-02-28',