From 85e48436d64b988bb9f5ee1faa74a5800ea038a9 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 12 Oct 2022 15:28:41 +0300 Subject: [PATCH 01/17] fix package --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c770221..ba55327 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( name='onlyoffice.plone', - version='3.0.0', + version='3.0.1', description="Plone ONLYOFFICE integration plugin", long_description=long_description, long_description_content_type="text/markdown", From f2b533029e1e133a52599d9f8e209fefc0de8724 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 12 Oct 2022 15:32:32 +0300 Subject: [PATCH 02/17] 3.0.1 --- src/onlyoffice/plone/profiles/default/metadata.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/onlyoffice/plone/profiles/default/metadata.xml b/src/onlyoffice/plone/profiles/default/metadata.xml index d066f7b..36ad6b1 100644 --- a/src/onlyoffice/plone/profiles/default/metadata.xml +++ b/src/onlyoffice/plone/profiles/default/metadata.xml @@ -1,6 +1,6 @@ - 3000 + 3010 From 408c384ec5c01d770c6a3ed08e97d66841b948b4 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 20 Jan 2023 14:18:31 +0300 Subject: [PATCH 03/17] fixed: method createSecurityToken() --- src/onlyoffice/plone/core/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/onlyoffice/plone/core/utils.py b/src/onlyoffice/plone/core/utils.py index c4c424b..4842887 100644 --- a/src/onlyoffice/plone/core/utils.py +++ b/src/onlyoffice/plone/core/utils.py @@ -42,7 +42,7 @@ def isJwtEnabled(): def createSecurityToken(payload, jwtSecret = None): if (jwtSecret is None): jwtSecret = getJwtSecret() - return jwt.encode(payload, jwtSecret, algorithm="HS256").decode("utf-8") + return jwt.encode(payload, jwtSecret, algorithm="HS256") def createSecurityTokenFromContext(obj): return createSecurityToken({"key": obj.id}, IUUID(obj)) From bdde1a37d03e2ed08f3f6ca2955a6c6601788b2e Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 20 Jan 2023 14:19:57 +0300 Subject: [PATCH 04/17] added: for actions allowed_attributes --- src/onlyoffice/plone/browser/configure.zcml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/onlyoffice/plone/browser/configure.zcml b/src/onlyoffice/plone/browser/configure.zcml index d41997e..116f5d7 100644 --- a/src/onlyoffice/plone/browser/configure.zcml +++ b/src/onlyoffice/plone/browser/configure.zcml @@ -31,6 +31,7 @@ class=".actions.View" permission="zope2.View" template="templates/view.pt" + allowed_attributes="isAvailable" /> @@ -165,6 +171,7 @@ name="onlyoffice-download-as-file" class=".actions.DownloadAsForm" permission="zope2.View" + allowed_attributes="isAvailable" /> Date: Fri, 20 Jan 2023 14:22:50 +0300 Subject: [PATCH 05/17] fixed: front-end for plone version 6 --- src/onlyoffice/plone/browser/actions.py | 2 +- src/onlyoffice/plone/browser/controlpanel.py | 2 +- .../plone/browser/static/js/controlpanel.js | 4 +- .../plone/browser/static/js/convert.js | 4 +- .../plone/browser/static/js/utils.js | 135 ++++++++++++++++-- .../plone/browser/templates/controlpanel.pt | 2 +- .../plone/browser/templates/convert.pt | 5 +- .../plone/browser/templates/download-as.pt | 18 ++- .../plone/profiles/default/actions.xml | 4 +- 9 files changed, 150 insertions(+), 26 deletions(-) diff --git a/src/onlyoffice/plone/browser/actions.py b/src/onlyoffice/plone/browser/actions.py index 9dc73df..42c112d 100644 --- a/src/onlyoffice/plone/browser/actions.py +++ b/src/onlyoffice/plone/browser/actions.py @@ -88,7 +88,7 @@ def handle_cancel(self, action): def updateActions(self): super().updateActions() if self.actions and "Convert" in self.actions: - self.actions["Convert"].addClass("context") + self.actions["Convert"].addClass("btn-primary") class DownloadAsForm(form.Form): fields = field.Fields(IDownloadAsForm) diff --git a/src/onlyoffice/plone/browser/controlpanel.py b/src/onlyoffice/plone/browser/controlpanel.py index 5a22d2f..721faf6 100644 --- a/src/onlyoffice/plone/browser/controlpanel.py +++ b/src/onlyoffice/plone/browser/controlpanel.py @@ -51,7 +51,7 @@ class IOnlyofficeControlPanel(Interface): ) docUrlPublicValidation = schema.Bool( - required=True, + required=False, default=True ) diff --git a/src/onlyoffice/plone/browser/static/js/controlpanel.js b/src/onlyoffice/plone/browser/static/js/controlpanel.js index 7f9cb6b..180e723 100644 --- a/src/onlyoffice/plone/browser/static/js/controlpanel.js +++ b/src/onlyoffice/plone/browser/static/js/controlpanel.js @@ -1,6 +1,4 @@ -require([ - "jquery" -], function ($) { +jQuery(function($){ /* Disable a control panel setting */ $.disableSettings = function (settings) { diff --git a/src/onlyoffice/plone/browser/static/js/convert.js b/src/onlyoffice/plone/browser/static/js/convert.js index 5cb6cea..bdcb9ac 100644 --- a/src/onlyoffice/plone/browser/static/js/convert.js +++ b/src/onlyoffice/plone/browser/static/js/convert.js @@ -1,6 +1,4 @@ -require([ - "jquery" -], function ($) { +jQuery(function($){ $(document).ready(function () { var form = $("form[class*='view-name-onlyoffice-convert']"); var titleInput = $("#form-widgets-title"); diff --git a/src/onlyoffice/plone/browser/static/js/utils.js b/src/onlyoffice/plone/browser/static/js/utils.js index baae1c7..274cb5c 100644 --- a/src/onlyoffice/plone/browser/static/js/utils.js +++ b/src/onlyoffice/plone/browser/static/js/utils.js @@ -1,8 +1,4 @@ -require([ - "jquery", - "mockup-i18n" -], function ($, I18N) { - +jQuery(function($){ $.I18N = function (msgid, mapping = {}) { var i18n = new I18N(); i18n.loadCatalog("onlyoffice.plone"); @@ -11,16 +7,137 @@ require([ } $.showMessage = function(message, type, modal = false) { - var global_message = modal ? $(".plone-modal-dialog #global_statusmessage") : $("#global_statusmessage"); - + var global_message = modal ? $(".modal-dialog #global_statusmessage") : $("#global_statusmessage"); global_message.empty(); + var svgError = 'Error'; + + var typeAlert = type == "error" ? "danger" : type; + global_message.html( - "
" + - "" + $("#" + type).text() + "" + + "
" + + "" + svgError + $("#" + type).text() + " " + message + "
" ); }; + + const I18N = function () { + var self = this; + self.baseUrl = $("body").attr("data-i18ncatalogurl"); + self.currentLanguage = $("html").attr("lang") || "en"; + + // Fix for country specific languages + if (self.currentLanguage.split("-").length > 1) { + self.currentLanguage = + self.currentLanguage.split("-")[0] + + "_" + + self.currentLanguage.split("-")[1].toUpperCase(); + } + + self.storage = null; + self.catalogs = {}; + self.ttl = 24 * 3600 * 1000; + + // Internet Explorer 8 does not know Date.now() which is used in e.g. loadCatalog, so we "define" it + if (!Date.now) { + Date.now = function () { + return new Date().valueOf(); + }; + } + + try { + if ( + "localStorage" in window && + window.localStorage !== null && + "JSON" in window && + window.JSON !== null + ) { + self.storage = window.localStorage; + } + } catch (e) {} + + self.configure = function (config) { + for (var key in config) { + self[key] = config[key]; + } + }; + + self._setCatalog = function (domain, language, catalog) { + if (domain in self.catalogs) { + self.catalogs[domain][language] = catalog; + } else { + self.catalogs[domain] = {}; + self.catalogs[domain][language] = catalog; + } + }; + + self._storeCatalog = function (domain, language, catalog) { + var key = domain + "-" + language; + if (self.storage !== null && catalog !== null) { + self.storage.setItem(key, JSON.stringify(catalog)); + self.storage.setItem(key + "-updated", Date.now()); + } + }; + + self.getUrl = function (domain, language) { + return self.baseUrl + "?domain=" + domain + "&language=" + language; + }; + + self.loadCatalog = function (domain, language) { + if (language === undefined) { + language = self.currentLanguage; + } + if (self.storage !== null) { + var key = domain + "-" + language; + if (key in self.storage) { + if ( + Date.now() - parseInt(self.storage.getItem(key + "-updated"), 10) < + self.ttl + ) { + var catalog = JSON.parse(self.storage.getItem(key)); + self._setCatalog(domain, language, catalog); + return; + } + } + } + if (!self.baseUrl) { + return; + } + $.getJSON(self.getUrl(domain, language), function (catalog) { + if (catalog === null) { + return; + } + self._setCatalog(domain, language, catalog); + self._storeCatalog(domain, language, catalog); + }); + }; + + self.MessageFactory = function (domain, language) { + language = language || self.currentLanguage; + return function translate(msgid, keywords) { + var msgstr; + if ( + domain in self.catalogs && + language in self.catalogs[domain] && + msgid in self.catalogs[domain][language] + ) { + msgstr = self.catalogs[domain][language][msgid]; + } else { + msgstr = msgid; + } + if (keywords) { + var regexp, keyword; + for (keyword in keywords) { + if (keywords.hasOwnProperty(keyword)) { + regexp = new RegExp("\\$\\{" + keyword + "\\}", "g"); + msgstr = msgstr.replace(regexp, keywords[keyword]); + } + } + } + return msgstr; + }; + }; + }; }); \ No newline at end of file diff --git a/src/onlyoffice/plone/browser/templates/controlpanel.pt b/src/onlyoffice/plone/browser/templates/controlpanel.pt index 7660867..6e46964 100644 --- a/src/onlyoffice/plone/browser/templates/controlpanel.pt +++ b/src/onlyoffice/plone/browser/templates/controlpanel.pt @@ -25,7 +25,7 @@ - + diff --git a/src/onlyoffice/plone/browser/templates/convert.pt b/src/onlyoffice/plone/browser/templates/convert.pt index 404e3cb..4b73071 100644 --- a/src/onlyoffice/plone/browser/templates/convert.pt +++ b/src/onlyoffice/plone/browser/templates/convert.pt @@ -38,11 +38,14 @@ padding: 0px !important; } + .hide { + display: none !important; + } - + diff --git a/src/onlyoffice/plone/browser/templates/download-as.pt b/src/onlyoffice/plone/browser/templates/download-as.pt index c982a1c..ec1a68c 100644 --- a/src/onlyoffice/plone/browser/templates/download-as.pt +++ b/src/onlyoffice/plone/browser/templates/download-as.pt @@ -23,7 +23,10 @@ * --> - + + + @@ -31,20 +34,25 @@ form div.fieldErrorBox { display: inline-block; } + form .choice-field{ width: 100% } + + .hide { + display: none !important; + }

Download as

-
+
- - -
+ + +
diff --git a/src/onlyoffice/plone/profiles/default/actions.xml b/src/onlyoffice/plone/profiles/default/actions.xml index 614be6b..fa2f596 100644 --- a/src/onlyoffice/plone/profiles/default/actions.xml +++ b/src/onlyoffice/plone/profiles/default/actions.xml @@ -14,7 +14,7 @@ True - {"width": "300"} + {} Download as @@ -28,7 +28,7 @@ True - {"width": "300"} + {} \ No newline at end of file From 5e2c5efd36128c4d26cf0cc38526aee966099cbc Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 20 Jan 2023 14:41:30 +0300 Subject: [PATCH 06/17] updated: setup.py for plone version 6 --- setup.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index ba55327..9cd0d1a 100644 --- a/setup.py +++ b/setup.py @@ -23,13 +23,12 @@ "Environment :: Web Environment", "Framework :: Plone", "Framework :: Plone :: Addon", - "Framework :: Plone :: 5.1", - "Framework :: Plone :: 5.2", + "Framework :: Plone :: 6.0", "Programming Language :: Python", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Operating System :: OS Independent", "License :: OSI Approved :: Apache Software License", ], From 31d440106eb039591ae47a8ea50b9a12c9ac54a9 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Fri, 20 Jan 2023 17:08:47 +0300 Subject: [PATCH 07/17] fixed: modal dialog in editor for plone version 6 --- src/onlyoffice/plone/browser/templates/view.pt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/onlyoffice/plone/browser/templates/view.pt b/src/onlyoffice/plone/browser/templates/view.pt index 8c4804a..8444b9d 100644 --- a/src/onlyoffice/plone/browser/templates/view.pt +++ b/src/onlyoffice/plone/browser/templates/view.pt @@ -39,17 +39,20 @@