Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_videoplayer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2022-01-05 15:03:42 +0300
committerGitHub <noreply@github.com>2022-01-05 15:03:42 +0300
commit25f5d8a299a49e496657e91348032c55c9afbc35 (patch)
tree4ecd2b843bb10829e66bdee46d46776cc76a9f03
parent3828649ea49f87fa94ecb24ae0e7631bfb55b18c (diff)
parentaf416c902c7211be664cacf7996ed962aed51c30 (diff)
Merge pull request #254 from nextcloud/enh/loading
-rw-r--r--lib/AppInfo/Application.php7
-rw-r--r--lib/Listener/BeforeTemplateRenderedListener.php42
2 files changed, 46 insertions, 3 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 3cd8a1c..eba1aac 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -11,13 +11,15 @@ declare(strict_types=1);
namespace OCA\FilesVideoPlayer\AppInfo;
+use OCA\Files\Event\LoadAdditionalScriptsEvent;
+use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
+use OCA\FilesVideoPlayer\Listener\BeforeTemplateRenderedListener;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\Security\IContentSecurityPolicyManager;
-use OCP\Util;
class Application extends App implements IBootstrap {
public const APP_ID = 'files_videoplayer';
@@ -27,11 +29,10 @@ class Application extends App implements IBootstrap {
}
public function register(IRegistrationContext $context): void {
+ $context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
}
public function boot(IBootContext $context): void {
- Util::addScript(self::APP_ID, 'files_videoplayer-main');
-
$csp = new ContentSecurityPolicy();
$csp->addAllowedWorkerSrcDomain('\'self\'');
$csp->addAllowedWorkerSrcDomain('blob:');
diff --git a/lib/Listener/BeforeTemplateRenderedListener.php b/lib/Listener/BeforeTemplateRenderedListener.php
new file mode 100644
index 0000000..0a1199b
--- /dev/null
+++ b/lib/Listener/BeforeTemplateRenderedListener.php
@@ -0,0 +1,42 @@
+<?php
+/*
+ * @copyright Copyright (c) 2021 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @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/>.
+ *
+ */
+
+declare(strict_types=1);
+
+namespace OCA\FilesVideoPlayer\Listener;
+
+use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
+use OCA\FilesVideoPlayer\AppInfo\Application;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use OCP\Util;
+
+class BeforeTemplateRenderedListener implements IEventListener {
+ public function handle(Event $event): void {
+ if (!$event instanceof BeforeTemplateRenderedEvent) {
+ return;
+ }
+
+ Util::addScript(Application::APP_ID, 'files_videoplayer-main');
+ }
+}