repod/lib/Controller/PageController.php
Michel Roux 2a4662e85b
All checks were successful
repod / nextcloud (push) Successful in 1m6s
repod / nodejs (push) Successful in 1m22s
search in PHP completed
2023-07-27 23:01:24 +02:00

45 lines
978 B
PHP

<?php
declare(strict_types=1);
namespace OCA\RePod\Controller;
use OCA\RePod\AppInfo\Application;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IRequest;
use OCP\Util;
class PageController extends Controller
{
public function __construct(IRequest $request, private IConfig $config)
{
parent::__construct(Application::APP_ID, $request);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function index(): TemplateResponse
{
Util::addScript(Application::APP_ID, 'repod-main');
$csp = new ContentSecurityPolicy();
$csp->addAllowedImageDomain('*');
if ($this->config->getSystemValueBool('debug')) {
// Unblock HMR requests.
$csp->addAllowedConnectDomain('*');
$csp->addAllowedScriptDomain('*');
}
$response = new TemplateResponse(Application::APP_ID, 'main');
$response->setContentSecurityPolicy($csp);
return $response;
}
}