From 170105efd3a05724f2db16169f1aa214acaf7e0b Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 10 Oct 2023 10:40:12 +0700 Subject: [PATCH 01/64] java-spring: mapping fix for csv and assets --- .../controllers/FileController.java | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 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 49b96c4d..4c337359 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 @@ -48,6 +48,7 @@ import org.json.simple.parser.JSONParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; +import org.springframework.core.io.UrlResource; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -70,6 +71,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; @@ -147,6 +149,34 @@ public class FileController { .body(resource); } + 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 + 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); + } + } catch (MalformedURLException e) { + e.printStackTrace(); + } + return null; + } + // download data from the specified history file private ResponseEntity downloadFileHistory(final String fileName, final String version, @@ -372,14 +402,12 @@ public class FileController { @GetMapping("/assets") public ResponseEntity assets(@RequestParam("name") final String name) { // get sample files from the assests - String fileName = Path.of("assets", "document-templates", "sample", fileUtility.getFileName(name)).toString(); - return downloadFile(fileName); + return downloadSample(name); } @GetMapping("/csv") public ResponseEntity csv() { // download a csv file - String fileName = Path.of("assets", "document-templates", "sample", "csv.csv").toString(); - return downloadFile(fileName); + return downloadSample("csv.csv"); } @GetMapping("/files") From 641cd912bba479a205af12643bbac23b2b429b19 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 11 Oct 2023 13:12:54 +0700 Subject: [PATCH 02/64] ruby: added asset route for sample download --- .../ruby/app/controllers/home_controller.rb | 13 +++++++++++++ .../ruby/config/application.rb | 1 + 2 files changed, 14 insertions(+) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 74f19097..42b1e13f 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -278,6 +278,19 @@ class HomeController < ApplicationController send_file csvPath, :x_sendfile => true end + # downloading an assets file + def asset + file_name = File.basename(params[:fileName]) + assetPath = 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-Disposition'] = "attachment;filename*=UTF-8\'\'" + ERB::Util.url_encode(file_name) + + send_file assetPath, :x_sendfile => true + end + # downloading a file def download begin diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index ae55c78c..6b39993d 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -28,6 +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 '/download', to: 'home#download', via: 'get' match '/downloadhistory', to: 'home#downloadhistory', via: 'get' match '/editor', to: 'home#editor', via: 'get' From 7b275b15b772752dc27de063c08057ea7ecde43f Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 11 Oct 2023 13:27:27 +0700 Subject: [PATCH 03/64] python: added assets route for sample download --- web/documentserver-example/python/manage.py | 1 + web/documentserver-example/python/src/views/actions.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/web/documentserver-example/python/manage.py b/web/documentserver-example/python/manage.py index c525d236..c9b46d73 100644 --- a/web/documentserver-example/python/manage.py +++ b/web/documentserver-example/python/manage.py @@ -63,6 +63,7 @@ def routers(): path('convert', actions.convert), path('create', actions.createNew), path('csv', actions.csv), + path('assets',actions.assets), path('download', actions.download), path('downloadhistory', actions.downloadhistory), path('edit', actions.edit), diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index c0bc48c2..b09fad3c 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -400,6 +400,13 @@ def csv(request): response = docManager.download(filePath) return response +# download a sample file +def assets(request): + filename = fileUtils.getFileName(request.GET['filename']) + filePath = os.path.join('assets', 'document-templates', 'sample', filename) + response = docManager.download(filePath) + return response + # download a file def download(request): try: From 75ab636a669c2d24e292017b91becf35bf5e8395 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 11 Oct 2023 13:37:06 +0700 Subject: [PATCH 04/64] php: removed wrong route and unused method assets --- web/documentserver-example/php/index.php | 6 ------ web/documentserver-example/php/src/ajax.php | 14 -------------- 2 files changed, 20 deletions(-) diff --git a/web/documentserver-example/php/index.php b/web/documentserver-example/php/index.php index 88ed6ab6..565489ac 100755 --- a/web/documentserver-example/php/index.php +++ b/web/documentserver-example/php/index.php @@ -74,12 +74,6 @@ function routers() $view->render(); return; } - if (str_starts_with($path, '/assets')) { - $response = assets(); - $response['status'] = 'success'; - echo json_encode($response); - return; - } if (str_starts_with($path, '/convert')) { $response = convert(); $response['status'] = 'success'; diff --git a/web/documentserver-example/php/src/ajax.php b/web/documentserver-example/php/src/ajax.php index e1eb6460..341baf7e 100644 --- a/web/documentserver-example/php/src/ajax.php +++ b/web/documentserver-example/php/src/ajax.php @@ -333,20 +333,6 @@ function files() } } -/** - * Download assets - * - * @return void - */ -function assets() -{ - $fileName = basename($_GET["name"]); - $filePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . - DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "document-templates" - . DIRECTORY_SEPARATOR . "sample" . DIRECTORY_SEPARATOR . $fileName; - downloadFile($filePath); -} - /** * Download a csv file * From 825aafda255c4f2f6203cd5e5c039c123043697e Mon Sep 17 00:00:00 2001 From: sshakndr Date: Fri, 13 Oct 2023 17:31:47 +0700 Subject: [PATCH 05/64] nodejs: date format fix --- web/documentserver-example/nodejs/helpers/docManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/documentserver-example/nodejs/helpers/docManager.js b/web/documentserver-example/nodejs/helpers/docManager.js index e35a4f8e..70c1d823 100644 --- a/web/documentserver-example/nodejs/helpers/docManager.js +++ b/web/documentserver-example/nodejs/helpers/docManager.js @@ -152,10 +152,10 @@ DocManager.prototype.saveFileData = function saveFileData(fileName, userid, user // get full creation date of the document const dateCreate = fileSystem.statSync(this.storagePath(fileName, address)).mtime; const minutes = (dateCreate.getMinutes() < 10 ? '0' : '') + dateCreate.getMinutes().toString(); - const month = (dateCreate.getMonth() < 10 ? '0' : '') + (parseInt(dateCreate.getMonth().toString(), 10) + 1); + const month = (dateCreate.getMonth() < 9 ? '0' : '') + (parseInt(dateCreate.getMonth().toString(), 10) + 1); const sec = (dateCreate.getSeconds() < 10 ? '0' : '') + dateCreate.getSeconds().toString(); const dateFormat = `${dateCreate.getFullYear()}-${month}-${dateCreate.getDate()}` - + `${dateCreate.getHours()}:${minutes}:${sec}`; + + ` ${dateCreate.getHours()}:${minutes}:${sec}`; const fileInfo = this.historyPath(fileName, address, true); // get file history information this.createDirectory(fileInfo); // create a new history directory if it doesn't exist From 18cf21efe4cab4c096847c6ac0872810c51b16f3 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 18 Oct 2023 11:21:58 +0700 Subject: [PATCH 06/64] python: getting history via api --- CHANGELOG.md | 1 + web/documentserver-example/python/manage.py | 1 + .../python/src/utils/docManager.py | 2 +- .../python/src/views/actions.py | 24 +++++-- .../python/templates/editor.html | 70 +++++++++++++------ 5 files changed, 72 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 128cc92e..8b688d67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- python: getting history via api - nodejs: link in referenceData - nodejs: onRequestSelectDocument method - nodejs: onRequestSelectSpreadsheet method diff --git a/web/documentserver-example/python/manage.py b/web/documentserver-example/python/manage.py index c525d236..a8093d44 100644 --- a/web/documentserver-example/python/manage.py +++ b/web/documentserver-example/python/manage.py @@ -65,6 +65,7 @@ def routers(): path('csv', actions.csv), path('download', actions.download), path('downloadhistory', actions.downloadhistory), + path('historyobj',actions.historyobj), path('edit', actions.edit), path('files', actions.files), path('reference', actions.reference), diff --git a/web/documentserver-example/python/src/utils/docManager.py b/web/documentserver-example/python/src/utils/docManager.py index 2a8dd500..257764db 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -101,7 +101,7 @@ def getServerUrl (forDocumentServer, req): def getFileUri(filename, forDocumentServer, req): host = getServerUrl(forDocumentServer, req) curAdr = req.META['REMOTE_ADDR'] - return f'{host}{settings.STATIC_URL}{curAdr}/{filename}' + return f'{host}/download?fileName={filename}&userAddress={curAdr}' # get absolute URL to the document storage service def getCallbackUrl(filename, req): diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index c0bc48c2..b54174a4 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -329,12 +329,8 @@ def edit(request): dataCompareFile['token'] = jwtManager.encode(dataCompareFile) # encode the dataCompareFile object into a token dataMailMergeRecipients['token'] = jwtManager.encode(dataMailMergeRecipients) # encode the dataMailMergeRecipients object into a token - hist = historyManager.getHistoryObject(storagePath, filename, docKey, fileUri, isEnableDirectUrl, request) # get the document history - 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 '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 @@ -459,6 +455,26 @@ 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 = {} + fileName = None + + try: + fileName = body['fileName'] + except Exception: + pass + + 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) + fileUri = docManager.getFileUri(fileName, True, request) + response = historyManager.getHistoryObject(storagePath, fileName, docKey, fileUri, False, request) + return HttpResponse(json.dumps(response), content_type='application/json') + # referenceData def reference(request): response = {} diff --git a/web/documentserver-example/python/templates/editor.html b/web/documentserver-example/python/templates/editor.html index 1b2f0d55..00a66bf4 100755 --- a/web/documentserver-example/python/templates/editor.html +++ b/web/documentserver-example/python/templates/editor.html @@ -42,6 +42,7 @@ var docEditor; var config; + var hist; var innerAlert = function (message, inEditor) { if (console && console.log) @@ -200,9 +201,52 @@ innerAlert(response.error) return } - document.location.reload(); + 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) + } } } + + function onRequestHistory(){ + const query = new URLSearchParams(window.location.search) + 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) + } + } + + function onRequestHistoryData(event) { + var ver = event.data; + var histData = hist.historyData; + docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history + } + + function onRequestHistoryClose(){ + document.location.reload(); + } var connectEditor = function () { @@ -219,32 +263,16 @@ 'onRequestInsertImage': onRequestInsertImage, 'onRequestCompareFile': onRequestCompareFile, "onRequestMailMergeRecipients": onRequestMailMergeRecipients, - 'onRequestRestore': onRequestRestore + 'onRequestRestore': onRequestRestore, + 'onRequestHistory': onRequestHistory, + 'onRequestHistoryData': onRequestHistoryData, + 'onRequestHistoryClose': onRequestHistoryClose }; if (config.editorConfig.user.id) { - {% if history and historyData %} - - // the user is trying to show the document version history - config.events['onRequestHistory'] = function () { - docEditor.refreshHistory({{ history | safe }}); // 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 | safe }}; - 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(); - }; - - {% endif %} - // add mentions for not anonymous users config.events['onRequestUsers'] = function () { docEditor.setUsers({ // set a list of users to mention in the comments From fe352ebad1ceb46facc3ad778052f09165982195 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 19 Oct 2023 12:15:35 +0700 Subject: [PATCH 07/64] ruby: getting history via api --- CHANGELOG.md | 1 + .../ruby/app/controllers/home_controller.rb | 22 ++++++++ .../ruby/app/models/file_model.rb | 2 +- .../ruby/app/views/home/editor.html.erb | 53 ++++++++++++------- .../ruby/config/application.rb | 1 + 5 files changed, 59 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b688d67..ca280b2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- ruby: getting history via api - python: getting history via api - nodejs: link in referenceData - nodejs: onRequestSelectDocument method diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 74f19097..6bf74df6 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -157,6 +157,28 @@ class HomeController < ApplicationController end + def historyobj + begin + data = request.body.read + if data == nil || data.empty? + return "" + end + fileData = 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'] + ) + history = file.get_history + render json: history + end + end + # downloading a history file from public def downloadhistory begin diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index e80814bd..66f4ea9f 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -233,7 +233,7 @@ class FileModel # 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["url"] = i == cur_ver ? DocumentHelper.get_download_url(file_name, true) : 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) 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 26af8db8..9a001fee 100755 --- a/web/documentserver-example/ruby/app/views/home/editor.html.erb +++ b/web/documentserver-example/ruby/app/views/home/editor.html.erb @@ -27,6 +27,7 @@ var docEditor; var config; + var versionHistory; var innerAlert = function (message, inEditor) { if (console && console.log) @@ -180,10 +181,38 @@ innerAlert(response.error) return } - document.location.reload(); + 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) + } } } + function onRequestHistory() { + 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) + } + } + + function onRequestHistoryData(event){ + var ver = event.data; + var histData = versionHistory.histData; + docEditor.setHistoryData(histData[ver - 1]); + } + + function onRequestHistoryClose(){ + document.location.reload(); + } + var сonnectEditor = function () { config = <%= raw @file.get_config.to_json %>; @@ -200,30 +229,16 @@ 'onRequestInsertImage': onRequestInsertImage, 'onRequestCompareFile': onRequestCompareFile, 'onRequestMailMergeRecipients': onRequestMailMergeRecipients, - 'onRequestRestore': onRequestRestore + 'onRequestRestore': onRequestRestore, + 'onRequestHistory': onRequestHistory, + 'onRequestHistoryData': onRequestHistoryData, + 'onRequestHistoryClose': onRequestHistoryClose }; <% - history = @file.get_history usersMentions = @file.get_users_mentions %> if (config.editorConfig.user.id) { - <% if history %> - // the user is trying to show the document version history - config.events['onRequestHistory'] = function () { - docEditor.refreshHistory(<%= raw history[:hist].to_json %>); // 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 = <%= raw history[:histData].to_json %>; - 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(); - }; - <% end %> // add mentions for not anonymous users config.events['onRequestUsers'] = function () { docEditor.setUsers({ // set a list of users to mention in the comments diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index ae55c78c..d671668b 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -30,6 +30,7 @@ class Application < Rails::Application match '/csv', to: 'home#csv', via: 'get' match '/download', to: 'home#download', via: 'get' match '/downloadhistory', to: 'home#downloadhistory', via: 'get' + match '/historyobj', to: 'home#historyobj', via: 'post' match '/editor', to: 'home#editor', via: 'get' match '/files', to: 'home#files', via: 'get' match '/index', to: 'home#index', via: 'get' From e9893c7c51eede04f30014f497ef807c031e3a91 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 19 Oct 2023 12:42:48 +0700 Subject: [PATCH 08/64] python: correct url/uri fix --- web/documentserver-example/python/src/utils/docManager.py | 2 +- web/documentserver-example/python/src/views/actions.py | 4 ++-- 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 257764db..ca40bf73 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -101,7 +101,7 @@ def getServerUrl (forDocumentServer, req): def getFileUri(filename, forDocumentServer, req): host = getServerUrl(forDocumentServer, req) curAdr = req.META['REMOTE_ADDR'] - return f'{host}/download?fileName={filename}&userAddress={curAdr}' + return f'{host}/storage/{curAdr}/{filename}' # get absolute URL to the document storage service def getCallbackUrl(filename, req): diff --git a/web/documentserver-example/python/src/views/actions.py b/web/documentserver-example/python/src/views/actions.py index b54174a4..74d5cb6f 100755 --- a/web/documentserver-example/python/src/views/actions.py +++ b/web/documentserver-example/python/src/views/actions.py @@ -471,8 +471,8 @@ def historyobj(request): storagePath = docManager.getStoragePath(fileName, request) docKey = docManager.generateFileKey(fileName, request) - fileUri = docManager.getFileUri(fileName, True, request) - response = historyManager.getHistoryObject(storagePath, fileName, docKey, fileUri, False, 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 From 39820cec0aadb45d1f43b0533a2e02873b04b9e1 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 19 Oct 2023 14:19:15 +0700 Subject: [PATCH 09/64] php: getting history via api --- CHANGELOG.md | 1 + web/documentserver-example/php/index.php | 5 ++ web/documentserver-example/php/src/ajax.php | 12 ++++ .../php/src/views/DocEditorView.php | 16 +---- .../php/templates/docEditor.tpl | 63 ++++++++++++++++++- 5 files changed, 80 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca280b2e..8b42f131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Change Log +- php: getting history via api - ruby: getting history via api - python: getting history via api - nodejs: link in referenceData diff --git a/web/documentserver-example/php/index.php b/web/documentserver-example/php/index.php index 88ed6ab6..cc8d3c5e 100755 --- a/web/documentserver-example/php/index.php +++ b/web/documentserver-example/php/index.php @@ -115,6 +115,11 @@ function routers() echo json_encode($response); return; } + if (str_starts_with($path, '/objhistory')) { + $response = historyObj(); + echo json_encode($response); + return; + } if (str_starts_with($path, '/reference')) { $response = reference(); $response['status'] = 'success'; diff --git a/web/documentserver-example/php/src/ajax.php b/web/documentserver-example/php/src/ajax.php index e1eb6460..d4042e5b 100644 --- a/web/documentserver-example/php/src/ajax.php +++ b/web/documentserver-example/php/src/ajax.php @@ -408,6 +408,18 @@ function historyDownload() } } +function historyObj() +{ + $input = file_get_contents('php://input'); + $body = json_decode($input, true); + $fileName = $body['fileName']; + $filetype = mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); + $docKey = getDocEditorKey($fileName); + $fileuri = fileUri($fileName, true); + $historyObject = getHistory($fileName, $filetype, $docKey, $fileuri, false); + return $historyObject; +} + /** * Download a file * diff --git a/web/documentserver-example/php/src/views/DocEditorView.php b/web/documentserver-example/php/src/views/DocEditorView.php index bb551a81..1e66a6fa 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -231,23 +231,9 @@ final class DocEditorView extends View // encode the dataMailMergeRecipients object into the token $dataMailMergeRecipients["token"] = $jwtManager->jwtEncode($dataMailMergeRecipients); } - $out = getHistory($filename, $filetype, $docKey, $fileuri, $isEnableDirectUrl); - $history = $out[0]; - $historyData = $out[1]; + $historyLayout = ""; if ($user->id != "uid-0") { - if ($history != null && $historyData != null) { - $historyLayout .= " config.events['onRequestHistory'] = function () { - // show the document version history - docEditor.refreshHistory(".json_encode($history).");};"; - $historyLayout .= " config.events['onRequestHistoryData'] = function (event) { - var ver = event.data; - var histData = ".json_encode($historyData).";". - "docEditor.setHistoryData(histData[ver - 1]);}; - config.events['onRequestHistoryClose'] = function () { - document.location.reload(); - };"; - } $historyLayout .= "// add mentions for not anonymous users config.events['onRequestUsers'] = function () { docEditor.setUsers({ // set a list of users to mention in the comments diff --git a/web/documentserver-example/php/templates/docEditor.tpl b/web/documentserver-example/php/templates/docEditor.tpl index a21400f5..f7b0bf78 100644 --- a/web/documentserver-example/php/templates/docEditor.tpl +++ b/web/documentserver-example/php/templates/docEditor.tpl @@ -45,6 +45,7 @@ var docEditor; var config; + let history; var innerAlert = function (message, inEditor) { if (console && console.log) @@ -189,6 +190,41 @@ } }; + function onRequestHistory() { + const query = new URLSearchParams(window.location.search) + 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 + } + ) + } + } + + function onRequestHistoryData(event) { + var ver = event.data; + var histData = history[1] + docEditor.setHistoryData(histData[ver - 1]) + } + + function onRequestHistoryClose() { + document.location.reload() + } + function onRequestRestore(event) { const query = new URLSearchParams(window.location.search) const config = {config} @@ -206,7 +242,27 @@ innerAlert(response.error) return } - document.location.reload(); + 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 + } + ) + } } } @@ -229,7 +285,10 @@ 'onRequestCompareFile': onRequestCompareFile, 'onRequestMailMergeRecipients': onRequestMailMergeRecipients, 'onRequestReferenceData': onRequestReferenceData, - 'onRequestRestore': onRequestRestore + 'onRequestRestore': onRequestRestore, + 'onRequestHistoryData': onRequestHistoryData, + 'onRequestHistory': onRequestHistory, + 'onRequestHistoryClose': onRequestHistoryClose }; {history} From 0e5e2b125d4d0386161aaf1f7547a92466e0e5b2 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Fri, 20 Oct 2023 21:00:39 +0700 Subject: [PATCH 10/64] java-spring: lint fix --- .../com/onlyoffice/integration/controllers/FileController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4c337359..55e09eea 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 @@ -149,7 +149,7 @@ public class FileController { .body(resource); } - private ResponseEntity downloadSample(final String fileName){ + private ResponseEntity downloadSample(final String fileName) { String serverPath = System.getProperty("user.dir"); String contentType = "application/octet-stream"; String fileLocation = serverPath From 5f2c5cea58b8200bb7d90500dbaf2e466a48f034 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Thu, 26 Oct 2023 11:15:26 +0700 Subject: [PATCH 11/64] 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 c75f024b..b844c7bc 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 @@ class HomeController < ApplicationController 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 cc61d1ba..e581c770 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 12/64] 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 a8093d44..910d38a4 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 969e9cf3..a701c8c5 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 13/64] 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 2508e8d0..f5fceebe 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 14/64] 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 0ecbf116..b608288a 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 @@ public class FileController { 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 15/64] 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 c9b46d73..6387e57b 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 16/64] 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 532b0ccf..bc56fa4e 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 @@ class HomeController < ApplicationController # 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 9d3d5243b2d9a68ff6eadbb74afdbf7b44405ec3 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 1 Nov 2023 10:59:41 +0700 Subject: [PATCH 17/64] 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 1902810e..b9ec57cc 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -26,7 +26,6 @@ import urllib.parse 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 fb9604f6..2bbf4718 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 d75a4c529d3b5026d5e6d7e355e0032b0a5910b0 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Wed, 8 Nov 2023 12:17:42 +0700 Subject: [PATCH 18/64] 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 988370dc..e473656e 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 @@ class HomeController < ApplicationController 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 6b39993d..12dfd4df 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 19/64] 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 4311d80b..af8c700d 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 d4081d06..54392dd4 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 20/64] 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 ea03c04b..3a2744ed 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 2184c411..8fc1e540 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -489,7 +489,7 @@ namespace OnlineEditorsExample 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 2b2a7592..ed1fad98 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -275,7 +275,7 @@ namespace OnlineEditorsExample 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 @@ namespace OnlineEditorsExample 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 21/64] 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 3a2744ed..49e6a0a6 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 00000000..bf21acc7 --- /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 22/64] 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 00000000..37d2df5c --- /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 23/64] 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 ea03c04b..985a0e5f 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 4de69296..7721001c 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs @@ -220,7 +220,7 @@ namespace OnlineEditorsExampleMVC.Helpers 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 c7d6abc2..3691fc7d 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 89487893..70d40e36 100644 --- a/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp-mvc/WebEditor.ashx.cs @@ -453,7 +453,7 @@ namespace OnlineEditorsExampleMVC 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 @@ namespace OnlineEditorsExampleMVC 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 24/64] 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 985a0e5f..04bd88a9 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 00000000..bf21acc7 --- /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 25/64] 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 7463daf9..f7eb6d8e 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 @@ namespace OnlineEditorsExampleMVC.Models ".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 26/64] 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 7721001c..41493888 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs @@ -51,24 +51,24 @@ namespace OnlineEditorsExampleMVC.Helpers // 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 f7eb6d8e..b2de3aba 100644 --- a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs @@ -40,39 +40,12 @@ namespace OnlineEditorsExampleMVC.Models { 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 @@ namespace OnlineEditorsExampleMVC.Models } } - 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 3691fc7d..e9e88433 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 fb6b5f44..51630ee6 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 27/64] 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 1a0378e4..647dfcb6 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 63b2202f8232cc5fce6f44f3c9e8ba7ee2189189 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Mon, 13 Nov 2023 16:15:05 +0700 Subject: [PATCH 28/64] 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 af8c700d..1cdf8f96 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 b9ec57cc..680d111f 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -26,6 +26,7 @@ import urllib.parse 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 29/64] 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 565489ac..6c7c25d7 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 9f9b7e5e..cd5ed06f 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 89f29b19..017bf62b 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -211,11 +211,11 @@ final class DocEditorView extends View // 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 30/64] 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 574daadf..6a6e12dd 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 c390c930..354ce639 100644 --- a/web/documentserver-example/python/src/utils/users.py +++ b/web/documentserver-example/python/src/utils/users.py @@ -42,7 +42,8 @@ descr_user_1 = [ "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 @@ descr_user_2 = [ "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 @@ descr_user_3 = [ "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 @@ descr_user_0 = [ "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 d4bc7eb6..c1a647ce 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 31/64] 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 87e42289..d1bbc1e3 100644 --- a/web/documentserver-example/php/src/helpers/ExampleUsers.php +++ b/web/documentserver-example/php/src/helpers/ExampleUsers.php @@ -38,6 +38,7 @@ final class ExampleUsers "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 @@ final class ExampleUsers "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 @@ final class ExampleUsers "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 @@ final class ExampleUsers "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 ec55fb51..f61969fb 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 9fbbb120..e68dd60f 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -85,7 +85,7 @@ final class DocEditorView extends View } // 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 32/64] 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 c50c4ad3..4693c963 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 class FileModel { 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 83fdae5e..4cf23f67 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 final class TrackManager { // 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 8f2c30b9..8aa4c222 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 33/64] 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 3fe48499..4c3e8d24 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 class ExampleData { "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 class ExampleData { "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 class ExampleData { "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 class ExampleData { "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 7d378ec7..f0efb4ac 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 class DefaultCallbackManager implements CallbackManager { 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 bcfad7db..3d51914a 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 @@ public class Customization { 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 23b75225..a296fd4b 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 5af0568b..1c8537ef 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 34/64] 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 2184c411..2a957cbf 100755 --- a/web/documentserver-example/csharp/DocEditor.aspx.cs +++ b/web/documentserver-example/csharp/DocEditor.aspx.cs @@ -153,7 +153,7 @@ namespace OnlineEditorsExample 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 cc5f8c93..9a267824 100644 --- a/web/documentserver-example/csharp/TrackManager.cs +++ b/web/documentserver-example/csharp/TrackManager.cs @@ -258,6 +258,22 @@ namespace OnlineEditorsExample 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 4ce7e731..7b899836 100644 --- a/web/documentserver-example/csharp/Users.cs +++ b/web/documentserver-example/csharp/Users.cs @@ -30,7 +30,8 @@ namespace OnlineEditorsExample "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 @@ namespace OnlineEditorsExample "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 @@ namespace OnlineEditorsExample "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 @@ namespace OnlineEditorsExample "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 35/64] 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 46785a4b..ef777ae9 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/TrackManager.cs @@ -256,6 +256,22 @@ namespace OnlineEditorsExampleMVC.Helpers 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 0ed0a9ab..937182b3 100644 --- a/web/documentserver-example/csharp-mvc/Helpers/Users.cs +++ b/web/documentserver-example/csharp-mvc/Helpers/Users.cs @@ -31,7 +31,8 @@ namespace OnlineEditorsExampleMVC.Helpers "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 @@ namespace OnlineEditorsExampleMVC.Helpers "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 @@ namespace OnlineEditorsExampleMVC.Helpers "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 @@ namespace OnlineEditorsExampleMVC.Helpers "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 ddc0028c..a3a1b1dc 100755 --- a/web/documentserver-example/csharp-mvc/Models/FileModel.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileModel.cs @@ -88,7 +88,7 @@ namespace OnlineEditorsExampleMVC.Models 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 36/64] 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 7c1129ae..76682c82 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 @@ class FileModel 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 844e9193..e62e70ff 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 @@ class TrackHelper 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 e8a3cfaf..ef2de6a7 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 37/64] 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 25912d68..30c09ea5 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 40d1c0c03b031c07b9066645008a88dc3fce6de4 Mon Sep 17 00:00:00 2001 From: sshakndr Date: Tue, 21 Nov 2023 14:20:35 +0700 Subject: [PATCH 38/64] 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 1cdf8f96..af8c700d 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 680d111f..28dd1f68 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -26,7 +26,6 @@ import urllib.parse 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 39/64] 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 756d0e89..936407a3 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 00000000..39193f07 --- /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 03a9c75d..21a227f0 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 40/64] 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 6a6e12dd..e218f73a 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 41/64] 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 eabac5f8..3602303c 100644 --- a/web/documentserver-example/csharp/Default.aspx.cs +++ b/web/documentserver-example/csharp/Default.aspx.cs @@ -30,46 +30,6 @@ using ASC.Api.DocumentConverter; 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 @@ namespace OnlineEditorsExample // 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 @@ namespace OnlineEditorsExample { 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 660be862..2206a469 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 a827d70f..8715147e 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 42/64] 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 37d2df5c..f5eba7c2 100644 --- a/web/documentserver-example/csharp/FormatManager.cs +++ b/web/documentserver-example/csharp/FormatManager.cs @@ -50,6 +50,8 @@ namespace OnlineEditorsExample public class FormatManager { + private static List cachedFormats; + public static List FillableExtensions() { return Fillable() @@ -159,11 +161,15 @@ namespace OnlineEditorsExample 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 43/64] 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 b2de3aba..11b214b1 100644 --- a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs @@ -73,6 +73,7 @@ namespace OnlineEditorsExampleMVC.Models public static class FormatManager { + private static List cachedFormats; public static List FillableExtensions() { return Fillable() @@ -182,11 +183,16 @@ namespace OnlineEditorsExampleMVC.Models 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 44/64] reorder modules --- .gitmodules | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitmodules b/.gitmodules index 04bd88a9..10509447 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 45/64] repo with formats to changelog --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17a48a31..b626a8db 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 46/64] link in referenceData in changelog --- CHANGELOG.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b626a8db..609fbca9 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 47/64] 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 647dfcb6..05793760 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 48/64] 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 e218f73a..fdbdfb51 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 49/64] 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 25912d68..43e21ad9 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 50/64] 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 f640fc8d..2052ae05 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.HashMap; 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 class DefaultHistoryManager implements HistoryManager { 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 class DefaultHistoryManager implements HistoryManager { // 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 @@ public class DefaultHistoryManager implements HistoryManager { } 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 51/64] 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 28dd1f68..cbb698fd 100755 --- a/web/documentserver-example/python/src/utils/docManager.py +++ b/web/documentserver-example/python/src/utils/docManager.py @@ -26,6 +26,7 @@ import urllib.parse 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 52/64] 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 609fbca9..8249c901 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 11b214b1..99dbe9da 100644 --- a/web/documentserver-example/csharp-mvc/Models/FileUtility.cs +++ b/web/documentserver-example/csharp-mvc/Models/FileUtility.cs @@ -126,9 +126,7 @@ namespace OnlineEditorsExampleMVC.Models 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 53/64] 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 8249c901..cb0cc9bb 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 f5eba7c2..6039f090 100644 --- a/web/documentserver-example/csharp/FormatManager.cs +++ b/web/documentserver-example/csharp/FormatManager.cs @@ -104,9 +104,7 @@ namespace OnlineEditorsExample 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 54/64] 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 970db304..ef4b4a24 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 @@ public class IndexServlet extends HttpServlet { 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 @@ public class IndexServlet extends HttpServlet { // 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 55/64] 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 a4838c19..9fb239e8 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 56/64] 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 7c1129ae..dd3cd0d2 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 @@ class FileModel :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 57/64] - auto-convert in changelog --- CHANGELOG.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb0cc9bb..566d777a 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 58/64] 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 936407a3..b69c874c 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 21a227f0..a0d9b132 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 59/64] 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 b69c874c..d4b959c8 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 60/64] 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 d4b959c8..b19cf30c 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 61/64] 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 b19cf30c..13d9458a 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 a0d9b132..a4cc7a26 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 62/64] 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 890212c6..92b734fe 100644 --- a/web/documentserver-example/php/src/views/DocEditorView.php +++ b/web/documentserver-example/php/src/views/DocEditorView.php @@ -244,7 +244,7 @@ final class DocEditorView extends View // 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 9718272d..5c4f4575 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 63/64] getting history in changelog --- CHANGELOG.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e229e987..1b648c40 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 64/64] 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 13d9458a..4eb8d860 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