From 646d79251528f60cdf82e19b8f69675e201cd9f4 Mon Sep 17 00:00:00 2001 From: vanekm Date: Wed, 21 Aug 2024 15:55:08 +0200 Subject: [PATCH] automatize dates --- .../Fykos/DefaultModule/DefaultPresenter.php | 109 ++++++- .../templates/Default/default.latte | 308 +++++------------- www/fykos/images/logos/{1.svg => serie-1.svg} | 0 .../{1_pointer.svg => serie-1_pointer.svg} | 0 ...{1_pointer_h.svg => serie-1_pointer_h.svg} | 0 .../logos/{1_white.svg => serie-1_white.svg} | 0 www/fykos/images/logos/{2.svg => serie-2.svg} | 0 .../{2_pointer.svg => serie-2_pointer.svg} | 0 ...{2_pointer_h.svg => serie-2_pointer_h.svg} | 0 .../logos/{2_white.svg => serie-2_white.svg} | 0 www/fykos/images/logos/{3.svg => serie-3.svg} | 0 .../{3_pointer.svg => serie-3_pointer.svg} | 0 ...{3_pointer_h.svg => serie-3_pointer_h.svg} | 0 .../logos/{3_white.svg => serie-3_white.svg} | 0 www/fykos/images/logos/{4.svg => serie-4.svg} | 0 .../{4_pointer.svg => serie-4_pointer.svg} | 0 ...{4_pointer_h.svg => serie-4_pointer_h.svg} | 0 .../logos/{4_white.svg => serie-4_white.svg} | 0 www/fykos/images/logos/{5.svg => serie-5.svg} | 0 .../{5_pointer.svg => serie-5_pointer.svg} | 0 ...{5_pointer_h.svg => serie-5_pointer_h.svg} | 0 .../logos/{5_white.svg => serie-5_white.svg} | 0 www/fykos/images/logos/{6.svg => serie-6.svg} | 0 .../{6_pointer.svg => serie-6_pointer.svg} | 0 ...{6_pointer_h.svg => serie-6_pointer_h.svg} | 0 .../logos/{6_white.svg => serie-6_white.svg} | 0 26 files changed, 179 insertions(+), 238 deletions(-) rename www/fykos/images/logos/{1.svg => serie-1.svg} (100%) rename www/fykos/images/logos/{1_pointer.svg => serie-1_pointer.svg} (100%) rename www/fykos/images/logos/{1_pointer_h.svg => serie-1_pointer_h.svg} (100%) rename www/fykos/images/logos/{1_white.svg => serie-1_white.svg} (100%) rename www/fykos/images/logos/{2.svg => serie-2.svg} (100%) rename www/fykos/images/logos/{2_pointer.svg => serie-2_pointer.svg} (100%) rename www/fykos/images/logos/{2_pointer_h.svg => serie-2_pointer_h.svg} (100%) rename www/fykos/images/logos/{2_white.svg => serie-2_white.svg} (100%) rename www/fykos/images/logos/{3.svg => serie-3.svg} (100%) rename www/fykos/images/logos/{3_pointer.svg => serie-3_pointer.svg} (100%) rename www/fykos/images/logos/{3_pointer_h.svg => serie-3_pointer_h.svg} (100%) rename www/fykos/images/logos/{3_white.svg => serie-3_white.svg} (100%) rename www/fykos/images/logos/{4.svg => serie-4.svg} (100%) rename www/fykos/images/logos/{4_pointer.svg => serie-4_pointer.svg} (100%) rename www/fykos/images/logos/{4_pointer_h.svg => serie-4_pointer_h.svg} (100%) rename www/fykos/images/logos/{4_white.svg => serie-4_white.svg} (100%) rename www/fykos/images/logos/{5.svg => serie-5.svg} (100%) rename www/fykos/images/logos/{5_pointer.svg => serie-5_pointer.svg} (100%) rename www/fykos/images/logos/{5_pointer_h.svg => serie-5_pointer_h.svg} (100%) rename www/fykos/images/logos/{5_white.svg => serie-5_white.svg} (100%) rename www/fykos/images/logos/{6.svg => serie-6.svg} (100%) rename www/fykos/images/logos/{6_pointer.svg => serie-6_pointer.svg} (100%) rename www/fykos/images/logos/{6_pointer_h.svg => serie-6_pointer_h.svg} (100%) rename www/fykos/images/logos/{6_white.svg => serie-6_white.svg} (100%) diff --git a/app/Modules/Fykos/DefaultModule/DefaultPresenter.php b/app/Modules/Fykos/DefaultModule/DefaultPresenter.php index e2fe11eda..4035637fd 100644 --- a/app/Modules/Fykos/DefaultModule/DefaultPresenter.php +++ b/app/Modules/Fykos/DefaultModule/DefaultPresenter.php @@ -73,21 +73,37 @@ public function loadNews(): array public function loadEventData(): void { $this->template->events = [ + 'DSEF' => [ + 'heading' => [ + 'cs' => 'DSEF', + 'en' => 'DSEF' // Added English translation + ], + 'date' => date('Y-m-d H:i:s', strtotime('2024-10-21 09:00:00')), + 'show-in-en' => false, + 'is_series' => false, + 'url' => 'https://dsef.cz', + 'description' => [ + 'cs' => 'Den s experimentální fyzikou na Matfyzu', + 'en' => 'Day with experimental physics at Matfyz' + ], + 'show-on-timeline' => true, + 'logo_eventbox' => '/images/logos/dsef_symbol.svg', + ], 'Naboj' => [ 'heading' => [ 'cs' => 'Fyzikální Náboj', - 'en' => null + 'en' => 'Physical Náboj' // Added English translation ], 'date' => date('Y-m-d H:i:s', strtotime('2024-11-15 09:00:00')), - 'show-in-en' => false - ], - 'DSEF' => [ - 'heading' => [ - 'cs' => 'DSEF', - 'en' => null + 'show-in-en' => false, + 'is_series' => false, + 'url' => 'https://physics.naboj.org', + 'description' => [ + 'cs' => 'Týmová soutěž v Praze, Ostravě a jinde ve světě', + 'en' => 'Team competition in Prague, Ostrava, and elsewhere in the world' ], - 'date' => date('Y-m-d H:i:s', strtotime('2024-10-21 09:00:00')), - 'show-in-en' => false + 'show-on-timeline' => true, + 'logo_eventbox' => '/images/logos/naboj_symbol.svg', ], 'FOL' => [ 'heading' => [ @@ -95,7 +111,15 @@ public function loadEventData(): void 'en' => 'Physics Brawl Online' ], 'date' => date('Y-m-d H:i:s', strtotime('2024-11-20 17:00:00')), - 'show-in-en' => true + 'show-in-en' => true, + 'is_series' => false, + 'url' => 'https://online.fyziklani.cz', + 'description' => [ + 'cs' => 'Celosvětová soutěž, které se může účastnit každý', + 'en' => 'Worldwide competition open to everyone' + ], + 'show-on-timeline' => true, + 'logo_eventbox' => '/images/logos/fyziklani_online_symbol.svg' ], 'FOF' => [ 'heading' => [ @@ -103,23 +127,43 @@ public function loadEventData(): void 'en' => 'Fyziklani' ], 'date' => date('Y-m-d H:i:s', strtotime('2025-02-14 10:30:00')), - 'show-in-en' => true + 'show-in-en' => true, + 'is_series' => false, + 'url' => 'https://fyziklani.cz', + 'description' => [ + 'cs' => 'Největší týmová fyzikální soutěž v Evropě', + 'en' => 'The largest team physics competition in Europe' + ], + 'show-on-timeline' => true, + 'logo_eventbox' => '/images/logos/fyziklani_symbol.svg' ], 'serie-1' => [ 'heading' => [ 'cs' => 'Deadline 1. série', 'en' => 'Deadline Series 1' ], - 'date' => date('Y-m-d H:i:s', strtotime('2024-10-06 23:59:59')), - 'show-in-en' => true + 'date' => date('Y-m-d H:i:s', strtotime('2024-10-06 23:59:59')), + 'show-in-en' => true, + 'is_series' => true, + 'description' => [ + 'cs' => 'Rýže, kondenzátor a filodendron na cestě', + 'en' => 'Rice, capacitor, and philodendron on the road' ], + 'show-on-timeline' => true + ], 'serie-2' => [ 'heading' => [ 'cs' => 'Deadline 2. série', 'en' => 'Deadline Series 2' ], 'date' => date('Y-m-d H:i:s', strtotime('2024-11-24 23:59:59')), - 'show-in-en' => true + 'show-in-en' => true, + 'is_series' => true, + 'description' => [ + 'cs' => 'Bitcoin, stromy a omrzování', + 'en' => 'Bitcoin, trees, and cold exposure' + ], + 'show-on-timeline' => true ], 'serie-3' => [ 'heading' => [ @@ -127,7 +171,13 @@ public function loadEventData(): void 'en' => 'Deadline Series 3' ], 'date' => date('Y-m-d H:i:s', strtotime('2025-01-12 23:59:59')), - 'show-in-en' => true + 'show-in-en' => true, + 'is_series' => true, + 'description' => [ + 'cs' => 'Chleba, starý zářič a aquapark', + 'en' => 'Bread, radiation emitter, and water park' + ], + 'show-on-timeline' => true ], 'serie-4' => [ 'heading' => [ @@ -135,7 +185,13 @@ public function loadEventData(): void 'en' => 'Deadline Series 4' ], 'date' => date('Y-m-d H:i:s', strtotime('2025-02-23 23:59:59')), - 'show-in-en' => true + 'show-in-en' => true, + 'is_series' => true, + 'description' => [ + 'cs' => 'Kouř, stín a raketou na zkoušku', + 'en' => 'Smoke, shadow, and rocketing to an exam' + ], + 'show-on-timeline' => true ], 'serie-5' => [ 'heading' => [ @@ -143,7 +199,13 @@ public function loadEventData(): void 'en' => 'Deadline Series 5' ], 'date' => date('Y-m-d H:i:s', strtotime('2025-03-30 23:59:59')), - 'show-in-en' => true + 'show-in-en' => true, + 'is_series' => true, + 'description' => [ + 'cs' => 'Čtverec, minigolf a vagon ve vesmíru', + 'en' => 'Square, minigolf, and a wagon in space' + ], + 'show-on-timeline' => true ], 'serie-6' => [ 'heading' => [ @@ -151,11 +213,22 @@ public function loadEventData(): void 'en' => 'Deadline Series 6' ], 'date' => date('Y-m-d H:i:s', strtotime('2025-05-11 23:59:59')), - 'show-in-en' => true + 'show-in-en' => true, + 'is_series' => true, + 'description' => [ + 'cs' => 'Akční film, ponorka a ořezávání tužky', + 'en' => 'Action movie, submarine, and pencil sharpening' + ], + 'show-on-timeline' => true ] ]; $this->template->timelineBegin = date('Y-m-d', strtotime('2024-09-01')); $this->template->timelineEnd = date('Y-m-d', strtotime('2025-05-31')); + + // sort chronologically + // usort($this->template->events, function ($a, $b) { + // return strtotime($a['date']) - strtotime($b['date']); + // }); } public function findCountdownEventIndices(array $events): array diff --git a/app/Modules/Fykos/DefaultModule/templates/Default/default.latte b/app/Modules/Fykos/DefaultModule/templates/Default/default.latte index 548da6271..72d4ed767 100644 --- a/app/Modules/Fykos/DefaultModule/templates/Default/default.latte +++ b/app/Modules/Fykos/DefaultModule/templates/Default/default.latte @@ -171,10 +171,8 @@
-
-

{switch $language->value} @@ -184,117 +182,41 @@

- - {if $lang == 'cs'} -
- -
-
-

- Fyzikální Náboj -

- 3. 11. -
-
- {/if} - - - - - {if $lang == 'cs'} - - {/if} - + {/if} + {/foreach}
{* Horizontal timeline -- hide on small screens *}
-

{$timelineBegin|date:'j. n. Y'|noescape}

@@ -307,11 +229,7 @@
- {* TODO: if its before the deadline of a given series, link to the generic task assignent page. - If it's after, link to the assignment page of the specific series *}
- - {* Timeline header -- show on small screens *}

{switch $language->value} {case 'cs'}Série semináře @@ -319,107 +237,39 @@ {/switch}

- -
-
-
-

{switch $language->value} - {case 'cs'}1. série - {default}1st Series - {/switch}

- 10. 10. -
-
-

{switch $language->value} - {case 'cs'}Velryba, nové kolo a tření papíru - {default}Whale, new wheel, and paper rubbing - {/switch}

-
-
-
-
-
-
-

{switch $language->value} - {case 'cs'}3. série - {default}3rd Series - {/switch}

- 2. 1. -
-
-

{switch $language->value} - {case 'cs'}Zvlhčovač, blesky a proteinový motor - {default}Humidifier, lightning, and protein motor - {/switch}

-
-
-
-
-
-
-

{switch $language->value} - {case 'cs'}5. série - {default}5th Series - {/switch}

- 9. 4. -
-

{switch $language->value} - {case 'cs'}Bowling, med a potápějící se člun - {default}Bowling, honey, and sinking boat - {/switch}

-
-
- - -
-
-
-

{switch $language->value} - {case 'cs'}2. série - {default}2nd Series - {/switch}

- 21. 11. -
-

{switch $language->value} - {case 'cs'}Pneumatika, cola a perpetuum mobile - {default}Pneumatics, cola, and perpetual motion - {/switch}

-
-
-
-
-
-

{switch $language->value} - {case 'cs'}4. série - {default}4th Series - {/switch}

- 27. 2. -
-

{switch $language->value} - {case 'cs'}Hokejista, svítilna a pozorování letadla - {default}Hockey player, flashlight, and airplane observation - {/switch}

-
-
-
-
-
-

{switch $language->value} - {case 'cs'}6. série - {default}6th Series - {/switch}

- 14. 5. + {var $seriesCounter = 0} + {foreach $events as $key => $event} + {if $event['is_series'] && $event['show-on-timeline']} + {*
*} + {php $seriesCounter++} + -

- {switch $language->value} - {case 'cs'}Antineutrína, ponorka a magnety - {default}Antineutrinos, submarine, and magnets - {/switch} -

-
-
+ {/if} + {/foreach}
+ +
@@ -832,32 +682,50 @@ let dates_events = []; let dates_series = []; + + let images_events_v = []; + let images_events_h = []; + let images_series_v = []; + let images_series_h = []; + let hide_event_in_en = []; let sortedEvents = Object.entries(events).sort((a, b) => new Date(a[1].date) - new Date(b[1].date)); sortedEvents.forEach(([key, event]) => { - let date = new Date(event.date); - let formattedDate = date.toISOString().split('T')[0]; // Format as YYYY-MM-DD + if (event['show-on-timeline']) { + let date = new Date(event.date); + let formattedDate = date.toISOString().split('T')[0]; // Format as YYYY-MM-DD + + if (key.startsWith('serie-')) { + dates_series.push(formattedDate); + } else { + dates_events.push(formattedDate); + hide_event_in_en.push(!event['show-in-en']); + } - if (key.startsWith('serie-')) { - dates_series.push(formattedDate); - } else { - dates_events.push(formattedDate); - hide_event_in_en.push(!event['show-in-en']); + if (event['is_series']) { + images_series_v.push(`/images/logos/${key}_pointer.svg`); + images_series_h.push(`/images/logos/${key}_pointer_h.svg`); + } else { + images_events_v.push(`/images/logos/${key}_pointer.svg`); + images_events_h.push(`/images/logos/${key}_pointer_h.svg`); + } } }); + + // let dates_events = ["2023-11-03", "2023-11-06", "2023-11-22", "2024-02-16"]; - let images_events_v = ["/images/logos/Naboj_pointer.svg", "/images/logos/DSEF_pointer.svg", "/images/logos/FOL_pointer.svg", "/images/logos/FOF_pointer.svg"]; - let images_events_h = ["/images/logos/Naboj_pointer_h.svg", "/images/logos/DSEF_pointer_h.svg", "/images/logos/FOL_pointer_h.svg", "/images/logos/FOF_pointer_h.svg"]; + // let images_events_v = ["/images/logos/Naboj_pointer.svg", "/images/logos/DSEF_pointer.svg", "/images/logos/FOL_pointer.svg", "/images/logos/FOF_pointer.svg"]; + // let images_events_h = ["/images/logos/Naboj_pointer_h.svg", "/images/logos/DSEF_pointer_h.svg", "/images/logos/FOL_pointer_h.svg", "/images/logos/FOF_pointer_h.svg"]; // let dates_series = ["2023-10-10", "2023-11-21", "2024-01-02", "2024-02-27", "2024-04-09", "2024-05-14"]; - let images_series_v = ["/images/logos/1_pointer.svg", "/images/logos/2_pointer.svg", "/images/logos/3_pointer.svg", - "/images/logos/4_pointer.svg", "/images/logos/5_pointer.svg", "/images/logos/6_pointer.svg"]; - let images_series_h = ["/images/logos/1_pointer_h.svg", "/images/logos/2_pointer_h.svg", "/images/logos/3_pointer_h.svg", - "/images/logos/4_pointer_h.svg", "/images/logos/5_pointer_h.svg", "/images/logos/6_pointer_h.svg"]; + // let images_series_v = ["/images/logos/1_pointer.svg", "/images/logos/2_pointer.svg", "/images/logos/3_pointer.svg", + // "/images/logos/4_pointer.svg", "/images/logos/5_pointer.svg", "/images/logos/6_pointer.svg"]; + // let images_series_h = ["/images/logos/1_pointer_h.svg", "/images/logos/2_pointer_h.svg", "/images/logos/3_pointer_h.svg", + // "/images/logos/4_pointer_h.svg", "/images/logos/5_pointer_h.svg", "/images/logos/6_pointer_h.svg"]; // let hide_event_in_en = [true, true, false, false]; diff --git a/www/fykos/images/logos/1.svg b/www/fykos/images/logos/serie-1.svg similarity index 100% rename from www/fykos/images/logos/1.svg rename to www/fykos/images/logos/serie-1.svg diff --git a/www/fykos/images/logos/1_pointer.svg b/www/fykos/images/logos/serie-1_pointer.svg similarity index 100% rename from www/fykos/images/logos/1_pointer.svg rename to www/fykos/images/logos/serie-1_pointer.svg diff --git a/www/fykos/images/logos/1_pointer_h.svg b/www/fykos/images/logos/serie-1_pointer_h.svg similarity index 100% rename from www/fykos/images/logos/1_pointer_h.svg rename to www/fykos/images/logos/serie-1_pointer_h.svg diff --git a/www/fykos/images/logos/1_white.svg b/www/fykos/images/logos/serie-1_white.svg similarity index 100% rename from www/fykos/images/logos/1_white.svg rename to www/fykos/images/logos/serie-1_white.svg diff --git a/www/fykos/images/logos/2.svg b/www/fykos/images/logos/serie-2.svg similarity index 100% rename from www/fykos/images/logos/2.svg rename to www/fykos/images/logos/serie-2.svg diff --git a/www/fykos/images/logos/2_pointer.svg b/www/fykos/images/logos/serie-2_pointer.svg similarity index 100% rename from www/fykos/images/logos/2_pointer.svg rename to www/fykos/images/logos/serie-2_pointer.svg diff --git a/www/fykos/images/logos/2_pointer_h.svg b/www/fykos/images/logos/serie-2_pointer_h.svg similarity index 100% rename from www/fykos/images/logos/2_pointer_h.svg rename to www/fykos/images/logos/serie-2_pointer_h.svg diff --git a/www/fykos/images/logos/2_white.svg b/www/fykos/images/logos/serie-2_white.svg similarity index 100% rename from www/fykos/images/logos/2_white.svg rename to www/fykos/images/logos/serie-2_white.svg diff --git a/www/fykos/images/logos/3.svg b/www/fykos/images/logos/serie-3.svg similarity index 100% rename from www/fykos/images/logos/3.svg rename to www/fykos/images/logos/serie-3.svg diff --git a/www/fykos/images/logos/3_pointer.svg b/www/fykos/images/logos/serie-3_pointer.svg similarity index 100% rename from www/fykos/images/logos/3_pointer.svg rename to www/fykos/images/logos/serie-3_pointer.svg diff --git a/www/fykos/images/logos/3_pointer_h.svg b/www/fykos/images/logos/serie-3_pointer_h.svg similarity index 100% rename from www/fykos/images/logos/3_pointer_h.svg rename to www/fykos/images/logos/serie-3_pointer_h.svg diff --git a/www/fykos/images/logos/3_white.svg b/www/fykos/images/logos/serie-3_white.svg similarity index 100% rename from www/fykos/images/logos/3_white.svg rename to www/fykos/images/logos/serie-3_white.svg diff --git a/www/fykos/images/logos/4.svg b/www/fykos/images/logos/serie-4.svg similarity index 100% rename from www/fykos/images/logos/4.svg rename to www/fykos/images/logos/serie-4.svg diff --git a/www/fykos/images/logos/4_pointer.svg b/www/fykos/images/logos/serie-4_pointer.svg similarity index 100% rename from www/fykos/images/logos/4_pointer.svg rename to www/fykos/images/logos/serie-4_pointer.svg diff --git a/www/fykos/images/logos/4_pointer_h.svg b/www/fykos/images/logos/serie-4_pointer_h.svg similarity index 100% rename from www/fykos/images/logos/4_pointer_h.svg rename to www/fykos/images/logos/serie-4_pointer_h.svg diff --git a/www/fykos/images/logos/4_white.svg b/www/fykos/images/logos/serie-4_white.svg similarity index 100% rename from www/fykos/images/logos/4_white.svg rename to www/fykos/images/logos/serie-4_white.svg diff --git a/www/fykos/images/logos/5.svg b/www/fykos/images/logos/serie-5.svg similarity index 100% rename from www/fykos/images/logos/5.svg rename to www/fykos/images/logos/serie-5.svg diff --git a/www/fykos/images/logos/5_pointer.svg b/www/fykos/images/logos/serie-5_pointer.svg similarity index 100% rename from www/fykos/images/logos/5_pointer.svg rename to www/fykos/images/logos/serie-5_pointer.svg diff --git a/www/fykos/images/logos/5_pointer_h.svg b/www/fykos/images/logos/serie-5_pointer_h.svg similarity index 100% rename from www/fykos/images/logos/5_pointer_h.svg rename to www/fykos/images/logos/serie-5_pointer_h.svg diff --git a/www/fykos/images/logos/5_white.svg b/www/fykos/images/logos/serie-5_white.svg similarity index 100% rename from www/fykos/images/logos/5_white.svg rename to www/fykos/images/logos/serie-5_white.svg diff --git a/www/fykos/images/logos/6.svg b/www/fykos/images/logos/serie-6.svg similarity index 100% rename from www/fykos/images/logos/6.svg rename to www/fykos/images/logos/serie-6.svg diff --git a/www/fykos/images/logos/6_pointer.svg b/www/fykos/images/logos/serie-6_pointer.svg similarity index 100% rename from www/fykos/images/logos/6_pointer.svg rename to www/fykos/images/logos/serie-6_pointer.svg diff --git a/www/fykos/images/logos/6_pointer_h.svg b/www/fykos/images/logos/serie-6_pointer_h.svg similarity index 100% rename from www/fykos/images/logos/6_pointer_h.svg rename to www/fykos/images/logos/serie-6_pointer_h.svg diff --git a/www/fykos/images/logos/6_white.svg b/www/fykos/images/logos/serie-6_white.svg similarity index 100% rename from www/fykos/images/logos/6_white.svg rename to www/fykos/images/logos/serie-6_white.svg