Skip to content

Commit

Permalink
Merge pull request #979 from nextcloud/enh/viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed May 25, 2020
2 parents 1dfead4 + af19f36 commit e9b97fb
Show file tree
Hide file tree
Showing 11 changed files with 1,316 additions and 1,206 deletions.
5 changes: 2 additions & 3 deletions appinfo/app.php
Expand Up @@ -37,14 +37,13 @@
$eventDispatcher->addListener(
'OCA\Files::loadAdditionalScripts',
function() {
\OCP\Util::addScript('richdocuments', 'viewer');
\OCP\Util::addStyle('richdocuments', 'viewer');
\OCP\Util::addScript('richdocuments', 'files');
}
);
$eventDispatcher->addListener(
'OCA\Files_Sharing::loadAdditionalScripts',
function() {
\OCP\Util::addScript('richdocuments', 'viewer');
\OCP\Util::addScript('richdocuments', 'files');
}
);

Expand Down
9 changes: 9 additions & 0 deletions lib/AppInfo/Application.php
Expand Up @@ -34,7 +34,9 @@
use OCA\Richdocuments\Preview\OpenDocument;
use OCA\Richdocuments\Preview\Pdf;
use OCA\Richdocuments\Service\FederationService;
use OCA\Viewer\Event\LoadViewer;
use OCP\AppFramework\App;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IPreview;

class Application extends App {
Expand All @@ -44,6 +46,12 @@ class Application extends App {
public function __construct(array $urlParams = array()) {
parent::__construct(self::APPNAME, $urlParams);

/** @var IEventDispatcher $eventDispatcher */
$eventDispatcher = $this->getContainer()->getServer()->query(IEventDispatcher::class);
$eventDispatcher->addListener(LoadViewer::class, function () {
\OCP\Util::addScript('richdocuments', 'viewer');
});

$this->getContainer()->registerCapability(Capabilities::class);
}

Expand Down Expand Up @@ -93,6 +101,7 @@ public function updateCSP() {
$cspManager = $container->getServer()->getContentSecurityPolicyManager();
$policy = new ContentSecurityPolicy();
if ($publicWopiUrl !== '') {
$policy->addAllowedFrameDomain('\'self\'');
$policy->addAllowedFrameDomain($publicWopiUrl);
if (method_exists($policy, 'addAllowedFormActionDomain')) {
$policy->addAllowedFormActionDomain($publicWopiUrl);
Expand Down
11 changes: 9 additions & 2 deletions lib/Controller/DocumentController.php
Expand Up @@ -217,12 +217,19 @@ public function open($fileId) {
* @NoAdminRequired
*
* @param string $fileId
* @param string|null $path
* @return RedirectResponse|TemplateResponse
*/
public function index($fileId) {
public function index($fileId, $path = null) {
try {
$folder = $this->rootFolder->getUserFolder($this->uid);
$item = $folder->getById($fileId)[0];

if ($path !== null) {
$item = $folder->get($path);
} else {
$item = $folder->getById($fileId)[0];
}

if(!($item instanceof File)) {
throw new \Exception();
}
Expand Down

0 comments on commit e9b97fb

Please sign in to comment.