From 558c7892d315d68c4308818d7faa06b2c2f1e2c6 Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Wed, 2 Aug 2023 16:56:28 +0400 Subject: [PATCH 001/488] java: add document-formats submodule --- .gitmodules | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitmodules b/.gitmodules index cf502b993..2eadc60d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -38,3 +38,7 @@ path = web/documentserver-example/java-spring/src/main/resources/assets/document-templates url = https://github.com/ONLYOFFICE/document-templates branch = main/en +[submodule "web/documentserver-example/java/src/main/resources/assets/document-formats"] + path = web/documentserver-example/java/src/main/resources/assets/document-formats + url = https://github.com/ONLYOFFICE/document-formats + branch = master From d259cf3ff70ea34b8d9330c3c42fbe7fff5f65dc Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Thu, 3 Aug 2023 15:27:19 +0400 Subject: [PATCH 002/488] java: add format module --- .../java/src/main/java/format/Format.java | 71 ++++++ .../src/main/java/format/FormatManager.java | 220 ++++++++++++++++++ .../main/java/helpers/DocumentManager.java | 31 ++- 3 files changed, 314 insertions(+), 8 deletions(-) create mode 100644 web/documentserver-example/java/src/main/java/format/Format.java create mode 100644 web/documentserver-example/java/src/main/java/format/FormatManager.java diff --git a/web/documentserver-example/java/src/main/java/format/Format.java b/web/documentserver-example/java/src/main/java/format/Format.java new file mode 100644 index 000000000..ffdb08e66 --- /dev/null +++ b/web/documentserver-example/java/src/main/java/format/Format.java @@ -0,0 +1,71 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package format; + +import java.util.List; + +import entities.FileType; + +public final class Format { + private final String name; + + public String getName() { + return this.name; + } + + private final FileType type; + + public FileType getType() { + return this.type; + } + + private final List actions; + + public List getActions() { + return this.actions; + } + + private final List convert; + + public List getConvert() { + return this.convert; + } + + private final List mime; + + public List getMime() { + return this.mime; + } + + public Format(final String nameParameter, + final FileType typeParameter, + final List actionsParameter, + final List convertParameter, + final List mimeParameter) { + this.name = nameParameter; + this.type = typeParameter; + this.actions = actionsParameter; + this.convert = convertParameter; + this.mime = mimeParameter; + } + + public String extension() { + return "." + this.name; + } +} diff --git a/web/documentserver-example/java/src/main/java/format/FormatManager.java b/web/documentserver-example/java/src/main/java/format/FormatManager.java new file mode 100644 index 000000000..1ae4110b4 --- /dev/null +++ b/web/documentserver-example/java/src/main/java/format/FormatManager.java @@ -0,0 +1,220 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package format; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; + +import entities.FileType; + +public final class FormatManager { + public List fillableExtensions() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .fillable() + .stream() + .map(format -> format.extension()) + .collect(Collectors.toList()); + } + + public List fillable() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .all() + .stream() + .filter(format -> format.getActions().contains("fill")) + .collect(Collectors.toList()); + } + + public List viewableExtensions() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .viewable() + .stream() + .map(format -> format.extension()) + .collect(Collectors.toList()); + } + + public List viewable() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .all() + .stream() + .filter(format -> format.getActions().contains("view")) + .collect(Collectors.toList()); + } + + public List editableExtensions() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .editable() + .stream() + .map(format -> format.extension()) + .collect(Collectors.toList()); + } + + public List editable() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .all() + .stream() + .filter(format -> ( + format.getActions().contains("edit") + || format.getActions().contains("lossy-edit") + )) + .collect(Collectors.toList()); + } + + public List convertibleExtensions() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .convertible() + .stream() + .map(format -> format.extension()) + .collect(Collectors.toList()); + } + + public List convertible() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .all() + .stream() + .filter(format -> ( + format.getType() == FileType.Cell && format.getConvert().contains("xlsx") + || format.getType() == FileType.Slide && format.getConvert().contains("pptx") + || format.getType() == FileType.Word && format.getConvert().contains("docx") + )) + .collect(Collectors.toList()); + } + + public List spreadsheetExtensions() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .spreadsheets() + .stream() + .map(format -> format.extension()) + .collect(Collectors.toList()); + } + + public List spreadsheets() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .all() + .stream() + .filter(format -> format.getType() == FileType.Cell) + .collect(Collectors.toList()); + } + + public List presentationExtensions() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .presentations() + .stream() + .map(format -> format.extension()) + .collect(Collectors.toList()); + } + + public List presentations() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .all() + .stream() + .filter(format -> format.getType() == FileType.Slide) + .collect(Collectors.toList()); + } + + public List documentExtensions() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .documents() + .stream() + .map(format -> format.extension()) + .collect(Collectors.toList()); + } + + public List documents() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .all() + .stream() + .filter(format -> format.getType() == FileType.Word) + .collect(Collectors.toList()); + } + + public List allExtensions() throws URISyntaxException, + IOException, + JsonSyntaxException { + return this + .all() + .stream() + .map(format -> format.extension()) + .collect(Collectors.toList()); + } + + public List all() throws URISyntaxException, + IOException, + JsonSyntaxException { + Path path = this.file(); + List lines = Files.readAllLines(path, StandardCharsets.UTF_8); + String contents = String.join(System.lineSeparator(), lines); + Gson gson = new Gson(); + Format[] formats = gson.fromJson(contents, Format[].class); + return Arrays.asList(formats); + } + + private Path file() throws URISyntaxException { + return this + .directory() + .resolve("onlyoffice-docs-formats.json"); + } + + private Path directory() throws URISyntaxException { + URI uri = Thread + .currentThread() + .getContextClassLoader() + .getResource("assets/document-formats") + .toURI(); + return Paths.get(uri); + } +} diff --git a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java index d4bfa66bf..4bffd9132 100755 --- a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java +++ b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java @@ -20,6 +20,8 @@ import entities.FileType; import entities.User; +import format.FormatManager; + import org.json.simple.JSONObject; import org.primeframework.jwt.Signer; import org.primeframework.jwt.Verifier; @@ -56,6 +58,7 @@ public final class DocumentManager { private static HttpServletRequest request; + private static FormatManager formatManager = new FormatManager(); private DocumentManager() { } @@ -89,26 +92,38 @@ public static List getFileExts() { } public static List getFillExts() { - String exts = ConfigManager.getProperty("files.docservice.fill-docs"); - return Arrays.asList(exts.split("\\|")); + try { + return DocumentManager.formatManager.fillableExtensions(); + } catch (Exception ex) { + return new ArrayList<>(); + } } // get file extensions that can be viewed public static List getViewedExts() { - String exts = ConfigManager.getProperty("files.docservice.viewed-docs"); - return Arrays.asList(exts.split("\\|")); + try { + return DocumentManager.formatManager.viewableExtensions(); + } catch (Exception ex) { + return new ArrayList<>(); + } } // get file extensions that can be edited public static List getEditedExts() { - String exts = ConfigManager.getProperty("files.docservice.edited-docs"); - return Arrays.asList(exts.split("\\|")); + try { + return DocumentManager.formatManager.editableExtensions(); + } catch (Exception ex) { + return new ArrayList<>(); + } } // get file extensions that can be converted public static List getConvertExts() { - String exts = ConfigManager.getProperty("files.docservice.convert-docs"); - return Arrays.asList(exts.split("\\|")); + try { + return DocumentManager.formatManager.convertibleExtensions(); + } catch (Exception ex) { + return new ArrayList<>(); + } } // get current user host address From fb16b88dd1027bcd1f4f48da158c8d9070a5b6ce Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Thu, 3 Aug 2023 15:27:38 +0400 Subject: [PATCH 003/488] java: replace the previous implementation of formats --- .../src/main/java/helpers/FileUtility.java | 55 +++++-------------- .../src/main/resources/settings.properties | 4 -- 2 files changed, 15 insertions(+), 44 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java index 6a9a251d9..b353d5774 100644 --- a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java +++ b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java @@ -19,13 +19,14 @@ package helpers; import entities.FileType; +import format.FormatManager; + import java.net.URL; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; public final class FileUtility { + private static FormatManager formatManager = new FormatManager(); private FileUtility() { } @@ -33,50 +34,24 @@ private FileUtility() { } public static FileType getFileType(final String fileName) { String ext = getFileExtension(fileName).toLowerCase(); - // word type for document extensions - if (extsDocument.contains(ext)) { - return FileType.Word; - } - - // cell type for spreadsheet extensions - if (extsSpreadsheet.contains(ext)) { - return FileType.Cell; - } - - // slide type for presentation extensions - if (extsPresentation.contains(ext)) { - return FileType.Slide; + try { + if (FileUtility.formatManager.documentExtensions().contains(ext)) { + return FileType.Word; + } + if (FileUtility.formatManager.spreadsheetExtensions().contains(ext)) { + return FileType.Cell; + } + if (FileUtility.formatManager.presentationExtensions().contains(ext)) { + return FileType.Slide; + } + } catch (Exception error) { + error.printStackTrace(); } // default file type is word return FileType.Word; } - // document extensions - private static List extsDocument = Arrays.asList( - ".doc", ".docx", ".docm", - ".dot", ".dotx", ".dotm", - ".odt", ".fodt", ".ott", ".rtf", ".txt", - ".html", ".htm", ".mht", ".xml", - ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform" - ); - - // spreadsheet extensions - private static List extsSpreadsheet = Arrays.asList( - ".xls", ".xlsx", ".xlsm", ".xlsb", - ".xlt", ".xltx", ".xltm", - ".ods", ".fods", ".ots", ".csv" - ); - - // presentation extensions - private static List extsPresentation = Arrays.asList( - ".pps", ".ppsx", ".ppsm", - ".ppt", ".pptx", ".pptm", - ".pot", ".potx", ".potm", - ".odp", ".fodp", ".otp" - ); - - // get file name from the url public static String getFileName(final String url) { if (url == null) { diff --git a/web/documentserver-example/java/src/main/resources/settings.properties b/web/documentserver-example/java/src/main/resources/settings.properties index a020e99dc..8c8192ebe 100644 --- a/web/documentserver-example/java/src/main/resources/settings.properties +++ b/web/documentserver-example/java/src/main/resources/settings.properties @@ -3,10 +3,6 @@ version=1.6.0 filesize-max=5242880 storage-folder=app_data -files.docservice.fill-docs=.docx|.oform -files.docservice.viewed-docs=.djvu|.oxps|.pdf|.xps -files.docservice.edited-docs=.csv|.docm|.docx|.docxf|.dotm|.dotx|.epub|.fb2|.html|.odp|.ods|.odt|.otp|.ots|.ott|.potm|.potx|.ppsm|.ppsx|.pptm|.pptx|.rtf|.txt|.xlsm|.xlsx|.xltm|.xltx -files.docservice.convert-docs=.doc|.dot|.dps|.dpt|.epub|.et|.ett|.fb2|.fodp|.fods|.fodt|.htm|.html|.mht|.mhtml|.odp|.ods|.odt|.otp|.ots|.ott|.pot|.pps|.ppt|.rtf|.stw|.sxc|.sxi|.sxw|.wps|.wpt|.xls|.xlsb|.xlt|.xml files.docservice.timeout=120000 files.docservice.url.site=http://documentserver/ From 4fa9d4c9fd952f2c3830e839ae78e48a3d162c21 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Sat, 2 Sep 2023 10:46:28 +0300 Subject: [PATCH 004/488] nodejs: remove /files route (8bcc15e320a337b38219191c7045f54cf339a180) --- web/documentserver-example/nodejs/app.js | 8 -------- web/documentserver-example/nodejs/config/default.json | 6 ------ .../nodejs/config/production-linux.json | 8 +------- .../nodejs/config/production-windows.json | 9 +-------- 4 files changed, 2 insertions(+), 29 deletions(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 0685dd32c..ba5e40ed9 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -81,14 +81,6 @@ app.use((req, res, next) => { }); app.use(express.static(path.join(__dirname, 'public'))); // public directory -// check if there are static files such as .js, .css files, images, samples and process them -if (config.has('server.static')) { - const staticContent = config.get('server.static'); - for (let i = 0; i < staticContent.length; i++) { - const staticContentElem = staticContent[i]; - app.use(staticContentElem.name, express.static(staticContentElem.path, staticContentElem.options)); - } -} app.use(favicon(`${__dirname}/public/images/favicon.ico`)); // use favicon app.use(bodyParser.json()); // connect middleware that parses json diff --git a/web/documentserver-example/nodejs/config/default.json b/web/documentserver-example/nodejs/config/default.json index 5b60d2e49..949bbee87 100644 --- a/web/documentserver-example/nodejs/config/default.json +++ b/web/documentserver-example/nodejs/config/default.json @@ -26,12 +26,6 @@ "storagePath": "/files", "maxFileSize": 1073741824, "mobileRegEx": "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino", - "static":[ - { - "name": "/files", - "path": "./files" - } - ], "token": { "enable": false, "useforrequest": true, diff --git a/web/documentserver-example/nodejs/config/production-linux.json b/web/documentserver-example/nodejs/config/production-linux.json index 71290d52c..76d594ba6 100644 --- a/web/documentserver-example/nodejs/config/production-linux.json +++ b/web/documentserver-example/nodejs/config/production-linux.json @@ -2,12 +2,6 @@ "server": { "siteUrl": "/", "maxFileSize": 104857600, - "storageFolder": "/var/lib/onlyoffice/documentserver-example/files", - "static":[ - { - "name": "/files", - "path": "/var/lib/onlyoffice/documentserver-example/files" - } - ] + "storageFolder": "/var/lib/onlyoffice/documentserver-example/files" } } diff --git a/web/documentserver-example/nodejs/config/production-windows.json b/web/documentserver-example/nodejs/config/production-windows.json index 37956fa22..c6e79d467 100644 --- a/web/documentserver-example/nodejs/config/production-windows.json +++ b/web/documentserver-example/nodejs/config/production-windows.json @@ -1,13 +1,6 @@ { "server": { "siteUrl": "/", - "maxFileSize": 104857600, - "static":[ - { - "name": "/files", - "path": "./files", - "options": {"maxAge": "7d"} - } - ] + "maxFileSize": 104857600 } } From 52a722cf892f09428c99e18f1beb700fa93e0cdf Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 4 Sep 2023 13:10:54 +0300 Subject: [PATCH 005/488] java: added api (history, historyData) for getting history --- .../main/java/controllers/IndexServlet.java | 173 ++++++++++++++++++ .../src/main/java/entities/FileModel.java | 127 ------------- .../main/java/helpers/DocumentManager.java | 17 ++ .../java/src/main/webapp/editor.jsp | 55 ++++-- 4 files changed, 225 insertions(+), 147 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index 663ffd72c..a1a57c38a 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -62,6 +62,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Scanner; @@ -132,6 +133,12 @@ protected void processRequest(final HttpServletRequest request, case "restore": restore(request, response, writer); break; + case "history": + history(request, response, writer); + break; + case "historydata": + historyData(request, response, writer); + break; default: break; } @@ -825,6 +832,172 @@ private static void restore(final HttpServletRequest request, } } + private static void history(final HttpServletRequest request, + final HttpServletResponse response, + final PrintWriter writer) { + String fileName = FileUtility.getFileName(request.getParameter("filename")); + String path = DocumentManager.storagePath(fileName, null); + + JSONParser parser = new JSONParser(); + response.setContentType("application/json"); + + // get history directory + String histDir = DocumentManager.historyDir(path); + if (DocumentManager.getFileVersion(histDir) > 0) { + + // get current file version if it is greater than 0 + Integer curVer = DocumentManager.getFileVersion(histDir); + + List hist = new ArrayList<>(); + Map histData = new HashMap(); + + for (Integer i = 1; i <= curVer; i++) { // run through all the file versions + Map obj = new HashMap(); + String verDir = DocumentManager.versionDir(histDir, i); // get the path to the given file version + + try { + String key = null; + + // get document key + if (i == curVer) { + key = ServiceConverter.generateRevisionId( + DocumentManager.curUserHostAddress(null) + "/" + fileName + "/" + + Long.toString(new File(DocumentManager.storagePath(fileName, null)) + .lastModified())); + } else { + key = DocumentManager.readFileToEnd(new File(verDir + File.separator + "key.txt")); + } + + obj.put("key", key); + obj.put("version", i); + + if (i == 1) { // check if the version number is equal to 1 + String createdInfo = DocumentManager.readFileToEnd(new File(histDir + File.separator + + "createdInfo.json")); // get file with meta data + JSONObject json = (JSONObject) parser.parse(createdInfo); // and turn it into json object + + // write meta information to the object (user information and creation date) + obj.put("created", json.get("created")); + Map user = new HashMap(); + user.put("id", json.get("id")); + user.put("name", json.get("name")); + obj.put("user", user); + } + + if (i > 1) { //check if the version number is greater than 1 + // if so, get the path to the changes.json file + JSONObject changes = (JSONObject) parser.parse( + DocumentManager.readFileToEnd(new File(DocumentManager + .versionDir(histDir, i - 1) + File.separator + "changes.json"))); + JSONObject change = (JSONObject) ((JSONArray) changes.get("changes")).get(0); + + // write information about changes to the object + obj.put("changes", !change.isEmpty() ? changes.get("changes") : null); + obj.put("serverVersion", changes.get("serverVersion")); + obj.put("created", !change.isEmpty() ? change.get("created") : null); + obj.put("user", !change.isEmpty() ? change.get("user") : null); + } + + hist.add(obj); + } catch (Exception ex) { } + } + + // write history information about the current file version to the history object + Map histObj = new HashMap(); + histObj.put("currentVersion", curVer); + histObj.put("history", hist); + + Gson gson = new Gson(); + writer.write(gson.toJson(histObj)); + return; + } + writer.write("{}"); + } + + private static void historyData(final HttpServletRequest request, + final HttpServletResponse response, + final PrintWriter writer) { + String fileName = FileUtility.getFileName(request.getParameter("filename")); + String version = request.getParameter("version"); + String directUrl = request.getParameter("directUrl"); + String path = DocumentManager.storagePath(fileName, null); + + response.setContentType("application/json"); + // get history directory + String histDir = DocumentManager.historyDir(path); + if (DocumentManager.getFileVersion(histDir) > 0) { + // get current file version if it is greater than 0 + Integer curVer = DocumentManager.getFileVersion(histDir); + + Map histData = new HashMap(); + for (Integer i = 1; i <= curVer; i++) { // run through all the file versions + Map dataObj = new HashMap(); + String verDir = DocumentManager.versionDir(histDir, i); // get the path to the given file version + + try { + String key = null; + + // get document key + if (i == curVer) { + key = ServiceConverter.generateRevisionId( + DocumentManager.curUserHostAddress(null) + "/" + fileName + "/" + + Long.toString(new File(DocumentManager.storagePath(fileName, null)) + .lastModified())); + } else { + key = DocumentManager.readFileToEnd(new File(verDir + File.separator + "key.txt")); + } + + String fileUrl = DocumentManager.getDownloadUrl(fileName, true); + dataObj.put("fileType", FileUtility.getFileExtension(fileName).substring(1)); + dataObj.put("key", key); + dataObj.put("url", i == curVer ? fileUrl : DocumentManager + .getDownloadHistoryUrl(fileName, i, "prev" + FileUtility + .getFileExtension(fileName), true)); + if (directUrl.equals("true")) { + dataObj.put("directUrl", i == curVer ? fileUrl : DocumentManager + .getDownloadHistoryUrl(fileName, i, "prev" + FileUtility + .getFileExtension(fileName), false)); + } + + dataObj.put("version", i); + + if (i > 1) { //check if the version number is greater than 1 + + // get the history data from the previous file version + Map prev = (Map) histData.get(Integer.toString(i - 1)); + Map prevInfo = new HashMap(); + prevInfo.put("fileType", prev.get("fileType")); + + // write key and url information about previous file version + prevInfo.put("key", prev.get("key")); + prevInfo.put("url", prev.get("url")); + + // write information about previous file version to the data object + dataObj.put("previous", prevInfo); + // write the path to the diff.zip archive with differences in this file version + Integer verdiff = i - 1; + String changesUrl = DocumentManager + .getDownloadHistoryUrl(fileName, verdiff, + "diff.zip", true); + dataObj.put("changesUrl", changesUrl); + } + + if (DocumentManager.tokenEnabled()) { + dataObj.put("token", DocumentManager.createToken(dataObj)); + } + + histData.put(Integer.toString(i), dataObj); + + } catch (Exception ex) { } + } + + Gson gson = new Gson(); + writer.write(gson.toJson(histData.get(version))); + return; + } + writer.write("{}"); + } + // process get request @Override protected void doGet(final HttpServletRequest request, diff --git a/web/documentserver-example/java/src/main/java/entities/FileModel.java b/web/documentserver-example/java/src/main/java/entities/FileModel.java index 6424c4247..13e944996 100755 --- a/web/documentserver-example/java/src/main/java/entities/FileModel.java +++ b/web/documentserver-example/java/src/main/java/entities/FileModel.java @@ -23,12 +23,8 @@ import helpers.DocumentManager; import helpers.FileUtility; import helpers.ServiceConverter; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; import java.io.File; -import java.io.FileInputStream; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; @@ -36,7 +32,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Scanner; public class FileModel { private String type = "desktop"; @@ -192,128 +187,6 @@ public void buildToken() { token = DocumentManager.createToken(map); } - // get document history - public String[] getHistory() { - JSONParser parser = new JSONParser(); - - // get history directory - String histDir = DocumentManager.historyDir(DocumentManager.storagePath(document.getTitle(), null)); - if (DocumentManager.getFileVersion(histDir) > 0) { - - // get current file version if it is greater than 0 - Integer curVer = DocumentManager.getFileVersion(histDir); - - List hist = new ArrayList<>(); - Map histData = new HashMap(); - - for (Integer i = 1; i <= curVer; i++) { // run through all the file versions - Map obj = new HashMap(); - Map dataObj = new HashMap(); - String verDir = DocumentManager.versionDir(histDir, i); // get the path to the given file version - - try { - String key = null; - - // get document key - key = i == curVer - ? document.getKey() : readFileToEnd(new File(verDir + File.separator + "key.txt")); - - obj.put("key", key); - obj.put("version", i); - - if (i == 1) { // check if the version number is equal to 1 - String createdInfo = readFileToEnd(new File(histDir + File.separator - + "createdInfo.json")); // get file with meta data - JSONObject json = (JSONObject) parser.parse(createdInfo); // and turn it into json object - - // write meta information to the object (user information and creation date) - obj.put("created", json.get("created")); - Map user = new HashMap(); - user.put("id", json.get("id")); - user.put("name", json.get("name")); - obj.put("user", user); - } - - dataObj.put("fileType", FileUtility.getFileExtension(document.getTitle()).substring(1)); - dataObj.put("key", key); - dataObj.put("url", i == curVer ? document.getUrl() : DocumentManager - .getDownloadHistoryUrl(document.getTitle(), i, "prev" + FileUtility - .getFileExtension(document.getTitle()), true)); - if (!document.getDirectUrl().equals("")) { - dataObj.put("directUrl", i == curVer ? document.getUrl() : DocumentManager - .getDownloadHistoryUrl(document.getTitle(), i, "prev" + FileUtility - .getFileExtension(document.getTitle()), false)); - } - dataObj.put("version", i); - - if (i > 1) { //check if the version number is greater than 1 - // if so, get the path to the changes.json file - JSONObject changes = (JSONObject) parser.parse(readFileToEnd(new File(DocumentManager - .versionDir(histDir, i - 1) + File.separator + "changes.json"))); - JSONObject change = (JSONObject) ((JSONArray) changes.get("changes")).get(0); - - // write information about changes to the object - obj.put("changes", !change.isEmpty() ? changes.get("changes") : null); - obj.put("serverVersion", changes.get("serverVersion")); - obj.put("created", !change.isEmpty() ? change.get("created") : null); - obj.put("user", !change.isEmpty() ? change.get("user") : null); - - // get the history data from the previous file version - Map prev = (Map) histData.get(Integer.toString(i - 2)); - Map prevInfo = new HashMap(); - prevInfo.put("fileType", prev.get("fileType")); - - // write key and url information about previous file version - prevInfo.put("key", prev.get("key")); - prevInfo.put("url", prev.get("url")); - - // write information about previous file version to the data object - dataObj.put("previous", prevInfo); - // write the path to the diff.zip archive with differences in this file version - Integer verdiff = i - 1; - String changesUrl = DocumentManager - .getDownloadHistoryUrl(document.getTitle(), verdiff, - "diff.zip", true); - dataObj.put("changesUrl", changesUrl); - } - - if (DocumentManager.tokenEnabled()) { - dataObj.put("token", DocumentManager.createToken(dataObj)); - } - - hist.add(obj); - histData.put(Integer.toString(i - 1), dataObj); - - } catch (Exception ex) { } - } - - // write history information about the current file version to the history object - Map histObj = new HashMap(); - histObj.put("currentVersion", curVer); - histObj.put("history", hist); - - Gson gson = new Gson(); - return new String[] {gson.toJson(histObj), gson.toJson(histData) }; - } - return new String[] {"", "" }; - } - - // read a file - private String readFileToEnd(final File file) { - String output = ""; - try { - try (FileInputStream is = new FileInputStream(file)) { - Scanner scanner = new Scanner(is); // read data from the source - scanner.useDelimiter("\\A"); - while (scanner.hasNext()) { - output += scanner.next(); - } - scanner.close(); - } - } catch (Exception e) { } - return output; - } - // the document parameters public class Document { private String title; diff --git a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java index d4bfa66bf..2295e12bd 100755 --- a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java +++ b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java @@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileFilter; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; @@ -50,6 +51,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Scanner; import static utils.Constants.KILOBYTE_SIZE; import static utils.Constants.MAX_FILE_SIZE; @@ -599,4 +601,19 @@ public static Map getLanguages() { }); return languages; } + + public static String readFileToEnd(final File file) { + String output = ""; + try { + try (FileInputStream is = new FileInputStream(file)) { + Scanner scanner = new Scanner(is); // read data from the source + scanner.useDelimiter("\\A"); + while (scanner.hasNext()) { + output += scanner.next(); + } + scanner.close(); + } + } catch (Exception e) { } + return output; + } } diff --git a/web/documentserver-example/java/src/main/webapp/editor.jsp b/web/documentserver-example/java/src/main/webapp/editor.jsp index 9d78046e8..c1744327f 100644 --- a/web/documentserver-example/java/src/main/webapp/editor.jsp +++ b/web/documentserver-example/java/src/main/webapp/editor.jsp @@ -193,6 +193,37 @@ } } + var onRequestHistory = function () { + var historyInfoUri = "IndexServlet?type=history&filename=" + config.document.title; + var xhr = new XMLHttpRequest(); + xhr.open("GET", historyInfoUri, false); + xhr.send(); + + if (xhr.status == 200) { + var historyInfo = JSON.parse(xhr.responseText); + docEditor.refreshHistory(historyInfo); + } + }; + + var onRequestHistoryData = function (event) { + var version = event.data; + var historyDataUri = "IndexServlet?type=historyData&filename=" + config.document.title + + "&version=" + version + + "&directUrl=" + !!config.document.directUrl; + var xhr = new XMLHttpRequest(); + xhr.open("GET", historyDataUri, false); + xhr.send(); + + if (xhr.status == 200) { + var historyData = JSON.parse(xhr.responseText); + docEditor.setHistoryData(historyData); + } + }; + + var onRequestHistoryClose = function() { + document.location.reload(); + }; + config = JSON.parse('<%= FileModel.serialize(Model) %>'); config.width = "100%"; config.height = "100%"; @@ -206,33 +237,17 @@ "onRequestInsertImage": onRequestInsertImage, "onRequestCompareFile": onRequestCompareFile, "onRequestMailMergeRecipients": onRequestMailMergeRecipients, - "onRequestRestore": onRequestRestore + "onRequestRestore": onRequestRestore, + "onRequestHistory": onRequestHistory, + "onRequestHistoryData": onRequestHistoryData, + "onRequestHistoryClose": onRequestHistoryClose }; <% - String[] histArray = Model.getHistory(); - String history = histArray[0]; - String historyData = histArray[1]; String usersForMentions = (String) request.getAttribute("usersForMentions"); %> if (config.editorConfig.user.id) { - <% if (!history.isEmpty() && !historyData.isEmpty()) { %> - // the user is trying to show the document version history - config.events['onRequestHistory'] = function () { - docEditor.refreshHistory(<%= history %>); // show the document version history - }; - // the user is trying to click the specific document version in the document version history - config.events['onRequestHistoryData'] = function (event) { - var ver = event.data; - var histData = <%= historyData %>; - docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history - }; - // the user is trying to go back to the document from viewing the document version history - config.events['onRequestHistoryClose'] = function () { - document.location.reload(); - }; - <% } %> // add mentions for not anonymous users config.events['onRequestUsers'] = function () { docEditor.setUsers({ // set a list of users to mention in the comments From 24b9a35651876a341db737b0687d70d4dccf4050 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 4 Sep 2023 13:08:27 +0300 Subject: [PATCH 006/488] java: changed restore version without reload page --- .../java/src/main/webapp/editor.jsp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/java/src/main/webapp/editor.jsp b/web/documentserver-example/java/src/main/webapp/editor.jsp index c1744327f..d1323be19 100644 --- a/web/documentserver-example/java/src/main/webapp/editor.jsp +++ b/web/documentserver-example/java/src/main/webapp/editor.jsp @@ -184,12 +184,20 @@ request.open('PUT', 'IndexServlet?type=restore') request.send(JSON.stringify(payload)) request.onload = function () { - if (request.status != 200) { - response = JSON.parse(request.response) - innerAlert(response.error) - return + const response = JSON.parse(request.responseText); + if (response.success && !response.error) { + var historyInfoUri = "IndexServlet?type=history&filename=" + config.document.title; + var xhr = new XMLHttpRequest(); + xhr.open("GET", historyInfoUri, false); + xhr.send(); + + if (xhr.status == 200) { + var historyInfo = JSON.parse(xhr.responseText); + docEditor.refreshHistory(historyInfo); + } + } else { + innerAlert(response.error); } - document.location.reload() } } From a3fa30b1929e2a5aa8def73f5d0c6b31809e7537 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 4 Sep 2023 15:19:34 +0300 Subject: [PATCH 007/488] fixed: directUrl for historyData --- .../src/main/java/controllers/IndexServlet.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index a1a57c38a..26206d811 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -947,15 +947,16 @@ private static void historyData(final HttpServletRequest request, key = DocumentManager.readFileToEnd(new File(verDir + File.separator + "key.txt")); } - String fileUrl = DocumentManager.getDownloadUrl(fileName, true); dataObj.put("fileType", FileUtility.getFileExtension(fileName).substring(1)); dataObj.put("key", key); - dataObj.put("url", i == curVer ? fileUrl : DocumentManager - .getDownloadHistoryUrl(fileName, i, "prev" + FileUtility + dataObj.put("url", i == curVer + ? DocumentManager.getDownloadUrl(fileName, true) + : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev" + FileUtility .getFileExtension(fileName), true)); if (directUrl.equals("true")) { - dataObj.put("directUrl", i == curVer ? fileUrl : DocumentManager - .getDownloadHistoryUrl(fileName, i, "prev" + FileUtility + dataObj.put("directUrl", i == curVer + ? DocumentManager.getDownloadUrl(fileName, false) + : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev" + FileUtility .getFileExtension(fileName), false)); } @@ -971,6 +972,9 @@ private static void historyData(final HttpServletRequest request, // write key and url information about previous file version prevInfo.put("key", prev.get("key")); prevInfo.put("url", prev.get("url")); + if (directUrl.equals("true")) { + prevInfo.put("directUrl", prev.get("directUrl")); + } // write information about previous file version to the data object dataObj.put("previous", prevInfo); From bc5393e28cf1bfa346f9029f6875ef138fd2ec63 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 4 Sep 2023 15:29:23 +0300 Subject: [PATCH 008/488] java-spring: added api (history, historyData) for getting history --- .../controllers/EditorController.java | 7 - .../controllers/FileController.java | 17 ++ .../history/DefaultHistoryManager.java | 151 ++++++++++++++++++ .../managers/history/HistoryManager.java | 6 +- .../src/main/resources/templates/editor.html | 54 ++++--- 5 files changed, 205 insertions(+), 30 deletions(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java index f9c24ad16..0d57f83aa 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java @@ -20,7 +20,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.onlyoffice.integration.documentserver.managers.history.HistoryManager; import com.onlyoffice.integration.documentserver.managers.jwt.JwtManager; import com.onlyoffice.integration.documentserver.models.enums.Action; import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; @@ -73,9 +72,6 @@ public class EditorController { @Autowired private UserServices userService; - @Autowired - private HistoryManager historyManager; - @Autowired private ObjectMapper objectMapper; @@ -140,9 +136,6 @@ public String index(@RequestParam("fileName") final String fileName, // add file model with the default parameters to the original model model.addAttribute("model", fileModel); - // get file history and add it to the model - model.addAttribute("fileHistory", historyManager.getHistory(fileModel.getDocument())); - // create the document service api URL and add it to the model model.addAttribute("docserviceApiUrl", docserviceSite + docserviceApiUrl); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index c5259eaed..3c1eb4b63 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -22,6 +22,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.onlyoffice.integration.documentserver.callbacks.CallbackHandler; +import com.onlyoffice.integration.documentserver.managers.history.HistoryManager; import com.onlyoffice.integration.documentserver.managers.jwt.JwtManager; import com.onlyoffice.integration.documentserver.storage.FileStorageMutator; import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; @@ -114,6 +115,8 @@ public class FileController { private ServiceConverter serviceConverter; @Autowired private CallbackManager callbackManager; + @Autowired + private HistoryManager historyManager; // create user metadata private String createUserMetadata(final String uid, final String fullFileName) { @@ -538,6 +541,20 @@ public String reference(@RequestBody final JSONObject body) { } } + @GetMapping("/history") + @ResponseBody + public String history(@RequestParam("fileName") final String fileName) { + return historyManager.getHistory(fileName); + } + + @GetMapping("/historydata") + @ResponseBody + public String history(@RequestParam("fileName") final String fileName, + @RequestParam("version") final String version, + @RequestParam(value = "directUrl", defaultValue = "false") final Boolean directUrl) { + return historyManager.getHistoryData(fileName, version, directUrl); + } + @PutMapping("/restore") @ResponseBody public String restore(@RequestBody final JSONObject body) { diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/DefaultHistoryManager.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/DefaultHistoryManager.java index 2511246e2..3c7af734a 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/DefaultHistoryManager.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/DefaultHistoryManager.java @@ -25,6 +25,7 @@ import com.onlyoffice.integration.documentserver.models.filemodel.Document; import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; import com.onlyoffice.integration.documentserver.util.file.FileUtility; +import com.onlyoffice.integration.documentserver.util.service.ServiceConverter; import lombok.SneakyThrows; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -62,6 +63,9 @@ public class DefaultHistoryManager implements HistoryManager { @Autowired private ObjectMapper objectMapper; + @Autowired + private ServiceConverter serviceConverter; + // todo: Refactoring @SneakyThrows public String[] getHistory(final Document document) { // get document history @@ -164,6 +168,153 @@ public String[] getHistory(final Document document) { // get document history return new String[]{"", ""}; } + // todo: Refactoring + @SneakyThrows + public String getHistory(final String fileName) { // get document history + + // get history directory + String histDir = storagePathBuilder.getHistoryDir(storagePathBuilder.getFileLocation(fileName)); + Integer curVer = storagePathBuilder.getFileVersion(histDir, false); // get current file version + + if (curVer > 0) { // check if the current file version is greater than 0 + List hist = new ArrayList<>(); + + for (Integer i = 1; i <= curVer; i++) { // run through all the file versions + Map obj = new HashMap(); + String verDir = documentManager + .versionDir(histDir, i, true); // get the path to the given file version + + String key; + if (i == curVer) { + key = serviceConverter + .generateRevisionId(storagePathBuilder.getStorageLocation() + + "/" + fileName + "/" + + new File(storagePathBuilder.getFileLocation(fileName)).lastModified()); + } else { + key = readFileToEnd(new File(verDir + File.separator + "key.txt")); + } + + obj.put("key", key); + obj.put("version", i); + + if (i == 1) { // check if the version number is equal to 1 + String createdInfo = readFileToEnd(new File(histDir + + File.separator + "createdInfo.json")); // get file with meta data + JSONObject json = (JSONObject) parser.parse(createdInfo); // and turn it into json object + + // write meta information to the object (user information and creation date) + obj.put("created", json.get("created")); + Map user = new HashMap(); + user.put("id", json.get("id")); + user.put("name", json.get("name")); + obj.put("user", user); + } + + if (i > 1) { //check if the version number is greater than 1 + // if so, get the path to the changes.json file + JSONObject changes = (JSONObject) parser.parse(readFileToEnd(new File(documentManager + .versionDir(histDir, i - 1, true) + File.separator + "changes.json"))); + JSONObject change = (JSONObject) ((JSONArray) changes.get("changes")).get(0); + + // write information about changes to the object + obj.put("changes", changes.get("changes")); + obj.put("serverVersion", changes.get("serverVersion")); + obj.put("created", change.get("created")); + obj.put("user", change.get("user")); + } + + hist.add(obj); + } + + // write history information about the current file version to the history object + Map histObj = new HashMap(); + histObj.put("currentVersion", curVer); + histObj.put("history", hist); + + try { + return objectMapper.writeValueAsString(histObj); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + } + return ""; + } + + // todo: Refactoring + @SneakyThrows + public String getHistoryData(final String fileName, final String version, final Boolean directUrl) { + // get history directory + String histDir = storagePathBuilder.getHistoryDir(storagePathBuilder.getFileLocation(fileName)); + Integer curVer = storagePathBuilder.getFileVersion(histDir, false); // get current file version + + if (curVer > 0) { // check if the current file version is greater than 0 + Map histData = new HashMap<>(); + + for (Integer i = 1; i <= curVer; i++) { // run through all the file versions + Map dataObj = new HashMap(); + String verDir = documentManager + .versionDir(histDir, i, true); // get the path to the given file version + + String key; + if (i == curVer) { + key = serviceConverter + .generateRevisionId(storagePathBuilder.getStorageLocation() + + "/" + fileName + "/" + + new File(storagePathBuilder.getFileLocation(fileName)).lastModified()); + } else { + key = readFileToEnd(new File(verDir + File.separator + "key.txt")); + } + + dataObj.put("fileType", fileUtility + .getFileExtension(fileName).replace(".", "")); + dataObj.put("key", key); + dataObj.put("url", i == curVer ? documentManager.getDownloadUrl(fileName, true) + : documentManager.getHistoryFileUrl(fileName, i, "prev" + fileUtility + .getFileExtension(fileName), true)); + if (directUrl) { + dataObj.put("directUrl", i == curVer + ? documentManager.getDownloadUrl(fileName, false) + : documentManager.getHistoryFileUrl(fileName, i, "prev" + fileUtility + .getFileExtension(fileName), false)); + } + dataObj.put("version", i); + + if (i > 1) { //check if the version number is greater than 1 + // get the history data from the previous file version + Map prev = (Map) histData.get(Integer.toString(i - 1)); + Map prevInfo = new HashMap(); + prevInfo.put("fileType", prev.get("fileType")); + prevInfo.put("key", prev.get("key")); // write key and URL information about previous file version + prevInfo.put("url", prev.get("url")); + if (directUrl) { + prevInfo.put("directUrl", prev.get("directUrl")); + } + + // write information about previous file version to the data object + dataObj.put("previous", prevInfo); + // write the path to the diff.zip archive with differences in this file version + Integer verdiff = i - 1; + dataObj.put("changesUrl", documentManager + .getHistoryFileUrl(fileName, verdiff, "diff.zip", true)); + } + + if (jwtManager.tokenEnabled()) { + dataObj.put("token", jwtManager.createToken(dataObj)); + } + + histData.put(Integer.toString(i), dataObj); + } + + try { + return objectMapper.writeValueAsString(histData.get(version)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + } + return ""; + } + + // read a file private String readFileToEnd(final File file) { String output = ""; diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/HistoryManager.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/HistoryManager.java index 2be05ff32..d3e2f62da 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/HistoryManager.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/HistoryManager.java @@ -18,9 +18,9 @@ package com.onlyoffice.integration.documentserver.managers.history; -import com.onlyoffice.integration.documentserver.models.filemodel.Document; - // specify the history manager functions public interface HistoryManager { - String[] getHistory(Document document); // get document history + String getHistory(String fileName); // get document history + + String getHistoryData(String fileName, String version, Boolean directUrl); // get document history data } diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html index e74424817..ad79e85fb 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html @@ -172,6 +172,36 @@ } }; + var onRequestHistory = function () { + var xhr = new XMLHttpRequest(); + xhr.open("GET", "history?fileName=" + config.document.title, false); + xhr.send(); + + if (xhr.status == 200) { + var historyInfo = JSON.parse(xhr.responseText); + docEditor.refreshHistory(historyInfo); + } + }; + + var onRequestHistoryData = function (event) { + var version = event.data; + var historyDataUri = "historydata?fileName=" + config.document.title + + "&version=" + version + + "&directUrl=" + !!config.document.directUrl; + var xhr = new XMLHttpRequest(); + xhr.open("GET", historyDataUri, false); + xhr.send(); + + if (xhr.status == 200) { + var historyData = JSON.parse(xhr.responseText); + docEditor.setHistoryData(historyData); + } + }; + + var onRequestHistoryClose = function() { + document.location.reload(); + }; + function onRequestRestore(event) { const query = new URLSearchParams(window.location.search) const config = [[${model}]] @@ -206,31 +236,15 @@ "onRequestInsertImage": onRequestInsertImage, "onRequestCompareFile": onRequestCompareFile, "onRequestMailMergeRecipients": onRequestMailMergeRecipients, - "onRequestRestore": onRequestRestore + "onRequestRestore": onRequestRestore, + "onRequestHistory": onRequestHistory, + "onRequestHistoryData": onRequestHistoryData, + "onRequestHistoryClose": onRequestHistoryClose }; - var histArray = [[${fileHistory}]]; - var hist = histArray[0]; - var historyData = histArray[1]; var usersForMentions = [[${usersForMentions}]]; if (config.editorConfig.user.id != 4) { - if (hist && historyData) { - // the user is trying to show the document version history - config.events['onRequestHistory'] = function () { - docEditor.refreshHistory(JSON.parse(hist)); // show the document version history - }; - // the user is trying to click the specific document version in the document version history - config.events['onRequestHistoryData'] = function (event) { - var ver = event.data; - var histData = historyData; - docEditor.setHistoryData(JSON.parse(histData)[ver - 1]); // send the link to the document for viewing the version history - }; - // the user is trying to go back to the document from viewing the document version history - config.events['onRequestHistoryClose'] = function () { - document.location.reload(); - }; - } // add mentions for not anonymous users config.events['onRequestUsers'] = function () { docEditor.setUsers({ // set a list of users to mention in the comments From a56b411c9329e38cc4231d48bb711f371126bf2b Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Mon, 4 Sep 2023 15:32:15 +0300 Subject: [PATCH 009/488] java-spring: changed restore version without reload page --- .../src/main/resources/templates/editor.html | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html index ad79e85fb..32dbfd60b 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html @@ -215,12 +215,20 @@ request.setRequestHeader('Content-Type', 'application/json') request.send(JSON.stringify(payload)) request.onload = function () { - if (request.status != 200) { - response = JSON.parse(request.response) - innerAlert(response.error) - return + const response = JSON.parse(request.responseText); + if (response.success && !response.error) { + var historyInfoUri = "history?fileName=" + config.document.title; + var xhr = new XMLHttpRequest(); + xhr.open("GET", historyInfoUri, false); + xhr.send(); + + if (xhr.status == 200) { + var historyInfo = JSON.parse(xhr.responseText); + docEditor.refreshHistory(historyInfo); + } + } else { + innerAlert(response.error); } - document.location.reload() } } From 05904fd68a3b543c407835324d7f5c062df8baa8 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 5 Sep 2023 13:57:13 +0300 Subject: [PATCH 010/488] java: link to Oracle --- web/documentserver-example/java-spring/README.md | 6 +----- web/documentserver-example/java/README.md | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/java-spring/README.md b/web/documentserver-example/java-spring/README.md index 337ee9a01..4f4a6a60b 100755 --- a/web/documentserver-example/java-spring/README.md +++ b/web/documentserver-example/java-spring/README.md @@ -128,11 +128,7 @@ See the detailed guide to learn how to install Document Server [for Linux](https ### Step 2. Install the prerequisites and run the website with the editors -1. Install **Java**: - - ``` - sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java11-installer - ``` +1. Install **Java** following the instructions [here](https://docs.oracle.com/en/java/javase/20/install/installation-jdk-linux-platforms.html#GUID-737A84E4-2EFF-4D38-8E60-3E29D1B884B8). 2. Download the archive with the Java-Spring example and unpack the archive or clone git repository: diff --git a/web/documentserver-example/java/README.md b/web/documentserver-example/java/README.md index 4e2e22900..05a09a529 100644 --- a/web/documentserver-example/java/README.md +++ b/web/documentserver-example/java/README.md @@ -140,11 +140,7 @@ See the detailed guide to learn how to [install Document Server for Linux](https ### Step 2. Install the prerequisites and run the website with the editors -1. Install **Java**: - - ``` - sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer - ``` +1. Install **Java** following the instructions [here](https://docs.oracle.com/en/java/javase/20/install/installation-jdk-linux-platforms.html#GUID-737A84E4-2EFF-4D38-8E60-3E29D1B884B8). 2. Download the archive with the Java example and unpack the archive: From 09f24a3b87809d7a0a4acbcdad7b4cdd8feb2fbd Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 5 Sep 2023 14:42:58 +0300 Subject: [PATCH 011/488] fix changelog --- CHANGELOG.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7658df2ab..c945cdd64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,14 +10,11 @@ - nodejs: using a repo with a list of formats - nodejs: delete file without reloading the page - nodejs: getting history by a separate request -- nodejs: restore from history -- python: restore from history -- ruby: restore from history -- php: restore from history - csharp-mvc: getting history by a separate request -- csharp-mvc: restore from history - csharp: getting history by a separate request -- csharp: restore from history +- java: getting history by a separate request +- java-spring: getting history by a separate request +- restore from history ## 1.6.0 - nodejs: setUsers for region protection From 8f14876b8156a886509cce80d7823dbe71c59403 Mon Sep 17 00:00:00 2001 From: Natalia Date: Wed, 6 Sep 2023 15:55:07 +0300 Subject: [PATCH 012/488] java and java spring: updated Docker instructions --- .../java-spring/README.md | 52 +++++++++++++++++-- web/documentserver-example/java/README.md | 40 ++++++++++++-- 2 files changed, 84 insertions(+), 8 deletions(-) diff --git a/web/documentserver-example/java-spring/README.md b/web/documentserver-example/java-spring/README.md index 4f4a6a60b..9dc3c10ef 100755 --- a/web/documentserver-example/java-spring/README.md +++ b/web/documentserver-example/java-spring/README.md @@ -206,13 +206,51 @@ Make sure that the Document Server has access to the server with the example ins ## For Docker -1. Edit the *application.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed ([installation instructions](https://helpcenter.onlyoffice.com/installation/docs-developer-install-docker.aspx)). +### Step 1. Install ONLYOFFICE Docs + +Download and install ONLYOFFICE Docs (packaged as Document Server). + +See the detailed guide to learn how to install Document Server [for Docker](https://helpcenter.onlyoffice.com/installation/docs-developer-install-docker.aspx). + +### Step 2. Install the prerequisites and run the website with the editors + +1. Install **Java** following the instructions [here](https://docs.oracle.com/en/java/javase/20/install/installation-jdk-linux-platforms.html#GUID-737A84E4-2EFF-4D38-8E60-3E29D1B884B8). + +2. Download the archive with the Java-Spring example and unpack the archive or clone git repository: + + a) archive with Java-Spring: + + ``` + wget https://api.onlyoffice.com/app_data/editor/Java%20Spring%20Example.zip + ``` + + ``` + unzip Java\ Spring\ Example.zip + ``` + b) git repository: + ``` + git clone https://github.com/ONLYOFFICE/document-server-integration.git + ``` + + +3. Change the current directory for the project directory: + + a) from archive + + ``` + cd Java\ Spring\ Example/ + ``` + b) from git repository + ``` + cd document-server-integration/web/documentserver-example/java-spring + ``` +4. Edit the *application.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed: ``` nano src/main/resources/application.properties ``` -2. Edit the following lines: +5. Edit the following lines: ``` files.storage= @@ -222,17 +260,23 @@ Make sure that the Document Server has access to the server with the example ins where the **documentserver** is the name of the server with the ONLYOFFICE Docs installed, **port** is any available port and **files.storage** is the path where files will be created and stored (in the project folder by default). You can set an absolute path. -3. Run the next command in the java example directory: +6. Run the next command in the java example directory: ``` docker-compose up ``` -4. Open your browser using **server.address** and **server.port**: +7. Open your browser using **server.address** and **server.port**: ``` http://server.address:server.port/ ``` +### Step 3. Check accessibility + +In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files. + +Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files. + ## Important security info Please keep in mind the following security aspects when you are using test examples: diff --git a/web/documentserver-example/java/README.md b/web/documentserver-example/java/README.md index 05a09a529..708a740e0 100644 --- a/web/documentserver-example/java/README.md +++ b/web/documentserver-example/java/README.md @@ -237,13 +237,39 @@ Make sure that the Document Server has access to the server with the example ins ## For Docker -1. Edit the *settings.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed ([installation instructions](https://helpcenter.onlyoffice.com/installation/docs-developer-install-docker.aspx)). +### Step 1. Install ONLYOFFICE Docs + +Download and install ONLYOFFICE Docs (packaged as Document Server). + +See the detailed guide to learn how to install Document Server [for Docker](https://helpcenter.onlyoffice.com/installation/docs-developer-install-docker.aspx). + +### Step 2. Install the prerequisites and run the website with the editors + +1. Install **Java** following the instructions [here](https://docs.oracle.com/en/java/javase/20/install/installation-jdk-linux-platforms.html#GUID-737A84E4-2EFF-4D38-8E60-3E29D1B884B8). + +2. Download the archive with the Java example and unpack the archive: + + ``` + wget https://api.onlyoffice.com/app_data/editor/Java%20Example.zip + ``` + + ``` + unzip Java\ Example.zip + ``` + +3. Change the current directory for the project directory: + + ``` + cd Java\ Example/ + ``` + +4. Edit the *settings.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed: ``` nano src/main/resources/settings.properties ``` -2. Edit the following lines: +5. Edit the following lines: ``` storage-folder = app_data @@ -252,13 +278,19 @@ Make sure that the Document Server has access to the server with the example ins where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storage-folder** is the path where files will be created and stored. -3. Run the next command in the Java example directory: +6. Run the next command in the Java example directory: ``` docker-compose up ``` -4. After it, all the *bin* files will be passed to the *./target* folder. +7. After it, all the *bin* files will be passed to the *./target* folder. + +### Step 3. Check accessibility + +In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files. + +Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files. ## Important security info From 651150709327ae1124f76946571ee44d2da2a62c Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 7 Sep 2023 10:23:34 +0300 Subject: [PATCH 013/488] java-spring: added dto/Restore.java --- .../controllers/FileController.java | 22 ++++++------- .../onlyoffice/integration/dto/Restore.java | 33 +++++++++++++++++++ .../src/main/resources/templates/editor.html | 4 +-- 3 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Restore.java diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index c5259eaed..acc8a856a 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -27,6 +27,7 @@ import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; import com.onlyoffice.integration.dto.Converter; import com.onlyoffice.integration.dto.ConvertedData; +import com.onlyoffice.integration.dto.Restore; import com.onlyoffice.integration.dto.Track; import com.onlyoffice.integration.entities.User; import com.onlyoffice.integration.documentserver.models.enums.DocumentType; @@ -540,13 +541,9 @@ public String reference(@RequestBody final JSONObject body) { @PutMapping("/restore") @ResponseBody - public String restore(@RequestBody final JSONObject body) { + public String restore(@RequestBody final Restore body, @CookieValue("uid") final Integer uid) { try { - String sourceBasename = (String) body.get("fileName"); - Integer version = (Integer) body.get("version"); - String userID = (String) body.get("userId"); - - String sourceStringFile = storagePathBuilder.getFileLocation(sourceBasename); + String sourceStringFile = storagePathBuilder.getFileLocation(body.getFileName()); File sourceFile = new File(sourceStringFile); Path sourcePathFile = sourceFile.toPath(); String historyDirectory = storagePathBuilder.getHistoryDir(sourcePathFile.toString()); @@ -564,7 +561,7 @@ public String restore(@RequestBody final JSONObject body) { String bumpedKey = serviceConverter.generateRevisionId( storagePathBuilder.getStorageLocation() + "/" - + sourceBasename + + body.getFileName() + "/" + Long.toString(sourceFile.lastModified()) ); @@ -572,8 +569,7 @@ public String restore(@RequestBody final JSONObject body) { bumpedKeyFileWriter.write(bumpedKey); bumpedKeyFileWriter.close(); - Integer userInnerID = Integer.parseInt(userID.replace("uid-", "")); - User user = userService.findUserById(userInnerID).get(); + User user = userService.findUserById(uid).get(); Path bumpedChangesPathFile = Paths.get(bumpedVersionStringDirectory, "changes.json"); String bumpedChangesStringFile = bumpedChangesPathFile.toString(); @@ -596,13 +592,17 @@ public String restore(@RequestBody final JSONObject body) { bumpedChangesFileWriter.write(bumpedChangesContent); bumpedChangesFileWriter.close(); - String sourceExtension = fileUtility.getFileExtension(sourceBasename); + String sourceExtension = fileUtility.getFileExtension(body.getFileName()); String previousBasename = "prev" + sourceExtension; Path bumpedFile = Paths.get(bumpedVersionStringDirectory, previousBasename); Files.move(sourcePathFile, bumpedFile); - String recoveryVersionStringDirectory = documentManager.versionDir(historyDirectory, version, true); + String recoveryVersionStringDirectory = documentManager.versionDir( + historyDirectory, + body.getVersion(), + true + ); Path recoveryPathFile = Paths.get(recoveryVersionStringDirectory, previousBasename); String recoveryStringFile = recoveryPathFile.toString(); FileInputStream recoveryStream = new FileInputStream(recoveryStringFile); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Restore.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Restore.java new file mode 100644 index 000000000..ddd6b1408 --- /dev/null +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Restore.java @@ -0,0 +1,33 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.onlyoffice.integration.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class Restore { + private String fileName; + private Integer version; +} diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html index e74424817..b8f9f6376 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html @@ -174,11 +174,9 @@ function onRequestRestore(event) { const query = new URLSearchParams(window.location.search) - const config = [[${model}]] const payload = { fileName: query.get('fileName'), - version: event.data.version, - userId: config.editorConfig.user.id + version: event.data.version } const request = new XMLHttpRequest() request.open('PUT', 'restore') From aa245e2aaeed75772257b20946d3f05d07d882ac Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 7 Sep 2023 10:24:18 +0300 Subject: [PATCH 014/488] java-spring: added dto/Reference.java and dto/ReferenceData.java --- .../controllers/FileController.java | 20 +++++------ .../onlyoffice/integration/dto/Reference.java | 34 +++++++++++++++++++ .../integration/dto/ReferenceData.java | 31 +++++++++++++++++ 3 files changed, 74 insertions(+), 11 deletions(-) create mode 100644 web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java create mode 100644 web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/ReferenceData.java diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index acc8a856a..4441df186 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -27,6 +27,8 @@ import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; import com.onlyoffice.integration.dto.Converter; import com.onlyoffice.integration.dto.ConvertedData; +import com.onlyoffice.integration.dto.Reference; +import com.onlyoffice.integration.dto.ReferenceData; import com.onlyoffice.integration.dto.Restore; import com.onlyoffice.integration.dto.Track; import com.onlyoffice.integration.entities.User; @@ -75,7 +77,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; @@ -472,7 +473,7 @@ public String rename(@RequestBody final JSONObject body) { @PostMapping("/reference") @ResponseBody - public String reference(@RequestBody final JSONObject body) { + public String reference(@RequestBody final Reference body) { try { JSONParser parser = new JSONParser(); Gson gson = new GsonBuilder().disableHtmlEscaping().create(); @@ -480,12 +481,11 @@ public String reference(@RequestBody final JSONObject body) { String userAddress = ""; String fileName = ""; - if (body.containsKey("referenceData")) { - LinkedHashMap referenceDataObj = (LinkedHashMap) body.get("referenceData"); - String instanceId = (String) referenceDataObj.get("instanceId"); + if (body.getReferenceData() != null) { + ReferenceData referenceData = body.getReferenceData(); - if (instanceId.equals(storagePathBuilder.getServerUrl(false))) { - JSONObject fileKey = (JSONObject) parser.parse((String) referenceDataObj.get("fileKey")); + if (referenceData.getInstanceId().equals(storagePathBuilder.getServerUrl(false))) { + JSONObject fileKey = (JSONObject) parser.parse(referenceData.getFileKey()); userAddress = (String) fileKey.get("userAddress"); if (userAddress.equals(InetAddress.getLocalHost().getHostAddress())) { fileName = (String) fileKey.get("fileName"); @@ -496,7 +496,7 @@ public String reference(@RequestBody final JSONObject body) { if (fileName.equals("")) { try { - String path = (String) body.get("path"); + String path = (String) body.getPath(); path = fileUtility.getFileName(path); File f = new File(storagePathBuilder.getFileLocation(path)); if (f.exists()) { @@ -511,8 +511,6 @@ public String reference(@RequestBody final JSONObject body) { return "{ \"error\": \"File not found\"}"; } - boolean directUrl = (boolean) body.get("directUrl"); - HashMap fileKey = new HashMap<>(); fileKey.put("fileName", fileName); fileKey.put("userAddress", InetAddress.getLocalHost().getHostAddress()); @@ -524,7 +522,7 @@ public String reference(@RequestBody final JSONObject body) { HashMap data = new HashMap<>(); data.put("fileType", fileUtility.getFileExtension(fileName).replace(".", "")); data.put("url", documentManager.getDownloadUrl(fileName, true)); - data.put("directUrl", directUrl ? documentManager.getDownloadUrl(fileName, false) : null); + data.put("directUrl", body.getDirectUrl() ? documentManager.getDownloadUrl(fileName, false) : null); data.put("referenceData", referenceData); data.put("path", fileName); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java new file mode 100644 index 000000000..705d0d873 --- /dev/null +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java @@ -0,0 +1,34 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.onlyoffice.integration.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class Reference { + private Boolean directUrl; + private ReferenceData referenceData; + private String path; +} diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/ReferenceData.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/ReferenceData.java new file mode 100644 index 000000000..ecd2fdfad --- /dev/null +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/ReferenceData.java @@ -0,0 +1,31 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.onlyoffice.integration.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ReferenceData { + private String fileKey; + private String instanceId; +} From 8c518fd109b6f1a02a20a6a6dd5c740e187019c5 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 7 Sep 2023 10:24:53 +0300 Subject: [PATCH 015/488] java-spring: added dto/Rename.java --- .../controllers/FileController.java | 20 +++-------- .../onlyoffice/integration/dto/Rename.java | 34 +++++++++++++++++++ .../src/main/resources/templates/editor.html | 6 ++-- 3 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Rename.java diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index 4441df186..8f695b0c3 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -29,6 +29,7 @@ import com.onlyoffice.integration.dto.ConvertedData; import com.onlyoffice.integration.dto.Reference; import com.onlyoffice.integration.dto.ReferenceData; +import com.onlyoffice.integration.dto.Rename; import com.onlyoffice.integration.dto.Restore; import com.onlyoffice.integration.dto.Track; import com.onlyoffice.integration.entities.User; @@ -445,25 +446,14 @@ public String saveAs(@RequestBody final JSONObject body, @CookieValue("uid") fin @PostMapping("/rename") @ResponseBody - public String rename(@RequestBody final JSONObject body) { - String newfilename = (String) body.get("newfilename"); - String dockey = (String) body.get("dockey"); - String origExt = "." + (String) body.get("ext"); - String curExt = newfilename; - - if (newfilename.indexOf(".") != -1) { - curExt = (String) fileUtility.getFileExtension(newfilename); - } - - if (origExt.compareTo(curExt) != 0) { - newfilename += origExt; - } + public String rename(@RequestBody final Rename body) { + String fileName = body.getFileName(); HashMap meta = new HashMap<>(); - meta.put("title", newfilename); + meta.put("title", fileName + "." + body.getFileType()); try { - callbackManager.commandRequest("meta", dockey, meta); + callbackManager.commandRequest("meta", body.getFileKey(), meta); return "result ok"; } catch (Exception e) { e.printStackTrace(); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Rename.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Rename.java new file mode 100644 index 000000000..71c3badb1 --- /dev/null +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Rename.java @@ -0,0 +1,34 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.onlyoffice.integration.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class Rename { + private String fileName; + private String fileKey; + private String fileType; +} diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html index b8f9f6376..87abb539b 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html @@ -147,9 +147,9 @@ var newfilename = event.data; var data = { - newfilename: newfilename, - dockey: config.document.key, - ext: config.document.fileType + fileName: newfilename, + fileKey: config.document.key, + fileType: config.document.fileType }; let xhr = new XMLHttpRequest(); xhr.open("POST", "rename"); From 95579f2376ed9bb14440187a0a34607899a10571 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Thu, 7 Sep 2023 10:25:30 +0300 Subject: [PATCH 016/488] java-spring: added dto/SaveAs.java --- .../controllers/FileController.java | 10 +++--- .../onlyoffice/integration/dto/SaveAs.java | 33 +++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/SaveAs.java diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index 8f695b0c3..1c4949b77 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -31,6 +31,7 @@ import com.onlyoffice.integration.dto.ReferenceData; import com.onlyoffice.integration.dto.Rename; import com.onlyoffice.integration.dto.Restore; +import com.onlyoffice.integration.dto.SaveAs; import com.onlyoffice.integration.dto.Track; import com.onlyoffice.integration.entities.User; import com.onlyoffice.integration.documentserver.models.enums.DocumentType; @@ -415,19 +416,16 @@ public String track(final HttpServletRequest request, // track file changes @PostMapping("/saveas") @ResponseBody - public String saveAs(@RequestBody final JSONObject body, @CookieValue("uid") final String uid) { - String title = (String) body.get("title"); - String saveAsFileUrl = (String) body.get("url"); - + public String saveAs(@RequestBody final SaveAs body, @CookieValue("uid") final String uid) { try { - String fileName = documentManager.getCorrectName(title); + String fileName = documentManager.getCorrectName(body.getTitle()); String curExt = fileUtility.getFileExtension(fileName); if (!fileUtility.getFileExts().contains(curExt)) { return "{\"error\":\"File type is not supported\"}"; } - URL url = new URL(saveAsFileUrl); + URL url = new URL(body.getUrl()); java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection(); InputStream stream = connection.getInputStream(); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/SaveAs.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/SaveAs.java new file mode 100644 index 000000000..cfae48cad --- /dev/null +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/SaveAs.java @@ -0,0 +1,33 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.onlyoffice.integration.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class SaveAs { + private String title; + private String url; +} From 969a8c6cfe3508b83b48c5f5f147bec1c3fd0899 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 1 Dec 2022 11:18:20 +0300 Subject: [PATCH 017/488] nodejs: link in referenceData --- CHANGELOG.md | 1 + web/documentserver-example/nodejs/app.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c945cdd64..103b29099 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- nodejs: link in referenceData - nodejs: onRequestSelectDocument method - nodejs: onRequestSelectSpreadsheet method - nodejs: onRequestOpen diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index ba5e40ed9..33c30ea38 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -27,6 +27,7 @@ const jwt = require('jsonwebtoken'); const config = require('config'); const mime = require('mime'); const urllib = require('urllib'); +const urlModule = require("url"); const { emitWarning } = require('process'); const DocManager = require('./helpers/docManager'); const documentService = require('./helpers/documentService'); @@ -498,6 +499,20 @@ app.post('/reference', (req, res) => { // define a handler for renaming file } } + if (!fileName && !!req.body.link) { + if (req.body.link.indexOf(req.DocManager.curUserHostAddress()) != -1) { + result({ error: 'You do not have access to this site' }); + return; + } + + let urlObj = urlModule.parse(req.body.link, true); + fileName = urlObj.query.fileName; + if (!req.DocManager.existsSync(req.DocManager.storagePath(fileName, userAddress))) { + result({ error: 'File is not exist' }); + return; + } + } + if (!fileName && !!req.body.path) { const filePath = fileUtility.getFileName(req.body.path); From 33600df8a9a98f9c280334e46f453e9136cdc632 Mon Sep 17 00:00:00 2001 From: Natalia Date: Mon, 11 Sep 2023 18:57:19 +0300 Subject: [PATCH 018/488] added paths to the config files --- Readme.md | 4 +++- web/documentserver-example/csharp-mvc/README.md | 2 +- web/documentserver-example/java-spring/README.md | 6 +++--- web/documentserver-example/java/README.md | 6 +++--- web/documentserver-example/nodejs/README.md | 2 +- web/documentserver-example/ruby/README.md | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Readme.md b/Readme.md index c7fb0950e..680f1e265 100644 --- a/Readme.md +++ b/Readme.md @@ -11,8 +11,10 @@ You should change `http://documentserver` to your server address in these files: * [.Net (C# MVC)](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/csharp-mvc) - `web/documentserver-example/csharp-mvc/web.appsettings.config` * [.Net (C#)](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/csharp) - `web/documentserver-example/csharp/settings.config` * [Java](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/java) - `web/documentserver-example/java/src/main/resources/settings.properties` +* [Java Spring](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/java-spring) - `web/documentserver-example/java-spring/src/main/resources/application.properties` * [Node.js](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/nodejs) - `web/documentserver-example/nodejs/config/default.json` -* [PHP](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/php) - `web/documentserver-example/php/config.php` +* [PHP](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/php) - `web/documentserver-example/php/config.json` +* [Python](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/python) - `web/documentserver-example/python/config.py` * [Ruby](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/ruby) - `web/documentserver-example/ruby/config/application.rb` More information on how to use these examples can be found here: [http://api.onlyoffice.com/editors/demopreview](http://api.onlyoffice.com/editors/demopreview "http://api.onlyoffice.com/editors/demopreview") diff --git a/web/documentserver-example/csharp-mvc/README.md b/web/documentserver-example/csharp-mvc/README.md index 3959a2beb..0b849571a 100644 --- a/web/documentserver-example/csharp-mvc/README.md +++ b/web/documentserver-example/csharp-mvc/README.md @@ -14,7 +14,7 @@ See the detailed guide to learn how to install Document Server [for Windows](htt Download the [.Net (C# MVC) example](https://api.onlyoffice.com/editors/demopreview) from our site. -To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *settings.config* file: +To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *web.appsettings.config* file: ``` diff --git a/web/documentserver-example/java-spring/README.md b/web/documentserver-example/java-spring/README.md index 9dc3c10ef..2419d9949 100755 --- a/web/documentserver-example/java-spring/README.md +++ b/web/documentserver-example/java-spring/README.md @@ -20,7 +20,7 @@ See the detailed guide to learn how to install Document Server [for Windows](htt Download the [Java-Spring example](https://api.onlyoffice.com/editors/demopreview) from our site. -To connect the editors to your website, specify the path to the editors installation, server port and the path to the storage folder in the *\src\main\resources\application.properties* file: +To connect the editors to your website, specify the path to the editors installation, server port and the path to the storage folder in the *src/main/resources/application.properties* file: ``` files.storage= @@ -158,7 +158,7 @@ See the detailed guide to learn how to install Document Server [for Linux](https ``` cd document-server-integration/web/documentserver-example/java-spring ``` -4. Edit the *application.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. +4. Edit the *src/main/resources/application.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. ``` nano src/main/resources/application.properties @@ -244,7 +244,7 @@ See the detailed guide to learn how to install Document Server [for Docker](http ``` cd document-server-integration/web/documentserver-example/java-spring ``` -4. Edit the *application.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed: +4. Edit the *src/main/resources/application.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed: ``` nano src/main/resources/application.properties diff --git a/web/documentserver-example/java/README.md b/web/documentserver-example/java/README.md index 708a740e0..fcbdb5c74 100644 --- a/web/documentserver-example/java/README.md +++ b/web/documentserver-example/java/README.md @@ -16,7 +16,7 @@ See the detailed guide to learn how to [install Document Server for Windows](htt Download the [Java example](https://api.onlyoffice.com/editors/demopreview) from our site. -To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *\src\main\resources\settings.properties* file: +To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *src/main/resources/settings.properties* file: ``` storage-folder = app_data @@ -158,7 +158,7 @@ See the detailed guide to learn how to [install Document Server for Linux](https cd Java\ Example/ ``` -4. Edit the *settings.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. +4. Edit the *src/main/resources/settings.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. ``` nano src/main/resources/settings.properties @@ -263,7 +263,7 @@ See the detailed guide to learn how to install Document Server [for Docker](http cd Java\ Example/ ``` -4. Edit the *settings.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed: +4. Edit the *src/main/resources/settings.properties* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed: ``` nano src/main/resources/settings.properties diff --git a/web/documentserver-example/nodejs/README.md b/web/documentserver-example/nodejs/README.md index 8980e48f8..aa82d1e9e 100644 --- a/web/documentserver-example/nodejs/README.md +++ b/web/documentserver-example/nodejs/README.md @@ -110,7 +110,7 @@ See the detailed guide to learn how to [install Document Server for Linux](https npm install ``` -5. Edit the *default.json* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. +5. Edit the *config/default.json* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. ``` nano config/default.json diff --git a/web/documentserver-example/ruby/README.md b/web/documentserver-example/ruby/README.md index e52f97bcd..8fb99f2f2 100755 --- a/web/documentserver-example/ruby/README.md +++ b/web/documentserver-example/ruby/README.md @@ -44,7 +44,7 @@ See the detailed guide to learn how to install Document Server [for Windows](htt bundle install ``` -5. Edit the *application.rb* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. +5. Edit the *config/application.rb* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. ``` nano config/application.rb From ef53346f165f3e34e47cba4f9f402c20ff132ca1 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Mon, 11 Sep 2023 22:34:11 +0300 Subject: [PATCH 019/488] nodejs: fix lint (6315ccbf45b601c2ed6328d3de3fe7d767a5422a) --- web/documentserver-example/nodejs/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 33c30ea38..7eec4cea4 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -1,4 +1,4 @@ -/** +/** * * (c) Copyright Ascensio System SIA 2023 * @@ -27,7 +27,7 @@ const jwt = require('jsonwebtoken'); const config = require('config'); const mime = require('mime'); const urllib = require('urllib'); -const urlModule = require("url"); +const urlModule = require('url'); const { emitWarning } = require('process'); const DocManager = require('./helpers/docManager'); const documentService = require('./helpers/documentService'); @@ -500,12 +500,12 @@ app.post('/reference', (req, res) => { // define a handler for renaming file } if (!fileName && !!req.body.link) { - if (req.body.link.indexOf(req.DocManager.curUserHostAddress()) != -1) { + if (req.body.link.indexOf(req.DocManager.curUserHostAddress()) !== -1) { result({ error: 'You do not have access to this site' }); return; } - let urlObj = urlModule.parse(req.body.link, true); + const urlObj = urlModule.parse(req.body.link, true); fileName = urlObj.query.fileName; if (!req.DocManager.existsSync(req.DocManager.storagePath(fileName, userAddress))) { result({ error: 'File is not exist' }); From 45051d2c291f0e6494da020043781c01c561ef5f Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 12 Sep 2023 17:24:29 +0300 Subject: [PATCH 020/488] java: fixed FormatManager --- .../src/main/java/format/FormatManager.java | 158 ++++-------------- .../src/main/java/helpers/FileUtility.java | 17 +- 2 files changed, 43 insertions(+), 132 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/format/FormatManager.java b/web/documentserver-example/java/src/main/java/format/FormatManager.java index 1ae4110b4..8185b2668 100644 --- a/web/documentserver-example/java/src/main/java/format/FormatManager.java +++ b/web/documentserver-example/java/src/main/java/format/FormatManager.java @@ -25,9 +25,11 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; @@ -35,66 +37,46 @@ import entities.FileType; public final class FormatManager { - public List fillableExtensions() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .fillable() - .stream() - .map(format -> format.extension()) - .collect(Collectors.toList()); + + private List formats; + + public FormatManager() { + formats = this.all(); } - public List fillable() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .all() - .stream() - .filter(format -> format.getActions().contains("fill")) - .collect(Collectors.toList()); + + public List getFormats() { + return this.formats; } - public List viewableExtensions() throws URISyntaxException, - IOException, - JsonSyntaxException { + public List getFormatsByAction(String action) { return this - .viewable() - .stream() - .map(format -> format.extension()) - .collect(Collectors.toList()); + .all() + .stream() + .filter(format -> format.getActions().contains(action)) + .collect(Collectors.toList()); } - public List viewable() throws URISyntaxException, - IOException, - JsonSyntaxException { + public List fillableExtensions() { return this - .all() + .getFormatsByAction("fill") .stream() - .filter(format -> format.getActions().contains("view")) + .map(format -> format.extension()) .collect(Collectors.toList()); } - public List editableExtensions() throws URISyntaxException, - IOException, - JsonSyntaxException { + public List viewableExtensions() { return this - .editable() + .getFormatsByAction("view") .stream() .map(format -> format.extension()) .collect(Collectors.toList()); } - public List editable() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .all() - .stream() - .filter(format -> ( - format.getActions().contains("edit") - || format.getActions().contains("lossy-edit") - )) + public List editableExtensions() { + return Stream.of(this.getFormatsByAction("edit"), this.getFormatsByAction("edit")) + .flatMap(x -> x.stream()) + .map(format -> format.extension()) .collect(Collectors.toList()); } @@ -112,7 +94,7 @@ public List convertible() throws URISyntaxException, IOException, JsonSyntaxException { return this - .all() + .formats .stream() .filter(format -> ( format.getType() == FileType.Cell && format.getConvert().contains("xlsx") @@ -122,85 +104,19 @@ public List convertible() throws URISyntaxException, .collect(Collectors.toList()); } - public List spreadsheetExtensions() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .spreadsheets() - .stream() - .map(format -> format.extension()) - .collect(Collectors.toList()); - } - - public List spreadsheets() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .all() - .stream() - .filter(format -> format.getType() == FileType.Cell) - .collect(Collectors.toList()); - } - - public List presentationExtensions() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .presentations() - .stream() - .map(format -> format.extension()) - .collect(Collectors.toList()); - } - - public List presentations() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .all() - .stream() - .filter(format -> format.getType() == FileType.Slide) - .collect(Collectors.toList()); - } - - public List documentExtensions() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .documents() - .stream() - .map(format -> format.extension()) - .collect(Collectors.toList()); - } - - public List documents() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .all() - .stream() - .filter(format -> format.getType() == FileType.Word) - .collect(Collectors.toList()); - } - - public List allExtensions() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .all() - .stream() - .map(format -> format.extension()) - .collect(Collectors.toList()); - } + private List all() { + try { + Path path = this.file(); + List lines = Files.readAllLines(path, StandardCharsets.UTF_8); + String contents = String.join(System.lineSeparator(), lines); + Gson gson = new Gson(); + Format[] formats = gson.fromJson(contents, Format[].class); + return Arrays.asList(formats); + } catch (Exception e) { + e.printStackTrace(); + } - public List all() throws URISyntaxException, - IOException, - JsonSyntaxException { - Path path = this.file(); - List lines = Files.readAllLines(path, StandardCharsets.UTF_8); - String contents = String.join(System.lineSeparator(), lines); - Gson gson = new Gson(); - Format[] formats = gson.fromJson(contents, Format[].class); - return Arrays.asList(formats); + return new ArrayList<>(); } private Path file() throws URISyntaxException { diff --git a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java index b353d5774..5a70fef8a 100644 --- a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java +++ b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java @@ -19,10 +19,12 @@ package helpers; import entities.FileType; +import format.Format; import format.FormatManager; import java.net.URL; import java.util.HashMap; +import java.util.List; import java.util.Map; public final class FileUtility { @@ -33,19 +35,12 @@ private FileUtility() { } // get file type public static FileType getFileType(final String fileName) { String ext = getFileExtension(fileName).toLowerCase(); + List formats = FileUtility.formatManager.getFormats(); - try { - if (FileUtility.formatManager.documentExtensions().contains(ext)) { - return FileType.Word; - } - if (FileUtility.formatManager.spreadsheetExtensions().contains(ext)) { - return FileType.Cell; - } - if (FileUtility.formatManager.presentationExtensions().contains(ext)) { - return FileType.Slide; + for (Format format : formats) { + if (format.getName().equals(ext)) { + return format.getType(); } - } catch (Exception error) { - error.printStackTrace(); } // default file type is word From 5f3b0c61ebf018aa30070b94baa304ccb6e032be Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 12 Sep 2023 17:33:52 +0300 Subject: [PATCH 021/488] java: delete submodule document-formats --- .gitmodules | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index 96191c4f1..52687a2de 100644 --- a/.gitmodules +++ b/.gitmodules @@ -30,10 +30,6 @@ path = web/documentserver-example/java/src/main/resources/assets/document-templates url = https://github.com/ONLYOFFICE/document-templates branch = main/en -[submodule "web/documentserver-example/java/src/main/resources/assets/document-formats"] - path = web/documentserver-example/java/src/main/resources/assets/document-formats - url = https://github.com/ONLYOFFICE/document-formats - branch = master [submodule "web/documentserver-example/ruby/assets/document-templates"] path = web/documentserver-example/ruby/assets/document-templates url = https://github.com/ONLYOFFICE/document-templates From c20687e2412f214881d69c491ed37192bc9a9845 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Tue, 12 Sep 2023 17:34:46 +0300 Subject: [PATCH 022/488] java: added submodule document-formats --- .gitmodules | 4 ++++ .../java/src/main/resources/assets/document-formats | 1 + 2 files changed, 5 insertions(+) create mode 160000 web/documentserver-example/java/src/main/resources/assets/document-formats diff --git a/.gitmodules b/.gitmodules index 52687a2de..eb76cf450 100644 --- a/.gitmodules +++ b/.gitmodules @@ -46,3 +46,7 @@ path = web/documentserver-example/ruby/assets/document-formats url = https://github.com/ONLYOFFICE/document-formats branch = master +[submodule "web/documentserver-example/java/src/main/resources/assets/document-formats"] + path = web/documentserver-example/java/src/main/resources/assets/document-formats + url = https://github.com/ONLYOFFICE/document-formats + branch = master diff --git a/web/documentserver-example/java/src/main/resources/assets/document-formats b/web/documentserver-example/java/src/main/resources/assets/document-formats new file mode 160000 index 000000000..bf21acc76 --- /dev/null +++ b/web/documentserver-example/java/src/main/resources/assets/document-formats @@ -0,0 +1 @@ +Subproject commit bf21acc7666b9ddb64606247f5afb119952f8475 From cb21d73641ce0ea388ee8c55b6f4a387d7ecf170 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 12 Sep 2023 21:36:09 +0300 Subject: [PATCH 023/488] format to changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 103b29099..9a087d367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ - nodejs: change reference source - php: using a repo with a list of formats - nodejs: using a repo with a list of formats +- java: using a repo with a list of formats +- python: using a repo with a list of formats +- ruby: using a repo with a list of formats - nodejs: delete file without reloading the page - nodejs: getting history by a separate request - csharp-mvc: getting history by a separate request From 0f3bb28d920ef79a68731fd0acfa7e12ae9cea20 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 13 Sep 2023 11:17:43 +0300 Subject: [PATCH 024/488] java: added lombok dependency --- .../java/3rd-Party.license | 4 + .../java/licenses/3rd-Party.license | 4 + .../java/licenses/lombok.license | 104 ++++++++++++++++++ web/documentserver-example/java/pom.xml | 6 + 4 files changed, 118 insertions(+) create mode 100644 web/documentserver-example/java/licenses/lombok.license diff --git a/web/documentserver-example/java/3rd-Party.license b/web/documentserver-example/java/3rd-Party.license index 4d1f25a44..6780f1de7 100644 --- a/web/documentserver-example/java/3rd-Party.license +++ b/web/documentserver-example/java/3rd-Party.license @@ -27,3 +27,7 @@ License File: jQuery.UI.license Prime JWT - is intended to be fast and easy to use. Prime JWT has a single external dependency on Jackson. (https://github.com/ws-apps/prime-jwt/blob/master/LICENSE) License: Apache 2.0 License File: prime-jwt.license + +Project Lombok - Spice up your java: Automatic Resource Management, automatic generation of getters, setters, equals, hashCode and toString, and more! (https://projectlombok.org/LICENSE) +License: MIT +License File: lombok.license diff --git a/web/documentserver-example/java/licenses/3rd-Party.license b/web/documentserver-example/java/licenses/3rd-Party.license index 4d1f25a44..48d683afd 100644 --- a/web/documentserver-example/java/licenses/3rd-Party.license +++ b/web/documentserver-example/java/licenses/3rd-Party.license @@ -27,3 +27,7 @@ License File: jQuery.UI.license Prime JWT - is intended to be fast and easy to use. Prime JWT has a single external dependency on Jackson. (https://github.com/ws-apps/prime-jwt/blob/master/LICENSE) License: Apache 2.0 License File: prime-jwt.license + +Project Lombok - Spice up your java: Automatic Resource Management, automatic generation of getters, setters, equals, hashCode and toString, and more! (https://projectlombok.org/LICENSE) +License: MIT +License File: lombok.license \ No newline at end of file diff --git a/web/documentserver-example/java/licenses/lombok.license b/web/documentserver-example/java/licenses/lombok.license new file mode 100644 index 000000000..a80ced429 --- /dev/null +++ b/web/documentserver-example/java/licenses/lombok.license @@ -0,0 +1,104 @@ +Copyright (C) 2009-2021 The Project Lombok Authors. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +============================================================================== +Licenses for included components: + +org.ow2.asm:asm +org.ow2.asm:asm-analysis +org.ow2.asm:asm-commons +org.ow2.asm:asm-tree +org.ow2.asm:asm-util +ASM: a very small and fast Java bytecode manipulation framework + Copyright (c) 2000-2011 INRIA, France Telecom + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------ +rzwitserloot/com.zwitserloot.cmdreader + + Copyright © 2010 Reinier Zwitserloot. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +------------------------------------------------------------------------------ + +projectlombok/lombok.patcher + + Copyright (C) 2009-2021 The Project Lombok Authors. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +------------------------------------------------------------------------------ \ No newline at end of file diff --git a/web/documentserver-example/java/pom.xml b/web/documentserver-example/java/pom.xml index 58c555b82..448b93430 100644 --- a/web/documentserver-example/java/pom.xml +++ b/web/documentserver-example/java/pom.xml @@ -36,6 +36,12 @@ prime-jwt 1.3.1 + + org.projectlombok + lombok + 1.18.28 + provided + From 5e2f812fee1d1b90c89a1dfd33bdb4f2d79cedb7 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 13 Sep 2023 11:24:51 +0300 Subject: [PATCH 025/488] java: refactoring Format.java, FormatManager.java, FileType.java --- .../java/src/main/java/entities/FileType.java | 15 ++++- .../java/src/main/java/format/Format.java | 54 ++++------------ .../src/main/java/format/FormatManager.java | 61 +++++++------------ .../main/java/helpers/DocumentManager.java | 45 ++++---------- .../src/main/java/helpers/FileUtility.java | 2 +- 5 files changed, 57 insertions(+), 120 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/entities/FileType.java b/web/documentserver-example/java/src/main/java/entities/FileType.java index d9c90fc45..57e5710ed 100644 --- a/web/documentserver-example/java/src/main/java/entities/FileType.java +++ b/web/documentserver-example/java/src/main/java/entities/FileType.java @@ -18,8 +18,17 @@ package entities; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.annotations.SerializedName; + public enum FileType { - Word, - Cell, - Slide + @JsonProperty("word") + @SerializedName("word") + WORD, + @JsonProperty("cell") + @SerializedName("cell") + CELL, + @JsonProperty("slide") + @SerializedName("slide") + SLIDE } diff --git a/web/documentserver-example/java/src/main/java/format/Format.java b/web/documentserver-example/java/src/main/java/format/Format.java index ffdb08e66..3ed805ec6 100644 --- a/web/documentserver-example/java/src/main/java/format/Format.java +++ b/web/documentserver-example/java/src/main/java/format/Format.java @@ -21,51 +21,19 @@ import java.util.List; import entities.FileType; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +@Getter +@Setter +@ToString public final class Format { - private final String name; - public String getName() { - return this.name; - } + private String name; + private FileType type; + private List actions; + private List convert; + private List mime; - private final FileType type; - - public FileType getType() { - return this.type; - } - - private final List actions; - - public List getActions() { - return this.actions; - } - - private final List convert; - - public List getConvert() { - return this.convert; - } - - private final List mime; - - public List getMime() { - return this.mime; - } - - public Format(final String nameParameter, - final FileType typeParameter, - final List actionsParameter, - final List convertParameter, - final List mimeParameter) { - this.name = nameParameter; - this.type = typeParameter; - this.actions = actionsParameter; - this.convert = convertParameter; - this.mime = mimeParameter; - } - - public String extension() { - return "." + this.name; - } } diff --git a/web/documentserver-example/java/src/main/java/format/FormatManager.java b/web/documentserver-example/java/src/main/java/format/FormatManager.java index 8185b2668..8fac55a2a 100644 --- a/web/documentserver-example/java/src/main/java/format/FormatManager.java +++ b/web/documentserver-example/java/src/main/java/format/FormatManager.java @@ -18,23 +18,18 @@ package format; -import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; - -import entities.FileType; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; public final class FormatManager { @@ -44,12 +39,11 @@ public FormatManager() { formats = this.all(); } - public List getFormats() { return this.formats; } - public List getFormatsByAction(String action) { + public List getFormatsByAction(final String action) { return this .all() .stream() @@ -57,11 +51,19 @@ public List getFormatsByAction(String action) { .collect(Collectors.toList()); } + public List allExtensions() { + return this + .formats + .stream() + .map(format -> format.getName()) + .collect(Collectors.toList()); + } + public List fillableExtensions() { return this .getFormatsByAction("fill") .stream() - .map(format -> format.extension()) + .map(format -> format.getName()) .collect(Collectors.toList()); } @@ -69,49 +71,30 @@ public List viewableExtensions() { return this .getFormatsByAction("view") .stream() - .map(format -> format.extension()) + .map(format -> format.getName()) .collect(Collectors.toList()); } public List editableExtensions() { - return Stream.of(this.getFormatsByAction("edit"), this.getFormatsByAction("edit")) + return Stream.of(this.getFormatsByAction("edit"), this.getFormatsByAction("lossy-edit")) .flatMap(x -> x.stream()) - .map(format -> format.extension()) - .collect(Collectors.toList()); - } - - public List convertibleExtensions() throws URISyntaxException, - IOException, - JsonSyntaxException { - return this - .convertible() - .stream() - .map(format -> format.extension()) + .map(format -> format.getName()) .collect(Collectors.toList()); } - public List convertible() throws URISyntaxException, - IOException, - JsonSyntaxException { + public List autoConvertExtensions() { return this - .formats - .stream() - .filter(format -> ( - format.getType() == FileType.Cell && format.getConvert().contains("xlsx") - || format.getType() == FileType.Slide && format.getConvert().contains("pptx") - || format.getType() == FileType.Word && format.getConvert().contains("docx") - )) - .collect(Collectors.toList()); + .getFormatsByAction("auto-convert") + .stream() + .map(format -> format.getName()) + .collect(Collectors.toList()); } private List all() { try { + ObjectMapper objectMapper = new ObjectMapper(); Path path = this.file(); - List lines = Files.readAllLines(path, StandardCharsets.UTF_8); - String contents = String.join(System.lineSeparator(), lines); - Gson gson = new Gson(); - Format[] formats = gson.fromJson(contents, Format[].class); - return Arrays.asList(formats); + return objectMapper.readValue(Files.readAllBytes(path), new TypeReference>() { }); } catch (Exception e) { e.printStackTrace(); } diff --git a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java index 0c6b4de5d..904724888 100755 --- a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java +++ b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java @@ -83,49 +83,26 @@ public static long getMaxFileSize() { // get all the supported file extensions public static List getFileExts() { - List res = new ArrayList<>(); - - res.addAll(getViewedExts()); - res.addAll(getEditedExts()); - res.addAll(getConvertExts()); - res.addAll(getFillExts()); - - return res; + return DocumentManager.formatManager.allExtensions(); } public static List getFillExts() { - try { - return DocumentManager.formatManager.fillableExtensions(); - } catch (Exception ex) { - return new ArrayList<>(); - } + return DocumentManager.formatManager.fillableExtensions(); } // get file extensions that can be viewed public static List getViewedExts() { - try { - return DocumentManager.formatManager.viewableExtensions(); - } catch (Exception ex) { - return new ArrayList<>(); - } + return DocumentManager.formatManager.viewableExtensions(); } // get file extensions that can be edited public static List getEditedExts() { - try { - return DocumentManager.formatManager.editableExtensions(); - } catch (Exception ex) { - return new ArrayList<>(); - } + return DocumentManager.formatManager.editableExtensions(); } // get file extensions that can be converted public static List getConvertExts() { - try { - return DocumentManager.formatManager.convertibleExtensions(); - } catch (Exception ex) { - return new ArrayList<>(); - } + return DocumentManager.formatManager.autoConvertExtensions(); } // get current user host address @@ -513,17 +490,17 @@ public static String getDownloadHistoryUrl(final String fileName, final Integer // get an editor internal extension public static String getInternalExtension(final FileType fileType) { // .docx for word file type - if (fileType.equals(FileType.Word)) { + if (fileType.equals(FileType.WORD)) { return ".docx"; } // .xlsx for cell file type - if (fileType.equals(FileType.Cell)) { + if (fileType.equals(FileType.CELL)) { return ".xlsx"; } // .pptx for slide file type - if (fileType.equals(FileType.Slide)) { + if (fileType.equals(FileType.SLIDE)) { return ".pptx"; } @@ -535,17 +512,17 @@ public static String getInternalExtension(final FileType fileType) { public static String getTemplateImageUrl(final FileType fileType) { String path = getServerUrl(true) + "/css/img/"; // for word file type - if (fileType.equals(FileType.Word)) { + if (fileType.equals(FileType.WORD)) { return path + "file_docx.svg"; } // .xlsx for cell file type - if (fileType.equals(FileType.Cell)) { + if (fileType.equals(FileType.CELL)) { return path + "file_xlsx.svg"; } // .pptx for slide file type - if (fileType.equals(FileType.Slide)) { + if (fileType.equals(FileType.SLIDE)) { return path + "file_pptx.svg"; } diff --git a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java index 5a70fef8a..e98446a9e 100644 --- a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java +++ b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java @@ -44,7 +44,7 @@ public static FileType getFileType(final String fileName) { } // default file type is word - return FileType.Word; + return FileType.WORD; } // get file name from the url From 5a63bd47c1c1951d89650ed18528c61e596deea5 Mon Sep 17 00:00:00 2001 From: Aleksandr Fedorov Date: Wed, 13 Sep 2023 11:27:06 +0300 Subject: [PATCH 026/488] java: changed getFileExtension return without dot --- .../src/main/java/controllers/IndexServlet.java | 14 +++++++------- .../java/src/main/java/entities/FileModel.java | 2 +- .../src/main/java/helpers/DocumentManager.java | 4 ++-- .../java/src/main/java/helpers/FileUtility.java | 2 +- .../src/main/java/helpers/ServiceConverter.java | 4 ++-- .../java/src/main/java/helpers/TrackManager.java | 14 +++++++------- .../java/src/main/webapp/index.jsp | 6 +++--- .../java/src/main/webapp/scripts/jscript.js | 8 ++++---- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index 26206d811..89e01672e 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -635,7 +635,7 @@ private static void rename(final HttpServletRequest request, String newfilename = (String) body.get("newfilename"); String dockey = (String) body.get("dockey"); - String origExt = "." + (String) body.get("ext"); + String origExt = (String) body.get("ext"); String curExt = newfilename; if (newfilename.indexOf(".") != -1) { @@ -643,7 +643,7 @@ private static void rename(final HttpServletRequest request, } if (origExt.compareTo(curExt) != 0) { - newfilename += origExt; + newfilename += "." + origExt; } HashMap meta = new HashMap<>(); @@ -724,7 +724,7 @@ private static void reference(final HttpServletRequest request, referenceData.put("fileKey", gson.toJson(fileKey)); HashMap data = new HashMap<>(); - data.put("fileType", FileUtility.getFileExtension(fileName).replace(".", "")); + data.put("fileType", FileUtility.getFileExtension(fileName)); data.put("url", DocumentManager.getDownloadUrl(fileName, true)); data.put("directUrl", directUrl ? DocumentManager.getDownloadUrl(fileName, false) : null); data.put("referenceData", referenceData); @@ -805,7 +805,7 @@ private static void restore(final HttpServletRequest request, bumpedChangesFileWriter.close(); String sourceExtension = FileUtility.getFileExtension(sourceBasename); - String previousBasename = "prev" + sourceExtension; + String previousBasename = "prev." + sourceExtension; Path bumpedFile = Paths.get(bumpedVersionStringDirectory, previousBasename); Files.move(sourcePathFile, bumpedFile); @@ -947,16 +947,16 @@ private static void historyData(final HttpServletRequest request, key = DocumentManager.readFileToEnd(new File(verDir + File.separator + "key.txt")); } - dataObj.put("fileType", FileUtility.getFileExtension(fileName).substring(1)); + dataObj.put("fileType", FileUtility.getFileExtension(fileName)); dataObj.put("key", key); dataObj.put("url", i == curVer ? DocumentManager.getDownloadUrl(fileName, true) - : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev" + FileUtility + : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev." + FileUtility .getFileExtension(fileName), true)); if (directUrl.equals("true")) { dataObj.put("directUrl", i == curVer ? DocumentManager.getDownloadUrl(fileName, false) - : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev" + FileUtility + : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev." + FileUtility .getFileExtension(fileName), false)); } diff --git a/web/documentserver-example/java/src/main/java/entities/FileModel.java b/web/documentserver-example/java/src/main/java/entities/FileModel.java index 13e944996..c50c4ad3e 100755 --- a/web/documentserver-example/java/src/main/java/entities/FileModel.java +++ b/web/documentserver-example/java/src/main/java/entities/FileModel.java @@ -63,7 +63,7 @@ public FileModel(final String fileNameParam, document.setDirectUrl(isEnableDirectUrl ? DocumentManager.getDownloadUrl(fileName, false) : ""); // get file extension from the file name - document.setFileType(FileUtility.getFileExtension(fileName).replace(".", "")); + document.setFileType(FileUtility.getFileExtension(fileName)); // generate document key document.setKey(ServiceConverter .generateRevisionId(DocumentManager diff --git a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java index 904724888..2e4d5dc13 100755 --- a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java +++ b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java @@ -248,12 +248,12 @@ public static int getFileVersion(final String fileName, final String userAddress public static String getCorrectName(final String fileName, final String userAddress) { String baseName = FileUtility.getFileNameWithoutExtension(fileName); String ext = FileUtility.getFileExtension(fileName); - String name = baseName + ext; + String name = baseName + "." + ext; File file = new File(storagePath(name, userAddress)); for (int i = 1; file.exists(); i++) { // run through all the files with such a name in the storage directory - name = baseName + " (" + i + ")" + ext; // and add an index to the base name + name = baseName + " (" + i + ")." + ext; // and add an index to the base name file = new File(storagePath(name, userAddress)); } diff --git a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java index e98446a9e..1ebc5fd4f 100644 --- a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java +++ b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java @@ -75,7 +75,7 @@ public static String getFileExtension(final String url) { if (fileName == null) { return null; } - String fileExt = fileName.substring(fileName.lastIndexOf(".")); + String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1); return fileExt.toLowerCase(); } diff --git a/web/documentserver-example/java/src/main/java/helpers/ServiceConverter.java b/web/documentserver-example/java/src/main/java/helpers/ServiceConverter.java index de29d42ed..9c76e84f3 100644 --- a/web/documentserver-example/java/src/main/java/helpers/ServiceConverter.java +++ b/web/documentserver-example/java/src/main/java/helpers/ServiceConverter.java @@ -158,8 +158,8 @@ public static Map getConvertedData(final String documentUri, fin ConvertBody body = new ConvertBody(); body.setRegion(lang); body.setUrl(documentUri); - body.setOutputtype(toExtension.replace(".", "")); - body.setFiletype(fromExt.replace(".", "")); + body.setOutputtype(toExtension); + body.setFiletype(fromExt); body.setTitle(title); body.setKey(documentRevId); body.setPassword(filePass); diff --git a/web/documentserver-example/java/src/main/java/helpers/TrackManager.java b/web/documentserver-example/java/src/main/java/helpers/TrackManager.java index 5acddef1c..83fdae5ed 100755 --- a/web/documentserver-example/java/src/main/java/helpers/TrackManager.java +++ b/web/documentserver-example/java/src/main/java/helpers/TrackManager.java @@ -150,7 +150,7 @@ public static void processSave(final JSONObject body, String newFileName = fileName; String curExt = FileUtility.getFileExtension(fileName); // get current file extension - String downloadExt = "." + (String) body.get("filetype"); // get the extension of the downloaded file + String downloadExt = (String) body.get("filetype"); // get the extension of the downloaded file // convert downloaded file to the file with the current extension if these extensions aren't equal if (!curExt.equals(downloadExt)) { @@ -164,13 +164,13 @@ public static void processSave(final JSONObject body, // get the correct file name if it already exists newFileName = DocumentManager .getCorrectName(FileUtility - .getFileNameWithoutExtension(fileName) + downloadExt, userAddress); + .getFileNameWithoutExtension(fileName) + "." + downloadExt, userAddress); } else { downloadUri = newFileUri; } } catch (Exception e) { newFileName = DocumentManager.getCorrectName(FileUtility - .getFileNameWithoutExtension(fileName) + downloadExt, userAddress); + .getFileNameWithoutExtension(fileName) + "." + downloadExt, userAddress); } } @@ -193,7 +193,7 @@ public static void processSave(final JSONObject body, } // get the path to the previous file version and rename the last file version with it - lastVersion.renameTo(new File(versionDir + File.separator + "prev" + curExt)); + lastVersion.renameTo(new File(versionDir + File.separator + "prev." + curExt)); saveFile(byteArrayFile, toSave); // save document file @@ -236,7 +236,7 @@ public static void processForceSave(final JSONObject body, String downloadUri = (String) body.get("url"); String curExt = FileUtility.getFileExtension(fileName); // get current file extension - String downloadExt = "." + (String) body.get("filetype"); // get the extension of the downloaded file + String downloadExt = (String) body.get("filetype"); // get the extension of the downloaded file Boolean newFileName = false; @@ -265,10 +265,10 @@ public static void processForceSave(final JSONObject body, // new file if (newFileName) { fileName = DocumentManager.getCorrectName(FileUtility.getFileNameWithoutExtension(fileName) - + "-form" + downloadExt, userAddress); // get the correct file name if it already exists + + "-form." + downloadExt, userAddress); // get the correct file name if it already exists } else { fileName = DocumentManager.getCorrectName(FileUtility.getFileNameWithoutExtension(fileName) - + "-form" + curExt, userAddress); + + "-form." + curExt, userAddress); } forcesavePath = DocumentManager.storagePath(fileName, userAddress); } else { diff --git a/web/documentserver-example/java/src/main/webapp/index.jsp b/web/documentserver-example/java/src/main/webapp/index.jsp index ca1dbab6d..2a95a6f6a 100755 --- a/web/documentserver-example/java/src/main/webapp/index.jsp +++ b/web/documentserver-example/java/src/main/webapp/index.jsp @@ -367,9 +367,9 @@ From f096fd4d93e59c3497ebce774362c6f51f9639a1 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Mon, 23 Oct 2023 18:02:51 +0300 Subject: [PATCH 143/488] nodejs: fix mobile size for chrome on iOS (Fix Bug 59054) --- web/documentserver-example/nodejs/views/editor.ejs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index 5d3ae7d86..7fccec98b 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -336,11 +336,18 @@ } }; + var onDocumentReady = function(){ + if (config.type === "mobile") { + document.getElementsByTagName("iframe")[0].style.height = window.innerHeight + "px"; + } + }; + config = { <%- include("config") %> }; config.events = { "onAppReady": onAppReady, + "onDocumentReady": fixSize, "onDocumentStateChange": onDocumentStateChange, "onError": onError, "onOutdatedVersion": onOutdatedVersion, From 304995c3e1331dd6d364e6106f782acbedd054f9 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 24 Oct 2023 11:23:55 +0700 Subject: [PATCH 144/488] flake8: E501 line too long (> 120 characters) --- .../python/src/utils/docManager.py | 33 +++++-- .../python/src/utils/historyManager.py | 20 ++-- .../python/src/utils/serviceConverter.py | 8 +- .../python/src/utils/trackManager.py | 37 +++++--- .../python/src/utils/users.py | 6 +- .../python/src/views/actions.py | 92 +++++++++++++------ .../python/src/views/index.py | 3 +- 7 files changed, 133 insertions(+), 66 deletions(-) diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 6bce2312a..3bc74a582 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -205,13 +205,22 @@ def getStoredFiles(req): directory = getRootFolder(req) files = os.listdir(directory) - files.sort(key=lambda x: os.path.getmtime(os.path.join(directory, x)), reverse=True) # sort files by time of last modification + + # sort files by time of last modification + files.sort(key=lambda x: os.path.getmtime(os.path.join(directory, x)), reverse=True) fileInfos = [] for f in files: if os.path.isfile(os.path.join(directory, f)): - fileInfos.append({'isFillFormDoc': isCanFillForms(fileUtils.getFileExt(f)), 'version': historyManager.getFileVersion(historyManager.getHistoryDir(getStoragePath(f, req))), 'type': fileUtils.getFileType(f), 'title': f, 'url': getFileUri(f, True, req), 'canEdit': isCanEdit(fileUtils.getFileExt(f))}) # write information about file type, title and url + fileInfos.append({ + 'isFillFormDoc': isCanFillForms(fileUtils.getFileExt(f)), + 'version': historyManager.getFileVersion(historyManager.getHistoryDir(getStoragePath(f, req))), + 'type': fileUtils.getFileType(f), + 'title': f, + 'url': getFileUri(f, True, req), + 'canEdit': isCanEdit(fileUtils.getFileExt(f)) + }) # write information about file type, title and url return fileInfos @@ -258,11 +267,12 @@ def createSample(fileType, sample, req): sample = 'false' sampleName = 'sample' if sample == 'true' else 'new' # create sample or new template - - filename = getCorrectName(f'{sampleName}{ext}', req) # get file name with an index if such a file name already exists + # get file name with an index if such a file name already exists + filename = getCorrectName(f'{sampleName}{ext}', req) path = getStoragePath(filename, req) - - with io.open(os.path.join('assets', 'document-templates', 'sample' if sample == 'true' else 'new', f'{sampleName}{ext}'), 'rb') as stream: # create sample file of the necessary extension in the directory + # create sample file of the necessary extension in the directory + with io.open(os.path.join('assets', 'document-templates', 'sample' if sample == 'true' else 'new', + f'{sampleName}{ext}'), 'rb') as stream: createFile(stream, path, req, True) return filename @@ -282,8 +292,8 @@ def generateFileKey(filename, req): path = getStoragePath(filename, req) uri = getFileUri(filename, False, req) stat = os.stat(path) # get the directory parameters - - h = str(hash(f'{uri}_{stat.st_mtime_ns}')) # get the hash value of the file url and the date of its last modification and turn it into a string format + # get the hash value of the file url and the date of its last modification and turn it into a string format + h = str(hash(f'{uri}_{stat.st_mtime_ns}')) replaced = re.sub(r'[^0-9-.a-zA-Z_=]', '_', h) return replaced[:20] # take the first 20 characters for the key @@ -307,7 +317,9 @@ def getFilesInfo(req): stats = os.stat(os.path.join(getRootFolder(req), f.get("title"))) # get file information result.append( # write file parameters to the file object { - "version": historyManager.getFileVersion(historyManager.getHistoryDir(getStoragePath(f.get("title"), req))), + "version": historyManager.getFileVersion(historyManager.getHistoryDir( + getStoragePath(f.get("title"), req) + )), "id": generateFileKey(f.get("title"), req), "contentLength": "%.2f KB" % (stats.st_size/1024), "pureContentLength": stats.st_size, @@ -331,7 +343,8 @@ def getFilesInfo(req): def download(filePath): response = FileResponse(open(filePath, 'rb'), True) # write headers to the response object response['Content-Length'] = os.path.getsize(filePath) - response['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + urllib.parse.quote_plus(os.path.basename(filePath)) + response['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + \ + urllib.parse.quote_plus(os.path.basename(filePath)) response['Content-Type'] = magic.from_file(filePath, mime=True) response['Access-Control-Allow-Origin'] = "*" return response diff --git a/web/documentserver-example/python/src/utils/historyManager.py b/web/documentserver-example/python/src/utils/historyManager.py index 8381cb070..b39022665 100644 --- a/web/documentserver-example/python/src/utils/historyManager.py +++ b/web/documentserver-example/python/src/utils/historyManager.py @@ -188,16 +188,21 @@ def getHistoryObject(storagePath, filename, docKey, docUrl, isEnableDirectUrl, r 'id': meta['uid'], 'name': meta['uname'] } - - dataObj['url'] = docUrl if i == version else getPublicHistUri(filename, i, "prev" + fileUtils.getFileExt(filename), req) # write file url to the data object + # write file url to the data object + dataObj['url'] = docUrl if i == version else getPublicHistUri( + filename, i, "prev" + fileUtils.getFileExt(filename), req + ) if isEnableDirectUrl: - dataObj['directUrl'] = docManager.getDownloadUrl(filename, req, False) if i == version else getPublicHistUri(filename, i, "prev" + fileUtils.getFileExt(filename), req, False) # write file direct url to the data object + # write file direct url to the data object + dataObj['directUrl'] = docManager.getDownloadUrl(filename, req, False) if i == version \ + else getPublicHistUri(filename, i, "prev" + fileUtils.getFileExt(filename), req, False) if i > 1: # check if the version number is greater than 1 (the file was modified) - changes = json.loads(readFile(getChangesHistoryPath(prevVerDir))) # get the path to the changes.json file + # get the path to the changes.json file + changes = json.loads(readFile(getChangesHistoryPath(prevVerDir))) change = changes['changes'][0] - - obj['changes'] = changes['changes'] if change else None # write information about changes to the object + # write information about changes to the object + obj['changes'] = changes['changes'] if change else None obj['serverVersion'] = changes['serverVersion'] obj['created'] = change['created'] if change else None obj['user'] = change['user'] if change else None @@ -214,7 +219,8 @@ def getHistoryObject(storagePath, filename, docKey, docUrl, isEnableDirectUrl, r 'url': prev['url'] } dataObj['previous'] = prevInfo # write information about previous file version to the data object - dataObj['changesUrl'] = getPublicHistUri(filename, i - 1, "diff.zip", req) # write the path to the diff.zip archive with differences in this file version + # write the path to the diff.zip archive with differences in this file version + dataObj['changesUrl'] = getPublicHistUri(filename, i - 1, "diff.zip", req) if jwtManager.isEnabled(): dataObj['token'] = jwtManager.encode(dataObj) diff --git a/web/documentserver-example/python/src/utils/serviceConverter.py b/web/documentserver-example/python/src/utils/serviceConverter.py index 566ec339e..a533ea170 100755 --- a/web/documentserver-example/python/src/utils/serviceConverter.py +++ b/web/documentserver-example/python/src/utils/serviceConverter.py @@ -49,9 +49,11 @@ def getConvertedData(docUri, fromExt, toExt, docKey, isAsync, filePass=None, lan if (jwtManager.isEnabled() and jwtManager.useForRequest()): # check if a secret key to generate token exists or not headerToken = jwtManager.encode({'payload': payload}) # encode a payload object into a header token payload['token'] = jwtManager.encode(payload) # encode a payload object into a body token - headers[config_manager.jwt_header()] = f'Bearer {headerToken}' # add a header Authorization with a header token with Authorization prefix in it - - response = requests.post(config_manager.document_server_converter_url().geturl(), json=payload, headers=headers, verify=config_manager.ssl_verify_peer_mode_enabled(), timeout=5) # send the headers and body values to the converter and write the result to the response + # add a header Authorization with a header token with Authorization prefix in it + headers[config_manager.jwt_header()] = f'Bearer {headerToken}' + # send the headers and body values to the converter and write the result to the response + response = requests.post(config_manager.document_server_converter_url().geturl(), json=payload, headers=headers, + verify=config_manager.ssl_verify_peer_mode_enabled(), timeout=5) status_code = response.status_code if status_code != 200: # checking status code raise RuntimeError('Convertation service returned status: %s' % status_code) diff --git a/web/documentserver-example/python/src/utils/trackManager.py b/web/documentserver-example/python/src/utils/trackManager.py index 37327ada5..feb4eaaa5 100755 --- a/web/documentserver-example/python/src/utils/trackManager.py +++ b/web/documentserver-example/python/src/utils/trackManager.py @@ -66,9 +66,12 @@ def processSave(raw_body, filename, usAddr): # convert downloaded file to the file with the current extension if these extensions aren't equal if (curExt != downloadExt): try: - convertedData = serviceConverter.getConvertedData(download, downloadExt, curExt, docManager.generateRevisionId(download), False) # convert file and give url to a new file + # convert file and give url to a new file + convertedData = serviceConverter.getConvertedData(download, downloadExt, curExt, + docManager.generateRevisionId(download), False) if not convertedData: - newFilename = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + downloadExt, usAddr) # get the correct file name if it already exists + newFilename = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + downloadExt, + usAddr) # get the correct file name if it already exists else: download = convertedData['uri'] except Exception: @@ -86,25 +89,28 @@ def processSave(raw_body, filename, usAddr): versionDir = historyManager.getNextVersionDir(histDir) # get the path to the next file version - os.rename(docManager.getStoragePath(filename, usAddr), historyManager.getPrevFilePath(versionDir, curExt)) # get the path to the previous file version and rename the storage path with it + # get the path to the previous file version and rename the storage path with it + os.rename(docManager.getStoragePath(filename, usAddr), historyManager.getPrevFilePath(versionDir, curExt)) docManager.saveFile(data, path) # save document file dataChanges = docManager.downloadFileFromUri(changesUri) # download changes file if (dataChanges is None): raise Exception("Downloaded changes is null") - docManager.saveFile(dataChanges, historyManager.getChangesZipPath(versionDir)) # save file changes to the diff.zip archive + # save file changes to the diff.zip archive + docManager.saveFile(dataChanges, historyManager.getChangesZipPath(versionDir)) hist = None hist = body.get('changeshistory') if (not hist) & ('history' in body): hist = json.dumps(body.get('history')) if hist: - historyManager.writeFile(historyManager.getChangesHistoryPath(versionDir), hist) # write the history changes to the changes.json file - - historyManager.writeFile(historyManager.getKeyPath(versionDir), body.get('key')) # write the key value to the key.txt file - - forcesavePath = docManager.getForcesavePath(newFilename, usAddr, False) # get the path to the forcesaved file version + # write the history changes to the changes.json file + historyManager.writeFile(historyManager.getChangesHistoryPath(versionDir), hist) + # write the key value to the key.txt file + historyManager.writeFile(historyManager.getKeyPath(versionDir), body.get('key')) + # get the path to the forcesaved file version + forcesavePath = docManager.getForcesavePath(newFilename, usAddr, False) if (forcesavePath != ""): # if the forcesaved file version exists os.remove(forcesavePath) # remove it @@ -125,7 +131,9 @@ def processForceSave(body, filename, usAddr): # convert downloaded file to the file with the current extension if these extensions aren't equal if (curExt != downloadExt): try: - convertedData = serviceConverter.getConvertedData(download, downloadExt, curExt, docManager.generateRevisionId(download), False) # convert file and give url to a new file + # convert file and give url to a new file + convertedData = serviceConverter.getConvertedData(download, downloadExt, curExt, + docManager.generateRevisionId(download), False) if not convertedData: newFilename = True else: @@ -141,7 +149,8 @@ def processForceSave(body, filename, usAddr): if (isSubmitForm): if (newFilename): - filename = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + "-form" + downloadExt, usAddr) # get the correct file name if it already exists + filename = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + "-form" + downloadExt, + usAddr) # get the correct file name if it already exists else: filename = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + "-form" + curExt, usAddr) forcesavePath = docManager.getStoragePath(filename, usAddr) @@ -174,10 +183,12 @@ def commandRequest(method, key, meta=None): if (jwtManager.isEnabled() and jwtManager.useForRequest()): # check if a secret key to generate token exists or not headerToken = jwtManager.encode({'payload': payload}) # encode a payload object into a header token - headers[config_manager.jwt_header()] = f'Bearer {headerToken}' # add a header Authorization with a header token with Authorization prefix in it + # add a header Authorization with a header token with Authorization prefix in it + headers[config_manager.jwt_header()] = f'Bearer {headerToken}' payload['token'] = jwtManager.encode(payload) # encode a payload object into a body token - response = requests.post(config_manager.document_server_command_url().geturl(), json=payload, headers=headers, verify=config_manager.ssl_verify_peer_mode_enabled()) + response = requests.post(config_manager.document_server_command_url().geturl(), json=payload, headers=headers, + verify=config_manager.ssl_verify_peer_mode_enabled()) if (meta): return response diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index d731c785a..45c12f327 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -20,7 +20,8 @@ class User: - def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates): + def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, + descriptions, templates): self.id = id self.name = name self.email = email @@ -47,7 +48,8 @@ def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfo descr_user_2 = [ "Belongs to Group2", "Can review only his own changes or changes made by users with no group", - "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", + ("Can view comments, edit his own comments and comments left by users with no group." + "Can remove his own comments only"), "This file is marked as favorite", "Can create new files from the editor", "Can see the information about users from Group2 and users who don’t belong to any group" diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 8f0093347..7e30e2900 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -39,17 +39,20 @@ def upload(request): try: fileInfo = request.FILES['uploadedFile'] - if ((fileInfo.size > config_manager.maximum_file_size()) | (fileInfo.size <= 0)): # check if the file size exceeds the maximum size allowed (5242880) + # check if the file size exceeds the maximum size allowed (5242880) + if ((fileInfo.size > config_manager.maximum_file_size()) | (fileInfo.size <= 0)): raise Exception('File size is incorrect') curExt = fileUtils.getFileExt(fileInfo.name) if not docManager.isSupportedExt(curExt): # check if the file extension is supported by the document manager raise Exception('File type is not supported') - name = docManager.getCorrectName(fileInfo.name, request) # get file name with an index if such a file name already exists + # get file name with an index if such a file name already exists + name = docManager.getCorrectName(fileInfo.name, request) path = docManager.getStoragePath(name, request) - docManager.createFile(fileInfo.file, path, request, True) # create file with meta information in the storage directory + # create file with meta information in the storage directory + docManager.createFile(fileInfo.file, path, request, True) response.setdefault('filename', name) response.setdefault('documentType', fileUtils.getFileType(name)) @@ -76,19 +79,25 @@ def convert(request): if docManager.isCanConvert(fileExt): # check if the file extension is available for converting key = docManager.generateFileKey(filename, request) # generate the file key - convertedData = serviceConverter.getConvertedData(fileUri, fileExt, newExt, key, True, filePass, lang) # get the url of the converted file + # get the url of the converted file + convertedData = serviceConverter.getConvertedData(fileUri, fileExt, newExt, key, True, filePass, lang) - if not convertedData: # if the converter url is not received, the original file name is passed to the response + # if the converter url is not received, the original file name is passed to the response + if not convertedData: response.setdefault('step', '0') response.setdefault('filename', filename) else: - correctName = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + '.' + convertedData['fileType'], request) # otherwise, create a new name with the necessary extension + correctName = docManager.getCorrectName( + fileUtils.getFileNameWithoutExt(filename) + '.' + convertedData['fileType'], request + ) # otherwise, create a new name with the necessary extension path = docManager.getStoragePath(correctName, request) - docManager.downloadFileFromUri(convertedData['uri'], path, True) # save the file from the new url in the storage directory + # save the file from the new url in the storage directory + docManager.downloadFileFromUri(convertedData['uri'], path, True) docManager.removeFile(filename, request) # remove the original file response.setdefault('filename', correctName) # pass the name of the converted file to the response else: - response.setdefault('filename', filename) # if the file can't be converted, the original file name is passed to the response + # if the file can't be converted, the original file name is passed to the response + response.setdefault('filename', filename) except Exception as e: response.setdefault('error', e.args[0]) @@ -127,7 +136,8 @@ def saveAs(request): path = docManager.getStoragePath(filename, request) resp = requests.get(saveAsFileUrl, verify=config_manager.ssl_verify_peer_mode_enabled()) - if ((len(resp.content) > config_manager.maximum_file_size()) | (len(resp.content) <= 0)): # check if the file size exceeds the maximum size allowed (5242880) + # check if the file size exceeds the maximum size allowed (5242880) + if ((len(resp.content) > config_manager.maximum_file_size()) | (len(resp.content) <= 0)): response.setdefault('error', 'File size is incorrect') raise Exception('File size is incorrect') @@ -136,7 +146,8 @@ def saveAs(request): response.setdefault('error', 'File type is not supported') raise Exception('File type is not supported') - docManager.downloadFileFromUri(saveAsFileUrl, path, True) # save the file from the new url in the storage directory + # save the file from the new url in the storage directory + docManager.downloadFileFromUri(saveAsFileUrl, path, True) response.setdefault('file', filename) except Exception as e: @@ -181,18 +192,22 @@ def edit(request): fileType = fileUtils.getFileType(filename) user = users.getUserFromReq(request) # get user - edMode = request.GET.get('mode') if request.GET.get('mode') else 'edit' # get the editor mode: view/edit/review/comment/fillForms/embedded (the default mode is edit) + # get the editor mode: view/edit/review/comment/fillForms/embedded (the default mode is edit) + edMode = request.GET.get('mode') if request.GET.get('mode') else 'edit' canEdit = docManager.isCanEdit(ext) # check if the file with this extension can be edited if (((not canEdit) and edMode == 'edit') or edMode == 'fillForms') and docManager.isCanFillForms(ext): edMode = 'fillForms' canEdit = True - submitForm = edMode == 'fillForms' and user.id == 'uid-1' and False # if the Submit form button is displayed or hidden + # if the Submit form button is displayed or hidden + submitForm = edMode == 'fillForms' and user.id == 'uid-1' and False mode = 'edit' if canEdit & (edMode != 'view') else 'view' # if the file can't be edited, the mode is view types = ['desktop', 'mobile', 'embedded'] - edType = request.GET.get('type') if request.GET.get('type') in types else 'desktop' # get the editor type: embedded/mobile/desktop (the default type is desktop) - lang = request.COOKIES.get('ulang') if request.COOKIES.get('ulang') else 'en' # get the editor language (the default language is English) + # get the editor type: embedded/mobile/desktop (the default type is desktop) + edType = request.GET.get('type') if request.GET.get('type') in types else 'desktop' + # get the editor language (the default language is English) + lang = request.COOKIES.get('ulang') if request.COOKIES.get('ulang') else 'en' storagePath = docManager.getStoragePath(filename, request) meta = historyManager.getMeta(storagePath) # get the document meta data @@ -201,7 +216,8 @@ def edit(request): actionData = request.GET.get('actionLink') # get the action data that will be scrolled to (comment or bookmark) actionLink = json.loads(actionData) if actionData else None - templatesImageUrl = docManager.getTemplateImageUrl(fileType, request) # templates image url in the "From Template" section + # templates image url in the "From Template" section + templatesImageUrl = docManager.getTemplateImageUrl(fileType, request) createUrl = docManager.getCreateUrl(edType, request) templates = [ { @@ -239,12 +255,15 @@ def edit(request): 'key': docKey, 'info': infObj, 'permissions': { # the permission for the document to be edited and downloaded or not - 'comment': (edMode != 'view') & (edMode != 'fillForms') & (edMode != 'embedded') & (edMode != "blockcontent"), + 'comment': (edMode != 'view') & (edMode != 'fillForms') & (edMode != 'embedded') \ + & (edMode != "blockcontent"), 'copy': 'copy' not in user.deniedPermissions, 'download': 'download' not in user.deniedPermissions, - 'edit': canEdit & ((edMode == 'edit') | (edMode == 'view') | (edMode == 'filter') | (edMode == "blockcontent")), + 'edit': canEdit & ((edMode == 'edit') | (edMode == 'view') | (edMode == 'filter') \ + | (edMode == "blockcontent")), 'print': 'print' not in user.deniedPermissions, - 'fillForms': (edMode != 'view') & (edMode != 'comment') & (edMode != 'embedded') & (edMode != "blockcontent"), + 'fillForms': (edMode != 'view') & (edMode != 'comment') & (edMode != 'embedded') \ + & (edMode != "blockcontent"), 'modifyFilter': edMode != 'filter', 'modifyContentControl': edMode != "blockcontent", 'review': canEdit & ((edMode == 'edit') | (edMode == 'review')), @@ -256,7 +275,8 @@ def edit(request): }, 'referenceData': { 'instanceId': docManager.getServerUrl(False, request), - 'fileKey': json.dumps({'fileName': filename, 'userAddress': request.META['REMOTE_ADDR']}) if user.id != 'uid-0' else None + 'fileKey': json.dumps({'fileName': filename, + 'userAddress': request.META['REMOTE_ADDR']}) if user.id != 'uid-0' else None } }, 'editorConfig': { @@ -277,8 +297,10 @@ def edit(request): 'group': user.group }, 'embedded': { # the parameters for the embedded document type - 'saveUrl': directUrl, # the absolute URL that will allow the document to be saved onto the user personal computer - 'embedUrl': directUrl, # the absolute URL to the document serving as a source file for the document embedded into the web page + # the absolute URL that will allow the document to be saved onto the user personal computer + 'saveUrl': directUrl, + # the absolute URL to the document serving as a source file for the document embedded into the web page + 'embedUrl': directUrl, 'shareUrl': directUrl, # the absolute URL that will allow other users to share this document 'toolbarDocked': 'top' # the place for the embedded viewer toolbar (top or bottom) }, @@ -289,7 +311,9 @@ def edit(request): 'forcesave': False, # adds the request for the forced file saving to the callback handler 'submitForm': submitForm, # if the Submit form button is displayed or not 'goback': { # settings for the Open file location menu button and upper right corner button - 'url': docManager.getServerUrl(False, request) # the absolute URL to the website address which will be opened when clicking the Open file location menu button + # the absolute URL to the website address + # which will be opened when clicking the Open file location menu button + 'url': docManager.getServerUrl(False, request) } } } @@ -334,15 +358,19 @@ def edit(request): dataDocument['token'] = jwtManager.encode(dataDocument) # encode the dataDocument object into a token dataSpreadsheet['token'] = jwtManager.encode(dataSpreadsheet) # encode the dataSpreadsheet object into a token - hist = historyManager.getHistoryObject(storagePath, filename, docKey, fileUri, isEnableDirectUrl, request) # get the document history + # get the document history + hist = historyManager.getHistoryObject(storagePath, filename, docKey, fileUri, isEnableDirectUrl, request) context = { # the data that will be passed to the template 'cfg': json.dumps(edConfig), # the document config in json format - 'history': json.dumps(hist['history']) if 'history' in hist else None, # the information about the current version - 'historyData': json.dumps(hist['historyData']) if 'historyData' in hist else None, # the information about the previous document versions if they exist + # the information about the current version + 'history': json.dumps(hist['history']) if 'history' in hist else None, + # the information about the previous document versions if they exist + 'historyData': json.dumps(hist['historyData']) if 'historyData' in hist else None, 'fileType': fileType, # the file type of the document (text, spreadsheet or presentation) 'apiUrl': config_manager.document_server_api_url().geturl(), # the absolute URL to the api - 'dataInsertImage': json.dumps(dataInsertImage)[1: len(json.dumps(dataInsertImage)) - 1], # the image which will be inserted into the document + # the image which will be inserted into the document + 'dataInsertImage': json.dumps(dataInsertImage)[1: len(json.dumps(dataInsertImage)) - 1], 'dataDocument': dataDocument, # document which will be compared with the current document 'dataSpreadsheet': json.dumps(dataSpreadsheet), # recipient data for mail merging 'usersForMentions': json.dumps(usersForMentions) if user.id != 'uid-0' else None @@ -362,7 +390,8 @@ def track(request): if (body['actions'] and body['actions'][0]['type'] == 0): # finished edit user = body['actions'][0]['userid'] # the user who finished editing if (user not in body['users']): - trackManager.commandRequest('forcesave', body['key']) # create a command request with the forcasave method + # create a command request with the forcasave method + trackManager.commandRequest('forcesave', body['key']) filename = fileUtils.getFileName(request.GET['filename']) usAddr = request.GET['userAddress'] @@ -373,12 +402,14 @@ def track(request): trackManager.processForceSave(body, filename, usAddr) except Exception as e: - response.setdefault("error", 1) # set the default error value as 1 (document key is missing or no document with such key could be found) + # set the default error value as 1 (document key is missing or no document with such key could be found) + response.setdefault("error", 1) response.setdefault("message", str(e.args[0])) response.setdefault('error', 0) # if no exceptions are raised, the default error value is 0 (no errors) # the response status is 200 if the changes are saved successfully; otherwise, it is equal to 500 - return HttpResponse(json.dumps(response), content_type='application/json', status=200 if response['error'] == 0 else 500) + return HttpResponse(json.dumps(response), content_type='application/json', + status=200 if response['error'] == 0 else 500) # remove a file @@ -430,7 +461,8 @@ def download(request): if (userAddress is None): userAddress = request - filePath = docManager.getForcesavePath(fileName, userAddress, False) # get the path to the forcesaved file version + # get the path to the forcesaved file version + filePath = docManager.getForcesavePath(fileName, userAddress, False) if (filePath == ""): filePath = docManager.getStoragePath(fileName, userAddress) # get file from the storage directory response = docManager.download(filePath) # download this file diff --git a/web/documentserver-example/python/src/views/index.py b/web/documentserver-example/python/src/views/index.py index 4f6b508f5..3ef9cf3e4 100755 --- a/web/documentserver-example/python/src/views/index.py +++ b/web/documentserver-example/python/src/views/index.py @@ -47,4 +47,5 @@ def default(request): # default parameters that will be passed to the template 'fillExt': json.dumps(format_manager.fillable_extensions()), 'directUrl': str(getDirectUrlParam(request)).lower } - return render(request, 'index.html', context) # execute the "index.html" template with context data and return http response in json format + # execute the "index.html" template with context data and return http response in json format + return render(request, 'index.html', context) From feaa30bf2dbf38554e613fdc193e6bacd6e4554e Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 24 Oct 2023 12:36:22 +0700 Subject: [PATCH 145/488] pylint: C0325: Unnecessary parens --- .../python/src/utils/docManager.py | 4 +-- .../python/src/utils/serviceConverter.py | 2 +- .../python/src/utils/trackManager.py | 36 +++++++++---------- .../python/src/utils/users.py | 2 +- .../python/src/views/actions.py | 18 +++++----- .../python/src/views/index.py | 2 +- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 3bc74a582..8a122a2cb 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -187,7 +187,7 @@ def getForcesavePath(filename, req, create): return "" directory = os.path.join(directory, f'{filename}-hist') # get the path to the history of the given file - if (not os.path.exists(directory)): + if not os.path.exists(directory): if create: # if the history directory doesn't exist os.makedirs(directory) # create history directory if it doesn't exist else: # the history directory doesn't exist and we are not supposed to create it @@ -300,7 +300,7 @@ def generateFileKey(filename, req): # generate the document key value def generateRevisionId(expectedKey): - if (len(expectedKey) > 20): + if len(expectedKey) > 20: expectedKey = str(hash(expectedKey)) key = re.sub(r'[^0-9-.a-zA-Z_=]', '_', expectedKey) diff --git a/web/documentserver-example/python/src/utils/serviceConverter.py b/web/documentserver-example/python/src/utils/serviceConverter.py index a533ea170..4213abc34 100755 --- a/web/documentserver-example/python/src/utils/serviceConverter.py +++ b/web/documentserver-example/python/src/utils/serviceConverter.py @@ -43,7 +43,7 @@ def getConvertedData(docUri, fromExt, toExt, docKey, isAsync, filePass=None, lan headers = {'accept': 'application/json'} - if (isAsync): # check if the operation is asynchronous + if isAsync: # check if the operation is asynchronous payload.setdefault('async', True) # and write this information to the payload object if (jwtManager.isEnabled() and jwtManager.useForRequest()): # check if a secret key to generate token exists or not diff --git a/web/documentserver-example/python/src/utils/trackManager.py b/web/documentserver-example/python/src/utils/trackManager.py index feb4eaaa5..81e68a10a 100755 --- a/web/documentserver-example/python/src/utils/trackManager.py +++ b/web/documentserver-example/python/src/utils/trackManager.py @@ -35,16 +35,16 @@ def readBody(request): if (jwtManager.isEnabled() and jwtManager.useForRequest()): # if the secret key to generate token exists token = body.get('token') # get the document token - if (not token): # if JSON web token is not received + if not token: # if JSON web token is not received token = request.headers.get(config_manager.jwt_header()) # get it from the Authorization header if token: token = token[len('Bearer '):] # and save it without Authorization prefix - if (not token): # if the token is not received + if not token: # if the token is not received raise Exception('Expected JWT') # an error occurs body = jwtManager.decode(token) - if (body.get('payload')): # get the payload object from the request body + if body.get('payload'): # get the payload object from the request body body = body['payload'] return body @@ -54,7 +54,7 @@ def processSave(raw_body, filename, usAddr): body = resolve_process_save_body(raw_body) download = body.get('url') - if (download is None): + if download is None: raise Exception("DownloadUrl is null") changesUri = body.get('changesurl') newFilename = filename @@ -64,7 +64,7 @@ def processSave(raw_body, filename, usAddr): downloadExt = "." + body.get('filetype') # get the extension of the downloaded file # convert downloaded file to the file with the current extension if these extensions aren't equal - if (curExt != downloadExt): + if curExt != downloadExt: try: # convert file and give url to a new file convertedData = serviceConverter.getConvertedData(download, downloadExt, curExt, @@ -80,7 +80,7 @@ def processSave(raw_body, filename, usAddr): path = docManager.getStoragePath(newFilename, usAddr) # get the file path data = docManager.downloadFileFromUri(download) # download document file - if (data is None): + if data is None: raise Exception("Downloaded document is null") histDir = historyManager.getHistoryDir(path) # get the path to the history direction @@ -95,7 +95,7 @@ def processSave(raw_body, filename, usAddr): docManager.saveFile(data, path) # save document file dataChanges = docManager.downloadFileFromUri(changesUri) # download changes file - if (dataChanges is None): + if dataChanges is None: raise Exception("Downloaded changes is null") # save file changes to the diff.zip archive docManager.saveFile(dataChanges, historyManager.getChangesZipPath(versionDir)) @@ -111,7 +111,7 @@ def processSave(raw_body, filename, usAddr): historyManager.writeFile(historyManager.getKeyPath(versionDir), body.get('key')) # get the path to the forcesaved file version forcesavePath = docManager.getForcesavePath(newFilename, usAddr, False) - if (forcesavePath != ""): # if the forcesaved file version exists + if forcesavePath != "": # if the forcesaved file version exists os.remove(forcesavePath) # remove it return @@ -120,7 +120,7 @@ def processSave(raw_body, filename, usAddr): # file force saving process def processForceSave(body, filename, usAddr): download = body.get('url') - if (download is None): + if download is None: raise Exception("DownloadUrl is null") curExt = fileUtils.getFileExt(filename) # get current file extension @@ -129,7 +129,7 @@ def processForceSave(body, filename, usAddr): newFilename = False # convert downloaded file to the file with the current extension if these extensions aren't equal - if (curExt != downloadExt): + if curExt != downloadExt: try: # convert file and give url to a new file convertedData = serviceConverter.getConvertedData(download, downloadExt, curExt, @@ -142,28 +142,28 @@ def processForceSave(body, filename, usAddr): newFilename = True data = docManager.downloadFileFromUri(download) # download document file - if (data is None): + if data is None: raise Exception("Downloaded document is null") isSubmitForm = body.get('forcesavetype') == 3 # SubmitForm - if (isSubmitForm): - if (newFilename): + if isSubmitForm: + if newFilename: filename = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + "-form" + downloadExt, usAddr) # get the correct file name if it already exists else: filename = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + "-form" + curExt, usAddr) forcesavePath = docManager.getStoragePath(filename, usAddr) else: - if (newFilename): + if newFilename: filename = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + downloadExt, usAddr) forcesavePath = docManager.getForcesavePath(filename, usAddr, False) - if (forcesavePath == ""): + if forcesavePath == "": forcesavePath = docManager.getForcesavePath(filename, usAddr, True) docManager.saveFile(download, forcesavePath) # save document file - if (isSubmitForm): + if isSubmitForm: uid = body['actions'][0]['userid'] # get the user id historyManager.createMetaData(filename, uid, "Filling Form", usAddr) # create meta data for forcesaved file return @@ -176,7 +176,7 @@ def commandRequest(method, key, meta=None): 'key': key } - if (meta): + if meta: payload['meta'] = meta headers = {'accept': 'application/json'} @@ -190,7 +190,7 @@ def commandRequest(method, key, meta=None): response = requests.post(config_manager.document_server_command_url().geturl(), json=payload, headers=headers, verify=config_manager.ssl_verify_peer_mode_enabled()) - if (meta): + if meta: return response return diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index 45c12f327..53b53b651 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -119,7 +119,7 @@ def getUserFromReq(req): uid = req.COOKIES.get('uid') for user in USERS: - if (user.id == uid): + if user.id == uid: return user return DEFAULT_USER diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 7e30e2900..d14415606 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -40,7 +40,7 @@ def upload(request): try: fileInfo = request.FILES['uploadedFile'] # check if the file size exceeds the maximum size allowed (5242880) - if ((fileInfo.size > config_manager.maximum_file_size()) | (fileInfo.size <= 0)): + if (fileInfo.size > config_manager.maximum_file_size()) | (fileInfo.size <= 0): raise Exception('File size is incorrect') curExt = fileUtils.getFileExt(fileInfo.name) @@ -137,7 +137,7 @@ def saveAs(request): resp = requests.get(saveAsFileUrl, verify=config_manager.ssl_verify_peer_mode_enabled()) # check if the file size exceeds the maximum size allowed (5242880) - if ((len(resp.content) > config_manager.maximum_file_size()) | (len(resp.content) <= 0)): + if (len(resp.content) > config_manager.maximum_file_size()) | (len(resp.content) <= 0): response.setdefault('error', 'File size is incorrect') raise Exception('File size is incorrect') @@ -166,7 +166,7 @@ def rename(request): origExt = '.' + body['ext'] curExt = fileUtils.getFileExt(newfilename) - if (origExt != curExt): + if origExt != curExt: newfilename += origExt dockey = body['dockey'] @@ -232,7 +232,7 @@ def edit(request): } ] - if (meta): # if the document meta data exists, + if meta: # if the document meta data exists, infObj = { # write author and creation time parameters to the information object 'owner': meta['uname'], 'uploaded': meta['created'] @@ -386,10 +386,10 @@ def track(request): body = trackManager.readBody(request) # read request body status = body['status'] # and get status from it - if (status == 1): # editing + if status == 1: # editing if (body['actions'] and body['actions'][0]['type'] == 0): # finished edit user = body['actions'][0]['userid'] # the user who finished editing - if (user not in body['users']): + if user not in body['users']: # create a command request with the forcasave method trackManager.commandRequest('forcesave', body['key']) @@ -458,12 +458,12 @@ def download(request): except Exception: return HttpResponse('JWT validation failed', status=403) - if (userAddress is None): + if userAddress is None: userAddress = request # get the path to the forcesaved file version filePath = docManager.getForcesavePath(fileName, userAddress, False) - if (filePath == ""): + if filePath == "": filePath = docManager.getStoragePath(fileName, userAddress) # get file from the storage directory response = docManager.download(filePath) # download this file return response @@ -549,7 +549,7 @@ def reference(request): 'path': fileName } - if (jwtManager.isEnabled()): + if jwtManager.isEnabled(): data['token'] = jwtManager.encode(data) return HttpResponse(json.dumps(data), content_type='application/json') diff --git a/web/documentserver-example/python/src/views/index.py b/web/documentserver-example/python/src/views/index.py index 3ef9cf3e4..bcac665bb 100755 --- a/web/documentserver-example/python/src/views/index.py +++ b/web/documentserver-example/python/src/views/index.py @@ -30,7 +30,7 @@ def getDirectUrlParam(request): - if ('directUrl' in request.GET): + if 'directUrl' in request.GET: return request.GET['directUrl'].lower() in ("true") else: return False From 8fd0cfcd47674ac258f5f7cf068d5a1f36a9a28e Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Tue, 24 Oct 2023 09:38:00 +0400 Subject: [PATCH 146/488] ruby: use bundler configuration instead of flags --- web/documentserver-example/ruby/.gitignore | 1 + web/documentserver-example/ruby/Makefile | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/.gitignore b/web/documentserver-example/ruby/.gitignore index d3b3b04c5..96a27689f 100644 --- a/web/documentserver-example/ruby/.gitignore +++ b/web/documentserver-example/ruby/.gitignore @@ -1,3 +1,4 @@ +.bundle bin db log diff --git a/web/documentserver-example/ruby/Makefile b/web/documentserver-example/ruby/Makefile index 13bc94d69..78bb6f85f 100644 --- a/web/documentserver-example/ruby/Makefile +++ b/web/documentserver-example/ruby/Makefile @@ -22,6 +22,8 @@ help: # Show help message for each of the Makefile recipes. awk 'BEGIN {FS = ": # "}; {printf "%s: %s\n", $$1, $$2}' .PHONY: dev +dev: \ + export BUNDLE_WITH := development:doc:test dev: # Install development dependencies and initialize the project. @bundle install @bundle exec rake app:update:bin @@ -30,8 +32,10 @@ ifeq ($(SORBET_SUPPORTED),1) endif .PHONY: prod +prod: \ + export BUNDLE_WITHOUT := development:doc:test prod: # Install production dependencies. - @bundle install --without development doc test + @bundle install @bundle exec rake app:update:bin .PHONY: server-dev From b49341f64e1571feb6acc2ca6527ee90ee9697f0 Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Tue, 24 Oct 2023 09:49:09 +0400 Subject: [PATCH 147/488] ruby: pin bundler version --- web/documentserver-example/ruby/.bundler-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 web/documentserver-example/ruby/.bundler-version diff --git a/web/documentserver-example/ruby/.bundler-version b/web/documentserver-example/ruby/.bundler-version new file mode 100644 index 000000000..b0f6bf0cd --- /dev/null +++ b/web/documentserver-example/ruby/.bundler-version @@ -0,0 +1 @@ +2.4.10 From de4414fbb16fa96f1776c9a22d918dc8dd0f718b Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 24 Oct 2023 13:19:32 +0700 Subject: [PATCH 148/488] pylint: R1711 useless-return --- web/documentserver-example/python/src/utils/docManager.py | 2 -- .../python/src/utils/historyManager.py | 5 ----- web/documentserver-example/python/src/utils/trackManager.py | 3 --- 3 files changed, 10 deletions(-) diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 8a122a2cb..1e912bd03 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -235,7 +235,6 @@ def createFile(stream, path, req=None, meta=False): read = stream.read(bufSize) if meta: historyManager.createMeta(path, req) # create meta data for the file if needed - return # save file @@ -243,7 +242,6 @@ def saveFile(response, path): with open(path, 'wb') as file: for chunk in response.iter_content(chunk_size=8192): file.write(chunk) - return # download file from the given url diff --git a/web/documentserver-example/python/src/utils/historyManager.py b/web/documentserver-example/python/src/utils/historyManager.py index b39022665..2cd54e072 100644 --- a/web/documentserver-example/python/src/utils/historyManager.py +++ b/web/documentserver-example/python/src/utils/historyManager.py @@ -103,8 +103,6 @@ def createMeta(storagePath, req): writeFile(path, json.dumps(obj)) - return - # create a json file with file meta data using the file name, user id, user name and user address def createMetaData(filename, uid, uname, usAddr): @@ -122,14 +120,11 @@ def createMetaData(filename, uid, uname, usAddr): writeFile(path, json.dumps(obj)) - return - # create file with a given content in it def writeFile(path, content): with io.open(path, 'w') as out: out.write(content) - return # read a file diff --git a/web/documentserver-example/python/src/utils/trackManager.py b/web/documentserver-example/python/src/utils/trackManager.py index 81e68a10a..0c398c803 100755 --- a/web/documentserver-example/python/src/utils/trackManager.py +++ b/web/documentserver-example/python/src/utils/trackManager.py @@ -114,8 +114,6 @@ def processSave(raw_body, filename, usAddr): if forcesavePath != "": # if the forcesaved file version exists os.remove(forcesavePath) # remove it - return - # file force saving process def processForceSave(body, filename, usAddr): @@ -166,7 +164,6 @@ def processForceSave(body, filename, usAddr): if isSubmitForm: uid = body['actions'][0]['userid'] # get the user id historyManager.createMetaData(filename, uid, "Filling Form", usAddr) # create meta data for forcesaved file - return # create a command request From 14025def1091f2d3da42b7bb1f3e1e2464125882 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 24 Oct 2023 13:51:44 +0700 Subject: [PATCH 149/488] pylint: W0622 redefined-builtin --- .../python/src/utils/fileUtils.py | 18 +++++++++--------- .../python/src/utils/users.py | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/web/documentserver-example/python/src/utils/fileUtils.py b/web/documentserver-example/python/src/utils/fileUtils.py index ef33890e5..0777c9500 100644 --- a/web/documentserver-example/python/src/utils/fileUtils.py +++ b/web/documentserver-example/python/src/utils/fileUtils.py @@ -24,28 +24,28 @@ # get file name from the document url -def getFileName(str): - ind = str.rfind('/') - return str[ind+1:] +def getFileName(uri): + ind = uri.rfind('/') + return uri[ind+1:] # get file name without extension from the document url -def getFileNameWithoutExt(str): - fn = getFileName(str) +def getFileNameWithoutExt(uri): + fn = getFileName(uri) ind = fn.rfind('.') return fn[:ind] # get file extension from the document url -def getFileExt(str): - fn = getFileName(str) +def getFileExt(uri): + fn = getFileName(uri) ind = fn.rfind('.') return fn[ind:].lower() # get file type -def getFileType(str): - ext = getFileExt(str) +def getFileType(uri): + ext = getFileExt(uri) if ext in format_manager.document_extensions(): return 'word' if ext in format_manager.spreadsheet_extensions(): diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index 53b53b651..0256f63e7 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -20,9 +20,9 @@ class User: - def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, - descriptions, templates): - self.id = id + def __init__(self, uid, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, + deniedPermissions, descriptions, templates): + self.id = uid self.name = name self.email = email self.group = group @@ -134,11 +134,11 @@ def getUsersForMentions(uid): return usersData -def find_user(id: Optional[str]) -> User: - if id is None: +def find_user(searchId: Optional[str]) -> User: + if searchId is None: return DEFAULT_USER for user in USERS: - if not user.id == id: + if not user.id == searchId: continue return user return DEFAULT_USER From b5251b0e92bc34fdf6d30714ed9ce276d5c5a279 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Mon, 23 Oct 2023 18:02:51 +0300 Subject: [PATCH 150/488] nodejs: fix mobile size for chrome on iOS (f096fd4d93e59c3497ebce774362c6f51f9639a1) --- web/documentserver-example/nodejs/views/editor.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index 7fccec98b..170208d9e 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -347,7 +347,7 @@ }; config.events = { "onAppReady": onAppReady, - "onDocumentReady": fixSize, + "onDocumentReady": onDocumentReady, "onDocumentStateChange": onDocumentStateChange, "onError": onError, "onOutdatedVersion": onOutdatedVersion, From 365898822553d864bbeb356fbd3eb744affa92c8 Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Tue, 24 Oct 2023 11:25:47 +0400 Subject: [PATCH 151/488] ruby: update readme --- web/documentserver-example/ruby/README.md | 121 +++++++++++----------- 1 file changed, 63 insertions(+), 58 deletions(-) diff --git a/web/documentserver-example/ruby/README.md b/web/documentserver-example/ruby/README.md index 8d03c31e5..44fc78a51 100755 --- a/web/documentserver-example/ruby/README.md +++ b/web/documentserver-example/ruby/README.md @@ -2,89 +2,94 @@ This example will help you integrate ONLYOFFICE Docs into your web application written on Ruby. -**Please note**: It is intended for testing purposes and demonstrating functionality of the editors. Do NOT use this integration example on your own server without proper code modifications! In case you enabled the test example, disable it before going for production. +> [!WARNING] +> It is intended for testing purposes and demonstrating functionality of the editors. **DO NOT** use this integration example on your own server without proper code modifications. In case you enabled the test example, disable it before going for production. -## Step 1. Install ONLYOFFICE Docs +## Installation -Download and install ONLYOFFICE Docs (packaged as Document Server). +The Ruby example offers various installation options, but we highly recommend using Docker for this purpose. -See the detailed guide to learn how to install Document Server [for Windows](https://helpcenter.onlyoffice.com/installation/docs-developer-install-windows.aspx), [for Linux](https://helpcenter.onlyoffice.com/installation/docs-developer-install-ubuntu.aspx), or [for Docker](https://helpcenter.onlyoffice.com/server/developer-edition/docker/docker-installation.aspx). +### Using Docker -## Step 2. Install the prerequisites and run the website with the editors +To run the example using [Docker](https://docker.com), you will need [Docker Desktop 4.17.0](https://docs.docker.com/desktop) or [Docker Engine 20.10.23](https://docs.docker.com/engine) with [Docker Compose 2.15.1](https://docs.docker.com/compose). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools. -1. Install **Ruby Version Manager (RVM)** and the latest stable **Ruby** version: +Once you have everything installed, download the release archive and unarchive it. - ``` - gpg --keyserver "hkp://keys.gnupg.net" --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 - ``` +```sh +$ curl --output Ruby.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/download/v1.6.0/Ruby.Example.zip +$ unzip Ruby.Example.zip +``` - ``` - \curl -sSL https://get.rvm.io | bash -s stable --ruby - ``` +Then open the example directory and [up containers](./Makefile#L46). -2. Download the archive with the Ruby example and unpack the archive: +```sh +$ cd "Ruby Example" +$ make compose-prod +``` - ``` - wget "https://api.onlyoffice.com/app_data/editor/Ruby.Example.zip" - ``` +By default, the server starts at `localhost:80`. - ``` - unzip Ruby.Example.zip - ``` +To configure the example, you can edit the environment variables in [`compose-base.yml`](./compose-base.yml). See [below](#configuration) for more information about environment variables. -3. Change the current directory for the project directory: +### On Local Machine - ``` - cd Ruby\ Example - ``` +Before diving into the example, you will need to install ONLYOFFICE Document Server (also known as Docs). See to the [detailed guide to learn how to install it](https://helpcenter.onlyoffice.com/server/developer-edition/docker/docker-installation.aspx) on Windows, Linux, or Docker. -4. Install the dependencies: +To run the example on your local machine, you will need [Ruby 3.2.2](https://ruby-lang.org) with [Bundler 2.4.10](https://bundler.io). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools. - ``` - bundle install - ``` +Once you have everything installed, download the release archive and unarchive it. -5. Edit the *config/application.rb* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. +```sh +$ curl --output Ruby.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/download/v1.6.0/Ruby.Example.zip +$ unzip Ruby.Example.zip +``` - ``` - nano config/application.rb - ``` +Then open the example directory, [install dependencies](./Makefile#L33), and [start the server](./Makefile#L42). - Edit the following lines: +```sh +$ cd "Ruby Example" +$ make prod +$ make server-prod +``` - ``` - Rails.configuration.storagePath="app_data" - Rails.configuration.urlSite="https://documentserver/" - ``` +By default, the server starts at `0.0.0.0:3000`. - where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storagePath** is the path where files will be created and stored. You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator. +To configure the example, you can pass the environment variables before the command that starts the server. See [below](#configuration) for more information about environment variables. -6. Run the **Rails** application: - - ``` - rails server -u webrick - rails s -b 0.0.0.0 -p 80 - ``` - -7. See the result in your browser using the address: - - ``` - http://localhost - ``` - - If you want to experiment with the editor configuration, modify the [parameters](https://api.onlyoffice.com/editors/advanced) in the *views\home\editor.html.erb* file. - -## Step 3. Check accessibility +## Post Installation In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files. Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files. -## Important security info +## Configuration + +The example is configured by changing environment variables. + +- `BINDING` \ +The address where the server should be started. \ +For example: `0.0.0.0` +- `DOCUMENT_SERVER_PRIVATE_URL` \ +The URL through which the server will communicate with Document Server. \ +For example: http://proxy:8080 +- `DOCUMENT_SERVER_PUBLIC_URL` \ +The URL through which a user will communicate with Document Server. \ +For example: http://localhost:8080 +- `EXAMPLE_URL` \ +The URL through which Document Server will communicate with the server. \ +For example: http://proxy +- `JWT_SECRET` \ +JWT authorization secret. Leave blank to disable authorization. \ +For example: `your-256-bit-secret` +- `PORT` \ +The port on which the server should be running. \ +For example: `80` + +## Security Info Please keep in mind the following security aspects when you are using test examples: -* There is no protection of the storage from unauthorized access since there is no need for authorization. -* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts. -* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server. -* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain. \ No newline at end of file +- There is no protection of the storage from unauthorized access since there is no need for authorization. +- There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts. +- There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server. +- There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain. From 9c26b4e563753c5d7e77cfb76723af6b115f63a7 Mon Sep 17 00:00:00 2001 From: Kseniya Fedoruk <39296259+kseniafedoruk@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:02:38 +0300 Subject: [PATCH 152/488] Update README.md --- web/documentserver-example/ruby/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/README.md b/web/documentserver-example/ruby/README.md index 44fc78a51..da1b82664 100755 --- a/web/documentserver-example/ruby/README.md +++ b/web/documentserver-example/ruby/README.md @@ -33,7 +33,7 @@ To configure the example, you can edit the environment variables in [`compose-ba ### On Local Machine -Before diving into the example, you will need to install ONLYOFFICE Document Server (also known as Docs). See to the [detailed guide to learn how to install it](https://helpcenter.onlyoffice.com/server/developer-edition/docker/docker-installation.aspx) on Windows, Linux, or Docker. +Before diving into the example, you will need to install ONLYOFFICE Document Server (also known as Docs). Check the [detailed guide to learn how to install it](https://helpcenter.onlyoffice.com/server/developer-edition/docker/docker-installation.aspx) on Windows, Linux, or Docker. To run the example on your local machine, you will need [Ruby 3.2.2](https://ruby-lang.org) with [Bundler 2.4.10](https://bundler.io). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools. From ac24eb73f7f861dba80156cf7bd05afabf0b7cfa Mon Sep 17 00:00:00 2001 From: Natalia Date: Tue, 24 Oct 2023 14:56:00 +0300 Subject: [PATCH 153/488] small fixes --- web/documentserver-example/ruby/README.md | 28 ++++++++--------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/web/documentserver-example/ruby/README.md b/web/documentserver-example/ruby/README.md index da1b82664..84ad20d9d 100755 --- a/web/documentserver-example/ruby/README.md +++ b/web/documentserver-example/ruby/README.md @@ -33,7 +33,7 @@ To configure the example, you can edit the environment variables in [`compose-ba ### On Local Machine -Before diving into the example, you will need to install ONLYOFFICE Document Server (also known as Docs). Check the [detailed guide to learn how to install it](https://helpcenter.onlyoffice.com/server/developer-edition/docker/docker-installation.aspx) on Windows, Linux, or Docker. +Before diving into the example, you will need to install ONLYOFFICE Document Server (also known as Docs). Check the detailed guide to learn how to install it on [Windows](https://helpcenter.onlyoffice.com/installation/docs-developer-install-windows.aspx), [Linux](https://helpcenter.onlyoffice.com/installation/docs-developer-install-ubuntu.aspx), or [Docker](https://helpcenter.onlyoffice.com/installation/docs-developer-install-docker.aspx). To run the example on your local machine, you will need [Ruby 3.2.2](https://ruby-lang.org) with [Bundler 2.4.10](https://bundler.io). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools. @@ -66,24 +66,14 @@ Make sure that the Document Server has access to the server with the example ins The example is configured by changing environment variables. -- `BINDING` \ -The address where the server should be started. \ -For example: `0.0.0.0` -- `DOCUMENT_SERVER_PRIVATE_URL` \ -The URL through which the server will communicate with Document Server. \ -For example: http://proxy:8080 -- `DOCUMENT_SERVER_PUBLIC_URL` \ -The URL through which a user will communicate with Document Server. \ -For example: http://localhost:8080 -- `EXAMPLE_URL` \ -The URL through which Document Server will communicate with the server. \ -For example: http://proxy -- `JWT_SECRET` \ -JWT authorization secret. Leave blank to disable authorization. \ -For example: `your-256-bit-secret` -- `PORT` \ -The port on which the server should be running. \ -For example: `80` +| Name | Description | Example | +| ------------- | ------------- | ------------- | +| `BINDING` | The address where the server should be started. | `0.0.0.0` | +| `DOCUMENT_SERVER_PRIVATE_URL` | The URL through which the server will communicate with Document Server. | `http://proxy:8080` | +| `DOCUMENT_SERVER_PUBLIC_URL` | The URL through which a user will communicate with Document Server. | `http://localhost:8080` | +| `EXAMPLE_URL` | The URL through which Document Server will communicate with the server. | `http://proxy` | +| `JWT_SECRET` | JWT authorization secret. Leave blank to disable authorization. | `your-256-bit-secret` | +| `PORT` | The port on which the server should be running. | `80` | ## Security Info From eaa06d1919ee92b72c945e14aa8d96871dd26879 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 24 Oct 2023 15:19:43 +0300 Subject: [PATCH 154/488] ruby: download last version --- web/documentserver-example/ruby/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/README.md b/web/documentserver-example/ruby/README.md index 84ad20d9d..c3fcfcfae 100755 --- a/web/documentserver-example/ruby/README.md +++ b/web/documentserver-example/ruby/README.md @@ -16,7 +16,7 @@ To run the example using [Docker](https://docker.com), you will need [Docker Des Once you have everything installed, download the release archive and unarchive it. ```sh -$ curl --output Ruby.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/download/v1.6.0/Ruby.Example.zip +$ curl --output Ruby.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/latest/download/Ruby.Example.zip $ unzip Ruby.Example.zip ``` @@ -40,7 +40,7 @@ To run the example on your local machine, you will need [Ruby 3.2.2](https://rub Once you have everything installed, download the release archive and unarchive it. ```sh -$ curl --output Ruby.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/download/v1.6.0/Ruby.Example.zip +$ curl --output Ruby.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/latest/download/Ruby.Example.zip $ unzip Ruby.Example.zip ``` From 687b811eefae3ab8015ac2f950c99c2ebba2a31a Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 25 Oct 2023 10:56:00 +0700 Subject: [PATCH 155/488] pylint: C0411 wrong-import-order --- web/documentserver-example/python/src/utils/docManager.py | 2 +- web/documentserver-example/python/src/utils/historyManager.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 1e912bd03..be56a91d2 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -21,9 +21,9 @@ import shutil import io import re -import requests import time import urllib.parse +import requests import magic from django.conf import settings diff --git a/web/documentserver-example/python/src/utils/historyManager.py b/web/documentserver-example/python/src/utils/historyManager.py index 2cd54e072..a4838c198 100644 --- a/web/documentserver-example/python/src/utils/historyManager.py +++ b/web/documentserver-example/python/src/utils/historyManager.py @@ -20,10 +20,10 @@ import io import json -from . import users, fileUtils from datetime import datetime from src.utils import docManager from src.utils import jwtManager +from . import users, fileUtils # get the path to the history direction From 28211493bc87fce04886c679f30a42bfde4aadbf Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 25 Oct 2023 11:12:39 +0700 Subject: [PATCH 156/488] pylint: C0209 consider-using-f-string --- web/documentserver-example/python/src/utils/docManager.py | 4 ++-- .../python/src/utils/serviceConverter.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index be56a91d2..502e8e055 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -249,7 +249,7 @@ def downloadFileFromUri(uri, path=None, withSave=False): resp = requests.get(uri, stream=True, verify=config_manager.ssl_verify_peer_mode_enabled(), timeout=5) status_code = resp.status_code if status_code != 200: # checking status code - raise RuntimeError('Document editing service returned status: %s' % status_code) + raise RuntimeError(f'Document editing service returned status: {status_code}') if withSave: if path is None: raise RuntimeError('Path for saving file is null') @@ -319,7 +319,7 @@ def getFilesInfo(req): getStoragePath(f.get("title"), req) )), "id": generateFileKey(f.get("title"), req), - "contentLength": "%.2f KB" % (stats.st_size/1024), + "contentLength": f"{(stats.st_size/1024):.2f} KB", "pureContentLength": stats.st_size, "title": f.get("title"), "updated": time.strftime("%Y-%m-%dT%X%z", time.gmtime(stats.st_mtime)) diff --git a/web/documentserver-example/python/src/utils/serviceConverter.py b/web/documentserver-example/python/src/utils/serviceConverter.py index 4213abc34..86d8c03f7 100755 --- a/web/documentserver-example/python/src/utils/serviceConverter.py +++ b/web/documentserver-example/python/src/utils/serviceConverter.py @@ -56,7 +56,7 @@ def getConvertedData(docUri, fromExt, toExt, docKey, isAsync, filePass=None, lan verify=config_manager.ssl_verify_peer_mode_enabled(), timeout=5) status_code = response.status_code if status_code != 200: # checking status code - raise RuntimeError('Convertation service returned status: %s' % status_code) + raise RuntimeError(f'Convertation service returned status: {status_code}') json = response.json() return getResponseUri(json) From 6bd081c44ddb0e13880188e41762fe094a4a7ce1 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 25 Oct 2023 11:19:19 +0700 Subject: [PATCH 157/488] pylint: R1705 no-else-return --- .../python/src/utils/docManager.py | 11 +++++------ web/documentserver-example/python/src/views/index.py | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 502e8e055..9766ecf0f 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -103,8 +103,8 @@ def getServerUrl(forDocumentServer, req): example_url = config_manager.example_url() if (forDocumentServer and example_url is not None): return example_url.geturl() - else: - return req.headers.get("x-forwarded-proto") or req.scheme + "://" + req.get_host() + + return req.headers.get("x-forwarded-proto") or req.scheme + "://" + req.get_host() # get file url @@ -331,10 +331,9 @@ def getFilesInfo(req): if fileId: if len(resultID) > 0: return resultID - else: - return "File not found" - else: - return result + return "File not found" + + return result # download the file diff --git a/web/documentserver-example/python/src/views/index.py b/web/documentserver-example/python/src/views/index.py index bcac665bb..337cf0470 100755 --- a/web/documentserver-example/python/src/views/index.py +++ b/web/documentserver-example/python/src/views/index.py @@ -32,8 +32,8 @@ def getDirectUrlParam(request): if 'directUrl' in request.GET: return request.GET['directUrl'].lower() in ("true") - else: - return False + + return False def default(request): # default parameters that will be passed to the template From c3b2785c3f512f091912ac92e5fedebbfa52f2e7 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 25 Oct 2023 11:29:54 +0700 Subject: [PATCH 158/488] pylint: W3101 missing-timeout --- web/documentserver-example/python/src/utils/trackManager.py | 2 +- web/documentserver-example/python/src/views/actions.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/python/src/utils/trackManager.py b/web/documentserver-example/python/src/utils/trackManager.py index 0c398c803..574daadfd 100755 --- a/web/documentserver-example/python/src/utils/trackManager.py +++ b/web/documentserver-example/python/src/utils/trackManager.py @@ -185,7 +185,7 @@ def commandRequest(method, key, meta=None): payload['token'] = jwtManager.encode(payload) # encode a payload object into a body token response = requests.post(config_manager.document_server_command_url().geturl(), json=payload, headers=headers, - verify=config_manager.ssl_verify_peer_mode_enabled()) + verify=config_manager.ssl_verify_peer_mode_enabled(), timeout=5) if meta: return response diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index d14415606..0c31d1c73 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -134,7 +134,7 @@ def saveAs(request): filename = docManager.getCorrectName(title, request) path = docManager.getStoragePath(filename, request) - resp = requests.get(saveAsFileUrl, verify=config_manager.ssl_verify_peer_mode_enabled()) + resp = requests.get(saveAsFileUrl, verify=config_manager.ssl_verify_peer_mode_enabled(), timeout=5) # check if the file size exceeds the maximum size allowed (5242880) if (len(resp.content) > config_manager.maximum_file_size()) | (len(resp.content) <= 0): From 39f39b031615092317f6d8cf1494688e01b53154 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 25 Oct 2023 11:44:00 +0700 Subject: [PATCH 159/488] pylint: W0613 unused-argument --- web/documentserver-example/python/src/views/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 0c31d1c73..5e1a95e82 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -435,7 +435,7 @@ def files(request): # download a csv file -def csv(request): +def csv(): filePath = os.path.join('assets', 'document-templates', 'sample', "csv.csv") response = docManager.download(filePath) return response From b7212b035a7521cd744d3250bffb66172170242d Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 25 Oct 2023 12:42:51 +0700 Subject: [PATCH 160/488] pylint: configuration file --- web/documentserver-example/python/.pylintrc | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 web/documentserver-example/python/.pylintrc diff --git a/web/documentserver-example/python/.pylintrc b/web/documentserver-example/python/.pylintrc new file mode 100644 index 000000000..55e1ee71c --- /dev/null +++ b/web/documentserver-example/python/.pylintrc @@ -0,0 +1,34 @@ +[MAIN] +disable=C0114, # missing-module-docstring + C0115, # missing-class-docstring + C0116, # missing-function-docstring + E0611, # no-name-in-module + R0902, # too-many-instance-attributes + R0913, # too-many-arguments + R0914, # too-many-locals + W1514, # unspecified-encoding + R1710, # inconsistent-return-statements + R1732, # consider-using-with + +[FORMAT] +max-line-length=120 + +[BASIC] +argument-naming-style=any +attr-naming-style=any +function-naming-style=any +module-naming-style=any +variable-naming-style=any + +[DESIGN] +# max-args= +# max-attributes= +max-branches=15 +# max-locals= +min-public-methods=0 + +[EXCEPTIONS] +overgeneral-exceptions = builtins.[] + +[MISCELLANEOUS] +notes = ["FIXME", "XXX"] \ No newline at end of file From c23a8ac47da58d565703beee45f165748c8134da Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 25 Oct 2023 12:48:34 +0700 Subject: [PATCH 161/488] python: lint workflow fix --- .github/workflows/lint-python.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 3e290ec6c..f46bb540e 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -32,9 +32,9 @@ jobs: - name: Lint Flake8 run: | - flake8 ./**/*.py --count --select=E9,F63,F7,F82 --show-source --statistics - flake8 ./**/*.py --count --max-complexity=10 --max-line-length=79 --statistics + flake8 --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 --count --max-complexity=15 --max-line-length=120 --per-file-ignores="__init__.py:F4" --statistics - name: Lint Pylint run: | - pylint ./**/*.py + pylint ./**/*.py --rcfile=.pylintrc From fdf55a0da2c7d29cf4688535e3179b4ea97440af Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 25 Oct 2023 13:10:12 +0700 Subject: [PATCH 162/488] python: pylint workflow import-error(E0401) ignore --- .github/workflows/lint-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index f46bb540e..05a3a211d 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -37,4 +37,4 @@ jobs: - name: Lint Pylint run: | - pylint ./**/*.py --rcfile=.pylintrc + pylint ./**/*.py --rcfile=.pylintrc --disable=import-error From 0a3785a3a4da09d8fa4a4136647d114f5f131598 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 25 Oct 2023 13:55:29 +0700 Subject: [PATCH 163/488] python: merging lint fix --- web/documentserver-example/python/src/utils/docManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 4ee335232..cbb698fd4 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -87,7 +87,7 @@ def getTemplateImageUrl(fileType, request): # get file name with an index if such a file name already exists def getCorrectName(filename, req): maxName = 50 - basename = fileUtils.getFileNameWithoutExt(filename)[0:maxName] + ('','[...]')[len(filename) > maxName] + basename = fileUtils.getFileNameWithoutExt(filename)[0:maxName] + ('', '[...]')[len(filename) > maxName] ext = fileUtils.getFileExt(filename) name = f'{basename}{ext}' From 5f2c5cea58b8200bb7d90500dbaf2e466a48f034 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 26 Oct 2023 11:15:26 +0700 Subject: [PATCH 164/488] ruby: code refactoring --- .../ruby/app/controllers/home_controller.rb | 20 ++++++++++--------- .../ruby/app/views/home/editor.html.erb | 9 +-------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index c75f024b9..b844c7bc2 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -163,19 +163,21 @@ def historyobj if data == nil || data.empty? return "" end - fileData = JSON.parse(data) + file_data = JSON.parse(data) file = FileModel.new( - :file_name => File.basename(fileData['file_name']), - :mode => fileData['mode'], - :type => fileData['type'], - :user_ip => fileData['user_ip'], - :lang => fileData['lang'], - :user => fileData['user'], - :action_data => fileData['action_data'], - :direct_url => fileData['direct_url'] + file_name: File.basename(file_data['file_name']), + mode: file_data['mode'], + type: file_data['type'], + user_ip: file_data['user_ip'], + lang: file_data['lang'], + user: file_data['user'], + action_data: file_data['action_data'], + direct_url: file_data['direct_url'] ) history = file.get_history render json: history + rescue + render json: '{ "error": "File not found"}' end end diff --git a/web/documentserver-example/ruby/app/views/home/editor.html.erb b/web/documentserver-example/ruby/app/views/home/editor.html.erb index cc61d1ba5..e581c7708 100755 --- a/web/documentserver-example/ruby/app/views/home/editor.html.erb +++ b/web/documentserver-example/ruby/app/views/home/editor.html.erb @@ -185,14 +185,7 @@ innerAlert(response.error) return } - fileData = <%= raw @file.to_json %>; - const req = new XMLHttpRequest() - req.open("POST", '/historyobj') - req.send(JSON.stringify(fileData)) - req.onload = function () { - versionHistory = JSON.parse(req.response) - docEditor.refreshHistory(versionHistory.hist) - } + onRequestHistory() } } From e5d4be0d618617382dcd052b60a8869c21b78a83 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 26 Oct 2023 11:27:01 +0700 Subject: [PATCH 165/488] python: code refactoring --- web/documentserver-example/python/manage.py | 2 +- .../python/templates/editor.html | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/web/documentserver-example/python/manage.py b/web/documentserver-example/python/manage.py index a8093d449..910d38a46 100644 --- a/web/documentserver-example/python/manage.py +++ b/web/documentserver-example/python/manage.py @@ -65,7 +65,7 @@ def routers(): path('csv', actions.csv), path('download', actions.download), path('downloadhistory', actions.downloadhistory), - path('historyobj',actions.historyobj), + path('historyobj', actions.historyobj), path('edit', actions.edit), path('files', actions.files), path('reference', actions.reference), diff --git a/web/documentserver-example/python/templates/editor.html b/web/documentserver-example/python/templates/editor.html index 969e9cf33..a701c8c57 100755 --- a/web/documentserver-example/python/templates/editor.html +++ b/web/documentserver-example/python/templates/editor.html @@ -203,21 +203,7 @@ innerAlert(response.error) return } - data = { - fileName: query.get('filename') - } - const req = new XMLHttpRequest() - req.open("POST", '/historyobj') - req.send(JSON.stringify(data)) - req.onload = function () { - if (req.status != 200) { - response = JSON.parse(req.response) - innerAlert(response.error) - return - } - hist = JSON.parse(req.response) - docEditor.refreshHistory(hist.history) - } + onRequestHistory() } } From 0d3cda32fa33e43ee4577c67af96ff332a3c9f18 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 26 Oct 2023 11:33:38 +0700 Subject: [PATCH 166/488] php: code refactoring --- .../php/templates/docEditor.tpl | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/web/documentserver-example/php/templates/docEditor.tpl b/web/documentserver-example/php/templates/docEditor.tpl index 2508e8d0d..f5fceebe6 100644 --- a/web/documentserver-example/php/templates/docEditor.tpl +++ b/web/documentserver-example/php/templates/docEditor.tpl @@ -246,27 +246,7 @@ innerAlert(response.error) return } - const data = { - fileName: query.get('fileID') - } - const req = new XMLHttpRequest() - req.open("POST", 'objhistory') - req.setRequestHeader('Content-Type', 'application/json') - req.send(JSON.stringify(data)) - req.onload = function () { - if (req.status != 200) { - response = JSON.parse(req.response) - innerAlert(response.error) - return - } - history = JSON.parse(req.response) - docEditor.refreshHistory( - { - currentVersion: history[0].currentVersion, - history: history[0].history - } - ) - } + onRequestHistory() } } From 7825d0ae48d695360ab762f6dafd2dfb6b0e005d Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 26 Oct 2023 12:57:07 +0700 Subject: [PATCH 167/488] java-spring: code refactoring --- .../controllers/FileController.java | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index 0ecbf1169..b608288a4 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -152,24 +152,18 @@ private ResponseEntity downloadFile(final String fileName) { private ResponseEntity downloadSample(final String fileName) { String serverPath = System.getProperty("user.dir"); String contentType = "application/octet-stream"; - String fileLocation = serverPath - + File.separator + "src" - + File.separator + "main" - + File.separator + "resources" - + File.separator + "assets" - + File.separator + "document-templates" - + File.separator + "sample" - + File.separator + fileName; - Path filePath = Paths.get(fileLocation); // get the path to the file location + String[] fileLocation = new String[] {serverPath, "src", "main", "resources", "assets", "document-templates", + "sample", fileName}; + Path filePath = Paths.get(String.join(File.separator, fileLocation)); Resource resource; try { resource = new UrlResource(filePath.toUri()); if (resource.exists()) { - return ResponseEntity.ok() - .contentType(MediaType.parseMediaType(contentType)) - .header(HttpHeaders.CONTENT_DISPOSITION, - "attachment; filename=\"" + resource.getFilename() + "\"") - .body(resource); + return ResponseEntity.ok() + .contentType(MediaType.parseMediaType(contentType)) + .header(HttpHeaders.CONTENT_DISPOSITION, + "attachment; filename=\"" + resource.getFilename() + "\"") + .body(resource); } } catch (MalformedURLException e) { e.printStackTrace(); From b093666d90442cf66bc0004fc3a3f122fa95f6c0 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 26 Oct 2023 13:03:10 +0700 Subject: [PATCH 168/488] python: code refactoring --- web/documentserver-example/python/manage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/python/manage.py b/web/documentserver-example/python/manage.py index c9b46d737..6387e57be 100644 --- a/web/documentserver-example/python/manage.py +++ b/web/documentserver-example/python/manage.py @@ -63,7 +63,7 @@ def routers(): path('convert', actions.convert), path('create', actions.createNew), path('csv', actions.csv), - path('assets',actions.assets), + path('assets', actions.assets), path('download', actions.download), path('downloadhistory', actions.downloadhistory), path('edit', actions.edit), From bbeaea6d2ea661182a98d64db33f575c8e9db11e Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 26 Oct 2023 13:34:14 +0700 Subject: [PATCH 169/488] ruby: code refactoring --- .../ruby/app/controllers/home_controller.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 532b0ccf2..bc56fa4ed 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -281,14 +281,13 @@ def csv # downloading an assets file def asset file_name = File.basename(params[:fileName]) - assetPath = Rails.root.join('assets', 'document-templates', 'sample', file_name) + asset_path = Rails.root.join('assets', 'document-templates', 'sample', file_name) - # add headers to the response to specify the page parameters - response.headers['Content-Length'] = File.size(assetPath).to_s - response.headers['Content-Type'] = MimeMagic.by_path(assetPath).type + response.headers['Content-Length'] = File.size(asset_path).to_s + response.headers['Content-Type'] = MimeMagic.by_path(asset_path).type response.headers['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + ERB::Util.url_encode(file_name) - send_file assetPath, :x_sendfile => true + send_file asset_path, :x_sendfile => true end # downloading a file From 6990bc40d2371360969b47d019300388f391a4b3 Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Thu, 26 Oct 2023 12:56:28 +0400 Subject: [PATCH 170/488] python: pin python with pip versions --- web/documentserver-example/python/.pip-version | 1 + web/documentserver-example/python/.python-version | 2 +- web/documentserver-example/python/pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 web/documentserver-example/python/.pip-version diff --git a/web/documentserver-example/python/.pip-version b/web/documentserver-example/python/.pip-version new file mode 100644 index 000000000..28a21844b --- /dev/null +++ b/web/documentserver-example/python/.pip-version @@ -0,0 +1 @@ +23.1.2 diff --git a/web/documentserver-example/python/.python-version b/web/documentserver-example/python/.python-version index 2c0733315..0c7d5f5f5 100644 --- a/web/documentserver-example/python/.python-version +++ b/web/documentserver-example/python/.python-version @@ -1 +1 @@ -3.11 +3.11.4 diff --git a/web/documentserver-example/python/pyproject.toml b/web/documentserver-example/python/pyproject.toml index 6fe216b0c..dcb79a313 100644 --- a/web/documentserver-example/python/pyproject.toml +++ b/web/documentserver-example/python/pyproject.toml @@ -6,7 +6,7 @@ requires = [ [project] name = "online-editor-example" version = "1.6.0" -requires-python = ">=3.11" +requires-python = ">=3.11.4" dependencies = [ "django>=3.1.3", "django-stubs>=4.2.3", From 038b2ffc573898084f861c70372a81335026b7a0 Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Thu, 26 Oct 2023 12:59:59 +0400 Subject: [PATCH 171/488] python: delete readme.md to be able to rename it in uppercase --- web/documentserver-example/python/readme.md | 82 --------------------- 1 file changed, 82 deletions(-) delete mode 100755 web/documentserver-example/python/readme.md diff --git a/web/documentserver-example/python/readme.md b/web/documentserver-example/python/readme.md deleted file mode 100755 index 8270e52e6..000000000 --- a/web/documentserver-example/python/readme.md +++ /dev/null @@ -1,82 +0,0 @@ -## Overview - -This example will help you integrate ONLYOFFICE Docs into your web application written in Python. - -**Please note**: It is intended for testing purposes and demonstrating functionality of the editors. Do NOT use this integration example on your own server without proper code modifications! In case you enabled the test example, disable it before going for production. - -## Step 1. Install ONLYOFFICE Docs - -Download and install ONLYOFFICE Docs (packaged as Document Server). - -See the detailed guide to learn how to install Document Server [for Windows](https://helpcenter.onlyoffice.com/installation/docs-developer-install-windows.aspx?from=api_python_example), [for Linux](https://helpcenter.onlyoffice.com/installation/docs-developer-install-ubuntu.aspx?from=api_python_example), or [for Docker](https://helpcenter.onlyoffice.com/server/developer-edition/docker/docker-installation.aspx?from=api_python_example). - -## Step 2. Install the prerequisites and run the website with the editors - -1. **Python** comes preinstalled on most Linux distributions, and is available as a package on all others. Python 3.9 is required. Please proceed to [official documentation](https://docs.python.org/3/using/unix.html) if you have any troubles. - -2. Download the archive with the Python example and unpack it: - - ``` - wget "https://api.onlyoffice.com/app_data/editor/Python.Example.zip" - ``` - - ``` - unzip Python.Example.zip - ``` - -3. Change the current directory for the project directory: - - ``` - cd Python\ Example - ``` - -4. Install the dependencies: - - ``` - pip install Django==3.1.3 - pip install requests==2.25.0 - pip install pyjwt==2.6.0 - pip install python-magic - ``` - -5. Edit the *config.py* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. And specify the name of the server on which example is installed. - - ``` - nano config.py - ``` - - Edit the following lines: - - ``` - STORAGE_PATH = 'app_data' - DOC_SERV_SITE_URL = 'https://documentserver/' - ``` - - where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **STORAGE_PATH** is the path where files will be created and stored. You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator. - -6. Run the **Python** server: - - ``` - python manage.py runserver 0.0.0.0:8000 - ``` - -7. See the result in your browser using the address: - - ``` - http://localhost:8000 - ``` - -## Step 3. Check accessibility - -In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files. - -Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files. - -## Important security info - -Please keep in mind the following security aspects when you are using test examples: - -* There is no protection of the storage from unauthorized access since there is no need for authorization. -* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts. -* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server. -* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain. \ No newline at end of file From cd0647e0f7a16eaa5af8d82fa09ae95cd3c483ba Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Thu, 26 Oct 2023 13:00:39 +0400 Subject: [PATCH 172/488] python: update readme --- web/documentserver-example/python/README.md | 86 +++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 web/documentserver-example/python/README.md diff --git a/web/documentserver-example/python/README.md b/web/documentserver-example/python/README.md new file mode 100755 index 000000000..cb7ae8408 --- /dev/null +++ b/web/documentserver-example/python/README.md @@ -0,0 +1,86 @@ +## Overview + +This example will help you integrate ONLYOFFICE Docs into your web application written on Python. + +> [!WARNING] +> It is intended for testing purposes and demonstrating functionality of the editors. **DO NOT** use this integration example on your own server without proper code modifications. In case you enabled the test example, disable it before going for production. + +## Installation + +The Python example offers various installation options, but we highly recommend using Docker for this purpose. + +### Using Docker + +To run the example using [Docker](https://docker.com), you will need [Docker Desktop 4.17.0](https://docs.docker.com/desktop) or [Docker Engine 20.10.23](https://docs.docker.com/engine) with [Docker Compose 2.15.1](https://docs.docker.com/compose). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools. + +Once you have everything installed, download the release archive and unarchive it. + +```sh +$ curl --output Python.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/latest/download/Python.Example.zip +$ unzip Python.Example.zip +``` + +Then open the example directory and [up containers](./Makefile#L38). + +```sh +$ cd "Python Example" +$ make compose-prod +``` + +By default, the server starts at `localhost:80`. + +To configure the example, you can edit the environment variables in [`compose-base.yml`](./compose-base.yml). See [below](#configuration) for more information about environment variables. + +### On Local Machine + +Before diving into the example, you will need to install ONLYOFFICE Document Server (also known as Docs). Check the detailed guide to learn how to install it on [Windows](https://helpcenter.onlyoffice.com/installation/docs-developer-install-windows.aspx), [Linux](https://helpcenter.onlyoffice.com/installation/docs-developer-install-ubuntu.aspx), or [Docker](https://helpcenter.onlyoffice.com/installation/docs-developer-install-docker.aspx). + +To run the example on your local machine, you will need [Python 3.11.4](https://python.org) with [pip 23.1.2](https://pip.pypa.io). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools. + +Once you have everything installed, download the release archive and unarchive it. + +```sh +$ curl --output Python.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/latest/download/Python.Example.zip +$ unzip Python.Example.zip +``` + +Then open the example directory, [install dependencies](./Makefile#L13), and [start the server](./Makefile#L21). + +```sh +$ cd "Python Example" +$ make prod +$ make server-prod +``` + +By default, the server starts at `0.0.0.0:8000`. + +To configure the example, you can pass the environment variables before the command that starts the server. See [below](#configuration) for more information about environment variables. + +## Post Installation + +In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files. + +Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files. + +## Configuration + +The example is configured by changing environment variables. + +| Name | Description | Example | +| ----------------------------- | ----------------------------------------------------------------------- | ----------------------- | +| `DEBUG` | Disable or enable debug mode. | `false` | +| `ADDRESS` | The address where the server should be started. | `0.0.0.0` | +| `PORT` | The port on which the server should be running. | `80` | +| `DOCUMENT_SERVER_PRIVATE_URL` | The URL through which the server will communicate with Document Server. | `http://proxy:8080` | +| `DOCUMENT_SERVER_PUBLIC_URL` | The URL through which a user will communicate with Document Server. | `http://localhost:8080` | +| `EXAMPLE_URL` | The URL through which Document Server will communicate with the server. | `http://proxy` | +| `JWT_SECRET` | JWT authorization secret. Leave blank to disable authorization. | `your-256-bit-secret` | + +## Security Info + +Please keep in mind the following security aspects when you are using test examples: + +- There is no protection of the storage from unauthorized access since there is no need for authorization. +- There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts. +- There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server. +- There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain. From 8696f26555c614e40207ef5e43a3122a7dbdf577 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 26 Oct 2023 15:23:45 +0300 Subject: [PATCH 173/488] nodejs: fix directUrl property (815b5fb) --- web/documentserver-example/nodejs/views/editor.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index 9ed86798a..a978eac5e 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -242,7 +242,7 @@ var requestReference = function(data, callback) { innerAlert(data); - event.data.directUrl = !!config.document.directUrl; + data.directUrl = !!config.document.directUrl; let xhr = new XMLHttpRequest(); xhr.open("POST", "reference"); From 5ab7261d314cf2e72d8d017981284300c4df84eb Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Fri, 20 Oct 2023 12:54:57 +0300 Subject: [PATCH 174/488] php: onRequestOpen for referenceData source file --- .../php/docker-compose.yml | 2 +- web/documentserver-example/php/src/ajax.php | 3 +- .../php/templates/docEditor.tpl | 36 ++++++++++++++++--- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/php/docker-compose.yml b/web/documentserver-example/php/docker-compose.yml index 1b9d75e21..9ff37c3d9 100644 --- a/web/documentserver-example/php/docker-compose.yml +++ b/web/documentserver-example/php/docker-compose.yml @@ -3,7 +3,7 @@ version: "3.8" services: document-server: container_name: document-server - image: onlyoffice/documentserver:7.3.3.50 + image: onlyoffice/documentserver:latest expose: - "80" environment: diff --git a/web/documentserver-example/php/src/ajax.php b/web/documentserver-example/php/src/ajax.php index 1353c82bc..59fc065e1 100644 --- a/web/documentserver-example/php/src/ajax.php +++ b/web/documentserver-example/php/src/ajax.php @@ -576,7 +576,8 @@ function reference() ]), "instanceId" => serverPath(), ], - "path" => $fileName + "path" => $fileName, + "link" => serverPath() . '/editor?fileID=' . $fileName ]; if ($jwtManager->isJwtEnabled()) { diff --git a/web/documentserver-example/php/templates/docEditor.tpl b/web/documentserver-example/php/templates/docEditor.tpl index 2d1787b67..561fab980 100644 --- a/web/documentserver-example/php/templates/docEditor.tpl +++ b/web/documentserver-example/php/templates/docEditor.tpl @@ -98,18 +98,43 @@ return link; }; + var onRequestOpen = function(event) { // user open external data source + innerAlert("onRequestOpen"); + var windowName = event.data.windowName; + + requestReference(event.data, function (data) { + if (data.error) { + var winEditor = window.open("", windowName); + winEditor.close(); + innerAlert(data.error, true); + return; + } + + var link = data.link; + window.open(link, windowName); + }); + }; + var onRequestReferenceData = function(event) { // user refresh external data source - innerAlert("onRequestReferenceData: " + JSON.stringify(event.data)); + innerAlert("onRequestReferenceData"); - event.data.directUrl = !!config.document.directUrl; + requestReference(event.data, function (data) { + docEditor.setReferenceData(data); + }); + }; + + var requestReference = function(data, callback) { + innerAlert(data); + + data.directUrl = !!config.document.directUrl; let xhr = new XMLHttpRequest(); xhr.open("POST", "reference"); xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify(event.data)); + xhr.send(JSON.stringify(data)); xhr.onload = function () { innerAlert(xhr.responseText); console.log(JSON.parse(xhr.responseText)); - docEditor.setReferenceData(JSON.parse(xhr.responseText)); + callback(JSON.parse(xhr.responseText)); } }; @@ -233,7 +258,8 @@ 'onRequestSelectDocument': onRequestSelectDocument, 'onRequestSelectSpreadsheet': onRequestSelectSpreadsheet, 'onRequestReferenceData': onRequestReferenceData, - 'onRequestRestore': onRequestRestore + 'onRequestRestore': onRequestRestore, + "onRequestOpen": onRequestOpen, }; {history} From 7ecec4219a1d4cb64beeff1cc3ee38adeed2c0c2 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Sat, 21 Oct 2023 14:18:08 +0300 Subject: [PATCH 175/488] csharp: onRequestOpen for referenceData source file --- .../csharp/DocEditor.aspx | 34 +++++++++++++++++-- .../csharp/WebEditor.ashx.cs | 3 +- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/csharp/DocEditor.aspx b/web/documentserver-example/csharp/DocEditor.aspx index 4d2540589..f7c92b2b3 100644 --- a/web/documentserver-example/csharp/DocEditor.aspx +++ b/web/documentserver-example/csharp/DocEditor.aspx @@ -194,16 +194,42 @@ } }; + var onRequestOpen = function (event) { // user open external data source + innerAlert("onRequestOpen"); + var windowName = event.data.windowName; + + requestReference(event.data, function (data) { + if (data.error) { + var winEditor = window.open("", windowName); + winEditor.close(); + innerAlert(data.error, true); + return; + } + + var link = data.link; + window.open(link, windowName); + }); + }; + var onRequestReferenceData = function (event) { // user refresh external data source + innerAlert("onRequestReferenceData"); - event.data.directUrl = !!config.document.directUrl; + requestReference(event.data, function (data) { + docEditor.setReferenceData(data); + }); + }; + + var requestReference = function (data, callback) { + innerAlert(data); + + data.directUrl = !!config.document.directUrl; let xhr = new XMLHttpRequest(); xhr.open("POST", "webeditor.ashx?type=reference"); xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify(event.data)); + xhr.send(JSON.stringify(data)); xhr.onload = function () { console.log(xhr.responseText); - docEditor.setReferenceData(JSON.parse(xhr.responseText)); + callback(JSON.parse(xhr.responseText)); } }; @@ -290,6 +316,8 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; + // add link to reference data source file + config.events['onRequestOpen'] = onRequestOpen; } if (config.editorConfig.createUrl) { diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index e69e36480..2b2a75929 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -665,7 +665,8 @@ private static void Reference(HttpContext context) {"instanceId", _Default.GetServerUrl(false) } } }, - { "path", fileName } + { "path", fileName }, + { "link", _Default.GetServerUrl(false) + "doceditor.aspx?fileID=" + fileName } }; if (JwtManager.Enabled) From 5b17ba41c341152d2f3ae468b8ff04a70209b7ed Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Sat, 21 Oct 2023 18:58:57 +0300 Subject: [PATCH 176/488] mvc: onRequestOpen for referenceData source file --- .../csharp-mvc/Views/Home/Editor.aspx | 32 +++++++++++++++++-- .../csharp-mvc/WebEditor.ashx.cs | 3 +- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx index 5c9ccdee9..4e2cacc2c 100644 --- a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx +++ b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx @@ -182,15 +182,39 @@ } }; + var onRequestOpen = function (event) { // user open external data source + innerAlert("onRequestOpen"); + var windowName = event.data.windowName; + requestReference(event.data, function (data) { + if (data.error) { + var winEditor = window.open("", windowName); + winEditor.close(); + innerAlert(data.error, true); + return; + } + var link = data.link; + window.open(link, windowName); + }); + }; + var onRequestReferenceData = function (event) { // user refresh external data source - event.data.directUrl = !!config.document.directUrl; + innerAlert("onRequestReferenceData"); + + requestReference(event.data, function (data) { + docEditor.setReferenceData(data); + }); + }; + + var requestReference = function (data, callback) { + innerAlert(data); + data.directUrl = !!config.document.directUrl; let xhr = new XMLHttpRequest(); xhr.open("POST", "webeditor.ashx?type=reference"); xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify(event.data)); + xhr.send(JSON.stringify(data)); xhr.onload = function () { console.log(xhr.responseText); - docEditor.setReferenceData(JSON.parse(xhr.responseText)); + callback(JSON.parse(xhr.responseText)); } }; @@ -287,6 +311,8 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; + // add link to reference data source file + config.events['onRequestOpen'] = onRequestOpen; } if (config.editorConfig.createUrl) { diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index 8fb782551..89487893e 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -853,7 +853,8 @@ private static void Reference(HttpContext context) { "instanceId", DocManagerHelper.GetServerUrl(false) } } }, - { "path", fileName } + { "path", fileName }, + { "link", DocManagerHelper.GetServerUrl(false) + "Editor?fileName=" + fileName } }; if (JwtManager.Enabled) From 8d94e424217f649f68ee30ffa9c6cf9663974549 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 23 Oct 2023 15:13:40 +0300 Subject: [PATCH 177/488] python: onRequestOpen for referenceData source file --- .../python/src/views/actions.py | 3 +- .../python/templates/editor.html | 32 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 10b6f010f..2da9be087 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -502,7 +502,8 @@ def reference(request): 'instanceId' : docManager.getServerUrl(False, request), 'fileKey' : json.dumps({'fileName' : fileName, 'userAddress': request.META['REMOTE_ADDR']}) }, - 'path' : fileName + 'path' : fileName, + 'link' : docManager.getServerUrl(False, request) + '/edit?filename=' + fileName } if (jwtManager.isEnabled()): diff --git a/web/documentserver-example/python/templates/editor.html b/web/documentserver-example/python/templates/editor.html index 722bf0d6e..f2297b516 100755 --- a/web/documentserver-example/python/templates/editor.html +++ b/web/documentserver-example/python/templates/editor.html @@ -170,18 +170,40 @@ } }; + var onRequestOpen = function (event) { // user open external data source + innerAlert("onRequestOpen"); + var windowName = event.data.windowName; + requestReference(event.data, function (data) { + if (data.error) { + var winEditor = window.open("", windowName); + winEditor.close(); + innerAlert(data.error, true); + return; + } + var link = data.link; + window.open(link, windowName); + }); + }; + var onRequestReferenceData = function(event) { // user refresh external data source - innerAlert("onRequestReferenceData: " + JSON.stringify(event.data)); + innerAlert("onRequestReferenceData"); - event.data.directUrl = !!config.document.directUrl; + requestReference(event.data, function (data) { + docEditor.setReferenceData(data); + }); + }; + + var requestReference = function (data, callback) { + innerAlert(data); + data.directUrl = !!config.document.directUrl; let xhr = new XMLHttpRequest(); xhr.open("POST", "reference"); xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify(event.data)); + xhr.send(JSON.stringify(data)); xhr.onload = function () { innerAlert(xhr.responseText); console.log(JSON.parse(xhr.responseText)); - docEditor.setReferenceData(JSON.parse(xhr.responseText)); + callback(JSON.parse(xhr.responseText)); } }; @@ -265,6 +287,8 @@ // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; + // add link to reference data source file + config.events['onRequestOpen'] = onRequestOpen; } if (config.editorConfig.createUrl) { From 4e3f87f692fc6657bb3a82909c53b6051f891aa6 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 23 Oct 2023 19:11:32 +0300 Subject: [PATCH 178/488] java-spring: onRequestOpen for referenceData source file --- .../controllers/FileController.java | 1 + .../onlyoffice/integration/dto/Reference.java | 1 + .../src/main/resources/templates/editor.html | 36 +++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index 315d8b1c4..159b0eea5 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -522,6 +522,7 @@ public String reference(@RequestBody final Reference body) { data.put("directUrl", body.getDirectUrl() ? documentManager.getDownloadUrl(fileName, false) : null); data.put("referenceData", referenceData); data.put("path", fileName); + data.put("link", storagePathBuilder.getServerUrl(true) + "/editor?fileName=" + fileName); if (jwtManager.tokenEnabled()) { String token = jwtManager.createToken(data); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java index 705d0d873..799ea7d9c 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java @@ -28,6 +28,7 @@ @AllArgsConstructor @NoArgsConstructor public class Reference { + private String windowName; private Boolean directUrl; private ReferenceData referenceData; private String path; diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html index 3694fc328..774be409c 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html @@ -166,15 +166,43 @@ } }; + var onRequestOpen = function(event) { // user open external data source + innerAlert("onRequestOpen"); + var windowName = event.data.windowName; + + requestReference(event.data, function (data) { + if (data.error) { + var winEditor = window.open("", windowName); + winEditor.close(); + innerAlert(data.error, true); + return; + } + + var link = data.link; + window.open(link, windowName); + }); + }; + var onRequestReferenceData = function(event) { // user refresh external data source - event.data.directUrl = !!config.document.directUrl; + innerAlert("onRequestReferenceData"); + + requestReference(event.data, function (data) { + docEditor.setReferenceData(data); + }); + }; + + var requestReference = function(data, callback) { + innerAlert(data); + + data.directUrl = !!config.document.directUrl; + let xhr = new XMLHttpRequest(); xhr.open("POST", "reference"); xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify(event.data)); + xhr.send(JSON.stringify(data)); xhr.onload = function () { innerAlert(xhr.responseText); - docEditor.setReferenceData(JSON.parse(xhr.responseText)); + callback(JSON.parse(xhr.responseText)); } }; @@ -274,6 +302,8 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; + // add link to reference data source file + config.events['onRequestOpen'] = onRequestOpen; } if (config.editorConfig.createUrl) { From 2f87f3b7c94f4c898ef04174dd0db3d0a49ceb47 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 20 Oct 2023 13:19:29 +0300 Subject: [PATCH 179/488] nodejs: set current avatar --- web/documentserver-example/nodejs/app.js | 1 + .../nodejs/helpers/users.js | 10 ++++++++-- .../nodejs/public/images/uid-1.png | Bin 0 -> 2226 bytes .../nodejs/public/images/uid-2.png | Bin 0 -> 2199 bytes .../nodejs/views/config.ejs | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 web/documentserver-example/nodejs/public/images/uid-1.png create mode 100644 web/documentserver-example/nodejs/public/images/uid-2.png diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 7eec4cea4..1842a79c9 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -1000,6 +1000,7 @@ app.get('/editor', (req, res) => { // define a handler for editing document curUserHostAddress: req.DocManager.curUserHostAddress(), lang, userid: userid !== 'uid-0' ? userid : null, + userImage: user.avatar ? `${req.DocManager.getServerUrl()}/images/${user.id}.png` : null, name, userGroup, reviewGroups: JSON.stringify(reviewGroups), diff --git a/web/documentserver-example/nodejs/helpers/users.js b/web/documentserver-example/nodejs/helpers/users.js index 09c8296f6..0461b9392 100644 --- a/web/documentserver-example/nodejs/helpers/users.js +++ b/web/documentserver-example/nodejs/helpers/users.js @@ -29,6 +29,7 @@ class User { deniedPermissions, descriptions, templates, + avatar, ) { this.id = id; this.name = name; @@ -41,6 +42,7 @@ class User { this.deniedPermissions = deniedPermissions; this.descriptions = descriptions; this.templates = templates; + this.avatar = avatar; } } @@ -53,6 +55,7 @@ const descrUser1 = [ 'Can create files from templates using data from the editor', 'Can see the information about all users', 'Can submit forms', + 'Has an avatar', ]; const descrUser2 = [ @@ -63,6 +66,7 @@ const descrUser2 = [ 'Can create new files from the editor', 'Can see the information about users from Group2 and users who don’t belong to any group', 'Can’t submit forms', + 'Has an avatar', ]; const descrUser3 = [ @@ -95,7 +99,7 @@ const descrUser0 = [ ]; const users = [ - new User('uid-1', 'John Smith', 'smith@example.com', null, null, {}, null, null, [], descrUser1, true), + new User('uid-1', 'John Smith', 'smith@example.com', null, null, {}, null, null, [], descrUser1, true, true), new User( 'uid-2', 'Mark Pottato', @@ -112,6 +116,7 @@ const users = [ [], descrUser2, false, + true, ), new User( 'uid-3', @@ -129,8 +134,9 @@ const users = [ ['copy', 'download', 'print'], descrUser3, false, + false, ), - new User('uid-0', null, null, null, null, {}, [], null, ['protect'], descrUser0, false), + new User('uid-0', null, null, null, null, {}, [], null, ['protect'], descrUser0, false, false), ]; // get a list of all the users diff --git a/web/documentserver-example/nodejs/public/images/uid-1.png b/web/documentserver-example/nodejs/public/images/uid-1.png new file mode 100644 index 0000000000000000000000000000000000000000..91cf9e02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4lMG#q}F%(y#(JWCnxFodxhpE9TI{#s0GN zuK>=C$c%|upLH`$R%pRgFlrK+Whu--j|jwaWzX6zS96CTzLOfxz%9hCB*ckj4Ttj` zCeW%cT-uvx7|ML~s4=TodfZI8R4UaLv9U;Sdj(_C(^1uz9%ktEch5JjkE;du+LU79fWvQN?OOY8IYrN3X@J_8fP^Q3I zMsm{EHN`g9ULnQ{@nU2VT!qAqex200Ri3O#RqWkAGT7XoyJzq3@`oevsLf7

=@QTFH*%9hw0afZChKaSVs@#Y{l6ET}z+LfFv#J1=E zo7Yg6H~fp)^7%eKJdY)aE!zt5UBTEYmni&n_y5{Al0Do|hQBy`B0yc9$83c3Jlh(4 zffdW;LYeNLzxM?U-`QPi885&dM$q~kEs)r4o3$oIpfV~xAo}L+lU%~`p(qvL#>c05c=9JzwTuWUK52JB5zEzepA!NeENbeA03PIq#?(DQb`qx;W&1f_( zhI`PKjx)Gy8C=F;A?O7PKjFIUGXZNn`NX3EYkYy&-i{19T!{D@=O)NRB1|Evy4es7 zus1PWkU8eQG1HZBAfCasCV|LLs6KUOEH=@wiO=W3@fsIcnhY|RONFy<4E`orBN6&x zrl`8;F9W_<9T8EE68OdOX6JxYYQe!n;ccmsNN}m^VgnKZJ|Cny;0>_D#5M|aVerO; zZ;NG-NfKpucXjigejM)%^7Y+zfamadgLWti2?^PlkWeg-l=S4Nt4=kHfnjV43R0B^R>?56m!4E>GrAYYa0t=A_XDsL<+3JVEoFACcnHQ3bG zm!Frh>lUc0di%90&#QNrg@qNB?O3(y%Fmboe6VZhwrwiadn=xL62AWdpl7dNzcw(i zv%LJ)Cm*kP<{3+x{gLDH53db;_Nm?HlaAy60nijp^WHMgaR2}S07*qoM6N<$g1R-5 A9RL6T literal 0 HcmV?d00001 diff --git a/web/documentserver-example/nodejs/public/images/uid-2.png b/web/documentserver-example/nodejs/public/images/uid-2.png new file mode 100644 index 0000000000000000000000000000000000000000..651b40c6b91e59c94b2752ddcbe0dac2ffe38cab GIT binary patch liter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rp_P>!Fcr+!yOHNy}*-ig4Yp{@)H zgR<4a);Myg&>+X*xG8@@rhjgo8sMTLWjvfT@RE~U1Jgtp-IY}T=3Dgwi8?c!7tZ5J zf)W_>wGO7ON39SZ5BB)2-zK6Yd4llp@S>vR^L&JXh8&DOeR_ou|CG}z5RBEU!)pct zlamJ-j5%##0EZ#DLNbRvyVh^?KvQhyuurI5oE$jGv7sd1{0a-gl|-W9o`ntgKy&`)5ttCD{V3@Mg+^)3TyXWZ}=IgQ_7SLPYS@L_e%_zdn?eCe% zYog08-avYTdiTA@ehIgK?Dp^d$uO66==OUXZ+-iT-`E{GpMCm?@fW`sfArx8+jlJb Z@qh8`Ye}<~)Vcrw002ovPDHLkV1jA>VwC^@ literal 0 HcmV?d00001 diff --git a/web/documentserver-example/nodejs/views/config.ejs b/web/documentserver-example/nodejs/views/config.ejs index 52c520b7e..fbfd44221 100755 --- a/web/documentserver-example/nodejs/views/config.ejs +++ b/web/documentserver-example/nodejs/views/config.ejs @@ -60,6 +60,7 @@ "user": { "group": "<%- editor.userGroup %>", "id": "<%- editor.userid %>", + "image": "<%- editor.userImage %>", "name": "<%- editor.name %>" } }, From e913cb3d2739b90c20a0d0ae4a38d51421588934 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 20 Oct 2023 13:29:31 +0300 Subject: [PATCH 180/488] nodejs: setUsers info --- web/documentserver-example/nodejs/app.js | 10 ++++++++++ web/documentserver-example/nodejs/views/editor.ejs | 3 +++ 2 files changed, 13 insertions(+) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 1842a79c9..4bf86a3d9 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -930,6 +930,15 @@ app.get('/editor', (req, res) => { // define a handler for editing document const { commentGroups } = user; const { userInfoGroups } = user; + const usersInfo = []; + if (user.id !== 'uid-0') { + users.getAllUsers().forEach((userInfo) => { + const u = userInfo; + u.image = userInfo.avatar ? `${req.DocManager.getServerUrl()}/images/${userInfo.id}.png` : null; + usersInfo.push(u); + }, usersInfo); + } + if (fileExt) { // create demo document of a given extension const fName = req.DocManager.createDemo(!!req.query.sample, fileExt, userid, name, false); @@ -1034,6 +1043,7 @@ app.get('/editor', (req, res) => { // define a handler for editing document }, usersForMentions: user.id !== 'uid-0' ? users.getUsersForMentions(user.id) : null, usersForProtect: user.id !== 'uid-0' ? users.getUsersForProtect(user.id) : null, + usersInfo, }; if (cfgSignatureEnable) { diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index 170208d9e..2dc0718ed 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -198,6 +198,9 @@ case "protect": var users = <%- JSON.stringify(usersForProtect) %>; break; + case "info": + var users = <%- JSON.stringify(usersInfo) %>; + break; default: users = <%- JSON.stringify(usersForMentions) %>; } From 4bce33e3c26c6dde30cdf925eb4edfcc1bbe39dc Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 20 Oct 2023 14:18:56 +0300 Subject: [PATCH 181/488] nodejs: set required users only --- web/documentserver-example/nodejs/views/editor.ejs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/nodejs/views/editor.ejs b/web/documentserver-example/nodejs/views/editor.ejs index 2dc0718ed..24bb951ed 100644 --- a/web/documentserver-example/nodejs/views/editor.ejs +++ b/web/documentserver-example/nodejs/views/editor.ejs @@ -199,7 +199,16 @@ var users = <%- JSON.stringify(usersForProtect) %>; break; case "info": - var users = <%- JSON.stringify(usersInfo) %>; + users = []; + var allUsers = <%- JSON.stringify(usersInfo) %>; + for (var i = 0; i < event.data.id.length; i++) { + for (var j = 0; j < allUsers.length; j++) { + if (allUsers[j].id == event.data.id[i]) { + users.push(allUsers[j]); + break; + } + } + } break; default: users = <%- JSON.stringify(usersForMentions) %>; From 438728294970bf6d4448ce74ee1cdf6dd8a24ece Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 24 Oct 2023 11:06:01 +0300 Subject: [PATCH 182/488] java: onRequestOpen for referenceData source file --- .../main/java/controllers/IndexServlet.java | 1 + .../java/src/main/webapp/editor.jsp | 34 +++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index c10abfdef..970db3044 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -733,6 +733,7 @@ private static void reference(final HttpServletRequest request, data.put("directUrl", directUrl ? DocumentManager.getDownloadUrl(fileName, false) : null); data.put("referenceData", referenceData); data.put("path", fileName); + data.put("link", DocumentManager.getServerUrl(false) + "/EditorServlet?fileName=" + fileName); if (DocumentManager.tokenEnabled()) { String token = DocumentManager.createToken(data); diff --git a/web/documentserver-example/java/src/main/webapp/editor.jsp b/web/documentserver-example/java/src/main/webapp/editor.jsp index e90821d62..a93dedc59 100644 --- a/web/documentserver-example/java/src/main/webapp/editor.jsp +++ b/web/documentserver-example/java/src/main/webapp/editor.jsp @@ -165,15 +165,41 @@ } }; + var onRequestOpen = function(event) { // user open external data source + innerAlert("onRequestOpen"); + var windowName = event.data.windowName; + + requestReference(event.data, function (data) { + if (data.error) { + var winEditor = window.open("", windowName); + winEditor.close(); + innerAlert(data.error, true); + return; + } + + var link = data.link; + window.open(link, windowName); + }); + }; + var onRequestReferenceData = function(event) { // user refresh external data source - event.data.directUrl = !!config.document.directUrl; + innerAlert("onRequestReferenceData"); + requestReference(event.data, function (data) { + docEditor.setReferenceData(data); + }); + }; + + var requestReference = function(data, callback) { + innerAlert(data); + data.directUrl = !!config.document.directUrl; + let xhr = new XMLHttpRequest(); xhr.open("POST", "IndexServlet?type=reference"); xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify(event.data)); + xhr.send(JSON.stringify(data)); xhr.onload = function () { innerAlert(xhr.responseText); - docEditor.setReferenceData(JSON.parse(xhr.responseText)); + callback(JSON.parse(xhr.responseText)); } }; @@ -277,6 +303,8 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; + // add link to reference data source file + config.events['onRequestOpen'] = onRequestOpen; } if (config.editorConfig.createUrl) { From 67000fd0ed0e50bd581d77906f199fbd7697a31d Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Thu, 26 Oct 2023 16:32:41 +0300 Subject: [PATCH 183/488] nodejs: avatar to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0728c1e89..be5781686 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- nodejs: user avatar - trimming long name of uploading file - nodejs: link in referenceData - onRequestSelectDocument method From 73c60fba7d4185b6b2b5d354f23bd8a54585403b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 26 Oct 2023 16:45:32 +0300 Subject: [PATCH 184/488] ruby: onRequestOpen for referenceData source file --- .../ruby/app/controllers/home_controller.rb | 3 +- .../ruby/app/views/home/editor.html.erb | 36 ++++++++++++++++--- .../ruby/compose-base.yml | 2 +- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 5bb3bd4ed..f02ab2b1a 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -416,7 +416,8 @@ def reference :instanceId => DocumentHelper.get_server_url(false), :fileKey => {:fileName => fileName,:userAddress => DocumentHelper.cur_user_host_address(nil)}.to_json }, - :path => fileName + :path => fileName, + :link => DocumentHelper.get_server_url(false) + '/editor?fileName=' + fileName } if JwtHelper.is_enabled diff --git a/web/documentserver-example/ruby/app/views/home/editor.html.erb b/web/documentserver-example/ruby/app/views/home/editor.html.erb index 7fd218ec4..79983ebde 100755 --- a/web/documentserver-example/ruby/app/views/home/editor.html.erb +++ b/web/documentserver-example/ruby/app/views/home/editor.html.erb @@ -155,17 +155,43 @@ } }; - var onRequestReferenceData = function(event) { // user refresh external data source + var onRequestOpen = function(event) { // user open external data source + innerAlert("onRequestOpen"); + var windowName = event.data.windowName; - event.data.directUrl = !!config.document.directUrl; + requestReference(event.data, function (data) { + if (data.error) { + var winEditor = window.open("", windowName); + winEditor.close(); + innerAlert(data.error, true); + return; + } + var link = data.link; + window.open(link, windowName); + }); + }; + + var onRequestReferenceData = function(event) { // user refresh external data source + innerAlert("onRequestReferenceData"); + + requestReference(event.data, function (data) { + docEditor.setReferenceData(data); + }); + }; + + var requestReference = function(data, callback) { + innerAlert(data); + + data.directUrl = !!config.document.directUrl; let xhr = new XMLHttpRequest(); xhr.open("POST", "reference"); xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify(event.data)); + xhr.send(JSON.stringify(data)); xhr.onload = function () { innerAlert(xhr.responseText); - docEditor.setReferenceData(JSON.parse(xhr.responseText)); + callback(JSON.parse(xhr.responseText)); } + }; function onRequestRestore(event) { @@ -245,6 +271,8 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; + // add link to reference data source file + config.events['onRequestOpen'] = onRequestOpen; } if (config.editorConfig.createUrl) { diff --git a/web/documentserver-example/ruby/compose-base.yml b/web/documentserver-example/ruby/compose-base.yml index a09574589..f47d78820 100644 --- a/web/documentserver-example/ruby/compose-base.yml +++ b/web/documentserver-example/ruby/compose-base.yml @@ -3,7 +3,7 @@ version: "3.8" services: document-server: container_name: document-server - image: onlyoffice/documentserver:7.3.3.50 + image: onlyoffice/documentserver:7.5 expose: - "80" environment: From 8b5a2aceb0afeadbdaa3e632f64ca37abec2fb71 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 26 Oct 2023 17:11:29 +0300 Subject: [PATCH 185/488] deleted comments that duplicate the context --- web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx | 1 - web/documentserver-example/csharp/DocEditor.aspx | 1 - .../java-spring/src/main/resources/templates/editor.html | 1 - web/documentserver-example/java/src/main/webapp/editor.jsp | 1 - web/documentserver-example/python/templates/editor.html | 1 - web/documentserver-example/ruby/app/views/home/editor.html.erb | 1 - 6 files changed, 6 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx index 4e2cacc2c..dccaf5e1c 100644 --- a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx +++ b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx @@ -311,7 +311,6 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; - // add link to reference data source file config.events['onRequestOpen'] = onRequestOpen; } diff --git a/web/documentserver-example/csharp/DocEditor.aspx b/web/documentserver-example/csharp/DocEditor.aspx index f7c92b2b3..d9ca694a3 100644 --- a/web/documentserver-example/csharp/DocEditor.aspx +++ b/web/documentserver-example/csharp/DocEditor.aspx @@ -316,7 +316,6 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; - // add link to reference data source file config.events['onRequestOpen'] = onRequestOpen; } diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html index 774be409c..4aa1d3ffa 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html @@ -302,7 +302,6 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; - // add link to reference data source file config.events['onRequestOpen'] = onRequestOpen; } diff --git a/web/documentserver-example/java/src/main/webapp/editor.jsp b/web/documentserver-example/java/src/main/webapp/editor.jsp index a93dedc59..ee034a3da 100644 --- a/web/documentserver-example/java/src/main/webapp/editor.jsp +++ b/web/documentserver-example/java/src/main/webapp/editor.jsp @@ -303,7 +303,6 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; - // add link to reference data source file config.events['onRequestOpen'] = onRequestOpen; } diff --git a/web/documentserver-example/python/templates/editor.html b/web/documentserver-example/python/templates/editor.html index f2297b516..19687cf98 100755 --- a/web/documentserver-example/python/templates/editor.html +++ b/web/documentserver-example/python/templates/editor.html @@ -287,7 +287,6 @@ // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; - // add link to reference data source file config.events['onRequestOpen'] = onRequestOpen; } diff --git a/web/documentserver-example/ruby/app/views/home/editor.html.erb b/web/documentserver-example/ruby/app/views/home/editor.html.erb index 79983ebde..be699fe24 100755 --- a/web/documentserver-example/ruby/app/views/home/editor.html.erb +++ b/web/documentserver-example/ruby/app/views/home/editor.html.erb @@ -271,7 +271,6 @@ config.events['onRequestReferenceData'] = onRequestReferenceData; // prevent switch the document from the viewing into the editing mode for anonymous users config.events['onRequestEditRights'] = onRequestEditRights; - // add link to reference data source file config.events['onRequestOpen'] = onRequestOpen; } From 880423545fc0c1f21b004e1c8121a319809f4b72 Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Fri, 27 Oct 2023 09:16:04 +0400 Subject: [PATCH 186/488] php: update readme --- web/documentserver-example/php/README.md | 227 +++++------------------ 1 file changed, 50 insertions(+), 177 deletions(-) diff --git a/web/documentserver-example/php/README.md b/web/documentserver-example/php/README.md index 6c2572b78..d049b4596 100644 --- a/web/documentserver-example/php/README.md +++ b/web/documentserver-example/php/README.md @@ -1,212 +1,85 @@ ## Overview -This example will help you integrate ONLYOFFICE Docs into your web application written in PHP. +This example will help you integrate ONLYOFFICE Docs into your web application written on PHP. -**Please note**: It is intended for testing purposes and demonstrating functionality of the editors. Do NOT use this integration example on your own server without proper code modifications! In case you enabled the test example, disable it before going for production. +> [!WARNING] +> It is intended for testing purposes and demonstrating functionality of the editors. **DO NOT** use this integration example on your own server without proper code modifications. In case you enabled the test example, disable it before going for production. -## For Windows +## Installation -### Step 1. Install ONLYOFFICE Docs +The PHP example offers various installation options, but we highly recommend using Docker for this purpose. -Download and install ONLYOFFICE Docs (packaged as Document Server). +### Using Docker -See the detailed guide to learn how to [install Document Server for Windows](https://helpcenter.onlyoffice.com/installation/docs-developer-install-windows.aspx?from=api_php_example). +To run the example using [Docker](https://docker.com), you will need [Docker Desktop 4.17.0](https://docs.docker.com/desktop) or [Docker Engine 20.10.23](https://docs.docker.com/engine) with [Docker Compose 2.15.1](https://docs.docker.com/compose). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools. -### Step 2. Download the PHP code for the editors integration - -Download the [PHP example](https://api.onlyoffice.com/editors/demopreview) from our site. - -To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *config.json* file: +Once you have everything installed, download the release archive and unarchive it. +```sh +$ curl --output PHP.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/latest/download/PHP.Example.zip +$ unzip PHP.Example.zip ``` -"storagePath" = ""; -"docServSiteUrl" = "https://documentserver/"; -``` - -where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storagePath** is the path where files will be created and stored. You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator. - -If you want to experiment with the editor configuration, modify the [parameters](https://api.onlyoffice.com/editors/advanced) in the *doceditor.php* file. - -### Step 3. Install the prerequisites - -You can use any web server capable of running PHP code to run the example. We will demonstrate how to run the PHP example using the **Internet Information Services (IIS)** web server. To set up and configure PHP on IIS, **PHP Manager for IIS** will be used. - -* **IIS**: version 7 or later (refer to [Microsoft official website](https://www.iis.net/learn/application-frameworks/scenario-build-a-php-website-on-iis/configuring-step-1-install-iis-and-php) to learn how to install IIS); -* **PHP** (download it from the [http://php.net](https://php.net/downloads.php) site); -* **PHP Manager for IIS** (download it from the [Microsoft open source site](https://www.iis.net/downloads/community/2018/05/php-manager-150-for-iis-10)). -* **Composer** (download it from the [Composer official website](https://getcomposer.org/download/)). - -### Step 4. IIS configuration - -1. **PHP Manager for IIS** configuration. - - After PHP Manager for IIS installation is complete, launch the **IIS Manager:** - - **Start** -> **Control Panel** -> **System and Security** -> **Administrative Tools** -> **Internet Information Services (IIS) Manager** - - and find the **PHP Manager** feature in the **Features View** in IIS. - - ![manager](screenshots/manager.png) - - You need to register the installed PHP version in IIS using PHP Manager. - - Double-click **PHP Manager** to open it, click the **Register new PHP version** task and specify the full path to the main PHP executable file location. For example: *C:\Program Files\PHP\php-cgi.exe*. - ![php-version-1](screenshots/php-version-1.jpg) +Then open the example directory and [up containers](./Makefile#L60). - After clicking **OK**, the new **PHP version** will be registered with IIS and will become active. - - ![php-version-2](screenshots/php-version-2.jpg) - -2. Configure IIS to handle PHP requests. - - For IIS to host PHP applications, you must add handler mapping that tells IIS to pass all the PHP-specific requests to the PHP application framework by using the **FastCGI** protocol. - - Double-click the **Handler Mappings** feature: - - ![handlerclick](screenshots/handlerclick.png) - - In the **Action** panel, click **Add Module Mapping**. In the **Add Module Mapping** dialog box, specify the configuration settings as follows: - - * **Request path**: *.php, - * **Module**: FastCgiModule, - * **Executable**: "C:\[Path to your PHP installation]\php-cgi.exe", - * **Name**: PHP via FastCGI. - - Click **OK**. - - ![handler-add](screenshots/handler-add.png) - - After IIS manager configuration is complete, everything is ready for running the PHP example. - -### Step 5. Run *composer install*: - - ``` - php composer.phar install - ``` +```sh +$ cd "PHP Example" +$ make compose-prod +``` -### Step 6. Run your website with the editors +By default, the server starts at `localhost:80`. -1. Add your website in the IIS Manager. +To configure the example, you can edit the environment variables in [`compose-base.yml`](./compose-base.yml). See [below](#configuration) for more information about environment variables. - On the **Connections** panel right-click the **Sites** node in the tree, then click **Add Website**. +### On Local Machine - ![add](screenshots/add.png) +Before diving into the example, you will need to install ONLYOFFICE Document Server (also known as Docs). Check the detailed guide to learn how to install it on [Windows](https://helpcenter.onlyoffice.com/installation/docs-developer-install-windows.aspx), [Linux](https://helpcenter.onlyoffice.com/installation/docs-developer-install-ubuntu.aspx), or [Docker](https://helpcenter.onlyoffice.com/installation/docs-developer-install-docker.aspx). -2. In the **Add Website** dialog box, specify the name of the folder with the PHP project in the **Site name** box. +To run the example on your local machine, you will need [PHP 8.2.11](https://php.net) with [Composer 2.6.5](https://getcomposer.org). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools. - Specify the path to the folder with your project in the **Physical path** box. +Once you have everything installed, download the release archive and unarchive it. - Specify the unique value used only for this website in the **Port** box. +```sh +$ curl --output PHP.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/latest/download/PHP.Example.zip +$ unzip PHP.Example.zip +``` - ![php-add](screenshots/php-add.png) +Then open the example directory, [install dependencies](./Makefile#L16), and [start the server](./Makefile#L40). -3. Browse your website with the IIS manager: +```sh +$ cd "PHP Example" +$ make prod +$ make server-prod +``` - Right-click the site -> **Manage Website** -> **Browse** +By default, the server starts at `0.0.0.0:9000`. - ![browse](screenshots/browse.png) +To configure the example, you can pass the environment variables before the command that starts the server. See [below](#configuration) for more information about environment variables. -### Step 7. Check accessibility +## Post Installation In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files. Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files. -## For Linux +## Configuration -### Step 1. Install ONLYOFFICE Docs +The example is configured by changing environment variables. -Download and install ONLYOFFICE Docs (packaged as Document Server). - -See the detailed guide to learn how to [install Document Server for Linux](https://helpcenter.onlyoffice.com/installation/docs-developer-install-ubuntu.aspx?from=api_php_example). - -### Step 2. Install the prerequisites and run the website with the editors - -1. Install **Apache** and **PHP**: - - ``` - apt-get install -y apache2 php7.0 libapache2-mod-php7.0 - ``` - -2. Install **Composer**: - - To install composer globally, use the following command which will download and install Composer as a system-wide command named composer, under /usr/local/bin: - - ``` - curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php - sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer - ``` - -3. Download the archive with the PHP example and unpack the archive: - - ``` - cd /var/www/html - ``` - - ``` - wget https://api.onlyoffice.com/app_data/editor/PHP.Example.zip - ``` - - ``` - unzip PHP.Example.zip - ``` - -4. Change the current directory for the project directory: - - ``` - cd PHP\ Example/ - ``` - -5. Edit the *config.json* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed. - - ``` - nano config.json - ``` - - Edit the following lines: - - ``` - "storagePath" = ""; - "docServSiteUrl" = "https://documentserver/"; - ``` - - where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **STORAGE_PATH** is the path where files will be created and stored. You can set an absolute path. - -6. Run *composer install*: - - ``` - php composer.phar install - ``` -7. Set permission for site: - - ``` - chown -R www-data:www-data /var/www/html - ``` - -8. Restart apache: - - ``` - service apache2 restart - ``` - -9. See the result in your browser using the address: - - ``` - http://localhost/PHP%20Example/ - ``` - -### Step 3. Check accessibility - -In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files. - -Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files. +| Name | Description | Example | +| ----------------------------- | ----------------------------------------------------------------------- | ----------------------- | +| `ADDRESS` | The address where the server should be started. | `0.0.0.0` | +| `PORT` | The port on which the server should be running. | `80` | +| `DOCUMENT_SERVER_PRIVATE_URL` | The URL through which the server will communicate with Document Server. | `http://proxy:8080` | +| `DOCUMENT_SERVER_PUBLIC_URL` | The URL through which a user will communicate with Document Server. | `http://localhost:8080` | +| `EXAMPLE_URL` | The URL through which Document Server will communicate with the server. | `http://proxy` | +| `JWT_SECRET` | JWT authorization secret. Leave blank to disable authorization. | `your-256-bit-secret` | -## Important security info +## Security Info Please keep in mind the following security aspects when you are using test examples: -* There is no protection of the storage from unauthorized access since there is no need for authorization. -* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts. -* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server. -* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain. \ No newline at end of file +- There is no protection of the storage from unauthorized access since there is no need for authorization. +- There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts. +- There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server. +- There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain. From 6aa57e3dfb6bd420c36a3aae5bfbceafd9e61f5c Mon Sep 17 00:00:00 2001 From: vanyauhalin Date: Fri, 27 Oct 2023 09:15:01 +0400 Subject: [PATCH 187/488] php: bump php version and pin composer version --- web/documentserver-example/php/.composer-version | 1 + web/documentserver-example/php/.php-version | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 web/documentserver-example/php/.composer-version diff --git a/web/documentserver-example/php/.composer-version b/web/documentserver-example/php/.composer-version new file mode 100644 index 000000000..57cf282eb --- /dev/null +++ b/web/documentserver-example/php/.composer-version @@ -0,0 +1 @@ +2.6.5 diff --git a/web/documentserver-example/php/.php-version b/web/documentserver-example/php/.php-version index dc16c14d2..770d52b60 100644 --- a/web/documentserver-example/php/.php-version +++ b/web/documentserver-example/php/.php-version @@ -1 +1 @@ -8.1.21 +8.2.11 From 36463aae8cb5f0245dc238dccd53bf7515a1e577 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 27 Oct 2023 11:28:00 +0300 Subject: [PATCH 188/488] nodejs: return external link in reference request --- web/documentserver-example/nodejs/app.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 4bf86a3d9..e10b0d48e 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -500,8 +500,11 @@ app.post('/reference', (req, res) => { // define a handler for renaming file } if (!fileName && !!req.body.link) { - if (req.body.link.indexOf(req.DocManager.curUserHostAddress()) !== -1) { - result({ error: 'You do not have access to this site' }); + if (req.body.link.indexOf(req.DocManager.curUserHostAddress()) === -1) { + result({ + url: req.body.link, + directUrl: req.body.link, + }); return; } From 1ab93ccb2879bf9beb89bbe067c14a1ffd6cc217 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 27 Oct 2023 11:44:46 +0300 Subject: [PATCH 189/488] nodejs: fix searching server address (969a8c6cfe3508b83b48c5f5f147bec1c3fd0899) --- web/documentserver-example/nodejs/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index e10b0d48e..1a0378e4b 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -500,7 +500,7 @@ app.post('/reference', (req, res) => { // define a handler for renaming file } if (!fileName && !!req.body.link) { - if (req.body.link.indexOf(req.DocManager.curUserHostAddress()) === -1) { + if (req.body.link.indexOf(req.DocManager.getServerUrl()) === -1) { result({ url: req.body.link, directUrl: req.body.link, From 4f0e00b59767e332a86f9b11ad69d8197f63dc0f Mon Sep 17 00:00:00 2001 From: Natalia Date: Fri, 27 Oct 2023 11:49:12 +0300 Subject: [PATCH 190/488] fixed the file name --- web/documentserver-example/php/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/php/README.md b/web/documentserver-example/php/README.md index d049b4596..f2df1ccc2 100644 --- a/web/documentserver-example/php/README.md +++ b/web/documentserver-example/php/README.md @@ -29,7 +29,7 @@ $ make compose-prod By default, the server starts at `localhost:80`. -To configure the example, you can edit the environment variables in [`compose-base.yml`](./compose-base.yml). See [below](#configuration) for more information about environment variables. +To configure the example, you can edit the environment variables in [`docker-compose.yml`](./docker-compose.yml). See [below](#configuration) for more information about environment variables. ### On Local Machine From ace724bc212c699f4044f86b1ab7d8cc96b062e9 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Fri, 27 Oct 2023 18:03:13 +0700 Subject: [PATCH 191/488] ruby: setUsers for region protection --- CHANGELOG.md | 1 + .../ruby/app/models/file_model.rb | 5 +++++ .../ruby/app/models/users.rb | 12 +++++++++++- .../ruby/app/views/home/editor.html.erb | 17 ++++++++++++++--- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0728c1e89..fde291818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- ruby: setUsers for region protection - trimming long name of uploading file - nodejs: link in referenceData - onRequestSelectDocument method diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 65ce0d979..7c1129aef 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -350,6 +350,11 @@ def get_users_mentions return !@user.id.eql?("uid-0") ? Users.get_users_for_mentions(@user.id) : nil end + # get users data for protect + def get_users_protect + return !@user.id.eql?("uid-0") ? Users.get_users_for_protect(@user.id) : nil + end + # get direct url existence flag def is_enable_direct_url return @direct_url != nil && @direct_url == "true" diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index a6acbc462..e8a3cfaf7 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -91,7 +91,7 @@ class Users }, ["group-2", ""], true, [], @@descr_user_2, false), - User.new("uid-3", "Hamish Mitchell", "mitchell@example.com", + User.new("uid-3", "Hamish Mitchell", nil, "group-3", ["group-2"], { :view => ["group-3", "group-2"], :edit => ["group-2"], @@ -128,6 +128,16 @@ def get_users_for_mentions(id) # get a list of users with their names and email return usersData end + def get_users_for_protect(id) # get a list of users with their id, names and emails for protect + users_data = [] + for user in @@users do + if (!user.id.eql?(id) && user.name != nil) + users_data.push({id: user.id, name: user.name, email: user.email}) + end + end + return users_data + end + end end diff --git a/web/documentserver-example/ruby/app/views/home/editor.html.erb b/web/documentserver-example/ruby/app/views/home/editor.html.erb index 7fd218ec4..23d1b82dc 100755 --- a/web/documentserver-example/ruby/app/views/home/editor.html.erb +++ b/web/documentserver-example/ruby/app/views/home/editor.html.erb @@ -229,9 +229,20 @@ }; <% end %> // add mentions for not anonymous users - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%= raw @file.get_users_mentions.to_json %> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "protect": + var users = <%= raw @file.get_users_protect.to_json %>; + break; + default: + users = <%= raw @file.get_users_mentions.to_json %>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; // the user is mentioned in a comment From eaf02452160a2d493dc6927b8f3bfc412592a261 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Fri, 27 Oct 2023 18:22:46 +0700 Subject: [PATCH 192/488] python: setUsers for region protection --- CHANGELOG.md | 1 + .../python/src/utils/users.py | 10 +++++++++- .../python/src/views/actions.py | 5 ++++- .../python/templates/editor.html | 19 +++++++++++++++---- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fde291818..7b4b7ee89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- python: setUsers for region protection - ruby: setUsers for region protection - trimming long name of uploading file - nodejs: link in referenceData diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index ad84024e5..de855893c 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -90,7 +90,7 @@ def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfo }, ['group-2', ''], True, [], descr_user_2, False), - User('uid-3', 'Hamish Mitchell', 'mitchell@example.com', + User('uid-3', 'Hamish Mitchell', None, 'group-3', ['group-2'], { 'view': ["group-3", "group-2"], 'edit': ["group-2"], @@ -126,6 +126,14 @@ def getUsersForMentions(uid): usersData.append({'name':user.name, 'email':user.email}) return usersData +# get users data for protect +def getUsersForProtect(uid): + usersData = [] + for user in USERS: + if(user.id != uid and user.name != None): + usersData.append({'id': user.id, 'name': user.name, 'email': user.email}) + return usersData + def find_user(id: Optional[str]) -> User: if id is None: return DEFAULT_USER diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 10b6f010f..e51967361 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -322,6 +322,8 @@ def edit(request): # users data for mentions usersForMentions = users.getUsersForMentions(user.id) + # users data for protect + usersForProtect = users.getUsersForProtect(user.id) if jwtManager.isEnabled(): # if the secret key to generate token exists edConfig['token'] = jwtManager.encode(edConfig) # encode the edConfig object into a token @@ -340,7 +342,8 @@ def edit(request): 'dataInsertImage': json.dumps(dataInsertImage)[1 : len(json.dumps(dataInsertImage)) - 1], # the image which will be inserted into the document 'dataDocument': dataDocument, # document which will be compared with the current document 'dataSpreadsheet': json.dumps(dataSpreadsheet), # recipient data for mail merging - 'usersForMentions': json.dumps(usersForMentions) if user.id !='uid-0' else None + 'usersForMentions': json.dumps(usersForMentions) if user.id !='uid-0' else None, + 'usersForProtect': json.dumps(usersForProtect) if user.id !='uid-0' else None } return render(request, 'editor.html', context) # execute the "editor.html" template with context data diff --git a/web/documentserver-example/python/templates/editor.html b/web/documentserver-example/python/templates/editor.html index 722bf0d6e..e71c72ac1 100755 --- a/web/documentserver-example/python/templates/editor.html +++ b/web/documentserver-example/python/templates/editor.html @@ -248,10 +248,21 @@ {% endif %} // add mentions for not anonymous users - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": {{ usersForMentions | safe }} - }); + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "protect": + var users = {{ usersForProtect | safe }}; + break; + default: + users = {{ usersForMentions | safe }}; + } + docEditor.setUsers({ + "c": c, + "users": users, + }) }; // the user is mentioned in a comment config.events['onRequestSendNotify'] = function (event) { From c2bb7985de31dea21855786a956b72251156a63e Mon Sep 17 00:00:00 2001 From: sshakndr Date: Fri, 27 Oct 2023 18:42:16 +0700 Subject: [PATCH 193/488] php: setUsers for region protection --- CHANGELOG.md | 1 + .../php/src/helpers/ExampleUsers.php | 24 ++++++++++++++++++- .../php/src/views/DocEditorView.php | 20 +++++++++++++--- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b4b7ee89..a17bde498 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- php: setUsers for region protection - python: setUsers for region protection - ruby: setUsers for region protection - trimming long name of uploading file diff --git a/web/documentserver-example/php/src/helpers/ExampleUsers.php b/web/documentserver-example/php/src/helpers/ExampleUsers.php index cf1e3a0f8..87e42289e 100644 --- a/web/documentserver-example/php/src/helpers/ExampleUsers.php +++ b/web/documentserver-example/php/src/helpers/ExampleUsers.php @@ -106,7 +106,7 @@ public function __construct() new Users( "uid-3", "Hamish Mitchell", - "mitchell@example.com", + null, "group-3", ["group-2"], [ @@ -184,4 +184,26 @@ public function getUsersForMentions(?string $id): array } return $usersData; } + + /** + * Get a list of users with their names and emails for protect + * + * @param string|null $id + * + * @return array + */ + public function getUsersForProtect(?string $id): array + { + $usersData = []; + foreach ($this->users as $user) { + if ($user->id != $id && $user->name != null) { + $usersData[] = [ + "id" => $user->id, + "name" => $user->name, + "email" => $user->email, + ]; + } + } + return $usersData; + } } diff --git a/web/documentserver-example/php/src/views/DocEditorView.php b/web/documentserver-example/php/src/views/DocEditorView.php index 89f29b195..9fbbb120e 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -220,6 +220,8 @@ public function __construct($request, $tempName = "docEditor") // users data for mentions $usersForMentions = $user->id != "uid-0" ? $userList->getUsersForMentions($user->id) : null; + // users data for protect + $usersForProtect = $user->id != "uid-0" ? $userList->getUsersForProtect($user->id) : null; // check if the secret key to generate token exists if ($jwtManager->isJwtEnabled()) { @@ -249,9 +251,20 @@ public function __construct($request, $tempName = "docEditor") };"; } $historyLayout .= "// add mentions for not anonymous users - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - \"users\": {usersForMentions} + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case \"protect\": + var users = {usersForProtect}; + break; + default: + users = {usersForMentions}; + } + docEditor.setUsers({ + \"c\": c, + \"users\": users, }); }; // the user is mentioned in a comment @@ -279,6 +292,7 @@ public function __construct($request, $tempName = "docEditor") "config" => json_encode($config), "history" => $historyLayout, "usersForMentions" => json_encode($usersForMentions), + "usersForProtect" => json_encode($usersForProtect), ]; } } From 043fb2c0cff32491bc64c7d3cb342cedee68de74 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Fri, 27 Oct 2023 16:49:54 +0300 Subject: [PATCH 194/488] returned documentserver version 7.3.3.50 to compose --- web/documentserver-example/php/docker-compose.yml | 2 +- web/documentserver-example/ruby/compose-base.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/php/docker-compose.yml b/web/documentserver-example/php/docker-compose.yml index 9ff37c3d9..1b9d75e21 100644 --- a/web/documentserver-example/php/docker-compose.yml +++ b/web/documentserver-example/php/docker-compose.yml @@ -3,7 +3,7 @@ version: "3.8" services: document-server: container_name: document-server - image: onlyoffice/documentserver:latest + image: onlyoffice/documentserver:7.3.3.50 expose: - "80" environment: diff --git a/web/documentserver-example/ruby/compose-base.yml b/web/documentserver-example/ruby/compose-base.yml index f47d78820..a09574589 100644 --- a/web/documentserver-example/ruby/compose-base.yml +++ b/web/documentserver-example/ruby/compose-base.yml @@ -3,7 +3,7 @@ version: "3.8" services: document-server: container_name: document-server - image: onlyoffice/documentserver:7.5 + image: onlyoffice/documentserver:7.3.3.50 expose: - "80" environment: From f5016120675df63af1b33cee7689edb5d8f09781 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 30 Oct 2023 14:15:09 +0700 Subject: [PATCH 195/488] java-spring: setUsers for region protection --- CHANGELOG.md | 1 + .../onlyoffice/integration/ExampleData.java | 2 +- .../controllers/EditorController.java | 20 ++++++++++++ .../onlyoffice/integration/dto/Protect.java | 32 +++++++++++++++++++ .../src/main/resources/templates/editor.html | 18 +++++++++-- 5 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Protect.java diff --git a/CHANGELOG.md b/CHANGELOG.md index a17bde498..c77ed5f3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- java-spring: setUsers for region protection - php: setUsers for region protection - python: setUsers for region protection - ruby: setUsers for region protection diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java index 6fe3c3aea..3fe484998 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java @@ -102,7 +102,7 @@ public void init() { true); // create user 3 with the specified parameters - userService.createUser("Hamish Mitchell", "mitchell@example.com", descriptionUserThird, + userService.createUser("Hamish Mitchell", null, descriptionUserThird, "group-3", List.of("group-2"), List.of("group-2", "group-3"), List.of("group-2"), new ArrayList<>(), List.of("group-2"), false, true, true); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java index d87321a81..9c1836552 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java @@ -25,6 +25,7 @@ import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; import com.onlyoffice.integration.entities.User; import com.onlyoffice.integration.dto.Mentions; +import com.onlyoffice.integration.dto.Protect; import com.onlyoffice.integration.documentserver.models.enums.Type; import com.onlyoffice.integration.documentserver.models.filemodel.FileModel; import com.onlyoffice.integration.services.UserServices; @@ -150,6 +151,9 @@ public String index(@RequestParam("fileName") final String fileName, // get user data for mentions and add it to the model model.addAttribute("usersForMentions", getUserMentions(uid)); + + // get user data for protect and add it to the model + model.addAttribute("usersForProtect", getUserProtect(uid)); return "editor.html"; } @@ -169,6 +173,22 @@ private List getUserMentions(final String uid) { // get user data for return usersForMentions; } + private List getUserProtect(final String uid) { // get user data for protect + List usersForProtect = new ArrayList<>(); + if (uid != null && !uid.equals("4")) { + List list = userService.findAll(); + for (User u : list) { + if (u.getId() != Integer.parseInt(uid) && u.getId() != ANONYMOUS_USER_ID) { + + // user data includes user names, IDs and emails + usersForProtect.add(new Protect(u.getId(), u.getName(), u.getEmail())); + } + } + } + + return usersForProtect; + } + @SneakyThrows private String getInsertImage(final Boolean directUrl) { // get an image that will be inserted into the document Map dataInsertImage = new HashMap<>(); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Protect.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Protect.java new file mode 100644 index 000000000..1d8b5d325 --- /dev/null +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Protect.java @@ -0,0 +1,32 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.onlyoffice.integration.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +public class Protect { + private Integer id; + private String name; + private String email; +} diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html index 3694fc328..cda31f795 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html @@ -255,12 +255,24 @@ }; var usersForMentions = [[${usersForMentions}]]; + var usersForProtect = [[${usersForProtect}]]; if (config.editorConfig.user.id != 4) { // add mentions for not anonymous users - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": usersForMentions + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "protect": + var users = usersForProtect; + break; + default: + users = usersForMentions; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; // the user is mentioned in a comment From b8c6f72e74a4f97aeb2a780932e5cd5b042217be Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 30 Oct 2023 14:38:45 +0700 Subject: [PATCH 196/488] java: setUsers for region protection --- CHANGELOG.md | 1 + .../main/java/controllers/EditorServlet.java | 3 +++ .../java/src/main/java/helpers/Users.java | 17 ++++++++++++++++- .../java/src/main/webapp/editor.jsp | 18 +++++++++++++++--- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c77ed5f3c..d6b0f31fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- java: setUsers for region protection - java-spring: setUsers for region protection - php: setUsers for region protection - python: setUsers for region protection diff --git a/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java b/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java index 2f6e65f27..9f8a022d1 100644 --- a/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java @@ -106,6 +106,7 @@ protected void processRequest(final HttpServletRequest request, // users data for mentions List> usersForMentions = Users.getUsersForMentions(user.getId()); + List> usersForProtect = Users.getUsersForProtect(user.getId()); // check if the document token is enabled if (DocumentManager.tokenEnabled()) { @@ -131,6 +132,8 @@ protected void processRequest(final HttpServletRequest request, request.setAttribute("dataSpreadsheet", gson.toJson(dataSpreadsheet)); request.setAttribute("usersForMentions", !user.getId() .equals("uid-0") ? gson.toJson(usersForMentions) : null); + request.setAttribute("usersForProtect", !user.getId() + .equals("uid-0") ? gson.toJson(usersForProtect) : null); request.getRequestDispatcher("editor.jsp").forward(request, response); } diff --git a/web/documentserver-example/java/src/main/java/helpers/Users.java b/web/documentserver-example/java/src/main/java/helpers/Users.java index 173802f4a..8f2c30b9e 100755 --- a/web/documentserver-example/java/src/main/java/helpers/Users.java +++ b/web/documentserver-example/java/src/main/java/helpers/Users.java @@ -84,7 +84,7 @@ public final class Users { "group-2", Arrays.asList("group-2", ""), new CommentGroups(null, Arrays.asList("group-2", ""), Arrays.asList("group-2")), Arrays.asList("group-2", ""), true, new ArrayList(), descriptionUserSecond, false)); - add(new User("uid-3", "Hamish Mitchell", "mitchell@example.com", + add(new User("uid-3", "Hamish Mitchell", null, "group-3", Arrays.asList("group-2"), new CommentGroups(Arrays.asList("group-3", "group-2"), Arrays.asList("group-2"), null), Arrays.asList("group-2"), false, Arrays.asList("copy", "download", "print"), @@ -124,5 +124,20 @@ public static List> getUsersForMentions(final String id) { } return usersData; } + + // get a list of users with their names and emails for protect + public static List> getUsersForProtect(final String id) { + List> usersData = new ArrayList<>(); + for (User user : users) { + if (!user.getId().equals(id) && user.getName() != null) { + Map data = new HashMap<>(); + data.put("name", user.getName()); + data.put("email", user.getEmail()); + data.put("id", user.getId()); + usersData.add(data); + } + } + return usersData; + } } diff --git a/web/documentserver-example/java/src/main/webapp/editor.jsp b/web/documentserver-example/java/src/main/webapp/editor.jsp index e90821d62..31ee7c34d 100644 --- a/web/documentserver-example/java/src/main/webapp/editor.jsp +++ b/web/documentserver-example/java/src/main/webapp/editor.jsp @@ -257,13 +257,25 @@ <% String usersForMentions = (String) request.getAttribute("usersForMentions"); + String usersForProtect = (String) request.getAttribute("usersForProtect"); %> if (config.editorConfig.user.id) { // add mentions for not anonymous users - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%=usersForMentions%> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "protect": + var users = <%=usersForProtect%>; + break; + default: + users = <%=usersForMentions%>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; // the user is mentioned in a comment From 7666394f1df8a8773c1bdc1ab02de4a5e1520232 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 30 Oct 2023 15:28:45 +0700 Subject: [PATCH 197/488] csharp-mvc: setUsers for region protection --- CHANGELOG.md | 1 + .../csharp-mvc/Helpers/Users.cs | 21 ++++++++++++++++++- .../csharp-mvc/Models/FileModel.cs | 9 ++++++++ .../csharp-mvc/Views/Home/Editor.aspx | 19 ++++++++++++++--- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b0f31fb..a645ccddf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp-mvc: setUsers for region protection - java: setUsers for region protection - java-spring: setUsers for region protection - php: setUsers for region protection diff --git a/web/documentserver-example/csharp-mvc/Helpers/Users.cs b/web/documentserver-example/csharp-mvc/Helpers/Users.cs index 6960f0584..0ed0a9aba 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/Users.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/Users.cs @@ -108,7 +108,7 @@ public class Users new User( "uid-3", "Hamish Mitchell", - "mitchell@example.com", + null, "group-3", new List() { "group-2" }, new Dictionary() @@ -171,6 +171,25 @@ public static List> getUsersForMentions(string id) } return usersData; } + + // get a list of users with their names and emails for protect + public static List> getUsersForProtect(string id) + { + List> usersData = new List>(); + foreach (User user in users) + { + if (!user.id.Equals(id) && user.name != null) + { + usersData.Add(new Dictionary() + { + {"name", user.name }, + {"email", user.email }, + {"id", user.id} + }); + } + } + return usersData; + } } public class User diff --git a/web/documentserver-example/csharp-mvc/Models/FileModel.cs b/web/documentserver-example/csharp-mvc/Models/FileModel.cs index 14ce0f7b5..ddc0028cb 100755 --- a/web/documentserver-example/csharp-mvc/Models/FileModel.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileModel.cs @@ -372,5 +372,14 @@ public void GetUsersMentions(HttpRequest request, out string usersForMentions) var user = Users.getUser(id); usersForMentions = !user.id.Equals("uid-0") ? jss.Serialize(Users.getUsersForMentions(user.id)) : null; } + + //get a users for protect + public void GetUsersProtect(HttpRequest request, out string usersForProtect) + { + var jss = new JavaScriptSerializer(); + var id = request.Cookies.GetOrDefault("uid", null); + var user = Users.getUser(id); + usersForProtect = !user.id.Equals("uid-0") ? jss.Serialize(Users.getUsersForProtect(user.id)) : null; + } } } \ No newline at end of file diff --git a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx index 5c9ccdee9..99c2b4859 100644 --- a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx +++ b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx @@ -254,6 +254,8 @@ <% string usersForMentions; %> <% Model.GetUsersMentions(Request, out usersForMentions); %> + <% string usersForProtect; %> + <% Model.GetUsersProtect(Request, out usersForProtect); %> if (config.editorConfig.user.id) { // the user is trying to show the document version history @@ -269,9 +271,20 @@ // add mentions for not anonymous users <% if (!string.IsNullOrEmpty(usersForMentions)) { %> - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%= usersForMentions %> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "protect": + var users = <%= usersForProtect %>; + break; + default: + users = <%= usersForMentions %>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; <% } %> From 0a76dba089159dc471669c74cc2e6fd7992979cc Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 30 Oct 2023 15:45:16 +0700 Subject: [PATCH 198/488] csharp: setUsers for region protection --- CHANGELOG.md | 1 + .../csharp/DocEditor.aspx | 17 +++++++++++--- .../csharp/DocEditor.aspx.cs | 5 +++++ web/documentserver-example/csharp/Users.cs | 22 ++++++++++++++++++- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a645ccddf..ef33c238e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp: setUsers for region protection - csharp-mvc: setUsers for region protection - java: setUsers for region protection - java-spring: setUsers for region protection diff --git a/web/documentserver-example/csharp/DocEditor.aspx b/web/documentserver-example/csharp/DocEditor.aspx index 4d2540589..25a38b0b6 100644 --- a/web/documentserver-example/csharp/DocEditor.aspx +++ b/web/documentserver-example/csharp/DocEditor.aspx @@ -272,9 +272,20 @@ // add mentions for not anonymous users <% if (!string.IsNullOrEmpty(UsersForMentions)) { %> - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%= UsersForMentions %> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "protect": + var users = <%= UsersForProtect %>; + break; + default: + users = <%= UsersForMentions %>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; <% } %> diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs index 334112a9a..2184c4116 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -64,6 +64,7 @@ protected string DocServiceApiUri protected string DocumentData { get; private set; } protected string DataSpreadsheet { get; private set; } protected string UsersForMentions { get; private set; } + protected string UsersForProtect { get; private set; } protected string DocumentType { get { return _Default.DocumentType(FileName); } } // get callback url @@ -317,6 +318,10 @@ protected void Page_Load(object sender, EventArgs e) // get users for mentions List> usersData = Users.getUsersForMentions(user.id); UsersForMentions = !user.id.Equals("uid-0") ? jss.Serialize(usersData) : null; + + // get users for protect + List> usersProtectData = Users.getUsersForProtect(user.id); + UsersForProtect = !user.id.Equals("uid-0") ? jss.Serialize(usersProtectData) : null; } catch { } } diff --git a/web/documentserver-example/csharp/Users.cs b/web/documentserver-example/csharp/Users.cs index 1dea57de9..4ce7e731b 100644 --- a/web/documentserver-example/csharp/Users.cs +++ b/web/documentserver-example/csharp/Users.cs @@ -107,7 +107,7 @@ public class Users new User( "uid-3", "Hamish Mitchell", - "mitchell@example.com", + null, "group-3", new List() { "group-2" }, new Dictionary() @@ -171,6 +171,26 @@ public static List> getUsersForMentions(string id) } return usersData; } + + // get a list of users with their names and emails for protect + public static List> getUsersForProtect(string id) + { + List> usersData = new List>(); + + foreach (User user in users) + { + if (!user.id.Equals(id) && user.name != null) + { + usersData.Add(new Dictionary() + { + {"name", user.name }, + {"email", user.email }, + {"id", user.id} + }); + } + } + return usersData; + } } public class User From c78814ced4993d024358a6f9e2770a4e543a16a7 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 30 Oct 2023 16:15:57 +0700 Subject: [PATCH 199/488] removed pylint --- .github/workflows/lint-python.yml | 6 +--- web/documentserver-example/python/.pylintrc | 34 --------------------- 2 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 web/documentserver-example/python/.pylintrc diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 05a3a211d..dda9fed9a 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -27,14 +27,10 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 - pip install pylint if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint Flake8 run: | flake8 --count --select=E9,F63,F7,F82 --show-source --statistics flake8 --count --max-complexity=15 --max-line-length=120 --per-file-ignores="__init__.py:F4" --statistics - - - name: Lint Pylint - run: | - pylint ./**/*.py --rcfile=.pylintrc --disable=import-error + diff --git a/web/documentserver-example/python/.pylintrc b/web/documentserver-example/python/.pylintrc deleted file mode 100644 index 55e1ee71c..000000000 --- a/web/documentserver-example/python/.pylintrc +++ /dev/null @@ -1,34 +0,0 @@ -[MAIN] -disable=C0114, # missing-module-docstring - C0115, # missing-class-docstring - C0116, # missing-function-docstring - E0611, # no-name-in-module - R0902, # too-many-instance-attributes - R0913, # too-many-arguments - R0914, # too-many-locals - W1514, # unspecified-encoding - R1710, # inconsistent-return-statements - R1732, # consider-using-with - -[FORMAT] -max-line-length=120 - -[BASIC] -argument-naming-style=any -attr-naming-style=any -function-naming-style=any -module-naming-style=any -variable-naming-style=any - -[DESIGN] -# max-args= -# max-attributes= -max-branches=15 -# max-locals= -min-public-methods=0 - -[EXCEPTIONS] -overgeneral-exceptions = builtins.[] - -[MISCELLANEOUS] -notes = ["FIXME", "XXX"] \ No newline at end of file From 03ffae8115800d0370d43e1389875ccfe004a99c Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 31 Oct 2023 13:54:06 +0700 Subject: [PATCH 200/488] php: fix convert (50dca2e2c06596d2ccd8fec1e912e97d50170c86) --- web/documentserver-example/php/assets/js/jscript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/php/assets/js/jscript.js b/web/documentserver-example/php/assets/js/jscript.js index c24117beb..d64210431 100644 --- a/web/documentserver-example/php/assets/js/jscript.js +++ b/web/documentserver-example/php/assets/js/jscript.js @@ -108,7 +108,7 @@ if (typeof jQuery != "undefined") { } var fileName = jq("#hiddenFileName").val(); - var posExt = fileName.lastIndexOf('.'); + var posExt = fileName.lastIndexOf('.') + 1; posExt = 0 <= posExt ? fileName.substring(posExt).trim().toLowerCase() : ''; if (ConverExtList.indexOf(posExt) == -1) { From c7409e3f35f68c20395553b74b0a88a4b96146ff Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 31 Oct 2023 13:02:14 +0300 Subject: [PATCH 201/488] java-spring: added JsonIgnoreProperties annotation to ignore the "windowName" field --- .../main/java/com/onlyoffice/integration/dto/Reference.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java index 799ea7d9c..2eb7d8488 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java @@ -18,6 +18,7 @@ package com.onlyoffice.integration.dto; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -27,8 +28,8 @@ @Setter @AllArgsConstructor @NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) public class Reference { - private String windowName; private Boolean directUrl; private ReferenceData referenceData; private String path; From 09c1b9e45cf442bea5043b0f501e0c2708a30633 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 31 Oct 2023 13:28:06 +0300 Subject: [PATCH 202/488] onRequestOpen to changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05842d70b..761f5a323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +- ruby: onRequestOpen +- java-spring: onRequestOpen +- java: onRequestOpen +- csharp-mvc: onRequestOpen +- csharp: onRequestOpen +- python: onRequestOpen +- php: onRequestOpen - onRequestSelectDocument method - onRequestSelectSpreadsheet method - key in referenceData From 84824d1ed4aaad3482b2ff8c804187d5a40bc865 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 31 Oct 2023 14:26:29 +0300 Subject: [PATCH 203/488] onRequestOpen to changelog --- CHANGELOG.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01f11413b..eeaafcd45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,6 @@ # Change Log -- ruby: onRequestOpen -- java-spring: onRequestOpen -- java: onRequestOpen -- csharp-mvc: onRequestOpen -- csharp: onRequestOpen -- python: onRequestOpen -- php: onRequestOpen +- onRequestOpen method - nodejs: user avatar - trimming long name of uploading file - nodejs: link in referenceData From a5a1df45b1ce6266e7171cd5de08e88062dabb43 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 1 Nov 2023 10:18:58 +0700 Subject: [PATCH 204/488] python: user avatar --- CHANGELOG.md | 1 + .../python/src/utils/users.py | 18 +++++++----- .../python/src/views/actions.py | 16 +++++++++-- .../python/static/images/uid-1.jpg | Bin 0 -> 61966 bytes .../python/static/images/uid-2.jpg | Bin 0 -> 77760 bytes .../python/templates/editor.html | 26 ++++++++++++++++-- 6 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 web/documentserver-example/python/static/images/uid-1.jpg create mode 100644 web/documentserver-example/python/static/images/uid-2.jpg diff --git a/CHANGELOG.md b/CHANGELOG.md index 05842d70b..0d0381dad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- python: user avatar - onRequestSelectDocument method - onRequestSelectSpreadsheet method - key in referenceData diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index ad84024e5..d92edd4aa 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -19,7 +19,8 @@ from typing import Optional class User: - def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates): + def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, + deniedPermissions, descriptions, templates, avatar): self.id = id self.name = name self.email = email @@ -31,6 +32,7 @@ def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfo self.descriptions = descriptions self.templates = templates self.userInfoGroups = userInfoGroups + self.avatar = avatar descr_user_1 = [ "File author by default", @@ -39,7 +41,8 @@ def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfo "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Has an avatar" ] descr_user_2 = [ @@ -48,7 +51,8 @@ def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfo "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Has an avatar" ] descr_user_3 = [ @@ -81,7 +85,7 @@ def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfo USERS = [ User('uid-1', 'John Smith', 'smith@example.com', '', None, {}, None, - None, [], descr_user_1, True), + None, [], descr_user_1, True, True), User('uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', ['group-2', ''], { 'view': "", @@ -89,17 +93,17 @@ def __init__(self, id, name, email, group, reviewGroups, commentGroups, userInfo 'remove': ["group-2"] }, ['group-2', ''], - True, [], descr_user_2, False), + True, [], descr_user_2, False, True), User('uid-3', 'Hamish Mitchell', 'mitchell@example.com', 'group-3', ['group-2'], { 'view': ["group-3", "group-2"], 'edit': ["group-2"], 'remove': [] }, ['group-2'], - False, ["copy", "download", "print"], descr_user_3, False), + False, ["copy", "download", "print"], descr_user_3, False, False), User('uid-0', None, None, '', None, {}, [], - None, ["protect"], descr_user_0, False) + None, ["protect"], descr_user_0, False, False) ] DEFAULT_USER = USERS[0] diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 10b6f010f..7d48a24ad 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -211,6 +211,16 @@ def edit(request): } ] + usersInfo = [] + if user.id != 'uid-0': + for userInfo in users.getAllUsers(): + u = userInfo + u.image = docManager.getServerUrl(True, request) + f'/static/images/{u.id}.jpg' if user.avatar else None + usersInfo.append({"id": u.id, "name": u.name, "email": u.email, "image": u.image, "group": u.group, + "reviewGroups":u.reviewGroups, "commentGroups":u.commentGroups, "favorite": u.favorite, + "deniedPermissions": u.deniedPermissions, "descriptions": u.descriptions, + "templates": u.templates, "userInfoGroups": u.userInfoGroups, "avatar": u.avatar}) + if (meta): # if the document meta data exists, infObj = { # write author and creation time parameters to the information object 'owner': meta['uname'], @@ -269,7 +279,8 @@ def edit(request): 'user': { # the user currently viewing or editing the document 'id': user.id if user.id !='uid-0' else None, 'name': user.name, - 'group': user.group + 'group': user.group, + 'image': docManager.getServerUrl(True, request) + f'/static/images/{user.id}.jpg' if user.avatar else None }, 'embedded': { # the parameters for the embedded document type 'saveUrl': directUrl, # the absolute URL that will allow the document to be saved onto the user personal computer @@ -340,7 +351,8 @@ def edit(request): 'dataInsertImage': json.dumps(dataInsertImage)[1 : len(json.dumps(dataInsertImage)) - 1], # the image which will be inserted into the document 'dataDocument': dataDocument, # document which will be compared with the current document 'dataSpreadsheet': json.dumps(dataSpreadsheet), # recipient data for mail merging - 'usersForMentions': json.dumps(usersForMentions) if user.id !='uid-0' else None + 'usersForMentions': json.dumps(usersForMentions) if user.id !='uid-0' else None, + 'usersInfo': json.dumps(usersInfo) } return render(request, 'editor.html', context) # execute the "editor.html" template with context data diff --git a/web/documentserver-example/python/static/images/uid-1.jpg b/web/documentserver-example/python/static/images/uid-1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e981731765b8cb2ea1eb8eff6bd083a116f31499 GIT binary patch literal 61966 zcmb5WbwE^I+b=x8C?E}jgoGmuQUX%a-2(_nH{39!h;$4fD4kM6D~)sw(jcXDr+{>e zz|i5h$NPET=bZE3cR8-T_pCkZ`mL+i+FSq3{P_tYRZ&n@0AXQ)Kv=*Z(4TpbEC~0` zox69yxOeZ~#lywLBOoUrxOb0$iiDJioR*4?mWGOk`XSR3$U_Dw12xTK9%d*z2iH?B zI><8tUQU50oLrokL9lS~@Cfh;CoIWK5-0x&%F*%t0@YHFW*;@cq9Z&N1p=`~j(n>eT)HNsu{kz$1Ul0|H3_$bdFc z30Dq=4PwET0sxF9?LAaIbvXb6Ng0)~M= zaS$mGNcu?}SScLn#Sj)H=S4+I?D+El=(^dAZ~$AwX*Q9aG2B=6{UvAfSt+gCu@kqc z*e%LAX{nC5%v)qVOZ`^1u)YVap;$4vq<_f}OEgxk^CztO8nETX{vR^{}jd0MwQCB>k&tO3DE zA|tk>;Gj#dISvzHITkl1PTb#LofSO2PDgJZIP{N~_Q?U`0Ga^?`+JlE&Tw-6P8^ho z&x8bby;H(K0EiR@_BQl)f0*GtS)6Y{iDV*ePMtepHT4$fY6e6s`gO4)qD63Jm-pB4 zu945Jr=V$T!yCBCasOP)>B^$GKi8MD;T>PUUkk^x6jH$a;_(B4QGuB;{R;qBiV3&| zfsok$IRW9_;abb)J7O3P&D45tBV%aCf#9ubtoQ4g7kd%iS~q?k zroVhx%DAa~41S-e!KsP`%U0s;jEqG4^M6;Lo_bv>j{BIg>=aJet@w!amJ|~1N@QN3 zstvx zht+02{j!9xX{eYjckh(QKdyMRE4|i>7{W*A9a@cSPBGNS&vLi5k-RjkkELJTDO


{)NS{#n?@)xRDhMU4U ze>%W)4Xd*0+~(0RgLj$gG))-Y<*yHQ;bi(fQaT zRGdsN+`swS_hEt=!8)SiJ9@J%f7J(CV@f9~%$lx$5}NDG-J7PbXtlnjetb7e70r@v$L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PL#`p7Z%JiK5^~y9C7#zAN+TvQbN9`QQ_hwXmG*1ZpUAsz{h@Z+-ACqo|w9OI8}axg_tJFJIsWnq#@EIy|_!0Eu`6YEHr zJsTq&VU*+%y91v12m7Z7fKLoU!5CIQFa#e~9D~5=>${Gio-!)@N#%fXoRfi%$mDU; zjQW5LSBXM$8zhcMZ`UIr41FLfpU>?0Q?N4rUGx=klGr-O{!2FM>!vIYG z00|huAcK!?o`n7f9`sy9v4PMGbDVm9N8F72RoHptf1l-5m3MwV;P(7;`g9$0R^nWK zKdnm|A0fgXJ9^@Sl?{COS6dKeeci*-@cu+LxT*YV_WR#an>2|35F z>-l>0`eqnM0FH-{ayjq${{Z#+ceJcer?x#i4}bIDn$46)x2Pa@;~(Vq>DThXhGouj zIQAL;0QL9$@$M}V`2PT(^Uq$D6Rvq34?+m%>F@p&&>1&z{HKm_&vT#i#(VUxS67QU zGd6PT-K`|K^^@+&tLw%S|sGi!9BUb>;8YwdYUur zG2f1zznAi;?h|Z>Kc{cbh}?10{6Ek5P%`Sd9OItA0oT*>0DdG?i;QyJun9a7_59D} z>s8iG+~f}Zxa0ggdk=cBjmbF~8R$p(KXebE$8kW3(2zg9lj)3~%dYHk(}B{YP(Ok2 zbJP-YeR%ql`uE}hK<|#($o~KzOrOV$RKNk(@y0mqfs^lmKBUtCWAgS3jPZ;PIR600 ze_E??7$i=qDc3fc+>LD*JIz%(yw`o~_TdETbxD z0k$*!n(`U4LZph!2U0W7>6-KsFi5XBUZbz)UV*30_KiN?QgT``xcZ!6{-D&!4HHpI RNm5WzMHB$EQA Date: Wed, 1 Nov 2023 10:59:41 +0700 Subject: [PATCH 205/488] python: lint fix --- web/documentserver-example/python/src/utils/docManager.py | 1 - web/documentserver-example/python/src/views/actions.py | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 1902810ea..b9ec57cc1 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -26,7 +26,6 @@ import requests import magic -from django.conf import settings from django.http import FileResponse from src.configuration import ConfigurationManager from src.format import FormatManager diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index fb9604f68..2bbf47184 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -186,7 +186,6 @@ def edit(request): ext = fileUtils.getFileExt(filename) - fileUri = docManager.getFileUri(filename, True, request) directUrl = docManager.getDownloadUrl(filename, request, False) docKey = docManager.generateFileKey(filename, request) fileType = fileUtils.getFileType(filename) @@ -495,6 +494,7 @@ def downloadhistory(request): response.setdefault('error', 'File not found') return HttpResponse(json.dumps(response), content_type='application/json', status=404) + def historyobj(request): body = json.loads(request.body) response = {} @@ -508,13 +508,14 @@ def historyobj(request): if fileName is None: response.setdefault('error', 'File not found') return HttpResponse(json.dumps(response), content_type='application/json', status=404) - + storagePath = docManager.getStoragePath(fileName, request) docKey = docManager.generateFileKey(fileName, request) fileUrl = docManager.getDownloadUrl(fileName, request) response = historyManager.getHistoryObject(storagePath, fileName, docKey, fileUrl, False, request) return HttpResponse(json.dumps(response), content_type='application/json') + # referenceData def reference(request): response = {} From 20ca2d0cbdb261044bc789a2c14f9b761f4864b6 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 1 Nov 2023 11:17:34 +0700 Subject: [PATCH 206/488] python: lint fix --- web/documentserver-example/python/src/utils/users.py | 2 +- web/documentserver-example/python/src/views/actions.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index 7311a4406..c390c9301 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -138,7 +138,7 @@ def getUsersForMentions(uid): def getUsersForProtect(uid): usersData = [] for user in USERS: - if(user.id != uid and user.name != None): + if (user.id != uid and user.name is not None): usersData.append({'id': user.id, 'name': user.name, 'email': user.email}) return usersData diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 95c31fd81..d4bc7eb63 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -350,7 +350,7 @@ def edit(request): } # users data for mentions - usersForMentions = users.getUsersForMentions(user.id) + usersForMentions = users.getUsersForMentions(user.id) # users data for protect usersForProtect = users.getUsersForProtect(user.id) @@ -375,8 +375,8 @@ def edit(request): 'dataInsertImage': json.dumps(dataInsertImage)[1: len(json.dumps(dataInsertImage)) - 1], 'dataDocument': dataDocument, # document which will be compared with the current document 'dataSpreadsheet': json.dumps(dataSpreadsheet), # recipient data for mail merging - 'usersForMentions': json.dumps(usersForMentions) if user.id !='uid-0' else None, - 'usersForProtect': json.dumps(usersForProtect) if user.id !='uid-0' else None + 'usersForMentions': json.dumps(usersForMentions) if user.id != 'uid-0' else None, + 'usersForProtect': json.dumps(usersForProtect) if user.id != 'uid-0' else None } return render(request, 'editor.html', context) # execute the "editor.html" template with context data From a220cdd6270aa6ffff242dad5a1d7313e782287d Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 1 Nov 2023 13:23:51 +0700 Subject: [PATCH 207/488] ruby: user avatar --- CHANGELOG.md | 1 + .../ruby/app/assets/images/uid-1.png | Bin 0 -> 2226 bytes .../ruby/app/assets/images/uid-2.png | Bin 0 -> 2199 bytes .../ruby/app/models/file_model.rb | 28 +++++++++++++++++- .../ruby/app/models/users.rb | 21 ++++++++----- .../ruby/app/views/home/editor.html.erb | 26 ++++++++++++++-- 6 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 web/documentserver-example/ruby/app/assets/images/uid-1.png create mode 100644 web/documentserver-example/ruby/app/assets/images/uid-2.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ee89e827..f026ffeb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- ruby: user avatar - python: user avatar - nodejs: user avatar - trimming long name of uploading file diff --git a/web/documentserver-example/ruby/app/assets/images/uid-1.png b/web/documentserver-example/ruby/app/assets/images/uid-1.png new file mode 100644 index 0000000000000000000000000000000000000000..91cf9e02ce9c581fd3515f132a68945a8b1dea29 GIT binary patch literal 2226 zcmV;j2u=5iP)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Ox)bu z)6>)9;o#oh-p$R;*45P8+1KFT-{0Tg-{0Th;Nafg-q+XH-QC^I&CSu#(bw14&CJWo z%gfW#)6&w?-rnBc-rmZ}%HQAL+S=OJ*VoO>&CSit%*@QPt*YAC*8BVS-rU;E%*@Eh z$jr>l+1c6I+1b(2(f9TB_xJbu`ueY@r=6RY`}+F(_x7csp0~2C`}_O6wz9movf

z*wfAW_Vf7j@#x~;=i=V$=;Ynq-QM2b(b3V^*x1(A*3{J0-{0TU)6><})yvDv+}zyP z*Vo(I+tSj~+1c69(9qi2+RV(%&(F`!&d$xv%@hm@BNY-K6cP~$2Mh-WI3pYy5f3I9 z7X17CG9nxu5f2y+3`{K~{QCI`1O&jFhE+BzDj5_|H!k}8{+^kbn3RzO0RgL}qC7G$ z;JT(aCL%E%7+N|ov5R;1)xxxoedN8Vk!xB#9vaT1l74q{#GZ;a9~nLaBomZdXlfNIGUgHDXCVUqm~ecxHubU!Z(x z^3c7AVpEfEVN5eD@y)n%O+eVJm+Hl_i-&{SzOg715Tu=%kbrzOD<_G2c$j8WP&_tC zHZMjkBl-6AR4^n)CLPAYzwG7Vd0bC|TuQl1#iEj#a%JS?vNI+uz#O*|wyP zZ(a8B?&iX;nRjN{ub@XOByT=9z@(U?a%1`0$y`rNbZ=~NX=m8i*Q%hO)WyP@YFELo zq_?G;aZ*IimxjBBd}mBPuat+GSXY2ZLt!v4n`d3dm4z`w5|{u006cV3PE!DoP_Ms$ zzYtLGAb)Rv&miwWPrq=VrAaEdX@4xS0&rq-LkiYNW z?~vk>3OoP+1oKHm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A9RL6T literal 0 HcmV?d00001 diff --git a/web/documentserver-example/ruby/app/assets/images/uid-2.png b/web/documentserver-example/ruby/app/assets/images/uid-2.png new file mode 100644 index 0000000000000000000000000000000000000000..651b40c6b91e59c94b2752ddcbe0dac2ffe38cab GIT binary patch literal 2199 zcmV;I2x#|-P)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Oq!vx ze}+AOW?e_fc_WbMi|LXMpNJ~|EXlJ0OxrB?IpQgB&pRoY}0h*z+hK-+` zqqU2Yq?@9&eT0{ak)w!@p@4^(hmN3uh?M3@LM|yN zB`G;IIU5fQI4?1|$=*^xJCnge>*BVWkG+?Pjd*pF zYG5-mI6592q_)mqUS?BQW6s;{h?%%NN@a0_ret-KFefTMGc#o(Xj|XN zy`74L@A&?ZaALrrl%%ArfmTf)AS=hLq4L_!gmZ5|K}Ty?T1YA*oUO(v3<^RqD}aKI zkD$I;YK%}{e3`1pTUlXjaD0)Z!B|H_UsYM4l$Nf))!ypzrmwzge44SYwY0s&p_{x zuivlFzmS)l?Zf~81k_1HK~y-)ebskZ6G<2c;6*{;?xcD?mQx@5_1-IzKtk}uAPWlt z0wj0 z_gH{gti85cPd{o`y=cjX)`Ra}TUJ(^$_FVx=e@SJx=$^(%XeF%#_kE{6p21Q@hJ(g za{<7nrq3+0dr0h&YTl`+RQMbLJTbv6A7E2c6BCmKdbu@;-K|p;ohgdonjmRVc}d%@ ze2W4v63^GGcA1+)eDYjqVx^B%iOXaqB?R7<*i}ejr`g;qHXv*tTwQaiQd)xB5IAmw z2OY$T;4-A0cG7#YY#)iagVh6-!Aimg6k#Ki2H`kC#OHgF*hvf7ZB_v9*=^5NC_}4p z!iLENSSD>NhmXlpy-*G(^fF(dFgsMKB=8EAJWyPrluBhde2n;tPQ4yl&Ce0GEUXS8 zs_G7mHZ){M`(G@l{^N)F$Huu~B({j6_N@Bq2;Dt_tR}STueG)8lXewkFTU&{RunTx?!mizG^|mQ*nD z_VzE~nKngQ7jtw3ttosxE;}yfzucT?|Jc~fj4Ecx@hB3*){tX`5bv`F+regE7Ybt< z9^__^0xsam3DxnauhHE?8hgWWZiPc}!kB;lYR$^d%FWB*i9=MXNOTdA*2P{!804^L zr;bifH&6T-oi*MX$>Rme+mD_!GlQB%-mdl7T1Rp_P>!Fcr+!yOHNy}*-ig4Yp{@)H zgR<4a);Myg&>+X*xG8@@rhjgo8sMTLWjvfT@RE~U1Jgtp-IY}T=3Dgwi8?c!7tZ5J zf)W_>wGO7ON39SZ5BB)2-zK6Yd4llp@S>vR^L&JXh8&DOeR_ou|CG}z5RBEU!)pct zlamJ-j5%##0EZ#DLNbRvyVh^?KvQhyuurI5oE$jGv7sd1{0a-gl|-W9o`ntgKy&`)5ttCD{V3@Mg+^)3TyXWZ}=IgQ_7SLPYS@L_e%_zdn?eCe% zYog08-avYTdiTA@ehIgK?Dp^d$uO66==OUXZ+-iT-`E{GpMCm?@fW`sfArx8+jlJb Z@qh8`Ye}<~)Vcrw002ovPDHLkV1jA>VwC^@ literal 0 HcmV?d00001 diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 65ce0d979..0798444d5 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -158,7 +158,8 @@ def get_config :user => { # the user currently viewing or editing the document :id => !@user.id.eql?("uid-0") ? @user.id : nil, :name => @user.name, - :group => @user.group + :group => @user.group, + :image => @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil }, :embedded => { # the parameters for the embedded document type :saveUrl => download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer @@ -350,6 +351,31 @@ def get_users_mentions return !@user.id.eql?("uid-0") ? Users.get_users_for_mentions(@user.id) : nil end + def get_users_info + users_info = [] + if !@user.id.eql?("uid-0") + Users.get_all_users().each do |user_info| + u = { + id: user_info.id, + name: user_info.name, + email: user_info.email, + group: user_info.group, + reviewGroups: user_info.reviewGroups, + commentGroups: user_info.commentGroups, + userInfoGroups: user_info.userInfoGroups, + favorite: user_info.favorite, + deniedPermissions: user_info.deniedPermissions, + descriptions: user_info.descriptions, + templates: user_info.templates, + avatar: user_info.avatar + } + u["image"] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil + users_info.push(u) + end + return users_info + end + end + # get direct url existence flag def is_enable_direct_url return @direct_url != nil && @direct_url == "true" diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index a6acbc462..b0435618f 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -15,9 +15,11 @@ # class User - attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, :deniedPermissions, :descriptions, :templates + attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, + :deniedPermissions, :descriptions, :templates, :avatar - def initialize (id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates) + def initialize (id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, + deniedPermissions, descriptions, templates, avatar) @id = id @name = name @email = email @@ -29,6 +31,7 @@ def initialize (id, name, email, group, reviewGroups, commentGroups, userInfoGro @descriptions = descriptions @templates = templates @userInfoGroups = userInfoGroups + @avatar = avatar end end @@ -40,7 +43,8 @@ class Users "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Has an avatar", ]; @@descr_user_2 = [ @@ -49,7 +53,8 @@ class Users "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Has an avatar", ]; @@descr_user_3 = [ @@ -82,7 +87,7 @@ class Users @@users = [ User.new("uid-1", "John Smith", "smith@example.com", "", nil, {}, nil, - nil, [], @@descr_user_1, true), + nil, [], @@descr_user_1, true, true), User.new("uid-2", "Mark Pottato", "pottato@example.com", "group-2", ["group-2", ""], { :view => "", @@ -90,7 +95,7 @@ class Users :remove => ["group-2"] }, ["group-2", ""], - true, [], @@descr_user_2, false), + true, [], @@descr_user_2, false, true), User.new("uid-3", "Hamish Mitchell", "mitchell@example.com", "group-3", ["group-2"], { :view => ["group-3", "group-2"], @@ -98,10 +103,10 @@ class Users :remove => [] }, ["group-2"], - false, ["copy", "download", "print"], @@descr_user_3, false), + false, ["copy", "download", "print"], @@descr_user_3, false, false), User.new("uid-0", nil, nil, "", nil, {}, [], - nil, ["protect"], @@descr_user_0, false) + nil, ["protect"], @@descr_user_0, false, false) ] class << self diff --git a/web/documentserver-example/ruby/app/views/home/editor.html.erb b/web/documentserver-example/ruby/app/views/home/editor.html.erb index 7fd218ec4..7f73044bd 100755 --- a/web/documentserver-example/ruby/app/views/home/editor.html.erb +++ b/web/documentserver-example/ruby/app/views/home/editor.html.erb @@ -229,9 +229,29 @@ }; <% end %> // add mentions for not anonymous users - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%= raw @file.get_users_mentions.to_json %> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "info": + users = []; + var allUsers = <%= raw @file.get_users_info.to_json %>; + for (var i = 0; i < event.data.id.length; i++) { + for (var j = 0; j < allUsers.length; j++) { + if (allUsers[j].id == event.data.id[i]) { + users.push(allUsers[j]); + break; + } + } + } + break; + default: + users = <%= raw @file.get_users_mentions.to_json %>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; // the user is mentioned in a comment From 20aea45ac7f35d39c811d26f54f0390701eab198 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 2 Nov 2023 17:17:41 +0700 Subject: [PATCH 208/488] php: user avatar --- CHANGELOG.md | 1 + .../php/assets/images/uid-1.png | Bin 0 -> 2226 bytes .../php/assets/images/uid-2.png | Bin 0 -> 2199 bytes .../php/src/helpers/ExampleUsers.php | 8 +++- .../php/src/helpers/Users.php | 7 +++- .../php/src/views/DocEditorView.php | 36 ++++++++++++++++-- 6 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 web/documentserver-example/php/assets/images/uid-1.png create mode 100644 web/documentserver-example/php/assets/images/uid-2.png diff --git a/CHANGELOG.md b/CHANGELOG.md index f026ffeb0..5f1f3ebef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- php: user avatar - ruby: user avatar - python: user avatar - nodejs: user avatar diff --git a/web/documentserver-example/php/assets/images/uid-1.png b/web/documentserver-example/php/assets/images/uid-1.png new file mode 100644 index 0000000000000000000000000000000000000000..91cf9e02ce9c581fd3515f132a68945a8b1dea29 GIT binary patch literal 2226 zcmV;j2u=5iP)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Ox)bu z)6>)9;o#oh-p$R;*45P8+1KFT-{0Tg-{0Th;Nafg-q+XH-QC^I&CSu#(bw14&CJWo z%gfW#)6&w?-rnBc-rmZ}%HQAL+S=OJ*VoO>&CSit%*@QPt*YAC*8BVS-rU;E%*@Eh z$jr>l+1c6I+1b(2(f9TB_xJbu`ueY@r=6RY`}+F(_x7csp0~2C`}_O6wz9movf

z*wfAW_Vf7j@#x~;=i=V$=;Ynq-QM2b(b3V^*x1(A*3{J0-{0TU)6><})yvDv+}zyP z*Vo(I+tSj~+1c69(9qi2+RV(%&(F`!&d$xv%@hm@BNY-K6cP~$2Mh-WI3pYy5f3I9 z7X17CG9nxu5f2y+3`{K~{QCI`1O&jFhE+BzDj5_|H!k}8{+^kbn3RzO0RgL}qC7G$ z;JT(aCL%E%7+N|ov5R;1)xxxoedN8Vk!xB#9vaT1l74q{#GZ;a9~nLaBomZdXlfNIGUgHDXCVUqm~ecxHubU!Z(x z^3c7AVpEfEVN5eD@y)n%O+eVJm+Hl_i-&{SzOg715Tu=%k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YQe!n;ccmsNN}m^VgnKZJ|Cny;0>_D#5M|aVerO; zZ;NG-NfKpucXjigejM)%^7Y+zfamadgLWti2?^PlkWeg-l=S4Nt4=kHfnjV43R0B^R>?56m!4E>GrAYYa0t=A_XDsL<+3JVEoFACcnHQ3bG zm!Frh>lUc0di%90&#QNrg@qNB?O3(y%Fmboe6VZhwrwiadn=xL62AWdpl7dNzcw(i zv%LJ)Cm*kP<{3+x{gLDH53db;_Nm?HlaAy60nijp^WHMgaR2}S07*qoM6N<$g1R-5 A9RL6T literal 0 HcmV?d00001 diff --git a/web/documentserver-example/php/assets/images/uid-2.png b/web/documentserver-example/php/assets/images/uid-2.png new file mode 100644 index 0000000000000000000000000000000000000000..651b40c6b91e59c94b2752ddcbe0dac2ffe38cab GIT binary patch literal 2199 zcmV;I2x#|-P)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Oq!vx ze}+AOW?e_fc_WbMi|LXMpNJ~|EXlJ0OxrB?IpQgB&pRoY}0h*z+hK-+` zqqU2Yq?@9&eT0{ak)w!@p@4^(hmN3uh?M3@LM|yN zB`G;IIU5fQI4?1|$=*^xJCnge>*BVWkG+?Pjd*pF zYG5-mI6592q_)mqUS?BQW6s;{h?%%NN@a0_ret-KFefTMGc#o(Xj|XN zy`74L@A&?ZaALrrl%%ArfmTf)AS=hLq4L_!gmZ5|K}Ty?T1YA*oUO(v3<^RqD}aKI zkD$I;YK%}{e3`1pTUlXjaD0)Z!B|H_UsYM4l$Nf))!ypzrmwzge44SYwY0s&p_{x zuivlFzmS)l?Zf~81k_1HK~y-)ebskZ6G<2c;6*{;?xcD?mQx@5_1-IzKtk}uAPWlt z0wj0 z_gH{gti85cPd{o`y=cjX)`Ra}TUJ(^$_FVx=e@SJx=$^(%XeF%#_kE{6p21Q@hJ(g za{<7nrq3+0dr0h&YTl`+RQMbLJTbv6A7E2c6BCmKdbu@;-K|p;ohgdonjmRVc}d%@ ze2W4v63^GGcA1+)eDYjqVx^B%iOXaqB?R7<*i}ejr`g;qHXv*tTwQaiQd)xB5IAmw z2OY$T;4-A0cG7#YY#)iagVh6-!Aimg6k#Ki2H`kC#OHgF*hvf7ZB_v9*=^5NC_}4p z!iLENSSD>NhmXlpy-*G(^fF(dFgsMKB=8EAJWyPrluBhde2n;tPQ4yl&Ce0GEUXS8 zs_G7mHZ){M`(G@l{^N)F$Huu~B({j6_N@Bq2;Dt_tR}STueG)8lXewkFTU&{RunTx?!mizG^|mQ*nD z_VzE~nKngQ7jtw3ttosxE;}yfzucT?|Jc~fj4Ecx@hB3*){tX`5bv`F+regE7Ybt< z9^__^0xsam3DxnauhHE?8hgWWZiPc}!kB;lYR$^d%FWB*i9=MXNOTdA*2P{!804^L zr;bifH&6T-oi*MX$>Rme+mD_!GlQB%-mdl7T1Rp_P>!Fcr+!yOHNy}*-ig4Yp{@)H zgR<4a);Myg&>+X*xG8@@rhjgo8sMTLWjvfT@RE~U1Jgtp-IY}T=3Dgwi8?c!7tZ5J zf)W_>wGO7ON39SZ5BB)2-zK6Yd4llp@S>vR^L&JXh8&DOeR_ou|CG}z5RBEU!)pct zlamJ-j5%##0EZ#DLNbRvyVh^?KvQhyuurI5oE$jGv7sd1{0a-gl|-W9o`ntgKy&`)5ttCD{V3@Mg+^)3TyXWZ}=IgQ_7SLPYS@L_e%_zdn?eCe% zYog08-avYTdiTA@ehIgK?Dp^d$uO66==OUXZ+-iT-`E{GpMCm?@fW`sfArx8+jlJb Z@qh8`Ye}<~)Vcrw002ovPDHLkV1jA>VwC^@ literal 0 HcmV?d00001 diff --git a/web/documentserver-example/php/src/helpers/ExampleUsers.php b/web/documentserver-example/php/src/helpers/ExampleUsers.php index cf1e3a0f8..33e0146e3 100644 --- a/web/documentserver-example/php/src/helpers/ExampleUsers.php +++ b/web/documentserver-example/php/src/helpers/ExampleUsers.php @@ -38,6 +38,7 @@ public function __construct() "The file favorite state is undefined", "Can create files from templates using data from the editor", "Can see the information about all users", + "Has an avatar", ]; $this->user2Description = [ "Belongs to Group2", @@ -47,6 +48,7 @@ public function __construct() "This file is marked as favorite", "Can create new files from the editor", "Can see the information about users from Group2 and users who don’t belong to any group", + "Has an avatar", ]; $this->user3Description = [ "Belongs to Group3", @@ -84,6 +86,7 @@ public function __construct() null, [], $this->user1Description, + true, true ), new Users( @@ -101,7 +104,8 @@ public function __construct() true, [], $this->user2Description, - false + false, + true ), new Users( "uid-3", @@ -118,6 +122,7 @@ public function __construct() false, ["copy", "download", "print"], $this->user3Description, + false, false ), new Users( @@ -131,6 +136,7 @@ public function __construct() null, ["protect"], $this->user0Description, + false, false ), ]; diff --git a/web/documentserver-example/php/src/helpers/Users.php b/web/documentserver-example/php/src/helpers/Users.php index 837ea4bc1..decb608c6 100644 --- a/web/documentserver-example/php/src/helpers/Users.php +++ b/web/documentserver-example/php/src/helpers/Users.php @@ -32,6 +32,8 @@ final class Users public ?bool $templates; public ?array $userInfoGroups; + public ?bool $avatar; + /** * Constructor * @@ -46,6 +48,7 @@ final class Users * @param array|null $deniedPermissions * @param array|null $descriptions * @param bool|null $templates + * @param bool|null $avatar * * @return void */ @@ -60,7 +63,8 @@ public function __construct( ?bool $favorite, ?array $deniedPermissions, ?array $descriptions, - ?bool $templates + ?bool $templates, + ?bool $avatar ) { $this->id = $id; $this->name = $name; @@ -73,5 +77,6 @@ public function __construct( $this->descriptions = $descriptions; $this->templates = $templates; $this->userInfoGroups = $userInfoGroups; + $this->avatar = $avatar; } } diff --git a/web/documentserver-example/php/src/views/DocEditorView.php b/web/documentserver-example/php/src/views/DocEditorView.php index 89f29b195..2b6acdd38 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -161,6 +161,7 @@ public function __construct($request, $tempName = "docEditor") "id" => $user->id != "uid-0" ? $user->id : null, "name" => $user->name, "group" => $user->group, + "image" => $user->avatar ? serverPath(true) . "/assets/images/" . $user->id . ".png" : null ], "embedded" => [ // the parameters for the embedded document type // the absolute URL that will allow the document to be saved onto the user personal computer @@ -220,6 +221,14 @@ public function __construct($request, $tempName = "docEditor") // users data for mentions $usersForMentions = $user->id != "uid-0" ? $userList->getUsersForMentions($user->id) : null; + $usersInfo = []; + if ($user->id != 'uid-0'){ + foreach ($userList->getAllUsers() as $userInfo){ + $u = $userInfo; + $u->image = $userInfo->avatar ? serverPath(true) . "/assets/images/" . $userInfo->id . ".png" : null; + array_push($usersInfo, $u); + } + } // check if the secret key to generate token exists if ($jwtManager->isJwtEnabled()) { @@ -249,9 +258,29 @@ public function __construct($request, $tempName = "docEditor") };"; } $historyLayout .= "// add mentions for not anonymous users - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - \"users\": {usersForMentions} + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case \"info\": + users = []; + var allUsers = {usersInfo}; + for (var i = 0; i < event.data.id.length; i++) { + for (var j = 0; j < allUsers.length; j++) { + if (allUsers[j].id == event.data.id[i]) { + users.push(allUsers[j]); + break; + } + } + } + break; + default: + users = {usersForMentions}; + } + docEditor.setUsers({ + \"c\": c, + \"users\": users, }); }; // the user is mentioned in a comment @@ -279,6 +308,7 @@ public function __construct($request, $tempName = "docEditor") "config" => json_encode($config), "history" => $historyLayout, "usersForMentions" => json_encode($usersForMentions), + "usersInfo" => json_encode($usersInfo) ]; } } From 13c93ce2de77afcea8fa71acbd19d0c84405bf88 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Fri, 3 Nov 2023 19:44:33 +0700 Subject: [PATCH 209/488] java-spring: user avatar --- CHANGELOG.md | 1 + .../onlyoffice/integration/ExampleData.java | 14 ++++---- .../controllers/EditorController.java | 18 ++++++++++ .../documentserver/models/filemodel/User.java | 7 +++- .../onlyoffice/integration/dto/UserInfo.java | 33 ++++++++++++++++++ .../onlyoffice/integration/entities/User.java | 2 ++ .../integration/services/UserServices.java | 4 ++- .../main/resources/static/css/img/uid-1.png | Bin 0 -> 2226 bytes .../main/resources/static/css/img/uid-2.png | Bin 0 -> 2199 bytes .../src/main/resources/templates/editor.html | 27 ++++++++++++-- 10 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/UserInfo.java create mode 100644 web/documentserver-example/java-spring/src/main/resources/static/css/img/uid-1.png create mode 100644 web/documentserver-example/java-spring/src/main/resources/static/css/img/uid-2.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f1f3ebef..dc2c91b83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- java-spring: user avatar - php: user avatar - ruby: user avatar - python: user avatar diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java index 6fe3c3aea..76ceb38cf 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java @@ -58,7 +58,8 @@ public void init() { "The file favorite state is undefined", "Can create a file from a template with data from the editor", "Can see the information about all users", - "Can view chat" + "Can view chat", + "Has an avatar" ); // the description for user 2 @@ -71,7 +72,8 @@ public void init() { "This file is favorite", "Can create a file from an editor", "Can see the information about users from Group2 and users who don’t belong to any group", - "Can view chat" + "Can view chat", + "Has an avatar" ); // the description for user 3 @@ -93,23 +95,23 @@ public void init() { userService.createUser("John Smith", "smith@example.com", descriptionUserFirst, "", List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), - List.of(FilterState.NULL.toString()), null, true, true); + List.of(FilterState.NULL.toString()), null, true, true, true); // create user 2 with the specified parameters userService.createUser("Mark Pottato", "pottato@example.com", descriptionUserSecond, "group-2", List.of("", "group-2"), List.of(FilterState.NULL.toString()), List.of("group-2", ""), List.of("group-2"), List.of("group-2", ""), true, true, - true); + true, true); // create user 3 with the specified parameters userService.createUser("Hamish Mitchell", "mitchell@example.com", descriptionUserThird, "group-3", List.of("group-2"), List.of("group-2", "group-3"), List.of("group-2"), - new ArrayList<>(), List.of("group-2"), false, true, true); + new ArrayList<>(), List.of("group-2"), false, true, true, false); // create user 0 with the specified parameters userService.createUser("Anonymous", null, descriptionUserZero, "", List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), - new ArrayList<>(), null, false, false); + new ArrayList<>(), null, false, false, false); } } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java index d87321a81..09316e3a1 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/EditorController.java @@ -25,6 +25,7 @@ import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; import com.onlyoffice.integration.entities.User; import com.onlyoffice.integration.dto.Mentions; +import com.onlyoffice.integration.dto.UserInfo; import com.onlyoffice.integration.documentserver.models.enums.Type; import com.onlyoffice.integration.documentserver.models.filemodel.FileModel; import com.onlyoffice.integration.services.UserServices; @@ -117,6 +118,8 @@ public String index(@RequestParam("fileName") final String fileName, } User user = optionalUser.get(); + user.setImage(user.getAvatar() ? storagePathBuilder.getServerUrl(true) + "/css/img/uid-" + + user.getId() + ".png" : null); // get file model with the default file parameters FileModel fileModel = fileConfigurer.getFileModel( @@ -150,6 +153,8 @@ public String index(@RequestParam("fileName") final String fileName, // get user data for mentions and add it to the model model.addAttribute("usersForMentions", getUserMentions(uid)); + + model.addAttribute("usersInfo", getUsersInfo(uid)); return "editor.html"; } @@ -169,6 +174,19 @@ private List getUserMentions(final String uid) { // get user data for return usersForMentions; } + private List getUsersInfo(final String uid) { // get user data for mentions + List usersInfo = new ArrayList<>(); + if (uid != null && !uid.equals("4")) { + List list = userService.findAll(); + for (User u : list) { + String image = u.getAvatar() ? storagePathBuilder.getServerUrl(true) + "/css/img/uid-" + + u.getId() + ".png" : null; + usersInfo.add(new UserInfo(u.getId(), u.getName(), u.getEmail(), image)); + } + } + return usersInfo; + } + @SneakyThrows private String getInsertImage(final Boolean directUrl) { // get an image that will be inserted into the document Map dataInsertImage = new HashMap<>(); diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/User.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/User.java index e7e9e6a5c..602988689 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/User.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/User.java @@ -19,6 +19,8 @@ package com.onlyoffice.integration.documentserver.models.filemodel; import com.onlyoffice.integration.documentserver.models.AbstractModel; +import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder; + import lombok.Getter; import lombok.Setter; import org.springframework.context.annotation.Scope; @@ -29,14 +31,17 @@ @Getter @Setter public class User extends AbstractModel { + private FileStoragePathBuilder storagePathBuilder; private String id; private String name; private String group; + private String image; // the user configuration parameters public void configure(final int idParam, final String nameParam, final String groupParam) { - this.id = "uid-" + idParam; // the user id + this.id = "" + idParam; // the user id this.name = nameParam; // the user name this.group = groupParam; // the group the user belongs to + this.image = storagePathBuilder.getServerUrl(true) + "/css/img/uid-" + this.id + ".png"; } } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/UserInfo.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/UserInfo.java new file mode 100644 index 000000000..573b15aa3 --- /dev/null +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/UserInfo.java @@ -0,0 +1,33 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.onlyoffice.integration.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +public class UserInfo { + private Integer id; + private String name; + private String email; + private String image; +} diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/entities/User.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/entities/User.java index 94e6b11a0..bf1a65afa 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/entities/User.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/entities/User.java @@ -45,4 +45,6 @@ public class User extends AbstractEntity { @ElementCollection @CollectionTable(name = "user_descriptions") private List descriptions; + private Boolean avatar; + private String image; } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/UserServices.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/UserServices.java index 53d0d5f63..13f76b704 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/UserServices.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/UserServices.java @@ -58,13 +58,15 @@ public User createUser(final String name, final String email, final List removeGroups, final List userInfoGroups, final Boolean favoriteDoc, final Boolean chat, - final Boolean protect) { + final Boolean protect, + final Boolean avatar) { User newUser = new User(); newUser.setName(name); // set the user name newUser.setEmail(email); // set the user email newUser.setGroup(groupServices.createGroup(group)); // set the user group newUser.setDescriptions(description); // set the user description newUser.setFavorite(favoriteDoc); // specify if the user has the favorite documents or not + newUser.setAvatar(avatar); List groupsReview = groupServices .createGroups(reviewGroups); // define the groups whose changes the user can accept/reject diff --git a/web/documentserver-example/java-spring/src/main/resources/static/css/img/uid-1.png b/web/documentserver-example/java-spring/src/main/resources/static/css/img/uid-1.png new file mode 100644 index 0000000000000000000000000000000000000000..91cf9e02ce9c581fd3515f132a68945a8b1dea29 GIT binary patch literal 2226 zcmV;j2u=5iP)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Ox)bu z)6>)9;o#oh-p$R;*45P8+1KFT-{0Tg-{0Th;Nafg-q+XH-QC^I&CSu#(bw14&CJWo z%gfW#)6&w?-rnBc-rmZ}%HQAL+S=OJ*VoO>&CSit%*@QPt*YAC*8BVS-rU;E%*@Eh z$jr>l+1c6I+1b(2(f9TB_xJbu`ueY@r=6RY`}+F(_x7csp0~2C`}_O6wz9movf

z*wfAW_Vf7j@#x~;=i=V$=;Ynq-QM2b(b3V^*x1(A*3{J0-{0TU)6><})yvDv+}zyP z*Vo(I+tSj~+1c69(9qi2+RV(%&(F`!&d$xv%@hm@BNY-K6cP~$2Mh-WI3pYy5f3I9 z7X17CG9nxu5f2y+3`{K~{QCI`1O&jFhE+BzDj5_|H!k}8{+^kbn3RzO0RgL}qC7G$ z;JT(aCL%E%7+N|ov5R;1)xxxoedN8Vk!xB#9vaT1l74q{#GZ;a9~nLaBomZdXlfNIGUgHDXCVUqm~ecxHubU!Z(x z^3c7AVpEfEVN5eD@y)n%O+eVJm+Hl_i-&{SzOg715Tu=%kbrzOD<_G2c$j8WP&_tC zHZMjkBl-6AR4^n)CLPAYzwG7Vd0bC|TuQl1#iEj#a%JS?vNI+uz#O*|wyP zZ(a8B?&iX;nRjN{ub@XOByT=9z@(U?a%1`0$y`rNbZ=~NX=m8i*Q%hO)WyP@YFELo zq_?G;aZ*IimxjBBd}mBPuat+GSXY2ZLt!v4n`d3dm4z`w5|{u006cV3PE!DoP_Ms$ zzYtLGAb)Rv&miwWPrq=VrAaEdX@4xS0&rq-LkiYNW z?~vk>3OoP+1oKHmK~y-)ebskV6G6A5`%X4wOWheClrc1};FPV)#djwz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java-spring/src/main/resources/static/css/img/uid-2.png b/web/documentserver-example/java-spring/src/main/resources/static/css/img/uid-2.png new file mode 100644 index 0000000000000000000000000000000000000000..651b40c6b91e59c94b2752ddcbe0dac2ffe38cab GIT binary patch literal 2199 zcmV;I2x#|-P)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Oq!vx ze}+AOW?e_fc_WbMi|LXMpNJ~|EXlJ0OxrB?IpQgB&pRoY}0h*z+hK-+` zqqU2Yq?@9&eT0{ak)w!@p@4^(hmN3uh?M3@LM|yN zB`G;IIU5fQI4?1|$=*^xJCnge>*BVWkG+?Pjd*pF zYG5-mI6592q_)mqUS?BQW6s;{h?%%NN@a0_ret-KFefTMGc#o(Xj|XN zy`74L@A&?ZaALrrl%%ArfmTf)AS=hLq4L_!gmZ5|K}Ty?T1YA*oUO(v3<^RqD}aKI zkD$I;YK%}{e3`1pTUlXjaD0)Z!B|H_UsYM4l$Nf))!ypzrmwzge44SYwY0s&p_{x zuivlFzmS)l?Zf~81k_1HK~y-)ebskZ6G<2c;6*{;?xcD?mQx@5_1-IzKtk}uAPWlt z0wj0 z_gH{gti85cPd{o`y=cjX)`Ra}TUJ(^$_FVx=e@SJx=$^(%XeF%#_kE{6p21Q@hJ(g za{<7nrq3+0dr0h&YTl`+RQMbLJTbv6A7E2c6BCmKdbu@;-K|p;ohgdonjmRVc}d%@ ze2W4v63^GGcA1+)eDYjqVx^B%iOXaqB?R7<*i}ejr`g;qHXv*tTwQaiQd)xB5IAmw z2OY$T;4-A0cG7#YY#)iagVh6-!Aimg6k#Ki2H`kC#OHgF*hvf7ZB_v9*=^5NC_}4p z!iLENSSD>NhmXlpy-*G(^fF(dFgsMKB=8EAJWyPrluBhde2n;tPQ4yl&Ce0GEUXS8 zs_G7mHZ){M`(G@l{^N)F$Huu~B({j6_N@Bq2;Dt_tR}STueG)8lXewkFTU&{RunTx?!mizG^|mQ*nD z_VzE~nKngQ7jtw3ttosxE;}yfzucT?|Jc~fj4Ecx@hB3*){tX`5bv`F+regE7Ybt< z9^__^0xsam3DxnauhHE?8hgWWZiPc}!kB;lYR$^d%FWB*i9=MXNOTdA*2P{!804^L zr;bifH&6T-oi*MX$>Rme+mD_!GlQB%-mdl7T1Rp_P>!Fcr+!yOHNy}*-ig4Yp{@)H zgR<4a);Myg&>+X*xG8@@rhjgo8sMTLWjvfT@RE~U1Jgtp-IY}T=3Dgwi8?c!7tZ5J zf)W_>wGO7ON39SZ5BB)2-zK6Yd4llp@S>vR^L&JXh8&DOeR_ou|CG}z5RBEU!)pct zlamJ-j5%##0EZ#DLNbRvyVh^?KvQhyuurI5oE$jGv7sd1{0a-gl|-W9o`ntgKy&`)5ttCD{V3@Mg+^)3TyXWZ}=IgQ_7SLPYS@L_e%_zdn?eCe% zYog08-avYTdiTA@ehIgK?Dp^d$uO66==OUXZ+-iT-`E{GpMCm?@fW`sfArx8+jlJb Z@qh8`Ye}<~)Vcrw002ovPDHLkV1jA>VwC^@ literal 0 HcmV?d00001 diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html index 3694fc328..d3fe4dc16 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/editor.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/editor.html @@ -255,12 +255,33 @@ }; var usersForMentions = [[${usersForMentions}]]; + var usersInfo = [[${usersInfo}]]; if (config.editorConfig.user.id != 4) { // add mentions for not anonymous users - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": usersForMentions + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "info": + users = []; + var allUsers = usersInfo; + for (var i = 0; i < event.data.id.length; i++) { + for (var j = 0; j < allUsers.length; j++) { + if (allUsers[j].id == event.data.id[i]) { + users.push(allUsers[j]); + break; + } + } + } + break; + default: + users = usersForMentions; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; // the user is mentioned in a comment From dfe61c501348cf56e288e10b8230993c8b95993e Mon Sep 17 00:00:00 2001 From: sshakndr Date: Fri, 3 Nov 2023 20:47:43 +0700 Subject: [PATCH 210/488] java: user avatar --- CHANGELOG.md | 1 + .../main/java/controllers/EditorServlet.java | 3 ++ .../src/main/java/entities/FileModel.java | 7 +++++ .../java/src/main/java/entities/User.java | 8 +++++- .../java/src/main/java/helpers/Users.java | 24 +++++++++++++--- .../java/src/main/webapp/css/img/uid-1.png | Bin 0 -> 2226 bytes .../java/src/main/webapp/css/img/uid-2.png | Bin 0 -> 2199 bytes .../java/src/main/webapp/editor.jsp | 27 ++++++++++++++++-- 8 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 web/documentserver-example/java/src/main/webapp/css/img/uid-1.png create mode 100644 web/documentserver-example/java/src/main/webapp/css/img/uid-2.png diff --git a/CHANGELOG.md b/CHANGELOG.md index dc2c91b83..24e23c663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- java: user avatar - java-spring: user avatar - php: user avatar - ruby: user avatar diff --git a/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java b/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java index 2f6e65f27..fad184190 100644 --- a/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java @@ -107,6 +107,8 @@ protected void processRequest(final HttpServletRequest request, // users data for mentions List> usersForMentions = Users.getUsersForMentions(user.getId()); + List> usersInfo = Users.getUsersInfo(); + // check if the document token is enabled if (DocumentManager.tokenEnabled()) { file.buildToken(); // generate document token @@ -131,6 +133,7 @@ protected void processRequest(final HttpServletRequest request, request.setAttribute("dataSpreadsheet", gson.toJson(dataSpreadsheet)); request.setAttribute("usersForMentions", !user.getId() .equals("uid-0") ? gson.toJson(usersForMentions) : null); + request.setAttribute("usersInfo", gson.toJson(usersInfo)); request.getRequestDispatcher("editor.jsp").forward(request, response); } diff --git a/web/documentserver-example/java/src/main/java/entities/FileModel.java b/web/documentserver-example/java/src/main/java/entities/FileModel.java index c50c4ad3e..071a695b8 100755 --- a/web/documentserver-example/java/src/main/java/entities/FileModel.java +++ b/web/documentserver-example/java/src/main/java/entities/FileModel.java @@ -111,6 +111,8 @@ public FileModel(final String fileNameParam, editorConfig.getUser().setId(!user.getId().equals("uid-0") ? user.getId() : null); editorConfig.getUser().setName(user.getName()); editorConfig.getUser().setGroup(user.getGroup()); + editorConfig.getUser().setImage(user.getAvatar() ? DocumentManager.getServerUrl(false) + + "/css/img/" + user.getId() + ".png" : null); // write the absolute URL to the file location editorConfig.getCustomization().getGoback() @@ -521,6 +523,7 @@ public class User { private String id; private String name; private String group; + private String image; public String getId() { return id; @@ -545,6 +548,10 @@ public String getGroup() { public void setGroup(final String groupParam) { this.group = groupParam; } + + public void setImage(final String imageParam) { + this.image = imageParam; + } } // customization parameters diff --git a/web/documentserver-example/java/src/main/java/entities/User.java b/web/documentserver-example/java/src/main/java/entities/User.java index 555acc526..f8c85afd0 100755 --- a/web/documentserver-example/java/src/main/java/entities/User.java +++ b/web/documentserver-example/java/src/main/java/entities/User.java @@ -32,12 +32,13 @@ public class User { private final List descriptions; private final Boolean templates; private final List userInfoGroups; + private final Boolean avatar; public User(final String idParam, final String nameParam, final String emailParam, final String groupParam, final List reviewGroupsParam, final CommentGroups commentGroupsParam, final List userInfoGroupsParam, final Boolean favoriteParam, final List deniedPermissionsParam, final List descriptionsParam, - final Boolean templatesParam) { + final Boolean templatesParam, final Boolean avatarParam) { this.id = idParam; this.name = nameParam; this.email = emailParam; @@ -49,6 +50,7 @@ public User(final String idParam, final String nameParam, final String emailPara this.descriptions = descriptionsParam; this.templates = templatesParam; this.userInfoGroups = userInfoGroupsParam; + this.avatar = avatarParam; } public String getId() { @@ -94,4 +96,8 @@ public Boolean getTemplates() { public List getUserInfoGroups() { return userInfoGroups; } + + public Boolean getAvatar() { + return avatar; + } } diff --git a/web/documentserver-example/java/src/main/java/helpers/Users.java b/web/documentserver-example/java/src/main/java/helpers/Users.java index 173802f4a..ca9b1ca8b 100755 --- a/web/documentserver-example/java/src/main/java/helpers/Users.java +++ b/web/documentserver-example/java/src/main/java/helpers/Users.java @@ -37,6 +37,7 @@ public final class Users { add("The file favorite state is undefined"); add("Can create files from templates using data from the editor"); add("Can see the information about all users"); + add("Has an avatar"); }}; private static List descriptionUserSecond = new ArrayList() {{ @@ -47,6 +48,7 @@ public final class Users { add("This file is marked as favorite"); add("Can create new files from the editor"); add("Can see the information about users from Group2 and users who don’t belong to any group"); + add("Has an avatar"); }}; private static List descriptionUserThird = new ArrayList() {{ @@ -79,19 +81,19 @@ public final class Users { private static List users = new ArrayList() {{ add(new User("uid-1", "John Smith", "smith@example.com", "", null, new CommentGroups(), null, - null, new ArrayList(), descriptionUserFirst, true)); + null, new ArrayList(), descriptionUserFirst, true, true)); add(new User("uid-2", "Mark Pottato", "pottato@example.com", "group-2", Arrays.asList("group-2", ""), new CommentGroups(null, Arrays.asList("group-2", ""), Arrays.asList("group-2")), Arrays.asList("group-2", ""), - true, new ArrayList(), descriptionUserSecond, false)); + true, new ArrayList(), descriptionUserSecond, false, true)); add(new User("uid-3", "Hamish Mitchell", "mitchell@example.com", "group-3", Arrays.asList("group-2"), new CommentGroups(Arrays.asList("group-3", "group-2"), Arrays.asList("group-2"), null), Arrays.asList("group-2"), false, Arrays.asList("copy", "download", "print"), - descriptionUserThird, false)); + descriptionUserThird, false, false)); add(new User("uid-0", null, null, "", null, null, null, - null, Arrays.asList("protect"), descriptionUserZero, false)); + null, Arrays.asList("protect"), descriptionUserZero, false, false)); }}; private Users() { } @@ -124,5 +126,19 @@ public static List> getUsersForMentions(final String id) { } return usersData; } + + public static List> getUsersInfo() { + List> usersData = new ArrayList<>(); + for (User user : users) { + Map data = new HashMap<>(); + data.put("id", user.getId()); + data.put("name", user.getName()); + data.put("email", user.getEmail()); + data.put("image", user.getAvatar() ? DocumentManager.getServerUrl(false) + + "/css/img/" + user.getId() + ".png" : null); + usersData.add(data); + } + return usersData; + } } diff --git a/web/documentserver-example/java/src/main/webapp/css/img/uid-1.png b/web/documentserver-example/java/src/main/webapp/css/img/uid-1.png new file mode 100644 index 0000000000000000000000000000000000000000..91cf9e02ce9c581fd3515f132a68945a8b1dea29 GIT binary patch literal 2226 zcmV;j2u=5iP)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Ox)bu z)6>)9;o#oh-p$R;*45P8+1KFT-{0Tg-{0Th;Nafg-q+XH-QC^I&CSu#(bw14&CJWo z%gfW#)6&w?-rnBc-rmZ}%HQAL+S=OJ*VoO>&CSit%*@QPt*YAC*8BVS-rU;E%*@Eh z$jr>l+1c6I+1b(2(f9TB_xJbu`ueY@r=6RY`}+F(_x7csp0~2C`}_O6wz9movf

z*wfAW_Vf7j@#x~;=i=V$=;Ynq-QM2b(b3V^*x1(A*3{J0-{0TU)6><})yvDv+}zyP z*Vo(I+tSj~+1c69(9qi2+RV(%&(F`!&d$xv%@hm@BNY-K6cP~$2Mh-WI3pYy5f3I9 z7X17CG9nxu5f2y+3`{K~{QCI`1O&jFhE+BzDj5_|H!k}8{+^kbn3RzO0RgL}qC7G$ z;JT(aCL%E%7+N|ov5R;1)xxxoedN8Vk!xB#9vaT1l74q{#GZ;a9~nLaBomZdXlfNIGUgHDXCVUqm~ecxHubU!Z(x z^3c7AVpEfEVN5eD@y)n%O+eVJm+Hl_i-&{SzOg715Tu=%kbrzOD<_G2c$j8WP&_tC zHZMjkBl-6AR4^n)CLPAYzwG7Vd0bC|TuQl1#iEj#a%JS?vNI+uz#O*|wyP zZ(a8B?&iX;nRjN{ub@XOByT=9z@(U?a%1`0$y`rNbZ=~NX=m8i*Q%hO)WyP@YFELo zq_?G;aZ*IimxjBBd}mBPuat+GSXY2ZLt!v4n`d3dm4z`w5|{u006cV3PE!DoP_Ms$ zzYtLGAb)Rv&miwWPrq=VrAaEdX@4xS0&rq-LkiYNW z?~vk>3OoP+1oKHmK~y-)ebskV6G6A5`%X4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001 diff --git a/web/documentserver-example/java/src/main/webapp/css/img/uid-2.png b/web/documentserver-example/java/src/main/webapp/css/img/uid-2.png new file mode 100644 index 0000000000000000000000000000000000000000..651b40c6b91e59c94b2752ddcbe0dac2ffe38cab GIT binary patch literal 2199 zcmV;I2x#|-P)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Oq!vx ze}+AOW?e_fc_WbMi|LXMpNJ~|EXlJ0OxrB?IpQgB&pRoY}0h*z+hK-+` zqqU2Yq?@9&eT0{ak)w!@p@4^(hmN3uh?M3@LM|yN zB`G;IIU5fQI4?1|$=*^xJCnge>*BVWkG+?Pjd*pF zYG5-mI6592q_)mqUS?BQW6s;{h?%%NN@a0_ret-KFefTMGc#o(Xj|XN zy`74L@A&?ZaALrrl%%ArfmTf)AS=hLq4L_!gmZ5|K}Ty?T1YA*oUO(v3<^RqD}aKI zkD$I;YK%}{e3`1pTUlXjaD0)Z!B|H_UsYM4l$Nf))!ypzrmwzge44SYwY0s&p_{x zuivlFzmS)l?Zf~81k_1HK~y-)ebskZ6G<2c;6*{;?xcD?mQx@5_1-IzKtk}uAPWlt z0wj0 z_gH{gti85cPd{o`y=cjX)`Ra}TUJ(^$_FVx=e@SJx=$^(%XeF%#_kE{6p21Q@hJ(g za{<7nrq3+0dr0h&YTl`+RQMbLJTbv6A7E2c6BCmKdbu@;-K|p;ohgdonjmRVc}d%@ ze2W4v63^GGcA1+)eDYjqVx^B%iOXaqB?R7<*i}ejr`g;qHXv*tTwQaiQd)xB5IAmw z2OY$T;4-A0cG7#YY#)iagVh6-!Aimg6k#Ki2H`kC#OHgF*hvf7ZB_v9*=^5NC_}4p z!iLENSSD>NhmXlpy-*G(^fF(dFgsMKB=8EAJWyPrluBhde2n;tPQ4yl&Ce0GEUXS8 zs_G7mHZ){M`(G@l{^N)F$Huu~B({j6_N@Bq2;Dt_tR}STueG)8lXewkFTU&{RunTx?!mizG^|mQ*nD z_VzE~nKngQ7jtw3ttosxE;}yfzucT?|Jc~fj4Ecx@hB3*){tX`5bv`F+regE7Ybt< z9^__^0xsam3DxnauhHE?8hgWWZiPc}!kB;lYR$^d%FWB*i9=MXNOTdA*2P{!804^L zr;bifH&6T-oi*MX$>Rme+mD_!GlQB%-mdl7T1Rp_P>!Fcr+!yOHNy}*-ig4Yp{@)H zgR<4a);Myg&>+X*xG8@@rhjgo8sMTLWjvfT@RE~U1Jgtp-IY}T=3Dgwi8?c!7tZ5J zf)W_>wGO7ON39SZ5BB)2-zK6Yd4llp@S>vR^L&JXh8&DOeR_ou|CG}z5RBEU!)pct zlamJ-j5%##0EZ#DLNbRvyVh^?KvQhyuurI5oE$jGv7sd1{0a-gl|-W9o`ntgKy&`)5ttCD{V3@Mg+^)3TyXWZ}=IgQ_7SLPYS@L_e%_zdn?eCe% zYog08-avYTdiTA@ehIgK?Dp^d$uO66==OUXZ+-iT-`E{GpMCm?@fW`sfArx8+jlJb Z@qh8`Ye}<~)Vcrw002ovPDHLkV1jA>VwC^@ literal 0 HcmV?d00001 diff --git a/web/documentserver-example/java/src/main/webapp/editor.jsp b/web/documentserver-example/java/src/main/webapp/editor.jsp index e90821d62..a471d7440 100644 --- a/web/documentserver-example/java/src/main/webapp/editor.jsp +++ b/web/documentserver-example/java/src/main/webapp/editor.jsp @@ -257,13 +257,34 @@ <% String usersForMentions = (String) request.getAttribute("usersForMentions"); + String usersInfo = (String) request.getAttribute("usersInfo"); %> if (config.editorConfig.user.id) { // add mentions for not anonymous users - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%=usersForMentions%> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "info": + users = []; + var allUsers = <%=usersInfo%>; + for (var i = 0; i < event.data.id.length; i++) { + for (var j = 0; j < allUsers.length; j++) { + if (allUsers[j].id == event.data.id[i]) { + users.push(allUsers[j]); + break; + } + } + } + break; + default: + users = <%=usersForMentions%>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; // the user is mentioned in a comment From 672a351402ac154fe3e6eeaadb198f3c85438b5f Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 6 Nov 2023 10:54:39 +0700 Subject: [PATCH 211/488] csharp-mvc: user image --- CHANGELOG.md | 1 + .../csharp-mvc/Content/images/uid-1.png | Bin 0 -> 2226 bytes .../csharp-mvc/Content/images/uid-2.png | Bin 0 -> 2199 bytes .../csharp-mvc/Helpers/Users.cs | 34 +++++++++++++++--- .../csharp-mvc/Models/FileModel.cs | 11 +++++- .../csharp-mvc/Views/Home/Editor.aspx | 28 +++++++++++++-- 6 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 web/documentserver-example/csharp-mvc/Content/images/uid-1.png create mode 100644 web/documentserver-example/csharp-mvc/Content/images/uid-2.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 24e23c663..638bbc061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp-mvc: user avatar - java: user avatar - java-spring: user avatar - php: user avatar diff --git a/web/documentserver-example/csharp-mvc/Content/images/uid-1.png b/web/documentserver-example/csharp-mvc/Content/images/uid-1.png new file mode 100644 index 0000000000000000000000000000000000000000..91cf9e02ce9c581fd3515f132a68945a8b1dea29 GIT binary patch literal 2226 zcmV;j2u=5iP)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Ox)bu z)6>)9;o#oh-p$R;*45P8+1KFT-{0Tg-{0Th;Nafg-q+XH-QC^I&CSu#(bw14&CJWo z%gfW#)6&w?-rnBc-rmZ}%HQAL+S=OJ*VoO>&CSit%*@QPt*YAC*8BVS-rU;E%*@Eh z$jr>l+1c6I+1b(2(f9TB_xJbu`ueY@r=6RY`}+F(_x7csp0~2C`}_O6wz9movf

z*wfAW_Vf7j@#x~;=i=V$=;Ynq-QM2b(b3V^*x1(A*3{J0-{0TU)6><})yvDv+}zyP z*Vo(I+tSj~+1c69(9qi2+RV(%&(F`!&d$xv%@hm@BNY-K6c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~xAo}L+lU%~`p(qvL#>c05c=9JzwTuWUK52JB5zEzepA!NeENbeA03PIq#?(DQb`qx;W&1f_( zhI`PKjx)Gy8C=F;A?O7PKjFIUGXZNn`NX3EYkYy&-i{19T!{D@=O)NRB1|Evy4es7 zus1PWkU8eQG1HZBAfCasCV|LLs6KUOEH=@wiO=W3@fsIcnhY|RONFy<4E`orBN6&x zrl`8;F9W_<9T8EE68OdOX6JxYYQe!n;ccmsNN}m^VgnKZJ|Cny;0>_D#5M|aVerO; zZ;NG-NfKpucXjigejM)%^7Y+zfamadgLWti2?^PlkWeg-l=S4Nt4=kHfnjV43R0B^R>?56m!4E>GrAYYa0t=A_XDsL<+3JVEoFACcnHQ3bG zm!Frh>lUc0di%90&#QNrg@qNB?O3(y%Fmboe6VZhwrwiadn=xL62AWdpl7dNzcw(i zv%LJ)Cm*kP<{3+x{gLDH53db;_Nm?HlaAy60nijp^WHMgaR2}S07*qoM6N<$g1R-5 A9RL6T literal 0 HcmV?d00001 diff --git a/web/documentserver-example/csharp-mvc/Content/images/uid-2.png b/web/documentserver-example/csharp-mvc/Content/images/uid-2.png new file mode 100644 index 0000000000000000000000000000000000000000..651b40c6b91e59c94b2752ddcbe0dac2ffe38cab GIT binary patch literal 2199 zcmV;I2x#|-P)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Oq!vx ze}+AOW?e_fc_WbMi|LXMpNJ~|EXlJ0OxrB?IpQgB&pRoY}0h*z+hK-+` zqqU2Yq?@9&eT0{ak)w!@p@4^(hmN3uh?M3@LM|yN zB`G;IIU5fQI4?1|$=*^xJCnge>*BVWkG+?Pjd*pF zYG5-mI6592q_)mqUS?BQW6s;{h?%%NN@a0_ret-KFefTMGc#o(Xj|XN zy`74L@A&?ZaALrrl%%ArfmTf)AS=hLq4L_!gmZ5|K}Ty?T1YA*oUO(v3<^RqD}aKI zkD$I;YK%}{e3`1pTUlXjaD0)Z!B|H_UsYM4l$Nf))!ypzrmwzge44SYwY0s&p_{x zuiv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d00001 diff --git a/web/documentserver-example/csharp-mvc/Helpers/Users.cs b/web/documentserver-example/csharp-mvc/Helpers/Users.cs index 6960f0584..d9f0abe43 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/Users.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/Users.cs @@ -31,7 +31,8 @@ public class Users "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Has an avatar" }; static List descr_user_2 = new List() @@ -41,7 +42,8 @@ public class Users "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Has an avatar" }; static List descr_user_3 = new List() @@ -85,6 +87,7 @@ public class Users null, new List(), descr_user_1, + true, true ), new User( @@ -103,7 +106,8 @@ public class Users true, new List(), descr_user_2, - false + false, + true ), new User( "uid-3", @@ -121,6 +125,7 @@ public class Users false, new List() { "copy", "download", "print" }, descr_user_3, + false, false ), new User( @@ -134,6 +139,7 @@ public class Users null, new List() { "protect" }, descr_user_0, + false, false ) }; @@ -171,6 +177,24 @@ public static List> getUsersForMentions(string id) } return usersData; } + + public static List> getUsersInfo(string id) + { + List> usersData = new List>(); + if (id != "uid-0") { + foreach (User user in users) + { + usersData.Add(new Dictionary() + { + {"id", user.id}, + {"name", user.name }, + {"email", user.email }, + {"image", user.avatar ? DocManagerHelper.GetServerUrl(false) + "/Content/images/" + user.id + ".png" : null} + }); + } + } + return usersData; + } } public class User @@ -186,8 +210,9 @@ public class User public List descriptions; public bool templates; public List userInfoGroups; + public bool avatar; - public User(string id, string name, string email, string group, List reviewGroups, Dictionary commentGroups, List userInfoGroups, bool? favorite, List deniedPermissions, List descriptions, bool templates) + public User(string id, string name, string email, string group, List reviewGroups, Dictionary commentGroups, List userInfoGroups, bool? favorite, List deniedPermissions, List descriptions, bool templates, bool avatar) { this.id = id; this.name = name; @@ -200,6 +225,7 @@ public User(string id, string name, string email, string group, List rev this.descriptions = descriptions; this.templates = templates; this.userInfoGroups = userInfoGroups; + this.avatar = avatar; } } } diff --git a/web/documentserver-example/csharp-mvc/Models/FileModel.cs b/web/documentserver-example/csharp-mvc/Models/FileModel.cs index 14ce0f7b5..bd097b047 100755 --- a/web/documentserver-example/csharp-mvc/Models/FileModel.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileModel.cs @@ -190,7 +190,8 @@ public string GetDocConfig(HttpRequest request, UrlHelper url) { { "id", !user.id.Equals("uid-0") ? user.id : null }, { "name", user.name }, - { "group", user.group } + { "group", user.group }, + { "image", user.avatar ? DocManagerHelper.GetServerUrl(false) + "/Content/images/" + user.id + ".png" : null} } }, { @@ -372,5 +373,13 @@ public void GetUsersMentions(HttpRequest request, out string usersForMentions) var user = Users.getUser(id); usersForMentions = !user.id.Equals("uid-0") ? jss.Serialize(Users.getUsersForMentions(user.id)) : null; } + + public void GetUsersInfo(HttpRequest request, out string usersInfo) + { + var jss = new JavaScriptSerializer(); + var id = request.Cookies.GetOrDefault("uid", null); + var user = Users.getUser(id); + usersInfo = jss.Serialize(Users.getUsersInfo(user.id)); + } } } \ No newline at end of file diff --git a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx index 5c9ccdee9..fa4315a3e 100644 --- a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx +++ b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx @@ -254,6 +254,8 @@ <% string usersForMentions; %> <% Model.GetUsersMentions(Request, out usersForMentions); %> + <% string usersInfo; %> + <% Model.GetUsersInfo(Request, out usersInfo); %> if (config.editorConfig.user.id) { // the user is trying to show the document version history @@ -269,9 +271,29 @@ // add mentions for not anonymous users <% if (!string.IsNullOrEmpty(usersForMentions)) { %> - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%= usersForMentions %> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "info": + users = []; + var allUsers = <%= usersInfo %>; + for (var i = 0; i < event.data.id.length; i++) { + for (var j = 0; j < allUsers.length; j++) { + if (allUsers[j].id == event.data.id[i]) { + users.push(allUsers[j]); + break; + } + } + } + break; + default: + users = <%= usersForMentions %>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; <% } %> From 62e2f7426c01a4aa9d030758731b0f7de0ab6ff9 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 6 Nov 2023 11:41:09 +0700 Subject: [PATCH 212/488] csharp: user avatar --- CHANGELOG.md | 1 + .../csharp/App_Themes/images/uid-1.png | Bin 0 -> 2226 bytes .../csharp/App_Themes/images/uid-2.png | Bin 0 -> 2199 bytes .../csharp/DocEditor.aspx | 26 ++++++++++++-- .../csharp/DocEditor.aspx.cs | 7 +++- web/documentserver-example/csharp/Users.cs | 34 +++++++++++++++--- 6 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 web/documentserver-example/csharp/App_Themes/images/uid-1.png create mode 100644 web/documentserver-example/csharp/App_Themes/images/uid-2.png diff --git a/CHANGELOG.md b/CHANGELOG.md index 638bbc061..5bbe64508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp: user avatar - csharp-mvc: user avatar - java: user avatar - java-spring: user avatar diff --git a/web/documentserver-example/csharp/App_Themes/images/uid-1.png b/web/documentserver-example/csharp/App_Themes/images/uid-1.png new file mode 100644 index 0000000000000000000000000000000000000000..91cf9e02ce9c581fd3515f132a68945a8b1dea29 GIT binary patch literal 2226 zcmV;j2u=5iP)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Ox)bu z)6>)9;o#oh-p$R;*45P8+1KFT-{0Tg-{0Th;Nafg-q+XH-QC^I&CSu#(bw14&CJWo z%gfW#)6&w?-rnBc-rmZ}%HQAL+S=OJ*VoO>&CSit%*@QPt*YAC*8BVS-rU;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qex200Ri3O#RqWkAGT7XoyJzq3@`oevsLf7

=@QTFH*%9hw0afZChKaSVs@#Y{l6ET}z+LfFv#J1=E zo7Yg6H~fp)^7%eKJdY)aE!zt5UBTEYmni&n_y5{Al0Do|hQBy`B0yc9$83c3Jlh(4 zffdW;LYeNLzxM?U-`QPi885&dM$q~kEs)r4o3$oIpfV~xAo}L+lU%~`p(qvL#>c05c=9JzwTuWUK52JB5zEzepA!NeENbeA03PIq#?(DQb`qx;W&1f_( zhI`PKjx)Gy8C=F;A?O7PKjFIUGXZNn`NX3EYkYy&-i{19T!{D@=O)NRB1|Evy4es7 zus1PWkU8eQG1HZBAfCasCV|LLs6KUOEH=@wiO=W3@fsIcnhY|RONFy<4E`orBN6&x zrl`8;F9W_<9T8EE68OdOX6JxYYQe!n;ccmsNN}m^VgnKZJ|Cny;0>_D#5M|aVerO; zZ;NG-NfKpucXjigejM)%^7Y+zfamadgLWti2?^PlkWeg-l=S4Nt4=kHfnjV43R0B^R>?56m!4E>GrAYYa0t=A_XDsL<+3JVEoFACcnHQ3bG zm!Frh>lUc0di%90&#QNrg@qNB?O3(y%Fmboe6VZhwrwiadn=xL62AWdpl7dNzcw(i zv%LJ)Cm*kP<{3+x{gLDH53db;_Nm?HlaAy60nijp^WHMgaR2}S07*qoM6N<$g1R-5 A9RL6T literal 0 HcmV?d00001 diff --git a/web/documentserver-example/csharp/App_Themes/images/uid-2.png b/web/documentserver-example/csharp/App_Themes/images/uid-2.png new file mode 100644 index 0000000000000000000000000000000000000000..651b40c6b91e59c94b2752ddcbe0dac2ffe38cab GIT binary patch literal 2199 zcmV;I2x#|-P)Px#32;bRa{vGf6951U69E94oEQKA0{~D=R7FQ{Oq!vx ze}+AOW?e_fc_WbMi|LXMpNJ~|EXlJ0OxrB?IpQgB&pRoY}0h*z+hK-+` zqqU2Yq?@9&eT0{ak)w!@p@4^(hmN3uh?M3@LM|yN zB`G;IIU5fQI4?1|$=*^xJCnge>*BVWkG+?Pjd*pF zYG5-mI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1{0a-gl|-W9o`ntgKy&`)5ttCD{V3@Mg+^)3TyXWZ}=IgQ_7SLPYS@L_e%_zdn?eCe% zYog08-avYTdiTA@ehIgK?Dp^d$uO66==OUXZ+-iT-`E{GpMCm?@fW`sfArx8+jlJb Z@qh8`Ye}<~)Vcrw002ovPDHLkV1jA>VwC^@ literal 0 HcmV?d00001 diff --git a/web/documentserver-example/csharp/DocEditor.aspx b/web/documentserver-example/csharp/DocEditor.aspx index 4d2540589..e4c6cdb62 100644 --- a/web/documentserver-example/csharp/DocEditor.aspx +++ b/web/documentserver-example/csharp/DocEditor.aspx @@ -272,9 +272,29 @@ // add mentions for not anonymous users <% if (!string.IsNullOrEmpty(UsersForMentions)) { %> - config.events['onRequestUsers'] = function () { - docEditor.setUsers({ // set a list of users to mention in the comments - "users": <%= UsersForMentions %> + config.events['onRequestUsers'] = function (event) { + if (event && event.data){ + var c = event.data.c; + } + switch (c) { + case "info": + users = []; + var allUsers = <%= UsersInfo %>; + for (var i = 0; i < event.data.id.length; i++) { + for (var j = 0; j < allUsers.length; j++) { + if (allUsers[j].id == event.data.id[i]) { + users.push(allUsers[j]); + break; + } + } + } + break; + default: + users = <%= UsersForMentions %>; + } + docEditor.setUsers({ + "c": c, + "users": users, }); }; <% } %> diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs index 334112a9a..28a2a67da 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -64,6 +64,7 @@ protected string DocServiceApiUri protected string DocumentData { get; private set; } protected string DataSpreadsheet { get; private set; } protected string UsersForMentions { get; private set; } + protected string UsersInfo { get; private set; } protected string DocumentType { get { return _Default.DocumentType(FileName); } } // get callback url @@ -256,7 +257,8 @@ protected void Page_Load(object sender, EventArgs e) { { "id", !user.id.Equals("uid-0") ? user.id : null }, { "name", user.name }, - { "group", user.group } + { "group", user.group }, + { "image", user.avatar ? _Default.GetServerUrl(false) + "/App_Themes/images/"+ user.id + ".png" : null } } }, { @@ -317,6 +319,9 @@ protected void Page_Load(object sender, EventArgs e) // get users for mentions List> usersData = Users.getUsersForMentions(user.id); UsersForMentions = !user.id.Equals("uid-0") ? jss.Serialize(usersData) : null; + + List> usersInfo = Users.getUsersInfo(user.id); + UsersInfo = jss.Serialize(usersData); } catch { } } diff --git a/web/documentserver-example/csharp/Users.cs b/web/documentserver-example/csharp/Users.cs index 1dea57de9..40c250a06 100644 --- a/web/documentserver-example/csharp/Users.cs +++ b/web/documentserver-example/csharp/Users.cs @@ -30,7 +30,8 @@ public class Users "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Has an avatar" }; static List descr_user_2 = new List() @@ -40,7 +41,8 @@ public class Users "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Has an avatar" }; static List descr_user_3 = new List() @@ -84,6 +86,7 @@ public class Users null, new List(), descr_user_1, + true, true ), new User( @@ -102,7 +105,8 @@ public class Users true, new List(), descr_user_2, - false + false, + true ), new User( "uid-3", @@ -120,6 +124,7 @@ public class Users false, new List() { "copy", "download", "print" }, descr_user_3, + false, false ), new User( @@ -133,6 +138,7 @@ public class Users null, new List() { "protect" }, descr_user_0, + false, false ) }; @@ -171,6 +177,24 @@ public static List> getUsersForMentions(string id) } return usersData; } + + public static List> getUsersInfo(string id) + { + List> usersData = new List>(); + if(id != "uid-0"){ + foreach (User user in users) + { + usersData.Add(new Dictionary() + { + {"id", user.id}, + {"name", user.name }, + {"email", user.email }, + {"image", user.avatar ? _Default.GetServerUrl(false) + "/App_Themes/images/"+ user.id + ".png" : null } + }); + } + } + return usersData; + } } public class User @@ -186,8 +210,9 @@ public class User public List descriptions; public bool templates; public List userInfoGroups; + public bool avatar; - public User(string id, string name, string email, string group, List reviewGroups, Dictionary commentGroups, List userInfoGroups, bool? favorite, List deniedPermissions, List descriptions, bool templates) + public User(string id, string name, string email, string group, List reviewGroups, Dictionary commentGroups, List userInfoGroups, bool? favorite, List deniedPermissions, List descriptions, bool templates, bool avatar) { this.id = id; this.name = name; @@ -200,6 +225,7 @@ public User(string id, string name, string email, string group, List rev this.descriptions = descriptions; this.templates = templates; this.userInfoGroups = userInfoGroups; + this.avatar = avatar; } } } From f620da3b98a0773de647bf0ff34bbff3a82e3e78 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 6 Nov 2023 12:02:38 +0700 Subject: [PATCH 213/488] java: empty usersInfo for anonymous --- .../main/java/controllers/EditorServlet.java | 2 +- .../java/src/main/java/helpers/Users.java | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java b/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java index fad184190..0cc639967 100644 --- a/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/EditorServlet.java @@ -107,7 +107,7 @@ protected void processRequest(final HttpServletRequest request, // users data for mentions List> usersForMentions = Users.getUsersForMentions(user.getId()); - List> usersInfo = Users.getUsersInfo(); + List> usersInfo = Users.getUsersInfo(user.getId()); // check if the document token is enabled if (DocumentManager.tokenEnabled()) { diff --git a/web/documentserver-example/java/src/main/java/helpers/Users.java b/web/documentserver-example/java/src/main/java/helpers/Users.java index ca9b1ca8b..969bb2a60 100755 --- a/web/documentserver-example/java/src/main/java/helpers/Users.java +++ b/web/documentserver-example/java/src/main/java/helpers/Users.java @@ -127,16 +127,18 @@ public static List> getUsersForMentions(final String id) { return usersData; } - public static List> getUsersInfo() { + public static List> getUsersInfo(final String id) { List> usersData = new ArrayList<>(); - for (User user : users) { - Map data = new HashMap<>(); - data.put("id", user.getId()); - data.put("name", user.getName()); - data.put("email", user.getEmail()); - data.put("image", user.getAvatar() ? DocumentManager.getServerUrl(false) - + "/css/img/" + user.getId() + ".png" : null); - usersData.add(data); + if (id != "uid-0") { + for (User user : users) { + Map data = new HashMap<>(); + data.put("id", user.getId()); + data.put("name", user.getName()); + data.put("email", user.getEmail()); + data.put("image", user.getAvatar() ? DocumentManager.getServerUrl(false) + + "/css/img/" + user.getId() + ".png" : null); + usersData.add(data); + } } return usersData; } From 65b9bfec01167fda8e60e5cb4d78ef9926080710 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 6 Nov 2023 09:55:45 +0300 Subject: [PATCH 214/488] java-spring: remove logo parameter in config and Logo.java class --- .../models/configurations/Customization.java | 2 - .../models/configurations/Logo.java | 38 ------------------- .../src/main/resources/application.properties | 4 -- 3 files changed, 44 deletions(-) delete mode 100755 web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Logo.java diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Customization.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Customization.java index 821b6dfe7..bcfad7db1 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Customization.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Customization.java @@ -32,8 +32,6 @@ other products (if there are any) and change the presence or absence of the additional buttons, links, change logos and editor owner details. */ public class Customization { - @Autowired - private Logo logo; // the image file at the top left corner of the Editor header @Autowired private Goback goback; // the settings for the Open file location menu button and upper right corner button private Boolean autosave = true; // if the Autosave menu option is enabled or disabled diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Logo.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Logo.java deleted file mode 100755 index ba66376bc..000000000 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Logo.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * - * (c) Copyright Ascensio System SIA 2023 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.onlyoffice.integration.documentserver.models.configurations; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; - -@Component -@Scope("prototype") -@Getter -@Setter -public class Logo { // the image file at the top left corner of the Editor header - @Value("${logo.image}") - private String image; // the path to the image file used to show in common work mode - @Value("${logo.imageEmbedded}") - private String imageEmbedded; // the path to the image file used to show in the embedded mode - @Value("${logo.url}") - private String url; // the absolute URL which will be used when someone clicks the logo image -} diff --git a/web/documentserver-example/java-spring/src/main/resources/application.properties b/web/documentserver-example/java-spring/src/main/resources/application.properties index 9c4c3f773..2fefdaf83 100755 --- a/web/documentserver-example/java-spring/src/main/resources/application.properties +++ b/web/documentserver-example/java-spring/src/main/resources/application.properties @@ -43,7 +43,3 @@ url.converter=/converter url.editor=/editor url.track=/track url.download=/download - -logo.image= -logo.imageEmbedded= -logo.url=https://www.onlyoffice.com From 089819cdc4b91e8d3aa66b36bca9d6c3d2200b10 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Mon, 6 Nov 2023 14:43:33 +0300 Subject: [PATCH 215/488] setUsers for region protection in changelog --- CHANGELOG.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bef986f63..0c7e01256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,6 @@ # Change Log -- csharp: setUsers for region protection -- csharp-mvc: setUsers for region protection -- java: setUsers for region protection -- java-spring: setUsers for region protection -- php: setUsers for region protection -- python: setUsers for region protection -- ruby: setUsers for region protection +- setUsers for region protection - onRequestOpen method - nodejs: user avatar - trimming long name of uploading file From 794e578a376909d993f516cd5009bf84f55684a6 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 7 Nov 2023 12:00:51 +0700 Subject: [PATCH 216/488] merging fix --- web/documentserver-example/php/src/views/DocEditorView.php | 6 +++--- web/documentserver-example/python/src/views/actions.py | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/php/src/views/DocEditorView.php b/web/documentserver-example/php/src/views/DocEditorView.php index fc5ecf775..79e520395 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -226,8 +226,8 @@ public function __construct($request, $tempName = "docEditor") $usersForProtect = $user->id != "uid-0" ? $userList->getUsersForProtect($user->id) : null; $usersInfo = []; - if ($user->id != 'uid-0'){ - foreach ($userList->getAllUsers() as $userInfo){ + if ($user->id != 'uid-0') { + foreach ($userList->getAllUsers() as $userInfo) { $u = $userInfo; $u->image = $userInfo->avatar ? serverPath(true) . "/assets/images/" . $userInfo->id . ".png" : null; array_push($usersInfo, $u); @@ -315,7 +315,7 @@ public function __construct($request, $tempName = "docEditor") "config" => json_encode($config), "history" => $historyLayout, "usersForMentions" => json_encode($usersForMentions), - "usersInfo" => json_encode($usersInfo) + "usersInfo" => json_encode($usersInfo), "usersForProtect" => json_encode($usersForProtect), ]; } diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index 7411465bf..fca6c1c15 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -238,7 +238,7 @@ def edit(request): u = userInfo u.image = docManager.getServerUrl(True, request) + f'/static/images/{u.id}.jpg' if user.avatar else None usersInfo.append({"id": u.id, "name": u.name, "email": u.email, "image": u.image, "group": u.group, - "reviewGroups":u.reviewGroups, "commentGroups":u.commentGroups, "favorite": u.favorite, + "reviewGroups": u.reviewGroups, "commentGroups": u.commentGroups, "favorite": u.favorite, "deniedPermissions": u.deniedPermissions, "descriptions": u.descriptions, "templates": u.templates, "userInfoGroups": u.userInfoGroups, "avatar": u.avatar}) @@ -305,7 +305,8 @@ def edit(request): 'id': user.id if user.id != 'uid-0' else None, 'name': user.name, 'group': user.group, - 'image': docManager.getServerUrl(True, request) + f'/static/images/{user.id}.jpg' if user.avatar else None + 'image': docManager.getServerUrl(True, request) + f'/static/images/{user.id}.jpg' if user.avatar + else None }, 'embedded': { # the parameters for the embedded document type # the absolute URL that will allow the document to be saved onto the user personal computer @@ -386,7 +387,7 @@ def edit(request): 'dataInsertImage': json.dumps(dataInsertImage)[1: len(json.dumps(dataInsertImage)) - 1], 'dataDocument': dataDocument, # document which will be compared with the current document 'dataSpreadsheet': json.dumps(dataSpreadsheet), # recipient data for mail merging - 'usersForMentions': json.dumps(usersForMentions) if user.id !='uid-0' else None, + 'usersForMentions': json.dumps(usersForMentions) if user.id != 'uid-0' else None, 'usersInfo': json.dumps(usersInfo), 'usersForProtect': json.dumps(usersForProtect) if user.id != 'uid-0' else None, } From e18d36f18de9271dd89d4e7d779cd48178e326b5 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 7 Nov 2023 12:43:05 +0700 Subject: [PATCH 217/488] php: convert after uploading only tagged formats --- CHANGELOG.md | 1 + web/documentserver-example/php/assets/document-formats | 2 +- web/documentserver-example/php/src/format/FormatManager.php | 5 +---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c7e01256..722ddc7c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- php: convert after uploading only tagged formats - setUsers for region protection - onRequestOpen method - nodejs: user avatar diff --git a/web/documentserver-example/php/assets/document-formats b/web/documentserver-example/php/assets/document-formats index 6e38b1767..bf21acc76 160000 --- a/web/documentserver-example/php/assets/document-formats +++ b/web/documentserver-example/php/assets/document-formats @@ -1 +1 @@ -Subproject commit 6e38b17679e4939684b067a9175e3bc64cf7923c +Subproject commit bf21acc7666b9ddb64606247f5afb119952f8475 diff --git a/web/documentserver-example/php/src/format/FormatManager.php b/web/documentserver-example/php/src/format/FormatManager.php index fcbf8dc51..fd4ee84ee 100644 --- a/web/documentserver-example/php/src/format/FormatManager.php +++ b/web/documentserver-example/php/src/format/FormatManager.php @@ -147,10 +147,7 @@ public function convertible(): array $formats = $this->all(); $filtered = []; foreach ($formats as $format) { - if ($format->type === 'cell' and in_array('xlsx', $format->convert) or - $format->type === 'slide' and in_array('pptx', $format->convert) or - $format->type === 'word' and in_array('docx', $format->convert) - ) { + if (in_array('auto-convert', $format->actions)) { $filtered[] = $format; } } From d3185253a872e6223f18d8912fe68722195c7bab Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 7 Nov 2023 12:56:06 +0700 Subject: [PATCH 218/488] python: convert after uploading only tagged formats --- CHANGELOG.md | 1 + web/documentserver-example/python/assets/document-formats | 2 +- web/documentserver-example/python/src/format/format.py | 4 +--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 722ddc7c9..69dbf29e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- python: convert after uploading only tagged formats - php: convert after uploading only tagged formats - setUsers for region protection - onRequestOpen method diff --git a/web/documentserver-example/python/assets/document-formats b/web/documentserver-example/python/assets/document-formats index 6e38b1767..bf21acc76 160000 --- a/web/documentserver-example/python/assets/document-formats +++ b/web/documentserver-example/python/assets/document-formats @@ -1 +1 @@ -Subproject commit 6e38b17679e4939684b067a9175e3bc64cf7923c +Subproject commit bf21acc7666b9ddb64606247f5afb119952f8475 diff --git a/web/documentserver-example/python/src/format/format.py b/web/documentserver-example/python/src/format/format.py index f9d87563f..494897078 100644 --- a/web/documentserver-example/python/src/format/format.py +++ b/web/documentserver-example/python/src/format/format.py @@ -77,9 +77,7 @@ def convertible(self) -> list[Format]: formats = self.all() filtered = filter( lambda format: ( - format.type == 'cell' and 'xlsx' in format.convert or - format.type == 'slide' and 'pptx' in format.convert or - format.type == 'word' and 'docx' in format.convert + 'auto-convert' in format.actions ), formats ) From f7386df0504f877ef4842c41467f41528e5d7b16 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 7 Nov 2023 13:01:27 +0700 Subject: [PATCH 219/488] ruby: convert after uploading only tagged formats --- CHANGELOG.md | 1 + web/documentserver-example/ruby/app/format/format.rb | 4 +--- web/documentserver-example/ruby/assets/document-formats | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69dbf29e0..f750a1478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- ruby: convert after uploading only tagged formats - python: convert after uploading only tagged formats - php: convert after uploading only tagged formats - setUsers for region protection diff --git a/web/documentserver-example/ruby/app/format/format.rb b/web/documentserver-example/ruby/app/format/format.rb index 314b9144b..130210fa2 100644 --- a/web/documentserver-example/ruby/app/format/format.rb +++ b/web/documentserver-example/ruby/app/format/format.rb @@ -88,9 +88,7 @@ def convertible_extensions sig { returns(T::Array[Format]) } def convertible all.filter do |format| - format.type == 'cell' && format.convert.include?('xlsx') || - format.type == 'slide' && format.convert.include?('pptx') || - format.type == 'word' && format.convert.include?('docx') + format.actions.include?('auto-convert') end end diff --git a/web/documentserver-example/ruby/assets/document-formats b/web/documentserver-example/ruby/assets/document-formats index 6e38b1767..bf21acc76 160000 --- a/web/documentserver-example/ruby/assets/document-formats +++ b/web/documentserver-example/ruby/assets/document-formats @@ -1 +1 @@ -Subproject commit 6e38b17679e4939684b067a9175e3bc64cf7923c +Subproject commit bf21acc7666b9ddb64606247f5afb119952f8475 From 2ee051e9fc08907fbaef818a9b2dee4dc4d0e612 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 8 Nov 2023 11:38:04 +0700 Subject: [PATCH 220/488] java-spring: 'uid-' prefix was returned to User class id field --- .../integration/documentserver/models/filemodel/User.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/User.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/User.java index 602988689..71ad9aeb4 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/User.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/filemodel/User.java @@ -39,7 +39,7 @@ public class User extends AbstractModel { // the user configuration parameters public void configure(final int idParam, final String nameParam, final String groupParam) { - this.id = "" + idParam; // the user id + this.id = "uid-" + idParam; // the user id this.name = nameParam; // the user name this.group = groupParam; // the group the user belongs to this.image = storagePathBuilder.getServerUrl(true) + "/css/img/uid-" + this.id + ".png"; From d75a4c529d3b5026d5e6d7e355e0032b0a5910b0 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 8 Nov 2023 12:17:42 +0700 Subject: [PATCH 221/488] ruby: renaming asset method to assets --- .../ruby/app/controllers/home_controller.rb | 2 +- web/documentserver-example/ruby/config/application.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 988370dcb..e473656ec 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -279,7 +279,7 @@ def csv end # downloading an assets file - def asset + def assets file_name = File.basename(params[:fileName]) asset_path = Rails.root.join('assets', 'document-templates', 'sample', file_name) diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index 6b39993d0..12dfd4df0 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -28,7 +28,7 @@ class Application < Rails::Application root to: 'home#index' match '/convert', to: 'home#convert', via: 'post' match '/csv', to: 'home#csv', via: 'get' - match '/asset', to: 'home#asset', via: 'get' + match '/asset', to: 'home#assets', via: 'get' match '/download', to: 'home#download', via: 'get' match '/downloadhistory', to: 'home#downloadhistory', via: 'get' match '/editor', to: 'home#editor', via: 'get' From 7c57b0f575b6e088c7b0e119d1fae3efe7a77a6f Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 8 Nov 2023 13:08:07 +0700 Subject: [PATCH 222/488] python: code refactoring --- web/documentserver-example/python/manage.py | 2 +- .../python/src/views/actions.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/web/documentserver-example/python/manage.py b/web/documentserver-example/python/manage.py index 4311d80b4..af8c700d6 100644 --- a/web/documentserver-example/python/manage.py +++ b/web/documentserver-example/python/manage.py @@ -70,7 +70,7 @@ def routers(): path('csv', actions.csv), path('download', actions.download), path('downloadhistory', actions.downloadhistory), - path('historyobj', actions.historyobj), + path('historyobj', actions.history_obj), path('edit', actions.edit), path('files', actions.files), path('reference', actions.reference), diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index d4081d06d..54392dd4e 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -498,24 +498,24 @@ def downloadhistory(request): return HttpResponse(json.dumps(response), content_type='application/json', status=404) -def historyobj(request): +def history_obj(request): body = json.loads(request.body) response = {} - fileName = None + file_name = None try: - fileName = body['fileName'] + file_name = body['fileName'] except Exception: pass - if fileName is None: + if file_name is None: response.setdefault('error', 'File not found') return HttpResponse(json.dumps(response), content_type='application/json', status=404) - storagePath = docManager.getStoragePath(fileName, request) - docKey = docManager.generateFileKey(fileName, request) - fileUrl = docManager.getDownloadUrl(fileName, request) - response = historyManager.getHistoryObject(storagePath, fileName, docKey, fileUrl, False, request) + storage_path = docManager.getStoragePath(file_name, request) + doc_key = docManager.generateFileKey(file_name, request) + file_url = docManager.getDownloadUrl(file_name, request) + response = historyManager.getHistoryObject(storage_path, file_name, doc_key, file_url, False, request) return HttpResponse(json.dumps(response), content_type='application/json') From 030985bbebed05c70035fd8c2df792eadb4a2ccc Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 8 Nov 2023 15:02:58 +0300 Subject: [PATCH 223/488] csharp: moved the submodule to the assets/document-templates subfolder --- .gitmodules | 8 ++++---- web/documentserver-example/csharp/DocEditor.aspx.cs | 2 +- web/documentserver-example/csharp/WebEditor.ashx.cs | 4 ++-- .../csharp/{assets => assets/document-templates} | 0 4 files changed, 7 insertions(+), 7 deletions(-) rename web/documentserver-example/csharp/{assets => assets/document-templates} (100%) diff --git a/.gitmodules b/.gitmodules index ea03c04be..3a2744ed3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,10 +2,6 @@ path = web/documentserver-example/csharp-mvc/assets url = https://github.com/ONLYOFFICE/document-templates branch = main/en -[submodule "web/documentserver-example/csharp/assets"] - path = web/documentserver-example/csharp/assets - url = https://github.com/ONLYOFFICE/document-templates - branch = main/en [submodule "web/documentserver-example/nodejs/public/assets/document-templates"] path = web/documentserver-example/nodejs/public/assets/document-templates url = https://github.com/ONLYOFFICE/document-templates @@ -54,3 +50,7 @@ path = web/documentserver-example/java-spring/src/main/resources/assets/document-formats url = https://github.com/ONLYOFFICE/document-formats branch = master +[submodule "web/documentserver-example/csharp/assets/document-templates"] + path = web/documentserver-example/csharp/assets/document-templates + url = https://github.com/ONLYOFFICE/document-templates + branch = main/en diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs index 2184c4116..8fc1e540d 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -489,7 +489,7 @@ private static void Try(string type, string sample, HttpRequest request) return; } var demoName = (string.IsNullOrEmpty(sample) ? "new" : "sample") + ext; // create demo document name with the necessary extension - var demoPath = "assets\\" + (string.IsNullOrEmpty(sample) ? "new\\" : "sample\\"); // and put this file into the assets directory + var demoPath = "assets\\document-templates\\" + (string.IsNullOrEmpty(sample) ? "new\\" : "sample\\"); // and put this file into the assets directory FileName = _Default.GetCorrectName(demoName); // get file name with an index if such a file name already exists diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index 2b2a75929..ed1fad984 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -275,7 +275,7 @@ private static void Files(HttpContext context) private static void Assets(HttpContext context) { var fileName = Path.GetFileName(context.Request["filename"]); - var filePath = HttpRuntime.AppDomainAppPath + "assets/sample/" + fileName; + var filePath = HttpRuntime.AppDomainAppPath + "assets/document-templates/sample/" + fileName; download(filePath, context); } @@ -283,7 +283,7 @@ private static void Assets(HttpContext context) private static void GetCsv(HttpContext context) { var fileName = "csv.csv"; - var filePath = HttpRuntime.AppDomainAppPath + "assets/sample/" + fileName; + var filePath = HttpRuntime.AppDomainAppPath + "assets/document-templates/sample/" + fileName; download(filePath, context); } diff --git a/web/documentserver-example/csharp/assets b/web/documentserver-example/csharp/assets/document-templates similarity index 100% rename from web/documentserver-example/csharp/assets rename to web/documentserver-example/csharp/assets/document-templates From c91fbf6320cb251ef1174a7c7ea3ea3ca41135e2 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 8 Nov 2023 15:24:14 +0300 Subject: [PATCH 224/488] csharp: add document-formats submodule --- .gitmodules | 3 +++ web/documentserver-example/csharp/assets/document-formats | 1 + 2 files changed, 4 insertions(+) create mode 160000 web/documentserver-example/csharp/assets/document-formats diff --git a/.gitmodules b/.gitmodules index 3a2744ed3..49e6a0a6f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -54,3 +54,6 @@ path = web/documentserver-example/csharp/assets/document-templates url = https://github.com/ONLYOFFICE/document-templates branch = main/en +[submodule "web/documentserver-example/csharp/assets/document-formats"] + path = web/documentserver-example/csharp/assets/document-formats + url = https://github.com/ONLYOFFICE/document-formats diff --git a/web/documentserver-example/csharp/assets/document-formats b/web/documentserver-example/csharp/assets/document-formats new file mode 160000 index 000000000..bf21acc76 --- /dev/null +++ b/web/documentserver-example/csharp/assets/document-formats @@ -0,0 +1 @@ +Subproject commit bf21acc7666b9ddb64606247f5afb119952f8475 From 28c8410e7d2ffbddb9cb36bcf4108fdccd3496ba Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 9 Nov 2023 09:51:43 +0300 Subject: [PATCH 225/488] csharp: add format module --- .../csharp/FormatManager.cs | 188 ++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 web/documentserver-example/csharp/FormatManager.cs diff --git a/web/documentserver-example/csharp/FormatManager.cs b/web/documentserver-example/csharp/FormatManager.cs new file mode 100644 index 000000000..37d2df5c6 --- /dev/null +++ b/web/documentserver-example/csharp/FormatManager.cs @@ -0,0 +1,188 @@ +/** + * + * (c) Copyright Ascensio System SIA 2023 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Newtonsoft.Json; + +namespace OnlineEditorsExample +{ + public class Format + { + public string Name { get; } + public string Type { get; } + public List Actions { get; } + public List Convert { get; } + public List Mime { get; } + + public Format(string name, string type, List actions, List convert, List mime) + { + Name = name; + Type = type; + Actions = actions; + Convert = convert; + Mime = mime; + } + + public string Extension() + { + return "." + Name; + } + } + + public class FormatManager + { + public static List FillableExtensions() + { + return Fillable() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Fillable() + { + return All() + .Where(format => format.Actions.Contains("fill")) + .ToList(); + } + + public static List ViewableExtensions() + { + return Viewable() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Viewable() + { + return All() + .Where(format => format.Actions.Contains("view")) + .ToList(); + } + + public static List EditableExtensions() + { + return Editable() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Editable() + { + return All() + .Where(format => format.Actions.Contains("edit") || format.Actions.Contains("lossy-edit")) + .ToList(); + } + + public static List ConvertibleExtensions() + { + return Convertible() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Convertible() + { + return All() + .Where(format => (format.Type == "cell" && format.Convert.Contains("xlsx")) + || (format.Type == "slide" && format.Convert.Contains("pptx")) + || (format.Type == "word" && format.Convert.Contains("docx"))) + .ToList(); + } + + public static List SpreadsheetExtensions() + { + return Spreadsheets() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Spreadsheets() + { + return All() + .Where(format => format.Type == "cell") + .ToList(); + } + + public static List PresentationExtensions() + { + return Presentations() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Presentations() + { + return All() + .Where(format => format.Type == "slide") + .ToList(); + } + + public static List DocumentExtensions() + { + return Documents() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Documents() + { + return All() + .Where(format => format.Type == "word") + .ToList(); + } + + public static List AllExtensions() + { + return All() + .Select(format => format.Extension()) + .ToList(); + } + + public static List All() + { + var path = GetPath(); + var lines = File.ReadLines(path, Encoding.UTF8); + var contents = string.Join(Environment.NewLine, lines); + var formats = JsonConvert.DeserializeObject(contents); + return formats.ToList(); + } + + private static string GetPath() + { + string path = Path.Combine(GetDirectory(), "onlyoffice-docs-formats.json"); + if (File.Exists(path)) + { + return path; + } + else + { + throw new FileNotFoundException("The JSON file does not exist."); + } + } + + private static string GetDirectory() + { + string directory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets", "document-formats"); + return Path.GetFullPath(directory); + } + } +} \ No newline at end of file From 0057b81adc72fe19d1fe82f9775a8f0c611f1fa8 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 9 Nov 2023 09:56:55 +0300 Subject: [PATCH 226/488] csharp-mvc: moved the submodule to the assets/document-templates subfolder --- .gitmodules | 8 +++---- .../csharp-mvc/Helpers/DocManagerHelper.cs | 2 +- .../csharp-mvc/OnlineEditorsExampleMVC.csproj | 23 ++++++++++--------- .../csharp-mvc/WebEditor.ashx.cs | 4 ++-- .../{assets => assets/document-templates} | 0 5 files changed, 19 insertions(+), 18 deletions(-) rename web/documentserver-example/csharp-mvc/{assets => assets/document-templates} (100%) diff --git a/.gitmodules b/.gitmodules index ea03c04be..985a0e5f3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "web/documentserver-example/csharp-mvc/assets"] - path = web/documentserver-example/csharp-mvc/assets - url = https://github.com/ONLYOFFICE/document-templates - branch = main/en [submodule "web/documentserver-example/csharp/assets"] path = web/documentserver-example/csharp/assets url = https://github.com/ONLYOFFICE/document-templates @@ -54,3 +50,7 @@ path = web/documentserver-example/java-spring/src/main/resources/assets/document-formats url = https://github.com/ONLYOFFICE/document-formats branch = master +[submodule "web/documentserver-example/csharp-mvc/assets/document-templates"] + path = web/documentserver-example/csharp-mvc/assets/document-templates + url = https://github.com/ONLYOFFICE/document-templates + branch = main/en diff --git a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs index 4de692969..7721001c2 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs @@ -220,7 +220,7 @@ public static List GetStoredFiles() public static string CreateDemo(string fileExt, bool withContent) { var demoName = (withContent ? "sample." : "new.") + fileExt; // create sample or new template file with the necessary extension - var demoPath = "assets\\" + (withContent ? "sample\\" : "new\\"); // get the path to the sample document + var demoPath = "assets\\document-templates\\" + (withContent ? "sample\\" : "new\\"); // get the path to the sample document var fileName = GetCorrectName(demoName); // get a file name with an index if the file with such a name already exists diff --git a/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj b/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj index c7d6abc25..3691fc7dc 100644 --- a/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj +++ b/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj @@ -181,17 +181,18 @@ - - - - - - - - - - - + + + + + + + + + + + + diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index 89487893e..70d40e36f 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -453,7 +453,7 @@ private static void Files(HttpContext context) private static void Assets(HttpContext context) { var fileName = Path.GetFileName(context.Request["filename"]); - var filePath = HttpRuntime.AppDomainAppPath + "assets/sample/" + fileName; + var filePath = HttpRuntime.AppDomainAppPath + "assets/document-templates/sample/" + fileName; download(filePath, context); } @@ -461,7 +461,7 @@ private static void Assets(HttpContext context) private static void GetCsv(HttpContext context) { var fileName = "csv.csv"; - var filePath = HttpRuntime.AppDomainAppPath + "assets/sample/" + fileName; + var filePath = HttpRuntime.AppDomainAppPath + "assets/document-templates/sample/" + fileName; download(filePath, context); } diff --git a/web/documentserver-example/csharp-mvc/assets b/web/documentserver-example/csharp-mvc/assets/document-templates similarity index 100% rename from web/documentserver-example/csharp-mvc/assets rename to web/documentserver-example/csharp-mvc/assets/document-templates From 6350e33c64b8133c3cdf2a35feebd58cbc8005ce Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Fri, 10 Nov 2023 11:10:06 +0300 Subject: [PATCH 227/488] csharp-mvc: add document-formats submodule --- .gitmodules | 3 +++ web/documentserver-example/csharp-mvc/assets/document-formats | 1 + 2 files changed, 4 insertions(+) create mode 160000 web/documentserver-example/csharp-mvc/assets/document-formats diff --git a/.gitmodules b/.gitmodules index 985a0e5f3..04bd88a9b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -54,3 +54,6 @@ path = web/documentserver-example/csharp-mvc/assets/document-templates url = https://github.com/ONLYOFFICE/document-templates branch = main/en +[submodule "web/documentserver-example/csharp-mvc/assets/document-formats"] + path = web/documentserver-example/csharp-mvc/assets/document-formats + url = https://github.com/ONLYOFFICE/document-formats diff --git a/web/documentserver-example/csharp-mvc/assets/document-formats b/web/documentserver-example/csharp-mvc/assets/document-formats new file mode 160000 index 000000000..bf21acc76 --- /dev/null +++ b/web/documentserver-example/csharp-mvc/assets/document-formats @@ -0,0 +1 @@ +Subproject commit bf21acc7666b9ddb64606247f5afb119952f8475 From 9b9049a2fc30b5719a96e7d18c19fe501a9e0544 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Fri, 10 Nov 2023 12:32:38 +0300 Subject: [PATCH 228/488] csharp-mvc: add format module --- .../csharp-mvc/Models/FileUtility.cs | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) diff --git a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs index 7463daf90..f7eb6d8e2 100644 --- a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs @@ -16,8 +16,13 @@ * */ +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.IO; +using static OnlineEditorsExampleMVC.Models.FileUtility; +using System.Linq; +using System.Text; namespace OnlineEditorsExampleMVC.Models { @@ -69,4 +74,165 @@ public static FileType GetFileType(string fileName) ".odp", ".fodp", ".otp" }; } + + public class Format + { + public string Name { get; } + public FileType Type { get; } + public List Actions { get; } + public List Convert { get; } + public List Mime { get; } + + public Format(string name, FileType type, List actions, List convert, List mime) + { + Name = name; + Type = type; + Actions = actions; + Convert = convert; + Mime = mime; + } + + public string Extension() + { + return "." + Name; + } + } + + public class FormatManager + { + public static List FillableExtensions() + { + return Fillable() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Fillable() + { + return All() + .Where(format => format.Actions.Contains("fill")) + .ToList(); + } + + public static List ViewableExtensions() + { + return Viewable() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Viewable() + { + return All() + .Where(format => format.Actions.Contains("view")) + .ToList(); + } + + public static List EditableExtensions() + { + return Editable() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Editable() + { + return All() + .Where(format => format.Actions.Contains("edit") || format.Actions.Contains("lossy-edit")) + .ToList(); + } + + public static List ConvertibleExtensions() + { + return Convertible() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Convertible() + { + return All() + .Where(format => (format.Type == FileType.Cell && format.Convert.Contains("xlsx")) + || (format.Type == FileType.Slide && format.Convert.Contains("pptx")) + || (format.Type == FileType.Word && format.Convert.Contains("docx"))) + .ToList(); + } + + public static List SpreadsheetExtensions() + { + return Spreadsheets() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Spreadsheets() + { + return All() + .Where(format => format.Type == FileType.Cell) + .ToList(); + } + + public static List PresentationExtensions() + { + return Presentations() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Presentations() + { + return All() + .Where(format => format.Type == FileType.Slide) + .ToList(); + } + + public static List DocumentExtensions() + { + return Documents() + .Select(format => format.Extension()) + .ToList(); + } + + public static List Documents() + { + return All() + .Where(format => format.Type == FileType.Word) + .ToList(); + } + + public static List AllExtensions() + { + return All() + .Select(format => format.Extension()) + .ToList(); + } + + public static List All() + { + var path = GetPath(); + var lines = File.ReadLines(path, Encoding.UTF8); + var contents = string.Join(Environment.NewLine, lines); + var formats = JsonConvert.DeserializeObject(contents); + return formats.ToList(); + } + + private static string GetPath() + { + string path = Path.Combine(GetDirectory(), "onlyoffice-docs-formats.json"); + if (File.Exists(path)) + { + return path; + } + else + { + throw new FileNotFoundException("The JSON file does not exist."); + } + } + + private static string GetDirectory() + { + string directory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets", "document-formats"); + return Path.GetFullPath(directory); + } + } } \ No newline at end of file From 9e351e41907f9cdc43bf98fae03b2f52cb381cd0 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Fri, 10 Nov 2023 12:46:30 +0300 Subject: [PATCH 229/488] csharp-mvc: replace the previous implementation of formats --- .../csharp-mvc/Helpers/DocManagerHelper.cs | 8 ++--- .../csharp-mvc/Models/FileUtility.cs | 35 +++---------------- .../csharp-mvc/OnlineEditorsExampleMVC.csproj | 5 +++ .../csharp-mvc/web.appsettings.config | 4 --- 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs index 7721001c2..41493888a 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs @@ -51,24 +51,24 @@ public static List FileExts // get file extensions that can be viewed public static List ViewedExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.viewed-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.ViewableExtensions(); } } public static List FillFormExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.fillform-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.FillableExtensions(); } } // get file extensions that can be edited public static List EditedExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.edited-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.EditableExtensions(); } } // get file extensions that can be converted public static List ConvertExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.convert-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.ConvertibleExtensions(); } } // get current user host address diff --git a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs index f7eb6d8e2..b2de3abac 100644 --- a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs @@ -40,39 +40,12 @@ public static FileType GetFileType(string fileName) { var ext = Path.GetExtension(fileName).ToLower(); - if (ExtsDocument.Contains(ext)) return FileType.Word; // word type for document extensions - if (ExtsSpreadsheet.Contains(ext)) return FileType.Cell; // cell type for spreadsheet extensions - if (ExtsPresentation.Contains(ext)) return FileType.Slide; // slide type for presentation extensions + if (FormatManager.DocumentExtensions().Contains(ext)) return FileType.Word; // word type for document extensions + if (FormatManager.SpreadsheetExtensions().Contains(ext)) return FileType.Cell; // cell type for spreadsheet extensions + if (FormatManager.PresentationExtensions().Contains(ext)) return FileType.Slide; // slide type for presentation extensions return FileType.Word; // the default type is word } - - // document extensions - public static readonly List ExtsDocument = new List - { - ".doc", ".docx", ".docm", - ".dot", ".dotx", ".dotm", - ".odt", ".fodt", ".ott", ".rtf", ".txt", - ".html", ".htm", ".mht", ".xml", - ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform" - }; - - // spreadsheet extensions - public static readonly List ExtsSpreadsheet = new List - { - ".xls", ".xlsx", ".xlsm", ".xlsb", - ".xlt", ".xltx", ".xltm", - ".ods", ".fods", ".ots", ".csv" - }; - - // presentation extensions - public static readonly List ExtsPresentation = new List - { - ".pps", ".ppsx", ".ppsm", - ".ppt", ".pptx", ".pptm", - ".pot", ".potx", ".potm", - ".odp", ".fodp", ".otp" - }; } public class Format @@ -98,7 +71,7 @@ public string Extension() } } - public class FormatManager + public static class FormatManager { public static List FillableExtensions() { diff --git a/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj b/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj index 3691fc7dc..e9e884332 100644 --- a/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj +++ b/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj @@ -193,6 +193,11 @@ + + + + + diff --git a/web/documentserver-example/csharp-mvc/web.appsettings.config b/web/documentserver-example/csharp-mvc/web.appsettings.config index fb6b5f440..51630ee63 100644 --- a/web/documentserver-example/csharp-mvc/web.appsettings.config +++ b/web/documentserver-example/csharp-mvc/web.appsettings.config @@ -7,10 +7,6 @@ - - - - From 1d65ec61eaa4a538259f6ee08573a85f0c5b9a73 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Fri, 10 Nov 2023 13:06:25 +0300 Subject: [PATCH 230/488] nodejs: saving formsdata --- web/documentserver-example/nodejs/app.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 1a0378e4b..647dfcb6b 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -762,6 +762,26 @@ app.post('/track', async (req, res) => { // define a handler for tracking file c if (isSubmitForm) { const uid = body.actions[0].userid; req.DocManager.saveFileData(correctName, uid, 'Filling Form', userAddress); + + const { formsdataurl } = body; + if (formsdataurl) { + const formsdataName = req.DocManager.getCorrectName( + `${fileUtility.getFileName(correctName, true)}.txt`, + userAddress, + ); + // get the path to the file with forms data + const formsdataPath = req.DocManager.storagePath(formsdataName, userAddress); + const formsdata = await urllib.request(formsdataurl, { method: 'GET' }); + const statusFormsdata = formsdata.status; + const dataFormsdata = formsdata.data; + if (status === 200) { + fileSystem.writeFileSync(formsdataPath, dataFormsdata); // write the forms data + } else { + emitWarning(`Document editing service returned status: ${statusFormsdata}`); + } + } else { + emitWarning('Document editing service do not returned formsdataurl'); + } } } catch (ex) { response.write('{"error":1}'); From c2d190e81177ea2810d27a570691e8a1ef688851 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Fri, 27 Oct 2023 08:24:51 +0300 Subject: [PATCH 231/488] python: link in referenceData --- CHANGELOG.md | 1 + .../python/src/views/actions.py | 25 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22691d660..8feec19b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- python: link in referenceData - ruby: convert after uploading only tagged formats - python: convert after uploading only tagged formats - php: convert after uploading only tagged formats diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index fca6c1c15..53c7a2303 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -29,6 +29,7 @@ from src.configuration import ConfigurationManager from src.response import ErrorResponse from src.utils import docManager, fileUtils, serviceConverter, users, jwtManager, historyManager, trackManager +from urllib.parse import urlparse, parse_qs config_manager = ConfigurationManager() @@ -540,19 +541,35 @@ def reference(request): if userAddress == request.META['REMOTE_ADDR']: fileName = fileKey['fileName'] + link = body['link'] + if not fileName and link: + if docManager.getServerUrl(False, request) not in link: + data = { + 'url': link, + 'directUrl': link + } + return HttpResponse(json.dumps(data), content_type='application/json') + + url_obj = urlparse(link) + query = parse_qs(url_obj.query) + if 'filename' in query: + fileName = query['filename'][0] + if not os.path.exists(docManager.getStoragePath(fileName, request)): + response.setdefault('error', 'File does not exist') + return HttpResponse(json.dumps(response), content_type='application/json', status=404) + if fileName is None: try: path = fileUtils.getFileName(body['path']) if os.path.exists(docManager.getStoragePath(path, request)): fileName = path + else: + response.setdefault('error', 'File not found') + return HttpResponse(json.dumps(response), content_type='application/json', status=404) except KeyError: response.setdefault('error', 'Path not found') return HttpResponse(json.dumps(response), content_type='application/json', status=404) - if fileName is None: - response.setdefault('error', 'File not found') - return HttpResponse(json.dumps(response), content_type='application/json', status=404) - data = { 'fileType': fileUtils.getFileExt(fileName).replace('.', ''), 'key': docManager.generateFileKey(fileName, request), From 99c046e49865aef409bf7488d65c012559f7ec35 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Fri, 27 Oct 2023 08:25:56 +0300 Subject: [PATCH 232/488] csharp: link in referenceData # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 1 + .../csharp/WebEditor.ashx.cs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8feec19b4..24844f766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp: link in referenceData - python: link in referenceData - ruby: convert after uploading only tagged formats - python: convert after uploading only tagged formats diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index 2b2a75929..481e8c668 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -29,6 +29,7 @@ using System.Collections; using System.Net.Sockets; using ASC.Api.DocumentConverter; +using Newtonsoft.Json; namespace OnlineEditorsExample { @@ -622,6 +623,27 @@ private static void Reference(HttpContext context) } } + if (fileName == "" && body.ContainsKey("link")) + { + string link = body["link"].ToString(); + if (!link.Contains(_Default.GetServerUrl(false))) + { + context.Response.Write(jss.Serialize(new Dictionary() { + { "url", link }, + { "directUrl", link } + })); + return; + } + + Uri linkUri = new Uri(link); + fileName = HttpUtility.ParseQueryString(linkUri.Query).Get("fileID"); + if (string.IsNullOrEmpty(fileName) || !File.Exists(_Default.StoragePath(fileName, null))) + { + context.Response.Write("{ \"error\": \"File is not exist\"}"); + return; + } + } + if (fileName == "") { try From 21e61a31af49673cacb37309f430e9deeb6200f3 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Fri, 27 Oct 2023 09:03:25 +0300 Subject: [PATCH 233/488] csharp-mvc: link in referenceData --- CHANGELOG.md | 1 + .../csharp-mvc/WebEditor.ashx.cs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24844f766..179298e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp-mvc: link in referenceData - csharp: link in referenceData - python: link in referenceData - ruby: convert after uploading only tagged formats diff --git a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs index 89487893e..3ff8e03a2 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -812,6 +812,27 @@ private static void Reference(HttpContext context) } } + if (fileName == "" && body.ContainsKey("link")) + { + string link = body["link"].ToString(); + if (!link.Contains(DocManagerHelper.GetServerUrl(false))) + { + context.Response.Write(jss.Serialize(new Dictionary() { + { "url", link }, + { "directUrl", link } + })); + return; + } + + Uri linkUri = new Uri(link); + fileName = HttpUtility.ParseQueryString(linkUri.Query).Get("fileName"); + if (string.IsNullOrEmpty(fileName) || !File.Exists(DocManagerHelper.StoragePath(fileName, null))) + { + context.Response.Write("{ \"error\": \"File is not exist\"}"); + return; + } + } + if (fileName == "") { try From 778121f2afffbddd4eb9f3c28b9aef79a2d8d97d Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 30 Oct 2023 15:04:09 +0300 Subject: [PATCH 234/488] java-spring: link in referenceData --- CHANGELOG.md | 1 + .../controllers/FileController.java | 18 ++++++++++++++++++ .../onlyoffice/integration/dto/Reference.java | 1 + 3 files changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 179298e64..041717aae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- java-spring: link in referenceData - csharp-mvc: link in referenceData - csharp: link in referenceData - python: link in referenceData diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java index 159b0eea5..4709da208 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/FileController.java @@ -62,6 +62,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; import javax.servlet.http.HttpServletRequest; import java.io.File; @@ -485,6 +487,22 @@ public String reference(@RequestBody final Reference body) { } } + String link = body.getLink(); + if (fileName.equals("") && link != null) { + if (!link.contains(storagePathBuilder.getServerUrl(true))) { + HashMap data = new HashMap<>(); + data.put("url", link); + data.put("directUrl", link); + return gson.toJson(data); + } + + UriComponents uriComponents = UriComponentsBuilder.fromUriString(body.getLink()).build(); + fileName = uriComponents.getQueryParams().getFirst("fileName"); + boolean fileExists = new File(storagePathBuilder.getFileLocation(fileName)).exists(); + if (!fileExists) { + return "{ \"error\": \"File is not exist\"}"; + } + } if (fileName.equals("")) { try { diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java index 2eb7d8488..141555582 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Reference.java @@ -33,4 +33,5 @@ public class Reference { private Boolean directUrl; private ReferenceData referenceData; private String path; + private String link; } From 6c6dd7a954abc8e3b7542d6e2045f3f81c0f403c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 30 Oct 2023 15:13:28 +0300 Subject: [PATCH 235/488] java: link in referenceData --- CHANGELOG.md | 1 + .../main/java/controllers/IndexServlet.java | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 041717aae..0af86a1c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- java: link in referenceData - java-spring: link in referenceData - csharp-mvc: link in referenceData - csharp: link in referenceData diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index 970db3044..778ddfecd 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -694,6 +694,33 @@ private static void reference(final HttpServletRequest request, } } + Object link = body.get("link"); + if (fileName.equals("") && link != null) { + if (!((String) link).contains(DocumentManager.getServerUrl(false))) { + HashMap data = new HashMap<>(); + data.put("url", link); + data.put("directUrl", link); + writer.write(gson.toJson(data)); + return; + } + + URL url = new URL((String) link); + String query = url.getQuery(); + String[] parameters = query.split("&"); + for (String parameter : parameters) { + String[] keyValue = parameter.split("="); + if (keyValue.length == 2 && "fileName".equals(keyValue[0])) { + fileName = keyValue[1]; + break; + } + } + boolean fileExists = new File(DocumentManager.storagePath(fileName, null)).exists(); + if (!fileExists) { + writer.write("{ \"error\": \"File is not exist\"}"); + return; + } + } + if (fileName.equals("")) { try { String path = (String) body.get("path"); From d2a6ebeb747aa38fd8028fddd6abc91730d0dd82 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 30 Oct 2023 18:11:04 +0300 Subject: [PATCH 236/488] ruby: link in referenceData --- CHANGELOG.md | 1 + .../ruby/app/controllers/home_controller.rb | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0af86a1c3..a84ed87e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- ruby: link in referenceData - java: link in referenceData - java-spring: link in referenceData - csharp-mvc: link in referenceData diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index f02ab2b1a..8b6a0f715 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -395,6 +395,26 @@ def reference end end + link = body["link"] + if fileName.empty? and body.key?("link") + if !link.include?(DocumentHelper.get_server_url(false)) + data = { + url: link, + directUrl: link + } + render plain: data.to_json + return + end + + url_obj = URI(link) + query_params = CGI.parse(url_obj.query) + fileName = query_params['fileName'].first + if !File.exist?(DocumentHelper.storage_path(fileName, nil)) + render plain: '{ "error": "File is not exist"}' + return + end + end + if fileName.empty? and body.key?("path") path = File.basename(body["path"]) if File.exist?(DocumentHelper.storage_path(path, nil)) From 9f70cca92c55845aaf49696a4bf8ebece34bafab Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 26 Oct 2023 19:02:50 +0300 Subject: [PATCH 237/488] php: link in referenceData # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 1 + web/documentserver-example/php/src/ajax.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a84ed87e4..17a48a314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- php: link in referenceData - ruby: link in referenceData - java: link in referenceData - java-spring: link in referenceData diff --git a/web/documentserver-example/php/src/ajax.php b/web/documentserver-example/php/src/ajax.php index 59fc065e1..9ce21a195 100644 --- a/web/documentserver-example/php/src/ajax.php +++ b/web/documentserver-example/php/src/ajax.php @@ -553,6 +553,20 @@ function reference() } } + $link = $post["link"]; + if (!isset($filename) && isset($link)) { + if (strpos($link, serverPath()) === false) { + return ["url" => $link, "directUrl"=> $link]; + } + + $urlObj = parse_url($link); + parse_str($urlObj["query"], $urlParams); + $fileName = $urlParams["fileID"]; + if (!file_exists(getStoragePath($fileName))) { + return ["error" => "File does not exist"]; + } + } + if (!isset($filename) && isset($post["path"])) { $path = basename($post["path"]); if (file_exists(getStoragePath($path))) { From 63b2202f8232cc5fce6f44f3c9e8ba7ee2189189 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 13 Nov 2023 16:15:05 +0700 Subject: [PATCH 238/488] python: storage folder in configuration manager --- web/documentserver-example/python/manage.py | 1 + web/documentserver-example/python/src/utils/docManager.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/python/manage.py b/web/documentserver-example/python/manage.py index af8c700d6..1cdf8f969 100644 --- a/web/documentserver-example/python/manage.py +++ b/web/documentserver-example/python/manage.py @@ -51,6 +51,7 @@ def configuration(): 'SECRET_KEY': uuid1(), 'STATIC_ROOT': f'{static_root}', 'STATIC_URL': static_url, + 'STORAGE_FOLDER': '/storage/', 'TEMPLATES': [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index b9ec57cc1..680d111f1 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -26,6 +26,7 @@ import requests import magic +from django.conf import settings from django.http import FileResponse from src.configuration import ConfigurationManager from src.format import FormatManager @@ -111,7 +112,7 @@ def getServerUrl(forDocumentServer, req): def getFileUri(filename, forDocumentServer, req): host = getServerUrl(forDocumentServer, req) curAdr = req.META['REMOTE_ADDR'] - return f'{host}/storage/{curAdr}/{filename}' + return f'{host}{settings.STORAGE_FOLDER}{curAdr}/{filename}' # get absolute URL to the document storage service From 888957c9673daa434b92096b1225c7e34727569a Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 13 Nov 2023 16:31:26 +0700 Subject: [PATCH 239/488] php: removed unnecessary route and method 'csv' --- web/documentserver-example/php/index.php | 6 ------ web/documentserver-example/php/src/ajax.php | 14 -------------- .../php/src/views/DocEditorView.php | 6 +++--- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/web/documentserver-example/php/index.php b/web/documentserver-example/php/index.php index 565489ac1..6c7c25d7e 100755 --- a/web/documentserver-example/php/index.php +++ b/web/documentserver-example/php/index.php @@ -80,12 +80,6 @@ function routers() echo json_encode($response); return; } - if (str_starts_with($path, '/csv')) { - $response = csv(); - $response['status'] = 'success'; - echo json_encode($response); - return; - } if (str_starts_with($path, '/delete')) { $response = delete(); $response['status'] = isset($response['error']) ? 'error' : 'success'; diff --git a/web/documentserver-example/php/src/ajax.php b/web/documentserver-example/php/src/ajax.php index 9f9b7e5ef..cd5ed06fe 100644 --- a/web/documentserver-example/php/src/ajax.php +++ b/web/documentserver-example/php/src/ajax.php @@ -333,20 +333,6 @@ function files() } } -/** - * Download a csv file - * - * @return void - */ -function csv() -{ - $fileName = "csv.csv"; - $filePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . - DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "document-templates" - . DIRECTORY_SEPARATOR . "sample" . DIRECTORY_SEPARATOR . $fileName; - downloadFile($filePath); -} - /** * Download a file from history * diff --git a/web/documentserver-example/php/src/views/DocEditorView.php b/web/documentserver-example/php/src/views/DocEditorView.php index 89f29b195..017bf62be 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -211,11 +211,11 @@ public function __construct($request, $tempName = "docEditor") // recipients data for mail merging $dataSpreadsheet = $isEnableDirectUrl ? [ "fileType" => "csv", - "url" => serverPath(true) . "/csv", - "directUrl" => serverPath(false) . "/csv", + "url" => serverPath(true) . "/assets/document-templates/sample/csv.csv", + "directUrl" => serverPath(false) . "/assets/document-templates/sample/csv.csv", ] : [ "fileType" => "csv", - "url" => serverPath(true) . "/csv", + "url" => serverPath(true) . "/assets/document-templates/sample/csv.csv", ]; // users data for mentions From 6207d0398454ff4bf43855a2eff4e900c4b76e2b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 13 Nov 2023 09:29:11 +0300 Subject: [PATCH 240/488] python: saving formsdata --- .../python/src/utils/trackManager.py | 17 ++++++++++++++++- .../python/src/utils/users.py | 10 +++++++--- .../python/src/views/actions.py | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/python/src/utils/trackManager.py b/web/documentserver-example/python/src/utils/trackManager.py index 574daadfd..6a6e12ddd 100755 --- a/web/documentserver-example/python/src/utils/trackManager.py +++ b/web/documentserver-example/python/src/utils/trackManager.py @@ -159,12 +159,27 @@ def processForceSave(body, filename, usAddr): if forcesavePath == "": forcesavePath = docManager.getForcesavePath(filename, usAddr, True) - docManager.saveFile(download, forcesavePath) # save document file + docManager.saveFile(data, forcesavePath) # save document file if isSubmitForm: uid = body['actions'][0]['userid'] # get the user id historyManager.createMetaData(filename, uid, "Filling Form", usAddr) # create meta data for forcesaved file + forms_data_url = body.get('formsdataurl') + if forms_data_url: + data_name = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + ".txt", usAddr) + data_path = docManager.getStoragePath(data_name, usAddr) + + forms_data = docManager.downloadFileFromUri(forms_data_url); + + if data is None: + raise Exception("Document editing service didn't return forms_data"); + else: + with open(data_path, 'w') as file: + file.write(forms_data.text) + else: + raise Exception('Document editing service did not return forms_data_url') + # create a command request def commandRequest(method, key, meta=None): diff --git a/web/documentserver-example/python/src/utils/users.py b/web/documentserver-example/python/src/utils/users.py index c390c9301..354ce639a 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -42,7 +42,8 @@ def __init__(self, uid, name, email, group, reviewGroups, commentGroups, userInf "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Can submit forms" ] descr_user_2 = [ @@ -52,7 +53,8 @@ def __init__(self, uid, name, email, group, reviewGroups, commentGroups, userInf "Can remove his own comments only"), "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Can’t submit forms" ] descr_user_3 = [ @@ -64,7 +66,8 @@ def __init__(self, uid, name, email, group, reviewGroups, commentGroups, userInf "Can’t download the file", "Can’t print the file", "Can create new files from the editor", - "Can see the information about Group2 users" + "Can see the information about Group2 users", + "Can’t submit forms" ] descr_user_0 = [ @@ -80,6 +83,7 @@ def __init__(self, uid, name, email, group, reviewGroups, commentGroups, userInf "Can't view chat", "Can't protect file", "View file without collaboration", + "Can’t submit forms" ] USERS = [ diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index d4bc7eb63..c1a647ceb 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -200,7 +200,7 @@ def edit(request): edMode = 'fillForms' canEdit = True # if the Submit form button is displayed or hidden - submitForm = edMode == 'fillForms' and user.id == 'uid-1' and False + submitForm = edMode == 'fillForms' and user.id == 'uid-1' mode = 'edit' if canEdit & (edMode != 'view') else 'view' # if the file can't be edited, the mode is view types = ['desktop', 'mobile', 'embedded'] From b6b001d7ef2a6e744055b1531d08c65437e88f06 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 13 Nov 2023 11:43:17 +0300 Subject: [PATCH 241/488] php: saving formsdata --- .../php/src/helpers/ExampleUsers.php | 4 ++++ .../php/src/trackmanager.php | 19 +++++++++++++++++++ .../php/src/views/DocEditorView.php | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/php/src/helpers/ExampleUsers.php b/web/documentserver-example/php/src/helpers/ExampleUsers.php index 87e42289e..d1bbc1e33 100644 --- a/web/documentserver-example/php/src/helpers/ExampleUsers.php +++ b/web/documentserver-example/php/src/helpers/ExampleUsers.php @@ -38,6 +38,7 @@ public function __construct() "The file favorite state is undefined", "Can create files from templates using data from the editor", "Can see the information about all users", + "Can submit forms" ]; $this->user2Description = [ "Belongs to Group2", @@ -47,6 +48,7 @@ public function __construct() "This file is marked as favorite", "Can create new files from the editor", "Can see the information about users from Group2 and users who don’t belong to any group", + "Can’t submit forms" ]; $this->user3Description = [ "Belongs to Group3", @@ -58,6 +60,7 @@ public function __construct() "Can’t print the file", "Can create new files from the editor", "Can see the information about Group2 users", + "Can’t submit forms" ]; $this->user0Description = [ "The name is requested when the editor is opened", @@ -71,6 +74,7 @@ public function __construct() "Can't rename files from the editor", "Can't view chat", "View file without collaboration", + "Can’t submit forms" ]; $this->users = [ new Users( diff --git a/web/documentserver-example/php/src/trackmanager.php b/web/documentserver-example/php/src/trackmanager.php index ec55fb518..f61969fbb 100755 --- a/web/documentserver-example/php/src/trackmanager.php +++ b/web/documentserver-example/php/src/trackmanager.php @@ -273,6 +273,25 @@ function processForceSave($data, $fileName, $userAddress) if ($isSubmitForm) { $uid = $data->actions[0]->userid; // get the user id createMeta($fileName, $uid, "Filling Form", $userAddress); // create meta data for the forcesaved file + + $formsDataUrl = $data->formsdataurl; + if ($formsDataUrl) { + $formsName = getCorrectName($baseNameWithoutExt . ".txt", $userAddress); + $formsPath = getStoragePath($formsName, $userAddress); + + if (!(($formsData = file_get_contents( + $formsDataUrl, + false, + stream_context_create(["http" => ["timeout" => 5]]) + )) === false) + ) { + file_put_contents($formsPath, $formsData, LOCK_EX); + } else { + throw new Exception("Document editing service didn't return formsData"); + } + } else { + throw new Exception('Document editing service did not return formsDataUrl'); + } } $saved = 0; diff --git a/web/documentserver-example/php/src/views/DocEditorView.php b/web/documentserver-example/php/src/views/DocEditorView.php index 9fbbb120e..e68dd60f7 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -85,7 +85,7 @@ public function __construct($request, $tempName = "docEditor") } // check if the Submit form button is displayed or not - $submitForm = $editorsMode == "fillForms" && $user->id == "uid-1" && !1; + $submitForm = $editorsMode == "fillForms" && $user->id == "uid-1"; $mode = $canEdit && $editorsMode != "view" ? "edit" : "view"; // define if the editing mode is edit or view $type = empty($request["type"]) ? "desktop" : $request["type"]; From 1fda76552fccdb30e77707d3f230950f4c4e1782 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 13 Nov 2023 13:10:52 +0300 Subject: [PATCH 242/488] java: saving formsdata --- .../java/src/main/java/entities/FileModel.java | 2 +- .../src/main/java/helpers/TrackManager.java | 18 ++++++++++++++++++ .../java/src/main/java/helpers/Users.java | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/java/src/main/java/entities/FileModel.java b/web/documentserver-example/java/src/main/java/entities/FileModel.java index c50c4ad3e..4693c963b 100755 --- a/web/documentserver-example/java/src/main/java/entities/FileModel.java +++ b/web/documentserver-example/java/src/main/java/entities/FileModel.java @@ -152,7 +152,7 @@ public void changeType(final String modeParam, final String typeParam, final Use String fileExt = FileUtility.getFileExtension(document.getTitle()); Boolean canEdit = DocumentManager.getEditedExts().contains(fileExt); // check if the Submit form button is displayed or not - editorConfig.getCustomization().setSubmitForm(false); + editorConfig.getCustomization().setSubmitForm(true); if ((!canEdit && mode.equals("edit") || mode.equals("fillForms")) && DocumentManager.getFillExts().contains(fileExt)) { diff --git a/web/documentserver-example/java/src/main/java/helpers/TrackManager.java b/web/documentserver-example/java/src/main/java/helpers/TrackManager.java index 83fdae5ed..4cf23f67c 100755 --- a/web/documentserver-example/java/src/main/java/helpers/TrackManager.java +++ b/web/documentserver-example/java/src/main/java/helpers/TrackManager.java @@ -293,6 +293,24 @@ public static void processForceSave(final JSONObject body, // create meta data for forcesaved file DocumentManager.createMeta(fileName, user, "Filling Form", userAddress); + + try { + String formsDataUrl = body.get("formsdataurl").toString(); + + if (formsDataUrl != null && !formsDataUrl.isEmpty()) { + String formsName = DocumentManager.getCorrectName(FileUtility + .getFileNameWithoutExtension(fileName) + ".txt", userAddress); + String formsPath = DocumentManager.storagePath(formsName, userAddress); + + byte[] byteArrayFormsData = getDownloadFile(formsDataUrl); + + saveFile(byteArrayFormsData, Paths.get(formsPath)); + } else { + throw new Exception("Document editing service did not return formsDataUrl"); + } + } catch (Exception e) { + e.printStackTrace(); + } } } diff --git a/web/documentserver-example/java/src/main/java/helpers/Users.java b/web/documentserver-example/java/src/main/java/helpers/Users.java index 8f2c30b9e..8aa4c2227 100755 --- a/web/documentserver-example/java/src/main/java/helpers/Users.java +++ b/web/documentserver-example/java/src/main/java/helpers/Users.java @@ -37,6 +37,7 @@ public final class Users { add("The file favorite state is undefined"); add("Can create files from templates using data from the editor"); add("Can see the information about all users"); + add("Can submit forms"); }}; private static List descriptionUserSecond = new ArrayList() {{ @@ -47,6 +48,7 @@ public final class Users { add("This file is marked as favorite"); add("Can create new files from the editor"); add("Can see the information about users from Group2 and users who don’t belong to any group"); + add("Can’t submit forms"); }}; private static List descriptionUserThird = new ArrayList() {{ @@ -59,6 +61,7 @@ public final class Users { add("Can’t print the file"); add("Can create new files from the editor"); add("Can see the information about Group2 users"); + add("Can’t submit forms"); }}; private static List descriptionUserZero = new ArrayList() {{ @@ -74,6 +77,7 @@ public final class Users { add("Can't view chat"); add("Can't protect file"); add("View file without collaboration"); + add("Can’t submit forms"); }}; private static List users = new ArrayList() {{ From ccf6fb4098f68f484c950029601666f75d35b52f Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 13 Nov 2023 14:02:49 +0300 Subject: [PATCH 243/488] java-spring: saving formsdata --- .../onlyoffice/integration/ExampleData.java | 12 ++++++++---- .../callback/DefaultCallbackManager.java | 18 ++++++++++++++++++ .../models/configurations/Customization.java | 2 +- .../com/onlyoffice/integration/dto/Track.java | 1 + .../DefaultCustomizationConfigurer.java | 1 - 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java index 3fe484998..4c3e8d245 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java @@ -46,7 +46,8 @@ public void init() { "Can't rename files from the editor", "Can't view chat", "Can't protect file", - "View file without collaboration" + "View file without collaboration", + "Can’t submit forms" ); // the description for user 1 @@ -58,7 +59,8 @@ public void init() { "The file favorite state is undefined", "Can create a file from a template with data from the editor", "Can see the information about all users", - "Can view chat" + "Can view chat", + "Can submit forms" ); // the description for user 2 @@ -71,7 +73,8 @@ public void init() { "This file is favorite", "Can create a file from an editor", "Can see the information about users from Group2 and users who don’t belong to any group", - "Can view chat" + "Can view chat", + "Can’t submit forms" ); // the description for user 3 @@ -86,7 +89,8 @@ public void init() { "He can’t print the file", "Can create a file from an editor", "Can see the information about Group2 users", - "Can view chat" + "Can view chat", + "Can’t submit forms" ); // create user 1 with the specified parameters diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/callback/DefaultCallbackManager.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/callback/DefaultCallbackManager.java index 7d378ec71..f0efb4acc 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/callback/DefaultCallbackManager.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/callback/DefaultCallbackManager.java @@ -315,6 +315,24 @@ public void processForceSave(final Track body, final String fileNameParam) { // String user = action.getUserid(); // get the user ID // create meta data for the forcesaved file storageMutator.createMeta(fileName, user, "Filling Form"); + + try { + String formsDataUrl = body.getFormsdataurl(); + + if (formsDataUrl != null && !formsDataUrl.isEmpty()) { + String formsName = documentManager.getCorrectName(fileUtility + .getFileNameWithoutExtension(fileName) + ".txt"); + String formsPath = storagePathBuilder.getFileLocation(formsName); + + byte[] byteArrayFormsData = getDownloadFile(formsDataUrl); + + saveFile(byteArrayFormsData, Paths.get(formsPath)); + } else { + throw new RuntimeException("Document editing service did not return formsDataUrl"); + } + } catch (Exception e) { + e.printStackTrace(); + } } else { if (newFileName) { fileName = documentManager diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Customization.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Customization.java index bcfad7db1..3d51914ad 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Customization.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/models/configurations/Customization.java @@ -45,7 +45,7 @@ in the upper part of the editor window header next to the logo (false) or in the private Boolean help = true; // if the Help menu button is displayed or hidden private Boolean hideRightMenu = false; // if the right menu is displayed or hidden on first loading private Boolean hideRulers = false; // if the editor rulers are displayed or hidden - private Boolean submitForm = false; // if the Submit form button is displayed or hidden + private Boolean submitForm = true; // if the Submit form button is displayed or hidden private Boolean about = true; private Boolean feedback = true; } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Track.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Track.java index 23b75225e..a296fd4bf 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Track.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/dto/Track.java @@ -43,4 +43,5 @@ public class Track { private String userdata; private String lastsave; private Boolean notmodified; + private String formsdataurl; } diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultCustomizationConfigurer.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultCustomizationConfigurer.java index 5af0568b5..1c8537ef6 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultCustomizationConfigurer.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/services/configurers/implementations/DefaultCustomizationConfigurer.java @@ -34,6 +34,5 @@ public class DefaultCustomizationConfigurer implements CustomizationConfigurer Date: Mon, 13 Nov 2023 15:17:44 +0300 Subject: [PATCH 244/488] csharp: saving formsdata --- .../csharp/DocEditor.aspx.cs | 2 +- .../csharp/TrackManager.cs | 16 ++++++++++++++++ web/documentserver-example/csharp/Users.cs | 10 +++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/csharp/DocEditor.aspx.cs b/web/documentserver-example/csharp/DocEditor.aspx.cs index 2184c4116..2a957cbf4 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -153,7 +153,7 @@ protected void Page_Load(object sender, EventArgs e) editorsMode = "fillForms"; canEdit = true; } - var submitForm = editorsMode.Equals("fillForms") && id.Equals("uid-1") && false; // check if the Submit form button is displayed or hidden + var submitForm = editorsMode.Equals("fillForms") && id.Equals("uid-1"); // check if the Submit form button is displayed or hidden var mode = canEdit && editorsMode != "view" ? "edit" : "view"; // get the editor opening mode (edit or view) var jss = new JavaScriptSerializer(); diff --git a/web/documentserver-example/csharp/TrackManager.cs b/web/documentserver-example/csharp/TrackManager.cs index cc5f8c93b..9a2678243 100644 --- a/web/documentserver-example/csharp/TrackManager.cs +++ b/web/documentserver-example/csharp/TrackManager.cs @@ -258,6 +258,22 @@ public static int processForceSave(Dictionary fileData, string f var action = jss.Deserialize>(jss.Serialize(actions[0])); var user = action["userid"].ToString(); // get the user id DocEditor.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file + + string formsDataUrl = fileData["formsdataurl"].ToString(); + + if (!string.IsNullOrEmpty(formsDataUrl)) + { + string formsName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + ".txt", userAddress); + string formsPath = _Default.StoragePath(formsName, userAddress); + + var bytesForms = DownloadFile(formsDataUrl); + + SaveFile(bytesForms, formsPath); + } + else + { + throw new Exception("Document editing service did not return formsDataUrl"); + } } } catch (Exception) diff --git a/web/documentserver-example/csharp/Users.cs b/web/documentserver-example/csharp/Users.cs index 4ce7e731b..7b899836a 100644 --- a/web/documentserver-example/csharp/Users.cs +++ b/web/documentserver-example/csharp/Users.cs @@ -30,7 +30,8 @@ public class Users "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Can submit forms" }; static List descr_user_2 = new List() @@ -40,7 +41,8 @@ public class Users "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Can’t submit forms" }; static List descr_user_3 = new List() @@ -53,7 +55,8 @@ public class Users "Can’t download the file", "Can’t print the file", "Can create new files from the editor", - "Can see the information about Group2 users" + "Can see the information about Group2 users", + "Can’t submit forms" }; static List descr_user_0 = new List() @@ -70,6 +73,7 @@ public class Users "Can't view chat", "Can't protect file", "View file without collaboration", + "Can’t submit forms" }; private static List users = new List() { From 9369b124da65d1f661d7d720b19140dfec6f80fe Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 13 Nov 2023 15:26:17 +0300 Subject: [PATCH 245/488] csharp-mvc: saving formsdata --- .../csharp-mvc/Helpers/TrackManager.cs | 16 ++++++++++++++++ .../csharp-mvc/Helpers/Users.cs | 10 +++++++--- .../csharp-mvc/Models/FileModel.cs | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs b/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs index 46785a4ba..ef777ae9e 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs @@ -256,6 +256,22 @@ public static int processForceSave(Dictionary fileData, string f var action = jss.Deserialize>(jss.Serialize(actions[0])); var user = action["userid"].ToString(); // get the user id DocManagerHelper.CreateMeta(fileName, user, "Filling Form", userAddress); // create meta data for the forcesaved file + + string formsDataUrl = fileData["formsdataurl"].ToString(); + + if (!string.IsNullOrEmpty(formsDataUrl)) + { + string formsName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + ".txt", userAddress); + string formsPath = DocManagerHelper.StoragePath(formsName, userAddress); + + var bytesForms = DownloadFile(formsDataUrl); + + SaveFile(bytesForms, formsPath); + } + else + { + throw new Exception("Document editing service did not return formsDataUrl"); + } } } catch (Exception) { diff --git a/web/documentserver-example/csharp-mvc/Helpers/Users.cs b/web/documentserver-example/csharp-mvc/Helpers/Users.cs index 0ed0a9aba..937182b37 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/Users.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/Users.cs @@ -31,7 +31,8 @@ public class Users "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Can submit forms" }; static List descr_user_2 = new List() @@ -41,7 +42,8 @@ public class Users "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Can’t submit forms" }; static List descr_user_3 = new List() @@ -54,7 +56,8 @@ public class Users "Can’t download the file", "Can’t print the file", "Can create new files from the editor", - "Can see the information about Group2 users" + "Can see the information about Group2 users", + "Can’t submit forms" }; static List descr_user_0 = new List() @@ -71,6 +74,7 @@ public class Users "Can't view chat", "Can't protect file", "View file without collaboration", + "Can’t submit forms" }; private static List users = new List() { diff --git a/web/documentserver-example/csharp-mvc/Models/FileModel.cs b/web/documentserver-example/csharp-mvc/Models/FileModel.cs index ddc0028cb..a3a1b1dc1 100755 --- a/web/documentserver-example/csharp-mvc/Models/FileModel.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileModel.cs @@ -88,7 +88,7 @@ public string GetDocConfig(HttpRequest request, UrlHelper url) editorsMode = "fillForms"; canEdit = true; } - var submitForm = editorsMode.Equals("fillForms") && id.Equals("uid-1") && false; // check if the Submit form button is displayed or not + var submitForm = editorsMode.Equals("fillForms") && id.Equals("uid-1"); // check if the Submit form button is displayed or not var mode = canEdit && editorsMode != "view" ? "edit" : "view"; // set the mode parameter: change it to view if the document can't be edited // favorite icon state From 9ea7e14c37769d552cbb56579878564b39968493 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 13 Nov 2023 16:45:48 +0300 Subject: [PATCH 246/488] ruby: saving formsdata --- .../ruby/app/models/file_model.rb | 2 +- .../ruby/app/models/track_helper.rb | 14 ++++++++++++++ .../ruby/app/models/users.rb | 10 +++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 7c1129aef..76682c82e 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -93,7 +93,7 @@ def get_config editorsmode = "fillForms" canEdit = true end - submitForm = editorsmode.eql?("fillForms") && @user.id.eql?("uid-1") && false # the Submit form button state + submitForm = editorsmode.eql?("fillForms") && @user.id.eql?("uid-1") # the Submit form button state mode = canEdit && !editorsmode.eql?("view") ? "edit" : "view" templatesImageUrl = DocumentHelper.get_template_image_url(document_type) # templates image url in the "From Template" section templates = [ diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 844e9193e..e62e70fff 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -238,6 +238,20 @@ def process_force_save(file_data, file_name, user_address) if is_submit_form uid = file_data['actions'][0]['userid'] DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name + + forms_data_url = file_data["formsdataurl"].to_s + + if forms_data_url && !forms_data_url.eql?("") + forms_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + ".txt", user_address) + forms_path = DocumentHelper.storage_path(forms_name, user_address) + forms = download_file(forms_data_url) + if forms.eql?(nil) + return saved + end + save_file(forms, forms_path) + else + raise 'Document editing service did not return formsDataUrl' + end end saved = 0 diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index e8a3cfaf7..ef2de6a7c 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -40,7 +40,8 @@ class Users "Can perform all actions with comments", "The file favorite state is undefined", "Can create files from templates using data from the editor", - "Can see the information about all users" + "Can see the information about all users", + "Can submit forms" ]; @@descr_user_2 = [ @@ -49,7 +50,8 @@ class Users "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group" + "Can see the information about users from Group2 and users who don’t belong to any group", + "Can't submit forms" ]; @@descr_user_3 = [ @@ -62,6 +64,7 @@ class Users "Can’t print the file", "Can create new files from the editor", "Can see the information about Group2 users", + "Can't submit forms" ]; @@descr_user_0 = [ @@ -76,7 +79,8 @@ class Users "Can't rename files from the editor", "Can't view chat", "Can't protect file", - "View file without collaboration" + "View file without collaboration", + "Can't submit forms" ]; @@users = [ From a1db88e0577497785bfcf329f8aa8e017692d7d2 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 13 Nov 2023 18:03:52 +0300 Subject: [PATCH 247/488] php: fixed overwriting of array elements when file creation dates are the same --- web/documentserver-example/php/src/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/php/src/functions.php b/web/documentserver-example/php/src/functions.php index 25912d68c..30c09ea59 100644 --- a/web/documentserver-example/php/src/functions.php +++ b/web/documentserver-example/php/src/functions.php @@ -353,12 +353,13 @@ function getStoredFiles() $cdir = scandir($directory); // get all the files and folders from the directory $result = []; + $index = 0; foreach ($cdir as $key => $fileName) { // run through all the file and folder names if (!in_array($fileName, [".", ".."])) { if (!is_dir($directory . DIRECTORY_SEPARATOR . $fileName)) { // if an element isn't a directory $ext = mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); $dat = filemtime($directory . DIRECTORY_SEPARATOR . $fileName); // get the time of element modification - $result[$dat] = (object) [ // and write the file to the result + $result[$dat + $index++] = (object) [ // and write the file to the result "name" => $fileName, "documentType" => getDocumentType($fileName), "canEdit" => in_array($ext, $formatManager->editableExtensions()), From ce9d62ad7daf9385938ce029dc071fb1e07b85d0 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 12:31:56 +0300 Subject: [PATCH 248/488] ruby: Layout/EmptyLineAfterGuardClause correct --- .../ruby/app/configuration/configuration.rb | 6 ++++++ web/documentserver-example/ruby/app/format/format.rb | 1 + .../ruby/app/models/document_helper.rb | 1 + web/documentserver-example/ruby/app/models/track_helper.rb | 2 ++ web/documentserver-example/ruby/app/proxy/proxy.rb | 1 + 5 files changed, 11 insertions(+) diff --git a/web/documentserver-example/ruby/app/configuration/configuration.rb b/web/documentserver-example/ruby/app/configuration/configuration.rb index 5803b11e3..c2c1846fb 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration.rb @@ -37,6 +37,7 @@ def initialize def example_uri url = ENV['EXAMPLE_URL'] return nil if url.nil? + URI(url) end @@ -50,6 +51,7 @@ def document_server_public_uri def document_server_private_uri url = ENV['DOCUMENT_SERVER_PRIVATE_URL'] return URI(url) if url + document_server_public_uri end @@ -99,6 +101,7 @@ def jwt_header def jwt_use_for_request env = ENV['JWT_USE_FOR_REQUEST'] return ActiveModel::Type::Boolean.new.cast(env) if env + true end @@ -106,6 +109,7 @@ def jwt_use_for_request def ssl_verify_peer_mode_enabled env = ENV['SSL_VERIFY_PEER_MODE_ENABLED'] return ActiveModel::Type::Boolean.new.cast(env) if env + false end @@ -114,6 +118,7 @@ def storage_path storage_path = ENV['STORAGE_PATH'] || 'storage' storage_directory = Pathname(storage_path) return storage_directory if storage_directory.absolute? + current_directory = Pathname(File.expand_path(__dir__)) directory = current_directory.join('..', '..', storage_directory) directory.cleanpath @@ -123,6 +128,7 @@ def storage_path def maximum_file_size env = ENV['MAXIMUM_FILE_SIZE'] return env.to_i if env + 5 * 1024 * 1024 end diff --git a/web/documentserver-example/ruby/app/format/format.rb b/web/documentserver-example/ruby/app/format/format.rb index 130210fa2..0cca61d83 100644 --- a/web/documentserver-example/ruby/app/format/format.rb +++ b/web/documentserver-example/ruby/app/format/format.rb @@ -136,6 +136,7 @@ def all_extensions sig { returns(T::Array[Format]) } def all return @all if defined?(@all) + content = file.read hash = JSON.parse(content) @all ||= hash.map do |item| diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 2bb9b9f08..47d5dce31 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -139,6 +139,7 @@ def get_file_version(hist_dir) Dir.foreach(hist_dir) {|e| # run through all the file versions next if e.eql?(".") next if e.eql?("..") + if File.directory?(File.join(hist_dir, e)) ver += 1 # and count them end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 844e9193e..92f306852 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -303,11 +303,13 @@ def download_file(uristr) if status_code != '200' # checking status code raise "Document editing service returned status: #{status_code}" end + data = res.body # and take its body if data == nil raise 'stream is null' end + data end diff --git a/web/documentserver-example/ruby/app/proxy/proxy.rb b/web/documentserver-example/ruby/app/proxy/proxy.rb index fa1c66b4f..fd5a364c1 100644 --- a/web/documentserver-example/ruby/app/proxy/proxy.rb +++ b/web/documentserver-example/ruby/app/proxy/proxy.rb @@ -32,6 +32,7 @@ def initialize(config_manager:) sig { params(uri: URI::Generic).returns(URI::Generic) } def resolve_uri(uri) return uri unless refer_public_url(uri) + redirect_public_url(uri) end From 266e249b125aaec2d96896f36d3bfe0ff97314b8 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 12:37:38 +0300 Subject: [PATCH 249/488] ruby: Layout/TrailingEmptyLines correct --- .../ruby/app/controllers/application_controller.rb | 2 +- web/documentserver-example/ruby/app/models/document_helper.rb | 2 +- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- web/documentserver-example/ruby/app/models/jwt_helper.rb | 2 +- web/documentserver-example/ruby/app/models/service_converter.rb | 2 +- web/documentserver-example/ruby/app/models/track_helper.rb | 2 +- web/documentserver-example/ruby/app/models/users.rb | 1 - 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/application_controller.rb b/web/documentserver-example/ruby/app/controllers/application_controller.rb index 92474a5f0..32ce5cfdb 100644 --- a/web/documentserver-example/ruby/app/controllers/application_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/application_controller.rb @@ -15,4 +15,4 @@ # class ApplicationController < ActionController::Base -end \ No newline at end of file +end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 47d5dce31..ab7f5d444 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -341,4 +341,4 @@ def verify_ssl(file_uri, http) end end -end \ No newline at end of file +end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index da63a1aa9..43ea40dc5 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -386,4 +386,4 @@ def is_enable_direct_url return @direct_url != nil && @direct_url == "true" end -end \ No newline at end of file +end diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 838659bd0..4101c144b 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -50,4 +50,4 @@ def decode(token) return decoded[0].to_json # get json payload end end -end \ No newline at end of file +end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index f4d4e86ca..aa951621d 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -184,4 +184,4 @@ def get_response_data(json_data) end -end \ No newline at end of file +end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 92f306852..a3250eacf 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -319,4 +319,4 @@ def save_file(data, path) end end end -end \ No newline at end of file +end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index bf0faabf0..fe827482a 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -145,4 +145,3 @@ def get_users_for_protect(id) # get a list of users with their id, names and em end end - From e9e6586d6d9110f59e2c65e65369a45de9813545 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 12:43:19 +0300 Subject: [PATCH 250/488] ruby: Layout/EmptyLinesAroundMethodBody correct --- .../ruby/app/controllers/home_controller.rb | 8 -------- .../ruby/app/models/document_helper.rb | 7 ------- web/documentserver-example/ruby/app/models/file_model.rb | 1 - .../ruby/app/models/service_converter.rb | 6 ------ 4 files changed, 22 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 8b6a0f715..c47353ba9 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -30,26 +30,21 @@ def index end def editor - DocumentHelper.init(request.remote_ip, request.base_url) user = Users.get_user(params[:userId]) @file = FileModel.new(:file_name => File.basename(params[:fileName]), :mode => params[:editorsMode], :type => params[:editorsType], :user_ip => request.remote_ip, :lang => cookies[:ulang], :user => user, :action_data => params[:actionLink], :direct_url => params[:directUrl]) - end # creating a sample document def sample - DocumentHelper.init(request.remote_ip, request.base_url) user = Users.get_user(params[:userId]) file_name = DocumentHelper.create_demo(params[:fileExt], params[:sample], user) redirect_to :controller => 'home', :action => 'editor', :fileName => file_name, :userId => user.id - end # uploading a file def upload - DocumentHelper.init(request.remote_ip, request.base_url) begin @@ -87,12 +82,10 @@ def upload rescue => ex render plain: '{ "error": "' + ex.message + '"}' # write an error message to the response end - end # converting a file def convert - begin file_data = request.body.read if file_data == nil || file_data.empty? @@ -154,7 +147,6 @@ def convert rescue => ex render plain: '{ "error": "' + ex.message + '"}' end - end # downloading a history file from public diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index ab7f5d444..dff8bd611 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -244,29 +244,22 @@ def get_server_url(for_document_server) # get callback url def get_callback(file_name) - get_server_url(true) + '/track?fileName=' + ERB::Util.url_encode(file_name) + '&userAddress=' + cur_user_host_address(nil) - end # get url to the created file def get_create_url(document_type) - get_server_url(false) + '/sample?fileExt=' + get_internal_extension(document_type).delete('.') - end # get url to download a file def get_download_url(file_name, is_serverUrl=true) - user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : "" get_server_url(is_serverUrl) + '/download?fileName=' + ERB::Util.url_encode(file_name) + user_host - end # get internal file extension by its type def get_internal_extension(file_type) - case file_type when 'word' # .docx for word type ext = '.docx' diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 43ea40dc5..15a7d3554 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -289,7 +289,6 @@ def get_history end return nil - end # get image information diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index aa951621d..b7268f011 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -30,7 +30,6 @@ class << self # get the url of the converted file def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_async, file_pass, lang = nil) - from_ext = from_ext == nil ? File.extname(document_uri).downcase : from_ext # get the current document extension # get the current document name or uuid @@ -93,7 +92,6 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ # generate the document key value def generate_revision_id(expected_key) - require 'zlib' if expected_key.length > 20 # check if the expected key length is greater than 20 @@ -102,12 +100,10 @@ def generate_revision_id(expected_key) key = expected_key.gsub(/[^0-9a-zA-Z.=]/, '_') key[(key.length - [key.length, 20].min)..key.length] # the resulting key is of the length 20 or less - end # create an error message for the error code def process_convert_service_responce_error(error_code) - error_message = 'unknown error' # add an error message to the error message template depending on the error code @@ -135,12 +131,10 @@ def process_convert_service_responce_error(error_code) end raise error_message - end # get the response url def get_response_data(json_data) - file_result = json_data error_element = file_result['error'] From 1b91592a9a90cd36fb91b829aa36aa7e207222cf Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:10:31 +0300 Subject: [PATCH 251/488] ruby: Layout/ExtraSpacing correct --- .../ruby/app/controllers/home_controller.rb | 68 +++++----- .../ruby/app/models/document_helper.rb | 56 ++++---- .../ruby/app/models/file_model.rb | 120 +++++++++--------- .../ruby/app/models/service_converter.rb | 54 ++++---- .../ruby/app/models/track_helper.rb | 86 ++++++------- .../ruby/app/models/users.rb | 6 +- 6 files changed, 195 insertions(+), 195 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index c47353ba9..f4218dbd0 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -78,9 +78,9 @@ def upload DocumentHelper.create_meta(file_name, user.id, user.name, nil) - render plain: '{ "filename": "' + file_name + '", "documentType": "' + document_type + '"}' # write a new file name to the response + render plain: '{ "filename": "' + file_name + '", "documentType": "' + document_type + '"}' # write a new file name to the response rescue => ex - render plain: '{ "error": "' + ex.message + '"}' # write an error message to the response + render plain: '{ "error": "' + ex.message + '"}' # write an error message to the response end end @@ -101,9 +101,9 @@ def convert extension = File.extname(file_name).downcase internal_extension = 'ooxml' - if DocumentHelper.convert_exts.include? (extension) # check if the file with such an extension can be converted - key = ServiceConverter.generate_revision_id(file_uri) # generate document key - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(file_uri, extension.delete('.'), internal_extension.delete('.'), key, true, file_pass, lang) # get the url and file type of the converted file and the conversion percentage + if DocumentHelper.convert_exts.include? (extension) # check if the file with such an extension can be converted + key = ServiceConverter.generate_revision_id(file_uri) # generate document key + percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(file_uri, extension.delete('.'), internal_extension.delete('.'), key, true, file_pass, lang) # get the url and file type of the converted file and the conversion percentage # if the conversion isn't completed, write file name and step values to the response if percent != 100 @@ -114,12 +114,12 @@ def convert # get the correct file name if such a name already exists correct_name = DocumentHelper.get_correct_name(File.basename(file_name, extension) + "." + new_file_type, nil) - uri = URI.parse(new_file_uri) # create the request url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + uri = URI.parse(new_file_uri) # create the request url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server DocumentHelper.verify_ssl(new_file_uri, http) - req = Net::HTTP::Get.new(uri.request_uri) # create the get requets + req = Net::HTTP::Get.new(uri.request_uri) # create the get requets res = http.request(req) data = res.body @@ -140,7 +140,7 @@ def convert file_name = correct_name user = Users.get_user(params[:userId]) - DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file + DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file end render plain: '{ "filename" : "' + file_name + '"}' @@ -190,9 +190,9 @@ def downloadhistory # tracking file changes def track - file_data = TrackHelper.read_body(request) # read the request body + file_data = TrackHelper.read_body(request) # read the request body if file_data == nil || file_data.empty? - render plain: '{"error":1}' # an error occurs if the file is empty + render plain: '{"error":1}' # an error occurs if the file is empty return end @@ -201,23 +201,23 @@ def track user_address = params[:userAddress] file_name = File.basename(params[:fileName]) - if status == 1 # editing - if file_data['actions'][0]['type'] == 0 # finished edit - user = file_data['actions'][0]['userid'] # get the user id + if status == 1 # editing + if file_data['actions'][0]['type'] == 0 # finished edit + user = file_data['actions'][0]['userid'] # get the user id if !file_data['users'].index(user) - json_data = TrackHelper.command_request("forcesave", file_data['key']) # call the forcesave command + json_data = TrackHelper.command_request("forcesave", file_data['key']) # call the forcesave command end end end - if status == 2 || status == 3 # MustSave, Corrupted - saved = TrackHelper.process_save(file_data, file_name, user_address) # save file + if status == 2 || status == 3 # MustSave, Corrupted + saved = TrackHelper.process_save(file_data, file_name, user_address) # save file render plain: '{"error":' + saved.to_s + '}' return end - if status == 6 || status == 7 # MustForceave, CorruptedForcesave - saved = TrackHelper.process_force_save(file_data, file_name, user_address) # force save file + if status == 6 || status == 7 # MustForceave, CorruptedForcesave + saved = TrackHelper.process_force_save(file_data, file_name, user_address) # force save file render plain: '{"error":' + saved.to_s + '}' return end @@ -228,9 +228,9 @@ def track # removing a file def remove - file_name = File.basename(params[:filename]) # get the file name - if !file_name # if it doesn't exist - render plain: '{"success":false}' # report that the operation is unsuccessful + file_name = File.basename(params[:filename]) # get the file name + if !file_name # if it doesn't exist + render plain: '{"success":false}' # report that the operation is unsuccessful return end @@ -238,22 +238,22 @@ def remove storage_path = DocumentHelper.storage_path(file_name, nil) hist_dir = DocumentHelper.history_dir(storage_path) - if File.exist?(storage_path) # if the file exists - File.delete(storage_path) # delete it from the storage path + if File.exist?(storage_path) # if the file exists + File.delete(storage_path) # delete it from the storage path end - if Dir.exist?(hist_dir) # if the history directory of this file exists - FileUtils.remove_entry_secure(hist_dir) # delete it + if Dir.exist?(hist_dir) # if the history directory of this file exists + FileUtils.remove_entry_secure(hist_dir) # delete it end - render plain: '{"success":true}' # report that the operation is successful + render plain: '{"success":true}' # report that the operation is successful return end # getting files information def files file_id = params[:fileId] - filesInfo = DocumentHelper.get_files_info(file_id) # get the information about the file specified by a file id + filesInfo = DocumentHelper.get_files_info(file_id) # get the information about the file specified by a file id render json: filesInfo end @@ -290,9 +290,9 @@ def download end end - file_path = DocumentHelper.forcesave_path(file_name, user_address, false) # get the path to the force saved document version + file_path = DocumentHelper.forcesave_path(file_name, user_address, false) # get the path to the force saved document version if file_path.eql?("") - file_path = DocumentHelper.storage_path(file_name, user_address) # or to the original document + file_path = DocumentHelper.storage_path(file_name, user_address) # or to the original document end # add headers to the response to specify the page parameters @@ -321,12 +321,12 @@ def saveas return end - uri = URI.parse(file_url) # create the request url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + uri = URI.parse(file_url) # create the request url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server DocumentHelper.verify_ssl(file_url, http) - req = Net::HTTP::Get.new(uri.request_uri) # create the get requets + req = Net::HTTP::Get.new(uri.request_uri) # create the get requets res = http.request(req) data = res.body @@ -339,7 +339,7 @@ def saveas file.write(data) end user = Users.get_user(params[:userId]) - DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file + DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file render plain: '{"file" : "' + file_name + '"}' return diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index dff8bd611..ab6be3bd2 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -93,16 +93,16 @@ def forcesave_path(file_name, user_address, create) return "" end - directory = File.join(directory,"#{File.basename(file_name)}-hist") # get the path to the history of the given file + directory = File.join(directory,"#{File.basename(file_name)}-hist") # get the path to the history of the given file unless File.directory?(directory) if create - FileUtils.mkdir_p(directory) # create history directory if it doesn't exist + FileUtils.mkdir_p(directory) # create history directory if it doesn't exist else - return "" # the history directory doesn't exist and we are not supposed to create it + return "" # the history directory doesn't exist and we are not supposed to create it end end - directory = File.join(directory, File.basename(file_name)) # get the path to the given file + directory = File.join(directory, File.basename(file_name)) # get the path to the given file unless File.file?(directory) if !create return "" @@ -136,12 +136,12 @@ def get_file_version(hist_dir) end ver = 1 - Dir.foreach(hist_dir) {|e| # run through all the file versions + Dir.foreach(hist_dir) {|e| # run through all the file versions next if e.eql?(".") next if e.eql?("..") if File.directory?(File.join(hist_dir, e)) - ver += 1 # and count them + ver += 1 # and count them end } @@ -151,14 +151,14 @@ def get_file_version(hist_dir) # get the correct file name if such a name already exists def get_correct_name(file_name, user_address) maxName = 50 - ext = File.extname(file_name) # get file extension + ext = File.extname(file_name) # get file extension # get file name without extension base_name = File.basename(file_name, ext)[0...maxName] + (file_name.length > maxName ? '[...]' : '') - name = base_name + ext.downcase # get full file name + name = base_name + ext.downcase # get full file name index = 1 - while File.exist?(storage_path(name, user_address)) # if the file with such a name already exists in this directory - name = base_name + ' (' + index.to_s + ')' + ext.downcase # add an index after its base name + while File.exist?(storage_path(name, user_address)) # if the file with such a name already exists in this directory + name = base_name + ' (' + index.to_s + ')' + ext.downcase # add an index after its base name index = index + 1 end @@ -172,12 +172,12 @@ def get_stored_files(user_address) arr = []; if Dir.exist?(directory) - Dir.foreach(directory) {|e| # run through all the elements from the folder + Dir.foreach(directory) {|e| # run through all the elements from the folder next if e.eql?(".") next if e.eql?("..") - next if File.directory?(File.join(directory, e)) # if the element is a directory, skip it + next if File.directory?(File.join(directory, e)) # if the element is a directory, skip it - arr.push(e) # push the file to the array + arr.push(e) # push the file to the array } end @@ -186,7 +186,7 @@ def get_stored_files(user_address) # create file meta information def create_meta(file_name, uid, uname, user_address) - hist_dir = history_dir(storage_path(file_name, user_address)) # get the path to the file history + hist_dir = history_dir(storage_path(file_name, user_address)) # get the path to the file history # write user name, user uid and the creation time to the json object json = { @@ -204,9 +204,9 @@ def create_meta(file_name, uid, uname, user_address) # create demo document def create_demo(file_ext, sample, user) demo_name = (sample == 'true' ? 'sample.' : 'new.') + file_ext - file_name = get_correct_name(demo_name, nil) # get the correct file name if such a name already exists + file_name = get_correct_name(demo_name, nil) # get the correct file name if such a name already exists - src = Rails.root.join('assets', 'document-templates', sample == 'true' ? 'sample' : 'new', demo_name) # save sample document of a necessary extension to the storage directory + src = Rails.root.join('assets', 'document-templates', sample == 'true' ? 'sample' : 'new', demo_name) # save sample document of a necessary extension to the storage directory dest = storage_path file_name, nil FileUtils.cp src, dest @@ -244,7 +244,7 @@ def get_server_url(for_document_server) # get callback url def get_callback(file_name) - get_server_url(true) + '/track?fileName=' + ERB::Util.url_encode(file_name) + '&userAddress=' + cur_user_host_address(nil) + get_server_url(true) + '/track?fileName=' + ERB::Util.url_encode(file_name) + '&userAddress=' + cur_user_host_address(nil) end # get url to the created file @@ -255,7 +255,7 @@ def get_create_url(document_type) # get url to download a file def get_download_url(file_name, is_serverUrl=true) user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : "" - get_server_url(is_serverUrl) + '/download?fileName=' + ERB::Util.url_encode(file_name) + user_host + get_server_url(is_serverUrl) + '/download?fileName=' + ERB::Util.url_encode(file_name) + user_host end # get internal file extension by its type @@ -265,10 +265,10 @@ def get_internal_extension(file_type) ext = '.docx' when 'cell' # .xlsx for cell type ext = '.xlsx' - when 'slide' # .pptx for slide type + when 'slide' # .pptx for slide type ext = '.pptx' else - ext = '.docx' # the default value is .docx + ext = '.docx' # the default value is .docx end ext @@ -282,10 +282,10 @@ def get_template_image_url(file_type) full_path = path + 'file_docx.svg' when 'cell' # .xlsx for cell type full_path = path + 'file_xlsx.svg' - when 'slide' # .pptx for slide type + when 'slide' # .pptx for slide type full_path = path + 'file_pptx.svg' else - full_path = path + 'file_docx.svg' # the default value is .docx + full_path = path + 'file_docx.svg' # the default value is .docx end full_path @@ -295,7 +295,7 @@ def get_template_image_url(file_type) def get_files_info(file_id) result = []; - for fileName in get_stored_files(nil) # run through all the stored files from the folder + for fileName in get_stored_files(nil) # run through all the stored files from the folder directory = storage_path(fileName, nil) uri = cur_user_host_address(nil) + '/' + fileName @@ -309,11 +309,11 @@ def get_files_info(file_id) "updated" => File.mtime(directory) } - if file_id == nil # if file id is undefined - result.push(info) # push info object to the response array - else # if file id is defined - if file_id.eql?(info["id"]) # and it is equal to the document key value - result.push(info) # response object will be equal to the info object + if file_id == nil # if file id is undefined + result.push(info) # push info object to the response array + else # if file id is defined + if file_id.eql?(info["id"]) # and it is equal to the document key value + result.push(info) # response object will be equal to the info object return result end end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 15a7d3554..8f2fb2c8f 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -35,7 +35,7 @@ def initialize(attributes = {}) end def type - @type ? @type : "desktop" # the default platform type is desktop + @type ? @type : "desktop" # the default platform type is desktop end # get file extension from its name @@ -60,8 +60,8 @@ def document_type # generate the document key value def key - uri = DocumentHelper.cur_user_host_address(nil) + '/' + @file_name # get current user host address - stat = File.mtime(DocumentHelper.storage_path(@file_name, nil)) # get the modification time of the given file + uri = DocumentHelper.cur_user_host_address(nil) + '/' + @file_name # get current user host address + stat = File.mtime(DocumentHelper.storage_path(@file_name, nil)) # get the modification time of the given file return ServiceConverter.generate_revision_id("#{uri}.#{stat.to_s}") end @@ -87,13 +87,13 @@ def cur_user_host_address # get config parameters def get_config - editorsmode = @mode ? @mode : "edit" # mode: view/edit/review/comment/fillForms/embedded - canEdit = DocumentHelper.edited_exts.include?(file_ext) # check if the document can be edited + editorsmode = @mode ? @mode : "edit" # mode: view/edit/review/comment/fillForms/embedded + canEdit = DocumentHelper.edited_exts.include?(file_ext) # check if the document can be edited if (!canEdit && editorsmode.eql?("edit") || editorsmode.eql?("fillForms")) && DocumentHelper.fill_forms_exts.include?(file_ext) editorsmode = "fillForms" canEdit = true end - submitForm = editorsmode.eql?("fillForms") && @user.id.eql?("uid-1") && false # the Submit form button state + submitForm = editorsmode.eql?("fillForms") && @user.id.eql?("uid-1") && false # the Submit form button state mode = canEdit && !editorsmode.eql?("view") ? "edit" : "view" templatesImageUrl = DocumentHelper.get_template_image_url(document_type) # templates image url in the "From Template" section templates = [ @@ -123,11 +123,11 @@ def get_config :uploaded => Time.now.to_s, :favorite => @user.favorite }, - :permissions => { # the permission for the document to be edited and downloaded or not + :permissions => { # the permission for the document to be edited and downloaded or not :comment => !editorsmode.eql?("view") && !editorsmode.eql?("fillForms") && !editorsmode.eql?("embedded") && !editorsmode.eql?("blockcontent"), :copy => !@user.deniedPermissions.include?("copy"), :download => !@user.deniedPermissions.include?("download"), - :edit => canEdit && (editorsmode.eql?("edit") || editorsmode.eql?("view") || editorsmode.eql?("filter") || editorsmode.eql?("blockcontent")), + :edit => canEdit && (editorsmode.eql?("edit") || editorsmode.eql?("view") || editorsmode.eql?("filter") || editorsmode.eql?("blockcontent")), :print => !@user.deniedPermissions.include?("print"), :fillForms => !editorsmode.eql?("view") && !editorsmode.eql?("comment") && !editorsmode.eql?("embedded") && !editorsmode.eql?("blockcontent"), :modifyFilter => !editorsmode.eql?("filter"), @@ -148,31 +148,31 @@ def get_config :actionLink => @action_data ? JSON.parse(@action_data) : nil, :mode => mode, :lang => @lang ? @lang : "en", - :callbackUrl => callback_url, # absolute URL to the document storage service + :callbackUrl => callback_url, # absolute URL to the document storage service :coEditing => editorsmode.eql?("view") && @user.id.eql?("uid-0") ? { :mode => "strict", :change => false } : nil, :createUrl => !@user.id.eql?("uid-0") ? create_url : nil, :templates => @user.templates ? templates : nil, - :user => { # the user currently viewing or editing the document + :user => { # the user currently viewing or editing the document :id => !@user.id.eql?("uid-0") ? @user.id : nil, :name => @user.name, :group => @user.group, :image => @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil }, - :embedded => { # the parameters for the embedded document type - :saveUrl => download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer + :embedded => { # the parameters for the embedded document type + :saveUrl => download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer :embedUrl => download_url(false), # the absolute URL to the document serving as a source file for the document embedded into the web page :shareUrl => download_url(false), # the absolute URL that will allow other users to share this document - :toolbarDocked => "top" # the place for the embedded viewer toolbar (top or bottom) + :toolbarDocked => "top" # the place for the embedded viewer toolbar (top or bottom) }, - :customization => { # the parameters for the editor interface - :about => true, # the About section display + :customization => { # the parameters for the editor interface + :about => true, # the About section display :comments => true, - :feedback => true, # the Feedback & Support menu button display - :forcesave => false, # adding the request for the forced file saving to the callback handler - :submitForm => submitForm, # the Submit form button state + :feedback => true, # the Feedback & Support menu button display + :forcesave => false, # adding the request for the forced file saving to the callback handler + :submitForm => submitForm, # the Submit form button state :goback => { :url => DocumentHelper.get_server_url(false) }, @@ -180,8 +180,8 @@ def get_config } } - if JwtHelper.is_enabled # check if a secret key to generate token exists or not - config["token"] = JwtHelper.encode(config) # encode a payload object into a token and write it to the config + if JwtHelper.is_enabled # check if a secret key to generate token exists or not + config["token"] = JwtHelper.encode(config) # encode a payload object into a token and write it to the config end return config @@ -194,17 +194,17 @@ def get_history doc_key = key() doc_uri = file_uri() - hist_dir = DocumentHelper.history_dir(DocumentHelper.storage_path(@file_name, nil)) # get the path to the file history - cur_ver = DocumentHelper.get_file_version(hist_dir) # get the file version + hist_dir = DocumentHelper.history_dir(DocumentHelper.storage_path(@file_name, nil)) # get the path to the file history + cur_ver = DocumentHelper.get_file_version(hist_dir) # get the file version - if (cur_ver > 0) # if file was modified + if (cur_ver > 0) # if file was modified hist = [] histData = {} - for i in 1..cur_ver # run through all the file versions + for i in 1..cur_ver # run through all the file versions obj = {} dataObj = {} - ver_dir = DocumentHelper.version_dir(hist_dir, i) # get the path to the given file version + ver_dir = DocumentHelper.version_dir(hist_dir, i) # get the path to the given file version # get document key cur_key = doc_key @@ -216,10 +216,10 @@ def get_history obj["key"] = cur_key obj["version"] = i - if (i == 1) # check if the version number is equal to 1 - if File.file?(File.join(hist_dir, "createdInfo.json")) # check if the createdInfo.json file with meta data exists - File.open(File.join(hist_dir, "createdInfo.json"), 'r') do |file| # open it - cr_info = JSON.parse(file.read()) # parse the file content + if (i == 1) # check if the version number is equal to 1 + if File.file?(File.join(hist_dir, "createdInfo.json")) # check if the createdInfo.json file with meta data exists + File.open(File.join(hist_dir, "createdInfo.json"), 'r') do |file| # open it + cr_info = JSON.parse(file.read()) # parse the file content # write information about changes to the object obj["created"] = cr_info["created"] @@ -240,11 +240,11 @@ def get_history end dataObj["version"] = i - if (i > 1) # check if the version number is greater than 1 + if (i > 1) # check if the version number is greater than 1 changes = nil change = nil - File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), "changes.json"), 'r') do |file| # get the path to the changes.json file - changes = JSON.parse(file.read()) # and parse its content + File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), "changes.json"), 'r') do |file| # get the path to the changes.json file + changes = JSON.parse(file.read()) # and parse its content end change = changes["changes"][0] @@ -255,8 +255,8 @@ def get_history obj["created"] = change ? change["created"] : nil obj["user"] = change ? change["user"] : nil - prev = histData[(i - 2).to_s] # get the history data from the previous file version - dataObj["previous"] = is_enable_direct_url == true ? { # write key and url information about previous file version with optional direct url + prev = histData[(i - 2).to_s] # get the history data from the previous file version + dataObj["previous"] = is_enable_direct_url == true ? { # write key and url information about previous file version with optional direct url :fileType => prev["fileType"], :key => prev["key"], :url => prev["url"], @@ -271,16 +271,16 @@ def get_history dataObj["changesUrl"] = DocumentHelper.get_historypath_uri(file_name, i - 1, "diff.zip") end - if JwtHelper.is_enabled # check if a secret key to generate token exists or not - dataObj["token"] = JwtHelper.encode(dataObj) # encode a payload object into a token and write it to the data object + if JwtHelper.is_enabled # check if a secret key to generate token exists or not + dataObj["token"] = JwtHelper.encode(dataObj) # encode a payload object into a token and write it to the data object end - hist.push(obj) # add object dictionary to the hist list - histData[(i - 1).to_s] = dataObj # write data object information to the history data + hist.push(obj) # add object dictionary to the hist list + histData[(i - 1).to_s] = dataObj # write data object information to the history data end return { - :hist => { # write history information about the current file version to the hist + :hist => { # write history information about the current file version to the hist :currentVersion => cur_ver, :history => hist }, @@ -294,16 +294,16 @@ def get_history # get image information def get_insert_image insert_image = is_enable_direct_url == true ? { - :fileType => "png", # image file type - :url => DocumentHelper.get_server_url(true) + "/assets/logo.png", # server url to the image - :directUrl => DocumentHelper.get_server_url(false) + "/assets/logo.png" # direct url to the image + :fileType => "png", # image file type + :url => DocumentHelper.get_server_url(true) + "/assets/logo.png", # server url to the image + :directUrl => DocumentHelper.get_server_url(false) + "/assets/logo.png" # direct url to the image } : { - :fileType => "png", # image file type - :url => DocumentHelper.get_server_url(true) + "/assets/logo.png" # server url to the image + :fileType => "png", # image file type + :url => DocumentHelper.get_server_url(true) + "/assets/logo.png" # server url to the image } - if JwtHelper.is_enabled # check if a secret key to generate token exists or not - insert_image["token"] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object + if JwtHelper.is_enabled # check if a secret key to generate token exists or not + insert_image["token"] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object end return insert_image.to_json.tr("{", "").tr("}","") @@ -312,16 +312,16 @@ def get_insert_image # get compared file information def dataDocument compare_file = is_enable_direct_url == true ? { - :fileType => "docx", # file type - :url => DocumentHelper.get_server_url(true) + "/asset?fileName=sample.docx", # server url to the compared file - :directUrl => DocumentHelper.get_server_url(false) + "/asset?fileName=sample.docx" # direct url to the compared file + :fileType => "docx", # file type + :url => DocumentHelper.get_server_url(true) + "/asset?fileName=sample.docx", # server url to the compared file + :directUrl => DocumentHelper.get_server_url(false) + "/asset?fileName=sample.docx" # direct url to the compared file } : { - :fileType => "docx", # file type - :url => DocumentHelper.get_server_url(true) + "/asset?fileName=sample.docx" # server url to the compared file + :fileType => "docx", # file type + :url => DocumentHelper.get_server_url(true) + "/asset?fileName=sample.docx" # server url to the compared file } - if JwtHelper.is_enabled # check if a secret key to generate token exists or not - compare_file["token"] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object + if JwtHelper.is_enabled # check if a secret key to generate token exists or not + compare_file["token"] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object end return compare_file @@ -330,16 +330,16 @@ def dataDocument # get mail merge recipients information def dataSpreadsheet dataSpreadsheet = is_enable_direct_url == true ? { - :fileType => "csv", # file type - :url => DocumentHelper.get_server_url(true) + "/csv", # server url to the mail merge recipients file - :directUrl => DocumentHelper.get_server_url(false) + "/csv" # direct url to the mail merge recipients file + :fileType => "csv", # file type + :url => DocumentHelper.get_server_url(true) + "/csv", # server url to the mail merge recipients file + :directUrl => DocumentHelper.get_server_url(false) + "/csv" # direct url to the mail merge recipients file } : { - :fileType => "csv", # file type - :url => DocumentHelper.get_server_url(true) + "/csv" # server url to the mail merge recipients file + :fileType => "csv", # file type + :url => DocumentHelper.get_server_url(true) + "/csv" # server url to the mail merge recipients file } - if JwtHelper.is_enabled # check if a secret key to generate token exists or not - dataSpreadsheet["token"] = JwtHelper.encode(dataSpreadsheet) # encode a payload object into a token and write it to the dataSpreadsheet object + if JwtHelper.is_enabled # check if a secret key to generate token exists or not + dataSpreadsheet["token"] = JwtHelper.encode(dataSpreadsheet) # encode a payload object into a token and write it to the dataSpreadsheet object end return dataSpreadsheet diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index b7268f011..ebb708237 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -30,7 +30,7 @@ class << self # get the url of the converted file def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_async, file_pass, lang = nil) - from_ext = from_ext == nil ? File.extname(document_uri).downcase : from_ext # get the current document extension + from_ext = from_ext == nil ? File.extname(document_uri).downcase : from_ext # get the current document extension # get the current document name or uuid title = File.basename(URI.parse(document_uri).path) @@ -40,7 +40,7 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ document_revision_id = document_revision_id.empty? ? document_uri : document_revision_id document_revision_id = generate_revision_id(document_revision_id) - payload = { # write all the conversion parameters to the payload + payload = { # write all the conversion parameters to the payload :async => is_async ? true : false, :url => document_uri, :outputtype => to_ext.delete('.'), @@ -54,52 +54,52 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ data = nil begin - uri = URI.parse(@@document_converter_url) # create the request url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + uri = URI.parse(@@document_converter_url) # create the request url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server DocumentHelper.verify_ssl(@@document_converter_url, http) http.read_timeout = @@convert_timeout http.open_timeout = 5 - req = Net::HTTP::Post.new(uri.request_uri) # create the post request - req.add_field("Accept", "application/json") # set headers + req = Net::HTTP::Post.new(uri.request_uri) # create the post request + req.add_field("Accept", "application/json") # set headers req.add_field("Content-Type", "application/json") - if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled - payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload - jwtHeader = ServiceConverter.config_manager.jwt_header; # get signature authorization header - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix + if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled + payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload + jwtHeader = ServiceConverter.config_manager.jwt_header; # get signature authorization header + req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix end req.body = payload.to_json - res = http.request(req) # get the response + res = http.request(req) # get the response status_code = res.code.to_i - if status_code != 200 # checking status code + if status_code != 200 # checking status code raise "Conversion service returned status: #{status_code}" end - data = res.body # and take its body + data = res.body # and take its body rescue Timeout::Error # try again rescue => ex raise ex.message end - json_data = JSON.parse(data) # parse response body - return get_response_data(json_data) # get response url + json_data = JSON.parse(data) # parse response body + return get_response_data(json_data) # get response url end # generate the document key value def generate_revision_id(expected_key) require 'zlib' - if expected_key.length > 20 # check if the expected key length is greater than 20 - expected_key = (Zlib.crc32 expected_key).to_s # calculate 32-bit crc value from the expected key and turn it into the string + if expected_key.length > 20 # check if the expected key length is greater than 20 + expected_key = (Zlib.crc32 expected_key).to_s # calculate 32-bit crc value from the expected key and turn it into the string end key = expected_key.gsub(/[^0-9a-zA-Z.=]/, '_') - key[(key.length - [key.length, 20].min)..key.length] # the resulting key is of the length 20 or less + key[(key.length - [key.length, 20].min)..key.length] # the resulting key is of the length 20 or less end # create an error message for the error code @@ -127,7 +127,7 @@ def process_convert_service_responce_error(error_code) when 0 # public const int c_nErrorNo = 0 else - error_message = 'ErrorCode = ' + error_code.to_s # default value for the error message + error_message = 'ErrorCode = ' + error_code.to_s # default value for the error message end raise error_message @@ -138,30 +138,30 @@ def get_response_data(json_data) file_result = json_data error_element = file_result['error'] - if error_element != nil # if an error occurs - process_convert_service_responce_error(error_element.to_i) # get an error message + if error_element != nil # if an error occurs + process_convert_service_responce_error(error_element.to_i) # get an error message end - is_end_convert = file_result['endConvert'] # check if the conversion is completed + is_end_convert = file_result['endConvert'] # check if the conversion is completed - result_percent = 0 # the conversion percentage + result_percent = 0 # the conversion percentage response_uri = '' response_file_type = '' - if is_end_convert # if the conversion is completed + if is_end_convert # if the conversion is completed file_url_element = file_result['fileUrl'] file_type_element = file_result['fileType'] - if file_url_element == nil # and the file url doesn't exist + if file_url_element == nil # and the file url doesn't exist raise 'Invalid answer format' # get ann error message end response_uri = file_url_element # otherwise, get the file url - response_file_type = file_type_element # get the file type + response_file_type = file_type_element # get the file type result_percent = 100 - else # if the conversion isn't completed + else # if the conversion isn't completed percent_element = file_result['percent'] # get the percentage value diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index a3250eacf..65b56b2ca 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -40,22 +40,22 @@ def read_body(request) return "" end - file_data = JSON.parse(body) # parse file data + file_data = JSON.parse(body) # parse file data # check if a secret key to generate token exists or not if JwtHelper.is_enabled && JwtHelper.use_for_request inHeader = false token = nil - jwtHeader = TrackHelper.config_manager.jwt_header; # get the authorization header from the config - if file_data["token"] # if the token is in the body - token = JwtHelper.decode(file_data["token"]) # decode a token into a payload object using a secret key - elsif request.headers[jwtHeader] # if the token is in the header + jwtHeader = TrackHelper.config_manager.jwt_header; # get the authorization header from the config + if file_data["token"] # if the token is in the body + token = JwtHelper.decode(file_data["token"]) # decode a token into a payload object using a secret key + elsif request.headers[jwtHeader] # if the token is in the header hdr = request.headers[jwtHeader] - hdr.slice!(0, "Bearer ".length) # get token from it (after Bearer prefix) - token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key + hdr.slice!(0, "Bearer ".length) # get token from it (after Bearer prefix) + token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key inHeader = true else - raise "Expected JWT" # token missing error message + raise "Expected JWT" # token missing error message end if !token || token.eql?("") @@ -108,9 +108,9 @@ def process_save(raw_file_data, file_name, user_address) end new_file_name = file_name - download_ext = "."+file_data['filetype'] # get the extension of the downloaded file + download_ext = "."+file_data['filetype'] # get the extension of the downloaded file - cur_ext = File.extname(file_name).downcase # get current file extension + cur_ext = File.extname(file_name).downcase # get current file extension # convert downloaded file to the file with the current extension if these extensions aren't equal unless cur_ext.eql?(download_ext) @@ -135,16 +135,16 @@ def process_save(raw_file_data, file_name, user_address) end begin - storage_path = DocumentHelper.storage_path(new_file_name, user_address) # get the storage directory of the new file + storage_path = DocumentHelper.storage_path(new_file_name, user_address) # get the storage directory of the new file - hist_dir = DocumentHelper.history_dir(storage_path) # get the history directory of the new file - ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) # get the path to the specified file version + hist_dir = DocumentHelper.history_dir(storage_path) # get the history directory of the new file + ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) # get the path to the specified file version - FileUtils.mkdir_p(ver_dir) # create the version directory if doesn't exist + FileUtils.mkdir_p(ver_dir) # create the version directory if doesn't exist - FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) # move the file from the storage directory to the previous file version directory + FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) # move the file from the storage directory to the previous file version directory - save_file(data, storage_path) # save the downloaded file to the storage directory + save_file(data, storage_path) # save the downloaded file to the storage directory change_data = download_file(file_data["changesurl"]) # download file with document versions differences save_file(change_data, File.join(ver_dir, "diff.zip")) # save file with document versions differences @@ -154,8 +154,8 @@ def process_save(raw_file_data, file_name, user_address) hist_data = file_data["history"].to_json # write the original history information to the history data end if hist_data - File.open(File.join(ver_dir, "changes.json"), 'wb') do |file| # open the file with document changes - file.write(hist_data) # and write history data to this file + File.open(File.join(ver_dir, "changes.json"), 'wb') do |file| # open the file with document changes + file.write(hist_data) # and write history data to this file end end @@ -164,7 +164,7 @@ def process_save(raw_file_data, file_name, user_address) file.write(file_data["key"]) end - forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) # get the path to the forcesaved file + forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) # get the path to the forcesaved file unless forcesave_path.eql?("") # if this path is empty File.delete(forcesave_path) # remove it end @@ -185,9 +185,9 @@ def process_force_save(file_data, file_name, user_address) return saved end - download_ext = "."+file_data['filetype'] # get the extension of the downloaded file + download_ext = "."+file_data['filetype'] # get the extension of the downloaded file - cur_ext = File.extname(file_name).downcase # get current file extension + cur_ext = File.extname(file_name).downcase # get current file extension new_file_name = false @@ -214,30 +214,30 @@ def process_force_save(file_data, file_name, user_address) end begin - is_submit_form = file_data["forcesavetype"].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) + is_submit_form = file_data["forcesavetype"].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) if is_submit_form if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + download_ext, user_address) # get the correct file name if it already exists + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + download_ext, user_address) # get the correct file name if it already exists else file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + cur_ext, user_address) end - forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file + forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else if new_file_name file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) end forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) if forcesave_path.eql?("") - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it + forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it end end - save_file(data, forcesave_path) # save the downloaded file to the storage directory + save_file(data, forcesave_path) # save the downloaded file to the storage directory if is_submit_form uid = file_data['actions'][0]['userid'] - DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name + DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name end saved = 0 @@ -263,35 +263,35 @@ def command_request(method, key, meta = nil) data = nil begin - uri = URI.parse(@@document_command_url) # parse the document command url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + uri = URI.parse(@@document_command_url) # parse the document command url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server DocumentHelper.verify_ssl(@@document_command_url, http) - req = Net::HTTP::Post.new(uri.request_uri) # create the post request - req.add_field("Content-Type", "application/json") # set headers + req = Net::HTTP::Post.new(uri.request_uri) # create the post request + req.add_field("Content-Type", "application/json") # set headers - if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled - payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload - jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix + if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled + payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload + jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header + req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix end - req.body = payload.to_json # convert the payload object into the json format - res = http.request(req) # get the response - data = res.body # and take its body + req.body = payload.to_json # convert the payload object into the json format + res = http.request(req) # get the response + data = res.body # and take its body rescue => ex raise ex.message end - json_data = JSON.parse(data) # convert the response body into the json format + json_data = JSON.parse(data) # convert the response body into the json format return json_data end # save file from the url def download_file(uristr) - uri = URI.parse(uristr) # parse the url string - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + uri = URI.parse(uristr) # parse the url string + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server http.open_timeout = 5 DocumentHelper.verify_ssl(uristr, http) @@ -304,7 +304,7 @@ def download_file(uristr) raise "Document editing service returned status: #{status_code}" end - data = res.body # and take its body + data = res.body # and take its body if data == nil raise 'stream is null' @@ -314,7 +314,7 @@ def download_file(uristr) end def save_file(data, path) - File.open(path, 'wb') do |file| # open the file from the path specified + File.open(path, 'wb') do |file| # open the file from the path specified file.write(data) # and write the response data to it end end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index fe827482a..00d43150d 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -110,11 +110,11 @@ class Users ] class << self - def get_all_users() # get a list of all the users + def get_all_users() # get a list of all the users @@users end - def get_user(id) # get a user by id specified + def get_user(id) # get a user by id specified for user in @@users do if user.id.eql?(id) return user @@ -123,7 +123,7 @@ def get_user(id) # get a user by id specified return @@users[0] end - def get_users_for_mentions(id) # get a list of users with their names and emails for mentions + def get_users_for_mentions(id) # get a list of users with their names and emails for mentions usersData = [] for user in @@users do if (!user.id.eql?(id) && user.name != nil && user.email != nil) From 3b66092a45e81b2eaf5393e465a631fb87cc697a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:25:32 +0300 Subject: [PATCH 252/488] ruby: Layout/IndentationWidth correct --- .../ruby/app/controllers/home_controller.rb | 148 +++--- .../ruby/app/models/document_helper.rb | 2 +- .../ruby/app/models/jwt_helper.rb | 52 +- .../ruby/app/models/track_helper.rb | 460 +++++++++--------- .../ruby/app/models/users.rb | 226 ++++----- 5 files changed, 444 insertions(+), 444 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index f4218dbd0..0d97d3f92 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -89,7 +89,7 @@ def convert begin file_data = request.body.read if file_data == nil || file_data.empty? - return "" + return "" end body = JSON.parse(file_data) @@ -205,7 +205,7 @@ def track if file_data['actions'][0]['type'] == 0 # finished edit user = file_data['actions'][0]['userid'] # get the user id if !file_data['users'].index(user) - json_data = TrackHelper.command_request("forcesave", file_data['key']) # call the forcesave command + json_data = TrackHelper.command_request("forcesave", file_data['key']) # call the forcesave command end end end @@ -280,7 +280,7 @@ def download if JwtHelper.is_enabled && isEmbedded == nil && user_address != nil && JwtHelper.use_for_request jwtHeader = HomeController.config_manager.jwt_header; if request.headers[jwtHeader] - hdr = request.headers[jwtHeader] + hdr = request.headers[jwtHeader] hdr.slice!(0, "Bearer ".length) token = JwtHelper.decode(hdr) end @@ -350,95 +350,95 @@ def saveas end # Rename... - def rename - body = JSON.parse(request.body.read) - dockey = body["dockey"] - newfilename = body["newfilename"] + def rename + body = JSON.parse(request.body.read) + dockey = body["dockey"] + newfilename = body["newfilename"] - orig_ext = '.' + body["ext"] - cur_ext = File.extname(newfilename).downcase - if orig_ext != cur_ext - newfilename += orig_ext - end + orig_ext = '.' + body["ext"] + cur_ext = File.extname(newfilename).downcase + if orig_ext != cur_ext + newfilename += orig_ext + end - meta = { - :title => newfilename - } + meta = { + :title => newfilename + } - json_data = TrackHelper.command_request("meta", dockey, meta) - render plain: '{ "result" : "' + JSON.dump(json_data) + '"}' - end + json_data = TrackHelper.command_request("meta", dockey, meta) + render plain: '{ "result" : "' + JSON.dump(json_data) + '"}' + end #ReferenceData - def reference - body = JSON.parse(request.body.read) - fileName = "" - - - if body.key?("referenceData") - referenceData = body["referenceData"] - instanceId = referenceData["instanceId"] - if instanceId == DocumentHelper.get_server_url(false) - fileKey = JSON.parse(referenceData["fileKey"]) - userAddress = fileKey["userAddress"] - if userAddress == DocumentHelper.cur_user_host_address(nil) - fileName = fileKey["fileName"] - end + def reference + body = JSON.parse(request.body.read) + fileName = "" + + + if body.key?("referenceData") + referenceData = body["referenceData"] + instanceId = referenceData["instanceId"] + if instanceId == DocumentHelper.get_server_url(false) + fileKey = JSON.parse(referenceData["fileKey"]) + userAddress = fileKey["userAddress"] + if userAddress == DocumentHelper.cur_user_host_address(nil) + fileName = fileKey["fileName"] end end + end - link = body["link"] - if fileName.empty? and body.key?("link") - if !link.include?(DocumentHelper.get_server_url(false)) - data = { - url: link, - directUrl: link - } - render plain: data.to_json - return - end - - url_obj = URI(link) - query_params = CGI.parse(url_obj.query) - fileName = query_params['fileName'].first - if !File.exist?(DocumentHelper.storage_path(fileName, nil)) - render plain: '{ "error": "File is not exist"}' - return - end + link = body["link"] + if fileName.empty? and body.key?("link") + if !link.include?(DocumentHelper.get_server_url(false)) + data = { + url: link, + directUrl: link + } + render plain: data.to_json + return end - if fileName.empty? and body.key?("path") - path = File.basename(body["path"]) - if File.exist?(DocumentHelper.storage_path(path, nil)) - fileName = path - end + url_obj = URI(link) + query_params = CGI.parse(url_obj.query) + fileName = query_params['fileName'].first + if !File.exist?(DocumentHelper.storage_path(fileName, nil)) + render plain: '{ "error": "File is not exist"}' + return end + end - if fileName.empty? - render plain: '{ "error": "File not found"}' - return + if fileName.empty? and body.key?("path") + path = File.basename(body["path"]) + if File.exist?(DocumentHelper.storage_path(path, nil)) + fileName = path end + end - data = { - :fileType => File.extname(fileName).downcase.delete("."), - :key => ServiceConverter.generate_revision_id("#{DocumentHelper.cur_user_host_address(nil) + '/' + fileName}.#{File.mtime(DocumentHelper.storage_path(fileName, nil)).to_s}"), - :url => DocumentHelper.get_download_url(fileName), - :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName, false) : nil, - :referenceData => { - :instanceId => DocumentHelper.get_server_url(false), - :fileKey => {:fileName => fileName,:userAddress => DocumentHelper.cur_user_host_address(nil)}.to_json - }, - :path => fileName, - :link => DocumentHelper.get_server_url(false) + '/editor?fileName=' + fileName - } + if fileName.empty? + render plain: '{ "error": "File not found"}' + return + end - if JwtHelper.is_enabled - data["token"] = JwtHelper.encode(data) - end + data = { + :fileType => File.extname(fileName).downcase.delete("."), + :key => ServiceConverter.generate_revision_id("#{DocumentHelper.cur_user_host_address(nil) + '/' + fileName}.#{File.mtime(DocumentHelper.storage_path(fileName, nil)).to_s}"), + :url => DocumentHelper.get_download_url(fileName), + :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName, false) : nil, + :referenceData => { + :instanceId => DocumentHelper.get_server_url(false), + :fileKey => {:fileName => fileName,:userAddress => DocumentHelper.cur_user_host_address(nil)}.to_json + }, + :path => fileName, + :link => DocumentHelper.get_server_url(false) + '/editor?fileName=' + fileName + } - render plain: data.to_json + if JwtHelper.is_enabled + data["token"] = JwtHelper.encode(data) end + render plain: data.to_json + end + def restore body = JSON.parse(request.body.read) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index ab6be3bd2..78558091d 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -158,7 +158,7 @@ def get_correct_name(file_name, user_address) index = 1 while File.exist?(storage_path(name, user_address)) # if the file with such a name already exists in this directory - name = base_name + ' (' + index.to_s + ')' + ext.downcase # add an index after its base name + name = base_name + ' (' + index.to_s + ')' + ext.downcase # add an index after its base name index = index + 1 end diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 4101c144b..1e0b22f62 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -19,35 +19,35 @@ class JwtHelper - @jwt_secret = ConfigurationManager.new.jwt_secret - @token_use_for_request = ConfigurationManager.new.jwt_use_for_request + @jwt_secret = ConfigurationManager.new.jwt_secret + @token_use_for_request = ConfigurationManager.new.jwt_use_for_request - class << self - # check if a secret key to generate token exists or not - def is_enabled - return @jwt_secret && !@jwt_secret.empty? ? true : false - end + class << self + # check if a secret key to generate token exists or not + def is_enabled + return @jwt_secret && !@jwt_secret.empty? ? true : false + end - # check if a secret key used for request - def use_for_request - return @token_use_for_request - end + # check if a secret key used for request + def use_for_request + return @token_use_for_request + end - # encode a payload object into a token using a secret key - def encode(payload) - return JWT.encode payload, @jwt_secret, 'HS256' # define the hashing algorithm and get token - end + # encode a payload object into a token using a secret key + def encode(payload) + return JWT.encode payload, @jwt_secret, 'HS256' # define the hashing algorithm and get token + end - # decode a token into a payload object using a secret key - def decode(token) - begin - decoded = JWT.decode token, @jwt_secret, true, { algorithm: 'HS256' } - rescue - return "" - end - # decoded = Array [ {"data"=>"test"}, # payload - # {"alg"=>"HS256"} # header ] - return decoded[0].to_json # get json payload - end + # decode a token into a payload object using a secret key + def decode(token) + begin + decoded = JWT.decode token, @jwt_secret, true, { algorithm: 'HS256' } + rescue + return "" + end + # decoded = Array [ {"data"=>"test"}, # payload + # {"alg"=>"HS256"} # header ] + return decoded[0].to_json # get json payload end + end end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 65b56b2ca..c7b0f45b7 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -30,293 +30,293 @@ class << self @@document_command_url = TrackHelper.config_manager.document_server_command_uri.to_s - class << self + class << self + + # read the request body + def read_body(request) + body = request.body.read - # read the request body - def read_body(request) - body = request.body.read + if body == nil || body.empty? + return "" + end - if body == nil || body.empty? - return "" + file_data = JSON.parse(body) # parse file data + + # check if a secret key to generate token exists or not + if JwtHelper.is_enabled && JwtHelper.use_for_request + inHeader = false + token = nil + jwtHeader = TrackHelper.config_manager.jwt_header; # get the authorization header from the config + if file_data["token"] # if the token is in the body + token = JwtHelper.decode(file_data["token"]) # decode a token into a payload object using a secret key + elsif request.headers[jwtHeader] # if the token is in the header + hdr = request.headers[jwtHeader] + hdr.slice!(0, "Bearer ".length) # get token from it (after Bearer prefix) + token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key + inHeader = true + else + raise "Expected JWT" # token missing error message end - file_data = JSON.parse(body) # parse file data - - # check if a secret key to generate token exists or not - if JwtHelper.is_enabled && JwtHelper.use_for_request - inHeader = false - token = nil - jwtHeader = TrackHelper.config_manager.jwt_header; # get the authorization header from the config - if file_data["token"] # if the token is in the body - token = JwtHelper.decode(file_data["token"]) # decode a token into a payload object using a secret key - elsif request.headers[jwtHeader] # if the token is in the header - hdr = request.headers[jwtHeader] - hdr.slice!(0, "Bearer ".length) # get token from it (after Bearer prefix) - token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key - inHeader = true - else - raise "Expected JWT" # token missing error message - end - - if !token || token.eql?("") - raise "Invalid JWT signature" - end - - file_data = JSON.parse(token) - - if inHeader - file_data = file_data["payload"] - end + if !token || token.eql?("") + raise "Invalid JWT signature" end - return file_data - end + file_data = JSON.parse(token) - def resolve_process_save_body(body) - copied = body.dup + if inHeader + file_data = file_data["payload"] + end + end - url = copied['url'] - if url - uri = URI(url) - resolved_uri = TrackHelper.proxy_manager.resolve_uri(uri) - copied['url'] = resolved_uri.to_s - end + return file_data + end - changesurl = copied['changesurl'] - if changesurl - uri = URI(changesurl) - resolved_uri = TrackHelper.proxy_manager.resolve_uri(uri) - copied['changesurl'] = resolved_uri.to_s - end + def resolve_process_save_body(body) + copied = body.dup + + url = copied['url'] + if url + uri = URI(url) + resolved_uri = TrackHelper.proxy_manager.resolve_uri(uri) + copied['url'] = resolved_uri.to_s + end + + changesurl = copied['changesurl'] + if changesurl + uri = URI(changesurl) + resolved_uri = TrackHelper.proxy_manager.resolve_uri(uri) + copied['changesurl'] = resolved_uri.to_s + end + + home = copied['home'] + if home + copied['home'] = resolve_process_save_body(home) + end + + copied + end - home = copied['home'] - if home - copied['home'] = resolve_process_save_body(home) - end + # file saving process + def process_save(raw_file_data, file_name, user_address) + file_data = resolve_process_save_body(raw_file_data) - copied + download_uri = file_data['url'] + if download_uri.eql?(nil) + saved = 1 + return saved end - # file saving process - def process_save(raw_file_data, file_name, user_address) - file_data = resolve_process_save_body(raw_file_data) + new_file_name = file_name + download_ext = "."+file_data['filetype'] # get the extension of the downloaded file - download_uri = file_data['url'] - if download_uri.eql?(nil) - saved = 1 - return saved - end + cur_ext = File.extname(file_name).downcase # get current file extension - new_file_name = file_name - download_ext = "."+file_data['filetype'] # get the extension of the downloaded file - - cur_ext = File.extname(file_name).downcase # get current file extension - - # convert downloaded file to the file with the current extension if these extensions aren't equal - unless cur_ext.eql?(download_ext) - key = ServiceConverter.generate_revision_id(download_uri) # get the document key - begin - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file - if new_file_uri == nil || new_file_uri.empty? - new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) # get the correct file name if it already exists - else - download_uri = new_file_uri - end - rescue StandardError => msg - new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) - end + # convert downloaded file to the file with the current extension if these extensions aren't equal + unless cur_ext.eql?(download_ext) + key = ServiceConverter.generate_revision_id(download_uri) # get the document key + begin + percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file + if new_file_uri == nil || new_file_uri.empty? + new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) # get the correct file name if it already exists + else + download_uri = new_file_uri + end + rescue StandardError => msg + new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) end + end - saved = 1 - - data = download_file(download_uri) # download document file - if data.eql?(nil) - return saved - end + saved = 1 - begin - storage_path = DocumentHelper.storage_path(new_file_name, user_address) # get the storage directory of the new file + data = download_file(download_uri) # download document file + if data.eql?(nil) + return saved + end - hist_dir = DocumentHelper.history_dir(storage_path) # get the history directory of the new file - ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) # get the path to the specified file version + begin + storage_path = DocumentHelper.storage_path(new_file_name, user_address) # get the storage directory of the new file - FileUtils.mkdir_p(ver_dir) # create the version directory if doesn't exist + hist_dir = DocumentHelper.history_dir(storage_path) # get the history directory of the new file + ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) # get the path to the specified file version - FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) # move the file from the storage directory to the previous file version directory + FileUtils.mkdir_p(ver_dir) # create the version directory if doesn't exist - save_file(data, storage_path) # save the downloaded file to the storage directory + FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) # move the file from the storage directory to the previous file version directory - change_data = download_file(file_data["changesurl"]) # download file with document versions differences - save_file(change_data, File.join(ver_dir, "diff.zip")) # save file with document versions differences + save_file(data, storage_path) # save the downloaded file to the storage directory - hist_data = file_data["changeshistory"] - unless hist_data # if there are no changes in the history - hist_data = file_data["history"].to_json # write the original history information to the history data - end - if hist_data - File.open(File.join(ver_dir, "changes.json"), 'wb') do |file| # open the file with document changes - file.write(hist_data) # and write history data to this file - end - end + change_data = download_file(file_data["changesurl"]) # download file with document versions differences + save_file(change_data, File.join(ver_dir, "diff.zip")) # save file with document versions differences - # write the key value to the key.txt file - File.open(File.join(ver_dir, "key.txt"), 'wb') do |file| - file.write(file_data["key"]) - end + hist_data = file_data["changeshistory"] + unless hist_data # if there are no changes in the history + hist_data = file_data["history"].to_json # write the original history information to the history data + end + if hist_data + File.open(File.join(ver_dir, "changes.json"), 'wb') do |file| # open the file with document changes + file.write(hist_data) # and write history data to this file + end + end - forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) # get the path to the forcesaved file - unless forcesave_path.eql?("") # if this path is empty - File.delete(forcesave_path) # remove it - end + # write the key value to the key.txt file + File.open(File.join(ver_dir, "key.txt"), 'wb') do |file| + file.write(file_data["key"]) + end - saved = 0 - rescue StandardError => msg - saved = 1 - end + forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) # get the path to the forcesaved file + unless forcesave_path.eql?("") # if this path is empty + File.delete(forcesave_path) # remove it + end - saved + saved = 0 + rescue StandardError => msg + saved = 1 end - # file force saving process - def process_force_save(file_data, file_name, user_address) - download_uri = file_data['url'] - if download_uri.eql?(nil) - saved = 1 - return saved - end + saved + end - download_ext = "."+file_data['filetype'] # get the extension of the downloaded file - - cur_ext = File.extname(file_name).downcase # get current file extension - - new_file_name = false - - # convert downloaded file to the file with the current extension if these extensions aren't equal - unless cur_ext.eql?(download_ext) - key = ServiceConverter.generate_revision_id(download_uri) # get the document key - begin - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file - if new_file_uri == nil || new_file_uri.empty? - new_file_name = true - else - download_uri = new_file_uri - end - rescue StandardError => msg - new_file_name = true - end - end + # file force saving process + def process_force_save(file_data, file_name, user_address) + download_uri = file_data['url'] + if download_uri.eql?(nil) + saved = 1 + return saved + end - saved = 1 + download_ext = "."+file_data['filetype'] # get the extension of the downloaded file - data = download_file(download_uri) # download document file - if data.eql?(nil) - return saved - end + cur_ext = File.extname(file_name).downcase # get current file extension + + new_file_name = false + # convert downloaded file to the file with the current extension if these extensions aren't equal + unless cur_ext.eql?(download_ext) + key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin - is_submit_form = file_data["forcesavetype"].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) - - if is_submit_form - if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + download_ext, user_address) # get the correct file name if it already exists - else - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + cur_ext, user_address) - end - forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file - else - if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) - end - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) - if forcesave_path.eql?("") - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it - end - end - - save_file(data, forcesave_path) # save the downloaded file to the storage directory - - if is_submit_form - uid = file_data['actions'][0]['userid'] - DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name - end - - saved = 0 - rescue StandardError => msg - saved = 1 + percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file + if new_file_uri == nil || new_file_uri.empty? + new_file_name = true + else + download_uri = new_file_uri + end + rescue StandardError => msg + new_file_name = true end + end + + saved = 1 - saved + data = download_file(download_uri) # download document file + if data.eql?(nil) + return saved end - # send the command request - def command_request(method, key, meta = nil) - # create a payload object with the method and key - payload = { - :c => method, - :key => key - } + begin + is_submit_form = file_data["forcesavetype"].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) - if (meta != nil) - payload.merge!({:meta => meta}) + if is_submit_form + if new_file_name + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + download_ext, user_address) # get the correct file name if it already exists + else + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + cur_ext, user_address) end + forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file + else + if new_file_name + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) + end + forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) + if forcesave_path.eql?("") + forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it + end + end - data = nil - begin - - uri = URI.parse(@@document_command_url) # parse the document command url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + save_file(data, forcesave_path) # save the downloaded file to the storage directory - DocumentHelper.verify_ssl(@@document_command_url, http) + if is_submit_form + uid = file_data['actions'][0]['userid'] + DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name + end - req = Net::HTTP::Post.new(uri.request_uri) # create the post request - req.add_field("Content-Type", "application/json") # set headers + saved = 0 + rescue StandardError => msg + saved = 1 + end - if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled - payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload - jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix - end + saved + end - req.body = payload.to_json # convert the payload object into the json format - res = http.request(req) # get the response - data = res.body # and take its body - rescue => ex - raise ex.message - end + # send the command request + def command_request(method, key, meta = nil) + # create a payload object with the method and key + payload = { + :c => method, + :key => key + } - json_data = JSON.parse(data) # convert the response body into the json format - return json_data + if (meta != nil) + payload.merge!({:meta => meta}) end - # save file from the url - def download_file(uristr) - uri = URI.parse(uristr) # parse the url string - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - http.open_timeout = 5 + data = nil + begin - DocumentHelper.verify_ssl(uristr, http) + uri = URI.parse(@@document_command_url) # parse the document command url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - req = Net::HTTP::Get.new(uri) - res = http.request(req) # get the response + DocumentHelper.verify_ssl(@@document_command_url, http) - status_code = res.code - if status_code != '200' # checking status code - raise "Document editing service returned status: #{status_code}" - end + req = Net::HTTP::Post.new(uri.request_uri) # create the post request + req.add_field("Content-Type", "application/json") # set headers - data = res.body # and take its body + if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled + payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload + jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header + req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix + end - if data == nil - raise 'stream is null' - end + req.body = payload.to_json # convert the payload object into the json format + res = http.request(req) # get the response + data = res.body # and take its body + rescue => ex + raise ex.message + end + + json_data = JSON.parse(data) # convert the response body into the json format + return json_data + end + + # save file from the url + def download_file(uristr) + uri = URI.parse(uristr) # parse the url string + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + http.open_timeout = 5 + + DocumentHelper.verify_ssl(uristr, http) + + req = Net::HTTP::Get.new(uri) + res = http.request(req) # get the response - data + status_code = res.code + if status_code != '200' # checking status code + raise "Document editing service returned status: #{status_code}" end - def save_file(data, path) - File.open(path, 'wb') do |file| # open the file from the path specified - file.write(data) # and write the response data to it - end + data = res.body # and take its body + + if data == nil + raise 'stream is null' end + + data end + + def save_file(data, path) + File.open(path, 'wb') do |file| # open the file from the path specified + file.write(data) # and write the response data to it + end + end + end end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 00d43150d..471b6b382 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -15,133 +15,133 @@ # class User - attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, - :deniedPermissions, :descriptions, :templates, :avatar + attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, + :deniedPermissions, :descriptions, :templates, :avatar - def initialize (id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, - deniedPermissions, descriptions, templates, avatar) - @id = id - @name = name - @email = email - @group = group - @reviewGroups = reviewGroups - @commentGroups = commentGroups - @favorite = favorite - @deniedPermissions = deniedPermissions - @descriptions = descriptions - @templates = templates - @userInfoGroups = userInfoGroups - @avatar = avatar - end + def initialize (id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, + deniedPermissions, descriptions, templates, avatar) + @id = id + @name = name + @email = email + @group = group + @reviewGroups = reviewGroups + @commentGroups = commentGroups + @favorite = favorite + @deniedPermissions = deniedPermissions + @descriptions = descriptions + @templates = templates + @userInfoGroups = userInfoGroups + @avatar = avatar + end end class Users - @@descr_user_1 = [ - "File author by default", - "Doesn’t belong to any group", - "Can review all the changes", - "Can perform all actions with comments", - "The file favorite state is undefined", - "Can create files from templates using data from the editor", - "Can see the information about all users", - "Has an avatar", - ]; + @@descr_user_1 = [ + "File author by default", + "Doesn’t belong to any group", + "Can review all the changes", + "Can perform all actions with comments", + "The file favorite state is undefined", + "Can create files from templates using data from the editor", + "Can see the information about all users", + "Has an avatar", + ]; - @@descr_user_2 = [ - "Belongs to Group2", - "Can review only his own changes or changes made by users with no group", - "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", - "This file is marked as favorite", - "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group", - "Has an avatar", - ]; + @@descr_user_2 = [ + "Belongs to Group2", + "Can review only his own changes or changes made by users with no group", + "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", + "This file is marked as favorite", + "Can create new files from the editor", + "Can see the information about users from Group2 and users who don’t belong to any group", + "Has an avatar", + ]; - @@descr_user_3 = [ - "Belongs to Group3", - "Can review changes made by Group2 users", - "Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users", - "This file isn’t marked as favorite", - "Can’t copy data from the file to clipboard", - "Can’t download the file", - "Can’t print the file", - "Can create new files from the editor", - "Can see the information about Group2 users", - ]; + @@descr_user_3 = [ + "Belongs to Group3", + "Can review changes made by Group2 users", + "Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users", + "This file isn’t marked as favorite", + "Can’t copy data from the file to clipboard", + "Can’t download the file", + "Can’t print the file", + "Can create new files from the editor", + "Can see the information about Group2 users", + ]; - @@descr_user_0 = [ - "The name is requested when the editor is opened", - "Doesn’t belong to any group", - "Can review all the changes", - "Can perform all actions with comments", - "The file favorite state is undefined", - "Can't mention others in comments", - "Can't create new files from the editor", - "Can’t see anyone’s information", - "Can't rename files from the editor", - "Can't view chat", - "Can't protect file", - "View file without collaboration" - ]; + @@descr_user_0 = [ + "The name is requested when the editor is opened", + "Doesn’t belong to any group", + "Can review all the changes", + "Can perform all actions with comments", + "The file favorite state is undefined", + "Can't mention others in comments", + "Can't create new files from the editor", + "Can’t see anyone’s information", + "Can't rename files from the editor", + "Can't view chat", + "Can't protect file", + "View file without collaboration" + ]; - @@users = [ - User.new("uid-1", "John Smith", "smith@example.com", - "", nil, {}, nil, - nil, [], @@descr_user_1, true, true), - User.new("uid-2", "Mark Pottato", "pottato@example.com", - "group-2", ["group-2", ""], { - :view => "", - :edit => ["group-2", ""], - :remove => ["group-2"] - }, - ["group-2", ""], - true, [], @@descr_user_2, false, true), - User.new("uid-3", "Hamish Mitchell", nil, - "group-3", ["group-2"], { - :view => ["group-3", "group-2"], - :edit => ["group-2"], - :remove => [] - }, - ["group-2"], - false, ["copy", "download", "print"], @@descr_user_3, false, false), - User.new("uid-0", nil, nil, - "", nil, {}, [], - nil, ["protect"], @@descr_user_0, false, false) - ] + @@users = [ + User.new("uid-1", "John Smith", "smith@example.com", + "", nil, {}, nil, + nil, [], @@descr_user_1, true, true), + User.new("uid-2", "Mark Pottato", "pottato@example.com", + "group-2", ["group-2", ""], { + :view => "", + :edit => ["group-2", ""], + :remove => ["group-2"] + }, + ["group-2", ""], + true, [], @@descr_user_2, false, true), + User.new("uid-3", "Hamish Mitchell", nil, + "group-3", ["group-2"], { + :view => ["group-3", "group-2"], + :edit => ["group-2"], + :remove => [] + }, + ["group-2"], + false, ["copy", "download", "print"], @@descr_user_3, false, false), + User.new("uid-0", nil, nil, + "", nil, {}, [], + nil, ["protect"], @@descr_user_0, false, false) + ] - class << self - def get_all_users() # get a list of all the users - @@users - end + class << self + def get_all_users() # get a list of all the users + @@users + end - def get_user(id) # get a user by id specified - for user in @@users do - if user.id.eql?(id) - return user - end - end - return @@users[0] + def get_user(id) # get a user by id specified + for user in @@users do + if user.id.eql?(id) + return user end + end + return @@users[0] + end - def get_users_for_mentions(id) # get a list of users with their names and emails for mentions - usersData = [] - for user in @@users do - if (!user.id.eql?(id) && user.name != nil && user.email != nil) - usersData.push({:name => user.name, :email => user.email}) - end - end - return usersData + def get_users_for_mentions(id) # get a list of users with their names and emails for mentions + usersData = [] + for user in @@users do + if (!user.id.eql?(id) && user.name != nil && user.email != nil) + usersData.push({:name => user.name, :email => user.email}) + end end + return usersData + end - def get_users_for_protect(id) # get a list of users with their id, names and emails for protect - users_data = [] - for user in @@users do - if (!user.id.eql?(id) && user.name != nil) - users_data.push({id: user.id, name: user.name, email: user.email}) - end - end - return users_data + def get_users_for_protect(id) # get a list of users with their id, names and emails for protect + users_data = [] + for user in @@users do + if (!user.id.eql?(id) && user.name != nil) + users_data.push({id: user.id, name: user.name, email: user.email}) + end end - + return users_data end + + end end From dbce9946e0903a2b8bddde5142a2dc052973833d Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:29:46 +0300 Subject: [PATCH 253/488] ruby: Layout/TrailingWhitespace correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- .../ruby/app/models/document_helper.rb | 2 +- .../ruby/app/models/file_model.rb | 20 +++++++++---------- .../ruby/app/models/track_helper.rb | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 0d97d3f92..28ad29bff 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -93,7 +93,7 @@ def convert end body = JSON.parse(file_data) - + file_name = File.basename(body["filename"]) lang = cookies[:ulang] ? cookies[:ulang] : "en" file_pass = body["filePass"] ? body["filePass"] : nil @@ -373,7 +373,7 @@ def rename def reference body = JSON.parse(request.body.read) fileName = "" - + if body.key?("referenceData") referenceData = body["referenceData"] diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 78558091d..36ff13178 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -306,7 +306,7 @@ def get_files_info(file_id) "contentLength" => "#{(File.size(directory)/ 1024.0).round(2)} KB", "pureContentLength" => File.size(directory), "title" => fileName, - "updated" => File.mtime(directory) + "updated" => File.mtime(directory) } if file_id == nil # if file id is undefined diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 8f2fb2c8f..feb2e8e6f 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -150,7 +150,7 @@ def get_config :lang => @lang ? @lang : "en", :callbackUrl => callback_url, # absolute URL to the document storage service :coEditing => editorsmode.eql?("view") && @user.id.eql?("uid-0") ? { - :mode => "strict", + :mode => "strict", :change => false } : nil, :createUrl => !@user.id.eql?("uid-0") ? create_url : nil, @@ -169,7 +169,7 @@ def get_config }, :customization => { # the parameters for the editor interface :about => true, # the About section display - :comments => true, + :comments => true, :feedback => true, # the Feedback & Support menu button display :forcesave => false, # adding the request for the forced file saving to the callback handler :submitForm => submitForm, # the Submit form button state @@ -323,7 +323,7 @@ def dataDocument if JwtHelper.is_enabled # check if a secret key to generate token exists or not compare_file["token"] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object end - + return compare_file end @@ -358,14 +358,14 @@ def get_users_info id: user_info.id, name: user_info.name, email: user_info.email, - group: user_info.group, - reviewGroups: user_info.reviewGroups, - commentGroups: user_info.commentGroups, - userInfoGroups: user_info.userInfoGroups, + group: user_info.group, + reviewGroups: user_info.reviewGroups, + commentGroups: user_info.commentGroups, + userInfoGroups: user_info.userInfoGroups, favorite: user_info.favorite, - deniedPermissions: user_info.deniedPermissions, - descriptions: user_info.descriptions, - templates: user_info.templates, + deniedPermissions: user_info.deniedPermissions, + descriptions: user_info.descriptions, + templates: user_info.templates, avatar: user_info.avatar } u["image"] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index c7b0f45b7..34c03eb35 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -178,7 +178,7 @@ def process_save(raw_file_data, file_name, user_address) end # file force saving process - def process_force_save(file_data, file_name, user_address) + def process_force_save(file_data, file_name, user_address) download_uri = file_data['url'] if download_uri.eql?(nil) saved = 1 @@ -237,7 +237,7 @@ def process_force_save(file_data, file_name, user_address) if is_submit_form uid = file_data['actions'][0]['userid'] - DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name + DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name end saved = 0 From f1a69218ae0cd93d6f911921766f8dfd01e3bd01 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:32:08 +0300 Subject: [PATCH 254/488] ruby: Layout/IndentationConsistency correct --- .../ruby/app/controllers/home_controller.rb | 10 +- .../ruby/app/models/document_helper.rb | 2 +- .../ruby/app/models/file_model.rb | 2 +- .../ruby/app/models/jwt_helper.rb | 2 +- .../ruby/app/models/track_helper.rb | 342 +++++++++--------- .../ruby/app/models/users.rb | 44 +-- 6 files changed, 201 insertions(+), 201 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 28ad29bff..7124d017c 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -204,9 +204,9 @@ def track if status == 1 # editing if file_data['actions'][0]['type'] == 0 # finished edit user = file_data['actions'][0]['userid'] # get the user id - if !file_data['users'].index(user) - json_data = TrackHelper.command_request("forcesave", file_data['key']) # call the forcesave command - end + if !file_data['users'].index(user) + json_data = TrackHelper.command_request("forcesave", file_data['key']) # call the forcesave command + end end end @@ -281,8 +281,8 @@ def download jwtHeader = HomeController.config_manager.jwt_header; if request.headers[jwtHeader] hdr = request.headers[jwtHeader] - hdr.slice!(0, "Bearer ".length) - token = JwtHelper.decode(hdr) + hdr.slice!(0, "Bearer ".length) + token = JwtHelper.decode(hdr) end if !token || token.eql?("") render plain: "JWT validation failed", :status => 403 diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 36ff13178..6bdcd805a 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -159,7 +159,7 @@ def get_correct_name(file_name, user_address) while File.exist?(storage_path(name, user_address)) # if the file with such a name already exists in this directory name = base_name + ' (' + index.to_s + ')' + ext.downcase # add an index after its base name - index = index + 1 + index = index + 1 end name diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index feb2e8e6f..6f8620e29 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -371,7 +371,7 @@ def get_users_info u["image"] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil users_info.push(u) end - return users_info + return users_info end end diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 1e0b22f62..872251da9 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -47,7 +47,7 @@ def decode(token) end # decoded = Array [ {"data"=>"test"}, # payload # {"alg"=>"HS256"} # header ] - return decoded[0].to_json # get json payload + return decoded[0].to_json # get json payload end end end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 34c03eb35..0cec3d263 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -36,40 +36,40 @@ class << self def read_body(request) body = request.body.read - if body == nil || body.empty? - return "" - end + if body == nil || body.empty? + return "" + end - file_data = JSON.parse(body) # parse file data + file_data = JSON.parse(body) # parse file data # check if a secret key to generate token exists or not - if JwtHelper.is_enabled && JwtHelper.use_for_request - inHeader = false - token = nil - jwtHeader = TrackHelper.config_manager.jwt_header; # get the authorization header from the config - if file_data["token"] # if the token is in the body - token = JwtHelper.decode(file_data["token"]) # decode a token into a payload object using a secret key - elsif request.headers[jwtHeader] # if the token is in the header - hdr = request.headers[jwtHeader] - hdr.slice!(0, "Bearer ".length) # get token from it (after Bearer prefix) - token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key - inHeader = true - else - raise "Expected JWT" # token missing error message - end - - if !token || token.eql?("") - raise "Invalid JWT signature" - end - - file_data = JSON.parse(token) - - if inHeader - file_data = file_data["payload"] - end + if JwtHelper.is_enabled && JwtHelper.use_for_request + inHeader = false + token = nil + jwtHeader = TrackHelper.config_manager.jwt_header; # get the authorization header from the config + if file_data["token"] # if the token is in the body + token = JwtHelper.decode(file_data["token"]) # decode a token into a payload object using a secret key + elsif request.headers[jwtHeader] # if the token is in the header + hdr = request.headers[jwtHeader] + hdr.slice!(0, "Bearer ".length) # get token from it (after Bearer prefix) + token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key + inHeader = true + else + raise "Expected JWT" # token missing error message end - return file_data + if !token || token.eql?("") + raise "Invalid JWT signature" + end + + file_data = JSON.parse(token) + + if inHeader + file_data = file_data["payload"] + end + end + + return file_data end def resolve_process_save_body(body) @@ -101,151 +101,151 @@ def resolve_process_save_body(body) def process_save(raw_file_data, file_name, user_address) file_data = resolve_process_save_body(raw_file_data) - download_uri = file_data['url'] - if download_uri.eql?(nil) - saved = 1 - return saved - end + download_uri = file_data['url'] + if download_uri.eql?(nil) + saved = 1 + return saved + end - new_file_name = file_name - download_ext = "."+file_data['filetype'] # get the extension of the downloaded file + new_file_name = file_name + download_ext = "."+file_data['filetype'] # get the extension of the downloaded file - cur_ext = File.extname(file_name).downcase # get current file extension + cur_ext = File.extname(file_name).downcase # get current file extension # convert downloaded file to the file with the current extension if these extensions aren't equal - unless cur_ext.eql?(download_ext) - key = ServiceConverter.generate_revision_id(download_uri) # get the document key - begin - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file - if new_file_uri == nil || new_file_uri.empty? - new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) # get the correct file name if it already exists - else - download_uri = new_file_uri - end - rescue StandardError => msg - new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) - end + unless cur_ext.eql?(download_ext) + key = ServiceConverter.generate_revision_id(download_uri) # get the document key + begin + percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file + if new_file_uri == nil || new_file_uri.empty? + new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) # get the correct file name if it already exists + else + download_uri = new_file_uri + end + rescue StandardError => msg + new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) end + end - saved = 1 - - data = download_file(download_uri) # download document file - if data.eql?(nil) - return saved - end + saved = 1 - begin - storage_path = DocumentHelper.storage_path(new_file_name, user_address) # get the storage directory of the new file + data = download_file(download_uri) # download document file + if data.eql?(nil) + return saved + end - hist_dir = DocumentHelper.history_dir(storage_path) # get the history directory of the new file - ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) # get the path to the specified file version + begin + storage_path = DocumentHelper.storage_path(new_file_name, user_address) # get the storage directory of the new file - FileUtils.mkdir_p(ver_dir) # create the version directory if doesn't exist + hist_dir = DocumentHelper.history_dir(storage_path) # get the history directory of the new file + ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) # get the path to the specified file version - FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) # move the file from the storage directory to the previous file version directory + FileUtils.mkdir_p(ver_dir) # create the version directory if doesn't exist - save_file(data, storage_path) # save the downloaded file to the storage directory + FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) # move the file from the storage directory to the previous file version directory - change_data = download_file(file_data["changesurl"]) # download file with document versions differences - save_file(change_data, File.join(ver_dir, "diff.zip")) # save file with document versions differences + save_file(data, storage_path) # save the downloaded file to the storage directory - hist_data = file_data["changeshistory"] - unless hist_data # if there are no changes in the history - hist_data = file_data["history"].to_json # write the original history information to the history data - end - if hist_data - File.open(File.join(ver_dir, "changes.json"), 'wb') do |file| # open the file with document changes - file.write(hist_data) # and write history data to this file - end - end + change_data = download_file(file_data["changesurl"]) # download file with document versions differences + save_file(change_data, File.join(ver_dir, "diff.zip")) # save file with document versions differences - # write the key value to the key.txt file - File.open(File.join(ver_dir, "key.txt"), 'wb') do |file| - file.write(file_data["key"]) + hist_data = file_data["changeshistory"] + unless hist_data # if there are no changes in the history + hist_data = file_data["history"].to_json # write the original history information to the history data + end + if hist_data + File.open(File.join(ver_dir, "changes.json"), 'wb') do |file| # open the file with document changes + file.write(hist_data) # and write history data to this file end + end - forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) # get the path to the forcesaved file - unless forcesave_path.eql?("") # if this path is empty - File.delete(forcesave_path) # remove it - end + # write the key value to the key.txt file + File.open(File.join(ver_dir, "key.txt"), 'wb') do |file| + file.write(file_data["key"]) + end - saved = 0 - rescue StandardError => msg - saved = 1 + forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) # get the path to the forcesaved file + unless forcesave_path.eql?("") # if this path is empty + File.delete(forcesave_path) # remove it end - saved + saved = 0 + rescue StandardError => msg + saved = 1 + end + + saved end # file force saving process def process_force_save(file_data, file_name, user_address) download_uri = file_data['url'] - if download_uri.eql?(nil) - saved = 1 - return saved - end + if download_uri.eql?(nil) + saved = 1 + return saved + end - download_ext = "."+file_data['filetype'] # get the extension of the downloaded file + download_ext = "."+file_data['filetype'] # get the extension of the downloaded file - cur_ext = File.extname(file_name).downcase # get current file extension + cur_ext = File.extname(file_name).downcase # get current file extension - new_file_name = false + new_file_name = false # convert downloaded file to the file with the current extension if these extensions aren't equal - unless cur_ext.eql?(download_ext) - key = ServiceConverter.generate_revision_id(download_uri) # get the document key - begin - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file - if new_file_uri == nil || new_file_uri.empty? - new_file_name = true - else - download_uri = new_file_uri - end - rescue StandardError => msg + unless cur_ext.eql?(download_ext) + key = ServiceConverter.generate_revision_id(download_uri) # get the document key + begin + percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file + if new_file_uri == nil || new_file_uri.empty? new_file_name = true - end + else + download_uri = new_file_uri + end + rescue StandardError => msg + new_file_name = true end + end - saved = 1 + saved = 1 - data = download_file(download_uri) # download document file - if data.eql?(nil) - return saved - end + data = download_file(download_uri) # download document file + if data.eql?(nil) + return saved + end - begin - is_submit_form = file_data["forcesavetype"].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) - - if is_submit_form - if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + download_ext, user_address) # get the correct file name if it already exists - else - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + cur_ext, user_address) - end - forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file + begin + is_submit_form = file_data["forcesavetype"].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) + + if is_submit_form + if new_file_name + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + download_ext, user_address) # get the correct file name if it already exists else - if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) - end - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) - if forcesave_path.eql?("") - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it - end + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + cur_ext, user_address) end - - save_file(data, forcesave_path) # save the downloaded file to the storage directory - - if is_submit_form - uid = file_data['actions'][0]['userid'] - DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name + forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file + else + if new_file_name + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) + end + forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) + if forcesave_path.eql?("") + forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it end + end - saved = 0 - rescue StandardError => msg - saved = 1 + save_file(data, forcesave_path) # save the downloaded file to the storage directory + + if is_submit_form + uid = file_data['actions'][0]['userid'] + DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name end - saved + saved = 0 + rescue StandardError => msg + saved = 1 + end + + saved end # send the command request @@ -256,61 +256,61 @@ def command_request(method, key, meta = nil) :key => key } - if (meta != nil) - payload.merge!({:meta => meta}) - end - - data = nil - begin + if (meta != nil) + payload.merge!({:meta => meta}) + end - uri = URI.parse(@@document_command_url) # parse the document command url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + data = nil + begin - DocumentHelper.verify_ssl(@@document_command_url, http) + uri = URI.parse(@@document_command_url) # parse the document command url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - req = Net::HTTP::Post.new(uri.request_uri) # create the post request - req.add_field("Content-Type", "application/json") # set headers + DocumentHelper.verify_ssl(@@document_command_url, http) - if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled - payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload - jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix - end + req = Net::HTTP::Post.new(uri.request_uri) # create the post request + req.add_field("Content-Type", "application/json") # set headers - req.body = payload.to_json # convert the payload object into the json format - res = http.request(req) # get the response - data = res.body # and take its body - rescue => ex - raise ex.message + if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled + payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload + jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header + req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix end - json_data = JSON.parse(data) # convert the response body into the json format - return json_data + req.body = payload.to_json # convert the payload object into the json format + res = http.request(req) # get the response + data = res.body # and take its body + rescue => ex + raise ex.message + end + + json_data = JSON.parse(data) # convert the response body into the json format + return json_data end # save file from the url def download_file(uristr) uri = URI.parse(uristr) # parse the url string - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - http.open_timeout = 5 + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + http.open_timeout = 5 - DocumentHelper.verify_ssl(uristr, http) + DocumentHelper.verify_ssl(uristr, http) - req = Net::HTTP::Get.new(uri) - res = http.request(req) # get the response + req = Net::HTTP::Get.new(uri) + res = http.request(req) # get the response - status_code = res.code - if status_code != '200' # checking status code - raise "Document editing service returned status: #{status_code}" - end + status_code = res.code + if status_code != '200' # checking status code + raise "Document editing service returned status: #{status_code}" + end - data = res.body # and take its body + data = res.body # and take its body - if data == nil - raise 'stream is null' - end + if data == nil + raise 'stream is null' + end - data + data end def save_file(data, path) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 471b6b382..e17136010 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -21,17 +21,17 @@ class User def initialize (id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates, avatar) @id = id - @name = name - @email = email - @group = group - @reviewGroups = reviewGroups - @commentGroups = commentGroups - @favorite = favorite - @deniedPermissions = deniedPermissions - @descriptions = descriptions - @templates = templates - @userInfoGroups = userInfoGroups - @avatar = avatar + @name = name + @email = email + @group = group + @reviewGroups = reviewGroups + @commentGroups = commentGroups + @favorite = favorite + @deniedPermissions = deniedPermissions + @descriptions = descriptions + @templates = templates + @userInfoGroups = userInfoGroups + @avatar = avatar end end @@ -120,27 +120,27 @@ def get_user(id) # get a user by id specified return user end end - return @@users[0] + return @@users[0] end def get_users_for_mentions(id) # get a list of users with their names and emails for mentions usersData = [] - for user in @@users do - if (!user.id.eql?(id) && user.name != nil && user.email != nil) - usersData.push({:name => user.name, :email => user.email}) - end + for user in @@users do + if (!user.id.eql?(id) && user.name != nil && user.email != nil) + usersData.push({:name => user.name, :email => user.email}) end - return usersData + end + return usersData end def get_users_for_protect(id) # get a list of users with their id, names and emails for protect users_data = [] - for user in @@users do - if (!user.id.eql?(id) && user.name != nil) - users_data.push({id: user.id, name: user.name, email: user.email}) - end + for user in @@users do + if (!user.id.eql?(id) && user.name != nil) + users_data.push({id: user.id, name: user.name, email: user.email}) end - return users_data + end + return users_data end end From b5585cf3db168c24ddcff4309fec42aba324006c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:33:31 +0300 Subject: [PATCH 255/488] ruby: Layout/LeadingCommentSpace correct --- .../ruby/app/controllers/home_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 7124d017c..40a62cc77 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -369,7 +369,7 @@ def rename render plain: '{ "result" : "' + JSON.dump(json_data) + '"}' end - #ReferenceData + # ReferenceData def reference body = JSON.parse(request.body.read) fileName = "" From f12fb576d83500fa3748b7b8b9db457db1585478 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:34:49 +0300 Subject: [PATCH 256/488] ruby: Layout/SpaceInsideHashLiteralBraces correct --- .../ruby/app/controllers/home_controller.rb | 2 +- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- web/documentserver-example/ruby/app/models/track_helper.rb | 2 +- web/documentserver-example/ruby/app/models/users.rb | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 40a62cc77..36796b8e7 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -426,7 +426,7 @@ def reference :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName, false) : nil, :referenceData => { :instanceId => DocumentHelper.get_server_url(false), - :fileKey => {:fileName => fileName,:userAddress => DocumentHelper.cur_user_host_address(nil)}.to_json + :fileKey => { :fileName => fileName,:userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json }, :path => fileName, :link => DocumentHelper.get_server_url(false) + '/editor?fileName=' + fileName diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 6f8620e29..60410b155 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -141,7 +141,7 @@ def get_config }, :referenceData => { :instanceId => DocumentHelper.get_server_url(false), - :fileKey => !@user.id.eql?("uid-0") ? {:fileName => @file_name,:userAddress => DocumentHelper.cur_user_host_address(nil)}.to_json : nil + :fileKey => !@user.id.eql?("uid-0") ? { :fileName => @file_name,:userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json : nil } }, :editorConfig => { diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 0cec3d263..dcaee067c 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -257,7 +257,7 @@ def command_request(method, key, meta = nil) } if (meta != nil) - payload.merge!({:meta => meta}) + payload.merge!({ :meta => meta }) end data = nil diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index e17136010..8c170ca4b 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -127,7 +127,7 @@ def get_users_for_mentions(id) # get a list of users with their names and emails usersData = [] for user in @@users do if (!user.id.eql?(id) && user.name != nil && user.email != nil) - usersData.push({:name => user.name, :email => user.email}) + usersData.push({ :name => user.name, :email => user.email }) end end return usersData @@ -137,7 +137,7 @@ def get_users_for_protect(id) # get a list of users with their id, names and em users_data = [] for user in @@users do if (!user.id.eql?(id) && user.name != nil) - users_data.push({id: user.id, name: user.name, email: user.email}) + users_data.push({ id: user.id, name: user.name, email: user.email }) end end return users_data From fde6a09f7522aafc4c63fa04fc095fa620d7ffc8 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:39:32 +0300 Subject: [PATCH 257/488] ruby: Layout/SpaceAfterComma correct --- .../ruby/app/controllers/home_controller.rb | 2 +- web/documentserver-example/ruby/app/models/document_helper.rb | 4 ++-- web/documentserver-example/ruby/app/models/file_model.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 36796b8e7..68868fde4 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -426,7 +426,7 @@ def reference :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName, false) : nil, :referenceData => { :instanceId => DocumentHelper.get_server_url(false), - :fileKey => { :fileName => fileName,:userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json + :fileKey => { :fileName => fileName, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json }, :path => fileName, :link => DocumentHelper.get_server_url(false) + '/editor?fileName=' + fileName diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 6bdcd805a..5eac98727 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -93,7 +93,7 @@ def forcesave_path(file_name, user_address, create) return "" end - directory = File.join(directory,"#{File.basename(file_name)}-hist") # get the path to the history of the given file + directory = File.join(directory, "#{File.basename(file_name)}-hist") # get the path to the history of the given file unless File.directory?(directory) if create FileUtils.mkdir_p(directory) # create history directory if it doesn't exist @@ -226,7 +226,7 @@ def get_file_uri(file_name, for_document_server) end # get history path url - def get_historypath_uri(file_name,version,file,is_serverUrl=true) + def get_historypath_uri(file_name, version, file, is_serverUrl=true) # for redirection to my link user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : "" uri = get_server_url(is_serverUrl) + '/downloadhistory/?fileName=' + ERB::Util.url_encode(file_name) + '&ver='+ version.to_s + '&file='+ ERB::Util.url_encode(file) + user_host diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 60410b155..efccde508 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -141,7 +141,7 @@ def get_config }, :referenceData => { :instanceId => DocumentHelper.get_server_url(false), - :fileKey => !@user.id.eql?("uid-0") ? { :fileName => @file_name,:userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json : nil + :fileKey => !@user.id.eql?("uid-0") ? { :fileName => @file_name, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json : nil } }, :editorConfig => { @@ -306,7 +306,7 @@ def get_insert_image insert_image["token"] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object end - return insert_image.to_json.tr("{", "").tr("}","") + return insert_image.to_json.tr("{", "").tr("}", "") end # get compared file information From ac3e0faba86a0d8da02f9c0159d2b2006e34cc80 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:40:44 +0300 Subject: [PATCH 258/488] ruby: Layout/MultilineOperationIndentation correct --- web/documentserver-example/ruby/app/format/format.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/format/format.rb b/web/documentserver-example/ruby/app/format/format.rb index 0cca61d83..59bb56ea1 100644 --- a/web/documentserver-example/ruby/app/format/format.rb +++ b/web/documentserver-example/ruby/app/format/format.rb @@ -76,7 +76,7 @@ def editable_extensions def editable all.filter do |format| format.actions.include?('edit') || - format.actions.include?('lossy-edit') + format.actions.include?('lossy-edit') end end From 64f66d4fa3220dc248024218231f3f49392d40a2 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:41:38 +0300 Subject: [PATCH 259/488] ruby: Layout/EmptyLinesAroundClassBody correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 2 -- web/documentserver-example/ruby/app/models/file_model.rb | 2 -- web/documentserver-example/ruby/app/models/jwt_helper.rb | 1 - .../ruby/app/models/service_converter.rb | 3 --- web/documentserver-example/ruby/app/models/track_helper.rb | 1 - web/documentserver-example/ruby/app/models/users.rb | 1 - 6 files changed, 10 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 5eac98727..294c7cd53 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -31,7 +31,6 @@ class << self @@base_url = nil class << self - def init (ip, url) @@remote_ip = ip @@base_url = url @@ -333,5 +332,4 @@ def verify_ssl(file_uri, http) end end end - end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index efccde508..a20ffc0f0 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -17,7 +17,6 @@ require_relative '../configuration/configuration' class FileModel - attr_accessor :file_name, :mode, :type, :user_ip, :lang, :user, :action_data, :direct_url attr_reader :config_manager @@ -384,5 +383,4 @@ def get_users_protect def is_enable_direct_url return @direct_url != nil && @direct_url == "true" end - end diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 872251da9..779cb7aa5 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -18,7 +18,6 @@ require_relative '../configuration/configuration' class JwtHelper - @jwt_secret = ConfigurationManager.new.jwt_secret @token_use_for_request = ConfigurationManager.new.jwt_use_for_request diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index ebb708237..5f6e3cafe 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -27,7 +27,6 @@ class << self @@document_converter_url = ServiceConverter.config_manager.document_server_converter_uri.to_s class << self - # get the url of the converted file def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_async, file_pass, lang = nil) from_ext = from_ext == nil ? File.extname(document_uri).downcase : from_ext # get the current document extension @@ -175,7 +174,5 @@ def get_response_data(json_data) return result_percent, response_uri, response_file_type end - end - end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index dcaee067c..90c1d9882 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -31,7 +31,6 @@ class << self @@document_command_url = TrackHelper.config_manager.document_server_command_uri.to_s class << self - # read the request body def read_body(request) body = request.body.read diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 8c170ca4b..f2e2b4fde 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -142,6 +142,5 @@ def get_users_for_protect(id) # get a list of users with their id, names and em end return users_data end - end end From 276f5c1e2090f893d26fd61e99982b758bd96f3e Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:42:27 +0300 Subject: [PATCH 260/488] ruby: Layout/SpaceAfterMethodName correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 2 +- web/documentserver-example/ruby/app/models/users.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 294c7cd53..48fcdb9ff 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -31,7 +31,7 @@ class << self @@base_url = nil class << self - def init (ip, url) + def init(ip, url) @@remote_ip = ip @@base_url = url end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index f2e2b4fde..3d801aae2 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -18,7 +18,7 @@ class User attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, :deniedPermissions, :descriptions, :templates, :avatar - def initialize (id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, + def initialize(id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates, avatar) @id = id @name = name From 118779aac1e44ff7163df39eae620b0552110230 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:47:02 +0300 Subject: [PATCH 261/488] ruby: Layout/SpaceInsideBlockBraces correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 48fcdb9ff..92d6ef41a 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -135,7 +135,7 @@ def get_file_version(hist_dir) end ver = 1 - Dir.foreach(hist_dir) {|e| # run through all the file versions + Dir.foreach(hist_dir) { |e| # run through all the file versions next if e.eql?(".") next if e.eql?("..") @@ -171,7 +171,7 @@ def get_stored_files(user_address) arr = []; if Dir.exist?(directory) - Dir.foreach(directory) {|e| # run through all the elements from the folder + Dir.foreach(directory) { |e| # run through all the elements from the folder next if e.eql?(".") next if e.eql?("..") next if File.directory?(File.join(directory, e)) # if the element is a directory, skip it From c0eb1c8a859543a4bd7b7da8aca8270374e13b32 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:48:06 +0300 Subject: [PATCH 262/488] ruby: Layout/SpaceAroundEqualsInParameterDefault correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 4 ++-- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 92d6ef41a..9da15f2d5 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -225,7 +225,7 @@ def get_file_uri(file_name, for_document_server) end # get history path url - def get_historypath_uri(file_name, version, file, is_serverUrl=true) + def get_historypath_uri(file_name, version, file, is_serverUrl = true) # for redirection to my link user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : "" uri = get_server_url(is_serverUrl) + '/downloadhistory/?fileName=' + ERB::Util.url_encode(file_name) + '&ver='+ version.to_s + '&file='+ ERB::Util.url_encode(file) + user_host @@ -252,7 +252,7 @@ def get_create_url(document_type) end # get url to download a file - def get_download_url(file_name, is_serverUrl=true) + def get_download_url(file_name, is_serverUrl = true) user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : "" get_server_url(is_serverUrl) + '/download?fileName=' + ERB::Util.url_encode(file_name) + user_host end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index a20ffc0f0..407c34bea 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -75,7 +75,7 @@ def create_url end # get url to download a file - def download_url(is_serverUrl=true) + def download_url(is_serverUrl = true) DocumentHelper.get_download_url(@file_name, is_serverUrl) end From b48efac604d5cd66a7e904cf27a7c534c32a4be6 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:48:40 +0300 Subject: [PATCH 263/488] ruby: Layout/SpaceAroundOperators correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 4 ++-- web/documentserver-example/ruby/app/models/track_helper.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 9da15f2d5..d708dacbf 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -228,7 +228,7 @@ def get_file_uri(file_name, for_document_server) def get_historypath_uri(file_name, version, file, is_serverUrl = true) # for redirection to my link user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : "" - uri = get_server_url(is_serverUrl) + '/downloadhistory/?fileName=' + ERB::Util.url_encode(file_name) + '&ver='+ version.to_s + '&file='+ ERB::Util.url_encode(file) + user_host + uri = get_server_url(is_serverUrl) + '/downloadhistory/?fileName=' + ERB::Util.url_encode(file_name) + '&ver=' + version.to_s + '&file=' + ERB::Util.url_encode(file) + user_host return uri end @@ -302,7 +302,7 @@ def get_files_info(file_id) info = { "version" => get_file_version(history_dir(directory)), "id" => ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory).to_s}"), - "contentLength" => "#{(File.size(directory)/ 1024.0).round(2)} KB", + "contentLength" => "#{(File.size(directory) / 1024.0).round(2)} KB", "pureContentLength" => File.size(directory), "title" => fileName, "updated" => File.mtime(directory) diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 90c1d9882..31c6627a2 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -107,7 +107,7 @@ def process_save(raw_file_data, file_name, user_address) end new_file_name = file_name - download_ext = "."+file_data['filetype'] # get the extension of the downloaded file + download_ext = "." + file_data['filetype'] # get the extension of the downloaded file cur_ext = File.extname(file_name).downcase # get current file extension @@ -184,7 +184,7 @@ def process_force_save(file_data, file_name, user_address) return saved end - download_ext = "."+file_data['filetype'] # get the extension of the downloaded file + download_ext = "." + file_data['filetype'] # get the extension of the downloaded file cur_ext = File.extname(file_name).downcase # get current file extension From 95de0fc2c7d15f81b23a14d0858688102f5b5fc7 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:50:09 +0300 Subject: [PATCH 264/488] ruby: Layout/CaseIndentation correct --- .../ruby/app/models/document_helper.rb | 12 ++++++------ .../ruby/app/models/service_converter.rb | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index d708dacbf..dc2abb911 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -260,11 +260,11 @@ def get_download_url(file_name, is_serverUrl = true) # get internal file extension by its type def get_internal_extension(file_type) case file_type - when 'word' # .docx for word type + when 'word' # .docx for word type ext = '.docx' - when 'cell' # .xlsx for cell type + when 'cell' # .xlsx for cell type ext = '.xlsx' - when 'slide' # .pptx for slide type + when 'slide' # .pptx for slide type ext = '.pptx' else ext = '.docx' # the default value is .docx @@ -277,11 +277,11 @@ def get_internal_extension(file_type) def get_template_image_url(file_type) path = get_server_url(true) + "/assets/" case file_type - when 'word' # for word type + when 'word' # for word type full_path = path + 'file_docx.svg' - when 'cell' # .xlsx for cell type + when 'cell' # .xlsx for cell type full_path = path + 'file_xlsx.svg' - when 'slide' # .pptx for slide type + when 'slide' # .pptx for slide type full_path = path + 'file_pptx.svg' else full_path = path + 'file_docx.svg' # the default value is .docx diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 5f6e3cafe..cbf966bd4 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -107,23 +107,23 @@ def process_convert_service_responce_error(error_code) # add an error message to the error message template depending on the error code case error_code - when -8 + when -8 error_message = 'Error occurred in the ConvertService.ashx: Error document VKey' - when -7 + when -7 error_message = 'Error occurred in the ConvertService.ashx: Error document request' - when -6 + when -6 error_message = 'Error occurred in the ConvertService.ashx: Error database' - when -5 + when -5 error_message = 'Error occurred in the ConvertService.ashx: Incorrect password' - when -4 + when -4 error_message = 'Error occurred in the ConvertService.ashx: Error download error' - when -3 + when -3 error_message = 'Error occurred in the ConvertService.ashx: Error convertation error' - when -2 + when -2 error_message = 'Error occurred in the ConvertService.ashx: Error convertation timeout' - when -1 + when -1 error_message = 'Error occurred in the ConvertService.ashx: Error convertation unknown' - when 0 + when 0 # public const int c_nErrorNo = 0 else error_message = 'ErrorCode = ' + error_code.to_s # default value for the error message From 831e59b3901aa73d5a22b3d738aef43773249a3e Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:50:53 +0300 Subject: [PATCH 265/488] ruby: Layout/EmptyLineBetweenDefs correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index dc2abb911..8fc44dd82 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -324,6 +324,7 @@ def get_files_info(file_id) return result end end + # enable ignore certificate def verify_ssl(file_uri, http) if file_uri.start_with?('https') && DocumentHelper.config_manager.ssl_verify_peer_mode_enabled From 8ddbb6ba18e32834271b530c82acdaf3ad81e454 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:51:36 +0300 Subject: [PATCH 266/488] ruby: Layout/EmptyLinesAroundBeginBody correct --- web/documentserver-example/ruby/app/models/service_converter.rb | 1 - web/documentserver-example/ruby/app/models/track_helper.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index cbf966bd4..aee29c3cb 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -52,7 +52,6 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ data = nil begin - uri = URI.parse(@@document_converter_url) # create the request url http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 31c6627a2..8f652c0ae 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -261,7 +261,6 @@ def command_request(method, key, meta = nil) data = nil begin - uri = URI.parse(@@document_command_url) # parse the document command url http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server From d8b0bd55cfff3171f6415c5e06cd9ba423432cb6 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:52:07 +0300 Subject: [PATCH 267/488] ruby: Layout/FirstHashElementIndentation correct --- web/documentserver-example/ruby/app/models/track_helper.rb | 2 +- web/documentserver-example/ruby/app/models/users.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 8f652c0ae..1abf4d729 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -251,7 +251,7 @@ def process_force_save(file_data, file_name, user_address) def command_request(method, key, meta = nil) # create a payload object with the method and key payload = { - :c => method, + :c => method, :key => key } diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 3d801aae2..c4c003d85 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -90,7 +90,7 @@ class Users nil, [], @@descr_user_1, true, true), User.new("uid-2", "Mark Pottato", "pottato@example.com", "group-2", ["group-2", ""], { - :view => "", + :view => "", :edit => ["group-2", ""], :remove => ["group-2"] }, @@ -98,7 +98,7 @@ class Users true, [], @@descr_user_2, false, true), User.new("uid-3", "Hamish Mitchell", nil, "group-3", ["group-2"], { - :view => ["group-3", "group-2"], + :view => ["group-3", "group-2"], :edit => ["group-2"], :remove => [] }, From dcf78b13f2f63df863038e65fb1aab2fd49611c1 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:52:39 +0300 Subject: [PATCH 268/488] ruby: Layout/ArgumentAlignment correct --- .../ruby/app/models/users.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index c4c003d85..84e3d3f23 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -16,7 +16,7 @@ class User attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, - :deniedPermissions, :descriptions, :templates, :avatar + :deniedPermissions, :descriptions, :templates, :avatar def initialize(id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates, avatar) @@ -86,27 +86,27 @@ class Users @@users = [ User.new("uid-1", "John Smith", "smith@example.com", - "", nil, {}, nil, - nil, [], @@descr_user_1, true, true), + "", nil, {}, nil, + nil, [], @@descr_user_1, true, true), User.new("uid-2", "Mark Pottato", "pottato@example.com", - "group-2", ["group-2", ""], { + "group-2", ["group-2", ""], { :view => "", :edit => ["group-2", ""], :remove => ["group-2"] }, ["group-2", ""], - true, [], @@descr_user_2, false, true), + true, [], @@descr_user_2, false, true), User.new("uid-3", "Hamish Mitchell", nil, - "group-3", ["group-2"], { + "group-3", ["group-2"], { :view => ["group-3", "group-2"], :edit => ["group-2"], :remove => [] }, ["group-2"], - false, ["copy", "download", "print"], @@descr_user_3, false, false), + false, ["copy", "download", "print"], @@descr_user_3, false, false), User.new("uid-0", nil, nil, - "", nil, {}, [], - nil, ["protect"], @@descr_user_0, false, false) + "", nil, {}, [], + nil, ["protect"], @@descr_user_0, false, false) ] class << self From b6e71e42c1fbaeef7251872640c2dd08bc5db249 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:53:08 +0300 Subject: [PATCH 269/488] ruby: Layout/ParameterAlignment correct --- web/documentserver-example/ruby/app/models/users.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 84e3d3f23..01a9b27b6 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -19,7 +19,7 @@ class User :deniedPermissions, :descriptions, :templates, :avatar def initialize(id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, - deniedPermissions, descriptions, templates, avatar) + deniedPermissions, descriptions, templates, avatar) @id = id @name = name @email = email From 2d3fc7228300ef823939b07028723909d9b201cc Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 13:53:42 +0300 Subject: [PATCH 270/488] ruby: Layout/FirstArrayElementIndentation correct --- .../ruby/app/models/users.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 01a9b27b6..a7c367ba9 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -37,7 +37,7 @@ def initialize(id, name, email, group, reviewGroups, commentGroups, userInfoGrou class Users @@descr_user_1 = [ - "File author by default", + "File author by default", "Doesn’t belong to any group", "Can review all the changes", "Can perform all actions with comments", @@ -48,7 +48,7 @@ class Users ]; @@descr_user_2 = [ - "Belongs to Group2", + "Belongs to Group2", "Can review only his own changes or changes made by users with no group", "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", "This file is marked as favorite", @@ -58,7 +58,7 @@ class Users ]; @@descr_user_3 = [ - "Belongs to Group3", + "Belongs to Group3", "Can review changes made by Group2 users", "Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users", "This file isn’t marked as favorite", @@ -70,7 +70,7 @@ class Users ]; @@descr_user_0 = [ - "The name is requested when the editor is opened", + "The name is requested when the editor is opened", "Doesn’t belong to any group", "Can review all the changes", "Can perform all actions with comments", @@ -85,9 +85,9 @@ class Users ]; @@users = [ - User.new("uid-1", "John Smith", "smith@example.com", - "", nil, {}, nil, - nil, [], @@descr_user_1, true, true), + User.new("uid-1", "John Smith", "smith@example.com", + "", nil, {}, nil, + nil, [], @@descr_user_1, true, true), User.new("uid-2", "Mark Pottato", "pottato@example.com", "group-2", ["group-2", ""], { :view => "", From 63c04c85b0608294a835c938828ed41c749495cd Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 14:01:39 +0300 Subject: [PATCH 271/488] ruby: Lint/ParenthesesAsGroupedExpression correct --- .../ruby/app/controllers/home_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 68868fde4..86bc277eb 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -101,7 +101,7 @@ def convert extension = File.extname(file_name).downcase internal_extension = 'ooxml' - if DocumentHelper.convert_exts.include? (extension) # check if the file with such an extension can be converted + if DocumentHelper.convert_exts.include?(extension) # check if the file with such an extension can be converted key = ServiceConverter.generate_revision_id(file_uri) # generate document key percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(file_uri, extension.delete('.'), internal_extension.delete('.'), key, true, file_pass, lang) # get the url and file type of the converted file and the conversion percentage From de32be3945590b7d12fc2ebccae68caac9dee74a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 14:30:45 +0300 Subject: [PATCH 272/488] ruby: Lint/RedundantStringCoercion correct --- .../ruby/app/controllers/home_controller.rb | 2 +- web/documentserver-example/ruby/app/models/document_helper.rb | 2 +- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 86bc277eb..4c8f38f62 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -421,7 +421,7 @@ def reference data = { :fileType => File.extname(fileName).downcase.delete("."), - :key => ServiceConverter.generate_revision_id("#{DocumentHelper.cur_user_host_address(nil) + '/' + fileName}.#{File.mtime(DocumentHelper.storage_path(fileName, nil)).to_s}"), + :key => ServiceConverter.generate_revision_id("#{DocumentHelper.cur_user_host_address(nil) + '/' + fileName}.#{File.mtime(DocumentHelper.storage_path(fileName, nil))}"), :url => DocumentHelper.get_download_url(fileName), :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName, false) : nil, :referenceData => { diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 8fc44dd82..7c45357eb 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -301,7 +301,7 @@ def get_files_info(file_id) # write file parameters to the info object info = { "version" => get_file_version(history_dir(directory)), - "id" => ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory).to_s}"), + "id" => ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), "contentLength" => "#{(File.size(directory) / 1024.0).round(2)} KB", "pureContentLength" => File.size(directory), "title" => fileName, diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 407c34bea..e2c4ec5de 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -61,7 +61,7 @@ def document_type def key uri = DocumentHelper.cur_user_host_address(nil) + '/' + @file_name # get current user host address stat = File.mtime(DocumentHelper.storage_path(@file_name, nil)) # get the modification time of the given file - return ServiceConverter.generate_revision_id("#{uri}.#{stat.to_s}") + return ServiceConverter.generate_revision_id("#{uri}.#{stat}") end # get callback url From 5e29215a11d02d6e7ebf66e937b7a6402e4e7954 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 14:38:10 +0300 Subject: [PATCH 273/488] ruby: Style/StringLiterals correct --- web/documentserver-example/ruby/Gemfile | 46 ++--- .../ruby/app/controllers/home_controller.rb | 72 ++++---- .../ruby/app/models/document_helper.rb | 38 ++-- .../ruby/app/models/file_model.rb | 174 +++++++++--------- .../ruby/app/models/jwt_helper.rb | 2 +- .../ruby/app/models/service_converter.rb | 6 +- .../ruby/app/models/track_helper.rb | 50 ++--- .../ruby/app/models/users.rb | 96 +++++----- 8 files changed, 242 insertions(+), 242 deletions(-) diff --git a/web/documentserver-example/ruby/Gemfile b/web/documentserver-example/ruby/Gemfile index f826fb4c4..43adf6cd6 100644 --- a/web/documentserver-example/ruby/Gemfile +++ b/web/documentserver-example/ruby/Gemfile @@ -1,25 +1,25 @@ -source "https://rubygems.org" +source 'https://rubygems.org' -gem "byebug", "~> 11.1", :groups => [:development, :test] -gem "coffee-rails", "~> 5.0" -gem "dalli", "~> 3.2", :group => :development -gem "jbuilder", "~> 2.11" -gem "jquery-rails", "~> 4.5" -gem "jwt", "~> 2.7" -gem "mimemagic", github: "mimemagicrb/mimemagic", ref: "01f92d86d15d85cfd0f20dabd025dcbd36a8a60f" -gem "rack-cors", "~> 2.0" -gem "rails", "~> 7.0.8" -gem "rubocop", "~> 1.52", :group => :development -gem "sass-rails", "~> 6.0" -gem "sdoc", "~> 2.6", :group => :doc -gem "sorbet-runtime", "~> 0.5.10871" -gem "test-unit", "~> 3.6", :groups => [:development, :test] -gem "turbolinks", "~> 5.2" -gem "tzinfo-data", "~> 1.2023" -gem "uglifier", "~> 4.2" -gem "uuid", "~> 2.3" -gem "web-console", "~> 4.2", :groups => [:development, :test] -gem "webrick", "~> 1.8" +gem 'byebug', '~> 11.1', :groups => [:development, :test] +gem 'coffee-rails', '~> 5.0' +gem 'dalli', '~> 3.2', :group => :development +gem 'jbuilder', '~> 2.11' +gem 'jquery-rails', '~> 4.5' +gem 'jwt', '~> 2.7' +gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f' +gem 'rack-cors', '~> 2.0' +gem 'rails', '~> 7.0.8' +gem 'rubocop', '~> 1.52', :group => :development +gem 'sass-rails', '~> 6.0' +gem 'sdoc', '~> 2.6', :group => :doc +gem 'sorbet-runtime', '~> 0.5.10871' +gem 'test-unit', '~> 3.6', :groups => [:development, :test] +gem 'turbolinks', '~> 5.2' +gem 'tzinfo-data', '~> 1.2023' +gem 'uglifier', '~> 4.2' +gem 'uuid', '~> 2.3' +gem 'web-console', '~> 4.2', :groups => [:development, :test] +gem 'webrick', '~> 1.8' # Unfortunately, Sorbet only supports Darwin and Linux-based systems. # Additionally, it doesn't support Linux on ARM64, which may be used in a Docker @@ -28,6 +28,6 @@ gem "webrick", "~> 1.8" # https://github.com/sorbet/sorbet/issues/4011 # https://github.com/sorbet/sorbet/issues/4119 install_if -> { RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /x86_64/ } do - gem "sorbet", "~> 0.5.10871", :group => :development - gem "tapioca", "~> 0.11.6", :group => :development + gem 'sorbet', '~> 0.5.10871', :group => :development + gem 'tapioca', '~> 0.11.6', :group => :development end diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 4c8f38f62..b968b45bb 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -89,14 +89,14 @@ def convert begin file_data = request.body.read if file_data == nil || file_data.empty? - return "" + return '' end body = JSON.parse(file_data) - file_name = File.basename(body["filename"]) - lang = cookies[:ulang] ? cookies[:ulang] : "en" - file_pass = body["filePass"] ? body["filePass"] : nil + file_name = File.basename(body['filename']) + lang = cookies[:ulang] ? cookies[:ulang] : 'en' + file_pass = body['filePass'] ? body['filePass'] : nil file_uri = DocumentHelper.get_download_url(file_name) extension = File.extname(file_name).downcase internal_extension = 'ooxml' @@ -112,7 +112,7 @@ def convert end # get the correct file name if such a name already exists - correct_name = DocumentHelper.get_correct_name(File.basename(file_name, extension) + "." + new_file_type, nil) + correct_name = DocumentHelper.get_correct_name(File.basename(file_name, extension) + '.' + new_file_type, nil) uri = URI.parse(new_file_uri) # create the request url http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server @@ -162,18 +162,18 @@ def downloadhistory jwtHeader = HomeController.config_manager.jwt_header; if request.headers[jwtHeader] hdr = request.headers[jwtHeader] - hdr.slice!(0, "Bearer ".length) + hdr.slice!(0, 'Bearer '.length) token = JwtHelper.decode(hdr) - if !token || token.eql?("") - render plain: "JWT validation failed", :status => 403 + if !token || token.eql?('') + render plain: 'JWT validation failed', :status => 403 return end else - render plain: "JWT validation failed", :status => 403 + render plain: 'JWT validation failed', :status => 403 return end end - hist_path = DocumentHelper.storage_path(file_name, user_address) + "-hist" # or to the original document + hist_path = DocumentHelper.storage_path(file_name, user_address) + '-hist' # or to the original document file_path = File.join(hist_path, version, file) @@ -205,7 +205,7 @@ def track if file_data['actions'][0]['type'] == 0 # finished edit user = file_data['actions'][0]['userid'] # get the user id if !file_data['users'].index(user) - json_data = TrackHelper.command_request("forcesave", file_data['key']) # call the forcesave command + json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command end end end @@ -259,7 +259,7 @@ def files # downloading a csv file def csv - file_name = "csv.csv" + file_name = 'csv.csv' csvPath = Rails.root.join('assets', 'document-templates', 'sample', file_name) # add headers to the response to specify the page parameters @@ -281,17 +281,17 @@ def download jwtHeader = HomeController.config_manager.jwt_header; if request.headers[jwtHeader] hdr = request.headers[jwtHeader] - hdr.slice!(0, "Bearer ".length) + hdr.slice!(0, 'Bearer '.length) token = JwtHelper.decode(hdr) end - if !token || token.eql?("") - render plain: "JWT validation failed", :status => 403 + if !token || token.eql?('') + render plain: 'JWT validation failed', :status => 403 return end end file_path = DocumentHelper.forcesave_path(file_name, user_address, false) # get the path to the force saved document version - if file_path.eql?("") + if file_path.eql?('') file_path = DocumentHelper.storage_path(file_name, user_address) # or to the original document end @@ -310,8 +310,8 @@ def download def saveas begin body = JSON.parse(request.body.read) - file_url = body["url"] - title = body["title"] + file_url = body['url'] + title = body['title'] file_name = DocumentHelper.get_correct_name(title, nil) extension = File.extname(file_name).downcase all_exts = DocumentHelper.convert_exts + DocumentHelper.edited_exts + DocumentHelper.viewed_exts + DocumentHelper.fill_forms_exts @@ -352,10 +352,10 @@ def saveas # Rename... def rename body = JSON.parse(request.body.read) - dockey = body["dockey"] - newfilename = body["newfilename"] + dockey = body['dockey'] + newfilename = body['newfilename'] - orig_ext = '.' + body["ext"] + orig_ext = '.' + body['ext'] cur_ext = File.extname(newfilename).downcase if orig_ext != cur_ext newfilename += orig_ext @@ -365,30 +365,30 @@ def rename :title => newfilename } - json_data = TrackHelper.command_request("meta", dockey, meta) + json_data = TrackHelper.command_request('meta', dockey, meta) render plain: '{ "result" : "' + JSON.dump(json_data) + '"}' end # ReferenceData def reference body = JSON.parse(request.body.read) - fileName = "" + fileName = '' - if body.key?("referenceData") - referenceData = body["referenceData"] - instanceId = referenceData["instanceId"] + if body.key?('referenceData') + referenceData = body['referenceData'] + instanceId = referenceData['instanceId'] if instanceId == DocumentHelper.get_server_url(false) - fileKey = JSON.parse(referenceData["fileKey"]) - userAddress = fileKey["userAddress"] + fileKey = JSON.parse(referenceData['fileKey']) + userAddress = fileKey['userAddress'] if userAddress == DocumentHelper.cur_user_host_address(nil) - fileName = fileKey["fileName"] + fileName = fileKey['fileName'] end end end - link = body["link"] - if fileName.empty? and body.key?("link") + link = body['link'] + if fileName.empty? and body.key?('link') if !link.include?(DocumentHelper.get_server_url(false)) data = { url: link, @@ -407,8 +407,8 @@ def reference end end - if fileName.empty? and body.key?("path") - path = File.basename(body["path"]) + if fileName.empty? and body.key?('path') + path = File.basename(body['path']) if File.exist?(DocumentHelper.storage_path(path, nil)) fileName = path end @@ -420,10 +420,10 @@ def reference end data = { - :fileType => File.extname(fileName).downcase.delete("."), + :fileType => File.extname(fileName).downcase.delete('.'), :key => ServiceConverter.generate_revision_id("#{DocumentHelper.cur_user_host_address(nil) + '/' + fileName}.#{File.mtime(DocumentHelper.storage_path(fileName, nil))}"), :url => DocumentHelper.get_download_url(fileName), - :directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName, false) : nil, + :directUrl => body['directUrl'] ? DocumentHelper.get_download_url(fileName, false) : nil, :referenceData => { :instanceId => DocumentHelper.get_server_url(false), :fileKey => { :fileName => fileName, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json @@ -433,7 +433,7 @@ def reference } if JwtHelper.is_enabled - data["token"] = JwtHelper.encode(data) + data['token'] = JwtHelper.encode(data) end render plain: data.to_json diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 7c45357eb..445deddd6 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -89,7 +89,7 @@ def forcesave_path(file_name, user_address, create) # the directory with host address doesn't exist unless File.directory?(directory) - return "" + return '' end directory = File.join(directory, "#{File.basename(file_name)}-hist") # get the path to the history of the given file @@ -97,14 +97,14 @@ def forcesave_path(file_name, user_address, create) if create FileUtils.mkdir_p(directory) # create history directory if it doesn't exist else - return "" # the history directory doesn't exist and we are not supposed to create it + return '' # the history directory doesn't exist and we are not supposed to create it end end directory = File.join(directory, File.basename(file_name)) # get the path to the given file unless File.file?(directory) if !create - return "" + return '' end end @@ -136,8 +136,8 @@ def get_file_version(hist_dir) ver = 1 Dir.foreach(hist_dir) { |e| # run through all the file versions - next if e.eql?(".") - next if e.eql?("..") + next if e.eql?('.') + next if e.eql?('..') if File.directory?(File.join(hist_dir, e)) ver += 1 # and count them @@ -172,8 +172,8 @@ def get_stored_files(user_address) if Dir.exist?(directory) Dir.foreach(directory) { |e| # run through all the elements from the folder - next if e.eql?(".") - next if e.eql?("..") + next if e.eql?('.') + next if e.eql?('..') next if File.directory?(File.join(directory, e)) # if the element is a directory, skip it arr.push(e) # push the file to the array @@ -195,7 +195,7 @@ def create_meta(file_name, uid, uname, user_address) } # write file meta information to the createdInfo.json file - File.open(File.join(hist_dir, "createdInfo.json"), 'wb') do |file| + File.open(File.join(hist_dir, 'createdInfo.json'), 'wb') do |file| file.write(json.to_json) end end @@ -227,7 +227,7 @@ def get_file_uri(file_name, for_document_server) # get history path url def get_historypath_uri(file_name, version, file, is_serverUrl = true) # for redirection to my link - user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : "" + user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : '' uri = get_server_url(is_serverUrl) + '/downloadhistory/?fileName=' + ERB::Util.url_encode(file_name) + '&ver=' + version.to_s + '&file=' + ERB::Util.url_encode(file) + user_host return uri end @@ -253,7 +253,7 @@ def get_create_url(document_type) # get url to download a file def get_download_url(file_name, is_serverUrl = true) - user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : "" + user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : '' get_server_url(is_serverUrl) + '/download?fileName=' + ERB::Util.url_encode(file_name) + user_host end @@ -275,7 +275,7 @@ def get_internal_extension(file_type) # get image url for templates def get_template_image_url(file_type) - path = get_server_url(true) + "/assets/" + path = get_server_url(true) + '/assets/' case file_type when 'word' # for word type full_path = path + 'file_docx.svg' @@ -300,18 +300,18 @@ def get_files_info(file_id) # write file parameters to the info object info = { - "version" => get_file_version(history_dir(directory)), - "id" => ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), - "contentLength" => "#{(File.size(directory) / 1024.0).round(2)} KB", - "pureContentLength" => File.size(directory), - "title" => fileName, - "updated" => File.mtime(directory) + 'version' => get_file_version(history_dir(directory)), + 'id' => ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), + 'contentLength' => "#{(File.size(directory) / 1024.0).round(2)} KB", + 'pureContentLength' => File.size(directory), + 'title' => fileName, + 'updated' => File.mtime(directory) } if file_id == nil # if file id is undefined result.push(info) # push info object to the response array else # if file id is defined - if file_id.eql?(info["id"]) # and it is equal to the document key value + if file_id.eql?(info['id']) # and it is equal to the document key value result.push(info) # response object will be equal to the info object return result end @@ -319,7 +319,7 @@ def get_files_info(file_id) end if file_id != nil - return "\"File not found\"" + return '"File not found"' else return result end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index e2c4ec5de..d0b1e531b 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -34,7 +34,7 @@ def initialize(attributes = {}) end def type - @type ? @type : "desktop" # the default platform type is desktop + @type ? @type : 'desktop' # the default platform type is desktop end # get file extension from its name @@ -49,7 +49,7 @@ def file_uri # get file uri for document server def file_uri_user - @config_manager.storage_path.absolute? ? download_url + "&dmode=emb" : DocumentHelper.get_file_uri(@file_name, false) + @config_manager.storage_path.absolute? ? download_url + '&dmode=emb' : DocumentHelper.get_file_uri(@file_name, false) end # get document type from its name (word, cell or slide) @@ -86,25 +86,25 @@ def cur_user_host_address # get config parameters def get_config - editorsmode = @mode ? @mode : "edit" # mode: view/edit/review/comment/fillForms/embedded + editorsmode = @mode ? @mode : 'edit' # mode: view/edit/review/comment/fillForms/embedded canEdit = DocumentHelper.edited_exts.include?(file_ext) # check if the document can be edited - if (!canEdit && editorsmode.eql?("edit") || editorsmode.eql?("fillForms")) && DocumentHelper.fill_forms_exts.include?(file_ext) - editorsmode = "fillForms" + if (!canEdit && editorsmode.eql?('edit') || editorsmode.eql?('fillForms')) && DocumentHelper.fill_forms_exts.include?(file_ext) + editorsmode = 'fillForms' canEdit = true end - submitForm = editorsmode.eql?("fillForms") && @user.id.eql?("uid-1") && false # the Submit form button state - mode = canEdit && !editorsmode.eql?("view") ? "edit" : "view" + submitForm = editorsmode.eql?('fillForms') && @user.id.eql?('uid-1') && false # the Submit form button state + mode = canEdit && !editorsmode.eql?('view') ? 'edit' : 'view' templatesImageUrl = DocumentHelper.get_template_image_url(document_type) # templates image url in the "From Template" section templates = [ { - :image => "", - :title => "Blank", + :image => '', + :title => 'Blank', :url => create_url }, { :image => templatesImageUrl, - :title => "With sample content", - :url => create_url + "&sample=true" + :title => 'With sample content', + :url => create_url + '&sample=true' } ] @@ -114,48 +114,48 @@ def get_config :document => { :title => @file_name, :url => download_url, - :directUrl => is_enable_direct_url ? download_url(false) : "", - :fileType => file_ext.delete("."), + :directUrl => is_enable_direct_url ? download_url(false) : '', + :fileType => file_ext.delete('.'), :key => key, :info => { - :owner => "Me", + :owner => 'Me', :uploaded => Time.now.to_s, :favorite => @user.favorite }, :permissions => { # the permission for the document to be edited and downloaded or not - :comment => !editorsmode.eql?("view") && !editorsmode.eql?("fillForms") && !editorsmode.eql?("embedded") && !editorsmode.eql?("blockcontent"), - :copy => !@user.deniedPermissions.include?("copy"), - :download => !@user.deniedPermissions.include?("download"), - :edit => canEdit && (editorsmode.eql?("edit") || editorsmode.eql?("view") || editorsmode.eql?("filter") || editorsmode.eql?("blockcontent")), - :print => !@user.deniedPermissions.include?("print"), - :fillForms => !editorsmode.eql?("view") && !editorsmode.eql?("comment") && !editorsmode.eql?("embedded") && !editorsmode.eql?("blockcontent"), - :modifyFilter => !editorsmode.eql?("filter"), - :modifyContentControl => !editorsmode.eql?("blockcontent"), - :review => canEdit && (editorsmode.eql?("edit") || editorsmode.eql?("review")), - :chat => !@user.id.eql?("uid-0"), + :comment => !editorsmode.eql?('view') && !editorsmode.eql?('fillForms') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'), + :copy => !@user.deniedPermissions.include?('copy'), + :download => !@user.deniedPermissions.include?('download'), + :edit => canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('view') || editorsmode.eql?('filter') || editorsmode.eql?('blockcontent')), + :print => !@user.deniedPermissions.include?('print'), + :fillForms => !editorsmode.eql?('view') && !editorsmode.eql?('comment') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'), + :modifyFilter => !editorsmode.eql?('filter'), + :modifyContentControl => !editorsmode.eql?('blockcontent'), + :review => canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('review')), + :chat => !@user.id.eql?('uid-0'), :reviewGroups => @user.reviewGroups, :commentGroups => @user.commentGroups, :userInfoGroups => @user.userInfoGroups, - :protect => !@user.deniedPermissions.include?("protect") + :protect => !@user.deniedPermissions.include?('protect') }, :referenceData => { :instanceId => DocumentHelper.get_server_url(false), - :fileKey => !@user.id.eql?("uid-0") ? { :fileName => @file_name, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json : nil + :fileKey => !@user.id.eql?('uid-0') ? { :fileName => @file_name, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json : nil } }, :editorConfig => { :actionLink => @action_data ? JSON.parse(@action_data) : nil, :mode => mode, - :lang => @lang ? @lang : "en", + :lang => @lang ? @lang : 'en', :callbackUrl => callback_url, # absolute URL to the document storage service - :coEditing => editorsmode.eql?("view") && @user.id.eql?("uid-0") ? { - :mode => "strict", + :coEditing => editorsmode.eql?('view') && @user.id.eql?('uid-0') ? { + :mode => 'strict', :change => false } : nil, - :createUrl => !@user.id.eql?("uid-0") ? create_url : nil, + :createUrl => !@user.id.eql?('uid-0') ? create_url : nil, :templates => @user.templates ? templates : nil, :user => { # the user currently viewing or editing the document - :id => !@user.id.eql?("uid-0") ? @user.id : nil, + :id => !@user.id.eql?('uid-0') ? @user.id : nil, :name => @user.name, :group => @user.group, :image => @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil @@ -164,7 +164,7 @@ def get_config :saveUrl => download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer :embedUrl => download_url(false), # the absolute URL to the document serving as a source file for the document embedded into the web page :shareUrl => download_url(false), # the absolute URL that will allow other users to share this document - :toolbarDocked => "top" # the place for the embedded viewer toolbar (top or bottom) + :toolbarDocked => 'top' # the place for the embedded viewer toolbar (top or bottom) }, :customization => { # the parameters for the editor interface :about => true, # the About section display @@ -180,7 +180,7 @@ def get_config } if JwtHelper.is_enabled # check if a secret key to generate token exists or not - config["token"] = JwtHelper.encode(config) # encode a payload object into a token and write it to the config + config['token'] = JwtHelper.encode(config) # encode a payload object into a token and write it to the config end return config @@ -208,70 +208,70 @@ def get_history # get document key cur_key = doc_key if (i != cur_ver) - File.open(File.join(ver_dir, "key.txt"), 'r') do |file| + File.open(File.join(ver_dir, 'key.txt'), 'r') do |file| cur_key = file.read() end end - obj["key"] = cur_key - obj["version"] = i + obj['key'] = cur_key + obj['version'] = i if (i == 1) # check if the version number is equal to 1 - if File.file?(File.join(hist_dir, "createdInfo.json")) # check if the createdInfo.json file with meta data exists - File.open(File.join(hist_dir, "createdInfo.json"), 'r') do |file| # open it + if File.file?(File.join(hist_dir, 'createdInfo.json')) # check if the createdInfo.json file with meta data exists + File.open(File.join(hist_dir, 'createdInfo.json'), 'r') do |file| # open it cr_info = JSON.parse(file.read()) # parse the file content # write information about changes to the object - obj["created"] = cr_info["created"] - obj["user"] = { - :id => cr_info["uid"], - :name => cr_info["uname"] + obj['created'] = cr_info['created'] + obj['user'] = { + :id => cr_info['uid'], + :name => cr_info['uname'] } end end end # get the history data from the previous file version and write key and url information about it - dataObj["fileType"] = file_ext[1..file_ext.length] - dataObj["key"] = cur_key - dataObj["url"] = i == cur_ver ? doc_uri : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}") + dataObj['fileType'] = file_ext[1..file_ext.length] + dataObj['key'] = cur_key + dataObj['url'] = i == cur_ver ? doc_uri : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}") if is_enable_direct_url == true - dataObj["directUrl"] = i == cur_ver ? download_url(false) : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", false) + dataObj['directUrl'] = i == cur_ver ? download_url(false) : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", false) end - dataObj["version"] = i + dataObj['version'] = i if (i > 1) # check if the version number is greater than 1 changes = nil change = nil - File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), "changes.json"), 'r') do |file| # get the path to the changes.json file + File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), 'changes.json'), 'r') do |file| # get the path to the changes.json file changes = JSON.parse(file.read()) # and parse its content end - change = changes["changes"][0] + change = changes['changes'][0] # write information about changes to the object - obj["changes"] = change ? changes["changes"] : nil - obj["serverVersion"] = changes["serverVersion"] - obj["created"] = change ? change["created"] : nil - obj["user"] = change ? change["user"] : nil + obj['changes'] = change ? changes['changes'] : nil + obj['serverVersion'] = changes['serverVersion'] + obj['created'] = change ? change['created'] : nil + obj['user'] = change ? change['user'] : nil prev = histData[(i - 2).to_s] # get the history data from the previous file version - dataObj["previous"] = is_enable_direct_url == true ? { # write key and url information about previous file version with optional direct url - :fileType => prev["fileType"], - :key => prev["key"], - :url => prev["url"], - :directUrl => prev["directUrl"] + dataObj['previous'] = is_enable_direct_url == true ? { # write key and url information about previous file version with optional direct url + :fileType => prev['fileType'], + :key => prev['key'], + :url => prev['url'], + :directUrl => prev['directUrl'] } : { - :fileType => prev["fileType"], - :key => prev["key"], - :url => prev["url"] + :fileType => prev['fileType'], + :key => prev['key'], + :url => prev['url'] } # write the path to the diff.zip archive with differences in this file version - dataObj["changesUrl"] = DocumentHelper.get_historypath_uri(file_name, i - 1, "diff.zip") + dataObj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') end if JwtHelper.is_enabled # check if a secret key to generate token exists or not - dataObj["token"] = JwtHelper.encode(dataObj) # encode a payload object into a token and write it to the data object + dataObj['token'] = JwtHelper.encode(dataObj) # encode a payload object into a token and write it to the data object end hist.push(obj) # add object dictionary to the hist list @@ -293,34 +293,34 @@ def get_history # get image information def get_insert_image insert_image = is_enable_direct_url == true ? { - :fileType => "png", # image file type - :url => DocumentHelper.get_server_url(true) + "/assets/logo.png", # server url to the image - :directUrl => DocumentHelper.get_server_url(false) + "/assets/logo.png" # direct url to the image + :fileType => 'png', # image file type + :url => DocumentHelper.get_server_url(true) + '/assets/logo.png', # server url to the image + :directUrl => DocumentHelper.get_server_url(false) + '/assets/logo.png' # direct url to the image } : { - :fileType => "png", # image file type - :url => DocumentHelper.get_server_url(true) + "/assets/logo.png" # server url to the image + :fileType => 'png', # image file type + :url => DocumentHelper.get_server_url(true) + '/assets/logo.png' # server url to the image } if JwtHelper.is_enabled # check if a secret key to generate token exists or not - insert_image["token"] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object + insert_image['token'] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object end - return insert_image.to_json.tr("{", "").tr("}", "") + return insert_image.to_json.tr('{', '').tr('}', '') end # get compared file information def dataDocument compare_file = is_enable_direct_url == true ? { - :fileType => "docx", # file type - :url => DocumentHelper.get_server_url(true) + "/asset?fileName=sample.docx", # server url to the compared file - :directUrl => DocumentHelper.get_server_url(false) + "/asset?fileName=sample.docx" # direct url to the compared file + :fileType => 'docx', # file type + :url => DocumentHelper.get_server_url(true) + '/asset?fileName=sample.docx', # server url to the compared file + :directUrl => DocumentHelper.get_server_url(false) + '/asset?fileName=sample.docx' # direct url to the compared file } : { - :fileType => "docx", # file type - :url => DocumentHelper.get_server_url(true) + "/asset?fileName=sample.docx" # server url to the compared file + :fileType => 'docx', # file type + :url => DocumentHelper.get_server_url(true) + '/asset?fileName=sample.docx' # server url to the compared file } if JwtHelper.is_enabled # check if a secret key to generate token exists or not - compare_file["token"] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object + compare_file['token'] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object end return compare_file @@ -329,16 +329,16 @@ def dataDocument # get mail merge recipients information def dataSpreadsheet dataSpreadsheet = is_enable_direct_url == true ? { - :fileType => "csv", # file type - :url => DocumentHelper.get_server_url(true) + "/csv", # server url to the mail merge recipients file - :directUrl => DocumentHelper.get_server_url(false) + "/csv" # direct url to the mail merge recipients file + :fileType => 'csv', # file type + :url => DocumentHelper.get_server_url(true) + '/csv', # server url to the mail merge recipients file + :directUrl => DocumentHelper.get_server_url(false) + '/csv' # direct url to the mail merge recipients file } : { - :fileType => "csv", # file type - :url => DocumentHelper.get_server_url(true) + "/csv" # server url to the mail merge recipients file + :fileType => 'csv', # file type + :url => DocumentHelper.get_server_url(true) + '/csv' # server url to the mail merge recipients file } if JwtHelper.is_enabled # check if a secret key to generate token exists or not - dataSpreadsheet["token"] = JwtHelper.encode(dataSpreadsheet) # encode a payload object into a token and write it to the dataSpreadsheet object + dataSpreadsheet['token'] = JwtHelper.encode(dataSpreadsheet) # encode a payload object into a token and write it to the dataSpreadsheet object end return dataSpreadsheet @@ -346,12 +346,12 @@ def dataSpreadsheet # get users data for mentions def get_users_mentions - return !@user.id.eql?("uid-0") ? Users.get_users_for_mentions(@user.id) : nil + return !@user.id.eql?('uid-0') ? Users.get_users_for_mentions(@user.id) : nil end def get_users_info users_info = [] - if !@user.id.eql?("uid-0") + if !@user.id.eql?('uid-0') Users.get_all_users().each do |user_info| u = { id: user_info.id, @@ -367,7 +367,7 @@ def get_users_info templates: user_info.templates, avatar: user_info.avatar } - u["image"] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil + u['image'] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil users_info.push(u) end return users_info @@ -376,11 +376,11 @@ def get_users_info # get users data for protect def get_users_protect - return !@user.id.eql?("uid-0") ? Users.get_users_for_protect(@user.id) : nil + return !@user.id.eql?('uid-0') ? Users.get_users_for_protect(@user.id) : nil end # get direct url existence flag def is_enable_direct_url - return @direct_url != nil && @direct_url == "true" + return @direct_url != nil && @direct_url == 'true' end end diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 779cb7aa5..6951c6ced 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -42,7 +42,7 @@ def decode(token) begin decoded = JWT.decode token, @jwt_secret, true, { algorithm: 'HS256' } rescue - return "" + return '' end # decoded = Array [ {"data"=>"test"}, # payload # {"alg"=>"HS256"} # header ] diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index aee29c3cb..10bd71691 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -60,11 +60,11 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ http.read_timeout = @@convert_timeout http.open_timeout = 5 req = Net::HTTP::Post.new(uri.request_uri) # create the post request - req.add_field("Accept", "application/json") # set headers - req.add_field("Content-Type", "application/json") + req.add_field('Accept', 'application/json') # set headers + req.add_field('Content-Type', 'application/json') if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled - payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload + payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwtHeader = ServiceConverter.config_manager.jwt_header; # get signature authorization header req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 1abf4d729..1b61fe9e3 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -36,7 +36,7 @@ def read_body(request) body = request.body.read if body == nil || body.empty? - return "" + return '' end file_data = JSON.parse(body) # parse file data @@ -46,25 +46,25 @@ def read_body(request) inHeader = false token = nil jwtHeader = TrackHelper.config_manager.jwt_header; # get the authorization header from the config - if file_data["token"] # if the token is in the body - token = JwtHelper.decode(file_data["token"]) # decode a token into a payload object using a secret key + if file_data['token'] # if the token is in the body + token = JwtHelper.decode(file_data['token']) # decode a token into a payload object using a secret key elsif request.headers[jwtHeader] # if the token is in the header hdr = request.headers[jwtHeader] - hdr.slice!(0, "Bearer ".length) # get token from it (after Bearer prefix) + hdr.slice!(0, 'Bearer '.length) # get token from it (after Bearer prefix) token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key inHeader = true else - raise "Expected JWT" # token missing error message + raise 'Expected JWT' # token missing error message end - if !token || token.eql?("") - raise "Invalid JWT signature" + if !token || token.eql?('') + raise 'Invalid JWT signature' end file_data = JSON.parse(token) if inHeader - file_data = file_data["payload"] + file_data = file_data['payload'] end end @@ -107,7 +107,7 @@ def process_save(raw_file_data, file_name, user_address) end new_file_name = file_name - download_ext = "." + file_data['filetype'] # get the extension of the downloaded file + download_ext = '.' + file_data['filetype'] # get the extension of the downloaded file cur_ext = File.extname(file_name).downcase # get current file extension @@ -145,26 +145,26 @@ def process_save(raw_file_data, file_name, user_address) save_file(data, storage_path) # save the downloaded file to the storage directory - change_data = download_file(file_data["changesurl"]) # download file with document versions differences - save_file(change_data, File.join(ver_dir, "diff.zip")) # save file with document versions differences + change_data = download_file(file_data['changesurl']) # download file with document versions differences + save_file(change_data, File.join(ver_dir, 'diff.zip')) # save file with document versions differences - hist_data = file_data["changeshistory"] + hist_data = file_data['changeshistory'] unless hist_data # if there are no changes in the history - hist_data = file_data["history"].to_json # write the original history information to the history data + hist_data = file_data['history'].to_json # write the original history information to the history data end if hist_data - File.open(File.join(ver_dir, "changes.json"), 'wb') do |file| # open the file with document changes + File.open(File.join(ver_dir, 'changes.json'), 'wb') do |file| # open the file with document changes file.write(hist_data) # and write history data to this file end end # write the key value to the key.txt file - File.open(File.join(ver_dir, "key.txt"), 'wb') do |file| - file.write(file_data["key"]) + File.open(File.join(ver_dir, 'key.txt'), 'wb') do |file| + file.write(file_data['key']) end forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) # get the path to the forcesaved file - unless forcesave_path.eql?("") # if this path is empty + unless forcesave_path.eql?('') # if this path is empty File.delete(forcesave_path) # remove it end @@ -184,7 +184,7 @@ def process_force_save(file_data, file_name, user_address) return saved end - download_ext = "." + file_data['filetype'] # get the extension of the downloaded file + download_ext = '.' + file_data['filetype'] # get the extension of the downloaded file cur_ext = File.extname(file_name).downcase # get current file extension @@ -213,13 +213,13 @@ def process_force_save(file_data, file_name, user_address) end begin - is_submit_form = file_data["forcesavetype"].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) + is_submit_form = file_data['forcesavetype'].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) if is_submit_form if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + download_ext, user_address) # get the correct file name if it already exists + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + '-form' + download_ext, user_address) # get the correct file name if it already exists else - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + "-form" + cur_ext, user_address) + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + '-form' + cur_ext, user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else @@ -227,7 +227,7 @@ def process_force_save(file_data, file_name, user_address) file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) end forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) - if forcesave_path.eql?("") + if forcesave_path.eql?('') forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it end end @@ -236,7 +236,7 @@ def process_force_save(file_data, file_name, user_address) if is_submit_form uid = file_data['actions'][0]['userid'] - DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name + DocumentHelper.create_meta(file_name, uid, 'Filling Form', user_address) # create file meta information with the Filling form tag instead of user name end saved = 0 @@ -267,10 +267,10 @@ def command_request(method, key, meta = nil) DocumentHelper.verify_ssl(@@document_command_url, http) req = Net::HTTP::Post.new(uri.request_uri) # create the post request - req.add_field("Content-Type", "application/json") # set headers + req.add_field('Content-Type', 'application/json') # set headers if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled - payload["token"] = JwtHelper.encode(payload) # get token and save it to the payload + payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index a7c367ba9..8d85b376d 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -37,76 +37,76 @@ def initialize(id, name, email, group, reviewGroups, commentGroups, userInfoGrou class Users @@descr_user_1 = [ - "File author by default", - "Doesn’t belong to any group", - "Can review all the changes", - "Can perform all actions with comments", - "The file favorite state is undefined", - "Can create files from templates using data from the editor", - "Can see the information about all users", - "Has an avatar", + 'File author by default', + 'Doesn’t belong to any group', + 'Can review all the changes', + 'Can perform all actions with comments', + 'The file favorite state is undefined', + 'Can create files from templates using data from the editor', + 'Can see the information about all users', + 'Has an avatar', ]; @@descr_user_2 = [ - "Belongs to Group2", - "Can review only his own changes or changes made by users with no group", - "Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only", - "This file is marked as favorite", - "Can create new files from the editor", - "Can see the information about users from Group2 and users who don’t belong to any group", - "Has an avatar", + 'Belongs to Group2', + 'Can review only his own changes or changes made by users with no group', + 'Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only', + 'This file is marked as favorite', + 'Can create new files from the editor', + 'Can see the information about users from Group2 and users who don’t belong to any group', + 'Has an avatar', ]; @@descr_user_3 = [ - "Belongs to Group3", - "Can review changes made by Group2 users", - "Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users", - "This file isn’t marked as favorite", - "Can’t copy data from the file to clipboard", - "Can’t download the file", - "Can’t print the file", - "Can create new files from the editor", - "Can see the information about Group2 users", + 'Belongs to Group3', + 'Can review changes made by Group2 users', + 'Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users', + 'This file isn’t marked as favorite', + 'Can’t copy data from the file to clipboard', + 'Can’t download the file', + 'Can’t print the file', + 'Can create new files from the editor', + 'Can see the information about Group2 users', ]; @@descr_user_0 = [ - "The name is requested when the editor is opened", - "Doesn’t belong to any group", - "Can review all the changes", - "Can perform all actions with comments", - "The file favorite state is undefined", + 'The name is requested when the editor is opened', + 'Doesn’t belong to any group', + 'Can review all the changes', + 'Can perform all actions with comments', + 'The file favorite state is undefined', "Can't mention others in comments", "Can't create new files from the editor", - "Can’t see anyone’s information", + 'Can’t see anyone’s information', "Can't rename files from the editor", "Can't view chat", "Can't protect file", - "View file without collaboration" + 'View file without collaboration' ]; @@users = [ - User.new("uid-1", "John Smith", "smith@example.com", - "", nil, {}, nil, + User.new('uid-1', 'John Smith', 'smith@example.com', + '', nil, {}, nil, nil, [], @@descr_user_1, true, true), - User.new("uid-2", "Mark Pottato", "pottato@example.com", - "group-2", ["group-2", ""], { - :view => "", - :edit => ["group-2", ""], - :remove => ["group-2"] + User.new('uid-2', 'Mark Pottato', 'pottato@example.com', + 'group-2', ['group-2', ''], { + :view => '', + :edit => ['group-2', ''], + :remove => ['group-2'] }, - ["group-2", ""], + ['group-2', ''], true, [], @@descr_user_2, false, true), - User.new("uid-3", "Hamish Mitchell", nil, - "group-3", ["group-2"], { - :view => ["group-3", "group-2"], - :edit => ["group-2"], + User.new('uid-3', 'Hamish Mitchell', nil, + 'group-3', ['group-2'], { + :view => ['group-3', 'group-2'], + :edit => ['group-2'], :remove => [] }, - ["group-2"], - false, ["copy", "download", "print"], @@descr_user_3, false, false), - User.new("uid-0", nil, nil, - "", nil, {}, [], - nil, ["protect"], @@descr_user_0, false, false) + ['group-2'], + false, ['copy', 'download', 'print'], @@descr_user_3, false, false), + User.new('uid-0', nil, nil, + '', nil, {}, [], + nil, ['protect'], @@descr_user_0, false, false) ] class << self From 5255f0e4628a8066b016b7b77d87682094ef3b3a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 14:46:08 +0300 Subject: [PATCH 274/488] ruby: Style/SymbolArray correct --- web/documentserver-example/ruby/Gemfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/Gemfile b/web/documentserver-example/ruby/Gemfile index 43adf6cd6..656c32569 100644 --- a/web/documentserver-example/ruby/Gemfile +++ b/web/documentserver-example/ruby/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'byebug', '~> 11.1', :groups => [:development, :test] +gem 'byebug', '~> 11.1', :groups => %i[development test] gem 'coffee-rails', '~> 5.0' gem 'dalli', '~> 3.2', :group => :development gem 'jbuilder', '~> 2.11' @@ -13,12 +13,12 @@ gem 'rubocop', '~> 1.52', :group => :development gem 'sass-rails', '~> 6.0' gem 'sdoc', '~> 2.6', :group => :doc gem 'sorbet-runtime', '~> 0.5.10871' -gem 'test-unit', '~> 3.6', :groups => [:development, :test] +gem 'test-unit', '~> 3.6', :groups => %i[development test] gem 'turbolinks', '~> 5.2' gem 'tzinfo-data', '~> 1.2023' gem 'uglifier', '~> 4.2' gem 'uuid', '~> 2.3' -gem 'web-console', '~> 4.2', :groups => [:development, :test] +gem 'web-console', '~> 4.2', :groups => %i[development test] gem 'webrick', '~> 1.8' # Unfortunately, Sorbet only supports Darwin and Linux-based systems. From 15b905613c0ebc6ce4f8daf45e7a50868982bbd5 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 14:47:16 +0300 Subject: [PATCH 275/488] ruby: Style/EmptyMethod correct --- .../ruby/app/controllers/home_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index b968b45bb..6215583e0 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -26,8 +26,7 @@ class << self attr_reader :config_manager end - def index - end + def index; end def editor DocumentHelper.init(request.remote_ip, request.base_url) From f5801a7f8cb357c5be433ca73b830d03e72f4376 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 14:53:05 +0300 Subject: [PATCH 276/488] ruby: Style/IfUnlessModifier correct --- .../ruby/app/controllers/home_controller.rb | 36 +++++------------ .../ruby/app/models/document_helper.rb | 20 +++------- .../ruby/app/models/service_converter.rb | 8 +--- .../ruby/app/models/track_helper.rb | 40 +++++-------------- .../ruby/app/models/users.rb | 12 ++---- 5 files changed, 29 insertions(+), 87 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 6215583e0..d8c5652ea 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -52,16 +52,12 @@ def upload cur_size = http_posted_file.size # check if the file size exceeds the maximum file size - if DocumentHelper.file_size_max < cur_size || cur_size <= 0 - raise 'File size is incorrect' - end + raise 'File size is incorrect' if DocumentHelper.file_size_max < cur_size || cur_size <= 0 cur_ext = File.extname(file_name).downcase # check if the file extension is supported by the editor - unless DocumentHelper.file_exts.include? cur_ext - raise 'File type is not supported' - end + raise 'File type is not supported' unless DocumentHelper.file_exts.include? cur_ext # get the correct file name if such a name already exists file_name = DocumentHelper.get_correct_name(file_name, nil) @@ -87,9 +83,7 @@ def upload def convert begin file_data = request.body.read - if file_data == nil || file_data.empty? - return '' - end + return '' if file_data == nil || file_data.empty? body = JSON.parse(file_data) @@ -122,9 +116,7 @@ def convert res = http.request(req) data = res.body - if data == nil - raise 'stream is null' - end + raise 'stream is null' if data == nil # write a file with a new extension, but with the content from the origin file File.open(DocumentHelper.storage_path(correct_name, nil), 'wb') do |file| @@ -132,9 +124,7 @@ def convert end old_storage_path = DocumentHelper.storage_path(file_name, nil) - if File.exist?(old_storage_path) - File.delete(old_storage_path) - end + File.delete(old_storage_path) if File.exist?(old_storage_path) file_name = correct_name user = Users.get_user(params[:userId]) @@ -356,9 +346,7 @@ def rename orig_ext = '.' + body['ext'] cur_ext = File.extname(newfilename).downcase - if orig_ext != cur_ext - newfilename += orig_ext - end + newfilename += orig_ext if orig_ext != cur_ext meta = { :title => newfilename @@ -380,9 +368,7 @@ def reference if instanceId == DocumentHelper.get_server_url(false) fileKey = JSON.parse(referenceData['fileKey']) userAddress = fileKey['userAddress'] - if userAddress == DocumentHelper.cur_user_host_address(nil) - fileName = fileKey['fileName'] - end + fileName = fileKey['fileName'] if userAddress == DocumentHelper.cur_user_host_address(nil) end end @@ -408,9 +394,7 @@ def reference if fileName.empty? and body.key?('path') path = File.basename(body['path']) - if File.exist?(DocumentHelper.storage_path(path, nil)) - fileName = path - end + fileName = path if File.exist?(DocumentHelper.storage_path(path, nil)) end if fileName.empty? @@ -431,9 +415,7 @@ def reference :link => DocumentHelper.get_server_url(false) + '/editor?fileName=' + fileName } - if JwtHelper.is_enabled - data['token'] = JwtHelper.encode(data) - end + data['token'] = JwtHelper.encode(data) if JwtHelper.is_enabled render plain: data.to_json end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 445deddd6..ca9546972 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -75,9 +75,7 @@ def storage_path(file_name, user_address) directory = DocumentHelper.config_manager.storage_path.join(cur_user_host_address(user_address)) # create a new directory if it doesn't exist - unless File.directory?(directory) - FileUtils.mkdir_p(directory) - end + FileUtils.mkdir_p(directory) unless File.directory?(directory) # put the given file to this directory File.join(directory, File.basename(file_name)) @@ -88,9 +86,7 @@ def forcesave_path(file_name, user_address, create) directory = DocumentHelper.config_manager.storage_path.join(cur_user_host_address(user_address)) # the directory with host address doesn't exist - unless File.directory?(directory) - return '' - end + return '' unless File.directory?(directory) directory = File.join(directory, "#{File.basename(file_name)}-hist") # get the path to the history of the given file unless File.directory?(directory) @@ -103,9 +99,7 @@ def forcesave_path(file_name, user_address, create) directory = File.join(directory, File.basename(file_name)) # get the path to the given file unless File.file?(directory) - if !create - return '' - end + return '' if !create end return directory.to_s @@ -116,9 +110,7 @@ def history_dir(storage_path) directory = "#{storage_path}-hist" # create history directory if it doesn't exist - unless File.directory?(directory) - FileUtils.mkdir_p(directory) - end + FileUtils.mkdir_p(directory) unless File.directory?(directory) return directory end @@ -130,9 +122,7 @@ def version_dir(hist_dir, ver) # get the last file version def get_file_version(hist_dir) - if !Dir.exist?(hist_dir) - return 1 - end + return 1 if !Dir.exist?(hist_dir) ver = 1 Dir.foreach(hist_dir) { |e| # run through all the file versions diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 10bd71691..2200cc164 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -73,9 +73,7 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ res = http.request(req) # get the response status_code = res.code.to_i - if status_code != 200 # checking status code - raise "Conversion service returned status: #{status_code}" - end + raise "Conversion service returned status: #{status_code}" if status_code != 200 # checking status code data = res.body # and take its body rescue Timeout::Error @@ -163,9 +161,7 @@ def get_response_data(json_data) percent_element = file_result['percent'] # get the percentage value - if percent_element != nil - result_percent = percent_element.to_i - end + result_percent = percent_element.to_i if percent_element != nil result_percent = result_percent >= 100 ? 99 : result_percent diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 1b61fe9e3..2e436d1a9 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -35,9 +35,7 @@ class << self def read_body(request) body = request.body.read - if body == nil || body.empty? - return '' - end + return '' if body == nil || body.empty? file_data = JSON.parse(body) # parse file data @@ -57,15 +55,11 @@ def read_body(request) raise 'Expected JWT' # token missing error message end - if !token || token.eql?('') - raise 'Invalid JWT signature' - end + raise 'Invalid JWT signature' if !token || token.eql?('') file_data = JSON.parse(token) - if inHeader - file_data = file_data['payload'] - end + file_data = file_data['payload'] if inHeader end return file_data @@ -89,9 +83,7 @@ def resolve_process_save_body(body) end home = copied['home'] - if home - copied['home'] = resolve_process_save_body(home) - end + copied['home'] = resolve_process_save_body(home) if home copied end @@ -129,9 +121,7 @@ def process_save(raw_file_data, file_name, user_address) saved = 1 data = download_file(download_uri) # download document file - if data.eql?(nil) - return saved - end + return saved if data.eql?(nil) begin storage_path = DocumentHelper.storage_path(new_file_name, user_address) # get the storage directory of the new file @@ -208,9 +198,7 @@ def process_force_save(file_data, file_name, user_address) saved = 1 data = download_file(download_uri) # download document file - if data.eql?(nil) - return saved - end + return saved if data.eql?(nil) begin is_submit_form = file_data['forcesavetype'].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) @@ -223,9 +211,7 @@ def process_force_save(file_data, file_name, user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else - if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) - end + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) if new_file_name forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) if forcesave_path.eql?('') forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it @@ -255,9 +241,7 @@ def command_request(method, key, meta = nil) :key => key } - if (meta != nil) - payload.merge!({ :meta => meta }) - end + payload.merge!({ :meta => meta }) if (meta != nil) data = nil begin @@ -298,15 +282,11 @@ def download_file(uristr) res = http.request(req) # get the response status_code = res.code - if status_code != '200' # checking status code - raise "Document editing service returned status: #{status_code}" - end + raise "Document editing service returned status: #{status_code}" if status_code != '200' # checking status code data = res.body # and take its body - if data == nil - raise 'stream is null' - end + raise 'stream is null' if data == nil data end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 8d85b376d..17703e2e4 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -116,9 +116,7 @@ def get_all_users() # get a list of all the users def get_user(id) # get a user by id specified for user in @@users do - if user.id.eql?(id) - return user - end + return user if user.id.eql?(id) end return @@users[0] end @@ -126,9 +124,7 @@ def get_user(id) # get a user by id specified def get_users_for_mentions(id) # get a list of users with their names and emails for mentions usersData = [] for user in @@users do - if (!user.id.eql?(id) && user.name != nil && user.email != nil) - usersData.push({ :name => user.name, :email => user.email }) - end + usersData.push({ :name => user.name, :email => user.email }) if (!user.id.eql?(id) && user.name != nil && user.email != nil) end return usersData end @@ -136,9 +132,7 @@ def get_users_for_mentions(id) # get a list of users with their names and emails def get_users_for_protect(id) # get a list of users with their id, names and emails for protect users_data = [] for user in @@users do - if (!user.id.eql?(id) && user.name != nil) - users_data.push({ id: user.id, name: user.name, email: user.email }) - end + users_data.push({ id: user.id, name: user.name, email: user.email }) if (!user.id.eql?(id) && user.name != nil) end return users_data end From eb6861059efd414da13193cd6727e31f20d585d8 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 15:00:52 +0300 Subject: [PATCH 277/488] ruby: Style/StringConcatenation correct --- .../ruby/app/controllers/home_controller.rb | 36 +++++++++---------- .../ruby/app/models/document_helper.rb | 28 +++++++-------- .../ruby/app/models/file_model.rb | 24 ++++++------- .../ruby/app/models/service_converter.rb | 2 +- .../ruby/app/models/track_helper.rb | 8 ++--- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index d8c5652ea..6bd15d332 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -73,9 +73,9 @@ def upload DocumentHelper.create_meta(file_name, user.id, user.name, nil) - render plain: '{ "filename": "' + file_name + '", "documentType": "' + document_type + '"}' # write a new file name to the response + render plain: "{ \"filename\": \"#{file_name}\", \"documentType\": \"#{document_type}\"}" # write a new file name to the response rescue => ex - render plain: '{ "error": "' + ex.message + '"}' # write an error message to the response + render plain: "{ \"error\": \"#{ex.message}\"}" # write an error message to the response end end @@ -100,12 +100,12 @@ def convert # if the conversion isn't completed, write file name and step values to the response if percent != 100 - render plain: '{ "step" : "' + percent.to_s + '", "filename" : "' + file_name + '"}' + render plain: "{ \"step\" : \"#{percent.to_s}\", \"filename\" : \"#{file_name}\"}" return end # get the correct file name if such a name already exists - correct_name = DocumentHelper.get_correct_name(File.basename(file_name, extension) + '.' + new_file_type, nil) + correct_name = DocumentHelper.get_correct_name("#{File.basename(file_name, extension)}.#{new_file_type}", nil) uri = URI.parse(new_file_uri) # create the request url http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server @@ -132,9 +132,9 @@ def convert DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file end - render plain: '{ "filename" : "' + file_name + '"}' + render plain: "{ \"filename\" : \"#{file_name}\"}" rescue => ex - render plain: '{ "error": "' + ex.message + '"}' + render plain: "{ \"error\": \"#{ex.message}\"}" end end @@ -162,14 +162,14 @@ def downloadhistory return end end - hist_path = DocumentHelper.storage_path(file_name, user_address) + '-hist' # or to the original document + hist_path = "#{DocumentHelper.storage_path(file_name, user_address)}-hist" # or to the original document file_path = File.join(hist_path, version, file) # add headers to the response to specify the page parameters response.headers['Content-Length'] = File.size(file_path).to_s response.headers['Content-Type'] = MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type - response.headers['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + ERB::Util.url_encode(file) + response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file)}" send_file file_path, :x_sendfile => true rescue => ex @@ -201,13 +201,13 @@ def track if status == 2 || status == 3 # MustSave, Corrupted saved = TrackHelper.process_save(file_data, file_name, user_address) # save file - render plain: '{"error":' + saved.to_s + '}' + render plain: "{\"error\":#{saved.to_s}}" return end if status == 6 || status == 7 # MustForceave, CorruptedForcesave saved = TrackHelper.process_force_save(file_data, file_name, user_address) # force save file - render plain: '{"error":' + saved.to_s + '}' + render plain: "{\"error\":#{saved.to_s}}" return end @@ -254,7 +254,7 @@ def csv # add headers to the response to specify the page parameters response.headers['Content-Length'] = File.size(csvPath).to_s response.headers['Content-Type'] = MimeMagic.by_path(csvPath).type - response.headers['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + ERB::Util.url_encode(file_name) + response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" send_file csvPath, :x_sendfile => true end @@ -287,7 +287,7 @@ def download # add headers to the response to specify the page parameters response.headers['Content-Length'] = File.size(file_path).to_s response.headers['Content-Type'] = MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type - response.headers['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + ERB::Util.url_encode(file_name) + response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" send_file file_path, :x_sendfile => true rescue => ex @@ -330,10 +330,10 @@ def saveas user = Users.get_user(params[:userId]) DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file - render plain: '{"file" : "' + file_name + '"}' + render plain: "{\"file\" : \"#{file_name}\"}" return rescue => ex - render plain: '{"error":1, "message": "' + ex.message + '"}' + render plain: "{\"error\":1, \"message\": \"#{ex.message}\"}" return end end @@ -344,7 +344,7 @@ def rename dockey = body['dockey'] newfilename = body['newfilename'] - orig_ext = '.' + body['ext'] + orig_ext = ".#{body['ext']}" cur_ext = File.extname(newfilename).downcase newfilename += orig_ext if orig_ext != cur_ext @@ -353,7 +353,7 @@ def rename } json_data = TrackHelper.command_request('meta', dockey, meta) - render plain: '{ "result" : "' + JSON.dump(json_data) + '"}' + render plain: "{ \"result\" : \"#{JSON.dump(json_data)}\"}" end # ReferenceData @@ -404,7 +404,7 @@ def reference data = { :fileType => File.extname(fileName).downcase.delete('.'), - :key => ServiceConverter.generate_revision_id("#{DocumentHelper.cur_user_host_address(nil) + '/' + fileName}.#{File.mtime(DocumentHelper.storage_path(fileName, nil))}"), + :key => ServiceConverter.generate_revision_id("#{"#{DocumentHelper.cur_user_host_address(nil)}/#{fileName}"}.#{File.mtime(DocumentHelper.storage_path(fileName, nil))}"), :url => DocumentHelper.get_download_url(fileName), :directUrl => body['directUrl'] ? DocumentHelper.get_download_url(fileName, false) : nil, :referenceData => { @@ -412,7 +412,7 @@ def reference :fileKey => { :fileName => fileName, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json }, :path => fileName, - :link => DocumentHelper.get_server_url(false) + '/editor?fileName=' + fileName + :link => "#{DocumentHelper.get_server_url(false)}/editor?fileName=#{fileName}" } data['token'] = JwtHelper.encode(data) if JwtHelper.is_enabled diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index ca9546972..e00806891 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -147,7 +147,7 @@ def get_correct_name(file_name, user_address) index = 1 while File.exist?(storage_path(name, user_address)) # if the file with such a name already exists in this directory - name = base_name + ' (' + index.to_s + ')' + ext.downcase # add an index after its base name + name = "#{base_name} (#{index.to_s})#{ext.downcase}" # add an index after its base name index = index + 1 end @@ -209,7 +209,7 @@ def create_demo(file_ext, sample, user) # get file url def get_file_uri(file_name, for_document_server) - uri = get_server_url(for_document_server) + '/' + DocumentHelper.config_manager.storage_path.to_s + '/' + cur_user_host_address(nil) + '/' + ERB::Util.url_encode(file_name) + uri = "#{get_server_url(for_document_server)}/#{DocumentHelper.config_manager.storage_path.to_s}/#{cur_user_host_address(nil)}/#{ERB::Util.url_encode(file_name)}" return uri end @@ -217,8 +217,8 @@ def get_file_uri(file_name, for_document_server) # get history path url def get_historypath_uri(file_name, version, file, is_serverUrl = true) # for redirection to my link - user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : '' - uri = get_server_url(is_serverUrl) + '/downloadhistory/?fileName=' + ERB::Util.url_encode(file_name) + '&ver=' + version.to_s + '&file=' + ERB::Util.url_encode(file) + user_host + user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' + uri = "#{get_server_url(is_serverUrl)}/downloadhistory/?fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version.to_s}&file=#{ERB::Util.url_encode(file)}#{user_host}" return uri end @@ -233,18 +233,18 @@ def get_server_url(for_document_server) # get callback url def get_callback(file_name) - get_server_url(true) + '/track?fileName=' + ERB::Util.url_encode(file_name) + '&userAddress=' + cur_user_host_address(nil) + "#{get_server_url(true)}/track?fileName=#{ERB::Util.url_encode(file_name)}&userAddress=#{cur_user_host_address(nil)}" end # get url to the created file def get_create_url(document_type) - get_server_url(false) + '/sample?fileExt=' + get_internal_extension(document_type).delete('.') + "#{get_server_url(false)}/sample?fileExt=#{get_internal_extension(document_type).delete('.')}" end # get url to download a file def get_download_url(file_name, is_serverUrl = true) - user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : '' - get_server_url(is_serverUrl) + '/download?fileName=' + ERB::Util.url_encode(file_name) + user_host + user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' + "#{get_server_url(is_serverUrl)}/download?fileName=#{ERB::Util.url_encode(file_name)}#{user_host}" end # get internal file extension by its type @@ -265,16 +265,16 @@ def get_internal_extension(file_type) # get image url for templates def get_template_image_url(file_type) - path = get_server_url(true) + '/assets/' + path = "#{get_server_url(true)}/assets/" case file_type when 'word' # for word type - full_path = path + 'file_docx.svg' + full_path = "#{path}file_docx.svg" when 'cell' # .xlsx for cell type - full_path = path + 'file_xlsx.svg' + full_path = "#{path}file_xlsx.svg" when 'slide' # .pptx for slide type - full_path = path + 'file_pptx.svg' + full_path = "#{path}file_pptx.svg" else - full_path = path + 'file_docx.svg' # the default value is .docx + full_path = "#{path}file_docx.svg" # the default value is .docx end full_path @@ -286,7 +286,7 @@ def get_files_info(file_id) for fileName in get_stored_files(nil) # run through all the stored files from the folder directory = storage_path(fileName, nil) - uri = cur_user_host_address(nil) + '/' + fileName + uri = "#{cur_user_host_address(nil)}/#{fileName}" # write file parameters to the info object info = { diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index d0b1e531b..6de54e575 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -49,7 +49,7 @@ def file_uri # get file uri for document server def file_uri_user - @config_manager.storage_path.absolute? ? download_url + '&dmode=emb' : DocumentHelper.get_file_uri(@file_name, false) + @config_manager.storage_path.absolute? ? "#{download_url}&dmode=emb" : DocumentHelper.get_file_uri(@file_name, false) end # get document type from its name (word, cell or slide) @@ -59,7 +59,7 @@ def document_type # generate the document key value def key - uri = DocumentHelper.cur_user_host_address(nil) + '/' + @file_name # get current user host address + uri = "#{DocumentHelper.cur_user_host_address(nil)}/#{@file_name}" # get current user host address stat = File.mtime(DocumentHelper.storage_path(@file_name, nil)) # get the modification time of the given file return ServiceConverter.generate_revision_id("#{uri}.#{stat}") end @@ -104,7 +104,7 @@ def get_config { :image => templatesImageUrl, :title => 'With sample content', - :url => create_url + '&sample=true' + :url => "#{create_url}&sample=true" } ] @@ -294,11 +294,11 @@ def get_history def get_insert_image insert_image = is_enable_direct_url == true ? { :fileType => 'png', # image file type - :url => DocumentHelper.get_server_url(true) + '/assets/logo.png', # server url to the image - :directUrl => DocumentHelper.get_server_url(false) + '/assets/logo.png' # direct url to the image + :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image + :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image } : { :fileType => 'png', # image file type - :url => DocumentHelper.get_server_url(true) + '/assets/logo.png' # server url to the image + :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image } if JwtHelper.is_enabled # check if a secret key to generate token exists or not @@ -312,11 +312,11 @@ def get_insert_image def dataDocument compare_file = is_enable_direct_url == true ? { :fileType => 'docx', # file type - :url => DocumentHelper.get_server_url(true) + '/asset?fileName=sample.docx', # server url to the compared file - :directUrl => DocumentHelper.get_server_url(false) + '/asset?fileName=sample.docx' # direct url to the compared file + :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file + :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file } : { :fileType => 'docx', # file type - :url => DocumentHelper.get_server_url(true) + '/asset?fileName=sample.docx' # server url to the compared file + :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file } if JwtHelper.is_enabled # check if a secret key to generate token exists or not @@ -330,11 +330,11 @@ def dataDocument def dataSpreadsheet dataSpreadsheet = is_enable_direct_url == true ? { :fileType => 'csv', # file type - :url => DocumentHelper.get_server_url(true) + '/csv', # server url to the mail merge recipients file - :directUrl => DocumentHelper.get_server_url(false) + '/csv' # direct url to the mail merge recipients file + :url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file + :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file } : { :fileType => 'csv', # file type - :url => DocumentHelper.get_server_url(true) + '/csv' # server url to the mail merge recipients file + :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file } if JwtHelper.is_enabled # check if a secret key to generate token exists or not diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 2200cc164..243bbf17d 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -123,7 +123,7 @@ def process_convert_service_responce_error(error_code) when 0 # public const int c_nErrorNo = 0 else - error_message = 'ErrorCode = ' + error_code.to_s # default value for the error message + error_message = "ErrorCode = #{error_code.to_s}" # default value for the error message end raise error_message diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 2e436d1a9..c1403c06e 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -99,7 +99,7 @@ def process_save(raw_file_data, file_name, user_address) end new_file_name = file_name - download_ext = '.' + file_data['filetype'] # get the extension of the downloaded file + download_ext = ".#{file_data['filetype']}" # get the extension of the downloaded file cur_ext = File.extname(file_name).downcase # get current file extension @@ -174,7 +174,7 @@ def process_force_save(file_data, file_name, user_address) return saved end - download_ext = '.' + file_data['filetype'] # get the extension of the downloaded file + download_ext = ".#{file_data['filetype']}" # get the extension of the downloaded file cur_ext = File.extname(file_name).downcase # get current file extension @@ -205,9 +205,9 @@ def process_force_save(file_data, file_name, user_address) if is_submit_form if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + '-form' + download_ext, user_address) # get the correct file name if it already exists + file_name = DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists else - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + '-form' + cur_ext, user_address) + file_name = DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else From 519f6d6f3209126c5f0a93c279bff614b48b99dc Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 15:54:50 +0300 Subject: [PATCH 278/488] ruby: Style/NilComparison correct --- .../ruby/app/controllers/home_controller.rb | 8 ++++---- .../ruby/app/models/document_helper.rb | 4 ++-- .../ruby/app/models/service_converter.rb | 6 +++--- .../ruby/app/models/track_helper.rb | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 6bd15d332..7be7789b9 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -83,7 +83,7 @@ def upload def convert begin file_data = request.body.read - return '' if file_data == nil || file_data.empty? + return '' if file_data.nil? || file_data.empty? body = JSON.parse(file_data) @@ -116,7 +116,7 @@ def convert res = http.request(req) data = res.body - raise 'stream is null' if data == nil + raise 'stream is null' if data.nil? # write a file with a new extension, but with the content from the origin file File.open(DocumentHelper.storage_path(correct_name, nil), 'wb') do |file| @@ -180,7 +180,7 @@ def downloadhistory # tracking file changes def track file_data = TrackHelper.read_body(request) # read the request body - if file_data == nil || file_data.empty? + if file_data.nil? || file_data.empty? render plain: '{"error":1}' # an error occurs if the file is empty return end @@ -266,7 +266,7 @@ def download user_address = params[:userAddress] isEmbedded = params[:dmode] - if JwtHelper.is_enabled && isEmbedded == nil && user_address != nil && JwtHelper.use_for_request + if JwtHelper.is_enabled && isEmbedded.nil? && user_address != nil && JwtHelper.use_for_request jwtHeader = HomeController.config_manager.jwt_header; if request.headers[jwtHeader] hdr = request.headers[jwtHeader] diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index e00806891..c1bea5a5e 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -67,7 +67,7 @@ def convert_exts # get current user host address def cur_user_host_address(user_address) - (user_address == nil ? @@remote_ip : user_address).gsub(/[^0-9\-.a-zA-Z_=]/, '_'); + (user_address.nil? ? @@remote_ip : user_address).gsub(/[^0-9\-.a-zA-Z_=]/, '_'); end # get the storage path of the given file @@ -298,7 +298,7 @@ def get_files_info(file_id) 'updated' => File.mtime(directory) } - if file_id == nil # if file id is undefined + if file_id.nil? # if file id is undefined result.push(info) # push info object to the response array else # if file id is defined if file_id.eql?(info['id']) # and it is equal to the document key value diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 243bbf17d..d2c66ab71 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -29,11 +29,11 @@ class << self class << self # get the url of the converted file def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_async, file_pass, lang = nil) - from_ext = from_ext == nil ? File.extname(document_uri).downcase : from_ext # get the current document extension + from_ext = from_ext.nil? ? File.extname(document_uri).downcase : from_ext # get the current document extension # get the current document name or uuid title = File.basename(URI.parse(document_uri).path) - title = title == nil ? UUID.generate.to_s : title + title = title.nil? ? UUID.generate.to_s : title # get the document key document_revision_id = document_revision_id.empty? ? document_uri : document_revision_id @@ -149,7 +149,7 @@ def get_response_data(json_data) file_url_element = file_result['fileUrl'] file_type_element = file_result['fileType'] - if file_url_element == nil # and the file url doesn't exist + if file_url_element.nil? # and the file url doesn't exist raise 'Invalid answer format' # get ann error message end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index c1403c06e..da26e9239 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -35,7 +35,7 @@ class << self def read_body(request) body = request.body.read - return '' if body == nil || body.empty? + return '' if body.nil? || body.empty? file_data = JSON.parse(body) # parse file data @@ -108,7 +108,7 @@ def process_save(raw_file_data, file_name, user_address) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file - if new_file_uri == nil || new_file_uri.empty? + if new_file_uri.nil? || new_file_uri.empty? new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) # get the correct file name if it already exists else download_uri = new_file_uri @@ -185,7 +185,7 @@ def process_force_save(file_data, file_name, user_address) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file - if new_file_uri == nil || new_file_uri.empty? + if new_file_uri.nil? || new_file_uri.empty? new_file_name = true else download_uri = new_file_uri @@ -286,7 +286,7 @@ def download_file(uristr) data = res.body # and take its body - raise 'stream is null' if data == nil + raise 'stream is null' if data.nil? data end From 52d72371d5856138f4a035ebda4723e132bff86f Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 15:58:46 +0300 Subject: [PATCH 279/488] ruby: Style/Semicolon correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- .../ruby/app/models/document_helper.rb | 6 +++--- web/documentserver-example/ruby/app/models/users.rb | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 7be7789b9..921c66db8 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -148,7 +148,7 @@ def downloadhistory isEmbedded = params[:dmode] if JwtHelper.is_enabled && JwtHelper.use_for_request - jwtHeader = HomeController.config_manager.jwt_header; + jwtHeader = HomeController.config_manager.jwt_header if request.headers[jwtHeader] hdr = request.headers[jwtHeader] hdr.slice!(0, 'Bearer '.length) @@ -267,7 +267,7 @@ def download isEmbedded = params[:dmode] if JwtHelper.is_enabled && isEmbedded.nil? && user_address != nil && JwtHelper.use_for_request - jwtHeader = HomeController.config_manager.jwt_header; + jwtHeader = HomeController.config_manager.jwt_header if request.headers[jwtHeader] hdr = request.headers[jwtHeader] hdr.slice!(0, 'Bearer '.length) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index c1bea5a5e..271765acd 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -67,7 +67,7 @@ def convert_exts # get current user host address def cur_user_host_address(user_address) - (user_address.nil? ? @@remote_ip : user_address).gsub(/[^0-9\-.a-zA-Z_=]/, '_'); + (user_address.nil? ? @@remote_ip : user_address).gsub(/[^0-9\-.a-zA-Z_=]/, '_') end # get the storage path of the given file @@ -158,7 +158,7 @@ def get_correct_name(file_name, user_address) def get_stored_files(user_address) directory = DocumentHelper.config_manager.storage_path.join(cur_user_host_address(user_address)) - arr = []; + arr = [] if Dir.exist?(directory) Dir.foreach(directory) { |e| # run through all the elements from the folder @@ -282,7 +282,7 @@ def get_template_image_url(file_type) # get files information def get_files_info(file_id) - result = []; + result = [] for fileName in get_stored_files(nil) # run through all the stored files from the folder directory = storage_path(fileName, nil) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 17703e2e4..3c5ed65cd 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -45,7 +45,7 @@ class Users 'Can create files from templates using data from the editor', 'Can see the information about all users', 'Has an avatar', - ]; + ] @@descr_user_2 = [ 'Belongs to Group2', @@ -55,7 +55,7 @@ class Users 'Can create new files from the editor', 'Can see the information about users from Group2 and users who don’t belong to any group', 'Has an avatar', - ]; + ] @@descr_user_3 = [ 'Belongs to Group3', @@ -67,7 +67,7 @@ class Users 'Can’t print the file', 'Can create new files from the editor', 'Can see the information about Group2 users', - ]; + ] @@descr_user_0 = [ 'The name is requested when the editor is opened', @@ -82,7 +82,7 @@ class Users "Can't view chat", "Can't protect file", 'View file without collaboration' - ]; + ] @@users = [ User.new('uid-1', 'John Smith', 'smith@example.com', From f9375a74148b50bc93cb2d854fd79e4c7a8c5798 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 15:59:48 +0300 Subject: [PATCH 280/488] ruby: Style/SoleNestedConditional correct --- .../ruby/app/controllers/home_controller.rb | 4 +--- web/documentserver-example/ruby/app/models/document_helper.rb | 4 ++-- web/documentserver-example/ruby/app/models/file_model.rb | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 921c66db8..3e87e5a2a 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -190,14 +190,12 @@ def track user_address = params[:userAddress] file_name = File.basename(params[:fileName]) - if status == 1 # editing - if file_data['actions'][0]['type'] == 0 # finished edit + if status == 1 && (file_data['actions'][0]['type'] == 0) # finished edit user = file_data['actions'][0]['userid'] # get the user id if !file_data['users'].index(user) json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command end end - end if status == 2 || status == 3 # MustSave, Corrupted saved = TrackHelper.process_save(file_data, file_name, user_address) # save file diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 271765acd..746e921a8 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -98,8 +98,8 @@ def forcesave_path(file_name, user_address, create) end directory = File.join(directory, File.basename(file_name)) # get the path to the given file - unless File.file?(directory) - return '' if !create + if !File.file?(directory) && !create + return '' end return directory.to_s diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 6de54e575..1d9731cb8 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -215,8 +215,7 @@ def get_history obj['key'] = cur_key obj['version'] = i - if (i == 1) # check if the version number is equal to 1 - if File.file?(File.join(hist_dir, 'createdInfo.json')) # check if the createdInfo.json file with meta data exists + if (i == 1) && File.file?(File.join(hist_dir, 'createdInfo.json')) # check if the createdInfo.json file with meta data exists File.open(File.join(hist_dir, 'createdInfo.json'), 'r') do |file| # open it cr_info = JSON.parse(file.read()) # parse the file content @@ -228,7 +227,6 @@ def get_history } end end - end # get the history data from the previous file version and write key and url information about it dataObj['fileType'] = file_ext[1..file_ext.length] From b630764daf6dbaa43e41d3ca9d045b527eba2fea Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:02:59 +0300 Subject: [PATCH 281/488] ruby: Style/NegatedIf correct --- .../ruby/app/controllers/home_controller.rb | 8 ++++---- .../ruby/app/models/document_helper.rb | 2 +- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 3e87e5a2a..d1d9bf1c0 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -192,7 +192,7 @@ def track if status == 1 && (file_data['actions'][0]['type'] == 0) # finished edit user = file_data['actions'][0]['userid'] # get the user id - if !file_data['users'].index(user) + unless file_data['users'].index(user) json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command end end @@ -216,7 +216,7 @@ def track # removing a file def remove file_name = File.basename(params[:filename]) # get the file name - if !file_name # if it doesn't exist + unless file_name # if it doesn't exist render plain: '{"success":false}' # report that the operation is unsuccessful return end @@ -372,7 +372,7 @@ def reference link = body['link'] if fileName.empty? and body.key?('link') - if !link.include?(DocumentHelper.get_server_url(false)) + unless link.include?(DocumentHelper.get_server_url(false)) data = { url: link, directUrl: link @@ -384,7 +384,7 @@ def reference url_obj = URI(link) query_params = CGI.parse(url_obj.query) fileName = query_params['fileName'].first - if !File.exist?(DocumentHelper.storage_path(fileName, nil)) + unless File.exist?(DocumentHelper.storage_path(fileName, nil)) render plain: '{ "error": "File is not exist"}' return end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 746e921a8..d72710771 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -122,7 +122,7 @@ def version_dir(hist_dir, ver) # get the last file version def get_file_version(hist_dir) - return 1 if !Dir.exist?(hist_dir) + return 1 unless Dir.exist?(hist_dir) ver = 1 Dir.foreach(hist_dir) { |e| # run through all the file versions diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 1d9731cb8..471f75afa 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -349,7 +349,7 @@ def get_users_mentions def get_users_info users_info = [] - if !@user.id.eql?('uid-0') + unless @user.id.eql?('uid-0') Users.get_all_users().each do |user_info| u = { id: user_info.id, From 21d75418c251eb25f8817ea7d52a6474933de826 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:03:32 +0300 Subject: [PATCH 282/488] ruby: Style/MultipleComparison correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index d1d9bf1c0..6372fc3fb 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -197,13 +197,13 @@ def track end end - if status == 2 || status == 3 # MustSave, Corrupted + if [2, 3].include?(status) # MustSave, Corrupted saved = TrackHelper.process_save(file_data, file_name, user_address) # save file render plain: "{\"error\":#{saved.to_s}}" return end - if status == 6 || status == 7 # MustForceave, CorruptedForcesave + if [6, 7].include?(status) # MustForceave, CorruptedForcesave saved = TrackHelper.process_force_save(file_data, file_name, user_address) # force save file render plain: "{\"error\":#{saved.to_s}}" return From 23193739f798e6e1672e84472973e45049136475 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:04:41 +0300 Subject: [PATCH 283/488] ruby: Style/NonNilCheck correct --- .../ruby/app/controllers/home_controller.rb | 2 +- web/documentserver-example/ruby/app/models/document_helper.rb | 2 +- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- .../ruby/app/models/service_converter.rb | 4 ++-- web/documentserver-example/ruby/app/models/track_helper.rb | 2 +- web/documentserver-example/ruby/app/models/users.rb | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 6372fc3fb..e4949316e 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -264,7 +264,7 @@ def download user_address = params[:userAddress] isEmbedded = params[:dmode] - if JwtHelper.is_enabled && isEmbedded.nil? && user_address != nil && JwtHelper.use_for_request + if JwtHelper.is_enabled && isEmbedded.nil? && !user_address.nil? && JwtHelper.use_for_request jwtHeader = HomeController.config_manager.jwt_header if request.headers[jwtHeader] hdr = request.headers[jwtHeader] diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index d72710771..b0f1e463a 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -308,7 +308,7 @@ def get_files_info(file_id) end end - if file_id != nil + if !file_id.nil? return '"File not found"' else return result diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 471f75afa..5d9367182 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -379,6 +379,6 @@ def get_users_protect # get direct url existence flag def is_enable_direct_url - return @direct_url != nil && @direct_url == 'true' + return !@direct_url.nil? && @direct_url == 'true' end end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index d2c66ab71..a53a939a1 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -134,7 +134,7 @@ def get_response_data(json_data) file_result = json_data error_element = file_result['error'] - if error_element != nil # if an error occurs + if !error_element.nil? # if an error occurs process_convert_service_responce_error(error_element.to_i) # get an error message end @@ -161,7 +161,7 @@ def get_response_data(json_data) percent_element = file_result['percent'] # get the percentage value - result_percent = percent_element.to_i if percent_element != nil + result_percent = percent_element.to_i if !percent_element.nil? result_percent = result_percent >= 100 ? 99 : result_percent diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index da26e9239..097b7c370 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -241,7 +241,7 @@ def command_request(method, key, meta = nil) :key => key } - payload.merge!({ :meta => meta }) if (meta != nil) + payload.merge!({ :meta => meta }) if (!meta.nil?) data = nil begin diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 3c5ed65cd..f5eda73f1 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -124,7 +124,7 @@ def get_user(id) # get a user by id specified def get_users_for_mentions(id) # get a list of users with their names and emails for mentions usersData = [] for user in @@users do - usersData.push({ :name => user.name, :email => user.email }) if (!user.id.eql?(id) && user.name != nil && user.email != nil) + usersData.push({ :name => user.name, :email => user.email }) if (!user.id.eql?(id) && !user.name.nil? && !user.email.nil?) end return usersData end @@ -132,7 +132,7 @@ def get_users_for_mentions(id) # get a list of users with their names and emails def get_users_for_protect(id) # get a list of users with their id, names and emails for protect users_data = [] for user in @@users do - users_data.push({ id: user.id, name: user.name, email: user.email }) if (!user.id.eql?(id) && user.name != nil) + users_data.push({ id: user.id, name: user.name, email: user.email }) if (!user.id.eql?(id) && !user.name.nil?) end return users_data end From 1989c5f44d0095c87a7a3e2df6ca8665ca036229 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:05:53 +0300 Subject: [PATCH 284/488] ruby: Style/AccessorGrouping correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 3 +-- web/documentserver-example/ruby/app/models/track_helper.rb | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index b0f1e463a..eeae3083e 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -22,8 +22,7 @@ class DocumentHelper @format_manager = FormatManager.new class << self - attr_reader :config_manager - attr_reader :format_manager + attr_reader :config_manager, :format_manager end @@runtime_cache = {} diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 097b7c370..9759af987 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -24,8 +24,7 @@ class TrackHelper @proxy_manager = ProxyManager.new(config_manager: @config_manager) class << self - attr_reader :config_manager - attr_reader :proxy_manager + attr_reader :config_manager, :proxy_manager end @@document_command_url = TrackHelper.config_manager.document_server_command_uri.to_s From e9b4fce50b67c14ec2fc9f1aa5e8b00037e3f69c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:06:55 +0300 Subject: [PATCH 285/488] ruby: Style/GuardClause correct --- .../ruby/app/models/document_helper.rb | 28 +++++++++---------- .../ruby/app/models/file_model.rb | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index eeae3083e..7ea2b0a67 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -89,11 +89,11 @@ def forcesave_path(file_name, user_address, create) directory = File.join(directory, "#{File.basename(file_name)}-hist") # get the path to the history of the given file unless File.directory?(directory) - if create + return '' unless create FileUtils.mkdir_p(directory) # create history directory if it doesn't exist - else - return '' # the history directory doesn't exist and we are not supposed to create it - end + + # the history directory doesn't exist and we are not supposed to create it + end directory = File.join(directory, File.basename(file_name)) # get the path to the given file @@ -223,11 +223,11 @@ def get_historypath_uri(file_name, version, file, is_serverUrl = true) # get server url def get_server_url(for_document_server) - if for_document_server && DocumentHelper.config_manager.example_uri - return DocumentHelper.config_manager.example_uri.to_s - else + return DocumentHelper.config_manager.example_uri.to_s if for_document_server && DocumentHelper.config_manager.example_uri + + return @@base_url - end + end # get callback url @@ -307,19 +307,19 @@ def get_files_info(file_id) end end - if !file_id.nil? - return '"File not found"' - else + return '"File not found"' if !file_id.nil? + + return result - end + end # enable ignore certificate def verify_ssl(file_uri, http) - if file_uri.start_with?('https') && DocumentHelper.config_manager.ssl_verify_peer_mode_enabled + return unless file_uri.start_with?('https') && DocumentHelper.config_manager.ssl_verify_peer_mode_enabled http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session - end + end end end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 5d9367182..22038f819 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -349,7 +349,7 @@ def get_users_mentions def get_users_info users_info = [] - unless @user.id.eql?('uid-0') + return if @user.id.eql?('uid-0') Users.get_all_users().each do |user_info| u = { id: user_info.id, @@ -369,7 +369,7 @@ def get_users_info users_info.push(u) end return users_info - end + end # get users data for protect From 3df552b4b274bd8a0dd2f99231394c6de318f115 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:08:14 +0300 Subject: [PATCH 286/488] ruby: Style/BlockDelimiters correct --- .../ruby/app/models/document_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 7ea2b0a67..ff45ed5f6 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -124,14 +124,14 @@ def get_file_version(hist_dir) return 1 unless Dir.exist?(hist_dir) ver = 1 - Dir.foreach(hist_dir) { |e| # run through all the file versions + Dir.foreach(hist_dir) do |e| # run through all the file versions next if e.eql?('.') next if e.eql?('..') if File.directory?(File.join(hist_dir, e)) ver += 1 # and count them end - } + end return ver end @@ -160,13 +160,13 @@ def get_stored_files(user_address) arr = [] if Dir.exist?(directory) - Dir.foreach(directory) { |e| # run through all the elements from the folder + Dir.foreach(directory) do |e| # run through all the elements from the folder next if e.eql?('.') next if e.eql?('..') next if File.directory?(File.join(directory, e)) # if the element is a directory, skip it arr.push(e) # push the file to the array - } + end end return arr From 81a43656b2d411aa07825f8bacbd0792b469b5e2 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:08:52 +0300 Subject: [PATCH 287/488] ruby: Style/SelfAssignment correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index ff45ed5f6..68ca003b9 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -147,7 +147,7 @@ def get_correct_name(file_name, user_address) while File.exist?(storage_path(name, user_address)) # if the file with such a name already exists in this directory name = "#{base_name} (#{index.to_s})#{ext.downcase}" # add an index after its base name - index = index + 1 + index += 1 end name From 3247a75318e173d4766d2256e73d70cbd4ebe74e Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:09:49 +0300 Subject: [PATCH 288/488] ruby: Style/ConditionalAssignment correct --- .../ruby/app/models/document_helper.rb | 24 +++++++++---------- .../ruby/app/models/track_helper.rb | 8 +++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 68ca003b9..7fb0fd659 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -248,16 +248,16 @@ def get_download_url(file_name, is_serverUrl = true) # get internal file extension by its type def get_internal_extension(file_type) - case file_type + ext = case file_type when 'word' # .docx for word type - ext = '.docx' + '.docx' when 'cell' # .xlsx for cell type - ext = '.xlsx' + '.xlsx' when 'slide' # .pptx for slide type - ext = '.pptx' + '.pptx' else - ext = '.docx' # the default value is .docx - end + '.docx' # the default value is .docx + end ext end @@ -265,16 +265,16 @@ def get_internal_extension(file_type) # get image url for templates def get_template_image_url(file_type) path = "#{get_server_url(true)}/assets/" - case file_type + full_path = case file_type when 'word' # for word type - full_path = "#{path}file_docx.svg" + "#{path}file_docx.svg" when 'cell' # .xlsx for cell type - full_path = "#{path}file_xlsx.svg" + "#{path}file_xlsx.svg" when 'slide' # .pptx for slide type - full_path = "#{path}file_pptx.svg" + "#{path}file_pptx.svg" else - full_path = "#{path}file_docx.svg" # the default value is .docx - end + "#{path}file_docx.svg" # the default value is .docx + end full_path end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 9759af987..0e3d2d2d6 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -203,11 +203,11 @@ def process_force_save(file_data, file_name, user_address) is_submit_form = file_data['forcesavetype'].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) if is_submit_form - if new_file_name - file_name = DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists + file_name = if new_file_name + DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists else - file_name = DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) - end + DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) + end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) if new_file_name From 5171624adc402153913dbd4dd27231d087dcc649 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:10:50 +0300 Subject: [PATCH 289/488] ruby: Style/IfInsideElse correct --- .../ruby/app/models/document_helper.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 7fb0fd659..826aee305 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -299,11 +299,9 @@ def get_files_info(file_id) if file_id.nil? # if file id is undefined result.push(info) # push info object to the response array - else # if file id is defined - if file_id.eql?(info['id']) # and it is equal to the document key value - result.push(info) # response object will be equal to the info object - return result - end + elsif file_id.eql?(info['id']) # if file id is defined + result.push(info) # response object will be equal to the info object + return result # and it is equal to the document key value end end From 9b010f8315042adad1eb245306a143066b6436f2 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:11:23 +0300 Subject: [PATCH 290/488] ruby: Style/MethodCallWithoutArgsParentheses correct --- .../ruby/app/models/file_model.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 22038f819..6c2aa1c6e 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -109,7 +109,7 @@ def get_config ] config = { - :type => type(), + :type => type, :documentType => document_type, :document => { :title => @file_name, @@ -190,8 +190,8 @@ def get_config def get_history file_name = @file_name file_ext = File.extname(file_name).downcase - doc_key = key() - doc_uri = file_uri() + doc_key = key + doc_uri = file_uri hist_dir = DocumentHelper.history_dir(DocumentHelper.storage_path(@file_name, nil)) # get the path to the file history cur_ver = DocumentHelper.get_file_version(hist_dir) # get the file version @@ -209,7 +209,7 @@ def get_history cur_key = doc_key if (i != cur_ver) File.open(File.join(ver_dir, 'key.txt'), 'r') do |file| - cur_key = file.read() + cur_key = file.read end end obj['key'] = cur_key @@ -217,7 +217,7 @@ def get_history if (i == 1) && File.file?(File.join(hist_dir, 'createdInfo.json')) # check if the createdInfo.json file with meta data exists File.open(File.join(hist_dir, 'createdInfo.json'), 'r') do |file| # open it - cr_info = JSON.parse(file.read()) # parse the file content + cr_info = JSON.parse(file.read) # parse the file content # write information about changes to the object obj['created'] = cr_info['created'] @@ -241,7 +241,7 @@ def get_history changes = nil change = nil File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), 'changes.json'), 'r') do |file| # get the path to the changes.json file - changes = JSON.parse(file.read()) # and parse its content + changes = JSON.parse(file.read) # and parse its content end change = changes['changes'][0] @@ -350,7 +350,7 @@ def get_users_mentions def get_users_info users_info = [] return if @user.id.eql?('uid-0') - Users.get_all_users().each do |user_info| + Users.get_all_users.each do |user_info| u = { id: user_info.id, name: user_info.name, From f3cfdc353ed435e31fd98e1f255cdb1ea8bc1107 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:11:54 +0300 Subject: [PATCH 291/488] ruby: Style/MultilineTernaryOperator correct --- .../ruby/app/models/file_model.rb | 50 +++++++++++++++---- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 6c2aa1c6e..1a1e99615 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -148,10 +148,14 @@ def get_config :mode => mode, :lang => @lang ? @lang : 'en', :callbackUrl => callback_url, # absolute URL to the document storage service - :coEditing => editorsmode.eql?('view') && @user.id.eql?('uid-0') ? { + :coEditing => if editorsmode.eql?('view') && @user.id.eql?('uid-0') + { :mode => 'strict', :change => false - } : nil, + } +else + nil +end, :createUrl => !@user.id.eql?('uid-0') ? create_url : nil, :templates => @user.templates ? templates : nil, :user => { # the user currently viewing or editing the document @@ -253,16 +257,21 @@ def get_history obj['user'] = change ? change['user'] : nil prev = histData[(i - 2).to_s] # get the history data from the previous file version - dataObj['previous'] = is_enable_direct_url == true ? { # write key and url information about previous file version with optional direct url + # write key and url information about previous file version with optional direct url +dataObj['previous'] = if is_enable_direct_url == true + { # write key and url information about previous file version with optional direct url :fileType => prev['fileType'], :key => prev['key'], :url => prev['url'], :directUrl => prev['directUrl'] - } : { + } +else + { :fileType => prev['fileType'], :key => prev['key'], :url => prev['url'] } +end # write the path to the diff.zip archive with differences in this file version dataObj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') @@ -290,14 +299,21 @@ def get_history # get image information def get_insert_image - insert_image = is_enable_direct_url == true ? { + # image file type +# server url to the image +# direct url to the image +insert_image = if is_enable_direct_url == true + { :fileType => 'png', # image file type :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image - } : { + } +else + { :fileType => 'png', # image file type :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image } +end if JwtHelper.is_enabled # check if a secret key to generate token exists or not insert_image['token'] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object @@ -308,14 +324,21 @@ def get_insert_image # get compared file information def dataDocument - compare_file = is_enable_direct_url == true ? { + # file type +# server url to the compared file +# direct url to the compared file +compare_file = if is_enable_direct_url == true + { :fileType => 'docx', # file type :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file - } : { + } +else + { :fileType => 'docx', # file type :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file } +end if JwtHelper.is_enabled # check if a secret key to generate token exists or not compare_file['token'] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object @@ -326,14 +349,21 @@ def dataDocument # get mail merge recipients information def dataSpreadsheet - dataSpreadsheet = is_enable_direct_url == true ? { + # file type +# server url to the mail merge recipients file +# direct url to the mail merge recipients file +dataSpreadsheet = if is_enable_direct_url == true + { :fileType => 'csv', # file type :url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file - } : { + } +else + { :fileType => 'csv', # file type :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file } +end if JwtHelper.is_enabled # check if a secret key to generate token exists or not dataSpreadsheet['token'] = JwtHelper.encode(dataSpreadsheet) # encode a payload object into a token and write it to the dataSpreadsheet object From c350dd022fc52d82979293cd5beacca31ba804bd Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:12:30 +0300 Subject: [PATCH 292/488] ruby: Style/TrailingCommaInHashLiteral correct --- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 1a1e99615..b79f467d7 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -178,7 +178,7 @@ def get_config :submitForm => submitForm, # the Submit form button state :goback => { :url => DocumentHelper.get_server_url(false) - }, + } } } } From bd922d202e635f29baa40feef0944ff9b6fe337d Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:13:10 +0300 Subject: [PATCH 293/488] ruby: Style/ParenthesesAroundCondition correct --- web/documentserver-example/ruby/app/models/file_model.rb | 6 +++--- web/documentserver-example/ruby/app/models/track_helper.rb | 2 +- web/documentserver-example/ruby/app/models/users.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index b79f467d7..a58986773 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -200,7 +200,7 @@ def get_history hist_dir = DocumentHelper.history_dir(DocumentHelper.storage_path(@file_name, nil)) # get the path to the file history cur_ver = DocumentHelper.get_file_version(hist_dir) # get the file version - if (cur_ver > 0) # if file was modified + if cur_ver > 0 # if file was modified hist = [] histData = {} @@ -211,7 +211,7 @@ def get_history # get document key cur_key = doc_key - if (i != cur_ver) + if i != cur_ver File.open(File.join(ver_dir, 'key.txt'), 'r') do |file| cur_key = file.read end @@ -241,7 +241,7 @@ def get_history end dataObj['version'] = i - if (i > 1) # check if the version number is greater than 1 + if i > 1 # check if the version number is greater than 1 changes = nil change = nil File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), 'changes.json'), 'r') do |file| # get the path to the changes.json file diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 0e3d2d2d6..4679d4b15 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -240,7 +240,7 @@ def command_request(method, key, meta = nil) :key => key } - payload.merge!({ :meta => meta }) if (!meta.nil?) + payload.merge!({ :meta => meta }) if !meta.nil? data = nil begin diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index f5eda73f1..0064e95e4 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -124,7 +124,7 @@ def get_user(id) # get a user by id specified def get_users_for_mentions(id) # get a list of users with their names and emails for mentions usersData = [] for user in @@users do - usersData.push({ :name => user.name, :email => user.email }) if (!user.id.eql?(id) && !user.name.nil? && !user.email.nil?) + usersData.push({ :name => user.name, :email => user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? end return usersData end @@ -132,7 +132,7 @@ def get_users_for_mentions(id) # get a list of users with their names and emails def get_users_for_protect(id) # get a list of users with their id, names and emails for protect users_data = [] for user in @@users do - users_data.push({ id: user.id, name: user.name, email: user.email }) if (!user.id.eql?(id) && !user.name.nil?) + users_data.push({ id: user.id, name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? end return users_data end From 26fc316cee8b731c1b941adb06f7e8b31d49e806 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:15:09 +0300 Subject: [PATCH 294/488] ruby: Style/OrAssignment correct --- web/documentserver-example/ruby/app/models/track_helper.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 4679d4b15..c78eca5c7 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -138,9 +138,7 @@ def process_save(raw_file_data, file_name, user_address) save_file(change_data, File.join(ver_dir, 'diff.zip')) # save file with document versions differences hist_data = file_data['changeshistory'] - unless hist_data # if there are no changes in the history - hist_data = file_data['history'].to_json # write the original history information to the history data - end + hist_data ||= file_data['history'].to_json if hist_data File.open(File.join(ver_dir, 'changes.json'), 'wb') do |file| # open the file with document changes file.write(hist_data) # and write history data to this file From 7d6933803f5c3cdf4cecbae09370dbeee7957773 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:17:39 +0300 Subject: [PATCH 295/488] ruby: Style/TrailingCommaInArrayLiteral correct --- web/documentserver-example/ruby/app/models/users.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 0064e95e4..5e8f2c617 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -44,7 +44,7 @@ class Users 'The file favorite state is undefined', 'Can create files from templates using data from the editor', 'Can see the information about all users', - 'Has an avatar', + 'Has an avatar' ] @@descr_user_2 = [ @@ -54,7 +54,7 @@ class Users 'This file is marked as favorite', 'Can create new files from the editor', 'Can see the information about users from Group2 and users who don’t belong to any group', - 'Has an avatar', + 'Has an avatar' ] @@descr_user_3 = [ @@ -66,7 +66,7 @@ class Users 'Can’t download the file', 'Can’t print the file', 'Can create new files from the editor', - 'Can see the information about Group2 users', + 'Can see the information about Group2 users' ] @@descr_user_0 = [ From dd3b7ab07755d20903c18bfeff2fb2bc8d05c95a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:18:25 +0300 Subject: [PATCH 296/488] ruby: Style/WordArray correct --- web/documentserver-example/ruby/app/models/users.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 5e8f2c617..c3558f97f 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -98,12 +98,12 @@ class Users true, [], @@descr_user_2, false, true), User.new('uid-3', 'Hamish Mitchell', nil, 'group-3', ['group-2'], { - :view => ['group-3', 'group-2'], + :view => %w[group-3 group-2], :edit => ['group-2'], :remove => [] }, ['group-2'], - false, ['copy', 'download', 'print'], @@descr_user_3, false, false), + false, %w[copy download print], @@descr_user_3, false, false), User.new('uid-0', nil, nil, '', nil, {}, [], nil, ['protect'], @@descr_user_0, false, false) From d06bb98a6120d47e679c1e5947f02234d0d37b1a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:18:58 +0300 Subject: [PATCH 297/488] ruby: Style/DefWithParentheses correct --- web/documentserver-example/ruby/app/models/users.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index c3558f97f..830746369 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -110,7 +110,7 @@ class Users ] class << self - def get_all_users() # get a list of all the users + def get_all_users # get a list of all the users @@users end From c0d8e0e339215d988d172c9fe7a232c71b140616 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:52:29 +0300 Subject: [PATCH 298/488] ruby: Layout/IndentationWidth correct --- .../ruby/app/controllers/home_controller.rb | 2 +- .../ruby/app/models/document_helper.rb | 16 +-- .../ruby/app/models/file_model.rb | 112 +++++++++--------- .../ruby/app/models/service_converter.rb | 18 +-- .../ruby/app/models/track_helper.rb | 2 +- 5 files changed, 75 insertions(+), 75 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index e4949316e..9c7c6b9ae 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -191,7 +191,7 @@ def track file_name = File.basename(params[:fileName]) if status == 1 && (file_data['actions'][0]['type'] == 0) # finished edit - user = file_data['actions'][0]['userid'] # get the user id + user = file_data['actions'][0]['userid'] # get the user id unless file_data['users'].index(user) json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 826aee305..58514a948 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -250,13 +250,13 @@ def get_download_url(file_name, is_serverUrl = true) def get_internal_extension(file_type) ext = case file_type when 'word' # .docx for word type - '.docx' + '.docx' when 'cell' # .xlsx for cell type - '.xlsx' + '.xlsx' when 'slide' # .pptx for slide type - '.pptx' + '.pptx' else - '.docx' # the default value is .docx + '.docx' # the default value is .docx end ext @@ -267,13 +267,13 @@ def get_template_image_url(file_type) path = "#{get_server_url(true)}/assets/" full_path = case file_type when 'word' # for word type - "#{path}file_docx.svg" + "#{path}file_docx.svg" when 'cell' # .xlsx for cell type - "#{path}file_xlsx.svg" + "#{path}file_xlsx.svg" when 'slide' # .pptx for slide type - "#{path}file_pptx.svg" + "#{path}file_pptx.svg" else - "#{path}file_docx.svg" # the default value is .docx + "#{path}file_docx.svg" # the default value is .docx end full_path diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index a58986773..8fe62f0f7 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -149,10 +149,10 @@ def get_config :lang => @lang ? @lang : 'en', :callbackUrl => callback_url, # absolute URL to the document storage service :coEditing => if editorsmode.eql?('view') && @user.id.eql?('uid-0') - { - :mode => 'strict', - :change => false - } + { + :mode => 'strict', + :change => false + } else nil end, @@ -220,16 +220,16 @@ def get_history obj['version'] = i if (i == 1) && File.file?(File.join(hist_dir, 'createdInfo.json')) # check if the createdInfo.json file with meta data exists - File.open(File.join(hist_dir, 'createdInfo.json'), 'r') do |file| # open it - cr_info = JSON.parse(file.read) # parse the file content - - # write information about changes to the object - obj['created'] = cr_info['created'] - obj['user'] = { - :id => cr_info['uid'], - :name => cr_info['uname'] - } - end + File.open(File.join(hist_dir, 'createdInfo.json'), 'r') do |file| # open it + cr_info = JSON.parse(file.read) # parse the file content + + # write information about changes to the object + obj['created'] = cr_info['created'] + obj['user'] = { + :id => cr_info['uid'], + :name => cr_info['uname'] + } + end end # get the history data from the previous file version and write key and url information about it @@ -259,12 +259,12 @@ def get_history prev = histData[(i - 2).to_s] # get the history data from the previous file version # write key and url information about previous file version with optional direct url dataObj['previous'] = if is_enable_direct_url == true - { # write key and url information about previous file version with optional direct url - :fileType => prev['fileType'], - :key => prev['key'], - :url => prev['url'], - :directUrl => prev['directUrl'] - } + { # write key and url information about previous file version with optional direct url + :fileType => prev['fileType'], + :key => prev['key'], + :url => prev['url'], + :directUrl => prev['directUrl'] + } else { :fileType => prev['fileType'], @@ -302,18 +302,18 @@ def get_insert_image # image file type # server url to the image # direct url to the image -insert_image = if is_enable_direct_url == true - { - :fileType => 'png', # image file type - :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image - :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image - } -else - { - :fileType => 'png', # image file type - :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image - } -end + insert_image = if is_enable_direct_url == true + { + :fileType => 'png', # image file type + :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image + :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image + } + else + { + :fileType => 'png', # image file type + :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image + } + end if JwtHelper.is_enabled # check if a secret key to generate token exists or not insert_image['token'] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object @@ -327,18 +327,18 @@ def dataDocument # file type # server url to the compared file # direct url to the compared file -compare_file = if is_enable_direct_url == true - { - :fileType => 'docx', # file type - :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file - :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file - } -else - { - :fileType => 'docx', # file type - :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file - } -end + compare_file = if is_enable_direct_url == true + { + :fileType => 'docx', # file type + :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file + :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file + } + else + { + :fileType => 'docx', # file type + :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file + } + end if JwtHelper.is_enabled # check if a secret key to generate token exists or not compare_file['token'] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object @@ -352,18 +352,18 @@ def dataSpreadsheet # file type # server url to the mail merge recipients file # direct url to the mail merge recipients file -dataSpreadsheet = if is_enable_direct_url == true - { - :fileType => 'csv', # file type - :url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file - :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file - } -else - { - :fileType => 'csv', # file type - :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file - } -end + dataSpreadsheet = if is_enable_direct_url == true + { + :fileType => 'csv', # file type + :url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file + :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file + } + else + { + :fileType => 'csv', # file type + :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file + } + end if JwtHelper.is_enabled # check if a secret key to generate token exists or not dataSpreadsheet['token'] = JwtHelper.encode(dataSpreadsheet) # encode a payload object into a token and write it to the dataSpreadsheet object diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index a53a939a1..18f6b4996 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -105,25 +105,25 @@ def process_convert_service_responce_error(error_code) # add an error message to the error message template depending on the error code case error_code when -8 - error_message = 'Error occurred in the ConvertService.ashx: Error document VKey' + error_message = 'Error occurred in the ConvertService.ashx: Error document VKey' when -7 - error_message = 'Error occurred in the ConvertService.ashx: Error document request' + error_message = 'Error occurred in the ConvertService.ashx: Error document request' when -6 - error_message = 'Error occurred in the ConvertService.ashx: Error database' + error_message = 'Error occurred in the ConvertService.ashx: Error database' when -5 - error_message = 'Error occurred in the ConvertService.ashx: Incorrect password' + error_message = 'Error occurred in the ConvertService.ashx: Incorrect password' when -4 - error_message = 'Error occurred in the ConvertService.ashx: Error download error' + error_message = 'Error occurred in the ConvertService.ashx: Error download error' when -3 - error_message = 'Error occurred in the ConvertService.ashx: Error convertation error' + error_message = 'Error occurred in the ConvertService.ashx: Error convertation error' when -2 - error_message = 'Error occurred in the ConvertService.ashx: Error convertation timeout' + error_message = 'Error occurred in the ConvertService.ashx: Error convertation timeout' when -1 - error_message = 'Error occurred in the ConvertService.ashx: Error convertation unknown' + error_message = 'Error occurred in the ConvertService.ashx: Error convertation unknown' when 0 # public const int c_nErrorNo = 0 else - error_message = "ErrorCode = #{error_code.to_s}" # default value for the error message + error_message = "ErrorCode = #{error_code.to_s}" # default value for the error message end raise error_message diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index c78eca5c7..a72041aba 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -202,7 +202,7 @@ def process_force_save(file_data, file_name, user_address) if is_submit_form file_name = if new_file_name - DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists + DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists else DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) end From 42c2c93e8111e99830ab5c00babd0862098fc322 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:53:34 +0300 Subject: [PATCH 299/488] ruby: Layout/EndAlignment correct --- .../ruby/app/controllers/home_controller.rb | 2 +- .../ruby/app/models/file_model.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 9c7c6b9ae..1fe090c58 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -195,7 +195,7 @@ def track unless file_data['users'].index(user) json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command end - end + end if [2, 3].include?(status) # MustSave, Corrupted saved = TrackHelper.process_save(file_data, file_name, user_address) # save file diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 8fe62f0f7..5c5f1b7f6 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -155,7 +155,7 @@ def get_config } else nil -end, + end, :createUrl => !@user.id.eql?('uid-0') ? create_url : nil, :templates => @user.templates ? templates : nil, :user => { # the user currently viewing or editing the document @@ -230,7 +230,7 @@ def get_history :name => cr_info['uname'] } end - end + end # get the history data from the previous file version and write key and url information about it dataObj['fileType'] = file_ext[1..file_ext.length] @@ -271,7 +271,7 @@ def get_history :key => prev['key'], :url => prev['url'] } -end + end # write the path to the diff.zip archive with differences in this file version dataObj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') @@ -313,7 +313,7 @@ def get_insert_image :fileType => 'png', # image file type :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image } - end + end if JwtHelper.is_enabled # check if a secret key to generate token exists or not insert_image['token'] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object @@ -338,7 +338,7 @@ def dataDocument :fileType => 'docx', # file type :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file } - end + end if JwtHelper.is_enabled # check if a secret key to generate token exists or not compare_file['token'] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object @@ -363,7 +363,7 @@ def dataSpreadsheet :fileType => 'csv', # file type :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file } - end + end if JwtHelper.is_enabled # check if a secret key to generate token exists or not dataSpreadsheet['token'] = JwtHelper.encode(dataSpreadsheet) # encode a payload object into a token and write it to the dataSpreadsheet object From 97478679356a22ebf9cc7b12d8af9c3bf57c2665 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:54:06 +0300 Subject: [PATCH 300/488] ruby: Layout/CommentIndentation correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- .../ruby/app/models/document_helper.rb | 2 +- .../ruby/app/models/file_model.rb | 14 +++++++------- .../ruby/app/models/jwt_helper.rb | 12 ++++++------ .../ruby/app/models/track_helper.rb | 18 +++++++++--------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 1fe090c58..fa50be5f3 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -336,7 +336,7 @@ def saveas end end - # Rename... + # Rename... def rename body = JSON.parse(request.body.read) dockey = body['dockey'] @@ -354,7 +354,7 @@ def rename render plain: "{ \"result\" : \"#{JSON.dump(json_data)}\"}" end - # ReferenceData + # ReferenceData def reference body = JSON.parse(request.body.read) fileName = '' diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 58514a948..6024ffae7 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -92,7 +92,7 @@ def forcesave_path(file_name, user_address, create) return '' unless create FileUtils.mkdir_p(directory) # create history directory if it doesn't exist - # the history directory doesn't exist and we are not supposed to create it + # the history directory doesn't exist and we are not supposed to create it end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 5c5f1b7f6..fb27ce922 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -257,7 +257,7 @@ def get_history obj['user'] = change ? change['user'] : nil prev = histData[(i - 2).to_s] # get the history data from the previous file version - # write key and url information about previous file version with optional direct url +# write key and url information about previous file version with optional direct url dataObj['previous'] = if is_enable_direct_url == true { # write key and url information about previous file version with optional direct url :fileType => prev['fileType'], @@ -300,8 +300,8 @@ def get_history # get image information def get_insert_image # image file type -# server url to the image -# direct url to the image + # server url to the image + # direct url to the image insert_image = if is_enable_direct_url == true { :fileType => 'png', # image file type @@ -325,8 +325,8 @@ def get_insert_image # get compared file information def dataDocument # file type -# server url to the compared file -# direct url to the compared file + # server url to the compared file + # direct url to the compared file compare_file = if is_enable_direct_url == true { :fileType => 'docx', # file type @@ -350,8 +350,8 @@ def dataDocument # get mail merge recipients information def dataSpreadsheet # file type -# server url to the mail merge recipients file -# direct url to the mail merge recipients file + # server url to the mail merge recipients file + # direct url to the mail merge recipients file dataSpreadsheet = if is_enable_direct_url == true { :fileType => 'csv', # file type diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 6951c6ced..d50090c79 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -22,30 +22,30 @@ class JwtHelper @token_use_for_request = ConfigurationManager.new.jwt_use_for_request class << self - # check if a secret key to generate token exists or not + # check if a secret key to generate token exists or not def is_enabled return @jwt_secret && !@jwt_secret.empty? ? true : false end - # check if a secret key used for request + # check if a secret key used for request def use_for_request return @token_use_for_request end - # encode a payload object into a token using a secret key + # encode a payload object into a token using a secret key def encode(payload) return JWT.encode payload, @jwt_secret, 'HS256' # define the hashing algorithm and get token end - # decode a token into a payload object using a secret key + # decode a token into a payload object using a secret key def decode(token) begin decoded = JWT.decode token, @jwt_secret, true, { algorithm: 'HS256' } rescue return '' end - # decoded = Array [ {"data"=>"test"}, # payload - # {"alg"=>"HS256"} # header ] + # decoded = Array [ {"data"=>"test"}, # payload + # {"alg"=>"HS256"} # header ] return decoded[0].to_json # get json payload end end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index a72041aba..d5ab0d6b9 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -30,7 +30,7 @@ class << self @@document_command_url = TrackHelper.config_manager.document_server_command_uri.to_s class << self - # read the request body + # read the request body def read_body(request) body = request.body.read @@ -38,7 +38,7 @@ def read_body(request) file_data = JSON.parse(body) # parse file data - # check if a secret key to generate token exists or not + # check if a secret key to generate token exists or not if JwtHelper.is_enabled && JwtHelper.use_for_request inHeader = false token = nil @@ -87,7 +87,7 @@ def resolve_process_save_body(body) copied end - # file saving process + # file saving process def process_save(raw_file_data, file_name, user_address) file_data = resolve_process_save_body(raw_file_data) @@ -102,7 +102,7 @@ def process_save(raw_file_data, file_name, user_address) cur_ext = File.extname(file_name).downcase # get current file extension - # convert downloaded file to the file with the current extension if these extensions aren't equal + # convert downloaded file to the file with the current extension if these extensions aren't equal unless cur_ext.eql?(download_ext) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin @@ -163,7 +163,7 @@ def process_save(raw_file_data, file_name, user_address) saved end - # file force saving process + # file force saving process def process_force_save(file_data, file_name, user_address) download_uri = file_data['url'] if download_uri.eql?(nil) @@ -177,7 +177,7 @@ def process_force_save(file_data, file_name, user_address) new_file_name = false - # convert downloaded file to the file with the current extension if these extensions aren't equal + # convert downloaded file to the file with the current extension if these extensions aren't equal unless cur_ext.eql?(download_ext) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin @@ -230,9 +230,9 @@ def process_force_save(file_data, file_name, user_address) saved end - # send the command request + # send the command request def command_request(method, key, meta = nil) - # create a payload object with the method and key + # create a payload object with the method and key payload = { :c => method, :key => key @@ -267,7 +267,7 @@ def command_request(method, key, meta = nil) return json_data end - # save file from the url + # save file from the url def download_file(uristr) uri = URI.parse(uristr) # parse the url string http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server From 6ff7b4fa8f8be66682dec0eb202d74ac500e5803 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:56:34 +0300 Subject: [PATCH 301/488] ruby: Layout/EmptyLines correct --- .../ruby/app/controllers/home_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index fa50be5f3..1fd3a0c14 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -359,7 +359,6 @@ def reference body = JSON.parse(request.body.read) fileName = '' - if body.key?('referenceData') referenceData = body['referenceData'] instanceId = referenceData['instanceId'] From 8527ac602f315bc0f215ff5d9ce4d153a1fee4dc Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:57:05 +0300 Subject: [PATCH 302/488] ruby: Layout/EmptyLineAfterGuardClause correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 2 ++ web/documentserver-example/ruby/app/models/file_model.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 6024ffae7..41b9a5e8e 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -90,6 +90,7 @@ def forcesave_path(file_name, user_address, create) directory = File.join(directory, "#{File.basename(file_name)}-hist") # get the path to the history of the given file unless File.directory?(directory) return '' unless create + FileUtils.mkdir_p(directory) # create history directory if it doesn't exist # the history directory doesn't exist and we are not supposed to create it @@ -315,6 +316,7 @@ def get_files_info(file_id) # enable ignore certificate def verify_ssl(file_uri, http) return unless file_uri.start_with?('https') && DocumentHelper.config_manager.ssl_verify_peer_mode_enabled + http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index fb27ce922..3369a6bfd 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -380,6 +380,7 @@ def get_users_mentions def get_users_info users_info = [] return if @user.id.eql?('uid-0') + Users.get_all_users.each do |user_info| u = { id: user_info.id, From 5259cc19fa0e75184882ba97ead7ecd6ed9ba89e Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:57:29 +0300 Subject: [PATCH 303/488] ruby: Layout/IndentationConsistency correct --- .../ruby/app/controllers/home_controller.rb | 6 +- .../ruby/app/models/document_helper.rb | 12 ++-- .../ruby/app/models/file_model.rb | 66 +++++++++---------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 1fd3a0c14..caa8354d9 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -192,9 +192,9 @@ def track if status == 1 && (file_data['actions'][0]['type'] == 0) # finished edit user = file_data['actions'][0]['userid'] # get the user id - unless file_data['users'].index(user) - json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command - end + unless file_data['users'].index(user) + json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command + end end if [2, 3].include?(status) # MustSave, Corrupted diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 41b9a5e8e..256696bf2 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -91,7 +91,7 @@ def forcesave_path(file_name, user_address, create) unless File.directory?(directory) return '' unless create - FileUtils.mkdir_p(directory) # create history directory if it doesn't exist + FileUtils.mkdir_p(directory) # create history directory if it doesn't exist # the history directory doesn't exist and we are not supposed to create it @@ -227,7 +227,7 @@ def get_server_url(for_document_server) return DocumentHelper.config_manager.example_uri.to_s if for_document_server && DocumentHelper.config_manager.example_uri - return @@base_url + return @@base_url end @@ -302,14 +302,14 @@ def get_files_info(file_id) result.push(info) # push info object to the response array elsif file_id.eql?(info['id']) # if file id is defined result.push(info) # response object will be equal to the info object - return result # and it is equal to the document key value + return result # and it is equal to the document key value end end return '"File not found"' if !file_id.nil? - return result + return result end @@ -317,8 +317,8 @@ def get_files_info(file_id) def verify_ssl(file_uri, http) return unless file_uri.start_with?('https') && DocumentHelper.config_manager.ssl_verify_peer_mode_enabled - http.use_ssl = true - http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session end end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 3369a6bfd..e26a7da59 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -258,20 +258,20 @@ def get_history prev = histData[(i - 2).to_s] # get the history data from the previous file version # write key and url information about previous file version with optional direct url -dataObj['previous'] = if is_enable_direct_url == true - { # write key and url information about previous file version with optional direct url - :fileType => prev['fileType'], - :key => prev['key'], - :url => prev['url'], - :directUrl => prev['directUrl'] - } -else - { - :fileType => prev['fileType'], - :key => prev['key'], - :url => prev['url'] - } - end + dataObj['previous'] = if is_enable_direct_url == true + { # write key and url information about previous file version with optional direct url + :fileType => prev['fileType'], + :key => prev['key'], + :url => prev['url'], + :directUrl => prev['directUrl'] + } + else + { + :fileType => prev['fileType'], + :key => prev['key'], + :url => prev['url'] + } + end # write the path to the diff.zip archive with differences in this file version dataObj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') @@ -381,25 +381,25 @@ def get_users_info users_info = [] return if @user.id.eql?('uid-0') - Users.get_all_users.each do |user_info| - u = { - id: user_info.id, - name: user_info.name, - email: user_info.email, - group: user_info.group, - reviewGroups: user_info.reviewGroups, - commentGroups: user_info.commentGroups, - userInfoGroups: user_info.userInfoGroups, - favorite: user_info.favorite, - deniedPermissions: user_info.deniedPermissions, - descriptions: user_info.descriptions, - templates: user_info.templates, - avatar: user_info.avatar - } - u['image'] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil - users_info.push(u) - end - return users_info + Users.get_all_users.each do |user_info| + u = { + id: user_info.id, + name: user_info.name, + email: user_info.email, + group: user_info.group, + reviewGroups: user_info.reviewGroups, + commentGroups: user_info.commentGroups, + userInfoGroups: user_info.userInfoGroups, + favorite: user_info.favorite, + deniedPermissions: user_info.deniedPermissions, + descriptions: user_info.descriptions, + templates: user_info.templates, + avatar: user_info.avatar + } + u['image'] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil + users_info.push(u) + end + return users_info end From dccc970fa16baaedd949a06d43a97b10985684f7 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:58:00 +0300 Subject: [PATCH 304/488] ruby: Layout/TrailingWhitespace correct --- .../ruby/app/models/document_helper.rb | 18 +++++++++--------- .../ruby/app/models/file_model.rb | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 256696bf2..64fa559a6 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -92,9 +92,9 @@ def forcesave_path(file_name, user_address, create) return '' unless create FileUtils.mkdir_p(directory) # create history directory if it doesn't exist - + # the history directory doesn't exist and we are not supposed to create it - + end directory = File.join(directory, File.basename(file_name)) # get the path to the given file @@ -225,10 +225,10 @@ def get_historypath_uri(file_name, version, file, is_serverUrl = true) # get server url def get_server_url(for_document_server) return DocumentHelper.config_manager.example_uri.to_s if for_document_server && DocumentHelper.config_manager.example_uri - - + + return @@base_url - + end # get callback url @@ -307,10 +307,10 @@ def get_files_info(file_id) end return '"File not found"' if !file_id.nil? - - + + return result - + end # enable ignore certificate @@ -319,7 +319,7 @@ def verify_ssl(file_uri, http) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session - + end end end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index e26a7da59..5c3687057 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -400,7 +400,7 @@ def get_users_info users_info.push(u) end return users_info - + end # get users data for protect From de5fc508f2d2b3590a2d84b8370500b09ebc4ab2 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:58:24 +0300 Subject: [PATCH 305/488] ruby: Layout/CaseIndentation correct --- .../ruby/app/models/document_helper.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 64fa559a6..847c4dda0 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -250,11 +250,11 @@ def get_download_url(file_name, is_serverUrl = true) # get internal file extension by its type def get_internal_extension(file_type) ext = case file_type - when 'word' # .docx for word type + when 'word' # .docx for word type '.docx' - when 'cell' # .xlsx for cell type + when 'cell' # .xlsx for cell type '.xlsx' - when 'slide' # .pptx for slide type + when 'slide' # .pptx for slide type '.pptx' else '.docx' # the default value is .docx @@ -267,11 +267,11 @@ def get_internal_extension(file_type) def get_template_image_url(file_type) path = "#{get_server_url(true)}/assets/" full_path = case file_type - when 'word' # for word type + when 'word' # for word type "#{path}file_docx.svg" - when 'cell' # .xlsx for cell type + when 'cell' # .xlsx for cell type "#{path}file_xlsx.svg" - when 'slide' # .pptx for slide type + when 'slide' # .pptx for slide type "#{path}file_pptx.svg" else "#{path}file_docx.svg" # the default value is .docx From 27267e2d5bedc8a8fd85b35560e63ba594cf0cc3 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:58:59 +0300 Subject: [PATCH 306/488] ruby: Layout/ElseAlignment correct --- .../ruby/app/models/document_helper.rb | 4 ++-- .../ruby/app/models/file_model.rb | 10 +++++----- .../ruby/app/models/service_converter.rb | 2 +- .../ruby/app/models/track_helper.rb | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 847c4dda0..4db34c642 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -256,7 +256,7 @@ def get_internal_extension(file_type) '.xlsx' when 'slide' # .pptx for slide type '.pptx' - else + else '.docx' # the default value is .docx end @@ -273,7 +273,7 @@ def get_template_image_url(file_type) "#{path}file_xlsx.svg" when 'slide' # .pptx for slide type "#{path}file_pptx.svg" - else + else "#{path}file_docx.svg" # the default value is .docx end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 5c3687057..6645ab828 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -153,7 +153,7 @@ def get_config :mode => 'strict', :change => false } -else + else nil end, :createUrl => !@user.id.eql?('uid-0') ? create_url : nil, @@ -265,7 +265,7 @@ def get_history :url => prev['url'], :directUrl => prev['directUrl'] } - else + else { :fileType => prev['fileType'], :key => prev['key'], @@ -308,7 +308,7 @@ def get_insert_image :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image } - else + else { :fileType => 'png', # image file type :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image @@ -333,7 +333,7 @@ def dataDocument :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file } - else + else { :fileType => 'docx', # file type :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file @@ -358,7 +358,7 @@ def dataSpreadsheet :url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file } - else + else { :fileType => 'csv', # file type :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 18f6b4996..c325b3bef 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -122,7 +122,7 @@ def process_convert_service_responce_error(error_code) error_message = 'Error occurred in the ConvertService.ashx: Error convertation unknown' when 0 # public const int c_nErrorNo = 0 - else + else error_message = "ErrorCode = #{error_code.to_s}" # default value for the error message end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index d5ab0d6b9..83e32577b 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -203,7 +203,7 @@ def process_force_save(file_data, file_name, user_address) if is_submit_form file_name = if new_file_name DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists - else + else DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file From 79b98bed53cd4912141814321d13ac544cc29ab0 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 16:59:24 +0300 Subject: [PATCH 307/488] ruby: Layout/FirstHashElementIndentation correct --- .../ruby/app/models/file_model.rb | 36 +++++++++---------- .../ruby/app/models/users.rb | 8 ++--- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 6645ab828..4ff4c56a4 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -150,9 +150,9 @@ def get_config :callbackUrl => callback_url, # absolute URL to the document storage service :coEditing => if editorsmode.eql?('view') && @user.id.eql?('uid-0') { - :mode => 'strict', + :mode => 'strict', :change => false - } + } else nil end, @@ -260,17 +260,17 @@ def get_history # write key and url information about previous file version with optional direct url dataObj['previous'] = if is_enable_direct_url == true { # write key and url information about previous file version with optional direct url - :fileType => prev['fileType'], + :fileType => prev['fileType'], :key => prev['key'], :url => prev['url'], :directUrl => prev['directUrl'] - } + } else { - :fileType => prev['fileType'], + :fileType => prev['fileType'], :key => prev['key'], :url => prev['url'] - } + } end # write the path to the diff.zip archive with differences in this file version @@ -304,15 +304,15 @@ def get_insert_image # direct url to the image insert_image = if is_enable_direct_url == true { - :fileType => 'png', # image file type + :fileType => 'png', # image file type :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image - } + } else { - :fileType => 'png', # image file type + :fileType => 'png', # image file type :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image - } + } end if JwtHelper.is_enabled # check if a secret key to generate token exists or not @@ -329,15 +329,15 @@ def dataDocument # direct url to the compared file compare_file = if is_enable_direct_url == true { - :fileType => 'docx', # file type + :fileType => 'docx', # file type :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file - } + } else { - :fileType => 'docx', # file type + :fileType => 'docx', # file type :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file - } + } end if JwtHelper.is_enabled # check if a secret key to generate token exists or not @@ -354,15 +354,15 @@ def dataSpreadsheet # direct url to the mail merge recipients file dataSpreadsheet = if is_enable_direct_url == true { - :fileType => 'csv', # file type + :fileType => 'csv', # file type :url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file - } + } else { - :fileType => 'csv', # file type + :fileType => 'csv', # file type :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file - } + } end if JwtHelper.is_enabled # check if a secret key to generate token exists or not diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 830746369..d11934c62 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -90,18 +90,18 @@ class Users nil, [], @@descr_user_1, true, true), User.new('uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', ['group-2', ''], { - :view => '', + :view => '', :edit => ['group-2', ''], :remove => ['group-2'] - }, + }, ['group-2', ''], true, [], @@descr_user_2, false, true), User.new('uid-3', 'Hamish Mitchell', nil, 'group-3', ['group-2'], { - :view => %w[group-3 group-2], + :view => %w[group-3 group-2], :edit => ['group-2'], :remove => [] - }, + }, ['group-2'], false, %w[copy download print], @@descr_user_3, false, false), User.new('uid-0', nil, nil, From a17819efb22625533a5b90e3e9a92e725c8c2a37 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 17:03:09 +0300 Subject: [PATCH 308/488] ruby: Layout/RescueEnsureAlignment correct --- .../ruby/app/models/jwt_helper.rb | 2 +- .../ruby/app/models/track_helper.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index d50090c79..d206d5fbb 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -41,7 +41,7 @@ def encode(payload) def decode(token) begin decoded = JWT.decode token, @jwt_secret, true, { algorithm: 'HS256' } - rescue + rescue return '' end # decoded = Array [ {"data"=>"test"}, # payload diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 83e32577b..a287aa90c 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -112,7 +112,7 @@ def process_save(raw_file_data, file_name, user_address) else download_uri = new_file_uri end - rescue StandardError => msg + rescue StandardError => msg new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) end end @@ -156,7 +156,7 @@ def process_save(raw_file_data, file_name, user_address) end saved = 0 - rescue StandardError => msg + rescue StandardError => msg saved = 1 end @@ -187,7 +187,7 @@ def process_force_save(file_data, file_name, user_address) else download_uri = new_file_uri end - rescue StandardError => msg + rescue StandardError => msg new_file_name = true end end @@ -223,7 +223,7 @@ def process_force_save(file_data, file_name, user_address) end saved = 0 - rescue StandardError => msg + rescue StandardError => msg saved = 1 end @@ -259,7 +259,7 @@ def command_request(method, key, meta = nil) req.body = payload.to_json # convert the payload object into the json format res = http.request(req) # get the response data = res.body # and take its body - rescue => ex + rescue => ex raise ex.message end From d1b972fb1826abc2c06ab4d403c1779f8b242611 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 17:03:44 +0300 Subject: [PATCH 309/488] ruby: Layout/HashAlignment correct --- .../ruby/app/models/file_model.rb | 30 +++++++++---------- .../ruby/app/models/track_helper.rb | 2 +- .../ruby/app/models/users.rb | 8 ++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 4ff4c56a4..bac883289 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -151,7 +151,7 @@ def get_config :coEditing => if editorsmode.eql?('view') && @user.id.eql?('uid-0') { :mode => 'strict', - :change => false + :change => false } else nil @@ -261,15 +261,15 @@ def get_history dataObj['previous'] = if is_enable_direct_url == true { # write key and url information about previous file version with optional direct url :fileType => prev['fileType'], - :key => prev['key'], - :url => prev['url'], - :directUrl => prev['directUrl'] + :key => prev['key'], + :url => prev['url'], + :directUrl => prev['directUrl'] } else { :fileType => prev['fileType'], - :key => prev['key'], - :url => prev['url'] + :key => prev['key'], + :url => prev['url'] } end @@ -305,13 +305,13 @@ def get_insert_image insert_image = if is_enable_direct_url == true { :fileType => 'png', # image file type - :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image - :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image + :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image + :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image } else { :fileType => 'png', # image file type - :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image + :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image } end @@ -330,13 +330,13 @@ def dataDocument compare_file = if is_enable_direct_url == true { :fileType => 'docx', # file type - :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file - :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file + :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file + :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file } else { :fileType => 'docx', # file type - :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file + :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file } end @@ -355,13 +355,13 @@ def dataSpreadsheet dataSpreadsheet = if is_enable_direct_url == true { :fileType => 'csv', # file type - :url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file - :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file + :url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file + :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file } else { :fileType => 'csv', # file type - :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file + :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file } end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index a287aa90c..271139021 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -235,7 +235,7 @@ def command_request(method, key, meta = nil) # create a payload object with the method and key payload = { :c => method, - :key => key + :key => key } payload.merge!({ :meta => meta }) if !meta.nil? diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index d11934c62..480cd6bcf 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -91,16 +91,16 @@ class Users User.new('uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', ['group-2', ''], { :view => '', - :edit => ['group-2', ''], - :remove => ['group-2'] + :edit => ['group-2', ''], + :remove => ['group-2'] }, ['group-2', ''], true, [], @@descr_user_2, false, true), User.new('uid-3', 'Hamish Mitchell', nil, 'group-3', ['group-2'], { :view => %w[group-3 group-2], - :edit => ['group-2'], - :remove => [] + :edit => ['group-2'], + :remove => [] }, ['group-2'], false, %w[copy download print], @@descr_user_3, false, false), From bb4e2b3b465f83f863abb9cb6df4eee57271edb0 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 17:04:08 +0300 Subject: [PATCH 310/488] ruby: Layout/ExtraSpacing correct --- web/documentserver-example/ruby/app/models/track_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 271139021..59ce970ab 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -276,7 +276,7 @@ def download_file(uristr) DocumentHelper.verify_ssl(uristr, http) req = Net::HTTP::Get.new(uri) - res = http.request(req) # get the response + res = http.request(req) # get the response status_code = res.code raise "Document editing service returned status: #{status_code}" if status_code != '200' # checking status code From 4e685d9eabff68181587e94b7f020005e4400c09 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 17:04:34 +0300 Subject: [PATCH 311/488] ruby: Layout/ArrayAlignment correct --- .../ruby/app/models/users.rb | 102 +++++++++--------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 480cd6bcf..85a019a04 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -38,75 +38,75 @@ def initialize(id, name, email, group, reviewGroups, commentGroups, userInfoGrou class Users @@descr_user_1 = [ 'File author by default', - 'Doesn’t belong to any group', - 'Can review all the changes', - 'Can perform all actions with comments', - 'The file favorite state is undefined', - 'Can create files from templates using data from the editor', - 'Can see the information about all users', - 'Has an avatar' + 'Doesn’t belong to any group', + 'Can review all the changes', + 'Can perform all actions with comments', + 'The file favorite state is undefined', + 'Can create files from templates using data from the editor', + 'Can see the information about all users', + 'Has an avatar' ] @@descr_user_2 = [ 'Belongs to Group2', - 'Can review only his own changes or changes made by users with no group', - 'Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only', - 'This file is marked as favorite', - 'Can create new files from the editor', - 'Can see the information about users from Group2 and users who don’t belong to any group', - 'Has an avatar' + 'Can review only his own changes or changes made by users with no group', + 'Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only', + 'This file is marked as favorite', + 'Can create new files from the editor', + 'Can see the information about users from Group2 and users who don’t belong to any group', + 'Has an avatar' ] @@descr_user_3 = [ 'Belongs to Group3', - 'Can review changes made by Group2 users', - 'Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users', - 'This file isn’t marked as favorite', - 'Can’t copy data from the file to clipboard', - 'Can’t download the file', - 'Can’t print the file', - 'Can create new files from the editor', - 'Can see the information about Group2 users' + 'Can review changes made by Group2 users', + 'Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users', + 'This file isn’t marked as favorite', + 'Can’t copy data from the file to clipboard', + 'Can’t download the file', + 'Can’t print the file', + 'Can create new files from the editor', + 'Can see the information about Group2 users' ] @@descr_user_0 = [ 'The name is requested when the editor is opened', - 'Doesn’t belong to any group', - 'Can review all the changes', - 'Can perform all actions with comments', - 'The file favorite state is undefined', - "Can't mention others in comments", - "Can't create new files from the editor", - 'Can’t see anyone’s information', - "Can't rename files from the editor", - "Can't view chat", - "Can't protect file", - 'View file without collaboration' + 'Doesn’t belong to any group', + 'Can review all the changes', + 'Can perform all actions with comments', + 'The file favorite state is undefined', + "Can't mention others in comments", + "Can't create new files from the editor", + 'Can’t see anyone’s information', + "Can't rename files from the editor", + "Can't view chat", + "Can't protect file", + 'View file without collaboration' ] @@users = [ User.new('uid-1', 'John Smith', 'smith@example.com', '', nil, {}, nil, nil, [], @@descr_user_1, true, true), - User.new('uid-2', 'Mark Pottato', 'pottato@example.com', - 'group-2', ['group-2', ''], { - :view => '', - :edit => ['group-2', ''], - :remove => ['group-2'] - }, - ['group-2', ''], - true, [], @@descr_user_2, false, true), - User.new('uid-3', 'Hamish Mitchell', nil, - 'group-3', ['group-2'], { - :view => %w[group-3 group-2], - :edit => ['group-2'], - :remove => [] - }, - ['group-2'], - false, %w[copy download print], @@descr_user_3, false, false), - User.new('uid-0', nil, nil, - '', nil, {}, [], - nil, ['protect'], @@descr_user_0, false, false) + User.new('uid-2', 'Mark Pottato', 'pottato@example.com', + 'group-2', ['group-2', ''], { + :view => '', + :edit => ['group-2', ''], + :remove => ['group-2'] + }, + ['group-2', ''], + true, [], @@descr_user_2, false, true), + User.new('uid-3', 'Hamish Mitchell', nil, + 'group-3', ['group-2'], { + :view => %w[group-3 group-2], + :edit => ['group-2'], + :remove => [] + }, + ['group-2'], + false, %w[copy download print], @@descr_user_3, false, false), + User.new('uid-0', nil, nil, + '', nil, {}, [], + nil, ['protect'], @@descr_user_0, false, false) ] class << self From 4c92c1c750d9bd4e44a28028b14d3fa17ea1ce0e Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 17:08:38 +0300 Subject: [PATCH 312/488] ruby: Layout/IndentationWidth correct --- .../ruby/app/models/document_helper.rb | 16 ++++----- .../ruby/app/models/file_model.rb | 36 +++++++++---------- .../ruby/app/models/jwt_helper.rb | 2 +- .../ruby/app/models/track_helper.rb | 12 +++---- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 4db34c642..a3a6d9f47 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -251,13 +251,13 @@ def get_download_url(file_name, is_serverUrl = true) def get_internal_extension(file_type) ext = case file_type when 'word' # .docx for word type - '.docx' + '.docx' when 'cell' # .xlsx for cell type - '.xlsx' + '.xlsx' when 'slide' # .pptx for slide type - '.pptx' + '.pptx' else - '.docx' # the default value is .docx + '.docx' # the default value is .docx end ext @@ -268,13 +268,13 @@ def get_template_image_url(file_type) path = "#{get_server_url(true)}/assets/" full_path = case file_type when 'word' # for word type - "#{path}file_docx.svg" + "#{path}file_docx.svg" when 'cell' # .xlsx for cell type - "#{path}file_xlsx.svg" + "#{path}file_xlsx.svg" when 'slide' # .pptx for slide type - "#{path}file_pptx.svg" + "#{path}file_pptx.svg" else - "#{path}file_docx.svg" # the default value is .docx + "#{path}file_docx.svg" # the default value is .docx end full_path diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index bac883289..764bf5cc4 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -154,7 +154,7 @@ def get_config :change => false } else - nil + nil end, :createUrl => !@user.id.eql?('uid-0') ? create_url : nil, :templates => @user.templates ? templates : nil, @@ -266,11 +266,11 @@ def get_history :directUrl => prev['directUrl'] } else - { - :fileType => prev['fileType'], - :key => prev['key'], - :url => prev['url'] - } + { + :fileType => prev['fileType'], + :key => prev['key'], + :url => prev['url'] + } end # write the path to the diff.zip archive with differences in this file version @@ -309,10 +309,10 @@ def get_insert_image :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image } else - { - :fileType => 'png', # image file type - :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image - } + { + :fileType => 'png', # image file type + :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image + } end if JwtHelper.is_enabled # check if a secret key to generate token exists or not @@ -334,10 +334,10 @@ def dataDocument :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file } else - { - :fileType => 'docx', # file type - :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file - } + { + :fileType => 'docx', # file type + :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file + } end if JwtHelper.is_enabled # check if a secret key to generate token exists or not @@ -359,10 +359,10 @@ def dataSpreadsheet :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file } else - { - :fileType => 'csv', # file type - :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file - } + { + :fileType => 'csv', # file type + :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file + } end if JwtHelper.is_enabled # check if a secret key to generate token exists or not diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index d206d5fbb..a31e8b025 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -42,7 +42,7 @@ def decode(token) begin decoded = JWT.decode token, @jwt_secret, true, { algorithm: 'HS256' } rescue - return '' + return '' end # decoded = Array [ {"data"=>"test"}, # payload # {"alg"=>"HS256"} # header ] diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 59ce970ab..4920631c0 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -113,7 +113,7 @@ def process_save(raw_file_data, file_name, user_address) download_uri = new_file_uri end rescue StandardError => msg - new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) + new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) end end @@ -157,7 +157,7 @@ def process_save(raw_file_data, file_name, user_address) saved = 0 rescue StandardError => msg - saved = 1 + saved = 1 end saved @@ -188,7 +188,7 @@ def process_force_save(file_data, file_name, user_address) download_uri = new_file_uri end rescue StandardError => msg - new_file_name = true + new_file_name = true end end @@ -204,7 +204,7 @@ def process_force_save(file_data, file_name, user_address) file_name = if new_file_name DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists else - DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) + DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else @@ -224,7 +224,7 @@ def process_force_save(file_data, file_name, user_address) saved = 0 rescue StandardError => msg - saved = 1 + saved = 1 end saved @@ -260,7 +260,7 @@ def command_request(method, key, meta = nil) res = http.request(req) # get the response data = res.body # and take its body rescue => ex - raise ex.message + raise ex.message end json_data = JSON.parse(data) # convert the response body into the json format From 12aba3d66d4917a88ca047616033e94dc40e10f4 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 17:12:39 +0300 Subject: [PATCH 313/488] ruby: Layout/EmptyLines correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index a3a6d9f47..613973e11 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -226,7 +226,6 @@ def get_historypath_uri(file_name, version, file, is_serverUrl = true) def get_server_url(for_document_server) return DocumentHelper.config_manager.example_uri.to_s if for_document_server && DocumentHelper.config_manager.example_uri - return @@base_url end @@ -308,7 +307,6 @@ def get_files_info(file_id) return '"File not found"' if !file_id.nil? - return result end From 986eeefb4d405dacce709417e115ce6fc0a06eec Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 17:13:28 +0300 Subject: [PATCH 314/488] ruby: Layout/EmptyLinesAroundMethodBody correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 3 --- web/documentserver-example/ruby/app/models/file_model.rb | 1 - 2 files changed, 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 613973e11..f259e7470 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -227,7 +227,6 @@ def get_server_url(for_document_server) return DocumentHelper.config_manager.example_uri.to_s if for_document_server && DocumentHelper.config_manager.example_uri return @@base_url - end # get callback url @@ -308,7 +307,6 @@ def get_files_info(file_id) return '"File not found"' if !file_id.nil? return result - end # enable ignore certificate @@ -317,7 +315,6 @@ def verify_ssl(file_uri, http) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session - end end end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 764bf5cc4..12388a0c0 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -400,7 +400,6 @@ def get_users_info users_info.push(u) end return users_info - end # get users data for protect From 44445de6e7d528a2546dab186a3c217e5fa5eb25 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 14 Nov 2023 17:17:04 +0300 Subject: [PATCH 315/488] ruby: Layout/CommentIndentation correct --- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- web/documentserver-example/ruby/app/models/service_converter.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 12388a0c0..1d314efe6 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -257,7 +257,7 @@ def get_history obj['user'] = change ? change['user'] : nil prev = histData[(i - 2).to_s] # get the history data from the previous file version -# write key and url information about previous file version with optional direct url + # write key and url information about previous file version with optional direct url dataObj['previous'] = if is_enable_direct_url == true { # write key and url information about previous file version with optional direct url :fileType => prev['fileType'], diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index c325b3bef..690e557a8 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -121,7 +121,7 @@ def process_convert_service_responce_error(error_code) when -1 error_message = 'Error occurred in the ConvertService.ashx: Error convertation unknown' when 0 - # public const int c_nErrorNo = 0 + # public const int c_nErrorNo = 0 else error_message = "ErrorCode = #{error_code.to_s}" # default value for the error message end From 286fb47fb86af04a87114d9f257fab6e013a878b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 10:44:48 +0300 Subject: [PATCH 316/488] ruby: Lint/RedundantStringCoercion correct --- .../ruby/app/controllers/home_controller.rb | 6 +++--- .../ruby/app/models/document_helper.rb | 6 +++--- .../ruby/app/models/service_converter.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index caa8354d9..46bc638c3 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -100,7 +100,7 @@ def convert # if the conversion isn't completed, write file name and step values to the response if percent != 100 - render plain: "{ \"step\" : \"#{percent.to_s}\", \"filename\" : \"#{file_name}\"}" + render plain: "{ \"step\" : \"#{percent}\", \"filename\" : \"#{file_name}\"}" return end @@ -199,13 +199,13 @@ def track if [2, 3].include?(status) # MustSave, Corrupted saved = TrackHelper.process_save(file_data, file_name, user_address) # save file - render plain: "{\"error\":#{saved.to_s}}" + render plain: "{\"error\":#{saved}}" return end if [6, 7].include?(status) # MustForceave, CorruptedForcesave saved = TrackHelper.process_force_save(file_data, file_name, user_address) # force save file - render plain: "{\"error\":#{saved.to_s}}" + render plain: "{\"error\":#{saved}}" return end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index f259e7470..cbe4141b6 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -147,7 +147,7 @@ def get_correct_name(file_name, user_address) index = 1 while File.exist?(storage_path(name, user_address)) # if the file with such a name already exists in this directory - name = "#{base_name} (#{index.to_s})#{ext.downcase}" # add an index after its base name + name = "#{base_name} (#{index})#{ext.downcase}" # add an index after its base name index += 1 end @@ -209,7 +209,7 @@ def create_demo(file_ext, sample, user) # get file url def get_file_uri(file_name, for_document_server) - uri = "#{get_server_url(for_document_server)}/#{DocumentHelper.config_manager.storage_path.to_s}/#{cur_user_host_address(nil)}/#{ERB::Util.url_encode(file_name)}" + uri = "#{get_server_url(for_document_server)}/#{DocumentHelper.config_manager.storage_path}/#{cur_user_host_address(nil)}/#{ERB::Util.url_encode(file_name)}" return uri end @@ -218,7 +218,7 @@ def get_file_uri(file_name, for_document_server) def get_historypath_uri(file_name, version, file, is_serverUrl = true) # for redirection to my link user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' - uri = "#{get_server_url(is_serverUrl)}/downloadhistory/?fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version.to_s}&file=#{ERB::Util.url_encode(file)}#{user_host}" + uri = "#{get_server_url(is_serverUrl)}/downloadhistory/?fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}&file=#{ERB::Util.url_encode(file)}#{user_host}" return uri end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 690e557a8..e4111907a 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -123,7 +123,7 @@ def process_convert_service_responce_error(error_code) when 0 # public const int c_nErrorNo = 0 else - error_message = "ErrorCode = #{error_code.to_s}" # default value for the error message + error_message = "ErrorCode = #{error_code}" # default value for the error message end raise error_message From 3197702d7bb5b52ce15193bd48f18dd326b5586c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 10:51:15 +0300 Subject: [PATCH 317/488] ruby: Style/CommentedKeyword correct --- web/documentserver-example/ruby/app/models/users.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 85a019a04..3b886a272 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -110,26 +110,29 @@ class Users ] class << self - def get_all_users # get a list of all the users + def get_all_users @@users end - def get_user(id) # get a user by id specified + # get a user by id specified + def get_user(id) for user in @@users do return user if user.id.eql?(id) end return @@users[0] end - def get_users_for_mentions(id) # get a list of users with their names and emails for mentions + # get a list of users with their names and emails for mentions + def get_users_for_mentions(id) usersData = [] for user in @@users do usersData.push({ :name => user.name, :email => user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? end return usersData end - - def get_users_for_protect(id) # get a list of users with their id, names and emails for protect + + # get a list of users with their id, names and emails for protect + def get_users_for_protect(id) users_data = [] for user in @@users do users_data.push({ id: user.id, name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? From 6525c29107b02edcfb5a872c40caf9abe4aacd48 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 10:59:58 +0300 Subject: [PATCH 318/488] ruby: Style/NumericPredicate correct --- .../ruby/app/controllers/home_controller.rb | 2 +- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 46bc638c3..c7a6b4aa2 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -190,7 +190,7 @@ def track user_address = params[:userAddress] file_name = File.basename(params[:fileName]) - if status == 1 && (file_data['actions'][0]['type'] == 0) # finished edit + if status == 1 && ((file_data['actions'][0]['type']).zero?) # finished edit user = file_data['actions'][0]['userid'] # get the user id unless file_data['users'].index(user) json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 1d314efe6..337ab3676 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -200,7 +200,7 @@ def get_history hist_dir = DocumentHelper.history_dir(DocumentHelper.storage_path(@file_name, nil)) # get the path to the file history cur_ver = DocumentHelper.get_file_version(hist_dir) # get the file version - if cur_ver > 0 # if file was modified + if cur_ver.positive? # if file was modified hist = [] histData = {} From 56e96eeac169f92e1490d665c997b1047f512284 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 11:01:38 +0300 Subject: [PATCH 319/488] ruby: Style/Redundant correct --- .../ruby/app/controllers/home_controller.rb | 28 +++++++++---------- .../ruby/app/models/document_helper.rb | 18 ++++++------ .../ruby/app/models/file_model.rb | 26 ++++++++--------- .../ruby/app/models/jwt_helper.rb | 8 +++--- .../ruby/app/models/service_converter.rb | 4 +-- .../ruby/app/models/track_helper.rb | 4 +-- .../ruby/app/models/users.rb | 6 ++-- 7 files changed, 47 insertions(+), 47 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index c7a6b4aa2..3170a9887 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -81,15 +81,15 @@ def upload # converting a file def convert - begin + file_data = request.body.read return '' if file_data.nil? || file_data.empty? body = JSON.parse(file_data) file_name = File.basename(body['filename']) - lang = cookies[:ulang] ? cookies[:ulang] : 'en' - file_pass = body['filePass'] ? body['filePass'] : nil + lang = cookies[:ulang] || 'en' + file_pass = body['filePass'] || nil file_uri = DocumentHelper.get_download_url(file_name) extension = File.extname(file_name).downcase internal_extension = 'ooxml' @@ -135,12 +135,12 @@ def convert render plain: "{ \"filename\" : \"#{file_name}\"}" rescue => ex render plain: "{ \"error\": \"#{ex.message}\"}" - end + end # downloading a history file from public def downloadhistory - begin + file_name = File.basename(params[:fileName]) user_address = params[:userAddress] version = params[:ver] @@ -174,7 +174,7 @@ def downloadhistory send_file file_path, :x_sendfile => true rescue => ex render plain: '{ "error": "File not found"}' - end + end # tracking file changes @@ -210,7 +210,7 @@ def track end render plain: '{"error":0}' - return + nil end # removing a file @@ -234,7 +234,7 @@ def remove end render plain: '{"success":true}' # report that the operation is successful - return + nil end # getting files information @@ -259,7 +259,7 @@ def csv # downloading a file def download - begin + file_name = File.basename(params[:fileName]) user_address = params[:userAddress] isEmbedded = params[:dmode] @@ -290,12 +290,12 @@ def download send_file file_path, :x_sendfile => true rescue => ex render plain: '{ "error": "File not found"}' - end + end # Save Copy as... def saveas - begin + body = JSON.parse(request.body.read) file_url = body['url'] title = body['title'] @@ -329,11 +329,11 @@ def saveas DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file render plain: "{\"file\" : \"#{file_name}\"}" - return + nil rescue => ex render plain: "{\"error\":1, \"message\": \"#{ex.message}\"}" - return - end + nil + end # Rename... diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index cbe4141b6..fa1adcbb8 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -102,7 +102,7 @@ def forcesave_path(file_name, user_address, create) return '' end - return directory.to_s + directory.to_s end # get the path to the file history @@ -112,12 +112,12 @@ def history_dir(storage_path) # create history directory if it doesn't exist FileUtils.mkdir_p(directory) unless File.directory?(directory) - return directory + directory end # get the path to the specified file version def version_dir(hist_dir, ver) - return File.join(hist_dir, ver.to_s) + File.join(hist_dir, ver.to_s) end # get the last file version @@ -134,7 +134,7 @@ def get_file_version(hist_dir) end end - return ver + ver end # get the correct file name if such a name already exists @@ -170,7 +170,7 @@ def get_stored_files(user_address) end end - return arr + arr end # create file meta information @@ -211,7 +211,7 @@ def create_demo(file_ext, sample, user) def get_file_uri(file_name, for_document_server) uri = "#{get_server_url(for_document_server)}/#{DocumentHelper.config_manager.storage_path}/#{cur_user_host_address(nil)}/#{ERB::Util.url_encode(file_name)}" - return uri + uri end # get history path url @@ -219,14 +219,14 @@ def get_historypath_uri(file_name, version, file, is_serverUrl = true) # for redirection to my link user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' uri = "#{get_server_url(is_serverUrl)}/downloadhistory/?fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}&file=#{ERB::Util.url_encode(file)}#{user_host}" - return uri + uri end # get server url def get_server_url(for_document_server) return DocumentHelper.config_manager.example_uri.to_s if for_document_server && DocumentHelper.config_manager.example_uri - return @@base_url + @@base_url end # get callback url @@ -306,7 +306,7 @@ def get_files_info(file_id) return '"File not found"' if !file_id.nil? - return result + result end # enable ignore certificate diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 337ab3676..8f16e0fb8 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -34,7 +34,7 @@ def initialize(attributes = {}) end def type - @type ? @type : 'desktop' # the default platform type is desktop + @type || 'desktop' # the default platform type is desktop end # get file extension from its name @@ -61,7 +61,7 @@ def document_type def key uri = "#{DocumentHelper.cur_user_host_address(nil)}/#{@file_name}" # get current user host address stat = File.mtime(DocumentHelper.storage_path(@file_name, nil)) # get the modification time of the given file - return ServiceConverter.generate_revision_id("#{uri}.#{stat}") + ServiceConverter.generate_revision_id("#{uri}.#{stat}") end # get callback url @@ -86,7 +86,7 @@ def cur_user_host_address # get config parameters def get_config - editorsmode = @mode ? @mode : 'edit' # mode: view/edit/review/comment/fillForms/embedded + editorsmode = @mode || 'edit' # mode: view/edit/review/comment/fillForms/embedded canEdit = DocumentHelper.edited_exts.include?(file_ext) # check if the document can be edited if (!canEdit && editorsmode.eql?('edit') || editorsmode.eql?('fillForms')) && DocumentHelper.fill_forms_exts.include?(file_ext) editorsmode = 'fillForms' @@ -146,7 +146,7 @@ def get_config :editorConfig => { :actionLink => @action_data ? JSON.parse(@action_data) : nil, :mode => mode, - :lang => @lang ? @lang : 'en', + :lang => @lang || 'en', :callbackUrl => callback_url, # absolute URL to the document storage service :coEditing => if editorsmode.eql?('view') && @user.id.eql?('uid-0') { @@ -187,7 +187,7 @@ def get_config config['token'] = JwtHelper.encode(config) # encode a payload object into a token and write it to the config end - return config + config end # get document history @@ -294,7 +294,7 @@ def get_history } end - return nil + nil end # get image information @@ -319,7 +319,7 @@ def get_insert_image insert_image['token'] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object end - return insert_image.to_json.tr('{', '').tr('}', '') + insert_image.to_json.tr('{', '').tr('}', '') end # get compared file information @@ -344,7 +344,7 @@ def dataDocument compare_file['token'] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object end - return compare_file + compare_file end # get mail merge recipients information @@ -369,12 +369,12 @@ def dataSpreadsheet dataSpreadsheet['token'] = JwtHelper.encode(dataSpreadsheet) # encode a payload object into a token and write it to the dataSpreadsheet object end - return dataSpreadsheet + dataSpreadsheet end # get users data for mentions def get_users_mentions - return !@user.id.eql?('uid-0') ? Users.get_users_for_mentions(@user.id) : nil + !@user.id.eql?('uid-0') ? Users.get_users_for_mentions(@user.id) : nil end def get_users_info @@ -399,16 +399,16 @@ def get_users_info u['image'] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil users_info.push(u) end - return users_info + users_info end # get users data for protect def get_users_protect - return !@user.id.eql?('uid-0') ? Users.get_users_for_protect(@user.id) : nil + !@user.id.eql?('uid-0') ? Users.get_users_for_protect(@user.id) : nil end # get direct url existence flag def is_enable_direct_url - return !@direct_url.nil? && @direct_url == 'true' + !@direct_url.nil? && @direct_url == 'true' end end diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index a31e8b025..bdf2ea9a8 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -24,17 +24,17 @@ class JwtHelper class << self # check if a secret key to generate token exists or not def is_enabled - return @jwt_secret && !@jwt_secret.empty? ? true : false + @jwt_secret && !@jwt_secret.empty? ? true : false end # check if a secret key used for request def use_for_request - return @token_use_for_request + @token_use_for_request end # encode a payload object into a token using a secret key def encode(payload) - return JWT.encode payload, @jwt_secret, 'HS256' # define the hashing algorithm and get token + JWT.encode payload, @jwt_secret, 'HS256' # define the hashing algorithm and get token end # decode a token into a payload object using a secret key @@ -46,7 +46,7 @@ def decode(token) end # decoded = Array [ {"data"=>"test"}, # payload # {"alg"=>"HS256"} # header ] - return decoded[0].to_json # get json payload + decoded[0].to_json # get json payload end end end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index e4111907a..6d51af984 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -83,7 +83,7 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ end json_data = JSON.parse(data) # parse response body - return get_response_data(json_data) # get response url + get_response_data(json_data) # get response url end # generate the document key value @@ -167,7 +167,7 @@ def get_response_data(json_data) end - return result_percent, response_uri, response_file_type + [result_percent, response_uri, response_file_type] end end end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 4920631c0..88e94d523 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -61,7 +61,7 @@ def read_body(request) file_data = file_data['payload'] if inHeader end - return file_data + file_data end def resolve_process_save_body(body) @@ -264,7 +264,7 @@ def command_request(method, key, meta = nil) end json_data = JSON.parse(data) # convert the response body into the json format - return json_data + json_data end # save file from the url diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 3b886a272..719a9a24c 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -119,7 +119,7 @@ def get_user(id) for user in @@users do return user if user.id.eql?(id) end - return @@users[0] + @@users[0] end # get a list of users with their names and emails for mentions @@ -128,7 +128,7 @@ def get_users_for_mentions(id) for user in @@users do usersData.push({ :name => user.name, :email => user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? end - return usersData + usersData end # get a list of users with their id, names and emails for protect @@ -137,7 +137,7 @@ def get_users_for_protect(id) for user in @@users do users_data.push({ id: user.id, name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? end - return users_data + users_data end end end From 821df5c700a812fc57048bd31a509c15c8e432a1 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 11:03:48 +0300 Subject: [PATCH 320/488] ruby: Style/RescueStandardError correct --- .../ruby/app/controllers/home_controller.rb | 12 ++++++------ .../ruby/app/models/jwt_helper.rb | 2 +- .../ruby/app/models/service_converter.rb | 2 +- .../ruby/app/models/track_helper.rb | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 3170a9887..4ccf358ed 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -74,7 +74,7 @@ def upload DocumentHelper.create_meta(file_name, user.id, user.name, nil) render plain: "{ \"filename\": \"#{file_name}\", \"documentType\": \"#{document_type}\"}" # write a new file name to the response - rescue => ex + rescue StandardError => ex render plain: "{ \"error\": \"#{ex.message}\"}" # write an error message to the response end end @@ -133,7 +133,7 @@ def convert end render plain: "{ \"filename\" : \"#{file_name}\"}" - rescue => ex + rescue StandardError => ex render plain: "{ \"error\": \"#{ex.message}\"}" end @@ -172,7 +172,7 @@ def downloadhistory response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file)}" send_file file_path, :x_sendfile => true - rescue => ex + rescue StandardError => ex render plain: '{ "error": "File not found"}' end @@ -288,7 +288,7 @@ def download response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" send_file file_path, :x_sendfile => true - rescue => ex + rescue StandardError => ex render plain: '{ "error": "File not found"}' end @@ -330,7 +330,7 @@ def saveas render plain: "{\"file\" : \"#{file_name}\"}" nil - rescue => ex + rescue StandardError => ex render plain: "{\"error\":1, \"message\": \"#{ex.message}\"}" nil @@ -477,7 +477,7 @@ def restore error: nil, success: true } - rescue => error + rescue StandardError => error response.status = :internal_server_error render json: { error: error.message, diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index bdf2ea9a8..f97ebe801 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -41,7 +41,7 @@ def encode(payload) def decode(token) begin decoded = JWT.decode token, @jwt_secret, true, { algorithm: 'HS256' } - rescue + rescue StandardError return '' end # decoded = Array [ {"data"=>"test"}, # payload diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 6d51af984..9d33397f8 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -78,7 +78,7 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ data = res.body # and take its body rescue Timeout::Error # try again - rescue => ex + rescue StandardError => ex raise ex.message end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 88e94d523..6ed253089 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -259,7 +259,7 @@ def command_request(method, key, meta = nil) req.body = payload.to_json # convert the payload object into the json format res = http.request(req) # get the response data = res.body # and take its body - rescue => ex + rescue StandardError => ex raise ex.message end From b29b0c3fa59abb84ca5dedc1a2d60d3e3ee103c7 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 11:05:19 +0300 Subject: [PATCH 321/488] ruby: Style/AndOr correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 4ccf358ed..76501b7bd 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -370,7 +370,7 @@ def reference end link = body['link'] - if fileName.empty? and body.key?('link') + if fileName.empty? && body.key?('link') unless link.include?(DocumentHelper.get_server_url(false)) data = { url: link, @@ -389,7 +389,7 @@ def reference end end - if fileName.empty? and body.key?('path') + if fileName.empty? && body.key?('path') path = File.basename(body['path']) fileName = path if File.exist?(DocumentHelper.storage_path(path, nil)) end From a407b2b9c77d9f350fa58cab1997c662ccc42c7a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 11:06:03 +0300 Subject: [PATCH 322/488] ruby: Style/For correct --- .../ruby/app/models/document_helper.rb | 2 +- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- web/documentserver-example/ruby/app/models/users.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index fa1adcbb8..fd65c8422 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -282,7 +282,7 @@ def get_template_image_url(file_type) def get_files_info(file_id) result = [] - for fileName in get_stored_files(nil) # run through all the stored files from the folder + get_stored_files(nil).each do |fileName| # run through all the stored files from the folder directory = storage_path(fileName, nil) uri = "#{cur_user_host_address(nil)}/#{fileName}" diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 8f16e0fb8..2473427dd 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -204,7 +204,7 @@ def get_history hist = [] histData = {} - for i in 1..cur_ver # run through all the file versions + (1..cur_ver).each do |i| # run through all the file versions obj = {} dataObj = {} ver_dir = DocumentHelper.version_dir(hist_dir, i) # get the path to the given file version diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 719a9a24c..85fb40df2 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -116,7 +116,7 @@ def get_all_users # get a user by id specified def get_user(id) - for user in @@users do + @@users.each do |user| return user if user.id.eql?(id) end @@users[0] @@ -125,7 +125,7 @@ def get_user(id) # get a list of users with their names and emails for mentions def get_users_for_mentions(id) usersData = [] - for user in @@users do + @@users.each do |user| usersData.push({ :name => user.name, :email => user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? end usersData @@ -134,7 +134,7 @@ def get_users_for_mentions(id) # get a list of users with their id, names and emails for protect def get_users_for_protect(id) users_data = [] - for user in @@users do + @@users.each do |user| users_data.push({ id: user.id, name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? end users_data From 83843342d4e3926972a5b0759d49eb61855a61e3 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 11:07:09 +0300 Subject: [PATCH 323/488] ruby: Style/HashSyntax correct --- web/documentserver-example/ruby/Gemfile | 16 +- .../ruby/app/controllers/home_controller.rb | 36 ++-- .../ruby/app/models/document_helper.rb | 6 +- .../ruby/app/models/file_model.rb | 184 +++++++++--------- .../ruby/app/models/service_converter.rb | 18 +- .../ruby/app/models/track_helper.rb | 8 +- .../ruby/app/models/users.rb | 14 +- 7 files changed, 141 insertions(+), 141 deletions(-) diff --git a/web/documentserver-example/ruby/Gemfile b/web/documentserver-example/ruby/Gemfile index 656c32569..a31eca56b 100644 --- a/web/documentserver-example/ruby/Gemfile +++ b/web/documentserver-example/ruby/Gemfile @@ -1,24 +1,24 @@ source 'https://rubygems.org' -gem 'byebug', '~> 11.1', :groups => %i[development test] +gem 'byebug', '~> 11.1', groups: %i[development test] gem 'coffee-rails', '~> 5.0' -gem 'dalli', '~> 3.2', :group => :development +gem 'dalli', '~> 3.2', group: :development gem 'jbuilder', '~> 2.11' gem 'jquery-rails', '~> 4.5' gem 'jwt', '~> 2.7' gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f' gem 'rack-cors', '~> 2.0' gem 'rails', '~> 7.0.8' -gem 'rubocop', '~> 1.52', :group => :development +gem 'rubocop', '~> 1.52', group: :development gem 'sass-rails', '~> 6.0' -gem 'sdoc', '~> 2.6', :group => :doc +gem 'sdoc', '~> 2.6', group: :doc gem 'sorbet-runtime', '~> 0.5.10871' -gem 'test-unit', '~> 3.6', :groups => %i[development test] +gem 'test-unit', '~> 3.6', groups: %i[development test] gem 'turbolinks', '~> 5.2' gem 'tzinfo-data', '~> 1.2023' gem 'uglifier', '~> 4.2' gem 'uuid', '~> 2.3' -gem 'web-console', '~> 4.2', :groups => %i[development test] +gem 'web-console', '~> 4.2', groups: %i[development test] gem 'webrick', '~> 1.8' # Unfortunately, Sorbet only supports Darwin and Linux-based systems. @@ -28,6 +28,6 @@ gem 'webrick', '~> 1.8' # https://github.com/sorbet/sorbet/issues/4011 # https://github.com/sorbet/sorbet/issues/4119 install_if -> { RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /x86_64/ } do - gem 'sorbet', '~> 0.5.10871', :group => :development - gem 'tapioca', '~> 0.11.6', :group => :development + gem 'sorbet', '~> 0.5.10871', group: :development + gem 'tapioca', '~> 0.11.6', group: :development end diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 76501b7bd..246759ba6 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -31,7 +31,7 @@ def index; end def editor DocumentHelper.init(request.remote_ip, request.base_url) user = Users.get_user(params[:userId]) - @file = FileModel.new(:file_name => File.basename(params[:fileName]), :mode => params[:editorsMode], :type => params[:editorsType], :user_ip => request.remote_ip, :lang => cookies[:ulang], :user => user, :action_data => params[:actionLink], :direct_url => params[:directUrl]) + @file = FileModel.new(file_name: File.basename(params[:fileName]), mode: params[:editorsMode], type: params[:editorsType], user_ip: request.remote_ip, lang: cookies[:ulang], user:, action_data: params[:actionLink], direct_url: params[:directUrl]) end # creating a sample document @@ -39,7 +39,7 @@ def sample DocumentHelper.init(request.remote_ip, request.base_url) user = Users.get_user(params[:userId]) file_name = DocumentHelper.create_demo(params[:fileExt], params[:sample], user) - redirect_to :controller => 'home', :action => 'editor', :fileName => file_name, :userId => user.id + redirect_to controller: 'home', action: 'editor', fileName: file_name, userId: user.id end # uploading a file @@ -154,11 +154,11 @@ def downloadhistory hdr.slice!(0, 'Bearer '.length) token = JwtHelper.decode(hdr) if !token || token.eql?('') - render plain: 'JWT validation failed', :status => 403 + render plain: 'JWT validation failed', status: 403 return end else - render plain: 'JWT validation failed', :status => 403 + render plain: 'JWT validation failed', status: 403 return end end @@ -171,7 +171,7 @@ def downloadhistory response.headers['Content-Type'] = MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file)}" - send_file file_path, :x_sendfile => true + send_file file_path, x_sendfile: true rescue StandardError => ex render plain: '{ "error": "File not found"}' @@ -254,7 +254,7 @@ def csv response.headers['Content-Type'] = MimeMagic.by_path(csvPath).type response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" - send_file csvPath, :x_sendfile => true + send_file csvPath, x_sendfile: true end # downloading a file @@ -272,7 +272,7 @@ def download token = JwtHelper.decode(hdr) end if !token || token.eql?('') - render plain: 'JWT validation failed', :status => 403 + render plain: 'JWT validation failed', status: 403 return end end @@ -287,7 +287,7 @@ def download response.headers['Content-Type'] = MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" - send_file file_path, :x_sendfile => true + send_file file_path, x_sendfile: true rescue StandardError => ex render plain: '{ "error": "File not found"}' @@ -347,7 +347,7 @@ def rename newfilename += orig_ext if orig_ext != cur_ext meta = { - :title => newfilename + title: newfilename } json_data = TrackHelper.command_request('meta', dockey, meta) @@ -400,16 +400,16 @@ def reference end data = { - :fileType => File.extname(fileName).downcase.delete('.'), - :key => ServiceConverter.generate_revision_id("#{"#{DocumentHelper.cur_user_host_address(nil)}/#{fileName}"}.#{File.mtime(DocumentHelper.storage_path(fileName, nil))}"), - :url => DocumentHelper.get_download_url(fileName), - :directUrl => body['directUrl'] ? DocumentHelper.get_download_url(fileName, false) : nil, - :referenceData => { - :instanceId => DocumentHelper.get_server_url(false), - :fileKey => { :fileName => fileName, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json + fileType: File.extname(fileName).downcase.delete('.'), + key: ServiceConverter.generate_revision_id("#{"#{DocumentHelper.cur_user_host_address(nil)}/#{fileName}"}.#{File.mtime(DocumentHelper.storage_path(fileName, nil))}"), + url: DocumentHelper.get_download_url(fileName), + directUrl: body['directUrl'] ? DocumentHelper.get_download_url(fileName, false) : nil, + referenceData: { + instanceId: DocumentHelper.get_server_url(false), + fileKey: { fileName:, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json }, - :path => fileName, - :link => "#{DocumentHelper.get_server_url(false)}/editor?fileName=#{fileName}" + path: fileName, + link: "#{DocumentHelper.get_server_url(false)}/editor?fileName=#{fileName}" } data['token'] = JwtHelper.encode(data) if JwtHelper.is_enabled diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index fd65c8422..96f9146e1 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -179,9 +179,9 @@ def create_meta(file_name, uid, uname, user_address) # write user name, user uid and the creation time to the json object json = { - :created => Time.now.to_formatted_s(:db), - :uid => uid, - :uname => uname + created: Time.now.to_formatted_s(:db), + uid:, + uname: } # write file meta information to the createdInfo.json file diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 2473427dd..b64825fef 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -97,87 +97,87 @@ def get_config templatesImageUrl = DocumentHelper.get_template_image_url(document_type) # templates image url in the "From Template" section templates = [ { - :image => '', - :title => 'Blank', - :url => create_url + image: '', + title: 'Blank', + url: create_url }, { - :image => templatesImageUrl, - :title => 'With sample content', - :url => "#{create_url}&sample=true" + image: templatesImageUrl, + title: 'With sample content', + url: "#{create_url}&sample=true" } ] config = { - :type => type, - :documentType => document_type, - :document => { - :title => @file_name, - :url => download_url, - :directUrl => is_enable_direct_url ? download_url(false) : '', - :fileType => file_ext.delete('.'), - :key => key, - :info => { - :owner => 'Me', - :uploaded => Time.now.to_s, - :favorite => @user.favorite + type:, + documentType: document_type, + document: { + title: @file_name, + url: download_url, + directUrl: is_enable_direct_url ? download_url(false) : '', + fileType: file_ext.delete('.'), + key:, + info: { + owner: 'Me', + uploaded: Time.now.to_s, + favorite: @user.favorite }, - :permissions => { # the permission for the document to be edited and downloaded or not - :comment => !editorsmode.eql?('view') && !editorsmode.eql?('fillForms') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'), - :copy => !@user.deniedPermissions.include?('copy'), - :download => !@user.deniedPermissions.include?('download'), - :edit => canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('view') || editorsmode.eql?('filter') || editorsmode.eql?('blockcontent')), - :print => !@user.deniedPermissions.include?('print'), - :fillForms => !editorsmode.eql?('view') && !editorsmode.eql?('comment') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'), - :modifyFilter => !editorsmode.eql?('filter'), - :modifyContentControl => !editorsmode.eql?('blockcontent'), - :review => canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('review')), - :chat => !@user.id.eql?('uid-0'), - :reviewGroups => @user.reviewGroups, - :commentGroups => @user.commentGroups, - :userInfoGroups => @user.userInfoGroups, - :protect => !@user.deniedPermissions.include?('protect') + permissions: { # the permission for the document to be edited and downloaded or not + comment: !editorsmode.eql?('view') && !editorsmode.eql?('fillForms') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'), + copy: !@user.deniedPermissions.include?('copy'), + download: !@user.deniedPermissions.include?('download'), + edit: canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('view') || editorsmode.eql?('filter') || editorsmode.eql?('blockcontent')), + print: !@user.deniedPermissions.include?('print'), + fillForms: !editorsmode.eql?('view') && !editorsmode.eql?('comment') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'), + modifyFilter: !editorsmode.eql?('filter'), + modifyContentControl: !editorsmode.eql?('blockcontent'), + review: canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('review')), + chat: !@user.id.eql?('uid-0'), + reviewGroups: @user.reviewGroups, + commentGroups: @user.commentGroups, + userInfoGroups: @user.userInfoGroups, + protect: !@user.deniedPermissions.include?('protect') }, - :referenceData => { - :instanceId => DocumentHelper.get_server_url(false), - :fileKey => !@user.id.eql?('uid-0') ? { :fileName => @file_name, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json : nil + referenceData: { + instanceId: DocumentHelper.get_server_url(false), + fileKey: !@user.id.eql?('uid-0') ? { fileName: @file_name, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json : nil } }, - :editorConfig => { - :actionLink => @action_data ? JSON.parse(@action_data) : nil, - :mode => mode, - :lang => @lang || 'en', - :callbackUrl => callback_url, # absolute URL to the document storage service - :coEditing => if editorsmode.eql?('view') && @user.id.eql?('uid-0') + editorConfig: { + actionLink: @action_data ? JSON.parse(@action_data) : nil, + mode:, + lang: @lang || 'en', + callbackUrl: callback_url, # absolute URL to the document storage service + coEditing: if editorsmode.eql?('view') && @user.id.eql?('uid-0') { - :mode => 'strict', - :change => false + mode: 'strict', + change: false } else nil end, - :createUrl => !@user.id.eql?('uid-0') ? create_url : nil, - :templates => @user.templates ? templates : nil, - :user => { # the user currently viewing or editing the document - :id => !@user.id.eql?('uid-0') ? @user.id : nil, - :name => @user.name, - :group => @user.group, - :image => @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil + createUrl: !@user.id.eql?('uid-0') ? create_url : nil, + templates: @user.templates ? templates : nil, + user: { # the user currently viewing or editing the document + id: !@user.id.eql?('uid-0') ? @user.id : nil, + name: @user.name, + group: @user.group, + image: @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil }, - :embedded => { # the parameters for the embedded document type - :saveUrl => download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer - :embedUrl => download_url(false), # the absolute URL to the document serving as a source file for the document embedded into the web page - :shareUrl => download_url(false), # the absolute URL that will allow other users to share this document - :toolbarDocked => 'top' # the place for the embedded viewer toolbar (top or bottom) + embedded: { # the parameters for the embedded document type + saveUrl: download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer + embedUrl: download_url(false), # the absolute URL to the document serving as a source file for the document embedded into the web page + shareUrl: download_url(false), # the absolute URL that will allow other users to share this document + toolbarDocked: 'top' # the place for the embedded viewer toolbar (top or bottom) }, - :customization => { # the parameters for the editor interface - :about => true, # the About section display - :comments => true, - :feedback => true, # the Feedback & Support menu button display - :forcesave => false, # adding the request for the forced file saving to the callback handler - :submitForm => submitForm, # the Submit form button state - :goback => { - :url => DocumentHelper.get_server_url(false) + customization: { # the parameters for the editor interface + about: true, # the About section display + comments: true, + feedback: true, # the Feedback & Support menu button display + forcesave: false, # adding the request for the forced file saving to the callback handler + submitForm:, # the Submit form button state + goback: { + url: DocumentHelper.get_server_url(false) } } } @@ -226,8 +226,8 @@ def get_history # write information about changes to the object obj['created'] = cr_info['created'] obj['user'] = { - :id => cr_info['uid'], - :name => cr_info['uname'] + id: cr_info['uid'], + name: cr_info['uname'] } end end @@ -260,16 +260,16 @@ def get_history # write key and url information about previous file version with optional direct url dataObj['previous'] = if is_enable_direct_url == true { # write key and url information about previous file version with optional direct url - :fileType => prev['fileType'], - :key => prev['key'], - :url => prev['url'], - :directUrl => prev['directUrl'] + fileType: prev['fileType'], + key: prev['key'], + url: prev['url'], + directUrl: prev['directUrl'] } else { - :fileType => prev['fileType'], - :key => prev['key'], - :url => prev['url'] + fileType: prev['fileType'], + key: prev['key'], + url: prev['url'] } end @@ -286,11 +286,11 @@ def get_history end return { - :hist => { # write history information about the current file version to the hist - :currentVersion => cur_ver, - :history => hist + hist: { # write history information about the current file version to the hist + currentVersion: cur_ver, + history: hist }, - :histData => histData + histData: } end @@ -304,14 +304,14 @@ def get_insert_image # direct url to the image insert_image = if is_enable_direct_url == true { - :fileType => 'png', # image file type - :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image - :directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image + fileType: 'png', # image file type + url: "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image + directUrl: "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image } else { - :fileType => 'png', # image file type - :url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image + fileType: 'png', # image file type + url: "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image } end @@ -329,14 +329,14 @@ def dataDocument # direct url to the compared file compare_file = if is_enable_direct_url == true { - :fileType => 'docx', # file type - :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file - :directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file + fileType: 'docx', # file type + url: "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file + directUrl: "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file } else { - :fileType => 'docx', # file type - :url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file + fileType: 'docx', # file type + url: "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file } end @@ -354,14 +354,14 @@ def dataSpreadsheet # direct url to the mail merge recipients file dataSpreadsheet = if is_enable_direct_url == true { - :fileType => 'csv', # file type - :url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file - :directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file + fileType: 'csv', # file type + url: "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file + directUrl: "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file } else { - :fileType => 'csv', # file type - :url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file + fileType: 'csv', # file type + url: "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file } end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 9d33397f8..4df9605d9 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -40,14 +40,14 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ document_revision_id = generate_revision_id(document_revision_id) payload = { # write all the conversion parameters to the payload - :async => is_async ? true : false, - :url => document_uri, - :outputtype => to_ext.delete('.'), - :filetype => from_ext.delete('.'), - :title => title, - :key => document_revision_id, - :password => file_pass, - :region => lang + async: is_async ? true : false, + url: document_uri, + outputtype: to_ext.delete('.'), + filetype: from_ext.delete('.'), + title:, + key: document_revision_id, + password: file_pass, + region: lang } data = nil @@ -66,7 +66,7 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwtHeader = ServiceConverter.config_manager.jwt_header; # get signature authorization header - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix + req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") # set it to the request with the Bearer prefix end req.body = payload.to_json diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 6ed253089..8f8749861 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -234,11 +234,11 @@ def process_force_save(file_data, file_name, user_address) def command_request(method, key, meta = nil) # create a payload object with the method and key payload = { - :c => method, - :key => key + c: method, + key: } - payload.merge!({ :meta => meta }) if !meta.nil? + payload.merge!({ meta: }) if !meta.nil? data = nil begin @@ -253,7 +253,7 @@ def command_request(method, key, meta = nil) if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix + req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") # set it to the request with the Bearer prefix end req.body = payload.to_json # convert the payload object into the json format diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 85fb40df2..0f1d4e71e 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -90,17 +90,17 @@ class Users nil, [], @@descr_user_1, true, true), User.new('uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', ['group-2', ''], { - :view => '', - :edit => ['group-2', ''], - :remove => ['group-2'] + view: '', + edit: ['group-2', ''], + remove: ['group-2'] }, ['group-2', ''], true, [], @@descr_user_2, false, true), User.new('uid-3', 'Hamish Mitchell', nil, 'group-3', ['group-2'], { - :view => %w[group-3 group-2], - :edit => ['group-2'], - :remove => [] + view: %w[group-3 group-2], + edit: ['group-2'], + remove: [] }, ['group-2'], false, %w[copy download print], @@descr_user_3, false, false), @@ -126,7 +126,7 @@ def get_user(id) def get_users_for_mentions(id) usersData = [] @@users.each do |user| - usersData.push({ :name => user.name, :email => user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? + usersData.push({ name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? end usersData end From 7d09d87891403460c065658f300b9f390226f8c4 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 13:47:18 +0300 Subject: [PATCH 324/488] ruby: Layout/LineLength correct --- .../ruby/app/controllers/home_controller.rb | 295 ++++++++++-------- .../ruby/app/models/document_helper.rb | 31 +- .../ruby/app/models/file_model.rb | 86 +++-- .../ruby/app/models/service_converter.rb | 6 +- .../ruby/app/models/track_helper.rb | 59 +++- .../ruby/app/models/users.rb | 8 +- 6 files changed, 286 insertions(+), 199 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 246759ba6..d331e595d 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -31,7 +31,16 @@ def index; end def editor DocumentHelper.init(request.remote_ip, request.base_url) user = Users.get_user(params[:userId]) - @file = FileModel.new(file_name: File.basename(params[:fileName]), mode: params[:editorsMode], type: params[:editorsType], user_ip: request.remote_ip, lang: cookies[:ulang], user:, action_data: params[:actionLink], direct_url: params[:directUrl]) + @file = FileModel.new( + file_name: File.basename(params[:fileName]), + mode: params[:editorsMode], + type: params[:editorsType], + user_ip: request.remote_ip, + lang: cookies[:ulang], + user:, + action_data: params[:actionLink], + direct_url: params[:directUrl] + ) end # creating a sample document @@ -73,7 +82,8 @@ def upload DocumentHelper.create_meta(file_name, user.id, user.name, nil) - render plain: "{ \"filename\": \"#{file_name}\", \"documentType\": \"#{document_type}\"}" # write a new file name to the response + # write a new file name to the response + render plain: "{ \"filename\": \"#{file_name}\", \"documentType\": \"#{document_type}\"}" rescue StandardError => ex render plain: "{ \"error\": \"#{ex.message}\"}" # write an error message to the response end @@ -81,100 +91,105 @@ def upload # converting a file def convert - - file_data = request.body.read - return '' if file_data.nil? || file_data.empty? - - body = JSON.parse(file_data) - - file_name = File.basename(body['filename']) - lang = cookies[:ulang] || 'en' - file_pass = body['filePass'] || nil - file_uri = DocumentHelper.get_download_url(file_name) - extension = File.extname(file_name).downcase - internal_extension = 'ooxml' - - if DocumentHelper.convert_exts.include?(extension) # check if the file with such an extension can be converted - key = ServiceConverter.generate_revision_id(file_uri) # generate document key - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(file_uri, extension.delete('.'), internal_extension.delete('.'), key, true, file_pass, lang) # get the url and file type of the converted file and the conversion percentage - - # if the conversion isn't completed, write file name and step values to the response - if percent != 100 - render plain: "{ \"step\" : \"#{percent}\", \"filename\" : \"#{file_name}\"}" - return - end + file_data = request.body.read + return '' if file_data.nil? || file_data.empty? + + body = JSON.parse(file_data) + + file_name = File.basename(body['filename']) + lang = cookies[:ulang] || 'en' + file_pass = body['filePass'] || nil + file_uri = DocumentHelper.get_download_url(file_name) + extension = File.extname(file_name).downcase + internal_extension = 'ooxml' + + if DocumentHelper.convert_exts.include?(extension) # check if the file with such an extension can be converted + key = ServiceConverter.generate_revision_id(file_uri) # generate document key + percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data( + file_uri, + extension.delete('.'), + internal_extension.delete('.'), + key, + true, + file_pass, + lang + ) # get the url and file type of the converted file and the conversion percentage + + # if the conversion isn't completed, write file name and step values to the response + if percent != 100 + render plain: "{ \"step\" : \"#{percent}\", \"filename\" : \"#{file_name}\"}" + return + end - # get the correct file name if such a name already exists - correct_name = DocumentHelper.get_correct_name("#{File.basename(file_name, extension)}.#{new_file_type}", nil) + # get the correct file name if such a name already exists + correct_name = DocumentHelper.get_correct_name("#{File.basename(file_name, extension)}.#{new_file_type}", nil) - uri = URI.parse(new_file_uri) # create the request url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + uri = URI.parse(new_file_uri) # create the request url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - DocumentHelper.verify_ssl(new_file_uri, http) + DocumentHelper.verify_ssl(new_file_uri, http) - req = Net::HTTP::Get.new(uri.request_uri) # create the get requets - res = http.request(req) - data = res.body + req = Net::HTTP::Get.new(uri.request_uri) # create the get requets + res = http.request(req) + data = res.body - raise 'stream is null' if data.nil? + raise 'stream is null' if data.nil? - # write a file with a new extension, but with the content from the origin file - File.open(DocumentHelper.storage_path(correct_name, nil), 'wb') do |file| - file.write(data) - end + # write a file with a new extension, but with the content from the origin file + File.open(DocumentHelper.storage_path(correct_name, nil), 'wb') do |file| + file.write(data) + end - old_storage_path = DocumentHelper.storage_path(file_name, nil) - File.delete(old_storage_path) if File.exist?(old_storage_path) + old_storage_path = DocumentHelper.storage_path(file_name, nil) + File.delete(old_storage_path) if File.exist?(old_storage_path) - file_name = correct_name - user = Users.get_user(params[:userId]) + file_name = correct_name + user = Users.get_user(params[:userId]) - DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file - end + DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file + end - render plain: "{ \"filename\" : \"#{file_name}\"}" - rescue StandardError => ex - render plain: "{ \"error\": \"#{ex.message}\"}" - + render plain: "{ \"filename\" : \"#{file_name}\"}" + rescue StandardError => ex + render plain: "{ \"error\": \"#{ex.message}\"}" end # downloading a history file from public def downloadhistory - - file_name = File.basename(params[:fileName]) - user_address = params[:userAddress] - version = params[:ver] - file = params[:file] - isEmbedded = params[:dmode] - - if JwtHelper.is_enabled && JwtHelper.use_for_request - jwtHeader = HomeController.config_manager.jwt_header - if request.headers[jwtHeader] - hdr = request.headers[jwtHeader] - hdr.slice!(0, 'Bearer '.length) - token = JwtHelper.decode(hdr) - if !token || token.eql?('') - render plain: 'JWT validation failed', status: 403 - return - end - else + file_name = File.basename(params[:fileName]) + user_address = params[:userAddress] + version = params[:ver] + file = params[:file] + isEmbedded = params[:dmode] + + if JwtHelper.is_enabled && JwtHelper.use_for_request + jwtHeader = HomeController.config_manager.jwt_header + if request.headers[jwtHeader] + hdr = request.headers[jwtHeader] + hdr.slice!(0, 'Bearer '.length) + token = JwtHelper.decode(hdr) + if !token || token.eql?('') render plain: 'JWT validation failed', status: 403 return end + else + render plain: 'JWT validation failed', status: 403 + return end - hist_path = "#{DocumentHelper.storage_path(file_name, user_address)}-hist" # or to the original document - - file_path = File.join(hist_path, version, file) + end + hist_path = "#{DocumentHelper.storage_path(file_name, user_address)}-hist" # or to the original document - # add headers to the response to specify the page parameters - response.headers['Content-Length'] = File.size(file_path).to_s - response.headers['Content-Type'] = MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type - response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file)}" + file_path = File.join(hist_path, version, file) - send_file file_path, x_sendfile: true - rescue StandardError => ex - render plain: '{ "error": "File not found"}' - + # add headers to the response to specify the page parameters + response.headers['Content-Length'] = File.size(file_path).to_s + response.headers['Content-Type'] = + MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type + response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file)}" + + send_file file_path, x_sendfile: true + rescue StandardError => ex + render plain: '{ "error": "File not found"}' end # tracking file changes @@ -259,81 +274,82 @@ def csv # downloading a file def download - - file_name = File.basename(params[:fileName]) - user_address = params[:userAddress] - isEmbedded = params[:dmode] - - if JwtHelper.is_enabled && isEmbedded.nil? && !user_address.nil? && JwtHelper.use_for_request - jwtHeader = HomeController.config_manager.jwt_header - if request.headers[jwtHeader] - hdr = request.headers[jwtHeader] - hdr.slice!(0, 'Bearer '.length) - token = JwtHelper.decode(hdr) - end - if !token || token.eql?('') - render plain: 'JWT validation failed', status: 403 - return - end + file_name = File.basename(params[:fileName]) + user_address = params[:userAddress] + isEmbedded = params[:dmode] + + if JwtHelper.is_enabled && isEmbedded.nil? && !user_address.nil? && JwtHelper.use_for_request + jwtHeader = HomeController.config_manager.jwt_header + if request.headers[jwtHeader] + hdr = request.headers[jwtHeader] + hdr.slice!(0, 'Bearer '.length) + token = JwtHelper.decode(hdr) end - - file_path = DocumentHelper.forcesave_path(file_name, user_address, false) # get the path to the force saved document version - if file_path.eql?('') - file_path = DocumentHelper.storage_path(file_name, user_address) # or to the original document + if !token || token.eql?('') + render plain: 'JWT validation failed', status: 403 + return end + end - # add headers to the response to specify the page parameters - response.headers['Content-Length'] = File.size(file_path).to_s - response.headers['Content-Type'] = MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type - response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" + # get the path to the force saved document version + file_path = DocumentHelper.forcesave_path(file_name, user_address, false) + if file_path.eql?('') + file_path = DocumentHelper.storage_path(file_name, user_address) # or to the original document + end - send_file file_path, x_sendfile: true - rescue StandardError => ex - render plain: '{ "error": "File not found"}' - + # add headers to the response to specify the page parameters + response.headers['Content-Length'] = File.size(file_path).to_s + response.headers['Content-Type'] = + MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type + response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" + + send_file file_path, x_sendfile: true + rescue StandardError => ex + render plain: '{ "error": "File not found"}' end # Save Copy as... def saveas - - body = JSON.parse(request.body.read) - file_url = body['url'] - title = body['title'] - file_name = DocumentHelper.get_correct_name(title, nil) - extension = File.extname(file_name).downcase - all_exts = DocumentHelper.convert_exts + DocumentHelper.edited_exts + DocumentHelper.viewed_exts + DocumentHelper.fill_forms_exts - - unless all_exts.include?(extension) - render plain: '{"error": "File type is not supported"}' - return - end + body = JSON.parse(request.body.read) + file_url = body['url'] + title = body['title'] + file_name = DocumentHelper.get_correct_name(title, nil) + extension = File.extname(file_name).downcase + all_exts = DocumentHelper.convert_exts + + DocumentHelper.edited_exts + + DocumentHelper.viewed_exts + + DocumentHelper.fill_forms_exts + + unless all_exts.include?(extension) + render plain: '{"error": "File type is not supported"}' + return + end - uri = URI.parse(file_url) # create the request url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + uri = URI.parse(file_url) # create the request url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - DocumentHelper.verify_ssl(file_url, http) + DocumentHelper.verify_ssl(file_url, http) - req = Net::HTTP::Get.new(uri.request_uri) # create the get requets - res = http.request(req) - data = res.body + req = Net::HTTP::Get.new(uri.request_uri) # create the get requets + res = http.request(req) + data = res.body - if data.size <= 0 || data.size > HomeController.config_manager.maximum_file_size - render plain: '{"error": "File size is incorrect"}' - return - end + if data.size <= 0 || data.size > HomeController.config_manager.maximum_file_size + render plain: '{"error": "File size is incorrect"}' + return + end - File.open(DocumentHelper.storage_path(file_name, nil), 'wb') do |file| - file.write(data) - end - user = Users.get_user(params[:userId]) - DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file + File.open(DocumentHelper.storage_path(file_name, nil), 'wb') do |file| + file.write(data) + end + user = Users.get_user(params[:userId]) + DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file - render plain: "{\"file\" : \"#{file_name}\"}" - nil - rescue StandardError => ex - render plain: "{\"error\":1, \"message\": \"#{ex.message}\"}" - nil - + render plain: "{\"file\" : \"#{file_name}\"}" + nil + rescue StandardError => ex + render plain: "{\"error\":1, \"message\": \"#{ex.message}\"}" + nil end # Rename... @@ -401,7 +417,10 @@ def reference data = { fileType: File.extname(fileName).downcase.delete('.'), - key: ServiceConverter.generate_revision_id("#{"#{DocumentHelper.cur_user_host_address(nil)}/#{fileName}"}.#{File.mtime(DocumentHelper.storage_path(fileName, nil))}"), + key: ServiceConverter.generate_revision_id( + "#{DocumentHelper.cur_user_host_address(nil)}/#{fileName}" \ + ".#{File.mtime(DocumentHelper.storage_path(fileName, nil))}" + ), url: DocumentHelper.get_download_url(fileName), directUrl: body['directUrl'] ? DocumentHelper.get_download_url(fileName, false) : nil, referenceData: { diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 96f9146e1..e160abe89 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -87,7 +87,8 @@ def forcesave_path(file_name, user_address, create) # the directory with host address doesn't exist return '' unless File.directory?(directory) - directory = File.join(directory, "#{File.basename(file_name)}-hist") # get the path to the history of the given file + # get the path to the history of the given file + directory = File.join(directory, "#{File.basename(file_name)}-hist") unless File.directory?(directory) return '' unless create @@ -146,7 +147,8 @@ def get_correct_name(file_name, user_address) name = base_name + ext.downcase # get full file name index = 1 - while File.exist?(storage_path(name, user_address)) # if the file with such a name already exists in this directory + # if the file with such a name already exists in this directory + while File.exist?(storage_path(name, user_address)) name = "#{base_name} (#{index})#{ext.downcase}" # add an index after its base name index += 1 end @@ -195,7 +197,8 @@ def create_demo(file_ext, sample, user) demo_name = (sample == 'true' ? 'sample.' : 'new.') + file_ext file_name = get_correct_name(demo_name, nil) # get the correct file name if such a name already exists - src = Rails.root.join('assets', 'document-templates', sample == 'true' ? 'sample' : 'new', demo_name) # save sample document of a necessary extension to the storage directory + # save sample document of a necessary extension to the storage directory + src = Rails.root.join('assets', 'document-templates', sample == 'true' ? 'sample' : 'new', demo_name) dest = storage_path file_name, nil FileUtils.cp src, dest @@ -209,8 +212,10 @@ def create_demo(file_ext, sample, user) # get file url def get_file_uri(file_name, for_document_server) - uri = "#{get_server_url(for_document_server)}/#{DocumentHelper.config_manager.storage_path}/#{cur_user_host_address(nil)}/#{ERB::Util.url_encode(file_name)}" - + uri = "#{get_server_url(for_document_server)}/" \ + "#{DocumentHelper.config_manager.storage_path}/" \ + "#{cur_user_host_address(nil)}/" \ + "#{ERB::Util.url_encode(file_name)}" uri end @@ -218,20 +223,27 @@ def get_file_uri(file_name, for_document_server) def get_historypath_uri(file_name, version, file, is_serverUrl = true) # for redirection to my link user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' - uri = "#{get_server_url(is_serverUrl)}/downloadhistory/?fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}&file=#{ERB::Util.url_encode(file)}#{user_host}" + uri = "#{get_server_url(is_serverUrl)}/downloadhistory/?"\ + "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}"\ + "&file=#{ERB::Util.url_encode(file)}#{user_host}" uri end # get server url def get_server_url(for_document_server) - return DocumentHelper.config_manager.example_uri.to_s if for_document_server && DocumentHelper.config_manager.example_uri + return DocumentHelper.config_manager.example_uri.to_s if ( + for_document_server && + DocumentHelper.config_manager.example_uri + ) @@base_url end # get callback url def get_callback(file_name) - "#{get_server_url(true)}/track?fileName=#{ERB::Util.url_encode(file_name)}&userAddress=#{cur_user_host_address(nil)}" + "#{get_server_url(true)}/track?" \ + "fileName=#{ERB::Util.url_encode(file_name)}&" \ + "userAddress=#{cur_user_host_address(nil)}" end # get url to the created file @@ -314,7 +326,8 @@ def verify_ssl(file_uri, http) return unless file_uri.start_with?('https') && DocumentHelper.config_manager.ssl_verify_peer_mode_enabled http.use_ssl = true - http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session + # set the flags for the server certificate verification at the beginning of SSL session + http.verify_mode = OpenSSL::SSL::VERIFY_NONE end end end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index b64825fef..55e041796 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -49,7 +49,8 @@ def file_uri # get file uri for document server def file_uri_user - @config_manager.storage_path.absolute? ? "#{download_url}&dmode=emb" : DocumentHelper.get_file_uri(@file_name, false) + @config_manager.storage_path.absolute? ? "#{download_url}&dmode=emb" : DocumentHelper.get_file_uri(@file_name, + false) end # get document type from its name (word, cell or slide) @@ -88,13 +89,15 @@ def cur_user_host_address def get_config editorsmode = @mode || 'edit' # mode: view/edit/review/comment/fillForms/embedded canEdit = DocumentHelper.edited_exts.include?(file_ext) # check if the document can be edited - if (!canEdit && editorsmode.eql?('edit') || editorsmode.eql?('fillForms')) && DocumentHelper.fill_forms_exts.include?(file_ext) + if (!canEdit && editorsmode.eql?('edit') || editorsmode.eql?('fillForms')) && + DocumentHelper.fill_forms_exts.include?(file_ext) editorsmode = 'fillForms' canEdit = true end submitForm = editorsmode.eql?('fillForms') && @user.id.eql?('uid-1') && false # the Submit form button state mode = canEdit && !editorsmode.eql?('view') ? 'edit' : 'view' - templatesImageUrl = DocumentHelper.get_template_image_url(document_type) # templates image url in the "From Template" section + # templates image url in the "From Template" section + templatesImageUrl = DocumentHelper.get_template_image_url(document_type) templates = [ { image: '', @@ -123,12 +126,12 @@ def get_config favorite: @user.favorite }, permissions: { # the permission for the document to be edited and downloaded or not - comment: !editorsmode.eql?('view') && !editorsmode.eql?('fillForms') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'), + comment: !%w[view fillForms embedded blockcontent].include?(editorsmode), copy: !@user.deniedPermissions.include?('copy'), download: !@user.deniedPermissions.include?('download'), - edit: canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('view') || editorsmode.eql?('filter') || editorsmode.eql?('blockcontent')), + edit: canEdit && %w[edit view filter blockcontent].include?(editorsmode), print: !@user.deniedPermissions.include?('print'), - fillForms: !editorsmode.eql?('view') && !editorsmode.eql?('comment') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'), + fillForms: !%w[view comment embedded blockcontent].include?(editorsmode), modifyFilter: !editorsmode.eql?('filter'), modifyContentControl: !editorsmode.eql?('blockcontent'), review: canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('review')), @@ -140,7 +143,8 @@ def get_config }, referenceData: { instanceId: DocumentHelper.get_server_url(false), - fileKey: !@user.id.eql?('uid-0') ? { fileName: @file_name, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json : nil + fileKey: !@user.id.eql?('uid-0') ? { fileName: @file_name, + userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json : nil } }, editorConfig: { @@ -149,13 +153,13 @@ def get_config lang: @lang || 'en', callbackUrl: callback_url, # absolute URL to the document storage service coEditing: if editorsmode.eql?('view') && @user.id.eql?('uid-0') - { - mode: 'strict', - change: false - } - else - nil - end, + { + mode: 'strict', + change: false + } + else + nil + end, createUrl: !@user.id.eql?('uid-0') ? create_url : nil, templates: @user.templates ? templates : nil, user: { # the user currently viewing or editing the document @@ -165,9 +169,12 @@ def get_config image: @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil }, embedded: { # the parameters for the embedded document type - saveUrl: download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer - embedUrl: download_url(false), # the absolute URL to the document serving as a source file for the document embedded into the web page - shareUrl: download_url(false), # the absolute URL that will allow other users to share this document + # the absolute URL that will allow the document to be saved onto the user personal computer + saveUrl: download_url(false), + # the absolute URL to the document serving as a source file for the document embedded into the web page + embedUrl: download_url(false), + # the absolute URL that will allow other users to share this document + shareUrl: download_url(false), toolbarDocked: 'top' # the place for the embedded viewer toolbar (top or bottom) }, customization: { # the parameters for the editor interface @@ -197,7 +204,8 @@ def get_history doc_key = key doc_uri = file_uri - hist_dir = DocumentHelper.history_dir(DocumentHelper.storage_path(@file_name, nil)) # get the path to the file history + # get the path to the file history + hist_dir = DocumentHelper.history_dir(DocumentHelper.storage_path(@file_name, nil)) cur_ver = DocumentHelper.get_file_version(hist_dir) # get the file version if cur_ver.positive? # if file was modified @@ -219,7 +227,8 @@ def get_history obj['key'] = cur_key obj['version'] = i - if (i == 1) && File.file?(File.join(hist_dir, 'createdInfo.json')) # check if the createdInfo.json file with meta data exists + # check if the createdInfo.json file with meta data exists + if (i == 1) && File.file?(File.join(hist_dir, 'createdInfo.json')) File.open(File.join(hist_dir, 'createdInfo.json'), 'r') do |file| # open it cr_info = JSON.parse(file.read) # parse the file content @@ -237,14 +246,17 @@ def get_history dataObj['key'] = cur_key dataObj['url'] = i == cur_ver ? doc_uri : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}") if is_enable_direct_url == true - dataObj['directUrl'] = i == cur_ver ? download_url(false) : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", false) + dataObj['directUrl'] = + i == cur_ver ? download_url(false) : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", + false) end dataObj['version'] = i if i > 1 # check if the version number is greater than 1 changes = nil change = nil - File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), 'changes.json'), 'r') do |file| # get the path to the changes.json file + # get the path to the changes.json file + File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), 'changes.json'), 'r') do |file| changes = JSON.parse(file.read) # and parse its content end @@ -259,7 +271,7 @@ def get_history prev = histData[(i - 2).to_s] # get the history data from the previous file version # write key and url information about previous file version with optional direct url dataObj['previous'] = if is_enable_direct_url == true - { # write key and url information about previous file version with optional direct url + { # write key and url information about previous file version with optional directUrl fileType: prev['fileType'], key: prev['key'], url: prev['url'], @@ -278,7 +290,8 @@ def get_history end if JwtHelper.is_enabled # check if a secret key to generate token exists or not - dataObj['token'] = JwtHelper.encode(dataObj) # encode a payload object into a token and write it to the data object + # encode a payload object into a token and write it to the data object + dataObj['token'] = JwtHelper.encode(dataObj) end hist.push(obj) # add object dictionary to the hist list @@ -316,7 +329,8 @@ def get_insert_image end if JwtHelper.is_enabled # check if a secret key to generate token exists or not - insert_image['token'] = JwtHelper.encode(insert_image) # encode a payload object into a token and write it to the insert_image object + # encode a payload object into a token and write it to the insert_image object + insert_image['token'] = JwtHelper.encode(insert_image) end insert_image.to_json.tr('{', '').tr('}', '') @@ -330,18 +344,22 @@ def dataDocument compare_file = if is_enable_direct_url == true { fileType: 'docx', # file type - url: "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file - directUrl: "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file + # server url to the compared file + url: "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", + # direct url to the compared file + directUrl: "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" } else { fileType: 'docx', # file type - url: "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file + # server url to the compared file + url: "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" } end if JwtHelper.is_enabled # check if a secret key to generate token exists or not - compare_file['token'] = JwtHelper.encode(compare_file) # encode a payload object into a token and write it to the compare_file object + # encode a payload object into a token and write it to the compare_file object + compare_file['token'] = JwtHelper.encode(compare_file) end compare_file @@ -355,18 +373,22 @@ def dataSpreadsheet dataSpreadsheet = if is_enable_direct_url == true { fileType: 'csv', # file type - url: "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file - directUrl: "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file + # server url to the mail merge recipients file + url: "#{DocumentHelper.get_server_url(true)}/csv", + # direct url to the mail merge recipients file + directUrl: "#{DocumentHelper.get_server_url(false)}/csv" } else { fileType: 'csv', # file type - url: "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file + # server url to the mail merge recipients file + url: "#{DocumentHelper.get_server_url(true)}/csv" } end if JwtHelper.is_enabled # check if a secret key to generate token exists or not - dataSpreadsheet['token'] = JwtHelper.encode(dataSpreadsheet) # encode a payload object into a token and write it to the dataSpreadsheet object + # encode a payload object into a token and write it to the dataSpreadsheet object + dataSpreadsheet['token'] = JwtHelper.encode(dataSpreadsheet) end dataSpreadsheet diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 4df9605d9..f307c675c 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -66,7 +66,8 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwtHeader = ServiceConverter.config_manager.jwt_header; # get signature authorization header - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") # set it to the request with the Bearer prefix + # set it to the request with the Bearer prefix + req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") end req.body = payload.to_json @@ -91,7 +92,8 @@ def generate_revision_id(expected_key) require 'zlib' if expected_key.length > 20 # check if the expected key length is greater than 20 - expected_key = (Zlib.crc32 expected_key).to_s # calculate 32-bit crc value from the expected key and turn it into the string + # calculate 32-bit crc value from the expected key and turn it into the string + expected_key = (Zlib.crc32 expected_key).to_s end key = expected_key.gsub(/[^0-9a-zA-Z.=]/, '_') diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 8f8749861..c6ef61481 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -106,14 +106,25 @@ def process_save(raw_file_data, file_name, user_address) unless cur_ext.eql?(download_ext) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file + percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data( + download_uri, + download_ext.delete('.'), + cur_ext.delete('.'), + key, + false, + nil + ) # get the url of the converted file if new_file_uri.nil? || new_file_uri.empty? - new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) # get the correct file name if it already exists + new_file_name = DocumentHelper.get_correct_name( + File.basename(file_name, cur_ext) + download_ext, + user_address + ) # get the correct file name if it already exists else download_uri = new_file_uri end rescue StandardError => msg - new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) + new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, + user_address) end end @@ -123,14 +134,17 @@ def process_save(raw_file_data, file_name, user_address) return saved if data.eql?(nil) begin - storage_path = DocumentHelper.storage_path(new_file_name, user_address) # get the storage directory of the new file + # get the storage directory of the new file + storage_path = DocumentHelper.storage_path(new_file_name, user_address) hist_dir = DocumentHelper.history_dir(storage_path) # get the history directory of the new file - ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) # get the path to the specified file version + # get the path to the specified file version + ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) FileUtils.mkdir_p(ver_dir) # create the version directory if doesn't exist - FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) # move the file from the storage directory to the previous file version directory + # move the file from the storage directory to the previous file version directory + FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) save_file(data, storage_path) # save the downloaded file to the storage directory @@ -150,7 +164,8 @@ def process_save(raw_file_data, file_name, user_address) file.write(file_data['key']) end - forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) # get the path to the forcesaved file + # get the path to the forcesaved file + forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) unless forcesave_path.eql?('') # if this path is empty File.delete(forcesave_path) # remove it end @@ -181,7 +196,14 @@ def process_force_save(file_data, file_name, user_address) unless cur_ext.eql?(download_ext) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data(download_uri, download_ext.delete('.'), cur_ext.delete('.'), key, false, nil) # get the url of the converted file + percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data( + download_uri, + download_ext.delete('.'), + cur_ext.delete('.'), + key, + false, + nil + ) # get the url of the converted file if new_file_uri.nil? || new_file_uri.empty? new_file_name = true else @@ -198,20 +220,25 @@ def process_force_save(file_data, file_name, user_address) return saved if data.eql?(nil) begin - is_submit_form = file_data['forcesavetype'].to_i == 3 # check if the forcesave type is equal to 3 (the form was submitted) + # check if the forcesave type is equal to 3 (the form was submitted) + is_submit_form = file_data['forcesavetype'].to_i == 3 if is_submit_form file_name = if new_file_name - DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists + DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", + user_address) # get the correct file name if it already exists else - DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) + DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", + user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) if new_file_name + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, + user_address) if new_file_name forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) if forcesave_path.eql?('') - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it + # if the path to the new file doesn't exist, create it + forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) end end @@ -219,7 +246,8 @@ def process_force_save(file_data, file_name, user_address) if is_submit_form uid = file_data['actions'][0]['userid'] - DocumentHelper.create_meta(file_name, uid, 'Filling Form', user_address) # create file meta information with the Filling form tag instead of user name + # create file meta information with the Filling form tag instead of user name + DocumentHelper.create_meta(file_name, uid, 'Filling Form', user_address) end saved = 0 @@ -253,7 +281,8 @@ def command_request(method, key, meta = nil) if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") # set it to the request with the Bearer prefix + # set it to the request with the Bearer prefix + req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") end req.body = payload.to_json # convert the payload object into the json format diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 0f1d4e71e..d21897236 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -50,7 +50,8 @@ class Users @@descr_user_2 = [ 'Belongs to Group2', 'Can review only his own changes or changes made by users with no group', - 'Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only', + 'Can view comments, edit his own comments, and comments left by users with no group. ' \ + 'Can remove his own comments only', 'This file is marked as favorite', 'Can create new files from the editor', 'Can see the information about users from Group2 and users who don’t belong to any group', @@ -126,11 +127,12 @@ def get_user(id) def get_users_for_mentions(id) usersData = [] @@users.each do |user| - usersData.push({ name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? + usersData.push({ name: user.name, + email: user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? end usersData end - + # get a list of users with their id, names and emails for protect def get_users_for_protect(id) users_data = [] From f47f9bf897625f77b6e0e4e581f443c001fc6417 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:11:19 +0300 Subject: [PATCH 325/488] ruby: Style/FrozenStringLiteralComment correct --- web/documentserver-example/ruby/Gemfile | 1 + web/documentserver-example/ruby/Rakefile | 1 + .../ruby/app/controllers/application_controller.rb | 1 + .../ruby/app/controllers/home_controller.rb | 1 + .../ruby/app/helpers/application_helper.rb | 1 + web/documentserver-example/ruby/app/helpers/home_helper.rb | 1 + web/documentserver-example/ruby/app/models/document_helper.rb | 1 + web/documentserver-example/ruby/app/models/file_model.rb | 1 + web/documentserver-example/ruby/app/models/file_utility.rb | 1 + web/documentserver-example/ruby/app/models/jwt_helper.rb | 1 + web/documentserver-example/ruby/app/models/service_converter.rb | 1 + web/documentserver-example/ruby/app/models/track_helper.rb | 1 + web/documentserver-example/ruby/app/models/users.rb | 1 + web/documentserver-example/ruby/config.ru | 1 + web/documentserver-example/ruby/config/application.rb | 1 + web/documentserver-example/ruby/config/boot.rb | 1 + 16 files changed, 16 insertions(+) diff --git a/web/documentserver-example/ruby/Gemfile b/web/documentserver-example/ruby/Gemfile index a31eca56b..45e26a0cb 100644 --- a/web/documentserver-example/ruby/Gemfile +++ b/web/documentserver-example/ruby/Gemfile @@ -1,3 +1,4 @@ +# frozen_string_literal: true source 'https://rubygems.org' gem 'byebug', '~> 11.1', groups: %i[development test] diff --git a/web/documentserver-example/ruby/Rakefile b/web/documentserver-example/ruby/Rakefile index 3c3cea86d..bb8920958 100644 --- a/web/documentserver-example/ruby/Rakefile +++ b/web/documentserver-example/ruby/Rakefile @@ -1,3 +1,4 @@ +# frozen_string_literal: true require 'rake/testtask' require_relative 'config/application' diff --git a/web/documentserver-example/ruby/app/controllers/application_controller.rb b/web/documentserver-example/ruby/app/controllers/application_controller.rb index 32ce5cfdb..b6d3299e5 100644 --- a/web/documentserver-example/ruby/app/controllers/application_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/application_controller.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index d331e595d..81e8b0a6f 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/helpers/application_helper.rb b/web/documentserver-example/ruby/app/helpers/application_helper.rb index d17fe1b8d..3e7976e0a 100644 --- a/web/documentserver-example/ruby/app/helpers/application_helper.rb +++ b/web/documentserver-example/ruby/app/helpers/application_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/helpers/home_helper.rb b/web/documentserver-example/ruby/app/helpers/home_helper.rb index a0e2faf09..421fa0789 100644 --- a/web/documentserver-example/ruby/app/helpers/home_helper.rb +++ b/web/documentserver-example/ruby/app/helpers/home_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index e160abe89..0971ab723 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 55e041796..f29efeb86 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/file_utility.rb b/web/documentserver-example/ruby/app/models/file_utility.rb index 204dbcac9..5e7965a86 100644 --- a/web/documentserver-example/ruby/app/models/file_utility.rb +++ b/web/documentserver-example/ruby/app/models/file_utility.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index f97ebe801..842c89f29 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index f307c675c..89717134c 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index c6ef61481..aee649111 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index d21897236..6d178dcd2 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/config.ru b/web/documentserver-example/ruby/config.ru index e906496b0..edb2b97b1 100644 --- a/web/documentserver-example/ruby/config.ru +++ b/web/documentserver-example/ruby/config.ru @@ -1,3 +1,4 @@ +# frozen_string_literal: true require_relative 'config/application' Rails.application.initialize! diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index ae55c78c7..6f8a36e1c 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true require_relative 'boot' require 'active_model/railtie' diff --git a/web/documentserver-example/ruby/config/boot.rb b/web/documentserver-example/ruby/config/boot.rb index 5cea2ab21..3ceeeffec 100644 --- a/web/documentserver-example/ruby/config/boot.rb +++ b/web/documentserver-example/ruby/config/boot.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' From 5f053de539f417c9b32c25d1d3cddaa32d5ac13d Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:12:42 +0300 Subject: [PATCH 326/488] ruby: Style/RedundantParentheses correct --- .../ruby/app/controllers/home_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 81e8b0a6f..86a5a7e2b 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -206,7 +206,7 @@ def track user_address = params[:userAddress] file_name = File.basename(params[:fileName]) - if status == 1 && ((file_data['actions'][0]['type']).zero?) # finished edit + if status == 1 && (file_data['actions'][0]['type']).zero? # finished edit user = file_data['actions'][0]['userid'] # get the user id unless file_data['users'].index(user) json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command From a809af8ecab51f9da8457e993195eb54b3fc2ee3 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:14:55 +0300 Subject: [PATCH 327/488] ruby: Style/IfUnlessModifier correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 0971ab723..5a8570a66 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -100,9 +100,7 @@ def forcesave_path(file_name, user_address, create) end directory = File.join(directory, File.basename(file_name)) # get the path to the given file - if !File.file?(directory) && !create - return '' - end + return '' if !File.file?(directory) && !create directory.to_s end From 2477fb21c55661ac677b14927d8cbb8f31a7b14b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:15:41 +0300 Subject: [PATCH 328/488] ruby: Style/RedundantAssignment correct --- .../ruby/app/models/document_helper.rb | 16 ++++++++-------- .../ruby/app/models/track_helper.rb | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 5a8570a66..31da281ac 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -211,21 +211,21 @@ def create_demo(file_ext, sample, user) # get file url def get_file_uri(file_name, for_document_server) - uri = "#{get_server_url(for_document_server)}/" \ + "#{get_server_url(for_document_server)}/" \ "#{DocumentHelper.config_manager.storage_path}/" \ "#{cur_user_host_address(nil)}/" \ "#{ERB::Util.url_encode(file_name)}" - uri + end # get history path url def get_historypath_uri(file_name, version, file, is_serverUrl = true) # for redirection to my link user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' - uri = "#{get_server_url(is_serverUrl)}/downloadhistory/?"\ + "#{get_server_url(is_serverUrl)}/downloadhistory/?"\ "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}"\ "&file=#{ERB::Util.url_encode(file)}#{user_host}" - uri + end # get server url @@ -258,7 +258,7 @@ def get_download_url(file_name, is_serverUrl = true) # get internal file extension by its type def get_internal_extension(file_type) - ext = case file_type + case file_type when 'word' # .docx for word type '.docx' when 'cell' # .xlsx for cell type @@ -269,13 +269,13 @@ def get_internal_extension(file_type) '.docx' # the default value is .docx end - ext + end # get image url for templates def get_template_image_url(file_type) path = "#{get_server_url(true)}/assets/" - full_path = case file_type + case file_type when 'word' # for word type "#{path}file_docx.svg" when 'cell' # .xlsx for cell type @@ -286,7 +286,7 @@ def get_template_image_url(file_type) "#{path}file_docx.svg" # the default value is .docx end - full_path + end # get files information diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index aee649111..804d74125 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -293,8 +293,8 @@ def command_request(method, key, meta = nil) raise ex.message end - json_data = JSON.parse(data) # convert the response body into the json format - json_data + JSON.parse(data) # convert the response body into the json format + end # save file from the url From 498268a7a3c93206cfb5ca682e01c649a0ef5c1e Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:18:54 +0300 Subject: [PATCH 329/488] ruby: Style/ParenthesesAroundCondition correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 31da281ac..460efe632 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -230,10 +230,10 @@ def get_historypath_uri(file_name, version, file, is_serverUrl = true) # get server url def get_server_url(for_document_server) - return DocumentHelper.config_manager.example_uri.to_s if ( + return DocumentHelper.config_manager.example_uri.to_s if for_document_server && DocumentHelper.config_manager.example_uri - ) + @@base_url end From 24ff9ce804e4c66e0b3d0de4594ea03ca1d5570c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:21:29 +0300 Subject: [PATCH 330/488] ruby: Style/NegatedIf correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 2 +- .../ruby/app/models/service_converter.rb | 4 ++-- web/documentserver-example/ruby/app/models/track_helper.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 460efe632..e73bf1a2b 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -315,7 +315,7 @@ def get_files_info(file_id) end end - return '"File not found"' if !file_id.nil? + return '"File not found"' unless file_id.nil? result end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 89717134c..a598fa90d 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -137,7 +137,7 @@ def get_response_data(json_data) file_result = json_data error_element = file_result['error'] - if !error_element.nil? # if an error occurs + unless error_element.nil? # if an error occurs process_convert_service_responce_error(error_element.to_i) # get an error message end @@ -164,7 +164,7 @@ def get_response_data(json_data) percent_element = file_result['percent'] # get the percentage value - result_percent = percent_element.to_i if !percent_element.nil? + result_percent = percent_element.to_i unless percent_element.nil? result_percent = result_percent >= 100 ? 99 : result_percent diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 804d74125..72fdb5b36 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -267,7 +267,7 @@ def command_request(method, key, meta = nil) key: } - payload.merge!({ meta: }) if !meta.nil? + payload.merge!({ meta: }) unless meta.nil? data = nil begin From 9cbb946c8f26a7860c032930c9c968a7d7b7f026 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:24:36 +0300 Subject: [PATCH 331/488] ruby: Style/MultilineTernaryOperator correct --- .../ruby/app/models/file_model.rb | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index f29efeb86..99b92aeb7 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -50,8 +50,12 @@ def file_uri # get file uri for document server def file_uri_user - @config_manager.storage_path.absolute? ? "#{download_url}&dmode=emb" : DocumentHelper.get_file_uri(@file_name, + if @config_manager.storage_path.absolute? + "#{download_url}&dmode=emb" +else + DocumentHelper.get_file_uri(@file_name, false) +end end # get document type from its name (word, cell or slide) @@ -144,8 +148,12 @@ def get_config }, referenceData: { instanceId: DocumentHelper.get_server_url(false), - fileKey: !@user.id.eql?('uid-0') ? { fileName: @file_name, - userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json : nil + fileKey: if !@user.id.eql?('uid-0') + { fileName: @file_name, + userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json +else + nil +end } }, editorConfig: { @@ -248,8 +256,12 @@ def get_history dataObj['url'] = i == cur_ver ? doc_uri : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}") if is_enable_direct_url == true dataObj['directUrl'] = - i == cur_ver ? download_url(false) : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", + if i == cur_ver + download_url(false) +else + DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", false) +end end dataObj['version'] = i From 0728a71f010a292f914d90957daa84960f1cdf4b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:25:19 +0300 Subject: [PATCH 332/488] ruby: Style/EmptyElse correct --- web/documentserver-example/ruby/app/models/file_model.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 99b92aeb7..f39ece392 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -151,8 +151,6 @@ def get_config fileKey: if !@user.id.eql?('uid-0') { fileName: @file_name, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json -else - nil end } }, @@ -166,8 +164,6 @@ def get_config mode: 'strict', change: false } - else - nil end, createUrl: !@user.id.eql?('uid-0') ? create_url : nil, templates: @user.templates ? templates : nil, From f4d838710c3e03144dda4ddf69aa175ac1b5aa13 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:25:59 +0300 Subject: [PATCH 333/488] ruby: Style/MultilineIfModifier correct --- web/documentserver-example/ruby/app/models/track_helper.rb | 6 ++++-- web/documentserver-example/ruby/app/models/users.rb | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 72fdb5b36..c833ee45c 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -234,8 +234,10 @@ def process_force_save(file_data, file_name, user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, - user_address) if new_file_name + if new_file_name + file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, + user_address) + end forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) if forcesave_path.eql?('') # if the path to the new file doesn't exist, create it diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 6d178dcd2..e66c942f8 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -128,8 +128,10 @@ def get_user(id) def get_users_for_mentions(id) usersData = [] @@users.each do |user| - usersData.push({ name: user.name, - email: user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? + if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? + usersData.push({ name: user.name, + email: user.email }) + end end usersData end From 684fa89c1354020f37c8fe40181d23abd7b55b23 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 14:57:15 +0300 Subject: [PATCH 334/488] ruby: Style/EmptyLineAfterMagicComment correct --- web/documentserver-example/ruby/Gemfile | 1 + web/documentserver-example/ruby/Rakefile | 1 + .../ruby/app/controllers/application_controller.rb | 1 + .../ruby/app/controllers/home_controller.rb | 1 + .../ruby/app/helpers/application_helper.rb | 1 + web/documentserver-example/ruby/app/helpers/home_helper.rb | 1 + web/documentserver-example/ruby/app/models/document_helper.rb | 1 + web/documentserver-example/ruby/app/models/file_model.rb | 1 + web/documentserver-example/ruby/app/models/file_utility.rb | 1 + web/documentserver-example/ruby/app/models/jwt_helper.rb | 1 + web/documentserver-example/ruby/app/models/service_converter.rb | 1 + web/documentserver-example/ruby/app/models/track_helper.rb | 1 + web/documentserver-example/ruby/app/models/users.rb | 1 + web/documentserver-example/ruby/config.ru | 1 + web/documentserver-example/ruby/config/application.rb | 1 + web/documentserver-example/ruby/config/boot.rb | 1 + 16 files changed, 16 insertions(+) diff --git a/web/documentserver-example/ruby/Gemfile b/web/documentserver-example/ruby/Gemfile index 45e26a0cb..753e0bdfa 100644 --- a/web/documentserver-example/ruby/Gemfile +++ b/web/documentserver-example/ruby/Gemfile @@ -1,4 +1,5 @@ # frozen_string_literal: true + source 'https://rubygems.org' gem 'byebug', '~> 11.1', groups: %i[development test] diff --git a/web/documentserver-example/ruby/Rakefile b/web/documentserver-example/ruby/Rakefile index bb8920958..fd960c20f 100644 --- a/web/documentserver-example/ruby/Rakefile +++ b/web/documentserver-example/ruby/Rakefile @@ -1,4 +1,5 @@ # frozen_string_literal: true + require 'rake/testtask' require_relative 'config/application' diff --git a/web/documentserver-example/ruby/app/controllers/application_controller.rb b/web/documentserver-example/ruby/app/controllers/application_controller.rb index b6d3299e5..7f694b6cf 100644 --- a/web/documentserver-example/ruby/app/controllers/application_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/application_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 86a5a7e2b..56a2a6f75 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/helpers/application_helper.rb b/web/documentserver-example/ruby/app/helpers/application_helper.rb index 3e7976e0a..8e77b5bd5 100644 --- a/web/documentserver-example/ruby/app/helpers/application_helper.rb +++ b/web/documentserver-example/ruby/app/helpers/application_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/helpers/home_helper.rb b/web/documentserver-example/ruby/app/helpers/home_helper.rb index 421fa0789..de8697270 100644 --- a/web/documentserver-example/ruby/app/helpers/home_helper.rb +++ b/web/documentserver-example/ruby/app/helpers/home_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index e73bf1a2b..78bd7e16c 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index f39ece392..ed2b53faf 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/file_utility.rb b/web/documentserver-example/ruby/app/models/file_utility.rb index 5e7965a86..b25c3d3b7 100644 --- a/web/documentserver-example/ruby/app/models/file_utility.rb +++ b/web/documentserver-example/ruby/app/models/file_utility.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 842c89f29..1ca705192 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index a598fa90d..3990af67f 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index c833ee45c..4582f25af 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index e66c942f8..9ce9730e7 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # # (c) Copyright Ascensio System SIA 2023 # diff --git a/web/documentserver-example/ruby/config.ru b/web/documentserver-example/ruby/config.ru index edb2b97b1..ff628ad77 100644 --- a/web/documentserver-example/ruby/config.ru +++ b/web/documentserver-example/ruby/config.ru @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'config/application' Rails.application.initialize! diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index 6f8a36e1c..94076a0f3 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require_relative 'boot' require 'active_model/railtie' diff --git a/web/documentserver-example/ruby/config/boot.rb b/web/documentserver-example/ruby/config/boot.rb index 3ceeeffec..2d46de4ca 100644 --- a/web/documentserver-example/ruby/config/boot.rb +++ b/web/documentserver-example/ruby/config/boot.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' From f87fc045d331fad3a83af45a40ec2a33a3e40ea7 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 15:00:09 +0300 Subject: [PATCH 335/488] ruby: Lint/UselessAssignment correct --- .../ruby/app/controllers/home_controller.rb | 8 ++++---- .../ruby/app/models/file_model.rb | 2 +- .../ruby/app/models/track_helper.rb | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 56a2a6f75..154d64f14 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -162,7 +162,7 @@ def downloadhistory user_address = params[:userAddress] version = params[:ver] file = params[:file] - isEmbedded = params[:dmode] + params[:dmode] if JwtHelper.is_enabled && JwtHelper.use_for_request jwtHeader = HomeController.config_manager.jwt_header @@ -190,7 +190,7 @@ def downloadhistory response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file)}" send_file file_path, x_sendfile: true - rescue StandardError => ex + rescue StandardError render plain: '{ "error": "File not found"}' end @@ -210,7 +210,7 @@ def track if status == 1 && (file_data['actions'][0]['type']).zero? # finished edit user = file_data['actions'][0]['userid'] # get the user id unless file_data['users'].index(user) - json_data = TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command + TrackHelper.command_request('forcesave', file_data['key']) # call the forcesave command end end @@ -306,7 +306,7 @@ def download response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" send_file file_path, x_sendfile: true - rescue StandardError => ex + rescue StandardError render plain: '{ "error": "File not found"}' end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index ed2b53faf..164b199e6 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -264,7 +264,7 @@ def get_history if i > 1 # check if the version number is greater than 1 changes = nil - change = nil + nil # get the path to the changes.json file File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), 'changes.json'), 'r') do |file| changes = JSON.parse(file.read) # and parse its content diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 4582f25af..c97b12760 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -108,7 +108,7 @@ def process_save(raw_file_data, file_name, user_address) unless cur_ext.eql?(download_ext) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data( + _, new_file_uri, _ = ServiceConverter.get_converted_data( download_uri, download_ext.delete('.'), cur_ext.delete('.'), @@ -124,7 +124,7 @@ def process_save(raw_file_data, file_name, user_address) else download_uri = new_file_uri end - rescue StandardError => msg + rescue StandardError new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) end @@ -173,7 +173,7 @@ def process_save(raw_file_data, file_name, user_address) end saved = 0 - rescue StandardError => msg + rescue StandardError saved = 1 end @@ -198,7 +198,7 @@ def process_force_save(file_data, file_name, user_address) unless cur_ext.eql?(download_ext) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin - percent, new_file_uri, new_file_type = ServiceConverter.get_converted_data( + _, new_file_uri, _ = ServiceConverter.get_converted_data( download_uri, download_ext.delete('.'), cur_ext.delete('.'), @@ -211,7 +211,7 @@ def process_force_save(file_data, file_name, user_address) else download_uri = new_file_uri end - rescue StandardError => msg + rescue StandardError new_file_name = true end end @@ -255,7 +255,7 @@ def process_force_save(file_data, file_name, user_address) end saved = 0 - rescue StandardError => msg + rescue StandardError saved = 1 end From c0135c52c5db8c465d88cede93d47b1419283b60 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 15:02:01 +0300 Subject: [PATCH 336/488] ruby: Layout/TrailingWhitespace correct --- .../ruby/app/models/document_helper.rb | 45 ++++++++----------- .../ruby/app/models/file_model.rb | 26 +++++------ .../ruby/app/models/track_helper.rb | 1 - 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 78bd7e16c..6f21b61fe 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -216,7 +216,6 @@ def get_file_uri(file_name, for_document_server) "#{DocumentHelper.config_manager.storage_path}/" \ "#{cur_user_host_address(nil)}/" \ "#{ERB::Util.url_encode(file_name)}" - end # get history path url @@ -226,15 +225,13 @@ def get_historypath_uri(file_name, version, file, is_serverUrl = true) "#{get_server_url(is_serverUrl)}/downloadhistory/?"\ "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}"\ "&file=#{ERB::Util.url_encode(file)}#{user_host}" - end # get server url def get_server_url(for_document_server) - return DocumentHelper.config_manager.example_uri.to_s if + return DocumentHelper.config_manager.example_uri.to_s if for_document_server && DocumentHelper.config_manager.example_uri - @@base_url end @@ -260,34 +257,30 @@ def get_download_url(file_name, is_serverUrl = true) # get internal file extension by its type def get_internal_extension(file_type) case file_type - when 'word' # .docx for word type - '.docx' - when 'cell' # .xlsx for cell type - '.xlsx' - when 'slide' # .pptx for slide type - '.pptx' - else - '.docx' # the default value is .docx - end - - + when 'word' # .docx for word type + '.docx' + when 'cell' # .xlsx for cell type + '.xlsx' + when 'slide' # .pptx for slide type + '.pptx' + else + '.docx' # the default value is .docx + end end # get image url for templates def get_template_image_url(file_type) path = "#{get_server_url(true)}/assets/" case file_type - when 'word' # for word type - "#{path}file_docx.svg" - when 'cell' # .xlsx for cell type - "#{path}file_xlsx.svg" - when 'slide' # .pptx for slide type - "#{path}file_pptx.svg" - else - "#{path}file_docx.svg" # the default value is .docx - end - - + when 'word' # for word type + "#{path}file_docx.svg" + when 'cell' # .xlsx for cell type + "#{path}file_xlsx.svg" + when 'slide' # .pptx for slide type + "#{path}file_pptx.svg" + else + "#{path}file_docx.svg" # the default value is .docx + end end # get files information diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 164b199e6..b9ffbc706 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -52,11 +52,11 @@ def file_uri # get file uri for document server def file_uri_user if @config_manager.storage_path.absolute? - "#{download_url}&dmode=emb" -else - DocumentHelper.get_file_uri(@file_name, - false) -end + "#{download_url}&dmode=emb" + else + DocumentHelper.get_file_uri(@file_name, + false) + end end # get document type from its name (word, cell or slide) @@ -150,9 +150,9 @@ def get_config referenceData: { instanceId: DocumentHelper.get_server_url(false), fileKey: if !@user.id.eql?('uid-0') - { fileName: @file_name, - userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json -end + { fileName: @file_name, + userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json + end } }, editorConfig: { @@ -254,11 +254,11 @@ def get_history if is_enable_direct_url == true dataObj['directUrl'] = if i == cur_ver - download_url(false) -else - DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", - false) -end + download_url(false) + else + DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", + false) + end end dataObj['version'] = i diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index c97b12760..65885d46a 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -297,7 +297,6 @@ def command_request(method, key, meta = nil) end JSON.parse(data) # convert the response body into the json format - end # save file from the url From ea15f12551a56dfeb342c86812290f040527524c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Wed, 15 Nov 2023 18:18:56 +0300 Subject: [PATCH 337/488] ruby: Style/TrailingUnderscoreVariable correct --- web/documentserver-example/ruby/app/models/track_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 65885d46a..c0b77908c 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -108,7 +108,7 @@ def process_save(raw_file_data, file_name, user_address) unless cur_ext.eql?(download_ext) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin - _, new_file_uri, _ = ServiceConverter.get_converted_data( + _, new_file_uri, = ServiceConverter.get_converted_data( download_uri, download_ext.delete('.'), cur_ext.delete('.'), @@ -198,7 +198,7 @@ def process_force_save(file_data, file_name, user_address) unless cur_ext.eql?(download_ext) key = ServiceConverter.generate_revision_id(download_uri) # get the document key begin - _, new_file_uri, _ = ServiceConverter.get_converted_data( + _, new_file_uri, = ServiceConverter.get_converted_data( download_uri, download_ext.delete('.'), cur_ext.delete('.'), From c639ba42877ae1a86cb4666ba9d32f5dc11380ff Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 16 Nov 2023 10:15:11 +0300 Subject: [PATCH 338/488] ruby: Style/NegatedIf correct --- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index b9ffbc706..533207f85 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -149,7 +149,7 @@ def get_config }, referenceData: { instanceId: DocumentHelper.get_server_url(false), - fileKey: if !@user.id.eql?('uid-0') + fileKey: unless @user.id.eql?('uid-0') { fileName: @file_name, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json end From c5315de84f035349602ad9a67e5ee3b94e1921a8 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 16 Nov 2023 10:16:22 +0300 Subject: [PATCH 339/488] ruby: Lint/Void correct --- web/documentserver-example/ruby/app/models/file_model.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 533207f85..9a2c3c28b 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -264,7 +264,6 @@ def get_history if i > 1 # check if the version number is greater than 1 changes = nil - nil # get the path to the changes.json file File.open(File.join(DocumentHelper.version_dir(hist_dir, i - 1), 'changes.json'), 'r') do |file| changes = JSON.parse(file.read) # and parse its content From acdb60dd3b938d2652ab38fa3f07520ce08c392c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 16 Nov 2023 11:48:56 +0300 Subject: [PATCH 340/488] ruby: Style/ClassVars correct --- .../ruby/app/models/document_helper.rb | 14 +++++----- .../ruby/app/models/service_converter.rb | 10 +++---- .../ruby/app/models/track_helper.rb | 6 ++-- .../ruby/app/models/users.rb | 28 +++++++++---------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 6f21b61fe..279efe075 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -27,14 +27,14 @@ class << self attr_reader :config_manager, :format_manager end - @@runtime_cache = {} - @@remote_ip = nil - @@base_url = nil + @runtime_cache = {} + @remote_ip = nil + @base_url = nil class << self def init(ip, url) - @@remote_ip = ip - @@base_url = url + @remote_ip = ip + @base_url = url end # define max file size @@ -68,7 +68,7 @@ def convert_exts # get current user host address def cur_user_host_address(user_address) - (user_address.nil? ? @@remote_ip : user_address).gsub(/[^0-9\-.a-zA-Z_=]/, '_') + (user_address.nil? ? @remote_ip : user_address).gsub(/[^0-9\-.a-zA-Z_=]/, '_') end # get the storage path of the given file @@ -233,7 +233,7 @@ def get_server_url(for_document_server) for_document_server && DocumentHelper.config_manager.example_uri - @@base_url + @base_url end # get callback url diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 3990af67f..832e09648 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -25,8 +25,8 @@ class << self attr_reader :config_manager end - @@convert_timeout = ServiceConverter.config_manager.convertation_timeout - @@document_converter_url = ServiceConverter.config_manager.document_server_converter_uri.to_s + @convert_timeout = ServiceConverter.config_manager.convertation_timeout + @document_converter_url = ServiceConverter.config_manager.document_server_converter_uri.to_s class << self # get the url of the converted file @@ -54,12 +54,12 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ data = nil begin - uri = URI.parse(@@document_converter_url) # create the request url + uri = URI.parse(@document_converter_url) # create the request url http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - DocumentHelper.verify_ssl(@@document_converter_url, http) + DocumentHelper.verify_ssl(@document_converter_url, http) - http.read_timeout = @@convert_timeout + http.read_timeout = @convert_timeout http.open_timeout = 5 req = Net::HTTP::Post.new(uri.request_uri) # create the post request req.add_field('Accept', 'application/json') # set headers diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index c0b77908c..d900867ba 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -29,7 +29,7 @@ class << self attr_reader :config_manager, :proxy_manager end - @@document_command_url = TrackHelper.config_manager.document_server_command_uri.to_s + @document_command_url = TrackHelper.config_manager.document_server_command_uri.to_s class << self # read the request body @@ -274,10 +274,10 @@ def command_request(method, key, meta = nil) data = nil begin - uri = URI.parse(@@document_command_url) # parse the document command url + uri = URI.parse(@document_command_url) # parse the document command url http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - DocumentHelper.verify_ssl(@@document_command_url, http) + DocumentHelper.verify_ssl(@document_command_url, http) req = Net::HTTP::Post.new(uri.request_uri) # create the post request req.add_field('Content-Type', 'application/json') # set headers diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 9ce9730e7..146dee2c0 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -38,7 +38,7 @@ def initialize(id, name, email, group, reviewGroups, commentGroups, userInfoGrou end class Users - @@descr_user_1 = [ + @descr_user_1 = [ 'File author by default', 'Doesn’t belong to any group', 'Can review all the changes', @@ -49,7 +49,7 @@ class Users 'Has an avatar' ] - @@descr_user_2 = [ + @descr_user_2 = [ 'Belongs to Group2', 'Can review only his own changes or changes made by users with no group', 'Can view comments, edit his own comments, and comments left by users with no group. ' \ @@ -60,7 +60,7 @@ class Users 'Has an avatar' ] - @@descr_user_3 = [ + @descr_user_3 = [ 'Belongs to Group3', 'Can review changes made by Group2 users', 'Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users', @@ -72,7 +72,7 @@ class Users 'Can see the information about Group2 users' ] - @@descr_user_0 = [ + @descr_user_0 = [ 'The name is requested when the editor is opened', 'Doesn’t belong to any group', 'Can review all the changes', @@ -87,10 +87,10 @@ class Users 'View file without collaboration' ] - @@users = [ + @users = [ User.new('uid-1', 'John Smith', 'smith@example.com', '', nil, {}, nil, - nil, [], @@descr_user_1, true, true), + nil, [], @descr_user_1, true, true), User.new('uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', ['group-2', ''], { view: '', @@ -98,7 +98,7 @@ class Users remove: ['group-2'] }, ['group-2', ''], - true, [], @@descr_user_2, false, true), + true, [], @descr_user_2, false, true), User.new('uid-3', 'Hamish Mitchell', nil, 'group-3', ['group-2'], { view: %w[group-3 group-2], @@ -106,29 +106,29 @@ class Users remove: [] }, ['group-2'], - false, %w[copy download print], @@descr_user_3, false, false), + false, %w[copy download print], @descr_user_3, false, false), User.new('uid-0', nil, nil, '', nil, {}, [], - nil, ['protect'], @@descr_user_0, false, false) + nil, ['protect'], @descr_user_0, false, false) ] class << self def get_all_users - @@users + @users end # get a user by id specified def get_user(id) - @@users.each do |user| + @users.each do |user| return user if user.id.eql?(id) end - @@users[0] + @users[0] end # get a list of users with their names and emails for mentions def get_users_for_mentions(id) usersData = [] - @@users.each do |user| + @users.each do |user| if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? usersData.push({ name: user.name, email: user.email }) @@ -140,7 +140,7 @@ def get_users_for_mentions(id) # get a list of users with their id, names and emails for protect def get_users_for_protect(id) users_data = [] - @@users.each do |user| + @users.each do |user| users_data.push({ id: user.id, name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? end users_data From 4536f83d105527206b06f2a18e2ed4e4f32dc9ba Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 16 Nov 2023 12:26:27 +0300 Subject: [PATCH 341/488] ruby: Style/OptionalBooleanParameter correct --- .../ruby/app/controllers/home_controller.rb | 2 +- .../ruby/app/models/document_helper.rb | 4 ++-- .../ruby/app/models/file_model.rb | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 154d64f14..3a90bdd67 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -424,7 +424,7 @@ def reference ".#{File.mtime(DocumentHelper.storage_path(fileName, nil))}" ), url: DocumentHelper.get_download_url(fileName), - directUrl: body['directUrl'] ? DocumentHelper.get_download_url(fileName, false) : nil, + directUrl: body['directUrl'] ? DocumentHelper.get_download_url(fileName, is_serverUrl: false) : nil, referenceData: { instanceId: DocumentHelper.get_server_url(false), fileKey: { fileName:, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 279efe075..b31fec823 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -219,7 +219,7 @@ def get_file_uri(file_name, for_document_server) end # get history path url - def get_historypath_uri(file_name, version, file, is_serverUrl = true) + def get_historypath_uri(file_name, version, file, is_serverUrl: true) # for redirection to my link user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' "#{get_server_url(is_serverUrl)}/downloadhistory/?"\ @@ -249,7 +249,7 @@ def get_create_url(document_type) end # get url to download a file - def get_download_url(file_name, is_serverUrl = true) + def get_download_url(file_name, is_serverUrl: true) user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' "#{get_server_url(is_serverUrl)}/download?fileName=#{ERB::Util.url_encode(file_name)}#{user_host}" end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 9a2c3c28b..04f316dc0 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -82,8 +82,8 @@ def create_url end # get url to download a file - def download_url(is_serverUrl = true) - DocumentHelper.get_download_url(@file_name, is_serverUrl) + def download_url(is_serverUrl: true) + DocumentHelper.get_download_url(@file_name, is_serverUrl:) end # get current user host address @@ -123,7 +123,7 @@ def get_config document: { title: @file_name, url: download_url, - directUrl: is_enable_direct_url ? download_url(false) : '', + directUrl: is_enable_direct_url ? download_url(is_serverUrl: false) : '', fileType: file_ext.delete('.'), key:, info: { @@ -176,11 +176,11 @@ def get_config }, embedded: { # the parameters for the embedded document type # the absolute URL that will allow the document to be saved onto the user personal computer - saveUrl: download_url(false), + saveUrl: download_url(is_serverUrl: false), # the absolute URL to the document serving as a source file for the document embedded into the web page - embedUrl: download_url(false), + embedUrl: download_url(is_serverUrl: false), # the absolute URL that will allow other users to share this document - shareUrl: download_url(false), + shareUrl: download_url(is_serverUrl: false), toolbarDocked: 'top' # the place for the embedded viewer toolbar (top or bottom) }, customization: { # the parameters for the editor interface @@ -254,7 +254,7 @@ def get_history if is_enable_direct_url == true dataObj['directUrl'] = if i == cur_ver - download_url(false) + download_url(is_serverUrl: false) else DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", false) From 1cd457c5c6656253bbe68f8937b4689a5e279f59 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 16 Nov 2023 13:35:06 +0300 Subject: [PATCH 342/488] ruby: Lint/DuplicateMethods correct --- web/documentserver-example/ruby/app/models/file_model.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 04f316dc0..fab5a02f5 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -26,7 +26,7 @@ class FileModel def initialize(attributes = {}) @file_name = attributes[:file_name] @mode = attributes[:mode] - @type = attributes[:type] + @type = attributes[:type] || 'desktop' # the default platform type is desktop @user_ip = attributes[:user_ip] @lang = attributes[:lang] @user = attributes[:user] @@ -35,10 +35,6 @@ def initialize(attributes = {}) @config_manager = ConfigurationManager.new end - def type - @type || 'desktop' # the default platform type is desktop - end - # get file extension from its name def file_ext File.extname(@file_name).downcase From 902ad1341cc24ca1bbfbfeb585f4e2043f7aa731 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 16 Nov 2023 15:16:47 +0300 Subject: [PATCH 343/488] ruby: Naming/RescuedExceptionsVariableName correct --- .../ruby/app/controllers/home_controller.rb | 16 ++++++++-------- .../ruby/app/models/service_converter.rb | 4 ++-- .../ruby/app/models/track_helper.rb | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 3a90bdd67..7f1e5c09c 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -86,8 +86,8 @@ def upload # write a new file name to the response render plain: "{ \"filename\": \"#{file_name}\", \"documentType\": \"#{document_type}\"}" - rescue StandardError => ex - render plain: "{ \"error\": \"#{ex.message}\"}" # write an error message to the response + rescue StandardError => e + render plain: "{ \"error\": \"#{e.message}\"}" # write an error message to the response end end @@ -152,8 +152,8 @@ def convert end render plain: "{ \"filename\" : \"#{file_name}\"}" - rescue StandardError => ex - render plain: "{ \"error\": \"#{ex.message}\"}" + rescue StandardError => e + render plain: "{ \"error\": \"#{e.message}\"}" end # downloading a history file from public @@ -349,8 +349,8 @@ def saveas render plain: "{\"file\" : \"#{file_name}\"}" nil - rescue StandardError => ex - render plain: "{\"error\":1, \"message\": \"#{ex.message}\"}" + rescue StandardError => e + render plain: "{\"error\":1, \"message\": \"#{e.message}\"}" nil end @@ -498,10 +498,10 @@ def restore error: nil, success: true } - rescue StandardError => error + rescue StandardError => e response.status = :internal_server_error render json: { - error: error.message, + error: e.message, success: false } end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 832e09648..15db3f251 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -81,8 +81,8 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ data = res.body # and take its body rescue Timeout::Error # try again - rescue StandardError => ex - raise ex.message + rescue StandardError => e + raise e.message end json_data = JSON.parse(data) # parse response body diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index d900867ba..558850dd3 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -292,8 +292,8 @@ def command_request(method, key, meta = nil) req.body = payload.to_json # convert the payload object into the json format res = http.request(req) # get the response data = res.body # and take its body - rescue StandardError => ex - raise ex.message + rescue StandardError => e + raise e.message end JSON.parse(data) # convert the response body into the json format From dafc66d5d842b3338d6d5bca215a0264c30d1a71 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Sun, 19 Nov 2023 02:38:42 +0300 Subject: [PATCH 344/488] ruby: Style/Documentation correct --- .../ruby/app/configuration/configuration.rb | 1 + .../app/configuration/configuration_tests.rb | 16 ++++++++++++++++ .../ruby/app/controllers/home_controller.rb | 1 + .../ruby/app/format/format.rb | 2 ++ .../ruby/app/format/format_tests.rb | 9 +++++++++ .../ruby/app/helpers/application_helper.rb | 1 + .../ruby/app/helpers/home_helper.rb | 1 + .../ruby/app/models/document_helper.rb | 1 + .../ruby/app/models/file_model.rb | 1 + .../ruby/app/models/file_utility.rb | 1 + .../ruby/app/models/jwt_helper.rb | 1 + .../ruby/app/models/service_converter.rb | 1 + .../ruby/app/models/track_helper.rb | 1 + .../ruby/app/models/users.rb | 2 ++ .../ruby/app/proxy/proxy.rb | 1 + .../ruby/app/proxy/proxy_tests.rb | 6 ++++++ .../ruby/config/application.rb | 1 + 17 files changed, 47 insertions(+) diff --git a/web/documentserver-example/ruby/app/configuration/configuration.rb b/web/documentserver-example/ruby/app/configuration/configuration.rb index c2c1846fb..c4efd7fe1 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration.rb @@ -22,6 +22,7 @@ require 'sorbet-runtime' require 'uri' +# ConfigurationManager manages configuration settings for the application. class ConfigurationManager extend T::Sig diff --git a/web/documentserver-example/ruby/app/configuration/configuration_tests.rb b/web/documentserver-example/ruby/app/configuration/configuration_tests.rb index d98e8977b..ccf94cdf6 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration_tests.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration_tests.rb @@ -20,6 +20,7 @@ require 'test/unit' require_relative 'configuration' +# Enviroment module provides a mechanism for capturing and restoring the environment. module Enviroment def initialize(name) @env = ENV.to_hash @@ -31,6 +32,7 @@ def setup end end +# For testing the ConfigurationManager class. class ConfigurationManagerTests < Test::Unit::TestCase def test_corresponds_the_latest_version config_manager = ConfigurationManager.new @@ -38,6 +40,7 @@ def test_corresponds_the_latest_version end end +# For testing the example_uri method of ConfigurationManager. class ConfigurationManagerExampleURITests < Test::Unit::TestCase include Enviroment @@ -55,6 +58,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the document_server_public_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerPublicURITests < Test::Unit::TestCase include Enviroment @@ -72,6 +76,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the document_server_private_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerPrivateURITests < Test::Unit::TestCase include Enviroment @@ -89,6 +94,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the document_server_api_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerAPIURITests < Test::Unit::TestCase include Enviroment @@ -112,6 +118,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the document_server_preloader_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerPreloaderURITests < Test::Unit::TestCase include Enviroment @@ -135,6 +142,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the document_server_command_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerCommandURITests < Test::Unit::TestCase include Enviroment @@ -158,6 +166,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the document_server_converter_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerConverterURITests < Test::Unit::TestCase include Enviroment @@ -181,6 +190,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the jwt_secret method of ConfigurationManager. class ConfigurationManagerJWTSecretTests < Test::Unit::TestCase include Enviroment @@ -198,6 +208,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the jwt_header method of ConfigurationManager. class ConfigurationManagerJWTHeaderTests < Test::Unit::TestCase include Enviroment @@ -215,6 +226,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the jwt_use_for_request method of ConfigurationManager. class ConfigurationManagerJWTUseForRequest < Test::Unit::TestCase include Enviroment @@ -232,6 +244,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the ssl_verify_peer_mode_enabled method of ConfigurationManager. class ConfigurationManagerSSLTests < Test::Unit::TestCase include Enviroment @@ -249,6 +262,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the storage_path method of ConfigurationManager. class ConfigurationManagerStoragePathTests < Test::Unit::TestCase include Enviroment @@ -275,6 +289,7 @@ def test_assigns_an_absolute_path_from_the_environment end end +# For testing the maximum_file_size method of ConfigurationManager. class ConfigurationManagerMaximumFileSizeTests < Test::Unit::TestCase include Enviroment @@ -292,6 +307,7 @@ def test_assigns_a_value_from_the_environment end end +# For testing the convertation_timeout method of ConfigurationManager. class ConfigurationManagerConversionTimeoutTests < Test::Unit::TestCase def test_assigns_a_default_value config_manager = ConfigurationManager.new diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 7f1e5c09c..fb1dcbd67 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -21,6 +21,7 @@ require 'mimemagic' require_relative '../configuration/configuration' +# Handling requests controller class HomeController < ApplicationController @config_manager = ConfigurationManager.new diff --git a/web/documentserver-example/ruby/app/format/format.rb b/web/documentserver-example/ruby/app/format/format.rb index 59bb56ea1..03f1a04e4 100644 --- a/web/documentserver-example/ruby/app/format/format.rb +++ b/web/documentserver-example/ruby/app/format/format.rb @@ -20,6 +20,7 @@ require 'pathname' require 'sorbet-runtime' +# Struct representing a document format with properties. class Format < T::Struct extend T::Sig @@ -40,6 +41,7 @@ def extension end end +# FormatManager is responsible for managing document formats and providing various lists of supported extensions. class FormatManager extend T::Sig diff --git a/web/documentserver-example/ruby/app/format/format_tests.rb b/web/documentserver-example/ruby/app/format/format_tests.rb index 62fba2662..8f199c249 100644 --- a/web/documentserver-example/ruby/app/format/format_tests.rb +++ b/web/documentserver-example/ruby/app/format/format_tests.rb @@ -21,6 +21,7 @@ require 'test/unit' require_relative 'format' +# Test case for the Format class. class FormatTests < Test::Unit::TestCase def test_generates_extension content = @@ -39,6 +40,7 @@ def test_generates_extension end end +# Test case for the FormatManager class, checks availability "all" formats. class FormatManagerAllTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -46,6 +48,7 @@ def test_loads end end +# Test case for the FormatManager class, checks availability "documents" formats. class FormatManagerDocumentsTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -53,6 +56,7 @@ def test_loads end end +# Test case for the FormatManager class, checks availability "presentations" formats. class FormatManagerPresentationsTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -60,6 +64,7 @@ def test_loads end end +# Test case for the FormatManager class, checks availability "spreadsheets" formats. class FormatManagerSpreadsheetsTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -67,6 +72,7 @@ def test_loads end end +# Test case for the FormatManager class, checks availability "all convertible" formats. class FormatManagerConvertibleTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -74,6 +80,7 @@ def test_loads end end +# Test case for the FormatManager class, checks availability "all editable" formats. class FormatManagerEditableTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -81,6 +88,7 @@ def test_loads end end +# Test case for the FormatManager class, checks availability "all viewable" formats. class FormatManagerViewableTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -88,6 +96,7 @@ def test_loads end end +# Test case for the FormatManager class, checks availability "all filable" formats. class FormatManagerFilableTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new diff --git a/web/documentserver-example/ruby/app/helpers/application_helper.rb b/web/documentserver-example/ruby/app/helpers/application_helper.rb index 8e77b5bd5..4715a54ec 100644 --- a/web/documentserver-example/ruby/app/helpers/application_helper.rb +++ b/web/documentserver-example/ruby/app/helpers/application_helper.rb @@ -16,5 +16,6 @@ # limitations under the License. # +# Helper for application module ApplicationHelper end diff --git a/web/documentserver-example/ruby/app/helpers/home_helper.rb b/web/documentserver-example/ruby/app/helpers/home_helper.rb index de8697270..71cde17a3 100644 --- a/web/documentserver-example/ruby/app/helpers/home_helper.rb +++ b/web/documentserver-example/ruby/app/helpers/home_helper.rb @@ -16,5 +16,6 @@ # limitations under the License. # +# Helper for home module HomeHelper end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index b31fec823..e1cc34957 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -19,6 +19,7 @@ require_relative '../configuration/configuration' require_relative '../format/format' +# Class that provides various utility methods related to documents. class DocumentHelper @config_manager = ConfigurationManager.new @format_manager = FormatManager.new diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index fab5a02f5..afd86c1f9 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -18,6 +18,7 @@ require_relative '../configuration/configuration' +# Class for handling file-related operations and information. class FileModel attr_accessor :file_name, :mode, :type, :user_ip, :lang, :user, :action_data, :direct_url attr_reader :config_manager diff --git a/web/documentserver-example/ruby/app/models/file_utility.rb b/web/documentserver-example/ruby/app/models/file_utility.rb index b25c3d3b7..52551f2a9 100644 --- a/web/documentserver-example/ruby/app/models/file_utility.rb +++ b/web/documentserver-example/ruby/app/models/file_utility.rb @@ -18,6 +18,7 @@ require_relative '../format/format' +# Determination file type based on extensions, utilizing `@format_manager` for format management. class FileUtility @format_manager = FormatManager.new diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 1ca705192..1a76b1145 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -19,6 +19,7 @@ require 'jwt' require_relative '../configuration/configuration' +# Helper class for JSON Web Token (JWT) operations, including encoding and decoding. class JwtHelper @jwt_secret = ConfigurationManager.new.jwt_secret @token_use_for_request = ConfigurationManager.new.jwt_use_for_request diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 15db3f251..c5475d6ca 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -18,6 +18,7 @@ require_relative '../configuration/configuration' +# Class responsible for converting documents using a document conversion service. class ServiceConverter @config_manager = ConfigurationManager.new diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 558850dd3..a396ccd2e 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -21,6 +21,7 @@ require_relative '../configuration/configuration' require_relative '../proxy/proxy' +# Helper class for managing document tracking functionalities, such as saving and processing documents. class TrackHelper @config_manager = ConfigurationManager.new @proxy_manager = ProxyManager.new(config_manager: @config_manager) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 146dee2c0..cb58a04e8 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -16,6 +16,7 @@ # limitations under the License. # +# Represents a user with various attributes class User attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, :deniedPermissions, :descriptions, :templates, :avatar @@ -37,6 +38,7 @@ def initialize(id, name, email, group, reviewGroups, commentGroups, userInfoGrou end end +# Manages user-related data and operations. class Users @descr_user_1 = [ 'File author by default', diff --git a/web/documentserver-example/ruby/app/proxy/proxy.rb b/web/documentserver-example/ruby/app/proxy/proxy.rb index fd5a364c1..8fee7df38 100644 --- a/web/documentserver-example/ruby/app/proxy/proxy.rb +++ b/web/documentserver-example/ruby/app/proxy/proxy.rb @@ -21,6 +21,7 @@ require 'uri' require_relative '../configuration/configuration' +# Class manages URI resolution, redirecting public URLs to private ones based on the configuration. class ProxyManager extend T::Sig diff --git a/web/documentserver-example/ruby/app/proxy/proxy_tests.rb b/web/documentserver-example/ruby/app/proxy/proxy_tests.rb index e51d69d8f..2240d09b2 100644 --- a/web/documentserver-example/ruby/app/proxy/proxy_tests.rb +++ b/web/documentserver-example/ruby/app/proxy/proxy_tests.rb @@ -20,7 +20,9 @@ require 'test/unit' require_relative 'proxy' +# Test case for ProxyManager resolving URIs that refer to public and non-public URLs. class ProxyManagerRefersTests < Test::Unit::TestCase + # Mocked configuration manager for testing. class MockedConfigurationManager < ConfigurationManager def document_server_public_uri URI('http://localhost') @@ -31,6 +33,7 @@ def document_server_private_uri end end + # Test case to ensure resolving a URI that refers to the public URI. def test_resolves_a_uri_that_refers_to_the_public_uri config_manager = MockedConfigurationManager.new proxy_manager = ProxyManager.new(config_manager:) @@ -43,13 +46,16 @@ def test_resolves_a_uri_that_refers_to_the_public_uri end end +# Test case for ProxyManager resolving a URL that does not refer to the public URL. class ProxyManagerDoesNotRefersTests < Test::Unit::TestCase + # Mocked configuration manager for testing. class MockedConfigurationManager < ConfigurationManager def document_server_public_uri URI('http://localhost') end end + # Test case to ensure resolving a URL that does not refer to the public URL. def test_resolves_a_url_that_does_not_refers_to_the_public_url config_manager = MockedConfigurationManager.new proxy_manager = ProxyManager.new(config_manager:) diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index 94076a0f3..f9c59aa3c 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -11,6 +11,7 @@ require 'securerandom' +# Configuration for the Rails application. class Application < Rails::Application config.middleware.insert_before 0, Rack::Cors do allow do From 9b0d3e1a2090cc561ef440ed962a03733c848a0a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Sun, 19 Nov 2023 23:39:10 +0300 Subject: [PATCH 345/488] ruby: Naming/VariableName correct --- .../ruby/app/controllers/home_controller.rb | 70 ++++---- .../ruby/app/models/document_helper.rb | 24 +-- .../ruby/app/models/file_model.rb | 156 +++++++++--------- .../ruby/app/models/service_converter.rb | 4 +- .../ruby/app/models/track_helper.rb | 16 +- .../ruby/app/models/users.rb | 23 ++- 6 files changed, 146 insertions(+), 147 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index fb1dcbd67..4e5ae852e 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -166,9 +166,9 @@ def downloadhistory params[:dmode] if JwtHelper.is_enabled && JwtHelper.use_for_request - jwtHeader = HomeController.config_manager.jwt_header - if request.headers[jwtHeader] - hdr = request.headers[jwtHeader] + jwt_header = HomeController.config_manager.jwt_header + if request.headers[jwt_header] + hdr = request.headers[jwt_header] hdr.slice!(0, 'Bearer '.length) token = JwtHelper.decode(hdr) if !token || token.eql?('') @@ -258,33 +258,33 @@ def remove # getting files information def files file_id = params[:fileId] - filesInfo = DocumentHelper.get_files_info(file_id) # get the information about the file specified by a file id - render json: filesInfo + files_info = DocumentHelper.get_files_info(file_id) # get the information about the file specified by a file id + render json: files_info end # downloading a csv file def csv file_name = 'csv.csv' - csvPath = Rails.root.join('assets', 'document-templates', 'sample', file_name) + csv_path = Rails.root.join('assets', 'document-templates', 'sample', file_name) # add headers to the response to specify the page parameters - response.headers['Content-Length'] = File.size(csvPath).to_s - response.headers['Content-Type'] = MimeMagic.by_path(csvPath).type + response.headers['Content-Length'] = File.size(csv_path).to_s + response.headers['Content-Type'] = MimeMagic.by_path(csv_path).type response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" - send_file csvPath, x_sendfile: true + send_file csv_path, x_sendfile: true end # downloading a file def download file_name = File.basename(params[:fileName]) user_address = params[:userAddress] - isEmbedded = params[:dmode] + is_embedded = params[:dmode] - if JwtHelper.is_enabled && isEmbedded.nil? && !user_address.nil? && JwtHelper.use_for_request - jwtHeader = HomeController.config_manager.jwt_header - if request.headers[jwtHeader] - hdr = request.headers[jwtHeader] + if JwtHelper.is_enabled && is_embedded.nil? && !user_address.nil? && JwtHelper.use_for_request + jwt_header = HomeController.config_manager.jwt_header + if request.headers[jwt_header] + hdr = request.headers[jwt_header] hdr.slice!(0, 'Bearer '.length) token = JwtHelper.decode(hdr) end @@ -376,20 +376,20 @@ def rename # ReferenceData def reference body = JSON.parse(request.body.read) - fileName = '' + file_name = '' if body.key?('referenceData') - referenceData = body['referenceData'] - instanceId = referenceData['instanceId'] - if instanceId == DocumentHelper.get_server_url(false) - fileKey = JSON.parse(referenceData['fileKey']) - userAddress = fileKey['userAddress'] - fileName = fileKey['fileName'] if userAddress == DocumentHelper.cur_user_host_address(nil) + reference_data = body['referenceData'] + instance_id = reference_data['instanceId'] + if instance_id == DocumentHelper.get_server_url(false) + file_key = JSON.parse(reference_data['fileKey']) + user_address = file_key['userAddress'] + file_name = file_key['fileName'] if user_address == DocumentHelper.cur_user_host_address(nil) end end link = body['link'] - if fileName.empty? && body.key?('link') + if file_name.empty? && body.key?('link') unless link.include?(DocumentHelper.get_server_url(false)) data = { url: link, @@ -401,37 +401,37 @@ def reference url_obj = URI(link) query_params = CGI.parse(url_obj.query) - fileName = query_params['fileName'].first - unless File.exist?(DocumentHelper.storage_path(fileName, nil)) + file_name = query_params['fileName'].first + unless File.exist?(DocumentHelper.storage_path(file_name, nil)) render plain: '{ "error": "File is not exist"}' return end end - if fileName.empty? && body.key?('path') + if file_name.empty? && body.key?('path') path = File.basename(body['path']) - fileName = path if File.exist?(DocumentHelper.storage_path(path, nil)) + file_name = path if File.exist?(DocumentHelper.storage_path(path, nil)) end - if fileName.empty? + if file_name.empty? render plain: '{ "error": "File not found"}' return end data = { - fileType: File.extname(fileName).downcase.delete('.'), + fileType: File.extname(file_name).downcase.delete('.'), key: ServiceConverter.generate_revision_id( - "#{DocumentHelper.cur_user_host_address(nil)}/#{fileName}" \ - ".#{File.mtime(DocumentHelper.storage_path(fileName, nil))}" + "#{DocumentHelper.cur_user_host_address(nil)}/#{file_name}" \ + ".#{File.mtime(DocumentHelper.storage_path(file_name, nil))}" ), - url: DocumentHelper.get_download_url(fileName), - directUrl: body['directUrl'] ? DocumentHelper.get_download_url(fileName, is_serverUrl: false) : nil, + url: DocumentHelper.get_download_url(file_name), + directUrl: body['directUrl'] ? DocumentHelper.get_download_url(file_name, is_serverUrl: false) : nil, referenceData: { instanceId: DocumentHelper.get_server_url(false), - fileKey: { fileName:, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json + fileKey: { fileName: file_name, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json }, - path: fileName, - link: "#{DocumentHelper.get_server_url(false)}/editor?fileName=#{fileName}" + path: file_name, + link: "#{DocumentHelper.get_server_url(false)}/editor?fileName=#{file_name}" } data['token'] = JwtHelper.encode(data) if JwtHelper.is_enabled diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index e1cc34957..fa469917c 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -141,10 +141,10 @@ def get_file_version(hist_dir) # get the correct file name if such a name already exists def get_correct_name(file_name, user_address) - maxName = 50 + max_name = 50 ext = File.extname(file_name) # get file extension # get file name without extension - base_name = File.basename(file_name, ext)[0...maxName] + (file_name.length > maxName ? '[...]' : '') + base_name = File.basename(file_name, ext)[0...max_name] + (file_name.length > max_name ? '[...]' : '') name = base_name + ext.downcase # get full file name index = 1 @@ -220,10 +220,10 @@ def get_file_uri(file_name, for_document_server) end # get history path url - def get_historypath_uri(file_name, version, file, is_serverUrl: true) + def get_historypath_uri(file_name, version, file, is_server_url: true) # for redirection to my link - user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' - "#{get_server_url(is_serverUrl)}/downloadhistory/?"\ + user_host = is_server_url ? "&userAddress=#{cur_user_host_address(nil)}" : '' + "#{get_server_url(is_server_url)}/downloadhistory/?"\ "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}"\ "&file=#{ERB::Util.url_encode(file)}#{user_host}" end @@ -250,9 +250,9 @@ def get_create_url(document_type) end # get url to download a file - def get_download_url(file_name, is_serverUrl: true) - user_host = is_serverUrl ? "&userAddress=#{cur_user_host_address(nil)}" : '' - "#{get_server_url(is_serverUrl)}/download?fileName=#{ERB::Util.url_encode(file_name)}#{user_host}" + def get_download_url(file_name, is_server_url: true) + user_host = is_server_url ? "&userAddress=#{cur_user_host_address(nil)}" : '' + "#{get_server_url(is_server_url)}/download?fileName=#{ERB::Util.url_encode(file_name)}#{user_host}" end # get internal file extension by its type @@ -288,9 +288,9 @@ def get_template_image_url(file_type) def get_files_info(file_id) result = [] - get_stored_files(nil).each do |fileName| # run through all the stored files from the folder - directory = storage_path(fileName, nil) - uri = "#{cur_user_host_address(nil)}/#{fileName}" + get_stored_files(nil).each do |file_name| # run through all the stored files from the folder + directory = storage_path(file_name, nil) + uri = "#{cur_user_host_address(nil)}/#{file_name}" # write file parameters to the info object info = { @@ -298,7 +298,7 @@ def get_files_info(file_id) 'id' => ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), 'contentLength' => "#{(File.size(directory) / 1024.0).round(2)} KB", 'pureContentLength' => File.size(directory), - 'title' => fileName, + 'title' => file_name, 'updated' => File.mtime(directory) } diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index afd86c1f9..ea6d7745f 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -79,8 +79,8 @@ def create_url end # get url to download a file - def download_url(is_serverUrl: true) - DocumentHelper.get_download_url(@file_name, is_serverUrl:) + def download_url(is_server_url: true) + DocumentHelper.get_download_url(@file_name, is_server_url:) end # get current user host address @@ -90,17 +90,17 @@ def cur_user_host_address # get config parameters def get_config - editorsmode = @mode || 'edit' # mode: view/edit/review/comment/fillForms/embedded - canEdit = DocumentHelper.edited_exts.include?(file_ext) # check if the document can be edited - if (!canEdit && editorsmode.eql?('edit') || editorsmode.eql?('fillForms')) && + editors_mode = @mode || 'edit' # mode: view/edit/review/comment/fillForms/embedded + can_edit = DocumentHelper.edited_exts.include?(file_ext) # check if the document can be edited + if (!can_edit && editors_mode.eql?('edit') || editors_mode.eql?('fillForms')) && DocumentHelper.fill_forms_exts.include?(file_ext) - editorsmode = 'fillForms' - canEdit = true + editors_mode = 'fillForms' + can_edit = true end - submitForm = editorsmode.eql?('fillForms') && @user.id.eql?('uid-1') && false # the Submit form button state - mode = canEdit && !editorsmode.eql?('view') ? 'edit' : 'view' + submit_form = editors_mode.eql?('fillForms') && @user.id.eql?('uid-1') && false # the Submit form button state + mode = can_edit && !editors_mode.eql?('view') ? 'edit' : 'view' # templates image url in the "From Template" section - templatesImageUrl = DocumentHelper.get_template_image_url(document_type) + templates_image_url = DocumentHelper.get_template_image_url(document_type) templates = [ { image: '', @@ -108,7 +108,7 @@ def get_config url: create_url }, { - image: templatesImageUrl, + image: templates_image_url, title: 'With sample content', url: "#{create_url}&sample=true" } @@ -120,7 +120,7 @@ def get_config document: { title: @file_name, url: download_url, - directUrl: is_enable_direct_url ? download_url(is_serverUrl: false) : '', + directUrl: is_enable_direct_url ? download_url(is_server_url: false) : '', fileType: file_ext.delete('.'), key:, info: { @@ -129,20 +129,20 @@ def get_config favorite: @user.favorite }, permissions: { # the permission for the document to be edited and downloaded or not - comment: !%w[view fillForms embedded blockcontent].include?(editorsmode), - copy: !@user.deniedPermissions.include?('copy'), - download: !@user.deniedPermissions.include?('download'), - edit: canEdit && %w[edit view filter blockcontent].include?(editorsmode), - print: !@user.deniedPermissions.include?('print'), - fillForms: !%w[view comment embedded blockcontent].include?(editorsmode), - modifyFilter: !editorsmode.eql?('filter'), - modifyContentControl: !editorsmode.eql?('blockcontent'), - review: canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('review')), + comment: !%w[view fillForms embedded blockcontent].include?(editors_mode), + copy: !@user.denied_permissions.include?('copy'), + download: !@user.denied_permissions.include?('download'), + edit: can_edit && %w[edit view filter blockcontent].include?(editors_mode), + print: !@user.denied_permissions.include?('print'), + fillForms: !%w[view comment embedded blockcontent].include?(editors_mode), + modifyFilter: !editors_mode.eql?('filter'), + modifyContentControl: !editors_mode.eql?('blockcontent'), + review: can_edit && (editors_mode.eql?('edit') || editors_mode.eql?('review')), chat: !@user.id.eql?('uid-0'), - reviewGroups: @user.reviewGroups, - commentGroups: @user.commentGroups, - userInfoGroups: @user.userInfoGroups, - protect: !@user.deniedPermissions.include?('protect') + reviewGroups: @user.review_groups, + commentGroups: @user.comment_groups, + userInfoGroups: @user.user_info_groups, + protect: !@user.denied_permissions.include?('protect') }, referenceData: { instanceId: DocumentHelper.get_server_url(false), @@ -157,7 +157,7 @@ def get_config mode:, lang: @lang || 'en', callbackUrl: callback_url, # absolute URL to the document storage service - coEditing: if editorsmode.eql?('view') && @user.id.eql?('uid-0') + coEditing: if editors_mode.eql?('view') && @user.id.eql?('uid-0') { mode: 'strict', change: false @@ -173,11 +173,11 @@ def get_config }, embedded: { # the parameters for the embedded document type # the absolute URL that will allow the document to be saved onto the user personal computer - saveUrl: download_url(is_serverUrl: false), + saveUrl: download_url(is_server_url: false), # the absolute URL to the document serving as a source file for the document embedded into the web page - embedUrl: download_url(is_serverUrl: false), + embedUrl: download_url(is_server_url: false), # the absolute URL that will allow other users to share this document - shareUrl: download_url(is_serverUrl: false), + shareUrl: download_url(is_server_url: false), toolbarDocked: 'top' # the place for the embedded viewer toolbar (top or bottom) }, customization: { # the parameters for the editor interface @@ -185,7 +185,7 @@ def get_config comments: true, feedback: true, # the Feedback & Support menu button display forcesave: false, # adding the request for the forced file saving to the callback handler - submitForm:, # the Submit form button state + submitForm: submit_form, # the Submit form button state goback: { url: DocumentHelper.get_server_url(false) } @@ -213,11 +213,11 @@ def get_history if cur_ver.positive? # if file was modified hist = [] - histData = {} + hist_data = {} (1..cur_ver).each do |i| # run through all the file versions obj = {} - dataObj = {} + data_obj = {} ver_dir = DocumentHelper.version_dir(hist_dir, i) # get the path to the given file version # get document key @@ -245,19 +245,19 @@ def get_history end # get the history data from the previous file version and write key and url information about it - dataObj['fileType'] = file_ext[1..file_ext.length] - dataObj['key'] = cur_key - dataObj['url'] = i == cur_ver ? doc_uri : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}") + data_obj['fileType'] = file_ext[1..file_ext.length] + data_obj['key'] = cur_key + data_obj['url'] = i == cur_ver ? doc_uri : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}") if is_enable_direct_url == true - dataObj['directUrl'] = + data_obj['directUrl'] = if i == cur_ver - download_url(is_serverUrl: false) + download_url(is_server_url: false) else DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", false) end end - dataObj['version'] = i + data_obj['version'] = i if i > 1 # check if the version number is greater than 1 changes = nil @@ -274,34 +274,34 @@ def get_history obj['created'] = change ? change['created'] : nil obj['user'] = change ? change['user'] : nil - prev = histData[(i - 2).to_s] # get the history data from the previous file version + prev = hist_data[(i - 2).to_s] # get the history data from the previous file version # write key and url information about previous file version with optional direct url - dataObj['previous'] = if is_enable_direct_url == true - { # write key and url information about previous file version with optional directUrl - fileType: prev['fileType'], - key: prev['key'], - url: prev['url'], - directUrl: prev['directUrl'] - } - else - { - fileType: prev['fileType'], - key: prev['key'], - url: prev['url'] - } - end + data obj['previous'] = if is_enable_direct_url == true + { # write key and url information about previous file version with optional directUrl + fileType: prev['fileType'], + key: prev['key'], + url: prev['url'], + directUrl: prev['directUrl'] + } + else + { + fileType: prev['fileType'], + key: prev['key'], + url: prev['url'] + } + end # write the path to the diff.zip archive with differences in this file version - dataObj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') + data_obj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') end if JwtHelper.is_enabled # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the data object - dataObj['token'] = JwtHelper.encode(dataObj) + data_obj['token'] = JwtHelper.encode(data_obj) end hist.push(obj) # add object dictionary to the hist list - histData[(i - 1).to_s] = dataObj # write data object information to the history data + hist_data[(i - 1).to_s] = data_obj # write data object information to the history data end return { @@ -309,7 +309,7 @@ def get_history currentVersion: cur_ver, history: hist }, - histData: + histData: hist_data } end @@ -376,28 +376,28 @@ def dataSpreadsheet # file type # server url to the mail merge recipients file # direct url to the mail merge recipients file - dataSpreadsheet = if is_enable_direct_url == true - { - fileType: 'csv', # file type - # server url to the mail merge recipients file - url: "#{DocumentHelper.get_server_url(true)}/csv", - # direct url to the mail merge recipients file - directUrl: "#{DocumentHelper.get_server_url(false)}/csv" - } - else - { - fileType: 'csv', # file type - # server url to the mail merge recipients file - url: "#{DocumentHelper.get_server_url(true)}/csv" - } - end + data_spreadsheet = if is_enable_direct_url == true + { + fileType: 'csv', # file type + # server url to the mail merge recipients file + url: "#{DocumentHelper.get_server_url(true)}/csv", + # direct url to the mail merge recipients file + directUrl: "#{DocumentHelper.get_server_url(false)}/csv" + } + else + { + fileType: 'csv', # file type + # server url to the mail merge recipients file + url: "#{DocumentHelper.get_server_url(true)}/csv" + } + end if JwtHelper.is_enabled # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the dataSpreadsheet object - dataSpreadsheet['token'] = JwtHelper.encode(dataSpreadsheet) + data_spreadsheet['token'] = JwtHelper.encode(data_spreadsheet) end - dataSpreadsheet + data_spreadsheet end # get users data for mentions @@ -415,11 +415,11 @@ def get_users_info name: user_info.name, email: user_info.email, group: user_info.group, - reviewGroups: user_info.reviewGroups, - commentGroups: user_info.commentGroups, - userInfoGroups: user_info.userInfoGroups, + reviewGroups: user_info.review_groups, + commentGroups: user_info.comment_groups, + userInfoGroups: user_info.user_info_groups, favorite: user_info.favorite, - deniedPermissions: user_info.deniedPermissions, + deniedPermissions: user_info.denied_permissions, descriptions: user_info.descriptions, templates: user_info.templates, avatar: user_info.avatar diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index c5475d6ca..e1731c29d 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -68,9 +68,9 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload - jwtHeader = ServiceConverter.config_manager.jwt_header; # get signature authorization header + jwt_header = ServiceConverter.config_manager.jwt_header; # get signature authorization header # set it to the request with the Bearer prefix - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") + req.add_field(jwt_header, "Bearer #{JwtHelper.encode({ payload: })}") end req.body = payload.to_json diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index a396ccd2e..120c4f4a0 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -43,16 +43,16 @@ def read_body(request) # check if a secret key to generate token exists or not if JwtHelper.is_enabled && JwtHelper.use_for_request - inHeader = false + in_header = false token = nil - jwtHeader = TrackHelper.config_manager.jwt_header; # get the authorization header from the config + jwt_header = TrackHelper.config_manager.jwt_header; # get the authorization header from the config if file_data['token'] # if the token is in the body token = JwtHelper.decode(file_data['token']) # decode a token into a payload object using a secret key - elsif request.headers[jwtHeader] # if the token is in the header - hdr = request.headers[jwtHeader] + elsif request.headers[jwt_header] # if the token is in the header + hdr = request.headers[jwt_header] hdr.slice!(0, 'Bearer '.length) # get token from it (after Bearer prefix) token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key - inHeader = true + in_header = true else raise 'Expected JWT' # token missing error message end @@ -61,7 +61,7 @@ def read_body(request) file_data = JSON.parse(token) - file_data = file_data['payload'] if inHeader + file_data = file_data['payload'] if in_header end file_data @@ -285,9 +285,9 @@ def command_request(method, key, meta = nil) if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload - jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header + jwt_header = TrackHelper.config_manager.jwt_header; # get signature authorization header # set it to the request with the Bearer prefix - req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") + req.add_field(jwt_header, "Bearer #{JwtHelper.encode({ payload: })}") end req.body = payload.to_json # convert the payload object into the json format diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index cb58a04e8..2659ee0b5 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -18,22 +18,22 @@ # Represents a user with various attributes class User - attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, - :deniedPermissions, :descriptions, :templates, :avatar + attr_accessor :id, :name, :email, :group, :review_groups, :comment_groups, :user_info_groups, :favorite, + :denied_permissions, :descriptions, :templates, :avatar - def initialize(id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, - deniedPermissions, descriptions, templates, avatar) + def initialize(id, name, email, group, review_groups, comment_groups, user_info_groups, favorite, + denied_permissions, descriptions, templates, avatar) @id = id @name = name @email = email @group = group - @reviewGroups = reviewGroups - @commentGroups = commentGroups + @review_groups = review_groups + @comment_groups = comment_groups @favorite = favorite - @deniedPermissions = deniedPermissions + @denied_permissions = denied_permissions @descriptions = descriptions @templates = templates - @userInfoGroups = userInfoGroups + @user_info_groups = user_info_groups @avatar = avatar end end @@ -129,14 +129,13 @@ def get_user(id) # get a list of users with their names and emails for mentions def get_users_for_mentions(id) - usersData = [] + users_data = [] @users.each do |user| if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? - usersData.push({ name: user.name, - email: user.email }) + users_data.push({ name: user.name, email: user.email }) end end - usersData + users_data end # get a list of users with their id, names and emails for protect From f955096fc00dbdb4ac3f27c1bc7dbc906e4eed94 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 00:11:39 +0300 Subject: [PATCH 346/488] ruby: Naming/VariableNumber correct --- .../ruby/app/models/users.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 2659ee0b5..d2e782e72 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -40,7 +40,7 @@ def initialize(id, name, email, group, review_groups, comment_groups, user_info_ # Manages user-related data and operations. class Users - @descr_user_1 = [ + @descr_user_first = [ 'File author by default', 'Doesn’t belong to any group', 'Can review all the changes', @@ -51,7 +51,7 @@ class Users 'Has an avatar' ] - @descr_user_2 = [ + @descr_user_second = [ 'Belongs to Group2', 'Can review only his own changes or changes made by users with no group', 'Can view comments, edit his own comments, and comments left by users with no group. ' \ @@ -62,7 +62,7 @@ class Users 'Has an avatar' ] - @descr_user_3 = [ + @descr_user_third = [ 'Belongs to Group3', 'Can review changes made by Group2 users', 'Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users', @@ -74,7 +74,7 @@ class Users 'Can see the information about Group2 users' ] - @descr_user_0 = [ + @descr_user_null = [ 'The name is requested when the editor is opened', 'Doesn’t belong to any group', 'Can review all the changes', @@ -92,7 +92,7 @@ class Users @users = [ User.new('uid-1', 'John Smith', 'smith@example.com', '', nil, {}, nil, - nil, [], @descr_user_1, true, true), + nil, [], @descr_user_first, true, true), User.new('uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', ['group-2', ''], { view: '', @@ -100,7 +100,7 @@ class Users remove: ['group-2'] }, ['group-2', ''], - true, [], @descr_user_2, false, true), + true, [], @descr_user_second, false, true), User.new('uid-3', 'Hamish Mitchell', nil, 'group-3', ['group-2'], { view: %w[group-3 group-2], @@ -108,10 +108,10 @@ class Users remove: [] }, ['group-2'], - false, %w[copy download print], @descr_user_3, false, false), + false, %w[copy download print], @descr_user_third, false, false), User.new('uid-0', nil, nil, '', nil, {}, [], - nil, ['protect'], @descr_user_0, false, false) + nil, ['protect'], @descr_user_null, false, false) ] class << self From f8d62ab8dbcaf5032679a53a42bdef4794e1d971 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 00:06:41 +0300 Subject: [PATCH 347/488] ruby: Naming/AccessorMethodName correct --- .../ruby/app/models/file_model.rb | 14 +++++++------- .../ruby/app/models/users.rb | 2 +- .../ruby/app/views/home/editor.html.erb | 12 ++++++------ .../ruby/app/views/home/index.html.erb | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index ea6d7745f..0630b41c4 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -89,7 +89,7 @@ def cur_user_host_address end # get config parameters - def get_config + def config editors_mode = @mode || 'edit' # mode: view/edit/review/comment/fillForms/embedded can_edit = DocumentHelper.edited_exts.include?(file_ext) # check if the document can be edited if (!can_edit && editors_mode.eql?('edit') || editors_mode.eql?('fillForms')) && @@ -201,7 +201,7 @@ def get_config end # get document history - def get_history + def history file_name = @file_name file_ext = File.extname(file_name).downcase doc_key = key @@ -317,7 +317,7 @@ def get_history end # get image information - def get_insert_image + def insert_image # image file type # server url to the image # direct url to the image @@ -401,15 +401,15 @@ def dataSpreadsheet end # get users data for mentions - def get_users_mentions + def users_mentions !@user.id.eql?('uid-0') ? Users.get_users_for_mentions(@user.id) : nil end - def get_users_info + def users_info users_info = [] return if @user.id.eql?('uid-0') - Users.get_all_users.each do |user_info| + Users.all_users.each do |user_info| u = { id: user_info.id, name: user_info.name, @@ -431,7 +431,7 @@ def get_users_info end # get users data for protect - def get_users_protect + def users_protect !@user.id.eql?('uid-0') ? Users.get_users_for_protect(@user.id) : nil end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index d2e782e72..c72d3677b 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -115,7 +115,7 @@ class Users ] class << self - def get_all_users + def all_users @users end diff --git a/web/documentserver-example/ruby/app/views/home/editor.html.erb b/web/documentserver-example/ruby/app/views/home/editor.html.erb index 323c959bc..97c88e289 100755 --- a/web/documentserver-example/ruby/app/views/home/editor.html.erb +++ b/web/documentserver-example/ruby/app/views/home/editor.html.erb @@ -102,7 +102,7 @@ var onRequestInsertImage = function(event) { docEditor.insertImage({ // insert an image into the file "c": event.data.c, - <%= raw @file.get_insert_image %> + <%= raw @file.insert_image %> }) }; @@ -216,7 +216,7 @@ var сonnectEditor = function () { - config = <%= raw @file.get_config.to_json %>; + config = <%= raw @file.config.to_json %>; config.width = "100%"; config.height = "100%"; @@ -234,8 +234,8 @@ }; <% - history = @file.get_history - usersMentions = @file.get_users_mentions %> + history = @file.history + usersMentions = @file.users_mentions %> if (config.editorConfig.user.id) { <% if history %> @@ -262,7 +262,7 @@ switch (c) { case "info": users = []; - var allUsers = <%= raw @file.get_users_info.to_json %>; + var allUsers = <%= raw @file.users_info.to_json %>; for (var i = 0; i < event.data.id.length; i++) { for (var j = 0; j < allUsers.length; j++) { if (allUsers[j].id == event.data.id[i]) { @@ -276,7 +276,7 @@ var users = <%= raw @file.get_users_protect.to_json %>; break; default: - users = <%= raw @file.get_users_mentions.to_json %>; + users = <%= raw @file.users_mentions.to_json %>; } docEditor.setUsers({ "c": c, diff --git a/web/documentserver-example/ruby/app/views/home/index.html.erb b/web/documentserver-example/ruby/app/views/home/index.html.erb index b9018e386..9da594a42 100755 --- a/web/documentserver-example/ruby/app/views/home/index.html.erb +++ b/web/documentserver-example/ruby/app/views/home/index.html.erb @@ -62,7 +62,7 @@ Username @@ -110,7 +110,7 @@ Please do NOT use this integration example on your own server without proper code modifications, it is intended for testing purposes only. In case you enabled this test example, disable it before going for production. You can open the same document using different users in different Web browser sessions, so you can check out multi-user editing functions. - <% for user in Users.get_all_users() do %> + <% for user in Users.all_users() do %>

<%= user.name ? user.name : "Anonymous" %>
    From 94d22003b5a4bc28c867db026f4a683563019f80 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 11:50:10 +0300 Subject: [PATCH 348/488] ruby: Naming/MethodName correct --- web/documentserver-example/ruby/app/models/file_model.rb | 6 +++--- .../ruby/app/views/home/editor.html.erb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 0630b41c4..97b2b6356 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -343,7 +343,7 @@ def insert_image end # get compared file information - def dataDocument + def data_document # file type # server url to the compared file # direct url to the compared file @@ -372,7 +372,7 @@ def dataDocument end # get mail merge recipients information - def dataSpreadsheet + def data_spreadsheet # file type # server url to the mail merge recipients file # direct url to the mail merge recipients file @@ -393,7 +393,7 @@ def dataSpreadsheet end if JwtHelper.is_enabled # check if a secret key to generate token exists or not - # encode a payload object into a token and write it to the dataSpreadsheet object + # encode a payload object into a token and write it to the data_spreadsheet object data_spreadsheet['token'] = JwtHelper.encode(data_spreadsheet) end diff --git a/web/documentserver-example/ruby/app/views/home/editor.html.erb b/web/documentserver-example/ruby/app/views/home/editor.html.erb index 97c88e289..65c002c9d 100755 --- a/web/documentserver-example/ruby/app/views/home/editor.html.erb +++ b/web/documentserver-example/ruby/app/views/home/editor.html.erb @@ -108,14 +108,14 @@ // the user is trying to select document for comparing by clicking the Document from Storage button var onRequestSelectDocument = function(event) { - var data = <%= raw @file.dataDocument.to_json %>; + var data = <%= raw @file.data_document.to_json %>; data.c = event.data.c; docEditor.setRequestedDocument(data); // select a document for comparing }; // the user is trying to select recipients data by clicking the Mail merge button var onRequestSelectSpreadsheet = function (event) { - var data = <%= raw @file.dataSpreadsheet.to_json %>; + var data = <%= raw @file.data_spreadsheet.to_json %>; data.c = event.data.c; docEditor.setRequestedSpreadsheet(data); // insert recipient data for mail merge into the file }; From 8f4de5ce0d8b447e065ab91891d819752981b03b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 11:53:13 +0300 Subject: [PATCH 349/488] ruby: Naming/PredicateName correct --- .../ruby/app/controllers/home_controller.rb | 6 ++--- .../ruby/app/models/file_model.rb | 24 +++++++++---------- .../ruby/app/models/jwt_helper.rb | 2 +- .../ruby/app/models/service_converter.rb | 2 +- .../ruby/app/models/track_helper.rb | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 4e5ae852e..443d27074 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -165,7 +165,7 @@ def downloadhistory file = params[:file] params[:dmode] - if JwtHelper.is_enabled && JwtHelper.use_for_request + if JwtHelper.enabled? && JwtHelper.use_for_request jwt_header = HomeController.config_manager.jwt_header if request.headers[jwt_header] hdr = request.headers[jwt_header] @@ -281,7 +281,7 @@ def download user_address = params[:userAddress] is_embedded = params[:dmode] - if JwtHelper.is_enabled && is_embedded.nil? && !user_address.nil? && JwtHelper.use_for_request + if JwtHelper.enabled? && is_embedded.nil? && !user_address.nil? && JwtHelper.use_for_request jwt_header = HomeController.config_manager.jwt_header if request.headers[jwt_header] hdr = request.headers[jwt_header] @@ -434,7 +434,7 @@ def reference link: "#{DocumentHelper.get_server_url(false)}/editor?fileName=#{file_name}" } - data['token'] = JwtHelper.encode(data) if JwtHelper.is_enabled + data['token'] = JwtHelper.encode(data) if JwtHelper.enabled? render plain: data.to_json end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 97b2b6356..938f079e0 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -120,7 +120,7 @@ def config document: { title: @file_name, url: download_url, - directUrl: is_enable_direct_url ? download_url(is_server_url: false) : '', + directUrl: enable_direct_url? ? download_url(is_server_url: false) : '', fileType: file_ext.delete('.'), key:, info: { @@ -193,7 +193,7 @@ def config } } - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not config['token'] = JwtHelper.encode(config) # encode a payload object into a token and write it to the config end @@ -248,7 +248,7 @@ def history data_obj['fileType'] = file_ext[1..file_ext.length] data_obj['key'] = cur_key data_obj['url'] = i == cur_ver ? doc_uri : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}") - if is_enable_direct_url == true + if enable_direct_url? == true data_obj['directUrl'] = if i == cur_ver download_url(is_server_url: false) @@ -276,7 +276,7 @@ def history prev = hist_data[(i - 2).to_s] # get the history data from the previous file version # write key and url information about previous file version with optional direct url - data obj['previous'] = if is_enable_direct_url == true + data obj['previous'] = if enable_direct_url? == true { # write key and url information about previous file version with optional directUrl fileType: prev['fileType'], key: prev['key'], @@ -295,7 +295,7 @@ def history data_obj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') end - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the data object data_obj['token'] = JwtHelper.encode(data_obj) end @@ -321,7 +321,7 @@ def insert_image # image file type # server url to the image # direct url to the image - insert_image = if is_enable_direct_url == true + insert_image = if enable_direct_url? == true { fileType: 'png', # image file type url: "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image @@ -334,7 +334,7 @@ def insert_image } end - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the insert_image object insert_image['token'] = JwtHelper.encode(insert_image) end @@ -347,7 +347,7 @@ def data_document # file type # server url to the compared file # direct url to the compared file - compare_file = if is_enable_direct_url == true + compare_file = if enable_direct_url? == true { fileType: 'docx', # file type # server url to the compared file @@ -363,7 +363,7 @@ def data_document } end - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the compare_file object compare_file['token'] = JwtHelper.encode(compare_file) end @@ -376,7 +376,7 @@ def data_spreadsheet # file type # server url to the mail merge recipients file # direct url to the mail merge recipients file - data_spreadsheet = if is_enable_direct_url == true + data_spreadsheet = if enable_direct_url? == true { fileType: 'csv', # file type # server url to the mail merge recipients file @@ -392,7 +392,7 @@ def data_spreadsheet } end - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the data_spreadsheet object data_spreadsheet['token'] = JwtHelper.encode(data_spreadsheet) end @@ -436,7 +436,7 @@ def users_protect end # get direct url existence flag - def is_enable_direct_url + def enable_direct_url? !@direct_url.nil? && @direct_url == 'true' end end diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 1a76b1145..48679d790 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -26,7 +26,7 @@ class JwtHelper class << self # check if a secret key to generate token exists or not - def is_enabled + def enabled? @jwt_secret && !@jwt_secret.empty? ? true : false end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index e1731c29d..39bbff8f3 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -66,7 +66,7 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ req.add_field('Accept', 'application/json') # set headers req.add_field('Content-Type', 'application/json') - if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled + if JwtHelper.enabled? && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwt_header = ServiceConverter.config_manager.jwt_header; # get signature authorization header # set it to the request with the Bearer prefix diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 120c4f4a0..689183841 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -42,7 +42,7 @@ def read_body(request) file_data = JSON.parse(body) # parse file data # check if a secret key to generate token exists or not - if JwtHelper.is_enabled && JwtHelper.use_for_request + if JwtHelper.enabled? && JwtHelper.use_for_request in_header = false token = nil jwt_header = TrackHelper.config_manager.jwt_header; # get the authorization header from the config @@ -283,7 +283,7 @@ def command_request(method, key, meta = nil) req = Net::HTTP::Post.new(uri.request_uri) # create the post request req.add_field('Content-Type', 'application/json') # set headers - if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled + if JwtHelper.enabled? && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwt_header = TrackHelper.config_manager.jwt_header; # get signature authorization header # set it to the request with the Bearer prefix From 8fa40ab439c65a77be7bcfdfd762aeab0ea14b9b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:10:24 +0300 Subject: [PATCH 350/488] ruby: Style/SymbolArray correct --- web/documentserver-example/ruby/Gemfile | 6 +++--- web/documentserver-example/ruby/config/application.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/Gemfile b/web/documentserver-example/ruby/Gemfile index 753e0bdfa..01162d9aa 100644 --- a/web/documentserver-example/ruby/Gemfile +++ b/web/documentserver-example/ruby/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -gem 'byebug', '~> 11.1', groups: %i[development test] +gem 'byebug', '~> 11.1', groups: [:development, :test] gem 'coffee-rails', '~> 5.0' gem 'dalli', '~> 3.2', group: :development gem 'jbuilder', '~> 2.11' @@ -15,12 +15,12 @@ gem 'rubocop', '~> 1.52', group: :development gem 'sass-rails', '~> 6.0' gem 'sdoc', '~> 2.6', group: :doc gem 'sorbet-runtime', '~> 0.5.10871' -gem 'test-unit', '~> 3.6', groups: %i[development test] +gem 'test-unit', '~> 3.6', groups: [:development, :test] gem 'turbolinks', '~> 5.2' gem 'tzinfo-data', '~> 1.2023' gem 'uglifier', '~> 4.2' gem 'uuid', '~> 2.3' -gem 'web-console', '~> 4.2', groups: %i[development test] +gem 'web-console', '~> 4.2', groups: [:development, :test] gem 'webrick', '~> 1.8' # Unfortunately, Sorbet only supports Darwin and Linux-based systems. diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index f9c59aa3c..dfe4302f5 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -16,7 +16,7 @@ class Application < Rails::Application config.middleware.insert_before 0, Rack::Cors do allow do origins '*' - resource '*', headers: :any, methods: %i[get post patch delete put options] + resource '*', headers: :any, methods: [:get, :post, :patch, :delete, :put, :options] end end From 7fe7753c887fef92002478040ef59b1ac1578a1e Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:27:25 +0300 Subject: [PATCH 351/488] ruby: Layout/MultilineMethodArgumentLineBreaks correct --- .../ruby/app/models/file_model.rb | 4 +- .../ruby/app/models/users.rb | 72 +++++++++++++++---- 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 938f079e0..7bb0a353d 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -253,7 +253,9 @@ def history if i == cur_ver download_url(is_server_url: false) else - DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", + DocumentHelper.get_historypath_uri(file_name, +i, +"prev#{file_ext}", false) end end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index c72d3677b..a78f2903f 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -18,8 +18,18 @@ # Represents a user with various attributes class User - attr_accessor :id, :name, :email, :group, :review_groups, :comment_groups, :user_info_groups, :favorite, - :denied_permissions, :descriptions, :templates, :avatar + attr_accessor :id, +:name, +:email, +:group, +:review_groups, +:comment_groups, +:user_info_groups, +:favorite, + :denied_permissions, +:descriptions, +:templates, +:avatar def initialize(id, name, email, group, review_groups, comment_groups, user_info_groups, favorite, denied_permissions, descriptions, templates, avatar) @@ -90,28 +100,62 @@ class Users ] @users = [ - User.new('uid-1', 'John Smith', 'smith@example.com', - '', nil, {}, nil, - nil, [], @descr_user_first, true, true), - User.new('uid-2', 'Mark Pottato', 'pottato@example.com', - 'group-2', ['group-2', ''], { + User.new('uid-1', +'John Smith', +'smith@example.com', + '', +nil, +{}, +nil, + nil, +[], +@descr_user_first, +true, +true), + User.new('uid-2', +'Mark Pottato', +'pottato@example.com', + 'group-2', +['group-2', ''], +{ view: '', edit: ['group-2', ''], remove: ['group-2'] }, ['group-2', ''], - true, [], @descr_user_second, false, true), - User.new('uid-3', 'Hamish Mitchell', nil, - 'group-3', ['group-2'], { + true, +[], +@descr_user_second, +false, +true), + User.new('uid-3', +'Hamish Mitchell', +nil, + 'group-3', +['group-2'], +{ view: %w[group-3 group-2], edit: ['group-2'], remove: [] }, ['group-2'], - false, %w[copy download print], @descr_user_third, false, false), - User.new('uid-0', nil, nil, - '', nil, {}, [], - nil, ['protect'], @descr_user_null, false, false) + false, +%w[copy download print], +@descr_user_third, +false, +false), + User.new('uid-0', +nil, +nil, + '', +nil, +{}, +[], + nil, +['protect'], +@descr_user_null, +false, +false) ] class << self From 940b4bfc8052416c0338f738753f7d981a776b60 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:28:12 +0300 Subject: [PATCH 352/488] ruby: Layout/TrailingWhitespace correct --- .../ruby/app/models/file_model.rb | 4 +- .../ruby/app/models/users.rb | 88 +++++++++---------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 7bb0a353d..199ad579c 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -253,8 +253,8 @@ def history if i == cur_ver download_url(is_server_url: false) else - DocumentHelper.get_historypath_uri(file_name, -i, + DocumentHelper.get_historypath_uri(file_name, +i, "prev#{file_ext}", false) end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index a78f2903f..8e8d21985 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -18,17 +18,17 @@ # Represents a user with various attributes class User - attr_accessor :id, -:name, -:email, -:group, -:review_groups, -:comment_groups, -:user_info_groups, + attr_accessor :id, +:name, +:email, +:group, +:review_groups, +:comment_groups, +:user_info_groups, :favorite, - :denied_permissions, -:descriptions, -:templates, + :denied_permissions, +:descriptions, +:templates, :avatar def initialize(id, name, email, group, review_groups, comment_groups, user_info_groups, favorite, @@ -100,61 +100,61 @@ class Users ] @users = [ - User.new('uid-1', -'John Smith', + User.new('uid-1', +'John Smith', 'smith@example.com', - '', -nil, -{}, + '', nil, - nil, -[], -@descr_user_first, -true, +{}, +nil, + nil, +[], +@descr_user_first, +true, true), - User.new('uid-2', -'Mark Pottato', + User.new('uid-2', +'Mark Pottato', 'pottato@example.com', - 'group-2', -['group-2', ''], + 'group-2', +['group-2', ''], { view: '', edit: ['group-2', ''], remove: ['group-2'] }, ['group-2', ''], - true, -[], -@descr_user_second, -false, + true, +[], +@descr_user_second, +false, true), - User.new('uid-3', -'Hamish Mitchell', + User.new('uid-3', +'Hamish Mitchell', nil, - 'group-3', -['group-2'], + 'group-3', +['group-2'], { view: %w[group-3 group-2], edit: ['group-2'], remove: [] }, ['group-2'], - false, -%w[copy download print], -@descr_user_third, -false, + false, +%w[copy download print], +@descr_user_third, +false, false), - User.new('uid-0', -nil, + User.new('uid-0', +nil, +nil, + '', nil, - '', -nil, -{}, +{}, [], - nil, -['protect'], -@descr_user_null, -false, + nil, +['protect'], +@descr_user_null, +false, false) ] From 40c520e8fd8ac78906694a585f9cd880a29e5605 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:29:02 +0300 Subject: [PATCH 353/488] ruby: Layout/ArgumentAlignment correct --- .../ruby/app/models/file_model.rb | 4 +- .../ruby/app/models/users.rb | 104 +++++++++--------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 199ad579c..b6fb1bb74 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -254,8 +254,8 @@ def history download_url(is_server_url: false) else DocumentHelper.get_historypath_uri(file_name, -i, -"prev#{file_ext}", + i, + "prev#{file_ext}", false) end end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 8e8d21985..c4db0bbdf 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -19,17 +19,17 @@ # Represents a user with various attributes class User attr_accessor :id, -:name, -:email, -:group, -:review_groups, -:comment_groups, -:user_info_groups, -:favorite, + :name, + :email, + :group, + :review_groups, + :comment_groups, + :user_info_groups, + :favorite, :denied_permissions, -:descriptions, -:templates, -:avatar + :descriptions, + :templates, + :avatar def initialize(id, name, email, group, review_groups, comment_groups, user_info_groups, favorite, denied_permissions, descriptions, templates, avatar) @@ -101,61 +101,61 @@ class Users @users = [ User.new('uid-1', -'John Smith', -'smith@example.com', + 'John Smith', + 'smith@example.com', '', -nil, -{}, -nil, nil, -[], -@descr_user_first, -true, -true), + {}, + nil, + nil, + [], + @descr_user_first, + true, + true), User.new('uid-2', -'Mark Pottato', -'pottato@example.com', + 'Mark Pottato', + 'pottato@example.com', 'group-2', -['group-2', ''], -{ - view: '', - edit: ['group-2', ''], - remove: ['group-2'] - }, + ['group-2', ''], + { + view: '', + edit: ['group-2', ''], + remove: ['group-2'] + }, ['group-2', ''], true, -[], -@descr_user_second, -false, -true), + [], + @descr_user_second, + false, + true), User.new('uid-3', -'Hamish Mitchell', -nil, + 'Hamish Mitchell', + nil, 'group-3', -['group-2'], -{ - view: %w[group-3 group-2], - edit: ['group-2'], - remove: [] - }, ['group-2'], + { + view: %w[group-3 group-2], + edit: ['group-2'], + remove: [] + }, + ['group-2'], + false, + %w[copy download print], + @descr_user_third, false, -%w[copy download print], -@descr_user_third, -false, -false), + false), User.new('uid-0', -nil, -nil, + nil, + nil, '', -nil, -{}, -[], nil, -['protect'], -@descr_user_null, -false, -false) + {}, + [], + nil, + ['protect'], + @descr_user_null, + false, + false) ] class << self From 03a585685e94f98b76dd757a0fb6d03cb7ee514f Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:29:36 +0300 Subject: [PATCH 354/488] ruby: Layout/FirstMethodArgumentLineBreak correct --- .../ruby/app/models/file_model.rb | 6 ++++-- .../ruby/app/models/track_helper.rb | 12 ++++++++---- web/documentserver-example/ruby/app/models/users.rb | 12 ++++++++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index b6fb1bb74..80205a1db 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -51,7 +51,8 @@ def file_uri_user if @config_manager.storage_path.absolute? "#{download_url}&dmode=emb" else - DocumentHelper.get_file_uri(@file_name, + DocumentHelper.get_file_uri( +@file_name, false) end end @@ -253,7 +254,8 @@ def history if i == cur_ver download_url(is_server_url: false) else - DocumentHelper.get_historypath_uri(file_name, + DocumentHelper.get_historypath_uri( +file_name, i, "prev#{file_ext}", false) diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 689183841..a8255c49c 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -126,7 +126,8 @@ def process_save(raw_file_data, file_name, user_address) download_uri = new_file_uri end rescue StandardError - new_file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, + new_file_name = DocumentHelper.get_correct_name( +File.basename(file_name, cur_ext) + download_ext, user_address) end end @@ -228,16 +229,19 @@ def process_force_save(file_data, file_name, user_address) if is_submit_form file_name = if new_file_name - DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{download_ext}", + DocumentHelper.get_correct_name( +"#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists else - DocumentHelper.get_correct_name("#{File.basename(file_name, cur_ext)}-form#{cur_ext}", + DocumentHelper.get_correct_name( +"#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, + file_name = DocumentHelper.get_correct_name( +File.basename(file_name, cur_ext) + download_ext, user_address) end forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index c4db0bbdf..d64ac2729 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -100,7 +100,8 @@ class Users ] @users = [ - User.new('uid-1', + User.new( +'uid-1', 'John Smith', 'smith@example.com', '', @@ -112,7 +113,8 @@ class Users @descr_user_first, true, true), - User.new('uid-2', + User.new( +'uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', @@ -128,7 +130,8 @@ class Users @descr_user_second, false, true), - User.new('uid-3', + User.new( +'uid-3', 'Hamish Mitchell', nil, 'group-3', @@ -144,7 +147,8 @@ class Users @descr_user_third, false, false), - User.new('uid-0', + User.new( +'uid-0', nil, nil, '', From f5ccc21f69642e65a5adc3410c9153fed1fcf360 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:31:23 +0300 Subject: [PATCH 355/488] ruby: Style/FetchEnvVar correct --- .../ruby/app/configuration/configuration.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/configuration/configuration.rb b/web/documentserver-example/ruby/app/configuration/configuration.rb index c4efd7fe1..efae1f14a 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration.rb @@ -36,7 +36,7 @@ def initialize sig { returns(T.nilable(URI::Generic)) } def example_uri - url = ENV['EXAMPLE_URL'] + url = ENV.fetch('EXAMPLE_URL', nil) return nil if url.nil? URI(url) @@ -50,7 +50,7 @@ def document_server_public_uri sig { returns(URI::Generic) } def document_server_private_uri - url = ENV['DOCUMENT_SERVER_PRIVATE_URL'] + url = ENV.fetch('DOCUMENT_SERVER_PRIVATE_URL', nil) return URI(url) if url document_server_public_uri @@ -100,7 +100,7 @@ def jwt_header sig { returns(T::Boolean) } def jwt_use_for_request - env = ENV['JWT_USE_FOR_REQUEST'] + env = ENV.fetch('JWT_USE_FOR_REQUEST', nil) return ActiveModel::Type::Boolean.new.cast(env) if env true @@ -108,7 +108,7 @@ def jwt_use_for_request sig { returns(T::Boolean) } def ssl_verify_peer_mode_enabled - env = ENV['SSL_VERIFY_PEER_MODE_ENABLED'] + env = ENV.fetch('SSL_VERIFY_PEER_MODE_ENABLED', nil) return ActiveModel::Type::Boolean.new.cast(env) if env false @@ -127,7 +127,7 @@ def storage_path sig { returns(Numeric) } def maximum_file_size - env = ENV['MAXIMUM_FILE_SIZE'] + env = ENV.fetch('MAXIMUM_FILE_SIZE', nil) return env.to_i if env 5 * 1024 * 1024 From cba2eac65d8ac962ca8af81a183cb34b7ee97d45 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:32:09 +0300 Subject: [PATCH 356/488] ruby: Lint/NumberConversion correct --- .../ruby/app/configuration/configuration.rb | 2 +- .../ruby/app/controllers/home_controller.rb | 2 +- .../ruby/app/models/service_converter.rb | 6 +++--- web/documentserver-example/ruby/app/models/track_helper.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/configuration/configuration.rb b/web/documentserver-example/ruby/app/configuration/configuration.rb index efae1f14a..1faa56a31 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration.rb @@ -128,7 +128,7 @@ def storage_path sig { returns(Numeric) } def maximum_file_size env = ENV.fetch('MAXIMUM_FILE_SIZE', nil) - return env.to_i if env + return Integer(env, 10) if env 5 * 1024 * 1024 end diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 443d27074..8b9d270ca 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -203,7 +203,7 @@ def track return end - status = file_data['status'].to_i + status = Integer(file_data['status'], 10) user_address = params[:userAddress] file_name = File.basename(params[:fileName]) diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 39bbff8f3..a8f49dca9 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -76,7 +76,7 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ req.body = payload.to_json res = http.request(req) # get the response - status_code = res.code.to_i + status_code = Integer(res.code, 10) raise "Conversion service returned status: #{status_code}" if status_code != 200 # checking status code data = res.body # and take its body @@ -140,7 +140,7 @@ def get_response_data(json_data) error_element = file_result['error'] unless error_element.nil? # if an error occurs - process_convert_service_responce_error(error_element.to_i) # get an error message + process_convert_service_responce_error(Integer(error_element, 10)) # get an error message end is_end_convert = file_result['endConvert'] # check if the conversion is completed @@ -166,7 +166,7 @@ def get_response_data(json_data) percent_element = file_result['percent'] # get the percentage value - result_percent = percent_element.to_i unless percent_element.nil? + result_percent = Integer(percent_element, 10) unless percent_element.nil? result_percent = result_percent >= 100 ? 99 : result_percent diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index a8255c49c..37742e4b8 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -225,7 +225,7 @@ def process_force_save(file_data, file_name, user_address) begin # check if the forcesave type is equal to 3 (the form was submitted) - is_submit_form = file_data['forcesavetype'].to_i == 3 + is_submit_form = Integer(file_data['forcesavetype'], 10) == 3 if is_submit_form file_name = if new_file_name From 8580ea8a571da515b790f5d138fcb8616e8a53c0 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:32:54 +0300 Subject: [PATCH 357/488] ruby: Style/StringHashKeys correct --- .../ruby/app/configuration/configuration.rb | 80 +++++++++---------- .../ruby/app/models/document_helper.rb | 12 +-- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/web/documentserver-example/ruby/app/configuration/configuration.rb b/web/documentserver-example/ruby/app/configuration/configuration.rb index 1faa56a31..2f191b19b 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration.rb @@ -141,46 +141,46 @@ def convertation_timeout sig { returns(T::Hash[String, String]) } def languages { - 'en' => 'English', - 'hy' => 'Armenian', - 'az' => 'Azerbaijani', - 'eu' => 'Basque', - 'be' => 'Belarusian', - 'bg' => 'Bulgarian', - 'ca' => 'Catalan', - 'zh' => 'Chinese (Simplified)', - 'zh-TW' => 'Chinese (Traditional)', - 'cs' => 'Czech', - 'da' => 'Danish', - 'nl' => 'Dutch', - 'fi' => 'Finnish', - 'fr' => 'French', - 'gl' => 'Galego', - 'de' => 'German', - 'el' => 'Greek', - 'hu' => 'Hungarian', - 'id' => 'Indonesian', - 'it' => 'Italian', - 'ja' => 'Japanese', - 'ko' => 'Korean', - 'lo' => 'Lao', - 'lv' => 'Latvian', - 'ms' => 'Malay (Malaysia)', - 'no' => 'Norwegian', - 'pl' => 'Polish', - 'pt' => 'Portuguese (Brazil)', - 'pt-PT' => 'Portuguese (Portugal)', - 'ro' => 'Romanian', - 'ru' => 'Russian', - 'si' => 'Sinhala (Sri Lanka)', - 'sk' => 'Slovak', - 'sl' => 'Slovenian', - 'es' => 'Spanish', - 'sv' => 'Swedish', - 'tr' => 'Turkish', - 'uk' => 'Ukrainian', - 'vi' => 'Vietnamese', - 'aa-AA' => 'Test Language' + :en => 'English', + :hy => 'Armenian', + :az => 'Azerbaijani', + :eu => 'Basque', + :be => 'Belarusian', + :bg => 'Bulgarian', + :ca => 'Catalan', + :zh => 'Chinese (Simplified)', + :"zh-TW" => 'Chinese (Traditional)', + :cs => 'Czech', + :da => 'Danish', + :nl => 'Dutch', + :fi => 'Finnish', + :fr => 'French', + :gl => 'Galego', + :de => 'German', + :el => 'Greek', + :hu => 'Hungarian', + :id => 'Indonesian', + :it => 'Italian', + :ja => 'Japanese', + :ko => 'Korean', + :lo => 'Lao', + :lv => 'Latvian', + :ms => 'Malay (Malaysia)', + :no => 'Norwegian', + :pl => 'Polish', + :pt => 'Portuguese (Brazil)', + :"pt-PT" => 'Portuguese (Portugal)', + :ro => 'Romanian', + :ru => 'Russian', + :si => 'Sinhala (Sri Lanka)', + :sk => 'Slovak', + :sl => 'Slovenian', + :es => 'Spanish', + :sv => 'Swedish', + :tr => 'Turkish', + :uk => 'Ukrainian', + :vi => 'Vietnamese', + :"aa-AA" => 'Test Language' } end end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index fa469917c..98fe86061 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -294,12 +294,12 @@ def get_files_info(file_id) # write file parameters to the info object info = { - 'version' => get_file_version(history_dir(directory)), - 'id' => ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), - 'contentLength' => "#{(File.size(directory) / 1024.0).round(2)} KB", - 'pureContentLength' => File.size(directory), - 'title' => file_name, - 'updated' => File.mtime(directory) + :version => get_file_version(history_dir(directory)), + :id => ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), + :contentLength => "#{(File.size(directory) / 1024.0).round(2)} KB", + :pureContentLength => File.size(directory), + :title => file_name, + :updated => File.mtime(directory) } if file_id.nil? # if file id is undefined From 955b35f38238403442b9ca26ee0a3ec9941251e7 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:33:36 +0300 Subject: [PATCH 358/488] ruby: Style/MethodCallWithArgsParentheses correct --- .../app/configuration/configuration_tests.rb | 2 +- .../ruby/app/controllers/home_controller.rb | 74 +++++++++---------- .../ruby/app/models/document_helper.rb | 4 +- .../ruby/app/models/file_model.rb | 4 +- .../ruby/app/models/jwt_helper.rb | 4 +- .../ruby/app/models/service_converter.rb | 12 +-- .../ruby/app/models/track_helper.rb | 10 +-- .../ruby/config/application.rb | 2 +- 8 files changed, 56 insertions(+), 56 deletions(-) diff --git a/web/documentserver-example/ruby/app/configuration/configuration_tests.rb b/web/documentserver-example/ruby/app/configuration/configuration_tests.rb index ccf94cdf6..9dcbb0d5b 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration_tests.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration_tests.rb @@ -28,7 +28,7 @@ def initialize(name) end def setup - ENV.replace @env + ENV.replace(@env) end end diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 8b9d270ca..3eac5f51a 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -51,7 +51,7 @@ def sample DocumentHelper.init(request.remote_ip, request.base_url) user = Users.get_user(params[:userId]) file_name = DocumentHelper.create_demo(params[:fileExt], params[:sample], user) - redirect_to controller: 'home', action: 'editor', fileName: file_name, userId: user.id + redirect_to(controller: 'home', action: 'editor', fileName: file_name, userId: user.id) end # uploading a file @@ -64,12 +64,12 @@ def upload cur_size = http_posted_file.size # check if the file size exceeds the maximum file size - raise 'File size is incorrect' if DocumentHelper.file_size_max < cur_size || cur_size <= 0 + raise('File size is incorrect') if DocumentHelper.file_size_max < cur_size || cur_size <= 0 cur_ext = File.extname(file_name).downcase # check if the file extension is supported by the editor - raise 'File type is not supported' unless DocumentHelper.file_exts.include? cur_ext + raise('File type is not supported') unless DocumentHelper.file_exts.include?(cur_ext) # get the correct file name if such a name already exists file_name = DocumentHelper.get_correct_name(file_name, nil) @@ -86,9 +86,9 @@ def upload DocumentHelper.create_meta(file_name, user.id, user.name, nil) # write a new file name to the response - render plain: "{ \"filename\": \"#{file_name}\", \"documentType\": \"#{document_type}\"}" + render(plain: "{ \"filename\": \"#{file_name}\", \"documentType\": \"#{document_type}\"}") rescue StandardError => e - render plain: "{ \"error\": \"#{e.message}\"}" # write an error message to the response + render(plain: "{ \"error\": \"#{e.message}\"}") # write an error message to the response end end @@ -120,7 +120,7 @@ def convert # if the conversion isn't completed, write file name and step values to the response if percent != 100 - render plain: "{ \"step\" : \"#{percent}\", \"filename\" : \"#{file_name}\"}" + render(plain: "{ \"step\" : \"#{percent}\", \"filename\" : \"#{file_name}\"}") return end @@ -136,7 +136,7 @@ def convert res = http.request(req) data = res.body - raise 'stream is null' if data.nil? + raise('stream is null') if data.nil? # write a file with a new extension, but with the content from the origin file File.open(DocumentHelper.storage_path(correct_name, nil), 'wb') do |file| @@ -152,9 +152,9 @@ def convert DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file end - render plain: "{ \"filename\" : \"#{file_name}\"}" + render(plain: "{ \"filename\" : \"#{file_name}\"}") rescue StandardError => e - render plain: "{ \"error\": \"#{e.message}\"}" + render(plain: "{ \"error\": \"#{e.message}\"}") end # downloading a history file from public @@ -172,11 +172,11 @@ def downloadhistory hdr.slice!(0, 'Bearer '.length) token = JwtHelper.decode(hdr) if !token || token.eql?('') - render plain: 'JWT validation failed', status: 403 + render(plain: 'JWT validation failed', status: 403) return end else - render plain: 'JWT validation failed', status: 403 + render(plain: 'JWT validation failed', status: 403) return end end @@ -190,16 +190,16 @@ def downloadhistory MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file)}" - send_file file_path, x_sendfile: true + send_file(file_path, x_sendfile: true) rescue StandardError - render plain: '{ "error": "File not found"}' + render(plain: '{ "error": "File not found"}') end # tracking file changes def track file_data = TrackHelper.read_body(request) # read the request body if file_data.nil? || file_data.empty? - render plain: '{"error":1}' # an error occurs if the file is empty + render(plain: '{"error":1}') # an error occurs if the file is empty return end @@ -217,17 +217,17 @@ def track if [2, 3].include?(status) # MustSave, Corrupted saved = TrackHelper.process_save(file_data, file_name, user_address) # save file - render plain: "{\"error\":#{saved}}" + render(plain: "{\"error\":#{saved}}") return end if [6, 7].include?(status) # MustForceave, CorruptedForcesave saved = TrackHelper.process_force_save(file_data, file_name, user_address) # force save file - render plain: "{\"error\":#{saved}}" + render(plain: "{\"error\":#{saved}}") return end - render plain: '{"error":0}' + render(plain: '{"error":0}') nil end @@ -235,7 +235,7 @@ def track def remove file_name = File.basename(params[:filename]) # get the file name unless file_name # if it doesn't exist - render plain: '{"success":false}' # report that the operation is unsuccessful + render(plain: '{"success":false}') # report that the operation is unsuccessful return end @@ -251,7 +251,7 @@ def remove FileUtils.remove_entry_secure(hist_dir) # delete it end - render plain: '{"success":true}' # report that the operation is successful + render(plain: '{"success":true}') # report that the operation is successful nil end @@ -259,7 +259,7 @@ def remove def files file_id = params[:fileId] files_info = DocumentHelper.get_files_info(file_id) # get the information about the file specified by a file id - render json: files_info + render(json: files_info) end # downloading a csv file @@ -272,7 +272,7 @@ def csv response.headers['Content-Type'] = MimeMagic.by_path(csv_path).type response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" - send_file csv_path, x_sendfile: true + send_file(csv_path, x_sendfile: true) end # downloading a file @@ -289,7 +289,7 @@ def download token = JwtHelper.decode(hdr) end if !token || token.eql?('') - render plain: 'JWT validation failed', status: 403 + render(plain: 'JWT validation failed', status: 403) return end end @@ -306,9 +306,9 @@ def download MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" - send_file file_path, x_sendfile: true + send_file(file_path, x_sendfile: true) rescue StandardError - render plain: '{ "error": "File not found"}' + render(plain: '{ "error": "File not found"}') end # Save Copy as... @@ -324,7 +324,7 @@ def saveas DocumentHelper.fill_forms_exts unless all_exts.include?(extension) - render plain: '{"error": "File type is not supported"}' + render(plain: '{"error": "File type is not supported"}') return end @@ -338,7 +338,7 @@ def saveas data = res.body if data.size <= 0 || data.size > HomeController.config_manager.maximum_file_size - render plain: '{"error": "File size is incorrect"}' + render(plain: '{"error": "File size is incorrect"}') return end @@ -348,10 +348,10 @@ def saveas user = Users.get_user(params[:userId]) DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file - render plain: "{\"file\" : \"#{file_name}\"}" + render(plain: "{\"file\" : \"#{file_name}\"}") nil rescue StandardError => e - render plain: "{\"error\":1, \"message\": \"#{e.message}\"}" + render(plain: "{\"error\":1, \"message\": \"#{e.message}\"}") nil end @@ -370,7 +370,7 @@ def rename } json_data = TrackHelper.command_request('meta', dockey, meta) - render plain: "{ \"result\" : \"#{JSON.dump(json_data)}\"}" + render(plain: "{ \"result\" : \"#{JSON.dump(json_data)}\"}") end # ReferenceData @@ -395,7 +395,7 @@ def reference url: link, directUrl: link } - render plain: data.to_json + render(plain: data.to_json) return end @@ -403,7 +403,7 @@ def reference query_params = CGI.parse(url_obj.query) file_name = query_params['fileName'].first unless File.exist?(DocumentHelper.storage_path(file_name, nil)) - render plain: '{ "error": "File is not exist"}' + render(plain: '{ "error": "File is not exist"}') return end end @@ -414,7 +414,7 @@ def reference end if file_name.empty? - render plain: '{ "error": "File not found"}' + render(plain: '{ "error": "File not found"}') return end @@ -436,7 +436,7 @@ def reference data['token'] = JwtHelper.encode(data) if JwtHelper.enabled? - render plain: data.to_json + render(plain: data.to_json) end def restore @@ -495,15 +495,15 @@ def restore FileUtils.cp(source_file, bumped_file) FileUtils.cp(recovery_file, source_file) - render json: { + render(json: { error: nil, success: true - } + }) rescue StandardError => e response.status = :internal_server_error - render json: { + render(json: { error: e.message, success: false - } + }) end end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 98fe86061..1a71d137e 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -200,9 +200,9 @@ def create_demo(file_ext, sample, user) # save sample document of a necessary extension to the storage directory src = Rails.root.join('assets', 'document-templates', sample == 'true' ? 'sample' : 'new', demo_name) - dest = storage_path file_name, nil + dest = storage_path(file_name, nil) - FileUtils.cp src, dest + FileUtils.cp(src, dest) # save file meta data to the file diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 80205a1db..5a6485c96 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -280,7 +280,7 @@ def history prev = hist_data[(i - 2).to_s] # get the history data from the previous file version # write key and url information about previous file version with optional direct url - data obj['previous'] = if enable_direct_url? == true + data(obj['previous'] = if enable_direct_url? == true { # write key and url information about previous file version with optional directUrl fileType: prev['fileType'], key: prev['key'], @@ -293,7 +293,7 @@ def history key: prev['key'], url: prev['url'] } - end + end) # write the path to the diff.zip archive with differences in this file version data_obj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 48679d790..55ab0b32f 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -37,13 +37,13 @@ def use_for_request # encode a payload object into a token using a secret key def encode(payload) - JWT.encode payload, @jwt_secret, 'HS256' # define the hashing algorithm and get token + JWT.encode(payload, @jwt_secret, 'HS256') # define the hashing algorithm and get token end # decode a token into a payload object using a secret key def decode(token) begin - decoded = JWT.decode token, @jwt_secret, true, { algorithm: 'HS256' } + decoded = JWT.decode(token, @jwt_secret, true, { algorithm: 'HS256' }) rescue StandardError return '' end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index a8f49dca9..e5c77f006 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -77,13 +77,13 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ res = http.request(req) # get the response status_code = Integer(res.code, 10) - raise "Conversion service returned status: #{status_code}" if status_code != 200 # checking status code + raise("Conversion service returned status: #{status_code}") if status_code != 200 # checking status code data = res.body # and take its body rescue Timeout::Error # try again rescue StandardError => e - raise e.message + raise(e.message) end json_data = JSON.parse(data) # parse response body @@ -92,11 +92,11 @@ def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_ # generate the document key value def generate_revision_id(expected_key) - require 'zlib' + require('zlib') if expected_key.length > 20 # check if the expected key length is greater than 20 # calculate 32-bit crc value from the expected key and turn it into the string - expected_key = (Zlib.crc32 expected_key).to_s + expected_key = (Zlib.crc32(expected_key)).to_s end key = expected_key.gsub(/[^0-9a-zA-Z.=]/, '_') @@ -131,7 +131,7 @@ def process_convert_service_responce_error(error_code) error_message = "ErrorCode = #{error_code}" # default value for the error message end - raise error_message + raise(error_message) end # get the response url @@ -155,7 +155,7 @@ def get_response_data(json_data) file_type_element = file_result['fileType'] if file_url_element.nil? # and the file url doesn't exist - raise 'Invalid answer format' # get ann error message + raise('Invalid answer format') # get ann error message end response_uri = file_url_element # otherwise, get the file url diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 37742e4b8..9898b0b2c 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -54,10 +54,10 @@ def read_body(request) token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key in_header = true else - raise 'Expected JWT' # token missing error message + raise('Expected JWT') # token missing error message end - raise 'Invalid JWT signature' if !token || token.eql?('') + raise('Invalid JWT signature') if !token || token.eql?('') file_data = JSON.parse(token) @@ -298,7 +298,7 @@ def command_request(method, key, meta = nil) res = http.request(req) # get the response data = res.body # and take its body rescue StandardError => e - raise e.message + raise(e.message) end JSON.parse(data) # convert the response body into the json format @@ -316,11 +316,11 @@ def download_file(uristr) res = http.request(req) # get the response status_code = res.code - raise "Document editing service returned status: #{status_code}" if status_code != '200' # checking status code + raise("Document editing service returned status: #{status_code}") if status_code != '200' # checking status code data = res.body # and take its body - raise 'stream is null' if data.nil? + raise('stream is null') if data.nil? data end diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index dfe4302f5..cccafed30 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -13,7 +13,7 @@ # Configuration for the Rails application. class Application < Rails::Application - config.middleware.insert_before 0, Rack::Cors do + config.middleware.insert_before(0, Rack::Cors) do allow do origins '*' resource '*', headers: :any, methods: [:get, :post, :patch, :delete, :put, :options] From 5b99e3d17abb513535f42817327a1b72a2e5140d Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:35:14 +0300 Subject: [PATCH 359/488] ruby: Style/HashSyntax correct --- .../ruby/app/configuration/configuration.rb | 80 +++++++++---------- .../ruby/app/models/document_helper.rb | 12 +-- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/web/documentserver-example/ruby/app/configuration/configuration.rb b/web/documentserver-example/ruby/app/configuration/configuration.rb index 2f191b19b..f3dc744e3 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration.rb @@ -141,46 +141,46 @@ def convertation_timeout sig { returns(T::Hash[String, String]) } def languages { - :en => 'English', - :hy => 'Armenian', - :az => 'Azerbaijani', - :eu => 'Basque', - :be => 'Belarusian', - :bg => 'Bulgarian', - :ca => 'Catalan', - :zh => 'Chinese (Simplified)', - :"zh-TW" => 'Chinese (Traditional)', - :cs => 'Czech', - :da => 'Danish', - :nl => 'Dutch', - :fi => 'Finnish', - :fr => 'French', - :gl => 'Galego', - :de => 'German', - :el => 'Greek', - :hu => 'Hungarian', - :id => 'Indonesian', - :it => 'Italian', - :ja => 'Japanese', - :ko => 'Korean', - :lo => 'Lao', - :lv => 'Latvian', - :ms => 'Malay (Malaysia)', - :no => 'Norwegian', - :pl => 'Polish', - :pt => 'Portuguese (Brazil)', - :"pt-PT" => 'Portuguese (Portugal)', - :ro => 'Romanian', - :ru => 'Russian', - :si => 'Sinhala (Sri Lanka)', - :sk => 'Slovak', - :sl => 'Slovenian', - :es => 'Spanish', - :sv => 'Swedish', - :tr => 'Turkish', - :uk => 'Ukrainian', - :vi => 'Vietnamese', - :"aa-AA" => 'Test Language' + en: 'English', + hy: 'Armenian', + az: 'Azerbaijani', + eu: 'Basque', + be: 'Belarusian', + bg: 'Bulgarian', + ca: 'Catalan', + zh: 'Chinese (Simplified)', + "zh-TW": 'Chinese (Traditional)', + cs: 'Czech', + da: 'Danish', + nl: 'Dutch', + fi: 'Finnish', + fr: 'French', + gl: 'Galego', + de: 'German', + el: 'Greek', + hu: 'Hungarian', + id: 'Indonesian', + it: 'Italian', + ja: 'Japanese', + ko: 'Korean', + lo: 'Lao', + lv: 'Latvian', + ms: 'Malay (Malaysia)', + no: 'Norwegian', + pl: 'Polish', + pt: 'Portuguese (Brazil)', + "pt-PT": 'Portuguese (Portugal)', + ro: 'Romanian', + ru: 'Russian', + si: 'Sinhala (Sri Lanka)', + sk: 'Slovak', + sl: 'Slovenian', + es: 'Spanish', + sv: 'Swedish', + tr: 'Turkish', + uk: 'Ukrainian', + vi: 'Vietnamese', + "aa-AA": 'Test Language' } end end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 1a71d137e..efa6db433 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -294,12 +294,12 @@ def get_files_info(file_id) # write file parameters to the info object info = { - :version => get_file_version(history_dir(directory)), - :id => ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), - :contentLength => "#{(File.size(directory) / 1024.0).round(2)} KB", - :pureContentLength => File.size(directory), - :title => file_name, - :updated => File.mtime(directory) + version: get_file_version(history_dir(directory)), + id: ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), + contentLength: "#{(File.size(directory) / 1024.0).round(2)} KB", + pureContentLength: File.size(directory), + title: file_name, + updated: File.mtime(directory) } if file_id.nil? # if file id is undefined From 7710c6d6e838bdbaf7cd6134d4dfd93b5eee19eb Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:36:03 +0300 Subject: [PATCH 360/488] ruby: Style/QuotedSymbols correct --- .../ruby/app/configuration/configuration.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/configuration/configuration.rb b/web/documentserver-example/ruby/app/configuration/configuration.rb index f3dc744e3..308345c75 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration.rb @@ -149,7 +149,7 @@ def languages bg: 'Bulgarian', ca: 'Catalan', zh: 'Chinese (Simplified)', - "zh-TW": 'Chinese (Traditional)', + 'zh-TW': 'Chinese (Traditional)', cs: 'Czech', da: 'Danish', nl: 'Dutch', @@ -169,7 +169,7 @@ def languages no: 'Norwegian', pl: 'Polish', pt: 'Portuguese (Brazil)', - "pt-PT": 'Portuguese (Portugal)', + 'pt-PT': 'Portuguese (Portugal)', ro: 'Romanian', ru: 'Russian', si: 'Sinhala (Sri Lanka)', @@ -180,7 +180,7 @@ def languages tr: 'Turkish', uk: 'Ukrainian', vi: 'Vietnamese', - "aa-AA": 'Test Language' + 'aa-AA': 'Test Language' } end end From f2504ab740516ba360fa00d0c44fe868e2443cb2 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:36:45 +0300 Subject: [PATCH 361/488] ruby: Style/FileWrite correct --- .../ruby/app/controllers/home_controller.rb | 12 +++--------- .../ruby/app/models/document_helper.rb | 4 +--- .../ruby/app/models/track_helper.rb | 12 +++--------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 3eac5f51a..a16c33894 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -76,9 +76,7 @@ def upload document_type = FileUtility.get_file_type(file_name) # write the uploaded file to the storage directory - File.open(DocumentHelper.storage_path(file_name, nil), 'wb') do |file| - file.write(http_posted_file.read) - end + File.binwrite(DocumentHelper.storage_path(file_name, nil), http_posted_file.read) # create file meta information user = Users.get_user(params[:userId]) @@ -139,9 +137,7 @@ def convert raise('stream is null') if data.nil? # write a file with a new extension, but with the content from the origin file - File.open(DocumentHelper.storage_path(correct_name, nil), 'wb') do |file| - file.write(data) - end + File.binwrite(DocumentHelper.storage_path(correct_name, nil), data) old_storage_path = DocumentHelper.storage_path(file_name, nil) File.delete(old_storage_path) if File.exist?(old_storage_path) @@ -342,9 +338,7 @@ def saveas return end - File.open(DocumentHelper.storage_path(file_name, nil), 'wb') do |file| - file.write(data) - end + File.binwrite(DocumentHelper.storage_path(file_name, nil), data) user = Users.get_user(params[:userId]) DocumentHelper.create_meta(file_name, user.id, user.name, nil) # create meta data of the new file diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index efa6db433..977081644 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -188,9 +188,7 @@ def create_meta(file_name, uid, uname, user_address) } # write file meta information to the createdInfo.json file - File.open(File.join(hist_dir, 'createdInfo.json'), 'wb') do |file| - file.write(json.to_json) - end + File.binwrite(File.join(hist_dir, 'createdInfo.json'), json.to_json) end # create demo document diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 9898b0b2c..63444c937 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -158,15 +158,11 @@ def process_save(raw_file_data, file_name, user_address) hist_data = file_data['changeshistory'] hist_data ||= file_data['history'].to_json if hist_data - File.open(File.join(ver_dir, 'changes.json'), 'wb') do |file| # open the file with document changes - file.write(hist_data) # and write history data to this file - end + File.binwrite(File.join(ver_dir, 'changes.json'), hist_data) end # write the key value to the key.txt file - File.open(File.join(ver_dir, 'key.txt'), 'wb') do |file| - file.write(file_data['key']) - end + File.binwrite(File.join(ver_dir, 'key.txt'), file_data['key']) # get the path to the forcesaved file forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) @@ -326,9 +322,7 @@ def download_file(uristr) end def save_file(data, path) - File.open(path, 'wb') do |file| # open the file from the path specified - file.write(data) # and write the response data to it - end + File.binwrite(path, data) end end end From fd5a2b7b0e3dc6af9f00496008a8c71a4dab9a46 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:37:42 +0300 Subject: [PATCH 362/488] ruby: Style/NegatedIfElseCondition correct --- web/documentserver-example/ruby/app/models/file_model.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 5a6485c96..82b21f7c7 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -164,10 +164,10 @@ def config change: false } end, - createUrl: !@user.id.eql?('uid-0') ? create_url : nil, + createUrl: @user.id.eql?('uid-0') ? nil : create_url, templates: @user.templates ? templates : nil, user: { # the user currently viewing or editing the document - id: !@user.id.eql?('uid-0') ? @user.id : nil, + id: @user.id.eql?('uid-0') ? nil : @user.id, name: @user.name, group: @user.group, image: @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil @@ -406,7 +406,7 @@ def data_spreadsheet # get users data for mentions def users_mentions - !@user.id.eql?('uid-0') ? Users.get_users_for_mentions(@user.id) : nil + @user.id.eql?('uid-0') ? nil : Users.get_users_for_mentions(@user.id) end def users_info @@ -436,7 +436,7 @@ def users_info # get users data for protect def users_protect - !@user.id.eql?('uid-0') ? Users.get_users_for_protect(@user.id) : nil + @user.id.eql?('uid-0') ? nil : Users.get_users_for_protect(@user.id) end # get direct url existence flag From f441ab1650edf8de66255ecd7f39803d59342254 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:38:22 +0300 Subject: [PATCH 363/488] ruby: Style/RedundantParentheses correct --- web/documentserver-example/ruby/app/models/service_converter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index e5c77f006..73efaa272 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -96,7 +96,7 @@ def generate_revision_id(expected_key) if expected_key.length > 20 # check if the expected key length is greater than 20 # calculate 32-bit crc value from the expected key and turn it into the string - expected_key = (Zlib.crc32(expected_key)).to_s + expected_key = Zlib.crc32(expected_key).to_s end key = expected_key.gsub(/[^0-9a-zA-Z.=]/, '_') From 6f5a854cd25fdbcfa51f6a1eb6996906a6c000d7 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:38:50 +0300 Subject: [PATCH 364/488] ruby: Style/WordArray correct --- web/documentserver-example/ruby/app/models/file_model.rb | 6 +++--- web/documentserver-example/ruby/app/models/users.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 82b21f7c7..4e83b6bab 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -130,12 +130,12 @@ def config favorite: @user.favorite }, permissions: { # the permission for the document to be edited and downloaded or not - comment: !%w[view fillForms embedded blockcontent].include?(editors_mode), + comment: !['view', 'fillForms', 'embedded', 'blockcontent'].include?(editors_mode), copy: !@user.denied_permissions.include?('copy'), download: !@user.denied_permissions.include?('download'), - edit: can_edit && %w[edit view filter blockcontent].include?(editors_mode), + edit: can_edit && ['edit', 'view', 'filter', 'blockcontent'].include?(editors_mode), print: !@user.denied_permissions.include?('print'), - fillForms: !%w[view comment embedded blockcontent].include?(editors_mode), + fillForms: !['view', 'comment', 'embedded', 'blockcontent'].include?(editors_mode), modifyFilter: !editors_mode.eql?('filter'), modifyContentControl: !editors_mode.eql?('blockcontent'), review: can_edit && (editors_mode.eql?('edit') || editors_mode.eql?('review')), diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index d64ac2729..2457f5465 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -137,13 +137,13 @@ class Users 'group-3', ['group-2'], { - view: %w[group-3 group-2], + view: ['group-3', 'group-2'], edit: ['group-2'], remove: [] }, ['group-2'], false, - %w[copy download print], + ['copy', 'download', 'print'], @descr_user_third, false, false), From 9b6495718954e5e4d84ea62e1474a9cfda8bef4c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:39:19 +0300 Subject: [PATCH 365/488] ruby: Layout/MultilineMethodParameterLineBreaks correct --- .../ruby/app/models/users.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 2457f5465..268b9e308 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -31,8 +31,18 @@ class User :templates, :avatar - def initialize(id, name, email, group, review_groups, comment_groups, user_info_groups, favorite, - denied_permissions, descriptions, templates, avatar) + def initialize(id, +name, +email, +group, +review_groups, +comment_groups, +user_info_groups, +favorite, + denied_permissions, +descriptions, +templates, +avatar) @id = id @name = name @email = email From 9471891a89f62877e2b537c3b9b87d6bec73a117 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:40:05 +0300 Subject: [PATCH 366/488] ruby: Lint/NonAtomicFileOperation correct --- .../ruby/app/controllers/home_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index a16c33894..6e5933a75 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -140,7 +140,7 @@ def convert File.binwrite(DocumentHelper.storage_path(correct_name, nil), data) old_storage_path = DocumentHelper.storage_path(file_name, nil) - File.delete(old_storage_path) if File.exist?(old_storage_path) + FileUtils.rm_f(old_storage_path) file_name = correct_name user = Users.get_user(params[:userId]) @@ -239,13 +239,13 @@ def remove storage_path = DocumentHelper.storage_path(file_name, nil) hist_dir = DocumentHelper.history_dir(storage_path) - if File.exist?(storage_path) # if the file exists - File.delete(storage_path) # delete it from the storage path - end + # if the file exists + FileUtils.rm_f(storage_path) # delete it from the storage path + - if Dir.exist?(hist_dir) # if the history directory of this file exists - FileUtils.remove_entry_secure(hist_dir) # delete it - end + # if the history directory of this file exists + FileUtils.rm_rf(hist_dir) # delete it + render(plain: '{"success":true}') # report that the operation is successful nil From 9796abf846328f9918b78923bda638a05faa5d9d Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:40:48 +0300 Subject: [PATCH 367/488] ruby: Layout/FirstArgumentIndentation correct --- web/documentserver-example/ruby/app/models/file_model.rb | 4 ++-- .../ruby/app/models/track_helper.rb | 8 ++++---- web/documentserver-example/ruby/app/models/users.rb | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 4e83b6bab..760162f4a 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -52,7 +52,7 @@ def file_uri_user "#{download_url}&dmode=emb" else DocumentHelper.get_file_uri( -@file_name, + @file_name, false) end end @@ -255,7 +255,7 @@ def history download_url(is_server_url: false) else DocumentHelper.get_historypath_uri( -file_name, + file_name, i, "prev#{file_ext}", false) diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 63444c937..d2043354d 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -127,7 +127,7 @@ def process_save(raw_file_data, file_name, user_address) end rescue StandardError new_file_name = DocumentHelper.get_correct_name( -File.basename(file_name, cur_ext) + download_ext, + File.basename(file_name, cur_ext) + download_ext, user_address) end end @@ -226,18 +226,18 @@ def process_force_save(file_data, file_name, user_address) if is_submit_form file_name = if new_file_name DocumentHelper.get_correct_name( -"#{File.basename(file_name, cur_ext)}-form#{download_ext}", + "#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address) # get the correct file name if it already exists else DocumentHelper.get_correct_name( -"#{File.basename(file_name, cur_ext)}-form#{cur_ext}", + "#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else if new_file_name file_name = DocumentHelper.get_correct_name( -File.basename(file_name, cur_ext) + download_ext, + File.basename(file_name, cur_ext) + download_ext, user_address) end forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 268b9e308..f05ad42e4 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -111,7 +111,7 @@ class Users @users = [ User.new( -'uid-1', + 'uid-1', 'John Smith', 'smith@example.com', '', @@ -124,7 +124,7 @@ class Users true, true), User.new( -'uid-2', + 'uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', @@ -141,7 +141,7 @@ class Users false, true), User.new( -'uid-3', + 'uid-3', 'Hamish Mitchell', nil, 'group-3', @@ -158,7 +158,7 @@ class Users false, false), User.new( -'uid-0', + 'uid-0', nil, nil, '', From ae738e1be223288ba1bb96f16417112a9178ee4a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:41:28 +0300 Subject: [PATCH 368/488] ruby: Style/RedundantSelfAssignmentBranch correct --- .../ruby/app/models/service_converter.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 73efaa272..507dfa68c 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -32,14 +32,14 @@ class << self class << self # get the url of the converted file def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_async, file_pass, lang = nil) - from_ext = from_ext.nil? ? File.extname(document_uri).downcase : from_ext # get the current document extension + from_ext = File.extname(document_uri).downcase if from_ext.nil? # get the current document extension # get the current document name or uuid title = File.basename(URI.parse(document_uri).path) - title = title.nil? ? UUID.generate.to_s : title + title = UUID.generate.to_s if title.nil? # get the document key - document_revision_id = document_revision_id.empty? ? document_uri : document_revision_id + document_revision_id = document_uri if document_revision_id.empty? document_revision_id = generate_revision_id(document_revision_id) payload = { # write all the conversion parameters to the payload @@ -168,7 +168,7 @@ def get_response_data(json_data) result_percent = Integer(percent_element, 10) unless percent_element.nil? - result_percent = result_percent >= 100 ? 99 : result_percent + result_percent = 99 if result_percent >= 100 end From 992dbe18afc0f891141f69479e8990fba786f43a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:41:52 +0300 Subject: [PATCH 369/488] ruby: Layout/ArgumentAlignment correct --- .../ruby/app/models/file_model.rb | 8 +- .../ruby/app/models/track_helper.rb | 8 +- .../ruby/app/models/users.rb | 104 +++++++++--------- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 760162f4a..5e262979a 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -53,7 +53,7 @@ def file_uri_user else DocumentHelper.get_file_uri( @file_name, - false) + false) end end @@ -256,9 +256,9 @@ def history else DocumentHelper.get_historypath_uri( file_name, - i, - "prev#{file_ext}", - false) + i, + "prev#{file_ext}", + false) end end data_obj['version'] = i diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index d2043354d..ded766b0a 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -128,7 +128,7 @@ def process_save(raw_file_data, file_name, user_address) rescue StandardError new_file_name = DocumentHelper.get_correct_name( File.basename(file_name, cur_ext) + download_ext, - user_address) + user_address) end end @@ -227,18 +227,18 @@ def process_force_save(file_data, file_name, user_address) file_name = if new_file_name DocumentHelper.get_correct_name( "#{File.basename(file_name, cur_ext)}-form#{download_ext}", - user_address) # get the correct file name if it already exists + user_address) # get the correct file name if it already exists else DocumentHelper.get_correct_name( "#{File.basename(file_name, cur_ext)}-form#{cur_ext}", - user_address) + user_address) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else if new_file_name file_name = DocumentHelper.get_correct_name( File.basename(file_name, cur_ext) + download_ext, - user_address) + user_address) end forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) if forcesave_path.eql?('') diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index f05ad42e4..b8f746102 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -112,64 +112,64 @@ class Users @users = [ User.new( 'uid-1', - 'John Smith', - 'smith@example.com', - '', - nil, - {}, - nil, - nil, - [], - @descr_user_first, - true, - true), + 'John Smith', + 'smith@example.com', + '', + nil, + {}, + nil, + nil, + [], + @descr_user_first, + true, + true), User.new( 'uid-2', - 'Mark Pottato', - 'pottato@example.com', - 'group-2', - ['group-2', ''], - { - view: '', - edit: ['group-2', ''], - remove: ['group-2'] - }, - ['group-2', ''], - true, - [], - @descr_user_second, - false, - true), + 'Mark Pottato', + 'pottato@example.com', + 'group-2', + ['group-2', ''], + { + view: '', + edit: ['group-2', ''], + remove: ['group-2'] + }, + ['group-2', ''], + true, + [], + @descr_user_second, + false, + true), User.new( 'uid-3', - 'Hamish Mitchell', - nil, - 'group-3', - ['group-2'], - { - view: ['group-3', 'group-2'], - edit: ['group-2'], - remove: [] - }, - ['group-2'], - false, - ['copy', 'download', 'print'], - @descr_user_third, - false, - false), + 'Hamish Mitchell', + nil, + 'group-3', + ['group-2'], + { + view: ['group-3', 'group-2'], + edit: ['group-2'], + remove: [] + }, + ['group-2'], + false, + ['copy', 'download', 'print'], + @descr_user_third, + false, + false), User.new( 'uid-0', - nil, - nil, - '', - nil, - {}, - [], - nil, - ['protect'], - @descr_user_null, - false, - false) + nil, + nil, + '', + nil, + {}, + [], + nil, + ['protect'], + @descr_user_null, + false, + false) ] class << self From 1f5c23a2d1c625bb8cffe8b92cc6ccf2920f5d09 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:43:31 +0300 Subject: [PATCH 370/488] ruby: Layout/CommentIndentation correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 6e5933a75..499572a84 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -239,11 +239,11 @@ def remove storage_path = DocumentHelper.storage_path(file_name, nil) hist_dir = DocumentHelper.history_dir(storage_path) - # if the file exists + # if the file exists FileUtils.rm_f(storage_path) # delete it from the storage path - # if the history directory of this file exists + # if the history directory of this file exists FileUtils.rm_rf(hist_dir) # delete it From 58eec51312f8264646877b3b992fd7026da64be4 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:44:03 +0300 Subject: [PATCH 371/488] ruby: Layout/IndentationConsistency correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 499572a84..c6518137c 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -240,11 +240,11 @@ def remove hist_dir = DocumentHelper.history_dir(storage_path) # if the file exists - FileUtils.rm_f(storage_path) # delete it from the storage path + FileUtils.rm_f(storage_path) # delete it from the storage path # if the history directory of this file exists - FileUtils.rm_rf(hist_dir) # delete it + FileUtils.rm_rf(hist_dir) # delete it render(plain: '{"success":true}') # report that the operation is successful From 743176bb5ce22bea5bf839073cd54bb25557d794 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:44:29 +0300 Subject: [PATCH 372/488] ruby: Layout/TrailingWhitespace correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- .../ruby/app/models/users.rb | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index c6518137c..b4b51d072 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -241,11 +241,11 @@ def remove # if the file exists FileUtils.rm_f(storage_path) # delete it from the storage path - + # if the history directory of this file exists FileUtils.rm_rf(hist_dir) # delete it - + render(plain: '{"success":true}') # report that the operation is successful nil diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index b8f746102..c53883f93 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -31,17 +31,17 @@ class User :templates, :avatar - def initialize(id, -name, -email, -group, -review_groups, -comment_groups, -user_info_groups, + def initialize(id, +name, +email, +group, +review_groups, +comment_groups, +user_info_groups, favorite, - denied_permissions, -descriptions, -templates, + denied_permissions, +descriptions, +templates, avatar) @id = id @name = name From f00f2126620474518309c6d497f88b310f5eacc9 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:44:59 +0300 Subject: [PATCH 373/488] ruby: Lint/SymbolConversion correct --- .../ruby/app/controllers/home_controller.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index b4b51d072..d80464518 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -446,7 +446,7 @@ def restore DocumentHelper.init(request.remote_ip, request.base_url) file_model = FileModel.new( { - 'file_name': source_basename + file_name: source_basename } ) @@ -471,13 +471,13 @@ def restore bumped_changes_file = bumped_version_directory.join('changes.json') bumped_changes = { - 'serverVersion': nil, - 'changes': [ + serverVersion: nil, + changes: [ { - 'created': Time.now.to_formatted_s(:db), - 'user': { - 'id': user.id, - 'name': user.name + created: Time.now.to_formatted_s(:db), + user: { + id: user.id, + name: user.name } } ] From 18aa9487b3bb9d20befa524957c81490de4c05ba Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:45:27 +0300 Subject: [PATCH 374/488] ruby: Layout/FirstMethodArgumentLineBreak correct --- .../ruby/app/controllers/home_controller.rb | 6 ++++-- web/documentserver-example/ruby/app/models/file_model.rb | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index d80464518..eccb0bf9e 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -489,13 +489,15 @@ def restore FileUtils.cp(source_file, bumped_file) FileUtils.cp(recovery_file, source_file) - render(json: { + render( +json: { error: nil, success: true }) rescue StandardError => e response.status = :internal_server_error - render(json: { + render( +json: { error: e.message, success: false }) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 5e262979a..d4a268610 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -280,7 +280,8 @@ def history prev = hist_data[(i - 2).to_s] # get the history data from the previous file version # write key and url information about previous file version with optional direct url - data(obj['previous'] = if enable_direct_url? == true + data( +obj['previous'] = if enable_direct_url? == true { # write key and url information about previous file version with optional directUrl fileType: prev['fileType'], key: prev['key'], From 5f68d09e2f789b45eefc6e0c166e8608bbbc13ca Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:46:25 +0300 Subject: [PATCH 375/488] ruby: Layout/FirstHashElementIndentation correct --- .../ruby/app/controllers/home_controller.rb | 8 ++++---- web/documentserver-example/ruby/app/models/users.rb | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index eccb0bf9e..3b08a4cce 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -491,15 +491,15 @@ def restore render( json: { - error: nil, + error: nil, success: true - }) +}) rescue StandardError => e response.status = :internal_server_error render( json: { - error: e.message, + error: e.message, success: false - }) +}) end end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index c53883f93..463d6f204 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -130,10 +130,10 @@ class Users 'group-2', ['group-2', ''], { - view: '', + view: '', edit: ['group-2', ''], remove: ['group-2'] - }, + }, ['group-2', ''], true, [], @@ -147,10 +147,10 @@ class Users 'group-3', ['group-2'], { - view: ['group-3', 'group-2'], + view: ['group-3', 'group-2'], edit: ['group-2'], remove: [] - }, + }, ['group-2'], false, ['copy', 'download', 'print'], From 7e9356df5ec868483e5086abad4ef5daca8c12ef Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:46:53 +0300 Subject: [PATCH 376/488] ruby: Layout/MultilineMethodCallBraceLayout correct --- .../ruby/app/controllers/home_controller.rb | 6 ++++-- .../ruby/app/models/file_model.rb | 9 ++++++--- .../ruby/app/models/track_helper.rb | 12 ++++++++---- web/documentserver-example/ruby/app/models/users.rb | 12 ++++++++---- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 3b08a4cce..b6d0ff158 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -493,13 +493,15 @@ def restore json: { error: nil, success: true -}) +} +) rescue StandardError => e response.status = :internal_server_error render( json: { error: e.message, success: false -}) +} +) end end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index d4a268610..fb4fd5a1b 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -53,7 +53,8 @@ def file_uri_user else DocumentHelper.get_file_uri( @file_name, - false) + false +) end end @@ -258,7 +259,8 @@ def history file_name, i, "prev#{file_ext}", - false) + false +) end end data_obj['version'] = i @@ -294,7 +296,8 @@ def history key: prev['key'], url: prev['url'] } - end) + end +) # write the path to the diff.zip archive with differences in this file version data_obj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index ded766b0a..592e4de9d 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -128,7 +128,8 @@ def process_save(raw_file_data, file_name, user_address) rescue StandardError new_file_name = DocumentHelper.get_correct_name( File.basename(file_name, cur_ext) + download_ext, - user_address) + user_address +) end end @@ -227,18 +228,21 @@ def process_force_save(file_data, file_name, user_address) file_name = if new_file_name DocumentHelper.get_correct_name( "#{File.basename(file_name, cur_ext)}-form#{download_ext}", - user_address) # get the correct file name if it already exists + user_address +) # get the correct file name if it already exists else DocumentHelper.get_correct_name( "#{File.basename(file_name, cur_ext)}-form#{cur_ext}", - user_address) + user_address +) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else if new_file_name file_name = DocumentHelper.get_correct_name( File.basename(file_name, cur_ext) + download_ext, - user_address) + user_address +) end forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) if forcesave_path.eql?('') diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 463d6f204..9a8ae5cc3 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -122,7 +122,8 @@ class Users [], @descr_user_first, true, - true), + true +), User.new( 'uid-2', 'Mark Pottato', @@ -139,7 +140,8 @@ class Users [], @descr_user_second, false, - true), + true +), User.new( 'uid-3', 'Hamish Mitchell', @@ -156,7 +158,8 @@ class Users ['copy', 'download', 'print'], @descr_user_third, false, - false), + false +), User.new( 'uid-0', nil, @@ -169,7 +172,8 @@ class Users ['protect'], @descr_user_null, false, - false) + false +) ] class << self From af38a4ba61e21602925ceec712986e118d75a87c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:47:24 +0300 Subject: [PATCH 377/488] ruby: Layout/LineEndStringConcatenationIndentation correct --- .../ruby/app/models/document_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 977081644..53677c90b 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -222,8 +222,8 @@ def get_historypath_uri(file_name, version, file, is_server_url: true) # for redirection to my link user_host = is_server_url ? "&userAddress=#{cur_user_host_address(nil)}" : '' "#{get_server_url(is_server_url)}/downloadhistory/?"\ - "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}"\ - "&file=#{ERB::Util.url_encode(file)}#{user_host}" + "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}"\ + "&file=#{ERB::Util.url_encode(file)}#{user_host}" end # get server url @@ -238,8 +238,8 @@ def get_server_url(for_document_server) # get callback url def get_callback(file_name) "#{get_server_url(true)}/track?" \ - "fileName=#{ERB::Util.url_encode(file_name)}&" \ - "userAddress=#{cur_user_host_address(nil)}" + "fileName=#{ERB::Util.url_encode(file_name)}&" \ + "userAddress=#{cur_user_host_address(nil)}" end # get url to the created file From 94df21fe21fef692e2abbf67285318d762d4aef9 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:48:18 +0300 Subject: [PATCH 378/488] ruby: Style/ClassMethodsDefinitions correct --- .../ruby/app/models/document_helper.rb | 452 +++++++++-------- .../ruby/app/models/file_utility.rb | 15 +- .../ruby/app/models/jwt_helper.rb | 44 +- .../ruby/app/models/service_converter.rb | 238 +++++---- .../ruby/app/models/track_helper.rb | 454 +++++++++--------- .../ruby/app/models/users.rb | 48 +- 6 files changed, 621 insertions(+), 630 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 53677c90b..765eaafa4 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -32,294 +32,292 @@ class << self @remote_ip = nil @base_url = nil - class << self - def init(ip, url) - @remote_ip = ip - @base_url = url - end + def self.init(ip, url) + @remote_ip = ip + @base_url = url + end - # define max file size - def file_size_max - DocumentHelper.config_manager.maximum_file_size - end + # define max file size + def self.file_size_max + DocumentHelper.config_manager.maximum_file_size + end - # all the supported file extensions - def file_exts - DocumentHelper.format_manager.all_extensions - end + # all the supported file extensions + def self.file_exts + DocumentHelper.format_manager.all_extensions + end - def fill_forms_exts - DocumentHelper.format_manager.fillable_extensions - end + def self.fill_forms_exts + DocumentHelper.format_manager.fillable_extensions + end - # file extensions that can be viewed - def viewed_exts - DocumentHelper.format_manager.viewable_extensions - end + # file extensions that can be viewed + def self.viewed_exts + DocumentHelper.format_manager.viewable_extensions + end - # file extensions that can be edited - def edited_exts - DocumentHelper.format_manager.editable_extensions - end + # file extensions that can be edited + def self.edited_exts + DocumentHelper.format_manager.editable_extensions + end - # file extensions that can be converted - def convert_exts - DocumentHelper.format_manager.convertible_extensions - end + # file extensions that can be converted + def self.convert_exts + DocumentHelper.format_manager.convertible_extensions + end - # get current user host address - def cur_user_host_address(user_address) - (user_address.nil? ? @remote_ip : user_address).gsub(/[^0-9\-.a-zA-Z_=]/, '_') - end + # get current user host address + def self.cur_user_host_address(user_address) + (user_address.nil? ? @remote_ip : user_address).gsub(/[^0-9\-.a-zA-Z_=]/, '_') + end - # get the storage path of the given file - def storage_path(file_name, user_address) - directory = DocumentHelper.config_manager.storage_path.join(cur_user_host_address(user_address)) + # get the storage path of the given file + def self.storage_path(file_name, user_address) + directory = DocumentHelper.config_manager.storage_path.join(cur_user_host_address(user_address)) - # create a new directory if it doesn't exist - FileUtils.mkdir_p(directory) unless File.directory?(directory) + # create a new directory if it doesn't exist + FileUtils.mkdir_p(directory) unless File.directory?(directory) - # put the given file to this directory - File.join(directory, File.basename(file_name)) - end + # put the given file to this directory + File.join(directory, File.basename(file_name)) + end - # get the path to the forcesaved file version - def forcesave_path(file_name, user_address, create) - directory = DocumentHelper.config_manager.storage_path.join(cur_user_host_address(user_address)) + # get the path to the forcesaved file version + def self.forcesave_path(file_name, user_address, create) + directory = DocumentHelper.config_manager.storage_path.join(cur_user_host_address(user_address)) - # the directory with host address doesn't exist - return '' unless File.directory?(directory) + # the directory with host address doesn't exist + return '' unless File.directory?(directory) - # get the path to the history of the given file - directory = File.join(directory, "#{File.basename(file_name)}-hist") - unless File.directory?(directory) - return '' unless create + # get the path to the history of the given file + directory = File.join(directory, "#{File.basename(file_name)}-hist") + unless File.directory?(directory) + return '' unless create - FileUtils.mkdir_p(directory) # create history directory if it doesn't exist + FileUtils.mkdir_p(directory) # create history directory if it doesn't exist - # the history directory doesn't exist and we are not supposed to create it + # the history directory doesn't exist and we are not supposed to create it - end + end - directory = File.join(directory, File.basename(file_name)) # get the path to the given file - return '' if !File.file?(directory) && !create + directory = File.join(directory, File.basename(file_name)) # get the path to the given file + return '' if !File.file?(directory) && !create - directory.to_s - end + directory.to_s + end - # get the path to the file history - def history_dir(storage_path) - directory = "#{storage_path}-hist" + # get the path to the file history + def self.history_dir(storage_path) + directory = "#{storage_path}-hist" - # create history directory if it doesn't exist - FileUtils.mkdir_p(directory) unless File.directory?(directory) + # create history directory if it doesn't exist + FileUtils.mkdir_p(directory) unless File.directory?(directory) - directory - end + directory + end - # get the path to the specified file version - def version_dir(hist_dir, ver) - File.join(hist_dir, ver.to_s) - end + # get the path to the specified file version + def self.version_dir(hist_dir, ver) + File.join(hist_dir, ver.to_s) + end - # get the last file version - def get_file_version(hist_dir) - return 1 unless Dir.exist?(hist_dir) + # get the last file version + def self.get_file_version(hist_dir) + return 1 unless Dir.exist?(hist_dir) - ver = 1 - Dir.foreach(hist_dir) do |e| # run through all the file versions - next if e.eql?('.') - next if e.eql?('..') + ver = 1 + Dir.foreach(hist_dir) do |e| # run through all the file versions + next if e.eql?('.') + next if e.eql?('..') - if File.directory?(File.join(hist_dir, e)) - ver += 1 # and count them - end + if File.directory?(File.join(hist_dir, e)) + ver += 1 # and count them end - - ver end - # get the correct file name if such a name already exists - def get_correct_name(file_name, user_address) - max_name = 50 - ext = File.extname(file_name) # get file extension - # get file name without extension - base_name = File.basename(file_name, ext)[0...max_name] + (file_name.length > max_name ? '[...]' : '') - name = base_name + ext.downcase # get full file name - index = 1 - - # if the file with such a name already exists in this directory - while File.exist?(storage_path(name, user_address)) - name = "#{base_name} (#{index})#{ext.downcase}" # add an index after its base name - index += 1 - end + ver + end - name + # get the correct file name if such a name already exists + def self.get_correct_name(file_name, user_address) + max_name = 50 + ext = File.extname(file_name) # get file extension + # get file name without extension + base_name = File.basename(file_name, ext)[0...max_name] + (file_name.length > max_name ? '[...]' : '') + name = base_name + ext.downcase # get full file name + index = 1 + + # if the file with such a name already exists in this directory + while File.exist?(storage_path(name, user_address)) + name = "#{base_name} (#{index})#{ext.downcase}" # add an index after its base name + index += 1 end - # get all the stored files from the folder - def get_stored_files(user_address) - directory = DocumentHelper.config_manager.storage_path.join(cur_user_host_address(user_address)) + name + end + + # get all the stored files from the folder + def self.get_stored_files(user_address) + directory = DocumentHelper.config_manager.storage_path.join(cur_user_host_address(user_address)) - arr = [] + arr = [] - if Dir.exist?(directory) - Dir.foreach(directory) do |e| # run through all the elements from the folder - next if e.eql?('.') - next if e.eql?('..') - next if File.directory?(File.join(directory, e)) # if the element is a directory, skip it + if Dir.exist?(directory) + Dir.foreach(directory) do |e| # run through all the elements from the folder + next if e.eql?('.') + next if e.eql?('..') + next if File.directory?(File.join(directory, e)) # if the element is a directory, skip it - arr.push(e) # push the file to the array - end + arr.push(e) # push the file to the array end - - arr end - # create file meta information - def create_meta(file_name, uid, uname, user_address) - hist_dir = history_dir(storage_path(file_name, user_address)) # get the path to the file history + arr + end - # write user name, user uid and the creation time to the json object - json = { - created: Time.now.to_formatted_s(:db), - uid:, - uname: - } + # create file meta information + def self.create_meta(file_name, uid, uname, user_address) + hist_dir = history_dir(storage_path(file_name, user_address)) # get the path to the file history - # write file meta information to the createdInfo.json file - File.binwrite(File.join(hist_dir, 'createdInfo.json'), json.to_json) - end + # write user name, user uid and the creation time to the json object + json = { + created: Time.now.to_formatted_s(:db), + uid:, + uname: + } - # create demo document - def create_demo(file_ext, sample, user) - demo_name = (sample == 'true' ? 'sample.' : 'new.') + file_ext - file_name = get_correct_name(demo_name, nil) # get the correct file name if such a name already exists + # write file meta information to the createdInfo.json file + File.binwrite(File.join(hist_dir, 'createdInfo.json'), json.to_json) + end - # save sample document of a necessary extension to the storage directory - src = Rails.root.join('assets', 'document-templates', sample == 'true' ? 'sample' : 'new', demo_name) - dest = storage_path(file_name, nil) + # create demo document + def self.create_demo(file_ext, sample, user) + demo_name = (sample == 'true' ? 'sample.' : 'new.') + file_ext + file_name = get_correct_name(demo_name, nil) # get the correct file name if such a name already exists - FileUtils.cp(src, dest) + # save sample document of a necessary extension to the storage directory + src = Rails.root.join('assets', 'document-templates', sample == 'true' ? 'sample' : 'new', demo_name) + dest = storage_path(file_name, nil) - # save file meta data to the file + FileUtils.cp(src, dest) - create_meta(file_name, user.id, user.name, nil) + # save file meta data to the file - file_name - end + create_meta(file_name, user.id, user.name, nil) - # get file url - def get_file_uri(file_name, for_document_server) - "#{get_server_url(for_document_server)}/" \ - "#{DocumentHelper.config_manager.storage_path}/" \ - "#{cur_user_host_address(nil)}/" \ - "#{ERB::Util.url_encode(file_name)}" - end + file_name + end - # get history path url - def get_historypath_uri(file_name, version, file, is_server_url: true) - # for redirection to my link - user_host = is_server_url ? "&userAddress=#{cur_user_host_address(nil)}" : '' - "#{get_server_url(is_server_url)}/downloadhistory/?"\ - "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}"\ - "&file=#{ERB::Util.url_encode(file)}#{user_host}" - end + # get file url + def self.get_file_uri(file_name, for_document_server) + "#{get_server_url(for_document_server)}/" \ + "#{DocumentHelper.config_manager.storage_path}/" \ + "#{cur_user_host_address(nil)}/" \ + "#{ERB::Util.url_encode(file_name)}" + end - # get server url - def get_server_url(for_document_server) - return DocumentHelper.config_manager.example_uri.to_s if - for_document_server && - DocumentHelper.config_manager.example_uri + # get history path url + def self.get_historypath_uri(file_name, version, file, is_server_url: true) + # for redirection to my link + user_host = is_server_url ? "&userAddress=#{cur_user_host_address(nil)}" : '' + "#{get_server_url(is_server_url)}/downloadhistory/?"\ + "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}"\ + "&file=#{ERB::Util.url_encode(file)}#{user_host}" + end - @base_url - end + # get server url + def self.get_server_url(for_document_server) + return DocumentHelper.config_manager.example_uri.to_s if + for_document_server && + DocumentHelper.config_manager.example_uri - # get callback url - def get_callback(file_name) - "#{get_server_url(true)}/track?" \ - "fileName=#{ERB::Util.url_encode(file_name)}&" \ - "userAddress=#{cur_user_host_address(nil)}" - end + @base_url + end - # get url to the created file - def get_create_url(document_type) - "#{get_server_url(false)}/sample?fileExt=#{get_internal_extension(document_type).delete('.')}" - end + # get callback url + def self.get_callback(file_name) + "#{get_server_url(true)}/track?" \ + "fileName=#{ERB::Util.url_encode(file_name)}&" \ + "userAddress=#{cur_user_host_address(nil)}" + end - # get url to download a file - def get_download_url(file_name, is_server_url: true) - user_host = is_server_url ? "&userAddress=#{cur_user_host_address(nil)}" : '' - "#{get_server_url(is_server_url)}/download?fileName=#{ERB::Util.url_encode(file_name)}#{user_host}" - end + # get url to the created file + def self.get_create_url(document_type) + "#{get_server_url(false)}/sample?fileExt=#{get_internal_extension(document_type).delete('.')}" + end - # get internal file extension by its type - def get_internal_extension(file_type) - case file_type - when 'word' # .docx for word type - '.docx' - when 'cell' # .xlsx for cell type - '.xlsx' - when 'slide' # .pptx for slide type - '.pptx' - else - '.docx' # the default value is .docx - end + # get url to download a file + def self.get_download_url(file_name, is_server_url: true) + user_host = is_server_url ? "&userAddress=#{cur_user_host_address(nil)}" : '' + "#{get_server_url(is_server_url)}/download?fileName=#{ERB::Util.url_encode(file_name)}#{user_host}" + end + + # get internal file extension by its type + def self.get_internal_extension(file_type) + case file_type + when 'word' # .docx for word type + '.docx' + when 'cell' # .xlsx for cell type + '.xlsx' + when 'slide' # .pptx for slide type + '.pptx' + else + '.docx' # the default value is .docx end + end - # get image url for templates - def get_template_image_url(file_type) - path = "#{get_server_url(true)}/assets/" - case file_type - when 'word' # for word type - "#{path}file_docx.svg" - when 'cell' # .xlsx for cell type - "#{path}file_xlsx.svg" - when 'slide' # .pptx for slide type - "#{path}file_pptx.svg" - else - "#{path}file_docx.svg" # the default value is .docx - end + # get image url for templates + def self.get_template_image_url(file_type) + path = "#{get_server_url(true)}/assets/" + case file_type + when 'word' # for word type + "#{path}file_docx.svg" + when 'cell' # .xlsx for cell type + "#{path}file_xlsx.svg" + when 'slide' # .pptx for slide type + "#{path}file_pptx.svg" + else + "#{path}file_docx.svg" # the default value is .docx end + end + + # get files information + def self.get_files_info(file_id) + result = [] + + get_stored_files(nil).each do |file_name| # run through all the stored files from the folder + directory = storage_path(file_name, nil) + uri = "#{cur_user_host_address(nil)}/#{file_name}" + + # write file parameters to the info object + info = { + version: get_file_version(history_dir(directory)), + id: ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), + contentLength: "#{(File.size(directory) / 1024.0).round(2)} KB", + pureContentLength: File.size(directory), + title: file_name, + updated: File.mtime(directory) + } - # get files information - def get_files_info(file_id) - result = [] - - get_stored_files(nil).each do |file_name| # run through all the stored files from the folder - directory = storage_path(file_name, nil) - uri = "#{cur_user_host_address(nil)}/#{file_name}" - - # write file parameters to the info object - info = { - version: get_file_version(history_dir(directory)), - id: ServiceConverter.generate_revision_id("#{uri}.#{File.mtime(directory)}"), - contentLength: "#{(File.size(directory) / 1024.0).round(2)} KB", - pureContentLength: File.size(directory), - title: file_name, - updated: File.mtime(directory) - } - - if file_id.nil? # if file id is undefined - result.push(info) # push info object to the response array - elsif file_id.eql?(info['id']) # if file id is defined - result.push(info) # response object will be equal to the info object - return result # and it is equal to the document key value - end + if file_id.nil? # if file id is undefined + result.push(info) # push info object to the response array + elsif file_id.eql?(info['id']) # if file id is defined + result.push(info) # response object will be equal to the info object + return result # and it is equal to the document key value end + end - return '"File not found"' unless file_id.nil? + return '"File not found"' unless file_id.nil? - result - end + result + end - # enable ignore certificate - def verify_ssl(file_uri, http) - return unless file_uri.start_with?('https') && DocumentHelper.config_manager.ssl_verify_peer_mode_enabled + # enable ignore certificate + def self.verify_ssl(file_uri, http) + return unless file_uri.start_with?('https') && DocumentHelper.config_manager.ssl_verify_peer_mode_enabled - http.use_ssl = true - # set the flags for the server certificate verification at the beginning of SSL session - http.verify_mode = OpenSSL::SSL::VERIFY_NONE - end + http.use_ssl = true + # set the flags for the server certificate verification at the beginning of SSL session + http.verify_mode = OpenSSL::SSL::VERIFY_NONE end end diff --git a/web/documentserver-example/ruby/app/models/file_utility.rb b/web/documentserver-example/ruby/app/models/file_utility.rb index 52551f2a9..e521aa22f 100644 --- a/web/documentserver-example/ruby/app/models/file_utility.rb +++ b/web/documentserver-example/ruby/app/models/file_utility.rb @@ -25,14 +25,15 @@ class FileUtility class << self attr_reader :format_manager - def get_file_type(file_name) - ext = File.extname(file_name).downcase + end + + def self.get_file_type(file_name) + ext = File.extname(file_name).downcase - return 'word' if FileUtility.format_manager.document_extensinons.include?(ext) - return 'cell' if FileUtility.format_manager.spreadsheet_extensinons.include?(ext) - return 'slide' if FileUtility.format_manager.presentation_extensinons.include?(ext) + return 'word' if FileUtility.format_manager.document_extensinons.include?(ext) + return 'cell' if FileUtility.format_manager.spreadsheet_extensinons.include?(ext) + return 'slide' if FileUtility.format_manager.presentation_extensinons.include?(ext) - 'word' - end + 'word' end end diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 55ab0b32f..92c580173 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -24,32 +24,30 @@ class JwtHelper @jwt_secret = ConfigurationManager.new.jwt_secret @token_use_for_request = ConfigurationManager.new.jwt_use_for_request - class << self - # check if a secret key to generate token exists or not - def enabled? - @jwt_secret && !@jwt_secret.empty? ? true : false - end + # check if a secret key to generate token exists or not + def self.enabled? + @jwt_secret && !@jwt_secret.empty? ? true : false + end - # check if a secret key used for request - def use_for_request - @token_use_for_request - end + # check if a secret key used for request + def self.use_for_request + @token_use_for_request + end - # encode a payload object into a token using a secret key - def encode(payload) - JWT.encode(payload, @jwt_secret, 'HS256') # define the hashing algorithm and get token - end + # encode a payload object into a token using a secret key + def self.encode(payload) + JWT.encode(payload, @jwt_secret, 'HS256') # define the hashing algorithm and get token + end - # decode a token into a payload object using a secret key - def decode(token) - begin - decoded = JWT.decode(token, @jwt_secret, true, { algorithm: 'HS256' }) - rescue StandardError - return '' - end - # decoded = Array [ {"data"=>"test"}, # payload - # {"alg"=>"HS256"} # header ] - decoded[0].to_json # get json payload + # decode a token into a payload object using a secret key + def self.decode(token) + begin + decoded = JWT.decode(token, @jwt_secret, true, { algorithm: 'HS256' }) + rescue StandardError + return '' end + # decoded = Array [ {"data"=>"test"}, # payload + # {"alg"=>"HS256"} # header ] + decoded[0].to_json # get json payload end end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 507dfa68c..e58bcd3af 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -29,150 +29,148 @@ class << self @convert_timeout = ServiceConverter.config_manager.convertation_timeout @document_converter_url = ServiceConverter.config_manager.document_server_converter_uri.to_s - class << self - # get the url of the converted file - def get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_async, file_pass, lang = nil) - from_ext = File.extname(document_uri).downcase if from_ext.nil? # get the current document extension - - # get the current document name or uuid - title = File.basename(URI.parse(document_uri).path) - title = UUID.generate.to_s if title.nil? - - # get the document key - document_revision_id = document_uri if document_revision_id.empty? - document_revision_id = generate_revision_id(document_revision_id) - - payload = { # write all the conversion parameters to the payload - async: is_async ? true : false, - url: document_uri, - outputtype: to_ext.delete('.'), - filetype: from_ext.delete('.'), - title:, - key: document_revision_id, - password: file_pass, - region: lang - } - - data = nil - begin - uri = URI.parse(@document_converter_url) # create the request url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - - DocumentHelper.verify_ssl(@document_converter_url, http) - - http.read_timeout = @convert_timeout - http.open_timeout = 5 - req = Net::HTTP::Post.new(uri.request_uri) # create the post request - req.add_field('Accept', 'application/json') # set headers - req.add_field('Content-Type', 'application/json') - - if JwtHelper.enabled? && JwtHelper.use_for_request # if the signature is enabled - payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload - jwt_header = ServiceConverter.config_manager.jwt_header; # get signature authorization header - # set it to the request with the Bearer prefix - req.add_field(jwt_header, "Bearer #{JwtHelper.encode({ payload: })}") - end - - req.body = payload.to_json - res = http.request(req) # get the response - - status_code = Integer(res.code, 10) - raise("Conversion service returned status: #{status_code}") if status_code != 200 # checking status code - - data = res.body # and take its body - rescue Timeout::Error - # try again - rescue StandardError => e - raise(e.message) + # get the url of the converted file + def self.get_converted_data(document_uri, from_ext, to_ext, document_revision_id, is_async, file_pass, lang = nil) + from_ext = File.extname(document_uri).downcase if from_ext.nil? # get the current document extension + + # get the current document name or uuid + title = File.basename(URI.parse(document_uri).path) + title = UUID.generate.to_s if title.nil? + + # get the document key + document_revision_id = document_uri if document_revision_id.empty? + document_revision_id = generate_revision_id(document_revision_id) + + payload = { # write all the conversion parameters to the payload + async: is_async ? true : false, + url: document_uri, + outputtype: to_ext.delete('.'), + filetype: from_ext.delete('.'), + title:, + key: document_revision_id, + password: file_pass, + region: lang + } + + data = nil + begin + uri = URI.parse(@document_converter_url) # create the request url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + + DocumentHelper.verify_ssl(@document_converter_url, http) + + http.read_timeout = @convert_timeout + http.open_timeout = 5 + req = Net::HTTP::Post.new(uri.request_uri) # create the post request + req.add_field('Accept', 'application/json') # set headers + req.add_field('Content-Type', 'application/json') + + if JwtHelper.enabled? && JwtHelper.use_for_request # if the signature is enabled + payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload + jwt_header = ServiceConverter.config_manager.jwt_header; # get signature authorization header + # set it to the request with the Bearer prefix + req.add_field(jwt_header, "Bearer #{JwtHelper.encode({ payload: })}") end - json_data = JSON.parse(data) # parse response body - get_response_data(json_data) # get response url + req.body = payload.to_json + res = http.request(req) # get the response + + status_code = Integer(res.code, 10) + raise("Conversion service returned status: #{status_code}") if status_code != 200 # checking status code + + data = res.body # and take its body + rescue Timeout::Error + # try again + rescue StandardError => e + raise(e.message) end - # generate the document key value - def generate_revision_id(expected_key) - require('zlib') + json_data = JSON.parse(data) # parse response body + get_response_data(json_data) # get response url + end - if expected_key.length > 20 # check if the expected key length is greater than 20 - # calculate 32-bit crc value from the expected key and turn it into the string - expected_key = Zlib.crc32(expected_key).to_s - end + # generate the document key value + def self.generate_revision_id(expected_key) + require('zlib') - key = expected_key.gsub(/[^0-9a-zA-Z.=]/, '_') - key[(key.length - [key.length, 20].min)..key.length] # the resulting key is of the length 20 or less + if expected_key.length > 20 # check if the expected key length is greater than 20 + # calculate 32-bit crc value from the expected key and turn it into the string + expected_key = Zlib.crc32(expected_key).to_s end - # create an error message for the error code - def process_convert_service_responce_error(error_code) - error_message = 'unknown error' - - # add an error message to the error message template depending on the error code - case error_code - when -8 - error_message = 'Error occurred in the ConvertService.ashx: Error document VKey' - when -7 - error_message = 'Error occurred in the ConvertService.ashx: Error document request' - when -6 - error_message = 'Error occurred in the ConvertService.ashx: Error database' - when -5 - error_message = 'Error occurred in the ConvertService.ashx: Incorrect password' - when -4 - error_message = 'Error occurred in the ConvertService.ashx: Error download error' - when -3 - error_message = 'Error occurred in the ConvertService.ashx: Error convertation error' - when -2 - error_message = 'Error occurred in the ConvertService.ashx: Error convertation timeout' - when -1 - error_message = 'Error occurred in the ConvertService.ashx: Error convertation unknown' - when 0 - # public const int c_nErrorNo = 0 - else - error_message = "ErrorCode = #{error_code}" # default value for the error message - end + key = expected_key.gsub(/[^0-9a-zA-Z.=]/, '_') + key[(key.length - [key.length, 20].min)..key.length] # the resulting key is of the length 20 or less + end - raise(error_message) + # create an error message for the error code + def self.process_convert_service_responce_error(error_code) + error_message = 'unknown error' + + # add an error message to the error message template depending on the error code + case error_code + when -8 + error_message = 'Error occurred in the ConvertService.ashx: Error document VKey' + when -7 + error_message = 'Error occurred in the ConvertService.ashx: Error document request' + when -6 + error_message = 'Error occurred in the ConvertService.ashx: Error database' + when -5 + error_message = 'Error occurred in the ConvertService.ashx: Incorrect password' + when -4 + error_message = 'Error occurred in the ConvertService.ashx: Error download error' + when -3 + error_message = 'Error occurred in the ConvertService.ashx: Error convertation error' + when -2 + error_message = 'Error occurred in the ConvertService.ashx: Error convertation timeout' + when -1 + error_message = 'Error occurred in the ConvertService.ashx: Error convertation unknown' + when 0 + # public const int c_nErrorNo = 0 + else + error_message = "ErrorCode = #{error_code}" # default value for the error message end - # get the response url - def get_response_data(json_data) - file_result = json_data + raise(error_message) + end - error_element = file_result['error'] - unless error_element.nil? # if an error occurs - process_convert_service_responce_error(Integer(error_element, 10)) # get an error message - end + # get the response url + def self.get_response_data(json_data) + file_result = json_data - is_end_convert = file_result['endConvert'] # check if the conversion is completed + error_element = file_result['error'] + unless error_element.nil? # if an error occurs + process_convert_service_responce_error(Integer(error_element, 10)) # get an error message + end - result_percent = 0 # the conversion percentage - response_uri = '' - response_file_type = '' + is_end_convert = file_result['endConvert'] # check if the conversion is completed - if is_end_convert # if the conversion is completed + result_percent = 0 # the conversion percentage + response_uri = '' + response_file_type = '' - file_url_element = file_result['fileUrl'] - file_type_element = file_result['fileType'] + if is_end_convert # if the conversion is completed - if file_url_element.nil? # and the file url doesn't exist - raise('Invalid answer format') # get ann error message - end + file_url_element = file_result['fileUrl'] + file_type_element = file_result['fileType'] - response_uri = file_url_element # otherwise, get the file url - response_file_type = file_type_element # get the file type - result_percent = 100 + if file_url_element.nil? # and the file url doesn't exist + raise('Invalid answer format') # get ann error message + end - else # if the conversion isn't completed + response_uri = file_url_element # otherwise, get the file url + response_file_type = file_type_element # get the file type + result_percent = 100 - percent_element = file_result['percent'] # get the percentage value + else # if the conversion isn't completed - result_percent = Integer(percent_element, 10) unless percent_element.nil? + percent_element = file_result['percent'] # get the percentage value - result_percent = 99 if result_percent >= 100 + result_percent = Integer(percent_element, 10) unless percent_element.nil? - end + result_percent = 99 if result_percent >= 100 - [result_percent, response_uri, response_file_type] end + + [result_percent, response_uri, response_file_type] end end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 592e4de9d..2497a4c60 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -32,301 +32,299 @@ class << self @document_command_url = TrackHelper.config_manager.document_server_command_uri.to_s - class << self - # read the request body - def read_body(request) - body = request.body.read - - return '' if body.nil? || body.empty? - - file_data = JSON.parse(body) # parse file data - - # check if a secret key to generate token exists or not - if JwtHelper.enabled? && JwtHelper.use_for_request - in_header = false - token = nil - jwt_header = TrackHelper.config_manager.jwt_header; # get the authorization header from the config - if file_data['token'] # if the token is in the body - token = JwtHelper.decode(file_data['token']) # decode a token into a payload object using a secret key - elsif request.headers[jwt_header] # if the token is in the header - hdr = request.headers[jwt_header] - hdr.slice!(0, 'Bearer '.length) # get token from it (after Bearer prefix) - token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key - in_header = true - else - raise('Expected JWT') # token missing error message - end + # read the request body + def self.read_body(request) + body = request.body.read + + return '' if body.nil? || body.empty? + + file_data = JSON.parse(body) # parse file data + + # check if a secret key to generate token exists or not + if JwtHelper.enabled? && JwtHelper.use_for_request + in_header = false + token = nil + jwt_header = TrackHelper.config_manager.jwt_header; # get the authorization header from the config + if file_data['token'] # if the token is in the body + token = JwtHelper.decode(file_data['token']) # decode a token into a payload object using a secret key + elsif request.headers[jwt_header] # if the token is in the header + hdr = request.headers[jwt_header] + hdr.slice!(0, 'Bearer '.length) # get token from it (after Bearer prefix) + token = JwtHelper.decode(hdr) # decode a token into a payload object using a secret key + in_header = true + else + raise('Expected JWT') # token missing error message + end - raise('Invalid JWT signature') if !token || token.eql?('') + raise('Invalid JWT signature') if !token || token.eql?('') - file_data = JSON.parse(token) + file_data = JSON.parse(token) - file_data = file_data['payload'] if in_header - end + file_data = file_data['payload'] if in_header + end + + file_data + end + + def self.resolve_process_save_body(body) + copied = body.dup - file_data + url = copied['url'] + if url + uri = URI(url) + resolved_uri = TrackHelper.proxy_manager.resolve_uri(uri) + copied['url'] = resolved_uri.to_s end - def resolve_process_save_body(body) - copied = body.dup + changesurl = copied['changesurl'] + if changesurl + uri = URI(changesurl) + resolved_uri = TrackHelper.proxy_manager.resolve_uri(uri) + copied['changesurl'] = resolved_uri.to_s + end - url = copied['url'] - if url - uri = URI(url) - resolved_uri = TrackHelper.proxy_manager.resolve_uri(uri) - copied['url'] = resolved_uri.to_s - end + home = copied['home'] + copied['home'] = resolve_process_save_body(home) if home - changesurl = copied['changesurl'] - if changesurl - uri = URI(changesurl) - resolved_uri = TrackHelper.proxy_manager.resolve_uri(uri) - copied['changesurl'] = resolved_uri.to_s - end + copied + end - home = copied['home'] - copied['home'] = resolve_process_save_body(home) if home + # file saving process + def self.process_save(raw_file_data, file_name, user_address) + file_data = resolve_process_save_body(raw_file_data) - copied + download_uri = file_data['url'] + if download_uri.eql?(nil) + saved = 1 + return saved end - # file saving process - def process_save(raw_file_data, file_name, user_address) - file_data = resolve_process_save_body(raw_file_data) + new_file_name = file_name + download_ext = ".#{file_data['filetype']}" # get the extension of the downloaded file - download_uri = file_data['url'] - if download_uri.eql?(nil) - saved = 1 - return saved - end + cur_ext = File.extname(file_name).downcase # get current file extension - new_file_name = file_name - download_ext = ".#{file_data['filetype']}" # get the extension of the downloaded file - - cur_ext = File.extname(file_name).downcase # get current file extension - - # convert downloaded file to the file with the current extension if these extensions aren't equal - unless cur_ext.eql?(download_ext) - key = ServiceConverter.generate_revision_id(download_uri) # get the document key - begin - _, new_file_uri, = ServiceConverter.get_converted_data( - download_uri, - download_ext.delete('.'), - cur_ext.delete('.'), - key, - false, - nil - ) # get the url of the converted file - if new_file_uri.nil? || new_file_uri.empty? - new_file_name = DocumentHelper.get_correct_name( - File.basename(file_name, cur_ext) + download_ext, - user_address - ) # get the correct file name if it already exists - else - download_uri = new_file_uri - end - rescue StandardError + # convert downloaded file to the file with the current extension if these extensions aren't equal + unless cur_ext.eql?(download_ext) + key = ServiceConverter.generate_revision_id(download_uri) # get the document key + begin + _, new_file_uri, = ServiceConverter.get_converted_data( + download_uri, + download_ext.delete('.'), + cur_ext.delete('.'), + key, + false, + nil + ) # get the url of the converted file + if new_file_uri.nil? || new_file_uri.empty? new_file_name = DocumentHelper.get_correct_name( File.basename(file_name, cur_ext) + download_ext, user_address -) + ) # get the correct file name if it already exists + else + download_uri = new_file_uri end + rescue StandardError + new_file_name = DocumentHelper.get_correct_name( + File.basename(file_name, cur_ext) + download_ext, + user_address +) end + end - saved = 1 + saved = 1 - data = download_file(download_uri) # download document file - return saved if data.eql?(nil) + data = download_file(download_uri) # download document file + return saved if data.eql?(nil) - begin - # get the storage directory of the new file - storage_path = DocumentHelper.storage_path(new_file_name, user_address) + begin + # get the storage directory of the new file + storage_path = DocumentHelper.storage_path(new_file_name, user_address) - hist_dir = DocumentHelper.history_dir(storage_path) # get the history directory of the new file - # get the path to the specified file version - ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) + hist_dir = DocumentHelper.history_dir(storage_path) # get the history directory of the new file + # get the path to the specified file version + ver_dir = DocumentHelper.version_dir(hist_dir, DocumentHelper.get_file_version(hist_dir)) - FileUtils.mkdir_p(ver_dir) # create the version directory if doesn't exist + FileUtils.mkdir_p(ver_dir) # create the version directory if doesn't exist - # move the file from the storage directory to the previous file version directory - FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) + # move the file from the storage directory to the previous file version directory + FileUtils.move(DocumentHelper.storage_path(file_name, user_address), File.join(ver_dir, "prev#{cur_ext}")) - save_file(data, storage_path) # save the downloaded file to the storage directory + save_file(data, storage_path) # save the downloaded file to the storage directory - change_data = download_file(file_data['changesurl']) # download file with document versions differences - save_file(change_data, File.join(ver_dir, 'diff.zip')) # save file with document versions differences + change_data = download_file(file_data['changesurl']) # download file with document versions differences + save_file(change_data, File.join(ver_dir, 'diff.zip')) # save file with document versions differences - hist_data = file_data['changeshistory'] - hist_data ||= file_data['history'].to_json - if hist_data - File.binwrite(File.join(ver_dir, 'changes.json'), hist_data) - end + hist_data = file_data['changeshistory'] + hist_data ||= file_data['history'].to_json + if hist_data + File.binwrite(File.join(ver_dir, 'changes.json'), hist_data) + end - # write the key value to the key.txt file - File.binwrite(File.join(ver_dir, 'key.txt'), file_data['key']) + # write the key value to the key.txt file + File.binwrite(File.join(ver_dir, 'key.txt'), file_data['key']) - # get the path to the forcesaved file - forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) - unless forcesave_path.eql?('') # if this path is empty - File.delete(forcesave_path) # remove it - end - - saved = 0 - rescue StandardError - saved = 1 + # get the path to the forcesaved file + forcesave_path = DocumentHelper.forcesave_path(new_file_name, user_address, false) + unless forcesave_path.eql?('') # if this path is empty + File.delete(forcesave_path) # remove it end - saved + saved = 0 + rescue StandardError + saved = 1 end - # file force saving process - def process_force_save(file_data, file_name, user_address) - download_uri = file_data['url'] - if download_uri.eql?(nil) - saved = 1 - return saved - end + saved + end + + # file force saving process + def self.process_force_save(file_data, file_name, user_address) + download_uri = file_data['url'] + if download_uri.eql?(nil) + saved = 1 + return saved + end - download_ext = ".#{file_data['filetype']}" # get the extension of the downloaded file - - cur_ext = File.extname(file_name).downcase # get current file extension - - new_file_name = false - - # convert downloaded file to the file with the current extension if these extensions aren't equal - unless cur_ext.eql?(download_ext) - key = ServiceConverter.generate_revision_id(download_uri) # get the document key - begin - _, new_file_uri, = ServiceConverter.get_converted_data( - download_uri, - download_ext.delete('.'), - cur_ext.delete('.'), - key, - false, - nil - ) # get the url of the converted file - if new_file_uri.nil? || new_file_uri.empty? - new_file_name = true - else - download_uri = new_file_uri - end - rescue StandardError + download_ext = ".#{file_data['filetype']}" # get the extension of the downloaded file + + cur_ext = File.extname(file_name).downcase # get current file extension + + new_file_name = false + + # convert downloaded file to the file with the current extension if these extensions aren't equal + unless cur_ext.eql?(download_ext) + key = ServiceConverter.generate_revision_id(download_uri) # get the document key + begin + _, new_file_uri, = ServiceConverter.get_converted_data( + download_uri, + download_ext.delete('.'), + cur_ext.delete('.'), + key, + false, + nil + ) # get the url of the converted file + if new_file_uri.nil? || new_file_uri.empty? new_file_name = true + else + download_uri = new_file_uri end + rescue StandardError + new_file_name = true end + end - saved = 1 + saved = 1 - data = download_file(download_uri) # download document file - return saved if data.eql?(nil) + data = download_file(download_uri) # download document file + return saved if data.eql?(nil) - begin - # check if the forcesave type is equal to 3 (the form was submitted) - is_submit_form = Integer(file_data['forcesavetype'], 10) == 3 - - if is_submit_form - file_name = if new_file_name - DocumentHelper.get_correct_name( - "#{File.basename(file_name, cur_ext)}-form#{download_ext}", - user_address + begin + # check if the forcesave type is equal to 3 (the form was submitted) + is_submit_form = Integer(file_data['forcesavetype'], 10) == 3 + + if is_submit_form + file_name = if new_file_name + DocumentHelper.get_correct_name( + "#{File.basename(file_name, cur_ext)}-form#{download_ext}", + user_address ) # get the correct file name if it already exists - else - DocumentHelper.get_correct_name( - "#{File.basename(file_name, cur_ext)}-form#{cur_ext}", - user_address + else + DocumentHelper.get_correct_name( + "#{File.basename(file_name, cur_ext)}-form#{cur_ext}", + user_address ) - end - forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file - else - if new_file_name - file_name = DocumentHelper.get_correct_name( - File.basename(file_name, cur_ext) + download_ext, - user_address + end + forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file + else + if new_file_name + file_name = DocumentHelper.get_correct_name( + File.basename(file_name, cur_ext) + download_ext, + user_address ) - end - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) - if forcesave_path.eql?('') - # if the path to the new file doesn't exist, create it - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) - end end - - save_file(data, forcesave_path) # save the downloaded file to the storage directory - - if is_submit_form - uid = file_data['actions'][0]['userid'] - # create file meta information with the Filling form tag instead of user name - DocumentHelper.create_meta(file_name, uid, 'Filling Form', user_address) + forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) + if forcesave_path.eql?('') + # if the path to the new file doesn't exist, create it + forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) end + end - saved = 0 - rescue StandardError - saved = 1 + save_file(data, forcesave_path) # save the downloaded file to the storage directory + + if is_submit_form + uid = file_data['actions'][0]['userid'] + # create file meta information with the Filling form tag instead of user name + DocumentHelper.create_meta(file_name, uid, 'Filling Form', user_address) end - saved + saved = 0 + rescue StandardError + saved = 1 end - # send the command request - def command_request(method, key, meta = nil) - # create a payload object with the method and key - payload = { - c: method, - key: - } + saved + end - payload.merge!({ meta: }) unless meta.nil? + # send the command request + def self.command_request(method, key, meta = nil) + # create a payload object with the method and key + payload = { + c: method, + key: + } - data = nil - begin - uri = URI.parse(@document_command_url) # parse the document command url - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + payload.merge!({ meta: }) unless meta.nil? - DocumentHelper.verify_ssl(@document_command_url, http) + data = nil + begin + uri = URI.parse(@document_command_url) # parse the document command url + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - req = Net::HTTP::Post.new(uri.request_uri) # create the post request - req.add_field('Content-Type', 'application/json') # set headers + DocumentHelper.verify_ssl(@document_command_url, http) - if JwtHelper.enabled? && JwtHelper.use_for_request # if the signature is enabled - payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload - jwt_header = TrackHelper.config_manager.jwt_header; # get signature authorization header - # set it to the request with the Bearer prefix - req.add_field(jwt_header, "Bearer #{JwtHelper.encode({ payload: })}") - end + req = Net::HTTP::Post.new(uri.request_uri) # create the post request + req.add_field('Content-Type', 'application/json') # set headers - req.body = payload.to_json # convert the payload object into the json format - res = http.request(req) # get the response - data = res.body # and take its body - rescue StandardError => e - raise(e.message) + if JwtHelper.enabled? && JwtHelper.use_for_request # if the signature is enabled + payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload + jwt_header = TrackHelper.config_manager.jwt_header; # get signature authorization header + # set it to the request with the Bearer prefix + req.add_field(jwt_header, "Bearer #{JwtHelper.encode({ payload: })}") end - JSON.parse(data) # convert the response body into the json format + req.body = payload.to_json # convert the payload object into the json format + res = http.request(req) # get the response + data = res.body # and take its body + rescue StandardError => e + raise(e.message) end - # save file from the url - def download_file(uristr) - uri = URI.parse(uristr) # parse the url string - http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server - http.open_timeout = 5 + JSON.parse(data) # convert the response body into the json format + end - DocumentHelper.verify_ssl(uristr, http) + # save file from the url + def self.download_file(uristr) + uri = URI.parse(uristr) # parse the url string + http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server + http.open_timeout = 5 - req = Net::HTTP::Get.new(uri) - res = http.request(req) # get the response + DocumentHelper.verify_ssl(uristr, http) - status_code = res.code - raise("Document editing service returned status: #{status_code}") if status_code != '200' # checking status code + req = Net::HTTP::Get.new(uri) + res = http.request(req) # get the response - data = res.body # and take its body + status_code = res.code + raise("Document editing service returned status: #{status_code}") if status_code != '200' # checking status code - raise('stream is null') if data.nil? + data = res.body # and take its body - data - end + raise('stream is null') if data.nil? - def save_file(data, path) - File.binwrite(path, data) - end + data + end + + def self.save_file(data, path) + File.binwrite(path, data) end end diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 9a8ae5cc3..20549a773 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -176,37 +176,35 @@ class Users ) ] - class << self - def all_users - @users - end + def self.all_users + @users + end - # get a user by id specified - def get_user(id) - @users.each do |user| - return user if user.id.eql?(id) - end - @users[0] + # get a user by id specified + def self.get_user(id) + @users.each do |user| + return user if user.id.eql?(id) end + @users[0] + end - # get a list of users with their names and emails for mentions - def get_users_for_mentions(id) - users_data = [] - @users.each do |user| - if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? - users_data.push({ name: user.name, email: user.email }) - end + # get a list of users with their names and emails for mentions + def self.get_users_for_mentions(id) + users_data = [] + @users.each do |user| + if !user.id.eql?(id) && !user.name.nil? && !user.email.nil? + users_data.push({ name: user.name, email: user.email }) end - users_data end + users_data + end - # get a list of users with their id, names and emails for protect - def get_users_for_protect(id) - users_data = [] - @users.each do |user| - users_data.push({ id: user.id, name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? - end - users_data + # get a list of users with their id, names and emails for protect + def self.get_users_for_protect(id) + users_data = [] + @users.each do |user| + users_data.push({ id: user.id, name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? end + users_data end end From 4577861f8b3537a5ce3e48b92195845fe8d4faa4 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:48:42 +0300 Subject: [PATCH 379/488] ruby: Layout/ClosingParenthesisIndentation correct --- web/documentserver-example/ruby/app/models/file_model.rb | 4 ++-- .../ruby/app/models/track_helper.rb | 8 ++++---- web/documentserver-example/ruby/app/models/users.rb | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index fb4fd5a1b..df823ea63 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -54,7 +54,7 @@ def file_uri_user DocumentHelper.get_file_uri( @file_name, false -) + ) end end @@ -260,7 +260,7 @@ def history i, "prev#{file_ext}", false -) + ) end end data_obj['version'] = i diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 2497a4c60..7f839f4e8 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -128,7 +128,7 @@ def self.process_save(raw_file_data, file_name, user_address) new_file_name = DocumentHelper.get_correct_name( File.basename(file_name, cur_ext) + download_ext, user_address -) + ) end end @@ -228,12 +228,12 @@ def self.process_force_save(file_data, file_name, user_address) DocumentHelper.get_correct_name( "#{File.basename(file_name, cur_ext)}-form#{download_ext}", user_address -) # get the correct file name if it already exists + ) # get the correct file name if it already exists else DocumentHelper.get_correct_name( "#{File.basename(file_name, cur_ext)}-form#{cur_ext}", user_address -) + ) end forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file else @@ -241,7 +241,7 @@ def self.process_force_save(file_data, file_name, user_address) file_name = DocumentHelper.get_correct_name( File.basename(file_name, cur_ext) + download_ext, user_address -) + ) end forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) if forcesave_path.eql?('') diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 20549a773..5847d6e04 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -123,7 +123,7 @@ class Users @descr_user_first, true, true -), + ), User.new( 'uid-2', 'Mark Pottato', @@ -141,7 +141,7 @@ class Users @descr_user_second, false, true -), + ), User.new( 'uid-3', 'Hamish Mitchell', @@ -159,7 +159,7 @@ class Users @descr_user_third, false, false -), + ), User.new( 'uid-0', nil, @@ -173,7 +173,7 @@ class Users @descr_user_null, false, false -) + ) ] def self.all_users From 066de3359d5d536e3f4a6ea2dcac069bdcf05b00 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:49:06 +0300 Subject: [PATCH 380/488] ruby: Layout/ExtraSpacing correct --- .../ruby/app/models/service_converter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index e58bcd3af..43c1d94d5 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -154,10 +154,10 @@ def self.get_response_data(json_data) file_type_element = file_result['fileType'] if file_url_element.nil? # and the file url doesn't exist - raise('Invalid answer format') # get ann error message + raise('Invalid answer format') # get ann error message end - response_uri = file_url_element # otherwise, get the file url + response_uri = file_url_element # otherwise, get the file url response_file_type = file_type_element # get the file type result_percent = 100 From 4ff7b6e543566fa8ee2a7ec518c96f8c620a924f Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:49:36 +0300 Subject: [PATCH 381/488] ruby: Layout/IndentationWidth correct --- .../ruby/app/models/file_model.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index df823ea63..4e3182214 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -284,12 +284,12 @@ def history # write key and url information about previous file version with optional direct url data( obj['previous'] = if enable_direct_url? == true - { # write key and url information about previous file version with optional directUrl - fileType: prev['fileType'], - key: prev['key'], - url: prev['url'], - directUrl: prev['directUrl'] - } + { # write key and url information about previous file version with optional directUrl + fileType: prev['fileType'], + key: prev['key'], + url: prev['url'], + directUrl: prev['directUrl'] + } else { fileType: prev['fileType'], From d613a0206859b128e4e689684378222eec0610fb Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:50:13 +0300 Subject: [PATCH 382/488] ruby: Layout/FirstHashElementLineBreak correct --- web/documentserver-example/ruby/app/models/file_model.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 4e3182214..ec34f18d6 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -149,7 +149,8 @@ def config referenceData: { instanceId: DocumentHelper.get_server_url(false), fileKey: unless @user.id.eql?('uid-0') - { fileName: @file_name, + { +fileName: @file_name, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json end } From d4b2bf95bc70fb898f2b12bf08e2e7690ad65013 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:50:33 +0300 Subject: [PATCH 383/488] ruby: Layout/LineContinuationSpacing correct --- web/documentserver-example/ruby/app/models/document_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 765eaafa4..12a9a94ed 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -220,8 +220,8 @@ def self.get_file_uri(file_name, for_document_server) def self.get_historypath_uri(file_name, version, file, is_server_url: true) # for redirection to my link user_host = is_server_url ? "&userAddress=#{cur_user_host_address(nil)}" : '' - "#{get_server_url(is_server_url)}/downloadhistory/?"\ - "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}"\ + "#{get_server_url(is_server_url)}/downloadhistory/?" \ + "fileName=#{ERB::Util.url_encode(file_name)}&ver=#{version}" \ "&file=#{ERB::Util.url_encode(file)}#{user_host}" end From 10e1848beb1418c5cfd08471e5a81d79989c6090 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:50:59 +0300 Subject: [PATCH 384/488] ruby: Style/AccessorGrouping correct --- .../ruby/app/models/document_helper.rb | 3 ++- .../ruby/app/models/file_model.rb | 9 ++++++- .../ruby/app/models/track_helper.rb | 3 ++- .../ruby/app/models/users.rb | 24 +++++++++---------- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 12a9a94ed..7f7311e64 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -25,7 +25,8 @@ class DocumentHelper @format_manager = FormatManager.new class << self - attr_reader :config_manager, :format_manager + attr_reader :config_manager + attr_reader :format_manager end @runtime_cache = {} diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index ec34f18d6..0400d5dd5 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -20,7 +20,14 @@ # Class for handling file-related operations and information. class FileModel - attr_accessor :file_name, :mode, :type, :user_ip, :lang, :user, :action_data, :direct_url + attr_accessor :file_name + attr_accessor :mode + attr_accessor :type + attr_accessor :user_ip + attr_accessor :lang + attr_accessor :user + attr_accessor :action_data + attr_accessor :direct_url attr_reader :config_manager # set file parameters diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 7f839f4e8..220d79072 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -27,7 +27,8 @@ class TrackHelper @proxy_manager = ProxyManager.new(config_manager: @config_manager) class << self - attr_reader :config_manager, :proxy_manager + attr_reader :config_manager + attr_reader :proxy_manager end @document_command_url = TrackHelper.config_manager.document_server_command_uri.to_s diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 5847d6e04..8a160e8b1 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -18,18 +18,18 @@ # Represents a user with various attributes class User - attr_accessor :id, - :name, - :email, - :group, - :review_groups, - :comment_groups, - :user_info_groups, - :favorite, - :denied_permissions, - :descriptions, - :templates, - :avatar + attr_accessor :id + attr_accessor :name + attr_accessor :email + attr_accessor :group + attr_accessor :review_groups + attr_accessor :comment_groups + attr_accessor :user_info_groups + attr_accessor :favorite + attr_accessor :denied_permissions + attr_accessor :descriptions + attr_accessor :templates + attr_accessor :avatar def initialize(id, name, From 97420e18cf7d326b865e40447fcd710365f0fee3 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:51:34 +0300 Subject: [PATCH 385/488] ruby: Style/AccessModifierDeclarations correct --- web/documentserver-example/ruby/app/format/format.rb | 5 ++--- web/documentserver-example/ruby/app/proxy/proxy.rb | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/format/format.rb b/web/documentserver-example/ruby/app/format/format.rb index 03f1a04e4..378cfb7e8 100644 --- a/web/documentserver-example/ruby/app/format/format.rb +++ b/web/documentserver-example/ruby/app/format/format.rb @@ -146,15 +146,14 @@ def all end end - private sig { returns(Pathname) } - def file + private def file directory.join('onlyoffice-docs-formats.json') end sig { returns(Pathname) } - def directory + private def directory current_directory = Pathname(T.must(__dir__)) directory = current_directory.join('..', '..', 'assets', 'document-formats') directory.cleanpath diff --git a/web/documentserver-example/ruby/app/proxy/proxy.rb b/web/documentserver-example/ruby/app/proxy/proxy.rb index 8fee7df38..1ddb1d1b7 100644 --- a/web/documentserver-example/ruby/app/proxy/proxy.rb +++ b/web/documentserver-example/ruby/app/proxy/proxy.rb @@ -37,10 +37,9 @@ def resolve_uri(uri) redirect_public_url(uri) end - private sig { params(uri: URI::Generic).returns(T::Boolean) } - def refer_public_url(uri) + private def refer_public_url(uri) public_uri = @config_manager.document_server_public_uri uri.scheme == public_uri.scheme && uri.host == public_uri.host && @@ -48,7 +47,7 @@ def refer_public_url(uri) end sig { params(uri: URI::Generic).returns(URI::Generic) } - def redirect_public_url(uri) + private def redirect_public_url(uri) private_uri = @config_manager.document_server_private_uri redirected_uri = uri redirected_uri.scheme = private_uri.scheme From 5148fd26013792f83f17e1f70be55e27a715320c Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:52:02 +0300 Subject: [PATCH 386/488] ruby: Layout/EmptyLines correct --- .../ruby/app/controllers/home_controller.rb | 2 -- web/documentserver-example/ruby/app/format/format.rb | 1 - web/documentserver-example/ruby/app/proxy/proxy.rb | 1 - 3 files changed, 4 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index b6d0ff158..6b8fb3635 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -242,11 +242,9 @@ def remove # if the file exists FileUtils.rm_f(storage_path) # delete it from the storage path - # if the history directory of this file exists FileUtils.rm_rf(hist_dir) # delete it - render(plain: '{"success":true}') # report that the operation is successful nil end diff --git a/web/documentserver-example/ruby/app/format/format.rb b/web/documentserver-example/ruby/app/format/format.rb index 378cfb7e8..cb242ca04 100644 --- a/web/documentserver-example/ruby/app/format/format.rb +++ b/web/documentserver-example/ruby/app/format/format.rb @@ -146,7 +146,6 @@ def all end end - sig { returns(Pathname) } private def file directory.join('onlyoffice-docs-formats.json') diff --git a/web/documentserver-example/ruby/app/proxy/proxy.rb b/web/documentserver-example/ruby/app/proxy/proxy.rb index 1ddb1d1b7..45f3fca62 100644 --- a/web/documentserver-example/ruby/app/proxy/proxy.rb +++ b/web/documentserver-example/ruby/app/proxy/proxy.rb @@ -37,7 +37,6 @@ def resolve_uri(uri) redirect_public_url(uri) end - sig { params(uri: URI::Generic).returns(T::Boolean) } private def refer_public_url(uri) public_uri = @config_manager.document_server_public_uri From e0ed22d1f58e7ccf414c907e473bc8dc3ae86c54 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:52:31 +0300 Subject: [PATCH 387/488] ruby: Layout/FirstArgumentIndentation correct --- .../ruby/app/controllers/home_controller.rb | 16 +++++------ .../ruby/app/models/file_model.rb | 28 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 6b8fb3635..5369ecff9 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -488,18 +488,18 @@ def restore FileUtils.cp(recovery_file, source_file) render( -json: { - error: nil, - success: true -} + json: { + error: nil, + success: true + } ) rescue StandardError => e response.status = :internal_server_error render( -json: { - error: e.message, - success: false -} + json: { + error: e.message, + success: false + } ) end end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 0400d5dd5..abbe058db 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -291,20 +291,20 @@ def history prev = hist_data[(i - 2).to_s] # get the history data from the previous file version # write key and url information about previous file version with optional direct url data( -obj['previous'] = if enable_direct_url? == true - { # write key and url information about previous file version with optional directUrl - fileType: prev['fileType'], - key: prev['key'], - url: prev['url'], - directUrl: prev['directUrl'] - } - else - { - fileType: prev['fileType'], - key: prev['key'], - url: prev['url'] - } - end + obj['previous'] = if enable_direct_url? == true + { # write key and url information about previous file version with optional directUrl + fileType: prev['fileType'], + key: prev['key'], + url: prev['url'], + directUrl: prev['directUrl'] + } + else + { + fileType: prev['fileType'], + key: prev['key'], + url: prev['url'] + } + end ) # write the path to the diff.zip archive with differences in this file version From 4ea23d16778ed97b96f757fc3738b983b078968e Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:54:00 +0300 Subject: [PATCH 388/488] ruby: Style/Lambda correct --- web/documentserver-example/ruby/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/Gemfile b/web/documentserver-example/ruby/Gemfile index 01162d9aa..26eb9a681 100644 --- a/web/documentserver-example/ruby/Gemfile +++ b/web/documentserver-example/ruby/Gemfile @@ -29,7 +29,7 @@ gem 'webrick', '~> 1.8' # # https://github.com/sorbet/sorbet/issues/4011 # https://github.com/sorbet/sorbet/issues/4119 -install_if -> { RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /x86_64/ } do +install_if lambda { RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /x86_64/ } do gem 'sorbet', '~> 0.5.10871', group: :development gem 'tapioca', '~> 0.11.6', group: :development end From 10b40423ad5e8cd3ecf49ea1c9cc106abdb6e690 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:54:30 +0300 Subject: [PATCH 389/488] ruby: Layout/CommentIndentation correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 5369ecff9..f7fdc4f6d 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -239,10 +239,10 @@ def remove storage_path = DocumentHelper.storage_path(file_name, nil) hist_dir = DocumentHelper.history_dir(storage_path) - # if the file exists + # if the file exists FileUtils.rm_f(storage_path) # delete it from the storage path - # if the history directory of this file exists + # if the history directory of this file exists FileUtils.rm_rf(hist_dir) # delete it render(plain: '{"success":true}') # report that the operation is successful From a69f7f343ac497eb4277cd39dbd30a33e73a3229 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:54:56 +0300 Subject: [PATCH 390/488] ruby: Layout/HashAlignment correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- web/documentserver-example/ruby/app/models/users.rb | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index f7fdc4f6d..45e07a53e 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -490,7 +490,7 @@ def restore render( json: { error: nil, - success: true + success: true } ) rescue StandardError => e @@ -498,7 +498,7 @@ def restore render( json: { error: e.message, - success: false + success: false } ) end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index abbe058db..32e7d8569 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -158,7 +158,7 @@ def config fileKey: unless @user.id.eql?('uid-0') { fileName: @file_name, - userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json +userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json end } }, diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 8a160e8b1..4878c1137 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -132,8 +132,8 @@ class Users ['group-2', ''], { view: '', - edit: ['group-2', ''], - remove: ['group-2'] + edit: ['group-2', ''], + remove: ['group-2'] }, ['group-2', ''], true, @@ -150,8 +150,8 @@ class Users ['group-2'], { view: ['group-3', 'group-2'], - edit: ['group-2'], - remove: [] + edit: ['group-2'], + remove: [] }, ['group-2'], false, From d744bc2e2397e5bc0e7890384e4300851a5cca4f Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:55:19 +0300 Subject: [PATCH 391/488] ruby: Layout/ClosingParenthesisIndentation correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 45e07a53e..b9d5629e6 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -492,7 +492,7 @@ def restore error: nil, success: true } -) + ) rescue StandardError => e response.status = :internal_server_error render( @@ -500,6 +500,6 @@ def restore error: e.message, success: false } -) + ) end end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 32e7d8569..c55f7e38d 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -305,7 +305,7 @@ def history url: prev['url'] } end -) + ) # write the path to the diff.zip archive with differences in this file version data_obj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') From 716d4dc694434ae0f8adf551f65423e6a8e2c155 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:55:58 +0300 Subject: [PATCH 392/488] ruby: Layout/FirstHashElementIndentation correct --- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index c55f7e38d..895eeff95 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -157,7 +157,7 @@ def config instanceId: DocumentHelper.get_server_url(false), fileKey: unless @user.id.eql?('uid-0') { -fileName: @file_name, + fileName: @file_name, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json end } From 7197a216f8a95c30df9cea837e645d44229664fa Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:56:29 +0300 Subject: [PATCH 393/488] ruby: Layout/ParameterAlignment correct --- .../ruby/app/models/users.rb | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 4878c1137..116e5d447 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -32,17 +32,17 @@ class User attr_accessor :avatar def initialize(id, -name, -email, -group, -review_groups, -comment_groups, -user_info_groups, -favorite, + name, + email, + group, + review_groups, + comment_groups, + user_info_groups, + favorite, denied_permissions, -descriptions, -templates, -avatar) + descriptions, + templates, + avatar) @id = id @name = name @email = email From 0d3ed49adfc0096d7f20cebcceef5f1886439975 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:57:33 +0300 Subject: [PATCH 394/488] ruby: Layout/MultilineOperationIndentation correct --- web/documentserver-example/ruby/app/proxy/proxy.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/proxy/proxy.rb b/web/documentserver-example/ruby/app/proxy/proxy.rb index 45f3fca62..2e1a7a906 100644 --- a/web/documentserver-example/ruby/app/proxy/proxy.rb +++ b/web/documentserver-example/ruby/app/proxy/proxy.rb @@ -41,8 +41,8 @@ def resolve_uri(uri) private def refer_public_url(uri) public_uri = @config_manager.document_server_public_uri uri.scheme == public_uri.scheme && - uri.host == public_uri.host && - uri.port == public_uri.port + uri.host == public_uri.host && + uri.port == public_uri.port end sig { params(uri: URI::Generic).returns(URI::Generic) } From 63ec4db0b38c5c28a5eca9fed67163d9906cb10a Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 12:58:23 +0300 Subject: [PATCH 395/488] ruby: Lint/AmbiguousOperatorPrecedence correct --- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 895eeff95..f053b21d9 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -101,7 +101,7 @@ def cur_user_host_address def config editors_mode = @mode || 'edit' # mode: view/edit/review/comment/fillForms/embedded can_edit = DocumentHelper.edited_exts.include?(file_ext) # check if the document can be edited - if (!can_edit && editors_mode.eql?('edit') || editors_mode.eql?('fillForms')) && + if ((!can_edit && editors_mode.eql?('edit')) || editors_mode.eql?('fillForms')) && DocumentHelper.fill_forms_exts.include?(file_ext) editors_mode = 'fillForms' can_edit = true From 5fd2878c3d9c9771bfbacf95a64dd7eccb39d729 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:00:04 +0300 Subject: [PATCH 396/488] ruby: Layout/FirstHashElementIndentation correct --- web/documentserver-example/ruby/app/models/file_model.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index f053b21d9..b4d432827 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -156,9 +156,10 @@ def config referenceData: { instanceId: DocumentHelper.get_server_url(false), fileKey: unless @user.id.eql?('uid-0') - { + { fileName: @file_name, -userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json + userAddress: DocumentHelper.cur_user_host_address(nil) + }.to_json end } }, From 1e66124a8af848beaf65d704f98c6649633a0978 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:01:15 +0300 Subject: [PATCH 397/488] ruby: ElseAlignment correct --- .../ruby/app/models/file_model.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index b4d432827..948185aae 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -299,12 +299,12 @@ def history url: prev['url'], directUrl: prev['directUrl'] } - else - { - fileType: prev['fileType'], - key: prev['key'], - url: prev['url'] - } + else + { + fileType: prev['fileType'], + key: prev['key'], + url: prev['url'] + } end ) From d51dab82c59b10c7b9098939c66b33512456f008 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:01:55 +0300 Subject: [PATCH 398/488] ruby: Layout/EndAlignment correct --- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 948185aae..904390f22 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -305,7 +305,7 @@ def history key: prev['key'], url: prev['url'] } - end + end ) # write the path to the diff.zip archive with differences in this file version From 4c9c79ae8e02e077fc991f7b847c6f068abad5f6 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:02:20 +0300 Subject: [PATCH 399/488] ruby: Layout/EmptyLinesAroundClassBody correct --- web/documentserver-example/ruby/app/models/file_utility.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/file_utility.rb b/web/documentserver-example/ruby/app/models/file_utility.rb index e521aa22f..e9e09e6db 100644 --- a/web/documentserver-example/ruby/app/models/file_utility.rb +++ b/web/documentserver-example/ruby/app/models/file_utility.rb @@ -24,7 +24,6 @@ class FileUtility class << self attr_reader :format_manager - end def self.get_file_type(file_name) From e94d81e228eec611e3817f7fbf73ffa52e52e1ee Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:04:00 +0300 Subject: [PATCH 400/488] ruby: Layout/FirstMethodParameterLineBreak correct --- .../ruby/app/models/users.rb | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 116e5d447..560153786 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -31,18 +31,20 @@ class User attr_accessor :templates attr_accessor :avatar - def initialize(id, - name, - email, - group, - review_groups, - comment_groups, - user_info_groups, - favorite, - denied_permissions, - descriptions, - templates, - avatar) + def initialize( + id, + name, + email, + group, + review_groups, + comment_groups, + user_info_groups, + favorite, + denied_permissions, + descriptions, + templates, + avatar + ) @id = id @name = name @email = email From 0c2a2713576cb8efa5b23bfdbf7a495c899cb97f Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:11:01 +0300 Subject: [PATCH 401/488] ruby: added rubocop configuration file --- web/documentserver-example/ruby/.rubocop.yml | 161 +++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 web/documentserver-example/ruby/.rubocop.yml diff --git a/web/documentserver-example/ruby/.rubocop.yml b/web/documentserver-example/ruby/.rubocop.yml new file mode 100644 index 000000000..f2e7b4c9b --- /dev/null +++ b/web/documentserver-example/ruby/.rubocop.yml @@ -0,0 +1,161 @@ +AllCops: + NewCops: enable + +# Bundler + +Bundler/GemVersion: + Enabled: true + EnforcedStyle: required + +# Layout + +Layout/EmptyComment: + Enabled: true + AllowBorderComment: false + AllowMarginComment: true + +Layout/EmptyLineAfterGuardClause: + Enabled: false + +Layout/EndOfLine: + Enabled: true + EnforcedStyle: lf + +Layout/FirstArrayElementLineBreak: + Enabled: true + AllowMultilineFinalElement: false + +Layout/FirstHashElementLineBreak: + Enabled: true + AllowMultilineFinalElement: false + +Layout/FirstMethodArgumentLineBreak: + Enabled: true + AllowMultilineFinalElement: false + +Layout/FirstMethodParameterLineBreak: + Enabled: true + AllowMultilineFinalElement: false + +Layout/LineLength: + Enabled: true + Max: 120 + +Layout/MultilineArrayLineBreaks: + Enabled: true + AllowMultilineFinalElement: false + +Layout/MultilineAssignmentLayout: + Enabled: true + EnforcedStyle: new_line + SupportedTypes: [] + +Layout/MultilineHashKeyLineBreaks: + Enabled: true + AllowMultilineFinalElement: false + +Layout/MultilineMethodArgumentLineBreaks: + Enabled: true + AllowMultilineFinalElement: false + +Layout/MultilineMethodParameterLineBreaks: + Enabled: true + AllowMultilineFinalElement: false + +Layout/SingleLineBlockChain: + Enabled: true + +# Lint + +Lint/NumberConversion: + Enabled: true + +Lint/DuplicateBranch: + Enabled: false + +# Metrics + +Metrics: + Enabled: false + +# Naming + +Naming/InclusiveLanguage: + Enabled: true + +# Style + +Style/AccessModifierDeclarations: + Enabled: true + EnforcedStyle: inline + +Style/AccessorGrouping: + Enabled: true + EnforcedStyle: separated + +Style/ArrayCoercion: + Enabled: true + +Style/ClassAndModuleChildren: + Enabled: true + EnforcedStyle: compact + +Style/ClassMethodsDefinitions: + Enabled: true + +Style/CollectionMethods: + Enabled: true + +Style/DateTime: + Enabled: true + +Style/EndlessMethod: + Enabled: true + EnforcedStyle: disallow + +Style/FrozenStringLiteralComment: + Enabled: true + EnforcedStyle: always + Exclude: + - "Gemfile" + +Style/IfUnlessModifier: + Enabled: false + +Style/Lambda: + Enabled: true + EnforcedStyle: lambda + +Style/MethodCallWithArgsParentheses: + Enabled: true + AllowedMethods: [] + AllowedPatterns: [] + +Style/MethodCalledOnDoEndBlock: + Enabled: true + +Style/MissingElse: + Enabled: true + EnforcedStyle: case + +Style/MultipleComparison: + Enabled: false + +Style/NumberedParameters: + Enabled: true + EnforcedStyle: disallow + +Style/ParenthesesAroundCondition: + Enabled: true + AllowInMultilineConditions: true + +Style/StringHashKeys: + Enabled: true + +Style/SymbolArray: + Enabled: true + EnforcedStyle: brackets + +Style/WordArray: + Enabled: true + EnforcedStyle: brackets From 40d1c0c03b031c07b9066645008a88dc3fce6de4 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 21 Nov 2023 14:20:35 +0700 Subject: [PATCH 402/488] python: getting storage path to file uri from config manager --- web/documentserver-example/python/manage.py | 1 - web/documentserver-example/python/src/utils/docManager.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/web/documentserver-example/python/manage.py b/web/documentserver-example/python/manage.py index 1cdf8f969..af8c700d6 100644 --- a/web/documentserver-example/python/manage.py +++ b/web/documentserver-example/python/manage.py @@ -51,7 +51,6 @@ def configuration(): 'SECRET_KEY': uuid1(), 'STATIC_ROOT': f'{static_root}', 'STATIC_URL': static_url, - 'STORAGE_FOLDER': '/storage/', 'TEMPLATES': [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 680d111f1..28dd1f68b 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -26,7 +26,6 @@ import requests import magic -from django.conf import settings from django.http import FileResponse from src.configuration import ConfigurationManager from src.format import FormatManager @@ -112,7 +111,7 @@ def getServerUrl(forDocumentServer, req): def getFileUri(filename, forDocumentServer, req): host = getServerUrl(forDocumentServer, req) curAdr = req.META['REMOTE_ADDR'] - return f'{host}{settings.STORAGE_FOLDER}{curAdr}/{filename}' + return f'{host}{config_manager.storage_path}{curAdr}/{filename}' # get absolute URL to the document storage service From 9389607aaf66bf8cd34db25084b6920b51af450d Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 21 Nov 2023 15:39:31 +0700 Subject: [PATCH 403/488] python: flake8 configuration file --- .github/workflows/lint-python.yml | 3 +-- web/documentserver-example/python/.flake8 | 4 ++++ web/documentserver-example/python/Makefile | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 web/documentserver-example/python/.flake8 diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 756d0e89a..936407a3c 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -31,5 +31,4 @@ jobs: - name: Lint Flake8 run: | - flake8 --count --select=E9,F63,F7,F82 --show-source --statistics - flake8 --count --max-complexity=15 --max-line-length=120 --per-file-ignores="__init__.py:F4" --statistics + flake8 --count --show-source --statistics diff --git a/web/documentserver-example/python/.flake8 b/web/documentserver-example/python/.flake8 new file mode 100644 index 000000000..39193f07e --- /dev/null +++ b/web/documentserver-example/python/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-complexity = 15 +max-line-length = 120 +per-file-ignores = __init__.py:F4 \ No newline at end of file diff --git a/web/documentserver-example/python/Makefile b/web/documentserver-example/python/Makefile index 03a9c75df..21a227f0c 100644 --- a/web/documentserver-example/python/Makefile +++ b/web/documentserver-example/python/Makefile @@ -47,8 +47,7 @@ compose-prod: # Up containers in a production environment. .PHONY: lint lint: # Lint the source code for style and check for types. - @flake8 - @mypy . + @flake8 --count --show-source --statistics .PHONY: test test: # Recursively run the tests. From 2e69ba0d3fd4af75789d0edf5146379fdd3adc74 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 21 Nov 2023 12:58:17 +0300 Subject: [PATCH 404/488] python: fix lint --- web/documentserver-example/python/src/utils/trackManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/python/src/utils/trackManager.py b/web/documentserver-example/python/src/utils/trackManager.py index 6a6e12ddd..e218f73a1 100755 --- a/web/documentserver-example/python/src/utils/trackManager.py +++ b/web/documentserver-example/python/src/utils/trackManager.py @@ -170,10 +170,10 @@ def processForceSave(body, filename, usAddr): data_name = docManager.getCorrectName(fileUtils.getFileNameWithoutExt(filename) + ".txt", usAddr) data_path = docManager.getStoragePath(data_name, usAddr) - forms_data = docManager.downloadFileFromUri(forms_data_url); + forms_data = docManager.downloadFileFromUri(forms_data_url) if data is None: - raise Exception("Document editing service didn't return forms_data"); + raise Exception("Document editing service didn't return forms_data") else: with open(data_path, 'w') as file: file.write(forms_data.text) From 7ecbc6d458d24771a99bad8f2a6d867b0925f0d3 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 9 Nov 2023 09:55:15 +0300 Subject: [PATCH 405/488] csharp: replace the previous implementation of formats --- .../csharp/Default.aspx.cs | 56 +++---------------- .../csharp/OnlineEditorsExample.csproj | 29 ++++++---- .../csharp/settings.config | 4 -- 3 files changed, 26 insertions(+), 63 deletions(-) diff --git a/web/documentserver-example/csharp/Default.aspx.cs b/web/documentserver-example/csharp/Default.aspx.cs index eabac5f88..3602303c4 100644 --- a/web/documentserver-example/csharp/Default.aspx.cs +++ b/web/documentserver-example/csharp/Default.aspx.cs @@ -30,46 +30,6 @@ namespace OnlineEditorsExample { - internal static class FileType - { - // the spreadsheet extension list - public static readonly List ExtsSpreadsheet = new List - { - ".xls", ".xlsx", ".xlsm", ".xlsb", - ".xlt", ".xltx", ".xltm", - ".ods", ".fods", ".ots", ".csv" - }; - - // the presentation extension list - public static readonly List ExtsPresentation = new List - { - ".pps", ".ppsx", ".ppsm", - ".ppt", ".pptx", ".pptm", - ".pot", ".potx", ".potm", - ".odp", ".fodp", ".otp" - }; - - // the document extension list - public static readonly List ExtsDocument = new List - { - ".doc", ".docx", ".docm", - ".dot", ".dotx", ".dotm", - ".odt", ".fodt", ".ott", ".rtf", ".txt", - ".html", ".htm", ".mht", ".xml", - ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform" - }; - - // get an internal file extension - public static string GetInternalExtension(string extension) - { - extension = Path.GetExtension(extension).ToLower(); // get file extension - if (ExtsDocument.Contains(extension)) return ".docx"; // .docx for text document extensions - if (ExtsSpreadsheet.Contains(extension)) return ".xlsx"; // .xlsx for spreadsheet extensions - if (ExtsPresentation.Contains(extension)) return ".pptx"; // .pptx for presentation extensions - return string.Empty; - } - } - public partial class _Default : Page { @@ -115,24 +75,24 @@ private static List FileExts // file extensions that can be viewed private static List ViewedExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.viewed-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.ViewableExtensions(); } } - + public static List FillFormsExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.fillform-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.FillableExtensions(); } } // file extensions that can be edited public static List EditedExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.edited-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.EditableExtensions(); } } // file extensions that can be converted public static List ConvertExts { - get { return (WebConfigurationManager.AppSettings["files.docservice.convert-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } + get { return FormatManager.ConvertibleExtensions(); } } private static string _fileName; @@ -284,9 +244,9 @@ public static string DocumentType(string fileName) { var ext = Path.GetExtension(fileName).ToLower(); - if (FileType.ExtsDocument.Contains(ext)) return "word"; // word for text document extensions - if (FileType.ExtsSpreadsheet.Contains(ext)) return "cell"; // cell for spreadsheet extensions - if (FileType.ExtsPresentation.Contains(ext)) return "slide"; // slide for presentation extensions + if (FormatManager.DocumentExtensions().Contains(ext)) return "word"; // word for text document extensions + if (FormatManager.SpreadsheetExtensions().Contains(ext)) return "cell"; // cell for spreadsheet extensions + if (FormatManager.PresentationExtensions().Contains(ext)) return "slide"; // slide for presentation extensions return "word"; // the default document type is word } diff --git a/web/documentserver-example/csharp/OnlineEditorsExample.csproj b/web/documentserver-example/csharp/OnlineEditorsExample.csproj index 660be8620..2206a4696 100644 --- a/web/documentserver-example/csharp/OnlineEditorsExample.csproj +++ b/web/documentserver-example/csharp/OnlineEditorsExample.csproj @@ -119,6 +119,7 @@ DocEditor.aspx + @@ -157,17 +158,23 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/web/documentserver-example/csharp/settings.config b/web/documentserver-example/csharp/settings.config index a827d70ff..8715147e8 100644 --- a/web/documentserver-example/csharp/settings.config +++ b/web/documentserver-example/csharp/settings.config @@ -7,10 +7,6 @@ - - - - From c2466ddebe4bd1073a3ffeb47930e50a529bfa94 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 21 Nov 2023 14:20:37 +0300 Subject: [PATCH 406/488] csharp: added format caching --- .../csharp/FormatManager.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/csharp/FormatManager.cs b/web/documentserver-example/csharp/FormatManager.cs index 37d2df5c6..f5eba7c28 100644 --- a/web/documentserver-example/csharp/FormatManager.cs +++ b/web/documentserver-example/csharp/FormatManager.cs @@ -50,6 +50,8 @@ public string Extension() public class FormatManager { + private static List cachedFormats; + public static List FillableExtensions() { return Fillable() @@ -159,11 +161,15 @@ public static List AllExtensions() public static List All() { - var path = GetPath(); - var lines = File.ReadLines(path, Encoding.UTF8); - var contents = string.Join(Environment.NewLine, lines); - var formats = JsonConvert.DeserializeObject(contents); - return formats.ToList(); + if (cachedFormats == null) { + var path = GetPath(); + var lines = File.ReadLines(path, Encoding.UTF8); + var contents = string.Join(Environment.NewLine, lines); + var formats = JsonConvert.DeserializeObject(contents); + cachedFormats = formats.ToList(); + } + + return cachedFormats; } private static string GetPath() From 4d49e541290f2ee4d2ddacccc0d8fad4ca29b3be Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 21 Nov 2023 15:19:24 +0300 Subject: [PATCH 407/488] csharp-mvc: added format caching --- .../csharp-mvc/Models/FileUtility.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs index b2de3abac..11b214b11 100644 --- a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs @@ -73,6 +73,7 @@ public string Extension() public static class FormatManager { + private static List cachedFormats; public static List FillableExtensions() { return Fillable() @@ -182,11 +183,16 @@ public static List AllExtensions() public static List All() { - var path = GetPath(); - var lines = File.ReadLines(path, Encoding.UTF8); - var contents = string.Join(Environment.NewLine, lines); - var formats = JsonConvert.DeserializeObject(contents); - return formats.ToList(); + if (cachedFormats == null) + { + var path = GetPath(); + var lines = File.ReadLines(path, Encoding.UTF8); + var contents = string.Join(Environment.NewLine, lines); + var formats = JsonConvert.DeserializeObject(contents); + cachedFormats = formats.ToList(); + } + + return cachedFormats; } private static string GetPath() From 38aae731ba65e1ce9313cdd05737e5f758fd2ad6 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 21 Nov 2023 15:54:33 +0300 Subject: [PATCH 408/488] reorder modules --- .gitmodules | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitmodules b/.gitmodules index 04bd88a9b..10509447e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,6 +10,13 @@ path = web/documentserver-example/nodejs/public/assets/document-formats url = https://github.com/ONLYOFFICE/document-formats branch = master +[submodule "web/documentserver-example/csharp-mvc/assets/document-templates"] + path = web/documentserver-example/csharp-mvc/assets/document-templates + url = https://github.com/ONLYOFFICE/document-templates + branch = main/en +[submodule "web/documentserver-example/csharp-mvc/assets/document-formats"] + path = web/documentserver-example/csharp-mvc/assets/document-formats + url = https://github.com/ONLYOFFICE/document-formats [submodule "web/documentserver-example/php/assets/document-templates"] path = web/documentserver-example/php/assets/document-templates url = https://github.com/ONLYOFFICE/document-templates @@ -50,10 +57,3 @@ path = web/documentserver-example/java-spring/src/main/resources/assets/document-formats url = https://github.com/ONLYOFFICE/document-formats branch = master -[submodule "web/documentserver-example/csharp-mvc/assets/document-templates"] - path = web/documentserver-example/csharp-mvc/assets/document-templates - url = https://github.com/ONLYOFFICE/document-templates - branch = main/en -[submodule "web/documentserver-example/csharp-mvc/assets/document-formats"] - path = web/documentserver-example/csharp-mvc/assets/document-formats - url = https://github.com/ONLYOFFICE/document-formats From 8a2fc218d475f2b89c11ef1a6bda8aaaa0363d60 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 21 Nov 2023 15:59:08 +0300 Subject: [PATCH 409/488] repo with formats to changelog --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17a48a314..b626a8dbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- using a repo with a list of formats - php: link in referenceData - ruby: link in referenceData - java: link in referenceData @@ -19,11 +20,7 @@ - onRequestSelectSpreadsheet method - key in referenceData - restore from history -- python: using a repo with a list of formats -- ruby: using a repo with a list of formats -- java: using a repo with a list of formats - java: getting history by a separate request -- java-spring: using a repo with a list of formats - java-spring: getting history by a separate request ## 1.7.0 From 293bc9b5b0bcee9529a0422f7a783e9fad4f2753 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 21 Nov 2023 16:06:03 +0300 Subject: [PATCH 410/488] link in referenceData in changelog --- CHANGELOG.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b626a8dbb..609fbca9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,7 @@ # Change Log +- link in referenceData - using a repo with a list of formats -- php: link in referenceData -- ruby: link in referenceData -- java: link in referenceData -- java-spring: link in referenceData -- csharp-mvc: link in referenceData -- csharp: link in referenceData -- python: link in referenceData - ruby: convert after uploading only tagged formats - python: convert after uploading only tagged formats - php: convert after uploading only tagged formats @@ -15,7 +9,6 @@ - onRequestOpen method - user avatar - trimming long name of uploading file -- nodejs: link in referenceData - onRequestSelectDocument method - onRequestSelectSpreadsheet method - key in referenceData From f32f90282c081985954d4a4a684b7dc25e7a51e1 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 22 Nov 2023 11:42:05 +0300 Subject: [PATCH 411/488] nodejs: fix status check --- web/documentserver-example/nodejs/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 647dfcb6b..05793760f 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -774,7 +774,7 @@ app.post('/track', async (req, res) => { // define a handler for tracking file c const formsdata = await urllib.request(formsdataurl, { method: 'GET' }); const statusFormsdata = formsdata.status; const dataFormsdata = formsdata.data; - if (status === 200) { + if (statusFormsdata === 200) { fileSystem.writeFileSync(formsdataPath, dataFormsdata); // write the forms data } else { emitWarning(`Document editing service returned status: ${statusFormsdata}`); From c06b73404504946465bd6e0bf16b75a458562e53 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 22 Nov 2023 11:45:02 +0300 Subject: [PATCH 412/488] python: fix forms_data variable --- web/documentserver-example/python/src/utils/trackManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/python/src/utils/trackManager.py b/web/documentserver-example/python/src/utils/trackManager.py index e218f73a1..fdbdfb513 100755 --- a/web/documentserver-example/python/src/utils/trackManager.py +++ b/web/documentserver-example/python/src/utils/trackManager.py @@ -172,7 +172,7 @@ def processForceSave(body, filename, usAddr): forms_data = docManager.downloadFileFromUri(forms_data_url) - if data is None: + if forms_data is None: raise Exception("Document editing service didn't return forms_data") else: with open(data_path, 'w') as file: From 6578d414eaa888770c600913155a2f9c3043df4d Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 7 Nov 2023 08:40:12 +0300 Subject: [PATCH 413/488] php: fix opening history without changes --- web/documentserver-example/php/src/functions.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/php/src/functions.php b/web/documentserver-example/php/src/functions.php index 25912d68c..43e21ad91 100644 --- a/web/documentserver-example/php/src/functions.php +++ b/web/documentserver-example/php/src/functions.php @@ -950,8 +950,11 @@ function getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl) "url" => $prev["url"], ]; - // write the path to the diff.zip archive with differences in this file version - $dataObj["changesUrl"] = getHistoryDownloadUrl($filename, $i - 1, "diff.zip"); + $diffPath = implode(DIRECTORY_SEPARATOR, [$histDir, ($i - 1), "diff.zip"]); + if (file_exists($diffPath)) { + // write the path to the diff.zip archive with differences in this file version + $dataObj["changesUrl"] = getHistoryDownloadUrl($filename, $i - 1, "diff.zip"); + } } $jwtManager = new JwtManager(); From ad4b2d136c83a53f3bd3ebe070568e78aa2cebe0 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 7 Nov 2023 09:26:35 +0300 Subject: [PATCH 414/488] java-spring: fix opening history without changes --- .../history/DefaultHistoryManager.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/DefaultHistoryManager.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/DefaultHistoryManager.java index f640fc8da..2052ae051 100644 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/DefaultHistoryManager.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/documentserver/managers/history/DefaultHistoryManager.java @@ -40,6 +40,7 @@ import java.util.List; import java.util.Map; import java.util.Scanner; +import java.nio.file.Paths; // todo: Rebuild completely @Component @@ -280,8 +281,9 @@ public String getHistoryData(final String fileName, final String version, final dataObj.put("version", i); if (i > 1) { //check if the version number is greater than 1 + Integer verdiff = i - 1; // get the history data from the previous file version - Map prev = (Map) histData.get(Integer.toString(i - 1)); + Map prev = (Map) histData.get(Integer.toString(verdiff)); Map prevInfo = new HashMap(); prevInfo.put("fileType", prev.get("fileType")); prevInfo.put("key", prev.get("key")); // write key and URL information about previous file version @@ -292,10 +294,12 @@ public String getHistoryData(final String fileName, final String version, final // write information about previous file version to the data object dataObj.put("previous", prevInfo); - // write the path to the diff.zip archive with differences in this file version - Integer verdiff = i - 1; - dataObj.put("changesUrl", documentManager - .getHistoryFileUrl(fileName, verdiff, "diff.zip", true)); + + if (diffExists(histDir, verdiff)) { + // write the path to the diff.zip archive with differences in this file version + dataObj.put("changesUrl", documentManager + .getHistoryFileUrl(fileName, verdiff, "diff.zip", true)); + } } if (jwtManager.tokenEnabled()) { @@ -331,4 +335,11 @@ private String readFileToEnd(final File file) { } return output; } + + // diff.zip existence check + private Boolean diffExists(final String histDir, final Integer verdiff) { + String filePath = Paths.get(histDir, String.valueOf(verdiff), "diff.zip").toString(); + File file = new File(filePath); + return file.exists(); + } } From 4de6f4d8288266fa0fb57aa466a45a6bb99fdb15 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 27 Nov 2023 14:36:18 +0700 Subject: [PATCH 415/488] python: removing irrelevant changes --- web/documentserver-example/python/src/utils/docManager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 28dd1f68b..cbb698fd4 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -26,6 +26,7 @@ import requests import magic +from django.conf import settings from django.http import FileResponse from src.configuration import ConfigurationManager from src.format import FormatManager @@ -111,7 +112,7 @@ def getServerUrl(forDocumentServer, req): def getFileUri(filename, forDocumentServer, req): host = getServerUrl(forDocumentServer, req) curAdr = req.META['REMOTE_ADDR'] - return f'{host}{config_manager.storage_path}{curAdr}/{filename}' + return f'{host}{settings.STATIC_URL}{curAdr}/{filename}' # get absolute URL to the document storage service From b19abbcb3690958e1a32d16778bcd09bcc06b3d4 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 27 Nov 2023 10:44:17 +0300 Subject: [PATCH 416/488] csharp-mvc: convert after uploading only tagged formats --- CHANGELOG.md | 1 + web/documentserver-example/csharp-mvc/Models/FileUtility.cs | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 609fbca9b..8249c901c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp-mvc: convert after uploading only tagged formats - link in referenceData - using a repo with a list of formats - ruby: convert after uploading only tagged formats diff --git a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs index 11b214b11..99dbe9da8 100644 --- a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs @@ -126,9 +126,7 @@ public static List ConvertibleExtensions() public static List Convertible() { return All() - .Where(format => (format.Type == FileType.Cell && format.Convert.Contains("xlsx")) - || (format.Type == FileType.Slide && format.Convert.Contains("pptx")) - || (format.Type == FileType.Word && format.Convert.Contains("docx"))) + .Where(format => format.Actions.Contains("auto-convert")) .ToList(); } From 580f8f3e89406b15cab145233d07fdf31067dfd6 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 27 Nov 2023 10:45:29 +0300 Subject: [PATCH 417/488] csharp: convert after uploading only tagged formats --- CHANGELOG.md | 1 + web/documentserver-example/csharp/FormatManager.cs | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8249c901c..cb0cc9bbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- csharp: convert after uploading only tagged formats - csharp-mvc: convert after uploading only tagged formats - link in referenceData - using a repo with a list of formats diff --git a/web/documentserver-example/csharp/FormatManager.cs b/web/documentserver-example/csharp/FormatManager.cs index f5eba7c28..6039f0902 100644 --- a/web/documentserver-example/csharp/FormatManager.cs +++ b/web/documentserver-example/csharp/FormatManager.cs @@ -104,9 +104,7 @@ public static List ConvertibleExtensions() public static List Convertible() { return All() - .Where(format => (format.Type == "cell" && format.Convert.Contains("xlsx")) - || (format.Type == "slide" && format.Convert.Contains("pptx")) - || (format.Type == "word" && format.Convert.Contains("docx"))) + .Where(format => format.Actions.Contains("auto-convert")) .ToList(); } From b903bfc0cb233dabaf63483c5eca693ca98b8a3d Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 7 Nov 2023 11:02:41 +0300 Subject: [PATCH 418/488] java: fix opening history without changes --- .../main/java/controllers/IndexServlet.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index 970db3044..ef4b4a24e 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -968,9 +968,10 @@ private static void historyData(final HttpServletRequest request, dataObj.put("version", i); if (i > 1) { //check if the version number is greater than 1 + Integer verdiff = i - 1; // get the history data from the previous file version - Map prev = (Map) histData.get(Integer.toString(i - 1)); + Map prev = (Map) histData.get(Integer.toString(verdiff)); Map prevInfo = new HashMap(); prevInfo.put("fileType", prev.get("fileType")); @@ -983,12 +984,16 @@ private static void historyData(final HttpServletRequest request, // write information about previous file version to the data object dataObj.put("previous", prevInfo); - // write the path to the diff.zip archive with differences in this file version - Integer verdiff = i - 1; - String changesUrl = DocumentManager - .getDownloadHistoryUrl(fileName, verdiff, - "diff.zip", true); - dataObj.put("changesUrl", changesUrl); + + String diffPath = Paths.get(histDir, String.valueOf(verdiff), "diff.zip").toString(); + File diffFile = new File(diffPath); + if (diffFile.exists()) { + // write the path to the diff.zip archive with differences in this file version + String changesUrl = DocumentManager + .getDownloadHistoryUrl(fileName, verdiff, + "diff.zip", true); + dataObj.put("changesUrl", changesUrl); + } } if (DocumentManager.tokenEnabled()) { From 0b5b0d9c270545ebf4fe440097d7e6d01b6a1381 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 7 Nov 2023 13:39:37 +0300 Subject: [PATCH 419/488] python: fix opening history without changes --- .../python/src/utils/historyManager.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/python/src/utils/historyManager.py b/web/documentserver-example/python/src/utils/historyManager.py index a4838c198..9fb239e80 100644 --- a/web/documentserver-example/python/src/utils/historyManager.py +++ b/web/documentserver-example/python/src/utils/historyManager.py @@ -214,8 +214,11 @@ def getHistoryObject(storagePath, filename, docKey, docUrl, isEnableDirectUrl, r 'url': prev['url'] } dataObj['previous'] = prevInfo # write information about previous file version to the data object - # write the path to the diff.zip archive with differences in this file version - dataObj['changesUrl'] = getPublicHistUri(filename, i - 1, "diff.zip", req) + + diffPath = os.path.sep.join([histDir, str(i - 1), "diff.zip"]) + if (os.path.exists(diffPath)): + # write the path to the diff.zip archive with differences in this file version + dataObj['changesUrl'] = getPublicHistUri(filename, i - 1, "diff.zip", req) if jwtManager.isEnabled(): dataObj['token'] = jwtManager.encode(dataObj) From 160c0bef3c5521e82f78c44182d3ab8711ad8fb5 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Tue, 7 Nov 2023 22:30:33 +0300 Subject: [PATCH 420/488] ruby: fix opening history without changes --- web/documentserver-example/ruby/app/models/file_model.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 7c1129aef..dd3cd0d2e 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -266,8 +266,11 @@ def get_history :url => prev["url"] } - # write the path to the diff.zip archive with differences in this file version - dataObj["changesUrl"] = DocumentHelper.get_historypath_uri(file_name, i - 1, "diff.zip") + diff_path = [hist_dir, (i - 1).to_s, "diff.zip"].join(File::SEPARATOR) + if File.exist?(diff_path) + # write the path to the diff.zip archive with differences in this file version + dataObj["changesUrl"] = DocumentHelper.get_historypath_uri(file_name, i - 1, "diff.zip") + end end if JwtHelper.is_enabled # check if a secret key to generate token exists or not From 495d97bd3ad4d168f1c4995dc4f8f802ff16aee1 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Mon, 27 Nov 2023 11:35:23 +0300 Subject: [PATCH 421/488] - auto-convert in changelog --- CHANGELOG.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb0cc9bbd..566d777a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,8 @@ # Change Log -- csharp: convert after uploading only tagged formats -- csharp-mvc: convert after uploading only tagged formats -- link in referenceData - using a repo with a list of formats -- ruby: convert after uploading only tagged formats -- python: convert after uploading only tagged formats -- php: convert after uploading only tagged formats +- convert after uploading only tagged formats +- link in referenceData - setUsers for region protection - onRequestOpen method - user avatar From 8fd9113c47e5a3cf0433127a6368fbd97d7cad5c Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 27 Nov 2023 15:36:56 +0700 Subject: [PATCH 422/488] python: mypy in lint workflow --- .github/workflows/lint-python.yml | 4 +++- web/documentserver-example/python/Makefile | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 936407a3c..b69c874ca 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -27,8 +27,10 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 + pip install mypy + pip install django-stubs if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint Flake8 run: | - flake8 --count --show-source --statistics + make lint diff --git a/web/documentserver-example/python/Makefile b/web/documentserver-example/python/Makefile index 21a227f0c..a0d9b1326 100644 --- a/web/documentserver-example/python/Makefile +++ b/web/documentserver-example/python/Makefile @@ -48,6 +48,7 @@ compose-prod: # Up containers in a production environment. .PHONY: lint lint: # Lint the source code for style and check for types. @flake8 --count --show-source --statistics + @mypy . .PHONY: test test: # Recursively run the tests. From 969240ad53d62281ac99d05bddf66f54ccc846fb Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 27 Nov 2023 17:30:09 +0700 Subject: [PATCH 423/488] python: intalling dependencies by make in lint workflow --- .github/workflows/lint-python.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index b69c874ca..d4b959c83 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -26,10 +26,8 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip - pip install flake8 - pip install mypy - pip install django-stubs - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + make prod + make dev - name: Lint Flake8 run: | From d397db61cd1f5332bb35cd3fe07d5e949dc4766e Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 27 Nov 2023 17:36:21 +0700 Subject: [PATCH 424/488] python: lint workflow python version fix --- .github/workflows/lint-python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index d4b959c83..b19cf30ce 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -21,7 +21,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Install Dependencies run: | From 9d5feaaf99d511ac30762b4e0029f3d9f1283c4c Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 28 Nov 2023 13:49:12 +0700 Subject: [PATCH 425/488] python: flake8 and mypy separated --- .github/workflows/lint-python.yml | 5 +++++ web/documentserver-example/python/Makefile | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index b19cf30ce..13d9458a3 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -32,3 +32,8 @@ jobs: - name: Lint Flake8 run: | make lint + + # TODO: Configure mypy + # - name: Types mypy + # run: | + # make types diff --git a/web/documentserver-example/python/Makefile b/web/documentserver-example/python/Makefile index a0d9b1326..a4cc7a267 100644 --- a/web/documentserver-example/python/Makefile +++ b/web/documentserver-example/python/Makefile @@ -46,8 +46,11 @@ compose-prod: # Up containers in a production environment. up --detach .PHONY: lint -lint: # Lint the source code for style and check for types. +lint: # Lint the source code for style. @flake8 --count --show-source --statistics + +.PHONY: types +types: # Check the source code for types. @mypy . .PHONY: test From dac1cdcdc164cfafa89e9947aef1161ecaedbbb2 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 28 Nov 2023 10:08:01 +0300 Subject: [PATCH 426/488] format --- web/documentserver-example/php/src/views/DocEditorView.php | 2 +- web/documentserver-example/python/templates/editor.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/php/src/views/DocEditorView.php b/web/documentserver-example/php/src/views/DocEditorView.php index 890212c6f..92b734fe0 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -244,7 +244,7 @@ public function __construct($request, $tempName = "docEditor") // encode the dataSpreadsheet object into the token $dataSpreadsheet["token"] = $jwtManager->jwtEncode($dataSpreadsheet); } - + $historyLayout = ""; if ($user->id != "uid-0") { $historyLayout .= "// add mentions for not anonymous users diff --git a/web/documentserver-example/python/templates/editor.html b/web/documentserver-example/python/templates/editor.html index 9718272d9..5c4f45756 100755 --- a/web/documentserver-example/python/templates/editor.html +++ b/web/documentserver-example/python/templates/editor.html @@ -228,7 +228,7 @@ onRequestHistory() } } - + function onRequestHistory(){ const query = new URLSearchParams(window.location.search) data = { From d6d19812964c0084b96cb3cf80dab4a4b1483116 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Tue, 28 Nov 2023 10:11:09 +0300 Subject: [PATCH 427/488] getting history in changelog --- CHANGELOG.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e229e987e..1b648c405 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,6 @@ # Change Log -- php: getting history via api -- ruby: getting history via api -- python: getting history via api +- getting history via api - using a repo with a list of formats - convert after uploading only tagged formats - link in referenceData @@ -14,8 +12,6 @@ - onRequestSelectSpreadsheet method - key in referenceData - restore from history -- java: getting history by a separate request -- java-spring: getting history by a separate request ## 1.7.0 - nodejs: onRequestSelectDocument method From d40f932863e4f807ff9f5e36fbd8322a1aa04cc5 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 29 Nov 2023 10:11:43 +0700 Subject: [PATCH 428/488] python: deleted unnecessary lines from workflows --- .github/workflows/lint-python.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index 13d9458a3..4eb8d860a 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -25,8 +25,6 @@ jobs: - name: Install Dependencies run: | - python -m pip install --upgrade pip - make prod make dev - name: Lint Flake8 From 7c1939e8c92fe75ef9ae09cd3b2e4d0022286fd7 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:46:02 +0300 Subject: [PATCH 429/488] ruby: updated rubocop configuration file --- web/documentserver-example/ruby/.rubocop.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/documentserver-example/ruby/.rubocop.yml b/web/documentserver-example/ruby/.rubocop.yml index f2e7b4c9b..d640f95a7 100644 --- a/web/documentserver-example/ruby/.rubocop.yml +++ b/web/documentserver-example/ruby/.rubocop.yml @@ -1,3 +1,5 @@ +require: rubocop-rails + AllCops: NewCops: enable From 037c5682f8bd3266d0fac99b5bc8fc72074708f0 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:47:28 +0300 Subject: [PATCH 430/488] ruby: Rails/Blank correct --- .../ruby/app/controllers/home_controller.rb | 4 ++-- web/documentserver-example/ruby/app/models/track_helper.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index b9d5629e6..7e9e9c2dc 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -93,7 +93,7 @@ def upload # converting a file def convert file_data = request.body.read - return '' if file_data.nil? || file_data.empty? + return '' if file_data.blank? body = JSON.parse(file_data) @@ -194,7 +194,7 @@ def downloadhistory # tracking file changes def track file_data = TrackHelper.read_body(request) # read the request body - if file_data.nil? || file_data.empty? + if file_data.blank? render(plain: '{"error":1}') # an error occurs if the file is empty return end diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 220d79072..1d4bd38ec 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -37,7 +37,7 @@ class << self def self.read_body(request) body = request.body.read - return '' if body.nil? || body.empty? + return '' if body.blank? file_data = JSON.parse(body) # parse file data @@ -117,7 +117,7 @@ def self.process_save(raw_file_data, file_name, user_address) false, nil ) # get the url of the converted file - if new_file_uri.nil? || new_file_uri.empty? + if new_file_uri.blank? new_file_name = DocumentHelper.get_correct_name( File.basename(file_name, cur_ext) + download_ext, user_address @@ -205,7 +205,7 @@ def self.process_force_save(file_data, file_name, user_address) false, nil ) # get the url of the converted file - if new_file_uri.nil? || new_file_uri.empty? + if new_file_uri.blank? new_file_name = true else download_uri = new_file_uri From efb4616ca6e53b447c5e8fe96fca1bbaca7e4ab4 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:49:10 +0300 Subject: [PATCH 431/488] ruby: Rails/HttpStatus correct --- .../ruby/app/controllers/home_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 7e9e9c2dc..10f5a84e6 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -168,11 +168,11 @@ def downloadhistory hdr.slice!(0, 'Bearer '.length) token = JwtHelper.decode(hdr) if !token || token.eql?('') - render(plain: 'JWT validation failed', status: 403) + render(plain: 'JWT validation failed', status: :forbidden) return end else - render(plain: 'JWT validation failed', status: 403) + render(plain: 'JWT validation failed', status: :forbidden) return end end @@ -283,7 +283,7 @@ def download token = JwtHelper.decode(hdr) end if !token || token.eql?('') - render(plain: 'JWT validation failed', status: 403) + render(plain: 'JWT validation failed', status: :forbidden) return end end From 3d0ae07de4c31c2e23eef21708d8a8f5fcbe074b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:49:39 +0300 Subject: [PATCH 432/488] ruby: Rails/TimeZone correct --- .../ruby/app/controllers/home_controller.rb | 2 +- web/documentserver-example/ruby/app/models/document_helper.rb | 2 +- web/documentserver-example/ruby/app/models/file_model.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 10f5a84e6..d9bd5a882 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -472,7 +472,7 @@ def restore serverVersion: nil, changes: [ { - created: Time.now.to_formatted_s(:db), + created: Time.zone.now.to_formatted_s(:db), user: { id: user.id, name: user.name diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 7f7311e64..0ffd082c5 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -182,7 +182,7 @@ def self.create_meta(file_name, uid, uname, user_address) # write user name, user uid and the creation time to the json object json = { - created: Time.now.to_formatted_s(:db), + created: Time.zone.now.to_formatted_s(:db), uid:, uname: } diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 904390f22..eea69a110 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -134,7 +134,7 @@ def config key:, info: { owner: 'Me', - uploaded: Time.now.to_s, + uploaded: Time.zone.now.to_s, favorite: @user.favorite }, permissions: { # the permission for the document to be edited and downloaded or not From b262a34540c3c71c78d18c7501bf96181d090f33 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:50:22 +0300 Subject: [PATCH 433/488] ruby: Rails/ToFormattedS correct --- .../ruby/app/controllers/home_controller.rb | 2 +- web/documentserver-example/ruby/app/models/document_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index d9bd5a882..88208f22a 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -472,7 +472,7 @@ def restore serverVersion: nil, changes: [ { - created: Time.zone.now.to_formatted_s(:db), + created: Time.zone.now.to_fs(:db), user: { id: user.id, name: user.name diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index 0ffd082c5..f1bde2136 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -182,7 +182,7 @@ def self.create_meta(file_name, uid, uname, user_address) # write user name, user uid and the creation time to the json object json = { - created: Time.zone.now.to_formatted_s(:db), + created: Time.zone.now.to_fs(:db), uid:, uname: } From d894663a4a88af447d4105443090423bb144aeee Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:50:44 +0300 Subject: [PATCH 434/488] ruby: Rails/NegateInclude correct --- .../ruby/app/models/file_model.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index eea69a110..a8631b158 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -138,12 +138,12 @@ def config favorite: @user.favorite }, permissions: { # the permission for the document to be edited and downloaded or not - comment: !['view', 'fillForms', 'embedded', 'blockcontent'].include?(editors_mode), - copy: !@user.denied_permissions.include?('copy'), - download: !@user.denied_permissions.include?('download'), + comment: ['view', 'fillForms', 'embedded', 'blockcontent'].exclude?(editors_mode), + copy: @user.denied_permissions.exclude?('copy'), + download: @user.denied_permissions.exclude?('download'), edit: can_edit && ['edit', 'view', 'filter', 'blockcontent'].include?(editors_mode), - print: !@user.denied_permissions.include?('print'), - fillForms: !['view', 'comment', 'embedded', 'blockcontent'].include?(editors_mode), + print: @user.denied_permissions.exclude?('print'), + fillForms: ['view', 'comment', 'embedded', 'blockcontent'].exclude?(editors_mode), modifyFilter: !editors_mode.eql?('filter'), modifyContentControl: !editors_mode.eql?('blockcontent'), review: can_edit && (editors_mode.eql?('edit') || editors_mode.eql?('review')), @@ -151,7 +151,7 @@ def config reviewGroups: @user.review_groups, commentGroups: @user.comment_groups, userInfoGroups: @user.user_info_groups, - protect: !@user.denied_permissions.include?('protect') + protect: @user.denied_permissions.exclude?('protect') }, referenceData: { instanceId: DocumentHelper.get_server_url(false), From e5560b25d78ad336ea433b11630aad8435a23294 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 13:52:09 +0300 Subject: [PATCH 435/488] ruby: Rails/Present correct --- web/documentserver-example/ruby/app/models/jwt_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 92c580173..44293d6a2 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -26,7 +26,7 @@ class JwtHelper # check if a secret key to generate token exists or not def self.enabled? - @jwt_secret && !@jwt_secret.empty? ? true : false + @jwt_secret.present? end # check if a secret key used for request From af1dc6d9b5fe670bd5ac7f32e761a4261469ff66 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 30 Nov 2023 09:28:05 +0300 Subject: [PATCH 436/488] ruby: add rubocop-rails --- web/documentserver-example/ruby/Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/web/documentserver-example/ruby/Gemfile b/web/documentserver-example/ruby/Gemfile index 26eb9a681..1f2da09b5 100644 --- a/web/documentserver-example/ruby/Gemfile +++ b/web/documentserver-example/ruby/Gemfile @@ -12,6 +12,7 @@ gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dab gem 'rack-cors', '~> 2.0' gem 'rails', '~> 7.0.8' gem 'rubocop', '~> 1.52', group: :development +gem 'rubocop-rails', '~> 2.20', group: :development gem 'sass-rails', '~> 6.0' gem 'sdoc', '~> 2.6', group: :doc gem 'sorbet-runtime', '~> 0.5.10871' From 9cf058078c3654c6d24cddc7dcce1998788114a9 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 30 Nov 2023 14:05:57 +0300 Subject: [PATCH 437/488] ruby: fix lint problems after merging develop --- .../ruby/app/controllers/home_controller.rb | 46 +++++++------- .../ruby/app/models/file_model.rb | 18 +++++- .../ruby/app/models/track_helper.rb | 62 +++++++------------ 3 files changed, 61 insertions(+), 65 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 94c209e42..23b6cbe9c 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -154,27 +154,25 @@ def convert end def historyobj - begin - data = request.body.read - if data == nil || data.empty? - return "" - end - file_data = JSON.parse(data) - file = FileModel.new( - file_name: File.basename(file_data['file_name']), - mode: file_data['mode'], - type: file_data['type'], - user_ip: file_data['user_ip'], - lang: file_data['lang'], - user: file_data['user'], - action_data: file_data['action_data'], - direct_url: file_data['direct_url'] - ) - history = file.get_history - render json: history - rescue - render json: '{ "error": "File not found"}' + data = request.body.read + if data.blank? + return '' end + file_data = JSON.parse(data) + file = FileModel.new( + file_name: File.basename(file_data['file_name']), + mode: file_data['mode'], + type: file_data['type'], + user_ip: file_data['user_ip'], + lang: file_data['lang'], + user: file_data['user'], + action_data: file_data['action_data'], + direct_url: file_data['direct_url'] + ) + history = file.get_history + render(json: history) + rescue StandardError + render(json: '{ "error": "File not found"}') end # downloading a history file from public @@ -223,7 +221,7 @@ def track return end - status = Integer(file_data['status'], 10) + status = file_data['status'] user_address = params[:userAddress] file_name = File.basename(params[:fileName]) @@ -300,11 +298,11 @@ def assets response.headers['Content-Length'] = File.size(asset_path).to_s response.headers['Content-Type'] = MimeMagic.by_path(asset_path).type - response.headers['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + ERB::Util.url_encode(file_name) + response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}" - send_file asset_path, :x_sendfile => true + send_file(asset_path, x_sendfile: true) end - + # downloading a file def download file_name = File.basename(params[:fileName]) diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 3dcb4224c..2ec252b62 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -216,7 +216,7 @@ def history file_name = @file_name file_ext = File.extname(file_name).downcase doc_key = key - doc_uri = file_uri + file_uri # get the path to the file history hist_dir = DocumentHelper.history_dir(DocumentHelper.storage_path(@file_name, nil)) @@ -258,7 +258,19 @@ def history # get the history data from the previous file version and write key and url information about it data_obj['fileType'] = file_ext[1..file_ext.length] data_obj['key'] = cur_key - data_obj['url'] = i == cur_ver ? DocumentHelper.get_download_url(file_name, true) : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}") + data_obj['url'] = + if i == cur_ver + DocumentHelper.get_download_url( + file_name, + true + ) + else + DocumentHelper.get_historypath_uri( + file_name, + i, + "prev#{file_ext}" + ) + end if enable_direct_url? == true data_obj['directUrl'] = if i == cur_ver @@ -308,7 +320,7 @@ def history end ) - diff_path = [hist_dir, (i - 1).to_s, "diff.zip"].join(File::SEPARATOR) + diff_path = [hist_dir, (i - 1).to_s, 'diff.zip'].join(File::SEPARATOR) if File.exist?(diff_path) # write the path to the diff.zip archive with differences in this file version data_obj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 1bbb59d3f..b55c44683 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -236,44 +236,13 @@ def self.process_force_save(file_data, file_name, user_address) user_address ) end - forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file - else - if new_file_name - file_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + download_ext, user_address) - end - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) - if forcesave_path.eql?("") - forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, true) # if the path to the new file doesn't exist, create it - end - end - - save_file(data, forcesave_path) # save the downloaded file to the storage directory - - if is_submit_form - uid = file_data['actions'][0]['userid'] - DocumentHelper.create_meta(file_name, uid, "Filling Form", user_address) # create file meta information with the Filling form tag instead of user name - - forms_data_url = file_data["formsdataurl"].to_s - - if forms_data_url && !forms_data_url.eql?("") - forms_name = DocumentHelper.get_correct_name(File.basename(file_name, cur_ext) + ".txt", user_address) - forms_path = DocumentHelper.storage_path(forms_name, user_address) - forms = download_file(forms_data_url) - if forms.eql?(nil) - return saved - end - save_file(forms, forms_path) - else - raise 'Document editing service did not return formsDataUrl' - end - end - - saved = 0 - rescue StandardError => msg - saved = 1 - end - - saved + forcesave_path = DocumentHelper.storage_path(file_name, user_address) # get the path to the new file + else + if new_file_name + file_name = DocumentHelper.get_correct_name( + File.basename(file_name, cur_ext) + download_ext, + user_address + ) end forcesave_path = DocumentHelper.forcesave_path(file_name, user_address, false) if forcesave_path.eql?('') @@ -288,6 +257,23 @@ def self.process_force_save(file_data, file_name, user_address) uid = file_data['actions'][0]['userid'] # create file meta information with the Filling form tag instead of user name DocumentHelper.create_meta(file_name, uid, 'Filling Form', user_address) + + forms_data_url = file_data['formsdataurl'].to_s + + unless forms_data_url && !forms_data_url.eql?('') + raise('Document editing service did not return formsDataUrl') + end + forms_name = DocumentHelper.get_correct_name( + "#{File.basename(file_name, cur_ext)}.txt", + user_address + ) + forms_path = DocumentHelper.storage_path(forms_name, user_address) + forms = download_file(forms_data_url) + if forms.eql?(nil) + return saved + end + save_file(forms, forms_path) + end saved = 0 From 83b1dc07e1d4ae9f2e53a2d072ef8be083b936f2 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Thu, 30 Nov 2023 18:19:38 +0300 Subject: [PATCH 438/488] =?UTF-8?q?node:=20fixed=20overflow=20when=20hashi?= =?UTF-8?q?ng=20=D1=81yrillic=20characters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/documentserver-example/nodejs/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/documentserver-example/nodejs/app.js b/web/documentserver-example/nodejs/app.js index 05793760f..38810d33e 100755 --- a/web/documentserver-example/nodejs/app.js +++ b/web/documentserver-example/nodejs/app.js @@ -55,7 +55,7 @@ String.prototype.hashCode = function hashCode() { const len = this.length; let ret = 0; for (let i = 0; i < len; i++) { - ret = Math.trunc(31 * ret + this.charCodeAt(i)); + ret = Math.imul(ret, 31) + this.charCodeAt(i); } return ret; }; From 449ad0759ba452c2a1acd396c038406803fd5e3a Mon Sep 17 00:00:00 2001 From: Taygunova Rina Date: Fri, 1 Dec 2023 10:50:26 +0300 Subject: [PATCH 439/488] java-spring: add version index.html --- .../onlyoffice/integration/controllers/IndexController.java | 4 ++++ .../java-spring/src/main/resources/templates/index.html | 1 + 2 files changed, 5 insertions(+) diff --git a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/IndexController.java b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/IndexController.java index 1088ead79..e519e1091 100755 --- a/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/IndexController.java +++ b/web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/controllers/IndexController.java @@ -76,6 +76,9 @@ public class IndexController { @Value("${files.docservice.languages}") private String langs; + @Value("${server.version}") + private String serverVersion; + @GetMapping("${url.index}") public String index(@RequestParam(value = "directUrl", required = false) final Boolean directUrl, final Model model) { @@ -124,6 +127,7 @@ public String index(@RequestParam(value = "directUrl", required = false) final B model.addAttribute("users", users); model.addAttribute("languages", languages); model.addAttribute("directUrl", directUrl); + model.addAttribute("serverVersion", serverVersion); return "index.html"; } diff --git a/web/documentserver-example/java-spring/src/main/resources/templates/index.html b/web/documentserver-example/java-spring/src/main/resources/templates/index.html index 5c519273b..d2d333c93 100755 --- a/web/documentserver-example/java-spring/src/main/resources/templates/index.html +++ b/web/documentserver-example/java-spring/src/main/resources/templates/index.html @@ -3,6 +3,7 @@ +