Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions appinfo/app.php

This file was deleted.

2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<screenshot small-thumbnail="https://raw.githubusercontent.com/ACTom/files_mindmap/master/screenshots/2-small.png">https://raw.githubusercontent.com/ACTom/files_mindmap/master/screenshots/2.png</screenshot>
<screenshot small-thumbnail="https://raw.githubusercontent.com/ACTom/files_mindmap/master/screenshots/3-small.png">https://raw.githubusercontent.com/ACTom/files_mindmap/master/screenshots/3.png</screenshot>
<dependencies>
<nextcloud min-version="14" max-version="27"/>
<nextcloud min-version="20" max-version="27"/>
</dependencies>
<repair-steps>
<install>
Expand Down
42 changes: 38 additions & 4 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,57 @@
namespace OCA\Files_MindMap\AppInfo;

use OC\Files\Type\Detection;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files_MindMap\Listener\LoadAdditionalScripts;
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\EventDispatcher\IEventDispatcher;
use OCP\Files\IMimeTypeDetector;
use OCP\Security\CSP\AddContentSecurityPolicyEvent;

class Application extends App {

class Application extends App implements IBootstrap {
const APPNAME = 'files_mindmap';

public function __construct(array $urlParams = array()) {
parent::__construct(self::APPNAME, $urlParams);
}


public function registerProvider() {
$container = $this->getContainer();

// Register mimetypes
/** @var Detection $detector */
$detector = $container->query(\OCP\Files\IMimeTypeDetector::class);
$detector = $container->get(IMimeTypeDetector::class);
$detector->getAllMappings();
$detector->registerType('km','application/km');
}
}

public function register(IRegistrationContext $context): void {

$context->registerEventListener(
LoadAdditionalScriptsEvent::class,
LoadAdditionalScripts::class
);
}

public function boot(IBootContext $context): void {
$this->registerProvider();

$context->injectFn([$this, 'registerEventsSecurity']);
}

public function registerEventsSecurity(IEventDispatcher $dispatcher): void {
$dispatcher->addListener(AddContentSecurityPolicyEvent::class, function (AddContentSecurityPolicyEvent $e) {
$policy = new ContentSecurityPolicy();
$policy->addAllowedChildSrcDomain("'self'");
$policy->addAllowedFrameDomain("data:");
$e->addPolicy($policy);
});

}
}
23 changes: 23 additions & 0 deletions lib/Listener/LoadAdditionalScripts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace OCA\Files_MindMap\Listener;

use OCA\Files_MindMap\AppInfo\Application;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Util;

class LoadAdditionalScripts implements IEventListener {
public function handle(Event $event): void {
if (!($event instanceof LoadAdditionalScriptsEvent)) {
return;
}

Util::addStyle(Application::APPNAME, 'style');
Util::addScript(Application::APPNAME, 'jszip');
Util::addScript(Application::APPNAME, 'mindmap');
}
}