diff --git a/appinfo/routes.php b/appinfo/routes.php index 891c2d29a..c0498c6b9 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -49,12 +49,13 @@ ['name' => 'public#watch_poll', 'url' => '/s/{token}/watch', 'verb' => 'GET'], ['name' => 'admin#index', 'url' => '/administration', 'verb' => 'GET'], + ['name' => 'admin#list', 'url' => '/administration/polls', 'verb' => 'GET'], ['name' => 'admin#takeover', 'url' => '/administration/poll/{pollId}/takeover', 'verb' => 'PUT'], ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], ['name' => 'page#index', 'url' => '/not-found', 'verb' => 'GET', 'postfix' => 'notfound'], - ['name' => 'page#index', 'url' => '/list/{id}', 'verb' => 'GET', 'postfix' => 'list'], + ['name' => 'page#index', 'url' => '/list/{category}', 'verb' => 'GET', 'postfix' => 'list', 'defaults' => array('category' => 'relevant')], ['name' => 'page#index', 'url' => '/combo', 'verb' => 'GET', 'postfix' => 'combo'], ['name' => 'page#vote', 'url' => '/vote/{id}', 'verb' => 'GET'], diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index 5bd95bd21..9e945dff4 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -27,9 +27,12 @@ use OCA\Polls\Service\PollService; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\TemplateResponse; +use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; +use OCP\Util; class AdminController extends BaseController { public function __construct( @@ -37,7 +40,8 @@ public function __construct( IRequest $request, ISession $session, private IURLGenerator $urlGenerator, - private PollService $pollService + private PollService $pollService, + private IEventDispatcher $eventDispatcher, ) { parent::__construct($appName, $request, $session); } @@ -46,7 +50,9 @@ public function __construct( * @NoCSRFRequired */ public function index(): TemplateResponse { - return new TemplateResponse(AppConstants::APP_ID, 'polls.tmpl', ['urlGenerator' => $this->urlGenerator]); + Util::addScript(AppConstants::APP_ID, 'polls-main'); + $this->eventDispatcher->dispatchTyped(new LoadAdditionalScriptsEvent()); + return new TemplateResponse(AppConstants::APP_ID, 'main', ['urlGenerator' => $this->urlGenerator]); } /** diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index f75cf1915..48baebed7 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -29,15 +29,19 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; +use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IRequest; use OCP\IURLGenerator; +use OCP\Util; class PageController extends Controller { public function __construct( string $appName, IRequest $request, private IURLGenerator $urlGenerator, - private NotificationService $notificationService + private NotificationService $notificationService, + private IEventDispatcher $eventDispatcher, ) { parent::__construct($appName, $request); } @@ -47,7 +51,9 @@ public function __construct( * @NoCSRFRequired */ public function index(): TemplateResponse { - return new TemplateResponse(AppConstants::APP_ID, 'polls.tmpl', ['urlGenerator' => $this->urlGenerator]); + Util::addScript(AppConstants::APP_ID, 'polls-main'); + $this->eventDispatcher->dispatchTyped(new LoadAdditionalScriptsEvent()); + return new TemplateResponse(AppConstants::APP_ID, 'main'); } /** @@ -56,6 +62,7 @@ public function index(): TemplateResponse { */ public function vote(int $id): TemplateResponse { $this->notificationService->removeNotification($id); - return new TemplateResponse(AppConstants::APP_ID, 'polls.tmpl', ['urlGenerator' => $this->urlGenerator]); + Util::addScript(AppConstants::APP_ID, 'polls-main'); + return new TemplateResponse(AppConstants::APP_ID, 'main'); } } diff --git a/lib/Controller/PublicController.php b/lib/Controller/PublicController.php index b17989885..4521a02da 100644 --- a/lib/Controller/PublicController.php +++ b/lib/Controller/PublicController.php @@ -41,6 +41,7 @@ use OCP\ISession; use OCP\IURLGenerator; use OCP\IUserSession; +use OCP\Util; class PublicController extends BaseController { public function __construct( @@ -69,10 +70,11 @@ public function __construct( * @return TemplateResponse|PublicTemplateResponse */ public function votePage(string $token) { + Util::addScript(AppConstants::APP_ID, 'polls-main'); if ($this->userSession->isLoggedIn()) { - return new TemplateResponse(AppConstants::APP_ID, 'polls.tmpl', ['urlGenerator' => $this->urlGenerator]); + return new TemplateResponse(AppConstants::APP_ID, 'main'); } else { - $template = new PublicTemplateResponse(AppConstants::APP_ID, 'polls.tmpl', ['urlGenerator' => $this->urlGenerator]); + $template = new PublicTemplateResponse(AppConstants::APP_ID, 'main'); $template->setFooterVisible(false); return $template; } diff --git a/lib/Settings/AdminSettings.php b/lib/Settings/AdminSettings.php index b402fa908..74829dc75 100644 --- a/lib/Settings/AdminSettings.php +++ b/lib/Settings/AdminSettings.php @@ -26,10 +26,12 @@ use OCA\Polls\AppConstants; use OCP\AppFramework\Http\TemplateResponse; use OCP\Settings\ISettings; +use OCP\Util; class AdminSettings implements ISettings { public function getForm(): TemplateResponse { - return new TemplateResponse(AppConstants::APP_ID, 'admin', []); + Util::addScript(AppConstants::APP_ID, 'polls-adminSettings'); + return new TemplateResponse(AppConstants::APP_ID, 'main', []); } public function getSection(): string { diff --git a/lib/Settings/PersonalSettings.php b/lib/Settings/PersonalSettings.php index 0a98b8e1b..e4c6adc19 100644 --- a/lib/Settings/PersonalSettings.php +++ b/lib/Settings/PersonalSettings.php @@ -26,10 +26,12 @@ use OCA\Polls\AppConstants; use OCP\AppFramework\Http\TemplateResponse; use OCP\Settings\ISettings; +use OCP\Util; class PersonalSettings implements ISettings { public function getForm(): TemplateResponse { - return new TemplateResponse(AppConstants::APP_ID, 'settings', []); + Util::addScript(AppConstants::APP_ID, 'polls-userSettings'); + return new TemplateResponse(AppConstants::APP_ID, 'main', []); } public function getSection(): string { diff --git a/src/js/adminSettings.js b/src/js/adminSettings.js index 8dc65090b..6cd8ead8a 100644 --- a/src/js/adminSettings.js +++ b/src/js/adminSettings.js @@ -51,7 +51,7 @@ const store = new Store({ /* eslint-disable-next-line no-new */ new Vue({ - el: '#admin_settings', + el: '#content_polls', store, render: (h) => h(AdminSettingsPage), }) diff --git a/src/js/router.js b/src/js/router.js index 7090513e1..7ea3feb85 100644 --- a/src/js/router.js +++ b/src/js/router.js @@ -93,6 +93,15 @@ export default new Router({ }, }, }, + { + path: '/list', + redirect: { + name: 'list', + params: { + type: 'relevant', + }, + }, + }, { path: '/list/:type?', components: { diff --git a/src/js/userSettings.js b/src/js/userSettings.js index d0a121489..545c1332e 100644 --- a/src/js/userSettings.js +++ b/src/js/userSettings.js @@ -53,7 +53,7 @@ const store = new Store({ /* eslint-disable-next-line no-new */ new Vue({ - el: '#user_settings', + el: '#content_polls', store, render: (h) => h(UserSettingsPage), }) diff --git a/templates/admin.php b/templates/admin.php deleted file mode 100644 index aef0241cf..000000000 --- a/templates/admin.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * @author René Gieling - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 program. If not, see . - * - */ -declare(strict_types=1); - -script('polls', 'polls-adminSettings'); -?> -
diff --git a/templates/main.php b/templates/main.php new file mode 100644 index 000000000..6df80ac95 --- /dev/null +++ b/templates/main.php @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/templates/polls.tmpl.php b/templates/polls.tmpl.php deleted file mode 100644 index 3153d1423..000000000 --- a/templates/polls.tmpl.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * @author Vinzenz Rosenkranz - * @author René Gieling - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 program. If not, see . - * - */ -declare(strict_types=1); - -script('polls', 'polls-main'); -\OC::$server->getEventDispatcher()->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts'); diff --git a/templates/settings.php b/templates/settings.php deleted file mode 100644 index fc82d565a..000000000 --- a/templates/settings.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * @author René Gieling - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 program. If not, see . - * - */ -declare(strict_types=1); - -script('polls', 'polls-userSettings'); -?> -