60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Radio App.
|
|
*
|
|
* @author Jonas Heinrich
|
|
* @copyright 2021 Jonas Heinrich <onny@project-insanity.org>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* License as published by the Free Software Foundation; either
|
|
* version 3 of the License, or any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\Radio\Controller;
|
|
|
|
use OCA\Radio\AppInfo\Application;
|
|
use OCP\AppFramework\Controller;
|
|
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
|
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
|
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
use OCP\IRequest;
|
|
use OCP\Util;
|
|
|
|
class PageController extends Controller
|
|
{
|
|
public function __construct(IRequest $request) {
|
|
parent::__construct(Application::APP_ID, $request);
|
|
}
|
|
|
|
#[NoAdminRequired]
|
|
#[NoCSRFRequired]
|
|
public function index(): TemplateResponse {
|
|
Util::addScript(Application::APP_ID, 'radio-main');
|
|
Util::addStyle(Application::APP_ID, 'icons');
|
|
|
|
// Allow radio-browser hosts in the csp
|
|
$policy = new ContentSecurityPolicy();
|
|
$policy->addAllowedConnectDomain('https://de1.api.radio-browser.info');
|
|
$policy->addAllowedImageDomain('*');
|
|
$policy->addAllowedMediaDomain('*');
|
|
|
|
$response = new TemplateResponse(Application::APP_ID, 'main');
|
|
$response->setContentSecurityPolicy($policy);
|
|
|
|
return $response;
|
|
}
|
|
}
|