Add initial Plenario live polling app
CakePHP 5.4 app for live polls: create via email without login, manage via secret admin link, join via code. Includes slide types (choice, wordcloud, open, scale, content), presenter mode, CSV export, captcha, throttling, tests and Gitea CI/deploy workflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
eb319f8c1e
120 files changed
+15572
No files matched your search
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Cake\Controller\Controller;
|
||||
use Cake\Event\EventInterface;
|
||||
use Cake\Http\Response;
|
||||
|
||||
/**
|
||||
* Base controller of Plenario.
|
||||
*/
|
||||
class AppController extends Controller
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initialize(): void
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
$this->loadComponent('Flash');
|
||||
}
|
||||
|
||||
/**
|
||||
* Security headers for every HTML response.
|
||||
*
|
||||
* @param \Cake\Event\EventInterface<\Cake\Controller\Controller> $event Event
|
||||
* @return void
|
||||
*/
|
||||
public function beforeRender(EventInterface $event): void
|
||||
{
|
||||
parent::beforeRender($event);
|
||||
|
||||
$this->response = $this->response
|
||||
->withHeader('X-Content-Type-Options', 'nosniff')
|
||||
->withHeader('X-Frame-Options', 'SAMEORIGIN')
|
||||
->withHeader('Referrer-Policy', 'same-origin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON response without going through the view layer.
|
||||
*
|
||||
* @param array<string, mixed> $data Payload
|
||||
* @param int $status HTTP status
|
||||
* @return \Cake\Http\Response
|
||||
*/
|
||||
protected function json(array $data, int $status = 200): Response
|
||||
{
|
||||
return $this->response
|
||||
->withStatus($status)
|
||||
->withType('application/json')
|
||||
->withHeader('Cache-Control', 'no-store')
|
||||
->withStringBody((string)json_encode($data, JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user