Skip to content

Commit

Permalink
Merge pull request #305 from ONLYOFFICE/develop
Browse files Browse the repository at this point in the history
Release/4.3.0
  • Loading branch information
LinneyS authored Jun 25, 2020
2 parents f91753d + 4c04a0b commit 4b4722a
Show file tree
Hide file tree
Showing 32 changed files with 457 additions and 193 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## 4.3.0
## Added
- integration to viewer app
- show the version of the Document Service on the settings page

## Changed
- Nextcloud v16 is no longer supported
- notification with toastify
- proper header bar for public share links

## 4.2.0
## Added
- review display settings
Expand Down
32 changes: 32 additions & 0 deletions appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
namespace OCA\Onlyoffice\AppInfo;

use OCP\AppFramework\App;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\DirectEditing\RegisterDirectEditorEvent;
use OCP\Util;

use OCA\Viewer\Event\LoadViewer;

use OCA\Onlyoffice\AppConfig;
use OCA\Onlyoffice\Controller\CallbackController;
use OCA\Onlyoffice\Controller\EditorController;
Expand Down Expand Up @@ -73,15 +76,44 @@ function() {
&& $this->appConfig->isUserAllowedToUse()) {
Util::addScript("onlyoffice", "desktop");
Util::addScript("onlyoffice", "main");

if ($this->appConfig->GetSameTab()) {
Util::addScript("onlyoffice", "listener");
}

Util::addStyle("onlyoffice", "main");
}
});

if (class_exists(LoadViewer::class)) {
$eventDispatcher->addListener(LoadViewer::class,
function() {
if (!empty($this->appConfig->GetDocumentServerUrl())
&& $this->appConfig->SettingsAreSuccessful()
&& $this->appConfig->isUserAllowedToUse()) {
Util::addScript("onlyoffice", "viewer");
Util::addScript("onlyoffice", "listener");

Util::addStyle("onlyoffice", "viewer");

$csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain("'self'");
$cspManager = $this->getContainer()->getServer()->getContentSecurityPolicyManager();
$cspManager->addDefaultPolicy($csp);
}
});
}

