From 726c3bffff5dfc687f0a60b60e22723d00c53727 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C5=A0pa=C4=8Dek?=
Date: Tue, 21 Nov 2023 01:19:14 +0100
Subject: [PATCH] Show slides note in talk page
---
site/app/Form/TalkFormFactory.php | 6 ++++++
site/app/Talks/Talk.php | 14 ++++++++++++++
site/app/Talks/TalkFactory.php | 2 ++
site/app/Talks/Talks.php | 12 +++++++++++-
site/app/Talks/talkInputs.latte | 3 +++
site/app/Www/Presenters/templates/Talks/talk.latte | 3 ++-
site/tests/Talks/TalkLocaleUrlsTest.phpt | 2 ++
7 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/site/app/Form/TalkFormFactory.php b/site/app/Form/TalkFormFactory.php
index 7ee8c8321..bb62311ce 100644
--- a/site/app/Form/TalkFormFactory.php
+++ b/site/app/Form/TalkFormFactory.php
@@ -70,6 +70,9 @@ public function create(callable $onSuccess, ?Talk $talk = null): UiForm
$form->addText('slidesEmbed', 'Embed odkaz na slajdy:')
->setRequired(false)
->addRule($form::MaxLength, 'Maximální délka embed odkazu na slajdy je %d znaků', 200);
+ $form->addTextArea('slidesNote', 'Poznámka ke slajdům:')
+ ->setRequired(false)
+ ->addRule($form::MaxLength, 'Maximální délka poznámek je %d znaků', 65535);
$form->addText('videoHref', 'Odkaz na video:')
->setRequired(false)
->addRule($form::MaxLength, 'Maximální délka odkazu na video je %d znaků', 200);
@@ -124,6 +127,7 @@ public function create(callable $onSuccess, ?Talk $talk = null): UiForm
$values->filenamesTalk,
$values->slidesHref,
$values->slidesEmbed,
+ $values->slidesNote,
$values->videoHref,
$videoThumbnailBasename ?? ($removeVideoThumbnail ? null : $thumbnailFilename),
$videoThumbnailBasenameAlternative ?? ($removeVideoThumbnailAlternative ? null : $thumbnailAlternativeFilename),
@@ -158,6 +162,7 @@ public function create(callable $onSuccess, ?Talk $talk = null): UiForm
$values->filenamesTalk,
$values->slidesHref,
$values->slidesEmbed,
+ $values->slidesNote,
$values->videoHref,
$videoThumbnailBasename,
$videoThumbnailBasenameAlternative,
@@ -198,6 +203,7 @@ public function setTalk(UiForm $form, Talk $talk, SubmitButton $submit): void
'filenamesTalk' => $talk->getFilenamesTalkId(),
'slidesHref' => $talk->getSlidesHref(),
'slidesEmbed' => $talk->getSlidesEmbed(),
+ 'slidesNote' => $talk->getSlidesNote(),
'videoHref' => $talk->getVideo()->getVideoHref(),
'videoEmbed' => $talk->getVideoEmbed(),
'event' => $talk->getEventTexy(),
diff --git a/site/app/Talks/Talk.php b/site/app/Talks/Talk.php
index 362eb7418..ddb5adb77 100644
--- a/site/app/Talks/Talk.php
+++ b/site/app/Talks/Talk.php
@@ -27,6 +27,8 @@ public function __construct(
private readonly bool $hasSlides,
private readonly ?string $slidesHref,
private readonly ?string $slidesEmbed,
+ private readonly ?Html $slidesNote,
+ private readonly ?string $slidesNoteTexy,
private readonly Video $video,
private readonly ?string $videoEmbed,
private readonly Html $event,
@@ -142,6 +144,18 @@ public function getSlidesEmbed(): ?string
}
+ public function getSlidesNote(): ?Html
+ {
+ return $this->slidesNote;
+ }
+
+
+ public function getSlidesNoteTexy(): ?string
+ {
+ return $this->slidesNoteTexy;
+ }
+
+
public function getVideo(): Video
{
return $this->video;
diff --git a/site/app/Talks/TalkFactory.php b/site/app/Talks/TalkFactory.php
index 320f08b0c..305695d62 100644
--- a/site/app/Talks/TalkFactory.php
+++ b/site/app/Talks/TalkFactory.php
@@ -50,6 +50,8 @@ public function createFromDatabaseRow(Row $row): Talk
(bool)$row->hasSlides,
$row->slidesHref,
$row->slidesEmbed,
+ $row->slidesNote ? $this->texyFormatter->formatBlock($row->slidesNote) : null,
+ $row->slidesNote,
$this->videoFactory->createFromDatabaseRow($row),
$row->videoEmbed,
$this->texyFormatter->format($row->event),
diff --git a/site/app/Talks/Talks.php b/site/app/Talks/Talks.php
index cccbfbab7..cbebb6c7d 100644
--- a/site/app/Talks/Talks.php
+++ b/site/app/Talks/Talks.php
@@ -43,6 +43,7 @@ public function getAll(?int $limit = null): array
t.slides_href IS NOT NULL OR EXISTS (SELECT * FROM talk_slides s WHERE s.key_talk = COALESCE(t.key_talk_slides, t.id_talk)) AS hasSlides,
t.slides_href AS slidesHref,
t.slides_embed AS slidesEmbed,
+ t.slides_note AS slidesNote,
t.video_href AS videoHref,
t.video_thumbnail AS videoThumbnail,
t.video_thumbnail_alternative AS videoThumbnailAlternative,
@@ -103,6 +104,7 @@ public function getUpcoming(): array
t.slides_href IS NOT NULL OR EXISTS (SELECT * FROM talk_slides s WHERE s.key_talk = COALESCE(t.key_talk_slides, t.id_talk)) AS hasSlides,
t.slides_href AS slidesHref,
t.slides_embed AS slidesEmbed,
+ t.slides_note AS slidesNote,
t.video_href AS videoHref,
t.video_thumbnail AS videoThumbnail,
t.video_thumbnail_alternative AS videoThumbnailAlternative,
@@ -153,6 +155,7 @@ public function get(string $name): Talk
t.slides_href IS NOT NULL OR EXISTS (SELECT * FROM talk_slides s WHERE s.key_talk = COALESCE(t.key_talk_slides, t.id_talk)) AS hasSlides,
t.slides_href AS slidesHref,
t.slides_embed AS slidesEmbed,
+ t.slides_note AS slidesNote,
t.video_href AS videoHref,
t.video_thumbnail AS videoThumbnail,
t.video_thumbnail_alternative AS videoThumbnailAlternative,
@@ -203,6 +206,7 @@ public function getById(int $id): Talk
t.slides_href IS NOT NULL OR EXISTS (SELECT * FROM talk_slides s WHERE s.key_talk = COALESCE(t.key_talk_slides, t.id_talk)) AS hasSlides,
t.slides_href AS slidesHref,
t.slides_embed AS slidesEmbed,
+ t.slides_note AS slidesNote,
t.video_href AS videoHref,
t.video_thumbnail AS videoThumbnail,
t.video_thumbnail_alternative AS videoThumbnailAlternative,
@@ -275,6 +279,7 @@ public function update(
?int $filenamesTalk,
?string $slidesHref,
?string $slidesEmbed,
+ ?string $slidesNote,
?string $videoHref,
?string $videoThumbnail,
?string $videoThumbnailAlternative,
@@ -300,6 +305,7 @@ public function update(
$filenamesTalk,
$slidesHref,
$slidesEmbed,
+ $slidesNote,
$videoHref,
$videoThumbnail,
$videoThumbnailAlternative,
@@ -334,6 +340,7 @@ public function add(
?int $filenamesTalk,
?string $slidesHref,
?string $slidesEmbed,
+ ?string $slidesNote,
?string $videoHref,
?string $videoThumbnail,
?string $videoThumbnailAlternative,
@@ -359,6 +366,7 @@ public function add(
$filenamesTalk,
$slidesHref,
$slidesEmbed,
+ $slidesNote,
$videoHref,
$videoThumbnail,
$videoThumbnailAlternative,
@@ -386,7 +394,7 @@ public function pageTitle(string $translationKey, Talk $talk): Html
/**
- * @return array{key_locale:int, key_translation_group:int|null, action:string|null, title:string, description:string|null, date:DateTime, duration:int|null, href:string|null, key_talk_slides:int|null, key_talk_filenames:int|null, slides_href:string|null, slides_embed:string|null, video_href:string|null, video_thumbnail:string|null, video_thumbnail_alternative:string|null, video_embed:string|null, event:string, event_href:string|null, og_image:string|null, transcript:string|null, favorite:string|null, key_superseded_by:int|null, publish_slides:bool}
+ * @return array{key_locale:int, key_translation_group:int|null, action:string|null, title:string, description:string|null, date:DateTime, duration:int|null, href:string|null, key_talk_slides:int|null, key_talk_filenames:int|null, slides_href:string|null, slides_embed:string|null, slides_note:string|null, video_href:string|null, video_thumbnail:string|null, video_thumbnail_alternative:string|null, video_embed:string|null, event:string, event_href:string|null, og_image:string|null, transcript:string|null, favorite:string|null, key_superseded_by:int|null, publish_slides:bool}
* @throws TalkDateTimeException
*/
private function getAddUpdateParams(
@@ -402,6 +410,7 @@ private function getAddUpdateParams(
?int $filenamesTalk,
?string $slidesHref,
?string $slidesEmbed,
+ ?string $slidesNote,
?string $videoHref,
?string $videoThumbnail,
?string $videoThumbnailAlternative,
@@ -432,6 +441,7 @@ private function getAddUpdateParams(
'key_talk_filenames' => (empty($filenamesTalk) ? null : $filenamesTalk),
'slides_href' => (empty($slidesHref) ? null : $slidesHref),
'slides_embed' => (empty($slidesEmbed) ? null : $slidesEmbed),
+ 'slides_note' => (empty($slidesNote) ? null : $slidesNote),
'video_href' => (empty($videoHref) ? null : $videoHref),
'video_thumbnail' => $videoThumbnail,
'video_thumbnail_alternative' => $videoThumbnailAlternative,
diff --git a/site/app/Talks/talkInputs.latte b/site/app/Talks/talkInputs.latte
index 0f4cf7f38..b695f39b7 100644
--- a/site/app/Talks/talkInputs.latte
+++ b/site/app/Talks/talkInputs.latte
@@ -39,6 +39,9 @@
{label slidesEmbed /} | {input slidesEmbed} deprecated |
+
+ {label slidesNote /} | {input slidesNote} |
+
{label videoHref /} | {input videoHref} |
diff --git a/site/app/Www/Presenters/templates/Talks/talk.latte b/site/app/Www/Presenters/templates/Talks/talk.latte
index ad5a941df..e0a0f78c9 100644
--- a/site/app/Www/Presenters/templates/Talks/talk.latte
+++ b/site/app/Www/Presenters/templates/Talks/talk.latte
@@ -34,7 +34,8 @@
({if $talk->getDuration()}{_messages.talks.duration|format:$talk->getDuration()}{if $slides || $talk->getVideo()->getVideoHref()}, {/if}{/if}{if $slides}{_messages.talks.slidescount, count($slides)}{if $talk->getVideo()->getVideoHref()}, {/if}{/if}{if $talk->getVideo()->getVideoHref()}{_messages.label.lowercasevideo}{/if})
-{_messages.label.slides}
+{_messages.label.slides}
+{if $talk->getSlidesNote()}{$talk->getSlidesNote()}{/if}
{if $talk->getSlidesHref()}
{icon images} {$slidesPlatform ?? $talk->getSlidesHref()}
{if $talk->getTranscript()}
diff --git a/site/tests/Talks/TalkLocaleUrlsTest.phpt b/site/tests/Talks/TalkLocaleUrlsTest.phpt
index 34c5fd906..30eaad58f 100644
--- a/site/tests/Talks/TalkLocaleUrlsTest.phpt
+++ b/site/tests/Talks/TalkLocaleUrlsTest.phpt
@@ -63,6 +63,8 @@ class TalkLocaleUrlsTest extends TestCase
false,
null,
null,
+ null,
+ null,
$video,
null,
Html::fromText('event'),