RePod-Nextcloud-App/lib/Controller/PageController.php

42 lines
975 B
PHP
Raw Normal View History

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