Skip to content

Commit

Permalink
Fix for #133
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Rojek committed Mar 10, 2021
1 parent cf4d037 commit 0fdc792
Show file tree
Hide file tree
Showing 9 changed files with 550 additions and 220 deletions.
3 changes: 3 additions & 0 deletions drawio/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Change Log

## 1.0.0
-

## 0.9.9
- NC21 compatibility
- public link support (#20)
Expand Down
17 changes: 17 additions & 0 deletions drawio/appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use OCA\Drawio\AppConfig;
use OCA\Drawio\Controller\DisplayController;
use OCA\Drawio\Controller\EditorController;
use OCA\Drawio\Controller\ViewerController;
use OCA\Drawio\Controller\SettingsController;

class Application extends App {
Expand Down Expand Up @@ -105,5 +106,21 @@ function() {
$c->query("Session")
);
});

$container->registerService("ViewerController", function($c)
{
return new ViewerController(
$c->query("AppName"),
$c->query("Request"),
$c->query("RootStorage"),
$c->query("UserSession"),
$c->query("ServerContainer")->getURLGenerator(),
$c->query("L10N"),
$c->query("Logger"),
$this->appConfig,
$c->query("IManager"),
$c->query("Session")
);
});
}
}
7 changes: 5 additions & 2 deletions drawio/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
["name" => "editor#index", "url" => "/{fileId}", "verb" => "GET"],
["name" => "editor#create", "url" => "/ajax/new", "verb" => "POST"],

["name" => "editor#public_page", "url" => "/s/{shareToken}", "verb" => "GET"],
["name" => "editor#public_file", "url" => "/ajax/shared/{fileId}", "verb" => "GET"],
//["name" => "editor#public_page", "url" => "/s/{shareToken}", "verb" => "GET"],
//["name" => "editor#public_file", "url" => "/ajax/shared/{fileId}", "verb" => "GET"],

["name" => "viewer#public_page", "url" => "/s/{shareToken}", "verb" => "GET"],
["name" => "viewer#public_file", "url" => "/ajax/shared/{fileId}", "verb" => "GET"],

["name" => "settings#settings", "url" => "/ajax/settings", "verb" => "POST"],
["name" => "settings#getsettings", "url" => "/ajax/settings", "verb" => "GET"],
Expand Down
16 changes: 16 additions & 0 deletions drawio/controller/editorcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

use OCA\Files\Helper;
use OCA\Files_Versions\Storage;
use OCA\Viewer\Event\LoadViewer;

use OCA\Drawio\AppConfig;

Expand Down Expand Up @@ -173,6 +174,8 @@ public function index($fileId, $shareToken = NULL, $filePath = NULL) {
$lang = $this->config->GetLang();
$lang = trim(strtolower($lang));

$eventDispatcher = \OC::$server->getEventDispatcher();

if ("auto" === $lang)
{
$lang = \OC::$server->getL10NFactory("")->get("")->getLanguageCode();
Expand Down Expand Up @@ -226,6 +229,19 @@ public function index($fileId, $shareToken = NULL, $filePath = NULL) {
"shareToken" => $shareToken
];

//viewer code
if (class_exists(LoadViewer::class)) {
$eventDispatcher->addListener(LoadViewer::class,
function () {
Util::addScript("drawio", "viewer");
$csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain("'self'");
$cspManager = $this->getContainer()->getServer()->getContentSecurityPolicyManager();
$cspManager->addDefaultPolicy($csp);
});
}
//viewer code

$response = new TemplateResponse($this->appName, "editor", $params);

$csp = new ContentSecurityPolicy();
Expand Down
Loading

0 comments on commit 0fdc792

Please sign in to comment.