mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fcb807471f | |||
| 50a4ddbd11 | |||
| 01d1dc4274 | |||
| 1447b304eb | |||
| 8e79c6448f | |||
| badf3c7d49 | |||
| 342b31f7d7 | |||
| 0ae8f5d396 | |||
| 7a238c2b73 | |||
| 0b4c67e552 | |||
| f5391051b1 | |||
| 01c8a940d4 | |||
| 579992e40b | |||
| 3a2218a466 | |||
| 0ea28f525f | |||
| 33363f6144 | |||
| da8bdca022 | |||
| c4eccc5ee8 | |||
| ab13745cf6 | |||
| 97f07e4275 | |||
| 7c3e250797 | |||
| 32ab794f11 | |||
| 800ef84f84 | |||
| a7e4036667 | |||
| 4f589a7394 | |||
| a3abb58d72 | |||
| 17536df8e5 | |||
| 2e8a483a0c | |||
| a0aa7b4fd0 | |||
| 8b720beffa | |||
| a1c286cbaa | |||
| fc377b967d | |||
| b2de5eff4c | |||
| 02439f3699 | |||
| 2429f21a84 | |||
| aa0a4b5400 | |||
| a28300848b | |||
| fec0e87218 | |||
| efbace1e8b | |||
| 35e479355a | |||
| 32c91b9016 | |||
| 183d165c00 | |||
| a996f2c3c3 | |||
| 782243eb86 | |||
| f058d68126 | |||
| a8f07fce4d | |||
| 025bd1068d | |||
| 1da93ce071 | |||
| 837e34de37 | |||
| 20c4ec1b78 | |||
| 0068b6d87d | |||
| e3a088ccaf | |||
| 5865fedbe7 | |||
| 24a26fd530 | |||
| a5f91bc14f | |||
| a722b04226 | |||
| 9a1110a56e | |||
| 707122013f | |||
| f9ed5edf89 | |||
| dbf6766897 | |||
| a60c594505 | |||
| 2d0e6c0d3f | |||
| 63e7461995 | |||
| d2491ae6b7 | |||
| 7e36939392 | |||
| afec51b296 | |||
| 016611ba52 | |||
| 73d1011e8a |
@ -1,5 +1,7 @@
|
||||
# Change Log
|
||||
|
||||
## 1.6.0
|
||||
- nodejs: setUsers for region protection
|
||||
- si skin languages
|
||||
- fix "no" skin languages
|
||||
- anonymous can't change viewer to edit
|
||||
|
||||
@ -220,6 +220,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
var fileName = GetCorrectName(demoName); // get a file name with an index if the file with such a name already exists
|
||||
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, StoragePath(fileName)); // copy file to the storage directory
|
||||
File.SetLastWriteTime(StoragePath(fileName), DateTime.Now);
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
@ -236,6 +236,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
@ -244,6 +245,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
|
||||
@ -249,14 +249,14 @@ namespace OnlineEditorsExampleMVC
|
||||
// get the url and file type of the converted file
|
||||
Dictionary<string, string> newFileData;
|
||||
var result = ServiceConverter.GetConvertedData(downloadUri.ToString(), extension, internalExtension, key, true, out newFileData, filePass, lang);
|
||||
var newFileUri = newFileData["fileUrl"];
|
||||
var newFileType = "." + newFileData["fileType"];
|
||||
if (result != 100)
|
||||
{
|
||||
context.Response.Write("{ \"step\" : \"" + result + "\", \"filename\" : \"" + fileName + "\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
var newFileUri = newFileData["fileUrl"];
|
||||
var newFileType = "." + newFileData["fileType"];
|
||||
// get a file name of an internal file extension with an index if the file with such a name already exists
|
||||
var correctName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + newFileType);
|
||||
|
||||
@ -659,10 +659,12 @@ namespace OnlineEditorsExampleMVC
|
||||
return;
|
||||
}
|
||||
|
||||
var directUrl = (bool)body["directUrl"];
|
||||
|
||||
var data = new Dictionary<string, object>() {
|
||||
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower() },
|
||||
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower().Trim('.') },
|
||||
{ "url", DocManagerHelper.GetDownloadUrl(fileName)},
|
||||
{ "directUrl", DocManagerHelper.GetDownloadUrl(fileName) },
|
||||
{ "directUrl", directUrl ? DocManagerHelper.GetDownloadUrl(fileName, false) : null },
|
||||
{ "referenceData", new Dictionary<string, string>()
|
||||
{
|
||||
{ "fileKey", jss.Serialize(new Dictionary<string, object>{
|
||||
@ -670,7 +672,7 @@ namespace OnlineEditorsExampleMVC
|
||||
{"userAddress", HttpUtility.UrlEncode(DocManagerHelper.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))}
|
||||
})
|
||||
},
|
||||
{"instanceId", DocManagerHelper.GetServerUrl(false) }
|
||||
{ "instanceId", DocManagerHelper.GetServerUrl(false) }
|
||||
}
|
||||
},
|
||||
{ "path", fileName }
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.5.1"/>
|
||||
<add key="version" value="1.6.0"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
<add key="files.docservice.verify-peer-off" value="true"/>
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
@ -489,13 +489,13 @@ namespace OnlineEditorsExample
|
||||
// get the url and file type of the converted file
|
||||
Dictionary<string, string> newFileData;
|
||||
var result = ServiceConverter.GetConvertedData(fileUrl.ToString() , extension, internalExtension, key, true, out newFileData, filePass, lang);
|
||||
var newFileUri = newFileData["fileUrl"];
|
||||
var newFileType = "." + newFileData["fileType"];
|
||||
if (result != 100)
|
||||
{
|
||||
return "{ \"step\" : \"" + result + "\", \"filename\" : \"" + _fileName + "\"}";
|
||||
}
|
||||
|
||||
var newFileUri = newFileData["fileUrl"];
|
||||
var newFileType = "." + newFileData["fileType"];
|
||||
// get a file name of an internal file extension with an index if the file with such a name already exists
|
||||
var fileName = GetCorrectName(Path.GetFileNameWithoutExtension(_fileName) + newFileType);
|
||||
|
||||
|
||||
@ -632,6 +632,7 @@ namespace OnlineEditorsExample
|
||||
|
||||
var filePath = _Default.StoragePath(FileName, null);
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, filePath); // copy this file to the storage directory
|
||||
File.SetLastWriteTime(filePath, DateTime.Now);
|
||||
|
||||
// create a json file with file meta data
|
||||
var id = request.Cookies.GetOrDefault("uid", null);
|
||||
|
||||
@ -477,10 +477,12 @@ namespace OnlineEditorsExample
|
||||
return;
|
||||
}
|
||||
|
||||
var directUrl = (bool) body["directUrl"];
|
||||
|
||||
var data = new Dictionary<string, object>() {
|
||||
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower() },
|
||||
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower().Trim('.') },
|
||||
{ "url", DocEditor.getDownloadUrl(fileName)},
|
||||
{ "directUrl", DocEditor.getDownloadUrl(fileName) },
|
||||
{ "directUrl", directUrl ? DocEditor.getDownloadUrl(fileName, false) : null},
|
||||
{ "referenceData", new Dictionary<string, string>()
|
||||
{
|
||||
{ "fileKey", jss.Serialize(new Dictionary<string, object>{
|
||||
|
||||
@ -236,6 +236,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
@ -244,6 +245,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.5.1"/>
|
||||
<add key="version" value="1.6.0"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
<add key="files.docservice.token.useforrequest" value="true" />
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ import com.onlyoffice.integration.documentserver.util.service.ServiceConverter;
|
||||
import com.onlyoffice.integration.documentserver.managers.document.DocumentManager;
|
||||
import com.onlyoffice.integration.documentserver.managers.callback.CallbackManager;
|
||||
import org.json.simple.JSONObject;
|
||||
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;
|
||||
@ -64,6 +65,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -234,6 +236,9 @@ public class FileController {
|
||||
throw new RuntimeException("Input stream is null");
|
||||
}
|
||||
|
||||
// remove source file
|
||||
storageMutator.deleteFile(fileName);
|
||||
|
||||
// create the converted file with input stream
|
||||
storageMutator.createFile(Path.of(storagePathBuilder.getFileLocation(correctedName)), stream);
|
||||
fileName = correctedName;
|
||||
@ -459,18 +464,18 @@ public class FileController {
|
||||
@ResponseBody
|
||||
public String reference(@RequestBody final JSONObject body) {
|
||||
try {
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
|
||||
String userAddress = "";
|
||||
String fileName = "";
|
||||
|
||||
if (body.containsKey("referenceData")) {
|
||||
JSONObject referenceDataObj = (JSONObject) body.get("referenceData");
|
||||
LinkedHashMap referenceDataObj = (LinkedHashMap) body.get("referenceData");
|
||||
String instanceId = (String) referenceDataObj.get("instanceId");
|
||||
|
||||
if (instanceId.equals(storagePathBuilder.getServerUrl(false))) {
|
||||
JSONObject fileKey = (JSONObject) referenceDataObj.get("fileKey");
|
||||
JSONObject fileKey = (JSONObject) parser.parse((String) referenceDataObj.get("fileKey"));
|
||||
userAddress = (String) fileKey.get("userAddress");
|
||||
if (userAddress.equals(InetAddress.getLocalHost().getHostAddress())) {
|
||||
fileName = (String) fileKey.get("fileName");
|
||||
@ -496,18 +501,20 @@ public class FileController {
|
||||
return "{ \"error\": \"File not found\"}";
|
||||
}
|
||||
|
||||
boolean directUrl = (boolean) body.get("directUrl");
|
||||
|
||||
HashMap<String, Object> fileKey = new HashMap<>();
|
||||
fileKey.put("fileName", fileName);
|
||||
fileKey.put("userAddress", InetAddress.getLocalHost().getHostAddress());
|
||||
|
||||
HashMap<String, Object> referenceData = new HashMap<>();
|
||||
referenceData.put("instanceId", storagePathBuilder.getServerUrl(true));
|
||||
referenceData.put("fileKey", fileKey);
|
||||
referenceData.put("fileKey", gson.toJson(fileKey));
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("fileType", fileUtility.getFileExtension(fileName));
|
||||
data.put("fileType", fileUtility.getFileExtension(fileName).replace(".", ""));
|
||||
data.put("url", documentManager.getDownloadUrl(fileName, true));
|
||||
data.put("directUrl", documentManager.getDownloadUrl(fileName, true));
|
||||
data.put("directUrl", directUrl ? documentManager.getDownloadUrl(fileName, false) : null);
|
||||
data.put("referenceData", referenceData);
|
||||
data.put("path", fileName);
|
||||
|
||||
|
||||
@ -106,17 +106,17 @@ public class DefaultServiceConverter implements ServiceConverter {
|
||||
|
||||
connection.connect();
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte); // write bytes to the output stream
|
||||
os.flush(); // force write data to the output stream that can be cached in the current thread
|
||||
}
|
||||
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != HttpStatus.OK.value()) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new RuntimeException("Convertation service returned status: " + statusCode);
|
||||
}
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte); // write bytes to the output stream
|
||||
os.flush(); // force write data to the output stream that can be cached in the current thread
|
||||
}
|
||||
|
||||
response = connection.getInputStream(); // get the input stream
|
||||
jsonString = convertStreamToString(response); // convert the response stream into a string
|
||||
} finally {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
server.version=1.5.1
|
||||
server.version=1.6.0
|
||||
|
||||
server.address=
|
||||
server.port=4000
|
||||
@ -28,7 +28,7 @@ files.docservice.token-use-for-request=true
|
||||
|
||||
files.docservice.verify-peer-off=true
|
||||
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
|
||||
spring.datasource.url=jdbc:h2:mem:usersdb
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
@ -38,6 +38,8 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
hibernate.ddl-auto
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.path=/h2
|
||||
spring.servlet.multipart.max-file-size=5MB
|
||||
spring.servlet.multipart.max-request-size=5MB
|
||||
|
||||
url.index=/
|
||||
url.converter=/converter
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
|
||||
// the user is trying to switch the document from the viewing into the editing mode
|
||||
var onRequestEditRights = function () {
|
||||
location.href = location.href.replace(RegExp("\&?action=view\&?", "i"), "");
|
||||
location.href = location.href.replace(RegExp("\&?action=view", "i"), "");
|
||||
};
|
||||
|
||||
// an error or some other specific event occurs
|
||||
|
||||
@ -78,6 +78,11 @@ public class IndexServlet extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
|
||||
// charset for response headers if upload or convert
|
||||
if (action.matches("upload|convert")) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
}
|
||||
|
||||
DocumentManager.init(request, response);
|
||||
|
||||
// create a variable to display information about the application and error messages
|
||||
@ -310,9 +315,9 @@ public class IndexServlet extends HttpServlet {
|
||||
|
||||
connection.disconnect();
|
||||
|
||||
// remove source file ?
|
||||
// File sourceFile = new File(DocumentManager.StoragePath(fileName, null));
|
||||
// sourceFile.delete();
|
||||
// remove source file
|
||||
File sourceFile = new File(DocumentManager.storagePath(fileName, null));
|
||||
sourceFile.delete();
|
||||
|
||||
fileName = correctName;
|
||||
|
||||
@ -695,6 +700,8 @@ public class IndexServlet extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean directUrl = (boolean) body.get("directUrl");
|
||||
|
||||
HashMap<String, Object> fileKey = new HashMap<>();
|
||||
fileKey.put("fileName", fileName);
|
||||
fileKey.put("userAddress", DocumentManager.curUserHostAddress(null));
|
||||
@ -704,9 +711,9 @@ public class IndexServlet extends HttpServlet {
|
||||
referenceData.put("fileKey", gson.toJson(fileKey));
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("fileType", FileUtility.getFileExtension(fileName));
|
||||
data.put("fileType", FileUtility.getFileExtension(fileName).replace(".", ""));
|
||||
data.put("url", DocumentManager.getDownloadUrl(fileName, true));
|
||||
data.put("directUrl", DocumentManager.getDownloadUrl(fileName, true));
|
||||
data.put("directUrl", directUrl ? DocumentManager.getDownloadUrl(fileName, false) : null);
|
||||
data.put("referenceData", referenceData);
|
||||
data.put("path", fileName);
|
||||
|
||||
|
||||
@ -213,14 +213,15 @@ public final class ServiceConverter {
|
||||
|
||||
connection.connect();
|
||||
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte);
|
||||
}
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != HttpServletResponse.SC_OK) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new Exception("Conversion service returned status: " + statusCode);
|
||||
}
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte);
|
||||
}
|
||||
|
||||
InputStream stream = connection.getInputStream();
|
||||
|
||||
|
||||
@ -86,11 +86,11 @@ public final class Users {
|
||||
true, new ArrayList<String>(), descriptionUserSecond, false));
|
||||
add(new User("uid-3", "Hamish Mitchell", "mitchell@example.com",
|
||||
"group-3", Arrays.asList("group-2"), new CommentGroups(Arrays.asList("group-3", "group-2"),
|
||||
Arrays.asList("group-2"), new ArrayList<String>()), Arrays.asList("group-2"),
|
||||
Arrays.asList("group-2"), null), Arrays.asList("group-2"),
|
||||
false, Arrays.asList("copy", "download", "print"),
|
||||
descriptionUserThird, false));
|
||||
add(new User("uid-0", null, null,
|
||||
"", null, new CommentGroups(), new ArrayList<String>(),
|
||||
"", null, null, null,
|
||||
null, Arrays.asList("protect"), descriptionUserZero, false));
|
||||
}};
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
version=1.5.1
|
||||
version=1.6.0
|
||||
|
||||
filesize-max=5242880
|
||||
storage-folder=app_data
|
||||
@ -16,7 +16,7 @@ files.docservice.url.api=web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=web-apps/apps/api/documents/cache-scripts.html
|
||||
files.docservice.url.example=
|
||||
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
|
||||
files.docservice.secret=
|
||||
files.docservice.header=Authorization
|
||||
|
||||
@ -1019,6 +1019,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
directUrl: !userDirectUrl ? null : req.docManager.getServerUrl() + "/csv",
|
||||
},
|
||||
usersForMentions: user.id != "uid-0" ? users.getUsersForMentions(user.id) : null,
|
||||
usersForProtect: user.id != "uid-0" ? users.getUsersForProtect(user.id) : null,
|
||||
};
|
||||
|
||||
if (cfgSignatureEnable) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.5.1",
|
||||
"version": "1.6.0",
|
||||
"log": {
|
||||
"appenders": [
|
||||
{
|
||||
@ -54,8 +54,8 @@
|
||||
"be": "Belarusian",
|
||||
"bg": "Bulgarian",
|
||||
"ca": "Catalan",
|
||||
"zh": "Chinese",
|
||||
"zh-TW": "Chinese (Taiwan)",
|
||||
"zh": "Chinese (Simplified)",
|
||||
"zh-TW": "Chinese (Traditional)",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
"nl": "Dutch",
|
||||
|
||||
@ -178,7 +178,7 @@ docManager.prototype.getServerPath = function () {
|
||||
|
||||
// get host address from the request
|
||||
docManager.prototype.getServerHost = function () {
|
||||
return this.getProtocol() + "://" + (this.req.headers["x-forwarded-host"] || this.req.headers["host"]);
|
||||
return this.getProtocol() + "://" + (this.req.headers["x-forwarded-host"] || this.req.headers["host"]) + (this.req.headers["x-forwarded-prefix"] || "");
|
||||
};
|
||||
|
||||
// get protocol from the request
|
||||
|
||||
@ -77,7 +77,7 @@ var users = [
|
||||
remove: ["group-2"]
|
||||
}, ["group-2", ""],
|
||||
true, [], descr_user_2, false), // own and without group
|
||||
new User("uid-3", "Hamish Mitchell", "mitchell@example.com",
|
||||
new User("uid-3", "Hamish Mitchell", null,
|
||||
"group-3", ["group-2"], {
|
||||
view: ["group-3", "group-2"],
|
||||
edit: ["group-2"],
|
||||
@ -119,7 +119,7 @@ users.getUser = function (id) {
|
||||
return result ? result : this[0];
|
||||
};
|
||||
|
||||
// get a list of users with their name and email
|
||||
// get a list of users with their name and email for mentions
|
||||
users.getUsersForMentions = function (id) {
|
||||
var result = [];
|
||||
this.forEach(user => {
|
||||
@ -133,4 +133,19 @@ users.getUsersForMentions = function (id) {
|
||||
return result;
|
||||
};
|
||||
|
||||
// get a list of users with their name, id and email for protect
|
||||
users.getUsersForProtect = function (id) {
|
||||
var result = [];
|
||||
this.forEach(user => {
|
||||
if (user.id != id && user.name != null) {
|
||||
result.push({
|
||||
email: user.email,
|
||||
id: user.id,
|
||||
name: user.name
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = users;
|
||||
|
||||
@ -139,9 +139,22 @@
|
||||
docEditor.setMailMergeRecipients(<%- JSON.stringify(dataMailMergeRecipients) %>); // insert recipient data for mail merge into the file
|
||||
};
|
||||
|
||||
var onRequestUsers = function () {
|
||||
docEditor.setUsers({ // set a list of users to mention in the comments
|
||||
"users": <%- JSON.stringify(usersForMentions) %>
|
||||
var onRequestUsers = function (event) {
|
||||
if (event && event.data){
|
||||
var c = event.data.c;
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
case "protect":
|
||||
var users = <%- JSON.stringify(usersForProtect) %>;
|
||||
break;
|
||||
default:
|
||||
users = <%- JSON.stringify(usersForMentions) %>;
|
||||
}
|
||||
|
||||
docEditor.setUsers({
|
||||
"c": c,
|
||||
"users": users,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -252,7 +252,8 @@
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script type="text/javascript" src="javascripts/jquery-1.8.2.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-3.6.4.min.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-migrate-3.4.1.min.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-ui.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery.blockUI.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery.iframe-transport.js"></script>
|
||||
|
||||
@ -250,7 +250,7 @@ function convert()
|
||||
$post = json_decode(file_get_contents('php://input'), true);
|
||||
$fileName = basename($post["filename"]);
|
||||
$filePass = $post["filePass"];
|
||||
$lang = $_COOKIE["ulang"];
|
||||
$lang = $_COOKIE["ulang"] ?? "";
|
||||
$extension = mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
$internalExtension = "ooxml";
|
||||
$configManager = new ConfigManager();
|
||||
@ -445,8 +445,8 @@ function download()
|
||||
$fileName = realpath($configManager->getConfig("storagePath"))
|
||||
=== $configManager->getConfig("storagePath") ?
|
||||
$_GET["fileName"] : basename($_GET["fileName"]); // get the file name
|
||||
$userAddress = $_GET["userAddress"];
|
||||
$isEmbedded = $_GET["&dmode"];
|
||||
$userAddress = $_GET["userAddress"] ?? null;
|
||||
$isEmbedded = $_GET["&dmode"] ?? null;
|
||||
$jwtManager = new JwtManager();
|
||||
|
||||
if ($jwtManager->isJwtEnabled() && $isEmbedded == null && $userAddress) {
|
||||
@ -491,8 +491,9 @@ function downloadFile($filePath)
|
||||
|
||||
// write headers to the response object
|
||||
@header('Content-Length: ' . filesize($filePath));
|
||||
@header('Content-Disposition: attachment; filename*=UTF-8\'\'' . urldecode(basename($filePath)));
|
||||
@header('Content-Disposition: attachment; filename*=UTF-8\'\'' . str_replace("+", "%20", urlencode(basename($filePath))));
|
||||
@header('Content-Type: ' . mime_content_type($filePath));
|
||||
@header('Access-Control-Allow-Origin: *');
|
||||
|
||||
if ($fd = fopen($filePath, 'rb')) {
|
||||
while (!feof($fd)) {
|
||||
@ -588,9 +589,9 @@ function reference()
|
||||
}
|
||||
|
||||
$data = [
|
||||
"fileType" => getInternalExtension($fileName),
|
||||
"fileType" => trim(getInternalExtension($fileName), '.'),
|
||||
"url" => getDownloadUrl($fileName),
|
||||
"directUrl" => $post["directUrl"] ? getDownloadUrl($fileName) : getDownloadUrl($fileName, false),
|
||||
"directUrl" => $post["directUrl"] ? getDownloadUrl($fileName, false) : null,
|
||||
"referenceData" => [
|
||||
"fileKey" => json_encode([
|
||||
"fileName" => $fileName,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.5.1",
|
||||
"version": "1.6.0",
|
||||
|
||||
"fileSizeMax": 5242880,
|
||||
"storagePath": "",
|
||||
@ -51,8 +51,8 @@
|
||||
"be": "Belarusian",
|
||||
"bg": "Bulgarian",
|
||||
"ca": "Catalan",
|
||||
"zh": "Chinese",
|
||||
"zh-TW": "Chinese (Taiwan)",
|
||||
"zh": "Chinese (Simplified)",
|
||||
"zh-TW": "Chinese (Traditional)",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
"nl": "Dutch",
|
||||
|
||||
@ -895,8 +895,9 @@ function getResponseUri($document_response, &$response_uri)
|
||||
*/
|
||||
function tryGetDefaultByType($createExt, $user)
|
||||
{
|
||||
$demoName = ($_GET["sample"] ? "sample." : "new.") . $createExt;
|
||||
$demoPath = "assets" . DIRECTORY_SEPARATOR . ($_GET["sample"] ? "sample" : "new") . DIRECTORY_SEPARATOR;
|
||||
$sample = isset($_GET["sample"]) && $_GET["sample"];
|
||||
$demoName = ($sample ? "sample." : "new.") . $createExt;
|
||||
$demoPath = "assets" . DIRECTORY_SEPARATOR . ($sample ? "sample" : "new") . DIRECTORY_SEPARATOR;
|
||||
$demoFilename = GetCorrectName($demoName);
|
||||
|
||||
if (!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . $demoPath . $demoName, getStoragePath($demoFilename))) {
|
||||
|
||||
@ -43,13 +43,14 @@ final class DocEditorView extends View
|
||||
$confgManager = new ConfigManager();
|
||||
$jwtManager = new JwtManager();
|
||||
$userList = new ExampleUsers();
|
||||
$fileId = $request["fileID"] ?? "";
|
||||
$user = $userList->getUser($request["user"]);
|
||||
$isEnableDirectUrl = isset($request["directUrl"]) ? filter_var($request["directUrl"], FILTER_VALIDATE_BOOLEAN)
|
||||
: false;
|
||||
if (!empty($externalUrl)) {
|
||||
$filename = doUpload($externalUrl);
|
||||
} else { // if the file url doesn't exist, get file name and file extension
|
||||
$filename = basename($request["fileID"]);
|
||||
$filename = basename($fileId);
|
||||
}
|
||||
$createExt = $request["fileExt"] ?? "";
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
VERSION = '1.5.1'
|
||||
VERSION = '1.6.0'
|
||||
|
||||
FILE_SIZE_MAX = 5242880
|
||||
STORAGE_PATH = 'app_data'
|
||||
@ -67,8 +67,8 @@ LANGUAGES = {
|
||||
'be': 'Belarusian',
|
||||
'bg': 'Bulgarian',
|
||||
'ca': 'Catalan',
|
||||
'zh': 'Chinese',
|
||||
'zh-TW': 'Chinese (Taiwan)',
|
||||
'zh': 'Chinese (Simplified)',
|
||||
'zh-TW': 'Chinese (Traditional)',
|
||||
'cs': 'Czech',
|
||||
'da': 'Danish',
|
||||
'nl': 'Dutch',
|
||||
|
||||
@ -293,6 +293,7 @@ def getFilesInfo(req):
|
||||
def download(filePath):
|
||||
response = FileResponse(open(filePath, 'rb'), True) # write headers to the response object
|
||||
response['Content-Length'] = os.path.getsize(filePath)
|
||||
response['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + urllib.parse.unquote(os.path.basename(filePath))
|
||||
response['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + urllib.parse.quote_plus(os.path.basename(filePath))
|
||||
response['Content-Type'] = magic.from_file(filePath, mime=True)
|
||||
response['Access-Control-Allow-Origin'] = "*"
|
||||
return response
|
||||
@ -492,9 +492,9 @@ def reference(request):
|
||||
return HttpResponse(json.dumps(response), content_type='application/json', status=404)
|
||||
|
||||
data = {
|
||||
'fileType' : fileUtils.getFileExt(fileName),
|
||||
'fileType' : fileUtils.getFileExt(fileName).replace('.', ''),
|
||||
'url' : docManager.getDownloadUrl(fileName, request),
|
||||
'directUrl' : docManager.getDownloadUrl(fileName, request) if body["directUrl"] else docManager.getDownloadUrl(fileName, request, False),
|
||||
'directUrl' : docManager.getDownloadUrl(fileName, request, False) if body["directUrl"] else None,
|
||||
'referenceData' : {
|
||||
'instanceId' : docManager.getServerUrl(False, request),
|
||||
'fileKey' : json.dumps({'fileName' : fileName, 'userAddress': request.META['REMOTE_ADDR']})
|
||||
|
||||
@ -235,6 +235,7 @@ if (typeof jQuery !== "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq("#hiddenFileName").val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
@ -243,6 +244,7 @@ if (typeof jQuery !== "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq("#hiddenFileName").val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
|
||||
@ -240,6 +240,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
@ -248,6 +249,7 @@ if (typeof jQuery != "undefined") {
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
document.location.reload();
|
||||
});
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
|
||||
@ -131,6 +131,11 @@ class HomeController < ApplicationController
|
||||
file.write(data)
|
||||
end
|
||||
|
||||
old_storage_path = DocumentHelper.storage_path(file_name, nil)
|
||||
if File.exist?(old_storage_path)
|
||||
File.delete(old_storage_path)
|
||||
end
|
||||
|
||||
file_name = correct_name
|
||||
user = Users.get_user(params[:userId])
|
||||
|
||||
@ -395,9 +400,9 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
data = {
|
||||
:fileType => DocumentHelper.get_internal_extension(fileName),
|
||||
:fileType => File.extname(fileName).downcase.delete("."),
|
||||
:url => DocumentHelper.get_download_url(fileName),
|
||||
:directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName) : DocumentHelper.get_download_url(fileName,false),
|
||||
:directUrl => body["directUrl"] ? DocumentHelper.get_download_url(fileName, false) : nil,
|
||||
:referenceData => {
|
||||
:instanceId => DocumentHelper.get_server_url(false),
|
||||
:fileKey => {:fileName => fileName,:userAddress => DocumentHelper.cur_user_host_address(nil)}.to_json
|
||||
|
||||
@ -68,13 +68,13 @@ class ServiceConverter
|
||||
req.body = payload.to_json
|
||||
res = http.request(req) # get the response
|
||||
|
||||
status_code = res.code
|
||||
status_code = res.code.to_i
|
||||
if status_code != 200 # checking status code
|
||||
raise "Conversion service returned status: #{status_code}"
|
||||
end
|
||||
|
||||
data = res.body # and take its body
|
||||
rescue TimeoutError
|
||||
rescue Timeout::Error
|
||||
# try again
|
||||
rescue => ex
|
||||
raise ex.message
|
||||
|
||||
@ -26,7 +26,7 @@ module OnlineEditorsExampleRuby
|
||||
end
|
||||
end
|
||||
|
||||
Rails.configuration.version="1.5.1"
|
||||
Rails.configuration.version="1.6.0"
|
||||
|
||||
Rails.configuration.fileSizeMax=5242880
|
||||
Rails.configuration.storagePath="app_data"
|
||||
@ -59,8 +59,8 @@ module OnlineEditorsExampleRuby
|
||||
'be' => 'Belarusian',
|
||||
'bg' => 'Bulgarian',
|
||||
'ca' => 'Catalan',
|
||||
'zh' => 'Chinese',
|
||||
'zh-TW' => 'Chinese (Taiwan)',
|
||||
'zh' => 'Chinese (Simplified)',
|
||||
'zh-TW' => 'Chinese (Traditional)',
|
||||
'cs' => 'Czech',
|
||||
'da' => 'Danish',
|
||||
'nl' => 'Dutch',
|
||||
|
||||
Reference in New Issue
Block a user