diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-12 14:17:28 +0300 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-13 17:19:05 +0300 |
commit | 7b2198f24b873f1fd7869c0e87add794fd5e4ebe (patch) | |
tree | 8840b086e1097bfe21fcb05fcca90d48ef32713e /lib | |
parent | df9f2eb4339811156eb5be390847f71f597d43df (diff) |
Move packaging to webpack and update/clean all configs
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AppInfo/Application.php | 11 | ||||
-rw-r--r-- | lib/Controller/DisplayController.php | 36 | ||||
-rw-r--r-- | lib/Listeners/LoadViewerListener.php | 42 |
3 files changed, 74 insertions, 15 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 62d877b..713f742 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -1,10 +1,12 @@ <?php declare(strict_types=1); + /** * @copyright 2020 Morris Jobke <hey@morrisjobke.de> * * @author Morris Jobke <hey@morrisjobke.de> + * @author John Molakvoæ <skjnldsv@protonmail.com> * * @license GNU AGPL version 3 or any later version * @@ -20,15 +22,17 @@ declare(strict_types=1); * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. + * */ -namespace OCA\Files_PdfViewer\AppInfo; +namespace OCA\Files_PDFViewer\AppInfo; +use OCA\Files_PDFViewer\Listeners\LoadViewerListener; +use OCA\Viewer\Event\LoadViewer; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; -use OCP\Util; class Application extends App implements IBootstrap { public const APP_ID = 'files_pdfviewer'; @@ -38,10 +42,9 @@ class Application extends App implements IBootstrap { } public function register(IRegistrationContext $context): void { + $context->registerEventListener(LoadViewer::class, LoadViewerListener::class); } public function boot(IBootContext $context): void { - Util::addScript('files_pdfviewer', 'previewplugin'); - Util::addStyle('files_pdfviewer', 'style'); } } diff --git a/lib/Controller/DisplayController.php b/lib/Controller/DisplayController.php index 4de23f1..d7d90d0 100644 --- a/lib/Controller/DisplayController.php +++ b/lib/Controller/DisplayController.php @@ -1,16 +1,33 @@ <?php + declare(strict_types=1); + /** - * @author Lukas Reschke * @copyright 2014 Lukas Reschke lukas@owncloud.com * - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. + * @author Lukas Reschke <lukas@owncloud.com> + * @author John Molakvoæ <skjnldsv@protonmail.com> + * + * @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 <http://www.gnu.org/licenses/>. + * */ -namespace OCA\Files_PdfViewer\Controller; +namespace OCA\Files_PDFViewer\Controller; +use OCA\Files_PDFViewer\AppInfo\Application; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\TemplateResponse; @@ -23,14 +40,12 @@ class DisplayController extends Controller { private $urlGenerator; /** - * @param string $AppName * @param IRequest $request * @param IURLGenerator $urlGenerator */ - public function __construct(string $AppName, - IRequest $request, + public function __construct(IRequest $request, IURLGenerator $urlGenerator) { - parent::__construct($AppName, $request); + parent::__construct(Application::APP_ID, $request); $this->urlGenerator = $urlGenerator; } @@ -46,7 +61,7 @@ class DisplayController extends Controller { 'urlGenerator' => $this->urlGenerator, 'minmode' => $minmode ]; - $response = new TemplateResponse($this->appName, 'viewer', $params, 'blank'); + $response = new TemplateResponse(Application::APP_ID, 'viewer', $params, 'blank'); $policy = new ContentSecurityPolicy(); $policy->addAllowedChildSrcDomain('\'self\''); @@ -57,5 +72,4 @@ class DisplayController extends Controller { return $response; } - } diff --git a/lib/Listeners/LoadViewerListener.php b/lib/Listeners/LoadViewerListener.php new file mode 100644 index 0000000..a382b66 --- /dev/null +++ b/lib/Listeners/LoadViewerListener.php @@ -0,0 +1,42 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2020 John Molakvoæ <skjnldsv@protonmail.com> + * + * @author John Molakvoæ <skjnldsv@protonmail.com> + * + * @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 <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\Files_PDFViewer\Listeners; + +use OCA\Files_PDFViewer\AppInfo\Application; +use OCA\Viewer\Event\LoadViewer; +use OCP\EventDispatcher\Event; +use OCP\EventDispatcher\IEventListener; +use OCP\Util; + +class LoadViewerListener implements IEventListener { + public function handle(Event $event): void { + if (!$event instanceof LoadViewer) { + return; + } + Util::addScript(Application::APP_ID, 'files_pdfviewer-main'); + } +} |