49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\Retro\Controller;
|
|
|
|
use OCA\Retro\AppInfo\Application;
|
|
use OCP\AppFramework\Controller;
|
|
use OCP\AppFramework\Http\Attribute\FrontpageRoute;
|
|
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
|
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
use OCP\Files\IRootFolder;
|
|
use OCP\IRequest;
|
|
use OCP\IUserSession;
|
|
use OCP\Util;
|
|
|
|
class PageController extends Controller
|
|
{
|
|
public function __construct(
|
|
IRequest $request,
|
|
private readonly IRootFolder $rootFolder,
|
|
private readonly IUserSession $userSession
|
|
) {
|
|
parent::__construct(Application::APP_ID, $request);
|
|
}
|
|
|
|
#[NoCSRFRequired]
|
|
#[NoAdminRequired]
|
|
#[FrontpageRoute(verb: 'GET', url: '/{path}', requirements: ['path' => '.+'])]
|
|
public function run(string $path): TemplateResponse {
|
|
$user = $this->userSession->getUser();
|
|
|
|
if (!$user) {
|
|
throw new \Exception('User not logged in');
|
|
}
|
|
|
|
$folder = $this->rootFolder->getUserFolder($user->getUID());
|
|
$folder->get($path);
|
|
|
|
Util::addScript(Application::APP_ID, Application::APP_ID.'-main');
|
|
|
|
return new TemplateResponse(
|
|
Application::APP_ID,
|
|
'index',
|
|
);
|
|
}
|
|
}
|