diff --git a/.github/workflows/artifact-csharp-mvc.yml b/.github/workflows/artifact-csharp-mvc.yml index 05805cf49..c1f4337c1 100644 --- a/.github/workflows/artifact-csharp-mvc.yml +++ b/.github/workflows/artifact-csharp-mvc.yml @@ -3,10 +3,10 @@ name: Artifact Csharp MVC on: workflow_dispatch: push: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/csharp-mvc/**'] pull_request: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/csharp-mvc/**'] jobs: diff --git a/.github/workflows/artifact-csharp.yml b/.github/workflows/artifact-csharp.yml index bd08a90b4..ed83e6079 100644 --- a/.github/workflows/artifact-csharp.yml +++ b/.github/workflows/artifact-csharp.yml @@ -3,10 +3,10 @@ name: Artifact Csharp on: workflow_dispatch: push: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/csharp/**'] pull_request: - branches: [master, main, develop] + branches: [master] paths: ['web/documentserver-example/csharp/**'] jobs: diff --git a/.github/workflows/artifact-java.yml b/.github/workflows/artifact-java.yml index f026b5cf8..ab8fe55e2 100644 --- a/.github/workflows/artifact-java.yml +++ b/.github/workflows/artifact-java.yml @@ -3,10 +3,10 @@ name: Artifact Java on: workflow_dispatch: push: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/java/**'] pull_request: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/java/**'] jobs: diff --git a/.github/workflows/artifact-node.yml b/.github/workflows/artifact-node.yml index 1341c6297..d3e3eff7b 100644 --- a/.github/workflows/artifact-node.yml +++ b/.github/workflows/artifact-node.yml @@ -3,10 +3,10 @@ name: Artifact Nodejs on: workflow_dispatch: push: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/nodejs/**'] pull_request: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/nodejs/**'] jobs: diff --git a/.github/workflows/artifact-php.yml b/.github/workflows/artifact-php.yml index e3358fc15..0a75e6fef 100644 --- a/.github/workflows/artifact-php.yml +++ b/.github/workflows/artifact-php.yml @@ -3,10 +3,10 @@ name: Artifact PHP on: workflow_dispatch: push: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/php/**'] pull_request: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/php/**'] jobs: diff --git a/.github/workflows/artifact-python.yml b/.github/workflows/artifact-python.yml index 4591aeeb1..ad3318920 100644 --- a/.github/workflows/artifact-python.yml +++ b/.github/workflows/artifact-python.yml @@ -3,10 +3,10 @@ name: Artifact Python on: workflow_dispatch: push: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/python/**'] pull_request: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/python/**'] jobs: diff --git a/.github/workflows/artifact-ruby.yml b/.github/workflows/artifact-ruby.yml index 15fdc0fa6..407c4088f 100644 --- a/.github/workflows/artifact-ruby.yml +++ b/.github/workflows/artifact-ruby.yml @@ -3,10 +3,10 @@ name: Artifact Ruby on: workflow_dispatch: push: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/ruby/**'] pull_request: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/ruby/**'] jobs: diff --git a/.github/workflows/artifact-spring.yml b/.github/workflows/artifact-spring.yml index 0af691629..9d2be6c73 100644 --- a/.github/workflows/artifact-spring.yml +++ b/.github/workflows/artifact-spring.yml @@ -3,10 +3,10 @@ name: Artifact Java Spring on: workflow_dispatch: push: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/java-spring/**'] pull_request: - branches: [master, main] + branches: [master] paths: ['web/documentserver-example/java-spring/**'] jobs: diff --git a/.github/workflows/lint-python.yml b/.github/workflows/lint-python.yml index e323439bc..4eb8d860a 100644 --- a/.github/workflows/lint-python.yml +++ b/.github/workflows/lint-python.yml @@ -21,20 +21,17 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' - name: Install Dependencies run: | - python -m pip install --upgrade pip - pip install flake8 - pip install pylint - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + make dev - name: Lint Flake8 run: | - flake8 --count --select=E9,F63,F7,F82 --show-source --statistics - flake8 --count --max-complexity=10 --max-line-length=79 --statistics - - - name: Lint Pylint - run: | - find . -type f -name "*.py" | xargs pylint + make lint + + # TODO: Configure mypy + # - name: Types mypy + # run: | + # make types diff --git a/.gitmodules b/.gitmodules index 52687a2de..43b3007ad 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,11 +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 - 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 @@ -13,7 +5,14 @@ [submodule "web/documentserver-example/nodejs/public/assets/document-formats"] path = web/documentserver-example/nodejs/public/assets/document-formats url = https://github.com/ONLYOFFICE/document-formats - branch = master + branch = feature/v8.0 +[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 @@ -46,3 +45,18 @@ 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 +[submodule "web/documentserver-example/java-spring/src/main/resources/assets/document-formats"] + 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 +[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/3rd-Party.license b/3rd-Party.license index aca8b0499..d762967ce 100644 --- a/3rd-Party.license +++ b/3rd-Party.license @@ -113,6 +113,10 @@ Prime JWT - is intended to be fast and easy to use. Prime JWT has a single e 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 + web/documentserver-example/java-spring diff --git a/CHANGELOG.md b/CHANGELOG.md index e93b1af1c..79fe928aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Change Log +## 1.8.0 +- nodejs: pdf, djvu, xps, oxps as pdf documentType +- nodejs: filling pdf +- version number to page meta +- ar skin languages +- sr-Latn-CS skin languages +- getting history via api +- using a repo with a list of formats +- convert after uploading only tagged formats +- link in referenceData +- setUsers for region protection +- onRequestOpen method +- user avatar +- trimming long name of uploading file +- onRequestSelectDocument method +- onRequestSelectSpreadsheet method +- key in referenceData +- restore from history + ## 1.7.0 - nodejs: onRequestSelectDocument method - nodejs: onRequestSelectSpreadsheet method 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/App_Start/BundleConfig.cs b/web/documentserver-example/csharp-mvc/App_Start/BundleConfig.cs index 9fb3de29f..0613f38ba 100644 --- a/web/documentserver-example/csharp-mvc/App_Start/BundleConfig.cs +++ b/web/documentserver-example/csharp-mvc/App_Start/BundleConfig.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/App_Start/FilterConfig.cs b/web/documentserver-example/csharp-mvc/App_Start/FilterConfig.cs index 0809eedd1..7878b8c88 100644 --- a/web/documentserver-example/csharp-mvc/App_Start/FilterConfig.cs +++ b/web/documentserver-example/csharp-mvc/App_Start/FilterConfig.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/App_Start/RouteConfig.cs b/web/documentserver-example/csharp-mvc/App_Start/RouteConfig.cs index 6903f358f..4d9803d7a 100644 --- a/web/documentserver-example/csharp-mvc/App_Start/RouteConfig.cs +++ b/web/documentserver-example/csharp-mvc/App_Start/RouteConfig.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/App_Start/WebApiConfig.cs b/web/documentserver-example/csharp-mvc/App_Start/WebApiConfig.cs index cee3edc23..5135156e7 100644 --- a/web/documentserver-example/csharp-mvc/App_Start/WebApiConfig.cs +++ b/web/documentserver-example/csharp-mvc/App_Start/WebApiConfig.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Content/editor.css b/web/documentserver-example/csharp-mvc/Content/editor.css index 104b14c1f..6ec3cd1c7 100644 --- a/web/documentserver-example/csharp-mvc/Content/editor.css +++ b/web/documentserver-example/csharp-mvc/Content/editor.css @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Content/images/file_docx.svg b/web/documentserver-example/csharp-mvc/Content/images/file_docx.svg index 751395f69..662d545cc 100644 --- a/web/documentserver-example/csharp-mvc/Content/images/file_docx.svg +++ b/web/documentserver-example/csharp-mvc/Content/images/file_docx.svg @@ -1,8 +1 @@ - - - - - - - - + \ No newline at end of file diff --git a/web/documentserver-example/csharp-mvc/Content/images/file_docxf.svg b/web/documentserver-example/csharp-mvc/Content/images/file_docxf.svg index 984761e6f..ab5f02686 100644 --- a/web/documentserver-example/csharp-mvc/Content/images/file_docxf.svg +++ b/web/documentserver-example/csharp-mvc/Content/images/file_docxf.svg @@ -1,6 +1 @@ - - - - - - + \ No newline at end of file diff --git a/web/documentserver-example/csharp-mvc/Content/images/file_pptx.svg b/web/documentserver-example/csharp-mvc/Content/images/file_pptx.svg index deba611bb..66dbeaa0c 100644 --- a/web/documentserver-example/csharp-mvc/Content/images/file_pptx.svg +++ b/web/documentserver-example/csharp-mvc/Content/images/file_pptx.svg @@ -1,8 +1 @@ - - - - - - - - + \ No newline at end of file diff --git a/web/documentserver-example/csharp-mvc/Content/images/file_upload.svg b/web/documentserver-example/csharp-mvc/Content/images/file_upload.svg index 3617f42ee..3c78ce310 100644 --- a/web/documentserver-example/csharp-mvc/Content/images/file_upload.svg +++ b/web/documentserver-example/csharp-mvc/Content/images/file_upload.svg @@ -1,6 +1 @@ - - - - - - + \ No newline at end of file diff --git a/web/documentserver-example/csharp-mvc/Content/images/file_xlsx.svg b/web/documentserver-example/csharp-mvc/Content/images/file_xlsx.svg index 7ee32b7bd..1e738b599 100644 --- a/web/documentserver-example/csharp-mvc/Content/images/file_xlsx.svg +++ b/web/documentserver-example/csharp-mvc/Content/images/file_xlsx.svg @@ -1,12 +1 @@ - - - - - - - - - - - - + \ No newline at end of file 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 000000000..91cf9e02c Binary files /dev/null and b/web/documentserver-example/csharp-mvc/Content/images/uid-1.png differ 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 000000000..651b40c6b Binary files /dev/null and b/web/documentserver-example/csharp-mvc/Content/images/uid-2.png differ diff --git a/web/documentserver-example/csharp-mvc/Content/media.css b/web/documentserver-example/csharp-mvc/Content/media.css index 5ec026f12..705085cc6 100644 --- a/web/documentserver-example/csharp-mvc/Content/media.css +++ b/web/documentserver-example/csharp-mvc/Content/media.css @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Content/stylesheet.css b/web/documentserver-example/csharp-mvc/Content/stylesheet.css index 26e289cd8..6ca4a7718 100644 --- a/web/documentserver-example/csharp-mvc/Content/stylesheet.css +++ b/web/documentserver-example/csharp-mvc/Content/stylesheet.css @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Controllers/HomeController.cs b/web/documentserver-example/csharp-mvc/Controllers/HomeController.cs index 70bbca2b2..c863de2ea 100644 --- a/web/documentserver-example/csharp-mvc/Controllers/HomeController.cs +++ b/web/documentserver-example/csharp-mvc/Controllers/HomeController.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Global.asax.cs b/web/documentserver-example/csharp-mvc/Global.asax.cs index 0939d4ec9..7931e4c2e 100644 --- a/web/documentserver-example/csharp-mvc/Global.asax.cs +++ b/web/documentserver-example/csharp-mvc/Global.asax.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs index 7e7f8b219..0af5f59ac 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,12 @@ namespace OnlineEditorsExampleMVC.Helpers { public class DocManagerHelper { + //get server version + public static string GetVersion() + { + return WebConfigurationManager.AppSettings["version"]; + } + // get max file size public static long MaxFileSize { @@ -51,24 +57,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 @@ -177,7 +183,12 @@ public static int GetFileVersion(string fileName, string userAddress) // get a file name with an index if the file with such a name already exists public static string GetCorrectName(string fileName, string userAddress = null) { + int maxName; + int.TryParse(WebConfigurationManager.AppSettings["filename-max"], out maxName); var baseName = Path.GetFileNameWithoutExtension(fileName); + if (baseName.Length > maxName){ + baseName = baseName.Substring(0, maxName) + "[...]"; + } var ext = Path.GetExtension(fileName).ToLower(); var name = baseName + ext; @@ -215,7 +226,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/Helpers/DocumentConverter.cs b/web/documentserver-example/csharp-mvc/Helpers/DocumentConverter.cs index 145c509d2..3f395ec3a 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/DocumentConverter.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/DocumentConverter.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Helpers/JwtManager.cs b/web/documentserver-example/csharp-mvc/Helpers/JwtManager.cs index ea2b06420..455820ca8 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/JwtManager.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/JwtManager.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs b/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs index 46785a4ba..27ff3f007 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 6960f0584..60469aa96 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/Users.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/Users.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,9 @@ 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", + "Can submit forms" }; static List descr_user_2 = new List() @@ -41,7 +43,9 @@ 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", + "Can’t submit forms" }; static List descr_user_3 = new List() @@ -54,7 +58,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 +76,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() { @@ -85,6 +91,7 @@ public class Users null, new List(), descr_user_1, + true, true ), new User( @@ -103,12 +110,13 @@ public class Users true, new List(), descr_user_2, - false + false, + true ), new User( "uid-3", "Hamish Mitchell", - "mitchell@example.com", + null, "group-3", new List() { "group-2" }, new Dictionary() @@ -121,6 +129,7 @@ public class Users false, new List() { "copy", "download", "print" }, descr_user_3, + false, false ), new User( @@ -134,6 +143,7 @@ public class Users null, new List() { "protect" }, descr_user_0, + false, false ) }; @@ -171,6 +181,43 @@ 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; + } + + // 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 @@ -186,8 +233,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 +248,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/Helpers/Utils.cs b/web/documentserver-example/csharp-mvc/Helpers/Utils.cs index 44c8c48ad..a986b6655 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/Utils.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/Utils.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Models/FileModel.cs b/web/documentserver-example/csharp-mvc/Models/FileModel.cs index 28f537a05..2438ffcd7 100755 --- a/web/documentserver-example/csharp-mvc/Models/FileModel.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileModel.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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 @@ -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} } }, { @@ -236,7 +237,7 @@ public string GetDocConfig(HttpRequest request, UrlHelper url) } // get a document which will be compared with the current document - public void GetCompareFileData(out string compareConfig) + public void GetDocumentData(out string compareConfig) { var jss = new JavaScriptSerializer(); @@ -320,7 +321,7 @@ public void GetLogoConfig(out string logoUrl) } // get a mail merge config - public void GetMailMergeConfig(out string dataMailMergeRecipients) + public void GetSpreadsheetConfig(out string dataSpreadsheet) { var jss = new JavaScriptSerializer(); @@ -361,7 +362,7 @@ public void GetMailMergeConfig(out string dataMailMergeRecipients) mailMergeConfig.Add("token", mailmergeToken); // and add it to the mail merge config } - dataMailMergeRecipients = jss.Serialize(mailMergeConfig); + dataSpreadsheet = jss.Serialize(mailMergeConfig); } //get a users for mentions @@ -372,5 +373,22 @@ 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)); + } + + //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/Models/FileUtility.cs b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs index 7463daf90..99b2357de 100644 --- a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,14 @@ * */ +using Newtonsoft.Json; +using System; using System.Collections.Generic; using System.IO; +using static OnlineEditorsExampleMVC.Models.FileUtility; +using System.Linq; +using System.Text; +using Newtonsoft.Json.Converters; namespace OnlineEditorsExampleMVC.Models { @@ -35,38 +41,188 @@ 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 + public class EmptyTolerantStringEnumConverter : StringEnumConverter + { + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.String && string.IsNullOrWhiteSpace(reader.Value.ToString())) + return Activator.CreateInstance(objectType); + + return base.ReadJson(reader, objectType, existingValue, serializer); + } + } + + public class Format + { + public string Name { get; } + [JsonConverter(typeof(EmptyTolerantStringEnumConverter))] + 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 static class FormatManager + { + private static List cachedFormats; + 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.Actions.Contains("auto-convert")) + .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() + { + if (cachedFormats == null) { - ".xls", ".xlsx", ".xlsm", ".xlsb", - ".xlt", ".xltx", ".xltm", - ".ods", ".fods", ".ots", ".csv" - }; + 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(); + } - // presentation extensions - public static readonly List ExtsPresentation = new List + return cachedFormats; + } + + private static string GetPath() + { + string path = Path.Combine(GetDirectory(), "onlyoffice-docs-formats.json"); + if (File.Exists(path)) + { + return path; + } + else { - ".pps", ".ppsx", ".ppsm", - ".ppt", ".pptx", ".pptm", - ".pot", ".potx", ".potm", - ".odp", ".fodp", ".otp" - }; + 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 diff --git a/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj b/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj index 126648880..e9e884332 100644 --- a/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj +++ b/web/documentserver-example/csharp-mvc/OnlineEditorsExampleMVC.csproj @@ -159,7 +159,6 @@ - @@ -182,17 +181,23 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/web/documentserver-example/csharp-mvc/Properties/AssemblyInfo.cs b/web/documentserver-example/csharp-mvc/Properties/AssemblyInfo.cs index fad76dd5e..e9446709f 100644 --- a/web/documentserver-example/csharp-mvc/Properties/AssemblyInfo.cs +++ b/web/documentserver-example/csharp-mvc/Properties/AssemblyInfo.cs @@ -7,7 +7,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Ascensio System SIA")] [assembly: AssemblyProduct("OnlineEditorsExampleMVC")] -[assembly: AssemblyCopyright("Ascensio System SIA 2023")] +[assembly: AssemblyCopyright("Ascensio System SIA 2024")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] 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/csharp-mvc/Scripts/jquery.dropdownToggle.js b/web/documentserver-example/csharp-mvc/Scripts/jquery.dropdownToggle.js index d908bccbc..5f92e5d98 100644 --- a/web/documentserver-example/csharp-mvc/Scripts/jquery.dropdownToggle.js +++ b/web/documentserver-example/csharp-mvc/Scripts/jquery.dropdownToggle.js @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Scripts/jscript.js b/web/documentserver-example/csharp-mvc/Scripts/jscript.js index 8b4ab9788..35d827964 100644 --- a/web/documentserver-example/csharp-mvc/Scripts/jscript.js +++ b/web/documentserver-example/csharp-mvc/Scripts/jscript.js @@ -1,6 +1,6 @@ /** * - * (c) Copyright Ascensio System SIA 2023 + * (c) Copyright Ascensio System SIA 2024 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx index c9850fd3b..ab0c80333 100644 --- a/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx +++ b/web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx @@ -14,7 +14,7 @@