From 69d557c15a046ff85fd17c4855bf0ee67a06e4fd Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Sat, 7 Nov 2026 16:17:39 +0100 Subject: [PATCH] List all slide types on the start page The feature list was hard-coded and missed quiz, Q&A, content and YouTube slides. It is now rendered from Slide::typeLabels(). Co-Authored-By: Claude Opus 5.5 --- src/Controller/HomeController.php | 14 ++++++++++++++ templates/Home/index.php | 17 ++++++++++++----- .../TestCase/Controller/HomeControllerTest.php | 10 ++++++++++ webroot/css/plenario.css | 7 +++++-- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index a9a861a..45241ec 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -5,6 +5,7 @@ namespace App\Controller; use App\Captcha\CaptchaFactory; use App\Mailer\PollMailer; +use App\Model\Entity\Slide; use App\Model\Table\PollsTable; use App\Service\ThrottleService; use Cake\Core\Configure; @@ -47,6 +48,18 @@ class HomeController extends AppController $poll = $this->Polls->newEmptyEntity(); $captcha = CaptchaFactory::create('create')->challenge($this->request); $this->set(compact('poll', 'captcha')); + $this->setSlideTypes(); + } + + /** + * Slide types for the start page, listed from the model so new types show up automatically. + * + * @return void + */ + protected function setSlideTypes(): void + { + $this->set('typeLabels', Slide::typeLabels()); + $this->set('typeDescriptions', Slide::typeDescriptions()); } /** @@ -91,6 +104,7 @@ class HomeController extends AppController // Re-render the start page with errors. $this->set('poll', $poll); $this->set('captcha', $captcha->challenge($this->request)); + $this->setSlideTypes(); $this->render('index'); return null; diff --git a/templates/Home/index.php b/templates/Home/index.php index 83dbc73..77634bb 100644 --- a/templates/Home/index.php +++ b/templates/Home/index.php @@ -5,6 +5,8 @@ * @var \App\View\AppView $this * @var \App\Model\Entity\Poll $poll * @var array $captcha + * @var array $typeLabels + * @var array $typeDescriptions */ $this->assign('title', __('Live-Umfragen ohne Login')); ?> @@ -53,9 +55,14 @@ $this->assign('title', __('Live-Umfragen ohne Login')); -
-
-
-
-
+
+

+
    + $label) : ?> +
  • + + +
  • + +
diff --git a/tests/TestCase/Controller/HomeControllerTest.php b/tests/TestCase/Controller/HomeControllerTest.php index e630d21..5acfafb 100644 --- a/tests/TestCase/Controller/HomeControllerTest.php +++ b/tests/TestCase/Controller/HomeControllerTest.php @@ -3,6 +3,7 @@ declare(strict_types=1); namespace App\Test\TestCase\Controller; +use App\Model\Entity\Slide; use App\Test\TestCase\PlenarioTestTrait; use Cake\Cache\Cache; use Cake\Core\Configure; @@ -42,6 +43,15 @@ class HomeControllerTest extends TestCase $this->assertResponseContains('Teilnahme-Code'); } + public function testIndexListsAllSlideTypes(): void + { + $this->get('/'); + foreach (Slide::typeLabels() as $type => $label) { + $this->assertResponseContains('type-card--' . $type, $type); + $this->assertResponseContains(h($label), $type); + } + } + public function testCreateWithValidMathCaptchaSendsAdminMail(): void { $this->session(['Captcha.math.create' => 7]); diff --git a/webroot/css/plenario.css b/webroot/css/plenario.css index c994186..c94ded6 100644 --- a/webroot/css/plenario.css +++ b/webroot/css/plenario.css @@ -116,8 +116,11 @@ h3 { font-size: 1.05rem; margin-top: 1.6em; } .hero { text-align: center; max-width: 760px; margin: 16px auto 40px; } .hero h1 { font-size: clamp(1.9rem, 4.5vw, 3rem); } -.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 16px; } -.features div { padding: 16px; border-radius: var(--radius); background: var(--surface-2); } +.features-section { margin-top: 16px; } +.features-section h2 { text-align: center; } +.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; } +/* border colour per type: .type-card--{type} below */ +.features__item { padding: 16px; border-radius: var(--radius); background: var(--surface-2); border-top: 4px solid var(--c0); } .features strong { display: block; } .features span { color: var(--muted); font-size: .9rem; }