- Migrated from https://github.com/Yetangitu/owncloud-apps
- substantial bit rot accrued in 4 years of non-maintenance which made Reader unusable - Reader now works reliably on public pages - or at least it _Works For Me™_ - Refactored a substantial part of the code to comply to the "current" (ha ha) Nextcloud API - Dropped Owncloud compatibility for lack of a testing installation - Dropped IE (<11) support - Dropped compatibility with older (<20) Nextcloud versions - Dropped app-specific ajax code, now handled by SettingsController - Updated dependencies where applicable
This commit is contained in:
parent
16afbe45fe
commit
b190e180ef
137 changed files with 30984 additions and 2 deletions
31
lib/Listeners/CSPListener.php
Normal file
31
lib/Listeners/CSPListener.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Frank de Lange
|
||||
* @copyright 2022 Frank de Lange
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OCA\Files_Reader\Listeners;
|
||||
|
||||
use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Security\CSP\AddContentSecurityPolicyEvent;
|
||||
|
||||
class CSPListener implements IEventListener {
|
||||
public function handle(Event $event): void {
|
||||
if (!$event instanceof AddContentSecurityPolicyEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
$csp = new EmptyContentSecurityPolicy();
|
||||
$csp->addAllowedFrameDomain('\'self\'');
|
||||
$event->addPolicy($csp);
|
||||
}
|
||||
}
|
47
lib/Listeners/LoadPublicViewerListener.php
Normal file
47
lib/Listeners/LoadPublicViewerListener.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Frank de Lange
|
||||
* @copyright 2022 Frank de Lange
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OCA\Files_Reader\Listeners;
|
||||
|
||||
use OCA\Files_Reader\AppInfo\Application;
|
||||
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\AppFramework\Services\IInitialState;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Util;
|
||||
|
||||
class LoadPublicViewerListener implements IEventListener {
|
||||
private IInitialState $initialStateService;
|
||||
|
||||
public function __construct(
|
||||
IInitialState $initialStateService,
|
||||
) {
|
||||
$this->initialStateService = $initialStateService;
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if (!$event instanceof BeforeTemplateRenderedEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure we are on a public page rendering
|
||||
if ($event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_PUBLIC) {
|
||||
return;
|
||||
}
|
||||
$this->initialStateService->provideInitialState('epub_enabled', 'true');
|
||||
$this->initialStateService->provideInitialState('pdf_enabled', 'true');
|
||||
$this->initialStateService->provideInitialState('cbx_enabled', 'true');
|
||||
Util::addScript(Application::APP_ID, 'plugin-public');
|
||||
}
|
||||
}
|
51
lib/Listeners/LoadViewerListener.php
Normal file
51
lib/Listeners/LoadViewerListener.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @author Frank de Lange
|
||||
* @copyright 2022 Frank de Lange
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
namespace OCA\Files_Reader\Listeners;
|
||||
|
||||
use OCA\Files_Reader\AppInfo\Application;
|
||||
use OCA\Viewer\Event\LoadViewer;
|
||||
use OCP\AppFramework\Services\IInitialState;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\Util;
|
||||
use OCP\IConfig;
|
||||
use OCP\IUserSession;
|
||||
|
||||
class LoadViewerListener implements IEventListener {
|
||||
private IInitialState $initialStateService;
|
||||
private IConfig $config;
|
||||
private string $userId;
|
||||
|
||||
|
||||
|
||||
public function __construct(
|
||||
IInitialState $initialStateService,
|
||||
IConfig $config,
|
||||
string $userId
|
||||
) {
|
||||
$this->initialStateService = $initialStateService;
|
||||
$this->config = $config;
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
public function handle(Event $event): void {
|
||||
if (!($event instanceof LoadViewer || $event instanceof LoadAdditionalScriptsEvent)) {
|
||||
return;
|
||||
}
|
||||
$this->initialStateService->provideInitialState('epub_enabled', $this->config->getUserValue($this->userId, Application::APP_ID, 'epub_enable'));
|
||||
$this->initialStateService->provideInitialState('pdf_enabled', $this->config->getUserValue($this->userId, Application::APP_ID, 'pdf_enable'));
|
||||
$this->initialStateService->provideInitialState('cbx_enabled', $this->config->getUserValue($this->userId, Application::APP_ID, 'cbx_enable'));
|
||||
Util::addScript(Application::APP_ID, 'plugin');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue