Merge branch 'feature/upload-name' of https://github.com/ONLYOFFICE/document-server-integration into feature/upload-name

This commit is contained in:
sshakndr
2023-10-20 18:27:27 +07:00
32 changed files with 111 additions and 97 deletions

View File

@ -1,43 +1,36 @@
# Change Log
- csharp: trimming long name of uploading file
- csharp-mvc: trimming long name of uploading file
- java: trimming long name of uploading file
- java-spring: trimming long name of uploading file
- php: trimming long name of uploading file
- python: trimming long name of uploading file
- ruby: trimming long name of uploading file
- nodejs: trimming long name of uploading file
- csharp: key in referenceData
- csharp-mvc: key in referenceData
- java: key in referenceData
- java-spring: key in referenceData
- php: key in referenceData
- python: key in referenceData
- ruby: key in referenceData
- trimming long name of uploading file
- onRequestSelectDocument method
- onRequestSelectSpreadsheet method
- key in referenceData
- nodejs: link 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
- nodejs: onRequestSelectDocument method
- nodejs: onRequestSelectSpreadsheet method
- nodejs: onRequestOpen
- nodejs: submitForm
- nodejs: key in referenceData
- nodejs: change reference source
- java-spring: using a repo with a list of formats
- java: using a repo with a list of formats
- php: using a repo with a list of formats
- nodejs: using a repo with a list of formats
- java: using a repo with a list of formats
- python: using a repo with a list of formats
- ruby: using a repo with a list of formats
- nodejs: delete file without reloading the page
- nodejs: getting history by a separate request
- nodejs: restore from history
- php: using a repo with a list of formats
- php: restore from history
- python: restore from history
- ruby: restore from history
- csharp-mvc: getting history by a separate request
- csharp-mvc: restore from history
- csharp: getting history by a separate request
- java: getting history by a separate request
- java-spring: getting history by a separate request
- restore from history
- csharp: restore from history
## 1.6.0
- nodejs: setUsers for region protection

View File

@ -236,7 +236,7 @@ namespace OnlineEditorsExampleMVC.Models
}
// get a document which will be compared with the current document
public void GetCompareFileData(out string compareConfig)
public void GetDocumentData(out string compareConfig)
{
var jss = new JavaScriptSerializer();

View File

@ -159,7 +159,6 @@
<Content Include="favicon.ico" />
<Content Include="Global.asax" />
<Content Include="LICENSE" />
<Content Include="Scripts\jquery-1.8.2.js" />
<Content Include="Scripts\jquery-ui.js" />
<Content Include="Scripts\jquery.blockUI.js" />
<Content Include="Scripts\jquery.dropdownToggle.js" />

View File

@ -129,10 +129,12 @@
};
// the user is trying to select document for comparing by clicking the Document from Storage button
var onRequestCompareFile = function () {
<% string compareFileData; %>
<% Model.GetCompareFileData(out compareFileData); %>
docEditor.setRevisedFile(<%=compareFileData%>); // select a document for comparing
var onRequestSelectDocument = function (event) {
<% string documentData; %>
<% Model.GetDocumentData(out documentData); %>
var data = <%=documentData%>;
data.c = event.data.c;
docEditor.setRequestedDocument(data); // select a document for comparing
};
// the user is trying to select recipients data by clicking the Mail merge button
@ -246,7 +248,7 @@
"onMakeActionLink": onMakeActionLink,
"onMetaChange": onMetaChange,
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestSelectDocument": onRequestSelectDocument,
"onRequestSelectSpreadsheet": onRequestSelectSpreadsheet,
};

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<appSettings>
<clear />
<add key="version" value="1.6.0"/>
<add key="version" value="1.7.0"/>
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>

View File

@ -145,8 +145,10 @@
};
// the user is trying to select document for comparing by clicking the Document from Storage button
var onRequestCompareFile = function () {
docEditor.setRevisedFile(<%= CompareFileData %>); // select a document for comparing
var onRequestSelectDocument = function (event) {
var data = <%= DocumentData %>;
data.c = event.data.c;
docEditor.setRequestedDocument(data); // select a document for comparing
};
// the user is trying to select recipients data by clicking the Mail merge button
@ -218,7 +220,7 @@
'onMakeActionLink': onMakeActionLink,
'onMetaChange': onMetaChange,
'onRequestInsertImage': onRequestInsertImage,
'onRequestCompareFile': onRequestCompareFile,
'onRequestSelectDocument': onRequestSelectDocument,
"onRequestSelectSpreadsheet": onRequestSelectSpreadsheet,
};

View File

@ -61,7 +61,7 @@ namespace OnlineEditorsExample
protected string DocConfig { get; private set; }
protected string InsertImageConfig { get; private set; }
protected string CompareFileData { get; private set; }
protected string DocumentData { get; private set; }
protected string DataSpreadsheet { get; private set; }
protected string UsersForMentions { get; private set; }
protected string DocumentType { get { return _Default.DocumentType(FileName); } }
@ -308,7 +308,7 @@ namespace OnlineEditorsExample
// a document which will be compared with the current document
Dictionary<string, object> compareFile = GetCompareFile();
CompareFileData = jss.Serialize(compareFile);
DocumentData = jss.Serialize(compareFile);
// recipient data for spreadsheet
Dictionary<string, object> spreadsheetConfig = GetSpreadsheetConfig();

View File

@ -148,7 +148,6 @@
<Content Include="App_Themes\jquery-ui.css" />
<Content Include="App_Themes\stylesheet.css" />
<Content Include="DocEditor.aspx" />
<Content Include="script\jquery-1.9.0.min.js" />
<Content Include="script\jquery-ui.min.js" />
<Content Include="script\jquery.blockUI.js" />
<Content Include="script\jquery.dropdownToggle.js" />

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<clear />
<add key="version" value="1.6.0"/>
<add key="version" value="1.7.0"/>
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>

View File

@ -143,7 +143,7 @@ public class EditorController {
model.addAttribute("dataInsertImage", getInsertImage(directUrl));
// get a document for comparison and add it to the model
model.addAttribute("dataCompareFile", getCompareFile(directUrl));
model.addAttribute("dataDocument", getCompareFile(directUrl));
// get recipients data for mail merging and add it to the model
model.addAttribute("dataSpreadsheet", getSpreadsheet(directUrl));
@ -193,22 +193,22 @@ public class EditorController {
// get a document that will be compared with the current document
@SneakyThrows
private String getCompareFile(final Boolean directUrl) {
Map<String, Object> dataCompareFile = new HashMap<>();
dataCompareFile.put("fileType", "docx");
dataCompareFile.put("url", storagePathBuilder.getServerUrl(true) + "/assets?name=sample.docx");
Map<String, Object> dataDocument = new HashMap<>();
dataDocument.put("fileType", "docx");
dataDocument.put("url", storagePathBuilder.getServerUrl(true) + "/assets?name=sample.docx");
if (directUrl) {
dataCompareFile.put("directUrl", storagePathBuilder
dataDocument.put("directUrl", storagePathBuilder
.getServerUrl(false) + "/assets?name=sample.docx");
}
// check if the document token is enabled
if (jwtManager.tokenEnabled()) {
// create token from the dataCompareFile object
dataCompareFile.put("token", jwtManager.createToken(dataCompareFile));
// create token from the dataDocument object
dataDocument.put("token", jwtManager.createToken(dataDocument));
}
return objectMapper.writeValueAsString(dataCompareFile);
return objectMapper.writeValueAsString(dataDocument);
}
@SneakyThrows

View File

@ -143,7 +143,6 @@ public class DefaultFileUtility implements FileUtility {
if (fileName.length() > maxName) {
fileName = fileName.substring(0, maxName) + "[...]";
}
// get file name without extension
String fileExtension = getFileExtension(fullFileName); // get file extension
// get the path to the files with the specified name
Path path = Paths.get(directory + fileName + "." + fileExtension);

View File

@ -1,4 +1,4 @@
server.version=1.6.0
server.version=1.7.0
server.address=
server.port=4000

View File

@ -109,9 +109,12 @@
docEditor.insertImage(temp);
};
var dataDocument = [[${dataDocument}]];
// the user is trying to select document for comparing by clicking the Document from Storage button
var onRequestCompareFile = function() {
docEditor.setRevisedFile([[${dataCompareFile}]]);
var onRequestSelectDocument = function(event) {
const temp = Object.assign({"c": event.data.c}, JSON.parse(dataDocument));
docEditor.setRequestedDocument(temp);
};
var dataSpreadsheet = [[${dataSpreadsheet}]];
@ -243,7 +246,7 @@
"onMakeActionLink": onMakeActionLink,
"onMetaChange": onMetaChange,
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestSelectDocument": onRequestSelectDocument,
"onRequestSelectSpreadsheet": onRequestSelectSpreadsheet,
"onRequestRestore": onRequestRestore,
"onRequestHistory": onRequestHistory,

View File

@ -85,12 +85,12 @@ public class EditorServlet extends HttpServlet {
}
// a document that will be compared with the current document
Map<String, Object> dataCompareFile = new HashMap<>();
dataCompareFile.put("fileType", "docx");
dataCompareFile.put("url", DocumentManager.getServerUrl(true) + "/IndexServlet?type=assets&"
Map<String, Object> dataDocument = new HashMap<>();
dataDocument.put("fileType", "docx");
dataDocument.put("url", DocumentManager.getServerUrl(true) + "/IndexServlet?type=assets&"
+ "name=sample.docx");
if (isEnableDirectUrl) {
dataCompareFile.put("directUrl", DocumentManager.getServerUrl(false) + "/IndexServlet?"
dataDocument.put("directUrl", DocumentManager.getServerUrl(false) + "/IndexServlet?"
+ "type=assets&name=sample.docx");
}
@ -114,8 +114,8 @@ public class EditorServlet extends HttpServlet {
// create token from the dataInsertImage object
dataInsertImage.put("token", DocumentManager.createToken(dataInsertImage));
// create token from the dataCompareFile object
dataCompareFile.put("token", DocumentManager.createToken(dataCompareFile));
// create token from the dataDocument object
dataDocument.put("token", DocumentManager.createToken(dataDocument));
// create token from the dataSpreadsheet object
dataSpreadsheet.put("token", DocumentManager.createToken(dataSpreadsheet));
@ -127,7 +127,7 @@ public class EditorServlet extends HttpServlet {
+ ConfigManager.getProperty("files.docservice.url.api"));
request.setAttribute("dataInsertImage", gson.toJson(dataInsertImage)
.substring(1, gson.toJson(dataInsertImage).length() - 1));
request.setAttribute("dataCompareFile", gson.toJson(dataCompareFile));
request.setAttribute("dataDocument", gson.toJson(dataDocument));
request.setAttribute("dataSpreadsheet", gson.toJson(dataSpreadsheet));
request.setAttribute("usersForMentions", !user.getId()
.equals("uid-0") ? gson.toJson(usersForMentions) : null);

View File

@ -1,4 +1,4 @@
version=1.6.0
version=1.7.0
filesize-max=5242880
storage-folder=app_data

View File

@ -117,8 +117,10 @@
};
// the user is trying to select document for comparing by clicking the Document from Storage button
var onRequestCompareFile = function() {
docEditor.setRevisedFile(${dataCompareFile}); // select a document for comparing
var onRequestSelectDocument = function(event) {
var data = ${dataDocument};
data.c = event.data.c;
docEditor.setRequestedDocument(data); // select a document for comparing
};
// the user is trying to select recipients data by clicking the Mail merge button
@ -245,7 +247,7 @@
"onMakeActionLink": onMakeActionLink,
"onMetaChange": onMetaChange,
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestSelectDocument": onRequestSelectDocument,
"onRequestSelectSpreadsheet": onRequestSelectSpreadsheet,
"onRequestRestore": onRequestRestore,
"onRequestHistory": onRequestHistory,

View File

@ -1,5 +1,5 @@
{
"version": "1.6.0",
"version": "1.7.0",
"log": {
"appenders": [
{

View File

@ -536,7 +536,7 @@ DocManager.prototype.getHistory = function getHistory(fileName, content, keyVers
if (content && contentJson) {
userNameFromJson = oldVersion ? contentJson.username : contentJson.user.name;
userIdFromJson = oldVersion ? contentJson.userid : contentJson.user.userid;
userIdFromJson = oldVersion ? contentJson.userid : contentJson.user.id;
createdFromJson = oldVersion ? contentJson.date : contentJson.created;
}

View File

@ -177,7 +177,7 @@
docEditor.insertImage(data); // insert an image into the file
};
var onRequestSelectDocument = function() { // the user is trying to select document by clicking the Document from Storage button
var onRequestSelectDocument = function(event) { // the user is trying to select document by clicking the Document from Storage button
var data = <%- JSON.stringify(dataDocument) %>;
data.c = event.data.c;
docEditor.setRequestedDocument(data); // select a document

View File

@ -33,7 +33,7 @@ You can use any web server capable of running PHP code to run the example. We wi
* **IIS**: version 7 or later (refer to [Microsoft official website](https://www.iis.net/learn/application-frameworks/scenario-build-a-php-website-on-iis/configuring-step-1-install-iis-and-php) to learn how to install IIS);
* **PHP** (download it from the [http://php.net](https://php.net/downloads.php) site);
* **PHP Manager for IIS** (download it from the [Microsoft open source site](https://phpmanager.codeplex.com/releases/view/69115)).
* **PHP Manager for IIS** (download it from the [Microsoft open source site](https://www.iis.net/downloads/community/2018/05/php-manager-150-for-iis-10)).
* **Composer** (download it from the [Composer official website](https://getcomposer.org/download/)).
### Step 4. IIS configuration

View File

@ -31,6 +31,9 @@ services:
build:
context: .
target: proxy
depends_on:
- document-server
- example
ports:
- "80:80"
- "8080:8080"

View File

@ -22,7 +22,7 @@ use Example\Common\URL;
class ConfigurationManager
{
public string $version = '1.6.0';
public string $version = '1.7.0';
public function exampleURL(): ?URL
{

View File

@ -199,13 +199,13 @@ final class DocEditorView extends View
];
// a document for comparing
$dataCompareFile = $isEnableDirectUrl ? [
$dataDocument = $isEnableDirectUrl ? [
"fileType" => "docx",
"url" => serverPath(true) . "/assets?name=sample.docx",
"directUrl" => serverPath(false) . "/assets?name=sample.docx",
"url" => serverPath(true) . "/assets/document-templates/sample/sample.docx",
"directUrl" => serverPath(false) . "/assets/document-templates/sample/sample.docx",
] : [
"fileType" => "docx",
"url" => serverPath(true) . "/assets?name=sample.docx",
"url" => serverPath(true) . "/assets/document-templates/sample/sample.docx",
];
// recipients data for mail merging
@ -226,8 +226,8 @@ final class DocEditorView extends View
$config["token"] = $jwtManager->jwtEncode($config); // encode config into the token
// encode the dataInsertImage object into the token
$dataInsertImage["token"] = $jwtManager->jwtEncode($dataInsertImage);
// encode the dataCompareFile object into the token
$dataCompareFile["token"] = $jwtManager->jwtEncode($dataCompareFile);
// encode the dataDocument object into the token
$dataDocument["token"] = $jwtManager->jwtEncode($dataDocument);
// encode the dataSpreadsheet object into the token
$dataSpreadsheet["token"] = $jwtManager->jwtEncode($dataSpreadsheet);
}
@ -273,7 +273,7 @@ final class DocEditorView extends View
1,
mb_strlen(json_encode($dataInsertImage)) - 2
),
"dataCompareFile" => json_encode($dataCompareFile),
"dataDocument" => json_encode($dataDocument),
"dataSpreadsheet" => json_encode($dataSpreadsheet),
"fileNotFoundAlert" => !file_exists(getStoragePath($filename)) ? "alert('File not found'); return;" : "",
"config" => json_encode($config),

View File

@ -143,8 +143,10 @@
};
// the user is trying to select document for comparing by clicking the Document from Storage button
var onRequestCompareFile = function() {
docEditor.setRevisedFile({dataCompareFile}); // select a document for comparing
var onRequestSelectDocument = function(event) {
var data = {dataDocument};
data.c = event.data.c;
docEditor.setRequestedDocument(data); // select a document for comparing
};
// the user is trying to select recipients data by clicking the Mail merge button
@ -228,7 +230,7 @@
'onMakeActionLink': onMakeActionLink,
'onMetaChange': onMetaChange,
'onRequestInsertImage': onRequestInsertImage,
'onRequestCompareFile': onRequestCompareFile,
'onRequestSelectDocument': onRequestSelectDocument,
'onRequestSelectSpreadsheet': onRequestSelectSpreadsheet,
'onRequestReferenceData': onRequestReferenceData,
'onRequestRestore': onRequestRestore

View File

@ -28,6 +28,9 @@ services:
build:
context: .
target: proxy
depends_on:
- document-server
- example
ports:
- "80:80"
- "8080:8080"

View File

@ -21,7 +21,7 @@ from urllib.parse import ParseResult, urlparse, urljoin
from src.common import string
class ConfigurationManager:
version = '1.6.0'
version = '1.7.0'
def example_url(self) -> Optional[ParseResult]:
url = environ.get('EXAMPLE_URL')

View File

@ -301,13 +301,13 @@ def edit(request):
}
# a document which will be compared with the current document
dataCompareFile = {
dataDocument = {
'fileType': 'docx',
'url': docManager.getServerUrl(True, request) + '/static/sample.docx',
'directUrl': docManager.getServerUrl(False, request) + '/static/sample.docx'
'url': docManager.getServerUrl(True, request) + '/assets?filename=sample.docx',
'directUrl': docManager.getServerUrl(False, request) + '/assets?filename=sample.docx'
} if isEnableDirectUrl else {
'fileType': 'docx',
'url': docManager.getServerUrl(True, request) + '/static/sample.docx'
'url': docManager.getServerUrl(True, request) + '/assets?filename=sample.docx'
}
# recipient data for mail merging
@ -326,7 +326,7 @@ def edit(request):
if jwtManager.isEnabled(): # if the secret key to generate token exists
edConfig['token'] = jwtManager.encode(edConfig) # encode the edConfig object into a token
dataInsertImage['token'] = jwtManager.encode(dataInsertImage) # encode the dataInsertImage object into a token
dataCompareFile['token'] = jwtManager.encode(dataCompareFile) # encode the dataCompareFile object into a token
dataDocument['token'] = jwtManager.encode(dataDocument) # encode the dataDocument object into a token
dataSpreadsheet['token'] = jwtManager.encode(dataSpreadsheet) # encode the dataSpreadsheet object into a token
hist = historyManager.getHistoryObject(storagePath, filename, docKey, fileUri, isEnableDirectUrl, request) # get the document history
@ -338,7 +338,7 @@ def edit(request):
'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
'dataCompareFile': dataCompareFile, # document which will be compared with the current document
'dataDocument': dataDocument, # document which will be compared with the current document
'dataSpreadsheet': json.dumps(dataSpreadsheet), # recipient data for mail merging
'usersForMentions': json.dumps(usersForMentions) if user.id !='uid-0' else None
}

View File

@ -122,8 +122,10 @@
};
// the user is trying to select document for comparing by clicking the Document from Storage button
var onRequestCompareFile = function() {
docEditor.setRevisedFile({{ dataCompareFile | safe }}); // select a document for comparing
var onRequestSelectDocument = function(event) {
var data = {{ dataDocument | safe }};
data.c = event.data.c;
docEditor.setRequestedDocument(data); // select a document for comparing
};
// the user is trying to select recipients data by clicking the Mail merge button
@ -217,7 +219,7 @@
'onMakeActionLink': onMakeActionLink,
'onMetaChange': onMetaChange,
'onRequestInsertImage': onRequestInsertImage,
'onRequestCompareFile': onRequestCompareFile,
'onRequestSelectDocument': onRequestSelectDocument,
"onRequestSelectSpreadsheet": onRequestSelectSpreadsheet,
'onRequestRestore': onRequestRestore
};

View File

@ -30,7 +30,7 @@ class ConfigurationManager
sig { void }
def initialize
@version = '1.6.0'
@version = '1.7.0'
end
sig { returns(T.nilable(URI::Generic)) }

View File

@ -310,14 +310,14 @@ class FileModel
end
# get compared file information
def get_compare_file
def dataDocument
compare_file = is_enable_direct_url == true ? {
:fileType => "docx", # file type
:url => DocumentHelper.get_server_url(true) + "/assets/sample/sample.docx", # server url to the compared file
:directUrl => DocumentHelper.get_server_url(false) + "/assets/sample/sample.docx" # direct url to the compared file
:url => DocumentHelper.get_server_url(true) + "/asset?fileName=sample.docx", # server url to the compared file
:directUrl => DocumentHelper.get_server_url(false) + "/asset?fileName=sample.docx" # direct url to the compared file
} : {
:fileType => "docx", # file type
:url => DocumentHelper.get_server_url(true) + "/assets/sample/sample.docx" # server url to the compared file
:url => DocumentHelper.get_server_url(true) + "/asset?fileName=sample.docx" # server url to the compared file
}
if JwtHelper.is_enabled # check if a secret key to generate token exists or not

View File

@ -107,8 +107,10 @@
};
// the user is trying to select document for comparing by clicking the Document from Storage button
var onRequestCompareFile = function() {
docEditor.setRevisedFile(<%= raw @file.get_compare_file.to_json %>); // select a document for comparing
var onRequestSelectDocument = function(event) {
var data = <%= raw @file.dataDocument.to_json %>;
data.c = event.data.c;
docEditor.setRequestedDocument(data); // select a document for comparing
};
// the user is trying to select recipients data by clicking the Mail merge button
@ -200,7 +202,7 @@
'onMakeActionLink': onMakeActionLink,
'onMetaChange': onMetaChange,
'onRequestInsertImage': onRequestInsertImage,
'onRequestCompareFile': onRequestCompareFile,
'onRequestSelectDocument': onRequestSelectDocument,
'onRequestSelectSpreadsheet': onRequestSelectSpreadsheet,
'onRequestRestore': onRequestRestore
};

View File

@ -29,6 +29,9 @@ services:
build:
context: .
target: proxy
depends_on:
- document-server
- example
ports:
- "80:80"
- "8080:8080"