- 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:
Frank de Lange 2022-09-24 00:00:03 +00:00
parent 16afbe45fe
commit b190e180ef
137 changed files with 30984 additions and 2 deletions

View 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);
}
}

View 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');
}
}

View 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');
}
}