64 lines
1.3 KiB
PHP
64 lines
1.3 KiB
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, 'main');
|
|
|
|
$csp = new ContentSecurityPolicy();
|
|
$csp->addAllowedImageDomain('*');
|
|
$csp->addAllowedMediaDomain('*');
|
|
|
|
if ($this->config->getSystemValueBool('debug', false)) {
|
|
/** @psalm-suppress DeprecatedMethod */
|
|
$csp->allowEvalScript();
|
|
$csp->addAllowedConnectDomain('*');
|
|
$csp->addAllowedScriptDomain('*');
|
|
}
|
|
|
|
$response = new TemplateResponse(Application::APP_ID, 'main');
|
|
$response->setContentSecurityPolicy($csp);
|
|
|
|
return $response;
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
public function discover(): TemplateResponse {
|
|
return $this->index();
|
|
}
|
|
|
|
/**
|
|
* @NoAdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
public function feed(): TemplateResponse {
|
|
return $this->index();
|
|
}
|
|
}
|