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;
|
2024-08-22 17:34:27 +02:00
|
|
|
use OCP\IConfig;
|
2024-08-25 11:53:52 +02:00
|
|
|
use OCP\IRequest;
|
2023-06-24 17:18:27 +02:00
|
|
|
use OCP\Util;
|
|
|
|
|
2023-06-24 18:37:25 +02:00
|
|
|
class PageController extends Controller
|
|
|
|
{
|
2024-08-22 17:34:27 +02:00
|
|
|
public function __construct(
|
2024-08-25 11:53:52 +02:00
|
|
|
IRequest $request,
|
2024-08-22 17:34:27 +02:00
|
|
|
private IConfig $config
|
2024-08-25 11:53:52 +02:00
|
|
|
) {
|
|
|
|
parent::__construct(Application::APP_ID, $request);
|
|
|
|
}
|
2024-08-22 17:34:27 +02:00
|
|
|
|
2023-06-24 17:18:27 +02:00
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
* @NoCSRFRequired
|
|
|
|
*/
|
2023-12-23 17:25:20 +01:00
|
|
|
public function index(): TemplateResponse {
|
2024-09-13 17:52:10 +02:00
|
|
|
Util::addScript(Application::APP_ID, Application::APP_ID.'-main');
|
2023-06-24 17:18:27 +02:00
|
|
|
|
2023-07-03 00:12:40 +02:00
|
|
|
$csp = new ContentSecurityPolicy();
|
|
|
|
$csp->addAllowedImageDomain('*');
|
2023-08-27 12:45:19 +02:00
|
|
|
$csp->addAllowedMediaDomain('*');
|
2023-07-03 00:12:40 +02:00
|
|
|
|
2024-08-22 17:34:27 +02:00
|
|
|
if ($this->config->getSystemValueBool('debug', false)) {
|
2024-08-25 11:53:52 +02:00
|
|
|
/** @psalm-suppress DeprecatedMethod */
|
2024-08-22 17:34:27 +02:00
|
|
|
$csp->allowEvalScript();
|
|
|
|
$csp->addAllowedConnectDomain('*');
|
|
|
|
$csp->addAllowedScriptDomain('*');
|
|
|
|
}
|
|
|
|
|
2024-05-29 23:47:20 +02:00
|
|
|
$response = new TemplateResponse(Application::APP_ID, 'main');
|
2023-07-03 00:12:40 +02:00
|
|
|
$response->setContentSecurityPolicy($csp);
|
2023-07-27 23:01:24 +02:00
|
|
|
|
2023-07-03 00:12:40 +02:00
|
|
|
return $response;
|
2023-06-24 17:18:27 +02:00
|
|
|
}
|
2024-08-27 09:42:52 +02:00
|
|
|
|
2024-08-27 16:41:58 +02:00
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
* @NoCSRFRequired
|
|
|
|
*/
|
|
|
|
public function discover(): TemplateResponse {
|
|
|
|
return $this->index();
|
|
|
|
}
|
|
|
|
|
2024-08-27 09:42:52 +02:00
|
|
|
/**
|
|
|
|
* @NoAdminRequired
|
|
|
|
* @NoCSRFRequired
|
|
|
|
*/
|
|
|
|
public function feed(): TemplateResponse {
|
|
|
|
return $this->index();
|
|
|
|
}
|
2023-06-24 17:18:27 +02:00
|
|
|
}
|