diff --git a/src/Controller/HistoriqueAction.php b/src/Controller/HistoriqueAction.php new file mode 100644 index 0000000..9ad085f --- /dev/null +++ b/src/Controller/HistoriqueAction.php @@ -0,0 +1,72 @@ +meetups as $meetup) { + $meetupYear = (int) $meetup->date->format('Y'); + + $years[$meetupYear] = true; + + if (is_int($year) && $meetupYear === $year) { + $selectedMeetups[] = $meetup; + } + } + + $years = array_keys($years); + rsort($years); + + $recentYears = array_slice($years, 0, 10); + $olderYears = array_slice($years, 10); + + if (count($olderYears) > 0) { + $recentYears[] = 'anciens'; + } + + if ($year === 'anciens') { + $selectedMeetups = array_filter( + $antenne->meetups, + fn(Meetup $m) => in_array((int) $m->date->format('Y'), $olderYears), + ); + } + + usort($selectedMeetups, fn(Meetup $a, Meetup $b) => $b->date <=> $a->date); + + return $this->render('historique.html.twig', [ + 'antenne' => $antenne, + 'selectedYear' => $year, + 'years' => $recentYears, + 'selectedMeetups' => $selectedMeetups, + ]); + } +} diff --git a/src/Controller/IndexAction.php b/src/Controller/IndexAction.php index 25211fa..f7d5815 100644 --- a/src/Controller/IndexAction.php +++ b/src/Controller/IndexAction.php @@ -12,10 +12,12 @@ #[Route( path: '/', + name: 'home', host: '{code}.afup.org', )] #[Route( path: '/{code?}', + name: 'home', env: 'dev', )] final class IndexAction extends AbstractController diff --git a/src/Dto/Antenne.php b/src/Dto/Antenne.php index d05b9ec..da8efe8 100644 --- a/src/Dto/Antenne.php +++ b/src/Dto/Antenne.php @@ -11,6 +11,8 @@ public function __construct( public string $label, public Logo $logo, public Links $links, + /** @var array $meetups */ + public array $meetups, public ?Meetup $nextMeetup = null, ) {} } diff --git a/src/Dto/Meetup.php b/src/Dto/Meetup.php index b17a869..e965248 100644 --- a/src/Dto/Meetup.php +++ b/src/Dto/Meetup.php @@ -9,8 +9,9 @@ public function __construct( public string $title, public \DateTimeImmutable $date, - public string $location, + public ?string $location, public string $description, public string $url, + public ?string $photo, ) {} } diff --git a/templates/base.html.twig b/templates/base.html.twig index 7c90c44..64a79b1 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -5,14 +5,20 @@ - {% block title %}AFUP - Antennes{% endblock %} + AFUP {{ antenne.label }} {% block favicon %} - + {% endblock %} {% block head %}{% endblock %} + + + + + + {% block stylesheets %} {% endblock %} @@ -26,7 +32,40 @@
- {% block body %}{% endblock %} +
+
+
+ + Logo de l'antenne AFUP {{ antenne.label }} + +
+
+ +
+ afup.org + + + + Adhérer + + + + Historique +
+ + {% block body %}{% endblock %} + +
+ +
diff --git a/templates/historique.html.twig b/templates/historique.html.twig new file mode 100644 index 0000000..8b0014b --- /dev/null +++ b/templates/historique.html.twig @@ -0,0 +1,52 @@ +{% extends 'base.html.twig' %} + +{% block body %} + +
+ + + +
+ {% for meetup in selectedMeetups %} +
+ + +
+ {% if meetup.photo %} + + {% endif %} +
+
{{ meetup.title }}
+ + {{ meetup.date|format_datetime(pattern: 'EEEE d LLLL à H:mm', locale: 'fr') }} + {% if selectedYear == 'anciens' %} + {{ meetup.date.format('Y') }} + {% endif %} + + +
+
+ + +
+ {% endfor %} +
+ +
+ +{% endblock %} diff --git a/templates/index.html.twig b/templates/index.html.twig index 1edde7c..9bdc255 100644 --- a/templates/index.html.twig +++ b/templates/index.html.twig @@ -1,84 +1,44 @@ {% extends 'base.html.twig' %} -{% block title %}AFUP {{ antenne.label }}{% endblock %} - -{% block favicon %} - -{% endblock %} - -{% block head %} - - - - - - - -{% endblock %} - {% block body %} -
-
- Logo de l'antenne AFUP {{ antenne.label }} -
- -
- afup.org - - - - Devenir membre -
- -
-
- Meetup +
+
+ Meetup - {% if antenne.links.linkedin %} - LinkedIn - {% endif %} + {% if antenne.links.linkedin %} + LinkedIn + {% endif %} - {% if antenne.links.bluesky %} - Bluesky - {% endif %} + {% if antenne.links.bluesky %} + Bluesky + {% endif %} -
+
- {{ currentEvent }} -
+ {{ currentEvent }} +
- {% if antenne.nextMeetup %} -
-
-

Prochain meetup

- {{ antenne.nextMeetup.date|format_datetime(pattern: 'EEEE d LLLL à H:mm', locale: 'fr') }} -
+ {% if antenne.nextMeetup %} +
+
+

Prochain meetup

+ {{ antenne.nextMeetup.date|format_datetime(pattern: 'EEEE d LLLL à H:mm', locale: 'fr') }} +
- -

{{ antenne.nextMeetup.title }}

-
+ +

{{ antenne.nextMeetup.title }}

+
-
{{ antenne.nextMeetup.description|nl2br|markdown_to_html }}
+
{{ antenne.nextMeetup.description|nl2br|markdown_to_html }}
-
- - Rejoindre le prochain meetup - -
+
+ + Rejoindre le prochain meetup +
- {% endif %} -
-
- - + + {% endif %} + {% endblock %} diff --git a/tests/MockClientCallback.php b/tests/MockClientCallback.php index 9089a64..dbf2ef2 100644 --- a/tests/MockClientCallback.php +++ b/tests/MockClientCallback.php @@ -27,6 +27,8 @@ public function __invoke(string $method, string $url, array $options = []): Resp 'linkedin' => 'https://linkedin.example/lyon', 'bluesky' => 'https://bluesky.example/lyon', ], + 'photo' => 'https://photo.example/lyon.jpeg', + 'meetups' => [], ]); } @@ -42,6 +44,8 @@ public function __invoke(string $method, string $url, array $options = []): Resp 'linkedin' => null, 'bluesky' => null, ], + 'photo' => 'https://photo.example/bordeaux.jpeg', + 'meetups' => [], ]); }