$eventDispatcher->addListener("OCA\Files_Sharing::loadAdditionalScripts",
function() {
if (!empty($this->appConfig->GetDocumentServerUrl())
&& $this->appConfig->SettingsAreSuccessful()) {
Util::addScript("onlyoffice", "main");

if ($this->appConfig->GetSameTab()) {
Util::addScript("onlyoffice", "listener");
}

Util::addStyle("onlyoffice", "main");
}
});
Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description>ONLYOFFICE connector enables you to edit Office documents within ONLYOFFICE from the familiar web interface. This will create a new Open in ONLYOFFICE action within the document library for Office documents. This allows multiple users to collaborate in real time and to save back those changes to your file storage.</description>
<licence>agpl</licence>
<author mail="dev@onlyoffice.com" homepage="https://www.onlyoffice.com/">Ascensio System SIA</author>
<version>4.2.0</version>
<version>4.3.0</version>
<namespace>Onlyoffice</namespace>
<types>
<filesystem/>
Expand All @@ -29,7 +29,7 @@
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/new.png</screenshot>
<screenshot>https://raw.githubusercontent.com/ONLYOFFICE/onlyoffice-nextcloud/master/screenshots/open.png</screenshot>
<dependencies>
<nextcloud min-version="16" max-version="19"/>
<nextcloud min-version="17" max-version="19"/>
</dependencies>
<settings>
<admin>OCA\Onlyoffice\AdminSettings</admin>
Expand Down
18 changes: 15 additions & 3 deletions controller/editorcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\RedirectResponse;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
use OCP\Constants;
use OCP\Files\File;
use OCP\Files\Folder;
Expand Down Expand Up @@ -469,7 +470,8 @@ public function url($filePath) {
public function index($fileId, $filePath = null, $shareToken = null, $inframe = false) {
$this->logger->debug("Open: $fileId $filePath", ["app" => $this->appName]);

if (empty($shareToken) && !$this->userSession->isLoggedIn()) {
$isLoggedIn = $this->userSession->isLoggedIn();
if (empty($shareToken) && !$isLoggedIn) {
$redirectUrl = $this->urlGenerator->linkToRoute("core.login.showLoginForm", [
"redirect_url" => $this->request->getRequestUri()
]);
Expand All @@ -496,11 +498,21 @@ public function index($fileId, $filePath = null, $shareToken = null, $inframe =
"inframe" => false
];

$response = null;
if ($inframe === true) {
$params["inframe"] = true;
$response = new TemplateResponse($this->appName, "editor", $params, "plain");
} else {
$response = new TemplateResponse($this->appName, "editor", $params);
if ($isLoggedIn) {
$response = new TemplateResponse($this->appName, "editor", $params);
} else {
$response = new PublicTemplateResponse($this->appName, "editor", $params);

list ($file, $error, $share) = $this->fileUtility->getFileByToken($fileId, $shareToken);
if (!isset($error)) {
$response->setHeaderTitle($file->getName());
}
}
}

$csp = new ContentSecurityPolicy();
Expand All @@ -510,7 +522,7 @@ public function index($fileId, $filePath = null, $shareToken = null, $inframe =
$csp->addAllowedScriptDomain($documentServerUrl);
$csp->addAllowedFrameDomain($documentServerUrl);
} else {
$csp->addAllowedFrameDomain($this->urlGenerator->getAbsoluteURL("/"));
$csp->addAllowedFrameDomain("'self'");
}
$response->setContentSecurityPolicy($csp);

Expand Down
22 changes: 13 additions & 9 deletions controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ public function SaveAddress($documentserver,
}
$this->config->SetStorageUrl($storageUrl);

$version = null;
if (empty($error)) {
$documentserver = $this->config->GetDocumentServerUrl();
if (!empty($documentserver)) {
$error = $this->checkDocServiceUrl();
list ($error, $version) = $this->checkDocServiceUrl();
$this->config->SetSettingsError($error);
}
}
Expand All @@ -177,7 +178,8 @@ public function SaveAddress($documentserver,
"documentserverInternal" => $this->config->GetDocumentServerInternalUrl(true),
"storageUrl" => $this->config->GetStorageUrl(),
"secret" => $this->config->GetDocumentServerSecret(true),
"error" => $error
"error" => $error,
"version" => $version,
];
}

Expand Down Expand Up @@ -266,19 +268,21 @@ public function GetSettings() {
/**
* Checking document service location
*
* @return string
* @return array
*/
private function checkDocServiceUrl() {
$version = null;

try {

if (preg_match("/^https:\/\//i", $this->urlGenerator->getAbsoluteURL("/"))
&& preg_match("/^http:\/\//i", $this->config->GetDocumentServerUrl())) {
throw new \Exception($this->trans->t("Mixed Active Content is not allowed. HTTPS address for Document Server is required."));
}

} catch (\Exception $e) {
$this->logger->logException($e, ["Protocol on check error", "app" => $this->appName]);
return $e->getMessage();
return [$e->getMessage(), $version];
}

try {
Expand All @@ -292,7 +296,7 @@ private function checkDocServiceUrl() {

} catch (\Exception $e) {
$this->logger->logException($e, ["HealthcheckRequest on check error", "app" => $this->appName]);
return $e->getMessage();
return [$e->getMessage(), $version];
}

try {
Expand All @@ -314,7 +318,7 @@ private function checkDocServiceUrl() {

} catch (\Exception $e) {
$this->logger->logException($e, ["CommandRequest on check error", "app" => $this->appName]);
return $e->getMessage();
return [$e->getMessage(), $version];
}

$convertedFileUri = null;
Expand All @@ -330,16 +334,16 @@ private function checkDocServiceUrl() {

} catch (\Exception $e) {
$this->logger->logException($e, ["GetConvertedUri on check error", "app" => $this->appName]);
return $e->getMessage();
return [$e->getMessage(), $version];
}

try {
$documentService->Request($convertedFileUri);
} catch (\Exception $e) {
$this->logger->logException($e, ["Request converted file on check error", "app" => $this->appName]);
return $e->getMessage();
return [$e->getMessage(), $version];
}

return "";
return ["", $version];
}
}
9 changes: 7 additions & 2 deletions css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@
*
*/

#content.app-onlyoffice {
#content.app-onlyoffice,
#body-public #content.app-onlyoffice {
min-height: calc(100% - 50px);
}

#body-public #content {
#body-public #content.app-public {
height: 100%;
}

#body-public footer {
display: none;
}

#app > iframe {
position: absolute;
vertical-align: top;
Expand Down
37 changes: 37 additions & 0 deletions css/viewer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
*
* (c) Copyright Ascensio System SIA 2020
*
* This program is a free software product.
* You can redistribute it and/or modify it under the terms of the GNU Affero General Public License
* (AGPL) version 3 as published by the Free Software Foundation.
* In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions of the Program
* must display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product logo when distributing the program.
* Pursuant to Section 7(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as well as technical
* writing content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International.
* See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/

#onlyofficeViewerFrame {
background-color: #fff;
width: 100%;
height: calc(100vh - 50px);
display: block;
position: absolute;
top: 50px;
z-index: 110;
}
32 changes: 10 additions & 22 deletions js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

OCA.Onlyoffice.InitEditor = function () {
var displayError = function (error) {
OC.Notification.show(error, {
type: "error"
OCP.Toast.error(error, {
timeout: -1
});
};

Expand Down Expand Up @@ -152,7 +152,9 @@
config.events.onRequestClose = OCA.Onlyoffice.onRequestClose;
}

if (OCA.Onlyoffice.inframe && config._files_sharing && !shareToken) {
if (OCA.Onlyoffice.inframe
&& config._files_sharing && !shareToken
&& window.parent.OCA.Onlyoffice.context) {
config.events.onRequestSharingSettings = OCA.Onlyoffice.onRequestSharingSettings;
}

Expand Down Expand Up @@ -199,16 +201,11 @@
saveData,
function onSuccess(response) {
if (response.error) {
OC.Notification.show(response.error, {
type: "error",
timeout: 3
});
OCP.Toast.error(response.error);
return;
}

OC.Notification.show(t(OCA.Onlyoffice.AppName, "File saved") + " (" + response.name + ")", {
timeout: 3
});
OCP.Toast.success(t(OCA.Onlyoffice.AppName, "File saved") + " (" + response.name + ")");
});
};

Expand Down Expand Up @@ -238,10 +235,7 @@
}),
function onSuccess(response) {
if (response.error) {
OC.Notification.show(response.error, {
type: "error",
timeout: 3
});
OCP.Toast.error(response.error);
return;
}

Expand Down Expand Up @@ -272,10 +266,7 @@
}),
function onSuccess(response) {
if (response.error) {
OC.Notification.show(response.error, {
type: "error",
timeout: 3
});
OCP.Toast.error(response.error);
return;
}

Expand Down Expand Up @@ -325,10 +316,7 @@
}),
function onSuccess(response) {
if (response.error) {
OC.Notification.show(response.error, {
type: "error",
timeout: 3
});
OCP.Toast.error(response.error);
return;
}

Expand Down
Loading

0 comments on commit 4b4722a

Please sign in to comment.