mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Compare commits
116 Commits
v99.99.99.
...
v7.2.0.194
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ee110c2d5 | |||
| ad1d93dd20 | |||
| 7805f7dc91 | |||
| a482635e3f | |||
| d2c679f6b1 | |||
| 1da452d857 | |||
| d9b8d2b7e9 | |||
| 24aee6d194 | |||
| bd108a9c77 | |||
| e737e8ed48 | |||
| 53c30fbb7d | |||
| c5217242ab | |||
| c910d5193b | |||
| 58c27f8f2f | |||
| 1ec831789b | |||
| 0510fd1354 | |||
| 25238b5614 | |||
| 901bb61883 | |||
| 7f3e6c6364 | |||
| b3512ea0ce | |||
| 642a1bd19a | |||
| ac471588de | |||
| 17674ef5bc | |||
| dc2ee2a997 | |||
| c358fa814a | |||
| 143a73e083 | |||
| c266592434 | |||
| 19ed666d56 | |||
| 84b9202af0 | |||
| 8fb698bb75 | |||
| 00f46ef080 | |||
| 5c194da95d | |||
| 0d5cebe28e | |||
| dacf72cae2 | |||
| 208b8926be | |||
| 55c4853f04 | |||
| ccae7c6a06 | |||
| dc84dd3b29 | |||
| 65d3671b09 | |||
| 1fb5ef8bfd | |||
| b630c3802b | |||
| ad3993b532 | |||
| 35ee61e011 | |||
| ee59ab3dfd | |||
| 500f076e38 | |||
| e578f29d9d | |||
| 9de9bc90a4 | |||
| 7a9ebdbbe5 | |||
| 887089bcad | |||
| 680e53823a | |||
| 33e1489cd6 | |||
| 8c90737bf6 | |||
| e5f1bc8ed6 | |||
| 985b179475 | |||
| 775d15132f | |||
| 4a4298ca10 | |||
| cdbd264ed5 | |||
| e61f6cae89 | |||
| 22039078ef | |||
| 62793a42ab | |||
| f49f96a2c2 | |||
| 2031d65adb | |||
| 7f54659d3b | |||
| a3bc13bb6e | |||
| 29ea16c124 | |||
| 6d4c8b926e | |||
| 22d2031426 | |||
| fcc51e8154 | |||
| 8cd85ad63c | |||
| 1d51688884 | |||
| 2c63a85b00 | |||
| d1545c4db4 | |||
| bd8e4d6ec7 | |||
| e1c815b574 | |||
| 4042d2bb8a | |||
| 8c9d2d80bd | |||
| 3a9259d713 | |||
| 39129a537e | |||
| dfaf552bf8 | |||
| cc8b6f3716 | |||
| 13726b3c2f | |||
| 8bcc15e320 | |||
| 8fca045dd7 | |||
| a018cc5787 | |||
| 054236ef8a | |||
| e662c765e6 | |||
| 058bb0d2e2 | |||
| ac78d1fc08 | |||
| 070dac6878 | |||
| cfa0fb1b74 | |||
| 1d624e6831 | |||
| fe83e98b37 | |||
| f9ea7f7b50 | |||
| 328ea46693 | |||
| 41ec2742a7 | |||
| 76fc55c2d4 | |||
| e10f3962b6 | |||
| b9859ef5ca | |||
| 1cb2b586b1 | |||
| e5d31eebbf | |||
| 1ac40c539f | |||
| 371366befa | |||
| 0bee4817e7 | |||
| ad941e0ba4 | |||
| 93c69e51ed | |||
| 8b8b7d3938 | |||
| f8f01a033e | |||
| f497f10913 | |||
| 8b2478ac71 | |||
| 391c347419 | |||
| 5a08009b7b | |||
| 4e5b65f673 | |||
| 13e3d7673b | |||
| c0a46866ce | |||
| e7b76729a4 | |||
| ce2e7f97d6 |
@ -1,5 +1,10 @@
|
||||
# Change Log
|
||||
|
||||
- nodejs: option to send directUrl
|
||||
- opening file on client by directUrl
|
||||
- offline viewer for anonymous
|
||||
- added hy, eu, zh-TW, ms, pt-PT
|
||||
|
||||
## 1.3.0
|
||||
- update empty files
|
||||
- anonymous without chat
|
||||
|
||||
@ -313,9 +313,10 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
|
||||
// create the public history url
|
||||
public static string GetHistoryDownloadUrl(string filename, string version, string file)
|
||||
public static string GetHistoryDownloadUrl(string filename, string version, string file, Boolean isServer = true)
|
||||
{
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(true))
|
||||
var userAddress = "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress));
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(isServer))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
@ -323,7 +324,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=downloadhistory"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(filename)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))
|
||||
+ userAddress
|
||||
+ "&ver=" + version
|
||||
+ "&file="+ file
|
||||
};
|
||||
@ -331,9 +332,10 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
public static string GetDownloadUrl(string fileName)
|
||||
public static string GetDownloadUrl(string fileName, Boolean isServer = true)
|
||||
{
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(true))
|
||||
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress) : "";
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(isServer))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
@ -342,6 +344,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
Query = "type=download"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))
|
||||
+ userAddress
|
||||
};
|
||||
return downloadUrl.ToString();
|
||||
}
|
||||
|
||||
@ -69,6 +69,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
};
|
||||
|
||||
private static List<User> users = new List<User>() {
|
||||
|
||||
@ -97,6 +97,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
var actionLink = request.GetOrDefault("actionLink", null); // get the action link (comment or bookmark) if it exists
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink); // get action data for the action link
|
||||
|
||||
var directUrl = DocManagerHelper.GetDownloadUrl(FileName, false);
|
||||
var createUrl = DocManagerHelper.GetCreateUrl(FileUtility.GetFileType(FileName));
|
||||
var templatesImageUrl = DocManagerHelper.GetTemplateImageUrl(FileUtility.GetFileType(FileName)); // image url for templates
|
||||
var templates = new List<Dictionary<string, string>>
|
||||
@ -125,6 +126,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
{ "title", FileName },
|
||||
{ "url", DownloadUrl },
|
||||
{ "directUrl", directUrl },
|
||||
{ "fileType", ext.Trim('.') },
|
||||
{ "key", Key },
|
||||
{
|
||||
@ -163,6 +165,11 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "mode", mode },
|
||||
{ "lang", request.Cookies.GetOrDefault("ulang", "en") },
|
||||
{ "callbackUrl", CallbackUrl }, // absolute URL to the document storage service
|
||||
{ "coEditing", editorsMode == "view" && user.id.Equals("uid-0") ?
|
||||
new Dictionary<string, object>{
|
||||
{"mode", "strict"},
|
||||
{"change", false}
|
||||
} : null },
|
||||
{ "createUrl", !user.id.Equals("uid-0") ? createUrl : null },
|
||||
{ "templates", user.templates ? templates : null },
|
||||
{
|
||||
@ -178,9 +185,9 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
// the parameters for the embedded document type
|
||||
"embedded", new Dictionary<string, object>
|
||||
{
|
||||
{ "saveUrl", FileUriUser }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", FileUriUser }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", FileUriUser }, // the absolute URL that will allow other users to share this document
|
||||
{ "saveUrl", directUrl }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", directUrl }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", directUrl }, // the absolute URL that will allow other users to share this document
|
||||
{ "toolbarDocked", "top" } // the place for the embedded viewer toolbar (top or bottom)
|
||||
}
|
||||
},
|
||||
@ -263,17 +270,23 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
dataObj.Add("key", key);
|
||||
// write file url to the data object
|
||||
string prevFileUrl;
|
||||
string directPrevFileUrl;
|
||||
if (Path.IsPathRooted(storagePath) && !string.IsNullOrEmpty(storagePath))
|
||||
{
|
||||
prevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
|
||||
directPrevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext, false)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
|
||||
}
|
||||
else {
|
||||
prevFileUrl = i == currentVersion ? FileUri
|
||||
: DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext);
|
||||
prevFileUrl = i == currentVersion ? FileUri
|
||||
: DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext);
|
||||
directPrevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext, false)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
|
||||
}
|
||||
|
||||
dataObj.Add("url", prevFileUrl);
|
||||
dataObj.Add("directUrl", directPrevFileUrl);
|
||||
dataObj.Add("version", i);
|
||||
if (i > 1) // check if the version number is greater than 1 (the file was modified)
|
||||
{
|
||||
@ -295,6 +308,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
{ "directUrl", prev["directUrl"] },
|
||||
});
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
var changesUrl = DocManagerHelper.GetHistoryDownloadUrl(FileName, (i - 1).ToString(), "diff.zip");
|
||||
@ -333,11 +347,20 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx")
|
||||
};
|
||||
|
||||
var directCompareFileUrl = new UriBuilder(DocManagerHelper.GetServerUrl(false))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx")
|
||||
};
|
||||
|
||||
// create an object with the information about the compared file
|
||||
var dataCompareFile = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "docx" },
|
||||
{ "url", compareFileUrl.ToString() }
|
||||
{ "url", compareFileUrl.ToString() },
|
||||
{ "directUrl", directCompareFileUrl.ToString()}
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
@ -362,11 +385,19 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
+ "Content\\images\\logo.png"
|
||||
};
|
||||
|
||||
var directMailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(false))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "Content\\images\\logo.png"
|
||||
};
|
||||
|
||||
// create a logo config
|
||||
var logoConfig = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "png"},
|
||||
{ "url", mailMergeUrl.ToString()}
|
||||
{ "url", mailMergeUrl.ToString()},
|
||||
{ "directUrl", directMailMergeUrl.ToString()}
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
@ -393,11 +424,21 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
Query = "type=csv"
|
||||
};
|
||||
|
||||
var directMailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(false))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=csv"
|
||||
};
|
||||
|
||||
// create a mail merge config
|
||||
var mailMergeConfig = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "csv" },
|
||||
{ "url", mailMergeUrl.ToString()}
|
||||
{ "url", mailMergeUrl.ToString()},
|
||||
{ "directUrl", directMailMergeUrl.ToString()}
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
<add key="files.docservice.verify-peer-off" value="true"/>
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|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|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, 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|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
@ -100,16 +100,17 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
public static string getDownloadUrl(string fileName)
|
||||
public static string getDownloadUrl(string fileName, Boolean isServer = true)
|
||||
{
|
||||
var downloadUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
|
||||
var downloadUrl = new UriBuilder(_Default.GetServerUrl(isServer));
|
||||
downloadUrl.Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
downloadUrl.Query = "type=download"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress));
|
||||
+ userAddress;
|
||||
return downloadUrl.ToString();
|
||||
}
|
||||
|
||||
@ -165,6 +166,7 @@ namespace OnlineEditorsExample
|
||||
var actionLink = Request.GetOrDefault("actionLink", null); // get the action link (comment or bookmark) if it exists
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink); // get action data for the action link
|
||||
|
||||
var directUrl = getDownloadUrl(FileName, false);
|
||||
var createUrl = getCreateUrl(DocumentType, editorsType);
|
||||
var templatesImageUrl = GetTemplateImageUrl(ext); // image url for templates
|
||||
var templates = new List<Dictionary<string, string>>
|
||||
@ -193,6 +195,7 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
{ "title", FileName },
|
||||
{ "url", getDownloadUrl(FileName) },
|
||||
{ "directUrl", directUrl },
|
||||
{ "fileType", ext.Trim('.') },
|
||||
{ "key", Key },
|
||||
{
|
||||
@ -231,6 +234,11 @@ namespace OnlineEditorsExample
|
||||
{ "mode", mode },
|
||||
{ "lang", Request.Cookies.GetOrDefault("ulang", "en") },
|
||||
{ "callbackUrl", CallbackUrl }, // absolute URL to the document storage service
|
||||
{ "coEditing", editorsMode == "view" && user.id.Equals("uid-0") ?
|
||||
new Dictionary<string, object>{
|
||||
{"mode", "strict"},
|
||||
{"change", false}
|
||||
} : null },
|
||||
{ "createUrl", !user.id.Equals("uid-0") ? createUrl : null },
|
||||
{ "templates", user.templates ? templates : null },
|
||||
{
|
||||
@ -246,9 +254,9 @@ namespace OnlineEditorsExample
|
||||
// the parameters for the embedded document type
|
||||
"embedded", new Dictionary<string, object>
|
||||
{
|
||||
{ "saveUrl", FileUriUser }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", FileUriUser }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", FileUriUser }, // the absolute URL that will allow other users to share this document
|
||||
{ "saveUrl", directUrl }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", directUrl }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", directUrl }, // the absolute URL that will allow other users to share this document
|
||||
{ "toolbarDocked", "top" } // the place for the embedded viewer toolbar (top or bottom)
|
||||
}
|
||||
},
|
||||
@ -360,13 +368,16 @@ namespace OnlineEditorsExample
|
||||
dataObj.Add("fileType", ext.Replace(".", ""));
|
||||
dataObj.Add("key", key);
|
||||
// write file url to the data object
|
||||
var directPrevFileUrl = i == currentVersion ? _Default.FileUri(FileName, false) : MakePublicHistoryUrl(FileName, i.ToString(), "prev" + ext, false);
|
||||
var prevFileUrl = i == currentVersion ? FileUri : MakePublicHistoryUrl(FileName, i.ToString(), "prev" + ext);
|
||||
if (Path.IsPathRooted(storagePath))
|
||||
{
|
||||
prevFileUrl = i == currentVersion ? getDownloadUrl(FileName) : getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
|
||||
directPrevFileUrl = i == currentVersion ? getDownloadUrl(FileName, false) : getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
|
||||
}
|
||||
|
||||
dataObj.Add("url", prevFileUrl); // write file url to the data object
|
||||
dataObj.Add("directUrl", directPrevFileUrl); // write direct url to the data object
|
||||
dataObj.Add("version", i);
|
||||
if (i > 1) // check if the version number is greater than 1 (the file was modified)
|
||||
{
|
||||
@ -388,6 +399,7 @@ namespace OnlineEditorsExample
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
{ "directUrl", prev["directUrl"] },
|
||||
});
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
var changesUrl = MakePublicHistoryUrl(FileName, (i - 1).ToString(), "diff.zip");
|
||||
@ -421,11 +433,17 @@ namespace OnlineEditorsExample
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "App_Themes\\images\\logo.png";
|
||||
|
||||
var DirectImageUrl = new UriBuilder(_Default.GetServerUrl(false));
|
||||
DirectImageUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "App_Themes\\images\\logo.png";
|
||||
|
||||
// create a logo config
|
||||
Dictionary<string, object> logoConfig = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "png"},
|
||||
{ "url", InsertImageUrl.ToString()}
|
||||
{ "url", InsertImageUrl.ToString()},
|
||||
{ "directUrl", DirectImageUrl.ToString()}
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
@ -447,11 +465,18 @@ namespace OnlineEditorsExample
|
||||
+ "webeditor.ashx";
|
||||
compareFileUrl.Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx");
|
||||
|
||||
var DirectFileUrl = new UriBuilder(_Default.GetServerUrl(false));
|
||||
DirectFileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
DirectFileUrl.Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx");
|
||||
|
||||
// create an object with the information about the compared file
|
||||
Dictionary<string, object> dataCompareFile = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "docx" },
|
||||
{ "url", compareFileUrl.ToString() }
|
||||
{ "url", compareFileUrl.ToString() },
|
||||
{ "directUrl", DirectFileUrl.ToString() }
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
@ -474,11 +499,19 @@ namespace OnlineEditorsExample
|
||||
+ "webeditor.ashx";
|
||||
mailmergeUrl.Query = "type=csv";
|
||||
|
||||
var DirectMailMergeUrl = new UriBuilder(_Default.GetServerUrl(false));
|
||||
DirectMailMergeUrl.Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
DirectMailMergeUrl.Query = "type=csv";
|
||||
|
||||
// create a mail merge config
|
||||
Dictionary<string, object> mailMergeConfig = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "csv" },
|
||||
{ "url", mailmergeUrl.ToString() }
|
||||
{ "url", mailmergeUrl.ToString() },
|
||||
{ "directUrl", DirectMailMergeUrl.ToString() }
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
@ -522,15 +555,16 @@ namespace OnlineEditorsExample
|
||||
|
||||
|
||||
// create the public history url
|
||||
private string MakePublicHistoryUrl(string filename, string version, string file)
|
||||
private string MakePublicHistoryUrl(string filename, string version, string file, Boolean isServer = true)
|
||||
{
|
||||
var fileUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
|
||||
var fileUrl = new UriBuilder(_Default.GetServerUrl(isServer));
|
||||
fileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
fileUrl.Query = "type=downloadhistory&fileName=" + HttpUtility.UrlEncode(filename)
|
||||
+ "&ver=" + version + "&file=" + file
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress));
|
||||
+ userAddress;
|
||||
return fileUrl.ToString();
|
||||
}
|
||||
|
||||
|
||||
@ -68,6 +68,7 @@ namespace OnlineEditorsExample
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
};
|
||||
|
||||
private static List<User> users = new List<User>() {
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
<add key="files.docservice.header" value="Authorization" />
|
||||
<add key="files.docservice.verify-peer-off" value="true"/>
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|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|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, 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|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
@ -43,7 +43,8 @@ public class ExampleData {
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat"
|
||||
"Can't view chat",
|
||||
"View file without collaboration"
|
||||
);
|
||||
List<String> description_user_1 = List.of( // the description for user 1
|
||||
"File author by default",
|
||||
|
||||
@ -138,6 +138,7 @@ public class EditorController {
|
||||
Map<String, Object> dataInsertImage = new HashMap<>();
|
||||
dataInsertImage.put("fileType", "png");
|
||||
dataInsertImage.put("url", storagePathBuilder.getServerUrl(true) + "/css/img/logo.png");
|
||||
dataInsertImage.put("directUrl", storagePathBuilder.getServerUrl(false) + "/css/img/logo.png");
|
||||
|
||||
// check if the document token is enabled
|
||||
if(jwtManager.tokenEnabled()){
|
||||
@ -152,6 +153,7 @@ public class EditorController {
|
||||
Map<String, Object> dataCompareFile = new HashMap<>();
|
||||
dataCompareFile.put("fileType", "docx");
|
||||
dataCompareFile.put("url", storagePathBuilder.getServerUrl(true) + "/assets?name=sample.docx");
|
||||
dataCompareFile.put("directUrl", storagePathBuilder.getServerUrl(false) + "/assets?name=sample.docx");
|
||||
|
||||
// check if the document token is enabled
|
||||
if(jwtManager.tokenEnabled()){
|
||||
@ -166,6 +168,7 @@ public class EditorController {
|
||||
Map<String, Object> dataMailMergeRecipients = new HashMap<>(); // get recipients data for mail merging
|
||||
dataMailMergeRecipients.put("fileType", "csv");
|
||||
dataMailMergeRecipients.put("url", storagePathBuilder.getServerUrl(true) + "/csv");
|
||||
dataMailMergeRecipients.put("directUrl", storagePathBuilder.getServerUrl(false) + "/csv");
|
||||
|
||||
// check if the document token is enabled
|
||||
if(jwtManager.tokenEnabled()){
|
||||
|
||||
@ -164,7 +164,7 @@ public class FileController {
|
||||
public String convert(@RequestBody Converter body, // convert a file
|
||||
@CookieValue("uid") String uid, @CookieValue("ulang") String lang){
|
||||
String fileName = body.getFileName(); // get file name
|
||||
String fileUri = documentManager.getDownloadUrl(fileName); // get URL for downloading a file with the specified name
|
||||
String fileUri = documentManager.getDownloadUrl(fileName, true); // get URL for downloading a file with the specified name
|
||||
String filePass = body.getFilePass() != null ? body.getFilePass() : null; // get file password if it exists
|
||||
String fileExt = fileUtility.getFileExtension(fileName); // get file extension
|
||||
DocumentType type = fileUtility.getDocumentType(fileName); // get document type (word, cell or slide)
|
||||
|
||||
@ -118,10 +118,10 @@ public class DefaultDocumentManager implements DocumentManager {
|
||||
String hostAddress = storagePathBuilder.getStorageLocation(); // get the storage directory
|
||||
String filePathDownload = !fileName.contains(InetAddress.getLocalHost().getHostAddress()) ? fileName
|
||||
: fileName.substring(fileName.indexOf(InetAddress.getLocalHost().getHostAddress()) + InetAddress.getLocalHost().getHostAddress().length() + 1);
|
||||
|
||||
String userAddress = forDocumentServer ? "&userAddress" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
|
||||
String filePath = serverPath + "/downloadhistory?fileName=" + URLEncoder.encode(filePathDownload, java.nio.charset.StandardCharsets.UTF_8.toString())
|
||||
+ "&ver=" + version + "&file="+file
|
||||
+ "&userAddress" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
+ userAddress;
|
||||
return filePath;
|
||||
}
|
||||
catch (UnsupportedEncodingException | UnknownHostException e)
|
||||
@ -149,15 +149,15 @@ public class DefaultDocumentManager implements DocumentManager {
|
||||
}
|
||||
|
||||
// get URL to download a file
|
||||
public String getDownloadUrl(String fileName) {
|
||||
String serverPath = storagePathBuilder.getServerUrl(true);
|
||||
public String getDownloadUrl(String fileName, Boolean isServer) {
|
||||
String serverPath = storagePathBuilder.getServerUrl(isServer);
|
||||
String storageAddress = storagePathBuilder.getStorageLocation();
|
||||
try
|
||||
{
|
||||
String userAddress = isServer ? "&userAddress=" + URLEncoder.encode(storageAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
|
||||
String query = downloadUrl+"?fileName="
|
||||
+ URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString())
|
||||
+ "&userAddress="
|
||||
+ URLEncoder.encode(storageAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
+ userAddress;
|
||||
|
||||
return serverPath + query;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public interface DocumentManager {
|
||||
String getFileUri(String fileName, Boolean forDocumentServer); // get file URL
|
||||
String getHistoryFileUrl(String fileName, Integer version, String file, Boolean forDocumentServer); // get file URL
|
||||
String getCallback(String fileName); // get the callback URL
|
||||
String getDownloadUrl(String fileName); // get URL to download a file
|
||||
String getDownloadUrl(String fileName, Boolean forDocumentServer); // get URL to download a file
|
||||
ArrayList<Map<String, Object>> getFilesInfo(); // get file information
|
||||
ArrayList<Map<String, Object>> getFilesInfo(String fileId); // get file information by its ID
|
||||
String versionDir(String path, Integer version, boolean historyPath); // get the path to the file version by the history path and file version
|
||||
|
||||
@ -91,6 +91,8 @@ public class DefaultHistoryManager implements HistoryManager {
|
||||
dataObj.put("key", key);
|
||||
dataObj.put("url", i == curVer ? document.getUrl() :
|
||||
documentManager.getHistoryFileUrl(document.getTitle(), i, "prev" + fileUtility.getFileExtension(document.getTitle()), true));
|
||||
dataObj.put("directUrl", i == curVer ? document.getDirectUrl() :
|
||||
documentManager.getHistoryFileUrl(document.getTitle(), i, "prev" + fileUtility.getFileExtension(document.getTitle()), false));
|
||||
dataObj.put("version", i);
|
||||
|
||||
if (i > 1) { //check if the version number is greater than 1
|
||||
@ -109,6 +111,7 @@ public class DefaultHistoryManager implements HistoryManager {
|
||||
prevInfo.put("fileType", prev.get("fileType"));
|
||||
prevInfo.put("key", prev.get("key")); // write key and URL information about previous file version
|
||||
prevInfo.put("url", prev.get("url"));
|
||||
prevInfo.put("directUrl", prev.get("directUrl"));
|
||||
dataObj.put("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
|
||||
Integer verdiff = i - 1;
|
||||
|
||||
@ -39,4 +39,5 @@ public class Document { // the parameters pertaining to the document (title, ur
|
||||
private String urlUser; // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
private String title; // the desired file name for the viewed or edited document which will also be used as file name when the document is downloaded
|
||||
private String url; // the absolute URL where the source viewed or edited document is stored
|
||||
private String directUrl;
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ import java.util.List;
|
||||
public class EditorConfig { // the parameters pertaining to the editor interface: opening mode (viewer or editor), interface language, additional buttons, etc.
|
||||
private HashMap<String, Object> actionLink = null; // the data which contains the information about the action in the document that will be scrolled to
|
||||
private String callbackUrl; // the absolute URL to the document storage service
|
||||
private HashMap<String, Object> coEditing = null;
|
||||
private String createUrl; // the absolute URL of the document where it will be created and available after creation
|
||||
@Autowired
|
||||
private Customization customization; // the parameters which allow to customize the editor interface so that it looked like your other products (if there are any) and change the presence or absence of the additional buttons, links, change logos and editor owner details
|
||||
|
||||
@ -53,8 +53,9 @@ public class DefaultDocumentConfigurer implements DocumentConfigurer<DefaultDocu
|
||||
Permission permission = wrapper.getPermission(); // get the permission parameter from the document wrapper
|
||||
|
||||
document.setTitle(fileName); // set the title to the document config
|
||||
document.setUrl(documentManager.getDownloadUrl(fileName)); // set the URL to download a file to the document config
|
||||
document.setUrl(documentManager.getDownloadUrl(fileName, true)); // set the URL to download a file to the document config
|
||||
document.setUrlUser(documentManager.getFileUri(fileName, false)); // set the file URL to the document config
|
||||
document.setDirectUrl(documentManager.getDownloadUrl(fileName, false));
|
||||
document.setFileType(fileUtility.getFileExtension(fileName).replace(".","")); // set the file type to the document config
|
||||
document.getInfo().setFavorite(wrapper.getFavorite()); // set the favorite parameter to the document config
|
||||
|
||||
|
||||
@ -82,6 +82,10 @@ public class DefaultEditorConfigConfigurer implements EditorConfigConfigurer<Def
|
||||
config.setLang(wrapper.getLang()); // set the language to the editorConfig
|
||||
Boolean canEdit = wrapper.getCanEdit(); // check if the file of the specified type can be edited or not
|
||||
Action action = wrapper.getAction(); // get the action parameter from the editorConfig wrapper
|
||||
config.setCoEditing(action.equals(Action.view) && userIsAnon ? new HashMap<String, Object>() {{
|
||||
put("mode", "strict");
|
||||
put("change", false);
|
||||
}} : null);
|
||||
|
||||
defaultCustomizationConfigurer.configure(config.getCustomization(), DefaultCustomizationWrapper.builder() // define the customization configurer
|
||||
.action(action)
|
||||
|
||||
@ -37,7 +37,7 @@ public class DefaultEmbeddedConfigurer implements EmbeddedConfigurer<DefaultEmbe
|
||||
|
||||
public void configure(Embedded embedded, DefaultEmbeddedWrapper wrapper){ // define the embedded configurer
|
||||
if(wrapper.getType().equals(Type.embedded)) { // check if the type from the embedded wrapper is embedded
|
||||
String url = documentManager.getFileUri(wrapper.getFileName(), false); // get file URL of the specified file
|
||||
String url = documentManager.getDownloadUrl(wrapper.getFileName(), false); // get file URL of the specified file
|
||||
embedded.setEmbedUrl(url); // set the embedURL parameter to the embedded config (the absolute URL to the document serving as a source file for the document embedded into the web page)
|
||||
embedded.setSaveUrl(url); // set the saveURL parameter to the embedded config (the absolute URL that will allow the document to be saved onto the user personal computer)
|
||||
embedded.setShareUrl(url); // set the shareURL parameter to the embedded config (the absolute URL that will allow other users to share this document)
|
||||
|
||||
@ -27,7 +27,7 @@ files.docservice.header=Authorization
|
||||
|
||||
files.docservice.verify-peer-off=true
|
||||
|
||||
files.docservice.languages=en:English|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|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|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, 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|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese
|
||||
|
||||
spring.datasource.url=jdbc:h2:mem:usersdb
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
|
||||
@ -78,16 +78,19 @@ public class EditorServlet extends HttpServlet
|
||||
Map<String, Object> dataInsertImage = new HashMap<>();
|
||||
dataInsertImage.put("fileType", "png");
|
||||
dataInsertImage.put("url", DocumentManager.GetServerUrl(true) + "/css/img/logo.png");
|
||||
dataInsertImage.put("directUrl", DocumentManager.GetServerUrl(false) + "/css/img/logo.png");
|
||||
|
||||
// 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&name=sample.docx");
|
||||
dataCompareFile.put("directUrl", DocumentManager.GetServerUrl(false) + "/IndexServlet?type=assets&name=sample.docx");
|
||||
|
||||
// recipients data for mail merging
|
||||
Map<String, Object> dataMailMergeRecipients = new HashMap<>();
|
||||
dataMailMergeRecipients.put("fileType", "csv");
|
||||
dataMailMergeRecipients.put("url", DocumentManager.GetServerUrl(true) + "/IndexServlet?type=csv");
|
||||
dataMailMergeRecipients.put("directUrl", DocumentManager.GetServerUrl(false) + "/IndexServlet?type=csv");
|
||||
|
||||
// users data for mentions
|
||||
List<Map<String, Object>> usersForMentions = Users.getUsersForMentions(user.id);
|
||||
|
||||
@ -234,7 +234,7 @@ public class IndexServlet extends HttpServlet
|
||||
String fileName = FileUtility.GetFileName((String) body.get("filename"));
|
||||
String lang = cm.getCookie("ulang");
|
||||
String filePass = body.get("filePass") != null ? (String) body.get("filePass") : null;
|
||||
String fileUri = DocumentManager.GetDownloadUrl(fileName);
|
||||
String fileUri = DocumentManager.GetDownloadUrl(fileName, true);
|
||||
String fileExt = FileUtility.GetFileExtension(fileName);
|
||||
FileType fileType = FileUtility.GetFileType(fileName);
|
||||
String internalFileExt = DocumentManager.GetInternalExtension(fileType);
|
||||
|
||||
@ -51,7 +51,8 @@ public class FileModel
|
||||
// set the document parameters
|
||||
document = new Document();
|
||||
document.title = fileName;
|
||||
document.url = DocumentManager.GetDownloadUrl(fileName); // get file url
|
||||
document.url = DocumentManager.GetDownloadUrl(fileName, true); // get file url
|
||||
document.directUrl = DocumentManager.GetDownloadUrl(fileName, false); // get direct url
|
||||
document.fileType = FileUtility.GetFileExtension(fileName).replace(".", ""); // get file extension from the file name
|
||||
// generate document key
|
||||
document.key = ServiceConverter.GenerateRevisionId(DocumentManager.CurUserHostAddress(null) + "/" + fileName + "/" + Long.toString(new File(DocumentManager.StoragePath(fileName, null)).lastModified()));
|
||||
@ -77,6 +78,12 @@ public class FileModel
|
||||
// set the editor config parameters
|
||||
editorConfig = new EditorConfig(actionData);
|
||||
editorConfig.callbackUrl = DocumentManager.GetCallback(fileName); // get callback url
|
||||
|
||||
editorConfig.coEditing = mode.equals("view") && user.id.equals("uid-0") ?
|
||||
new HashMap<String, Object>() {{
|
||||
put("mode", "strict");
|
||||
put("change", false);
|
||||
}} : null;
|
||||
|
||||
if (lang != null) editorConfig.lang = lang; // write language parameter to the config
|
||||
|
||||
@ -121,7 +128,7 @@ public class FileModel
|
||||
|
||||
public void InitDesktop(String fileName)
|
||||
{
|
||||
editorConfig.InitDesktop(DocumentManager.GetDownloadUrl(fileName) + "&dmode=emb");
|
||||
editorConfig.InitDesktop(DocumentManager.GetDownloadUrl(fileName, false) + "&dmode=emb");
|
||||
}
|
||||
|
||||
// generate document token
|
||||
@ -177,7 +184,8 @@ public class FileModel
|
||||
|
||||
dataObj.put("fileType", FileUtility.GetFileExtension(document.title).substring(1));
|
||||
dataObj.put("key", key);
|
||||
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetDownloadHistoryUrl(document.title, i, "prev" + FileUtility.GetFileExtension(document.title)));
|
||||
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetDownloadHistoryUrl(document.title, i, "prev" + FileUtility.GetFileExtension(document.title), true));
|
||||
dataObj.put("directUrl", i == curVer ? document.url : DocumentManager.GetDownloadHistoryUrl(document.title, i, "prev" + FileUtility.GetFileExtension(document.title), false));
|
||||
dataObj.put("version", i);
|
||||
|
||||
if (i > 1) { //check if the version number is greater than 1
|
||||
@ -199,7 +207,7 @@ public class FileModel
|
||||
dataObj.put("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
|
||||
Integer verdiff = i - 1;
|
||||
String changesUrl = DocumentManager.GetDownloadHistoryUrl(document.title, verdiff, "diff.zip");
|
||||
String changesUrl = DocumentManager.GetDownloadHistoryUrl(document.title, verdiff, "diff.zip", true);
|
||||
dataObj.put("changesUrl", changesUrl);
|
||||
}
|
||||
|
||||
@ -247,6 +255,7 @@ public class FileModel
|
||||
{
|
||||
public String title;
|
||||
public String url;
|
||||
public String directUrl;
|
||||
public String fileType;
|
||||
public String key;
|
||||
public Info info;
|
||||
@ -269,6 +278,7 @@ public class FileModel
|
||||
public List<String> reviewGroups;
|
||||
public CommentGroups commentGroups;
|
||||
public List<String> userInfoGroups;
|
||||
//public Gson gson = new Gson();
|
||||
|
||||
// defines what can be done with a document
|
||||
public Permissions(String mode, String type, Boolean canEdit, User user)
|
||||
@ -307,6 +317,7 @@ public class FileModel
|
||||
public HashMap<String, Object> actionLink = null;
|
||||
public String mode = "edit";
|
||||
public String callbackUrl;
|
||||
public HashMap<String, Object> coEditing = null;
|
||||
public String lang = "en";
|
||||
public String createUrl;
|
||||
public List<Map<String, String>> templates;
|
||||
|
||||
@ -354,7 +354,7 @@ public class DocumentManager
|
||||
|
||||
String filePath = serverPath + "/" + storagePath + "/" + hostAddress + "/" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()).replace("+", "%20");
|
||||
if (f.isAbsolute() && f.isFile()) {
|
||||
filePath = GetDownloadUrl(fileName);
|
||||
filePath = GetDownloadUrl(fileName, true);
|
||||
if (!Files.isWritable(f.toPath())) {
|
||||
throw new SecurityException("No write permission to path: " + f.toPath());
|
||||
}
|
||||
@ -450,12 +450,13 @@ public class DocumentManager
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
public static String GetDownloadUrl(String fileName) {
|
||||
String serverPath = GetServerUrl(true);
|
||||
public static String GetDownloadUrl(String fileName, Boolean forDocumentServer) {
|
||||
String serverPath = GetServerUrl(forDocumentServer);
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
try
|
||||
{
|
||||
String query = "?type=download&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
String userAddress = forDocumentServer ? "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
|
||||
String query = "?type=download&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + userAddress;
|
||||
|
||||
return serverPath + "/IndexServlet" + query;
|
||||
}
|
||||
@ -466,12 +467,13 @@ public class DocumentManager
|
||||
}
|
||||
|
||||
// get url to download a file to History prev.*
|
||||
public static String GetDownloadHistoryUrl(String fileName, Integer version, String file) {
|
||||
String serverPath = GetServerUrl(true);
|
||||
public static String GetDownloadHistoryUrl(String fileName, Integer version, String file, Boolean forDocumentServer) {
|
||||
String serverPath = GetServerUrl(forDocumentServer);
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
try
|
||||
{
|
||||
String query = "?type=downloadhistory&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
String userAddress = forDocumentServer ? "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
|
||||
String query = "?type=downloadhistory&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + userAddress;
|
||||
query = query + "&ver=" + version + "&file=" + URLEncoder.encode(file, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
|
||||
return serverPath + "/IndexServlet" + query;
|
||||
|
||||
@ -66,6 +66,7 @@ public class Users {
|
||||
add("Can’t see anyone’s information");
|
||||
add("Can't rename files from the editor");
|
||||
add("Can't view chat");
|
||||
add("View file without collaboration");
|
||||
}};
|
||||
|
||||
private static List<User> users = new ArrayList<User>() {{
|
||||
|
||||
@ -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|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|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|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, 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|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese
|
||||
|
||||
files.docservice.secret=
|
||||
files.docservice.header=Authorization
|
||||
|
||||
@ -44,6 +44,7 @@ const cfgSignatureAuthorizationHeaderPrefix = configServer.get('token.authorizat
|
||||
const cfgSignatureSecretExpiresIn = configServer.get('token.expiresIn');
|
||||
const cfgSignatureSecret = configServer.get('token.secret');
|
||||
const urllib = require("urllib");
|
||||
const { emitWarning } = require("process");
|
||||
const verifyPeerOff = configServer.get('verify_peer_off');
|
||||
|
||||
if(verifyPeerOff) {
|
||||
@ -347,7 +348,7 @@ app.post("/convert", function (req, res) { // define a handler for converting f
|
||||
response.end();
|
||||
};
|
||||
|
||||
var callback = function (err, data) {
|
||||
var callback = async function (err, res) {
|
||||
if (err) { // if an error occurs
|
||||
if (err.name === "ConnectionTimeoutError" || err.name === "ResponseTimeoutError") { // check what type of error it is
|
||||
writeResult(fileName, 0, null); // despite the timeout errors, write the file to the result object
|
||||
@ -358,7 +359,7 @@ app.post("/convert", function (req, res) { // define a handler for converting f
|
||||
}
|
||||
|
||||
try {
|
||||
var responseUri = documentService.getResponseUri(data.toString());
|
||||
var responseUri = documentService.getResponseUri(res.toString());
|
||||
var result = responseUri.key;
|
||||
var newFileUri = responseUri.value; // get the callback url
|
||||
|
||||
@ -369,10 +370,11 @@ app.post("/convert", function (req, res) { // define a handler for converting f
|
||||
|
||||
var correctName = req.docManager.getCorrectName(fileUtility.getFileName(fileName, true) + internalFileExt); // get the file name with a new extension
|
||||
|
||||
urllib.request(newFileUri, {method: "GET"},function(err, data) {
|
||||
fileSystem.writeFileSync(req.docManager.storagePath(correctName), data); // write a file with a new extension, but with the content from the origin file
|
||||
});
|
||||
const {status, data} = await urllib.request(newFileUri, {method: "GET"});
|
||||
|
||||
if (status != 200) throw new Error("Conversion service returned status: " + status);
|
||||
|
||||
fileSystem.writeFileSync(req.docManager.storagePath(correctName), data); // write a file with a new extension, but with the content from the origin file
|
||||
fileSystem.unlinkSync(req.docManager.storagePath(fileName)); // remove file with the origin extension
|
||||
|
||||
var userAddress = req.docManager.curUserHostAddress();
|
||||
@ -467,7 +469,7 @@ app.get("/csv", function (req, res) { // define a handler for downloading csv f
|
||||
filestream.pipe(res); // send file information to the response by streams
|
||||
})
|
||||
|
||||
app.post("/track", function (req, res) { // define a handler for tracking file changes
|
||||
app.post("/track", async function (req, res) { // define a handler for tracking file changes
|
||||
|
||||
req.docManager = new docManager(req, res);
|
||||
|
||||
@ -476,11 +478,15 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
var version = 0;
|
||||
|
||||
// track file changes
|
||||
var processTrack = function (response, body, fileName, userAddress) {
|
||||
var processTrack = async function (response, body, fileName, userAddress) {
|
||||
|
||||
// callback file saving process
|
||||
var callbackProcessSave = function (downloadUri, body, fileName, userAddress, newFileName) {
|
||||
var callbackProcessSave = async function (downloadUri, body, fileName, userAddress, newFileName) {
|
||||
try {
|
||||
const {status, data} = await urllib.request(downloadUri, {method: "GET"});
|
||||
|
||||
if (status != 200) throw new Error("Document editing service returned status: " + status);
|
||||
|
||||
var storagePath = req.docManager.storagePath(newFileName, userAddress);
|
||||
|
||||
var historyPath = req.docManager.historyPath(newFileName, userAddress); // get the path to the history data
|
||||
@ -497,9 +503,12 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
var downloadZip = body.changesurl;
|
||||
if (downloadZip) {
|
||||
var path_changes = req.docManager.diffPath(newFileName, userAddress, version); // get the path to the file with document versions differences
|
||||
urllib.request(downloadZip, {method: "GET"},function(err, data) {
|
||||
const {status, data} = await urllib.request(downloadZip, {method: "GET"});
|
||||
if (status == 200) {
|
||||
fileSystem.writeFileSync(path_changes, data); // write the document version differences to the archive
|
||||
});
|
||||
} else {
|
||||
emitWarning("Document editing service returned status: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
var changeshistory = body.changeshistory || JSON.stringify(body.history);
|
||||
@ -514,9 +523,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
var path_prev = path.join(versionPath, "prev" + fileUtility.getFileExtension(fileName)); // get the path to the previous file version
|
||||
fileSystem.renameSync(req.docManager.storagePath(fileName, userAddress), path_prev); // and write it to the current path
|
||||
|
||||
urllib.request(downloadUri, {method: "GET"},function(err, data) {
|
||||
fileSystem.writeFileSync(storagePath, data);
|
||||
});
|
||||
fileSystem.writeFileSync(storagePath, data);
|
||||
|
||||
var forcesavePath = req.docManager.forcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file
|
||||
if (forcesavePath != "") { // if this path is empty
|
||||
@ -524,6 +531,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
response.write("{\"error\":1}");
|
||||
response.end();
|
||||
return;
|
||||
@ -534,7 +542,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
|
||||
// file saving process
|
||||
var processSave = function (downloadUri, body, fileName, userAddress) {
|
||||
var processSave = async function (downloadUri, body, fileName, userAddress) {
|
||||
|
||||
if (!downloadUri) {
|
||||
response.write("{\"error\":1}");
|
||||
@ -555,18 +563,18 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
var key = documentService.generateRevisionId(downloadUri);
|
||||
newFileName = req.docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress); // get the correct file name if it already exists
|
||||
try {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (err, data) {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, async function (err, data) {
|
||||
if (err) {
|
||||
callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
await callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var res = documentService.getResponseUri(data);
|
||||
callbackProcessSave(res.value, body, fileName, userAddress, fileName);
|
||||
await callbackProcessSave(res.value, body, fileName, userAddress, fileName);
|
||||
return;
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
await callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
return;
|
||||
}
|
||||
});
|
||||
@ -575,12 +583,16 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
console.log(ex);
|
||||
}
|
||||
}
|
||||
callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
await callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
};
|
||||
|
||||
// callback file force saving process
|
||||
var callbackProcessForceSave = function (downloadUri, body, fileName, userAddress, newFileName = false){
|
||||
var callbackProcessForceSave = async function (downloadUri, body, fileName, userAddress, newFileName = false){
|
||||
try {
|
||||
const {status, data} = await urllib.request(downloadUri, {method: "GET"});
|
||||
|
||||
if (status != 200) throw new Error("Document editing service returned status: " + status);
|
||||
|
||||
var downloadExt = "." + body.fileType;
|
||||
|
||||
/// TODO [Delete in version 7.0 or higher]
|
||||
@ -608,9 +620,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
}
|
||||
|
||||
urllib.request(downloadUri, {method: "GET"},function(err, data) {
|
||||
fileSystem.writeFileSync(forcesavePath, data);
|
||||
});
|
||||
fileSystem.writeFileSync(forcesavePath, data);
|
||||
|
||||
if (isSubmitForm) {
|
||||
var uid =body.actions[0].userid
|
||||
@ -627,7 +637,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
|
||||
// file force saving process
|
||||
var processForceSave = function (downloadUri, body, fileName, userAddress) {
|
||||
var processForceSave = async function (downloadUri, body, fileName, userAddress) {
|
||||
|
||||
if (!downloadUri) {
|
||||
response.write("{\"error\":1}");
|
||||
@ -645,18 +655,18 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
if (downloadExt != curExt) {
|
||||
var key = documentService.generateRevisionId(downloadUri);
|
||||
try {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (err, data) {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, async function (err, data) {
|
||||
if (err) {
|
||||
callbackProcessForceSave(downloadUri, body, fileName, userAddress, true);
|
||||
await callbackProcessForceSave(downloadUri, body, fileName, userAddress, true);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var res = documentService.getResponseUri(data);
|
||||
callbackProcessForceSave(res.value, body, fileName, userAddress, false);
|
||||
await callbackProcessForceSave(res.value, body, fileName, userAddress, false);
|
||||
return;
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
callbackProcessForceSave(downloadUri, body, fileName, userAddress, true);
|
||||
await callbackProcessForceSave(downloadUri, body, fileName, userAddress, true);
|
||||
return;
|
||||
}
|
||||
});
|
||||
@ -665,7 +675,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
console.log(ex);
|
||||
}
|
||||
}
|
||||
callbackProcessForceSave (downloadUri, body, fileName, userAddress, false);
|
||||
await callbackProcessForceSave (downloadUri, body, fileName, userAddress, false);
|
||||
};
|
||||
|
||||
if (body.status == 1) { // editing
|
||||
@ -681,10 +691,10 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
}
|
||||
} else if (body.status == 2 || body.status == 3) { // MustSave, Corrupted
|
||||
processSave(body.url, body, fileName, userAddress); // save file
|
||||
await processSave(body.url, body, fileName, userAddress); // save file
|
||||
return;
|
||||
} else if (body.status == 6 || body.status == 7) { // MustForceSave, CorruptedForceSave
|
||||
processForceSave(body.url, body, fileName, userAddress); // force save file
|
||||
await processForceSave(body.url, body, fileName, userAddress); // force save file
|
||||
return;
|
||||
}
|
||||
|
||||
@ -693,14 +703,14 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
};
|
||||
|
||||
// read request body
|
||||
var readbody = function (request, response, fileName, userAddress) {
|
||||
var readbody = async function (request, response, fileName, userAddress) {
|
||||
var content = "";
|
||||
request.on('data', function (data) { // get data from the request
|
||||
request.on('data', async function (data) { // get data from the request
|
||||
content += data;
|
||||
});
|
||||
request.on('end', function () {
|
||||
request.on('end', async function () {
|
||||
var body = JSON.parse(content);
|
||||
processTrack(response, body, fileName, userAddress); // and track file changes
|
||||
await processTrack(response, body, fileName, userAddress); // and track file changes
|
||||
});
|
||||
};
|
||||
|
||||
@ -732,14 +742,14 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
processTrack(res, body, fileName, userAddress);
|
||||
await processTrack(res, body, fileName, userAddress);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.hasOwnProperty("status")) { // if the request body has status parameter
|
||||
processTrack(res, req.body, fileName, userAddress); // track file changes
|
||||
await processTrack(res, req.body, fileName, userAddress); // track file changes
|
||||
} else {
|
||||
readbody(req, res, fileName, userAddress); // otherwise, read request body first
|
||||
await readbody(req, res, fileName, userAddress); // otherwise, read request body first
|
||||
}
|
||||
});
|
||||
|
||||
@ -754,6 +764,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
var historyData = [];
|
||||
var lang = req.docManager.getLang();
|
||||
var user = users.getUser(req.query.userid);
|
||||
var userDirectUrl = req.query.directUrl == "true";
|
||||
|
||||
var userid = user.id;
|
||||
var name = user.name;
|
||||
@ -806,7 +817,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
}
|
||||
var key = req.docManager.getKey(fileName);
|
||||
var url = req.docManager.getDownloadUrl(fileName, true);
|
||||
var urlUser = req.docManager.getDownloadUrl(fileName);
|
||||
var directUrl = req.docManager.getDownloadUrl(fileName);
|
||||
var mode = req.query.mode || "edit"; // mode: view/edit/review/comment/fillForms/embedded
|
||||
|
||||
var type = req.query.type || ""; // type: embedded/mobile/desktop
|
||||
@ -851,6 +862,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
version: i,
|
||||
key: keyVersion,
|
||||
url: i == countVersion ? url : (`${req.docManager.getServerUrl(true)}/history?fileName=${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}&useraddress=${userAddress}`),
|
||||
directUrl: !userDirectUrl ? null : i == countVersion ? directUrl : (`${req.docManager.getServerUrl(false)}/history?fileName=${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}`),
|
||||
};
|
||||
|
||||
if (i > 1 && req.docManager.existsSync(req.docManager.diffPath(fileName, userAddress, i-1))) { // check if the path to the file with document versions differences exists
|
||||
@ -858,6 +870,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
fileType: historyData[i-2].fileType,
|
||||
key: historyData[i-2].key,
|
||||
url: historyData[i-2].url,
|
||||
directUrl: !userDirectUrl ? null : historyData[i-2].directUrl,
|
||||
};
|
||||
let changesUrl = `${req.docManager.getServerUrl(true)}/history?fileName=${encodeURIComponent(fileName)}&file=diff.zip&ver=${i-1}&useraddress=${userAddress}`;
|
||||
historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object
|
||||
@ -875,7 +888,8 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
historyData.push({
|
||||
version: countVersion,
|
||||
key: key,
|
||||
url: url
|
||||
url: url,
|
||||
directUrl: !userDirectUrl ? null : directUrl,
|
||||
});
|
||||
}
|
||||
|
||||
@ -892,7 +906,8 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
name: fileName,
|
||||
ext: fileUtility.getFileExtension(fileName, true),
|
||||
uri: url,
|
||||
uriUser: urlUser,
|
||||
directUrl: !userDirectUrl ? null : directUrl,
|
||||
uriUser: directUrl,
|
||||
version: countVersion,
|
||||
created: new Date().toDateString(),
|
||||
favorite: user.favorite != null ? user.favorite : "null"
|
||||
@ -908,6 +923,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
isEdit: canEdit && (mode == "edit" || mode == "view" || mode == "filter" || mode == "blockcontent"),
|
||||
review: canEdit && (mode == "edit" || mode == "review"),
|
||||
chat: userid != "uid-0",
|
||||
coEditing: mode == "view" && userid == "uid-0" ? {mode: "strict", change: false} : null,
|
||||
comment: mode != "view" && mode != "fillForms" && mode != "embedded" && mode != "blockcontent",
|
||||
fillForms: mode != "view" && mode != "comment" && mode != "embedded" && mode != "blockcontent",
|
||||
modifyFilter: mode != "filter",
|
||||
@ -935,15 +951,18 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
historyData: historyData,
|
||||
dataInsertImage: {
|
||||
fileType: "png",
|
||||
url: req.docManager.getServerUrl(true) + "/images/logo.png"
|
||||
url: req.docManager.getServerUrl(true) + "/images/logo.png",
|
||||
directUrl: !userDirectUrl ? null : req.docManager.getServerUrl() + "/images/logo.png",
|
||||
},
|
||||
dataCompareFile: {
|
||||
fileType: "docx",
|
||||
url: req.docManager.getServerUrl(true) + "/assets/sample/sample.docx"
|
||||
url: req.docManager.getServerUrl(true) + "/assets/sample/sample.docx",
|
||||
directUrl: !userDirectUrl ? null : req.docManager.getServerUrl() + "/assets/sample/sample.docx",
|
||||
},
|
||||
dataMailMergeRecipients: {
|
||||
fileType: "csv",
|
||||
url: req.docManager.getServerUrl(true) + "/csv"
|
||||
url: req.docManager.getServerUrl(true) + "/csv",
|
||||
directUrl: !userDirectUrl ? null : req.docManager.getServerUrl() + "/csv",
|
||||
},
|
||||
usersForMentions: user.id != "uid-0" ? users.getUsersForMentions(user.id) : null,
|
||||
};
|
||||
|
||||
@ -48,11 +48,14 @@
|
||||
"verify_peer_off": true,
|
||||
"languages": {
|
||||
"en": "English",
|
||||
"hy": "Armenian",
|
||||
"az": "Azerbaijani",
|
||||
"eu": "Basque",
|
||||
"be": "Belarusian",
|
||||
"bg": "Bulgarian",
|
||||
"ca": "Catalan",
|
||||
"zh": "Chinese",
|
||||
"zh" : "Chinese (People's Republic of China)",
|
||||
"zh-TW" : "Chinese (Traditional, Taiwan)",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
"nl": "Dutch",
|
||||
@ -68,9 +71,11 @@
|
||||
"ko": "Korean",
|
||||
"lv": "Latvian",
|
||||
"lo": "Lao",
|
||||
"ms": "Malay (Malaysia)",
|
||||
"nb": "Norwegian",
|
||||
"pl": "Polish",
|
||||
"pt": "Portuguese",
|
||||
"pt" : "Portuguese (Brazil)",
|
||||
"pt-PT" : "Portuguese (Portugal)",
|
||||
"ro": "Romanian",
|
||||
"ru": "Russian",
|
||||
"sk": "Slovak",
|
||||
|
||||
@ -66,6 +66,9 @@ docManager.prototype.getCustomParams = function () {
|
||||
const lang = this.req.query.lang; // language
|
||||
params += (lang ? "&lang=" + this.getLang() : "");
|
||||
|
||||
const directUrl = this.req.query.directUrl; // directUrl
|
||||
params += (directUrl ? "&directUrl=" + (directUrl == "true") : "");
|
||||
|
||||
const fileName = this.req.query.fileName; // file name
|
||||
params += (fileName ? "&fileName=" + fileName : "");
|
||||
|
||||
|
||||
@ -61,6 +61,7 @@ var descr_user_0 = [
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
//"Can’t submit forms"
|
||||
];
|
||||
|
||||
|
||||
@ -18,12 +18,14 @@
|
||||
|
||||
var language;
|
||||
var userid;
|
||||
var directUrl;
|
||||
|
||||
if (typeof jQuery != "undefined") {
|
||||
jq = jQuery.noConflict();
|
||||
|
||||
userid = getUrlVars()["userid"];
|
||||
language = getUrlVars()["lang"];
|
||||
directUrl = getUrlVars()["directUrl"] == "true";
|
||||
|
||||
mustReload = false;
|
||||
|
||||
@ -34,19 +36,29 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
|
||||
jq("#language").change(function() {
|
||||
window.location = "?lang=" + jq(this).val() + "&userid=" + userid;
|
||||
window.location = "?lang=" + jq(this).val() + "&userid=" + userid + "&directUrl=" + directUrl;
|
||||
});
|
||||
|
||||
|
||||
if ("" != userid && undefined != userid)
|
||||
jq("#user").val(userid);
|
||||
else
|
||||
userid = jq("#user").val();
|
||||
|
||||
jq("#user").change(function() {
|
||||
window.location = "?lang=" + language + "&userid=" + jq(this).val();
|
||||
window.location = "?lang=" + language + "&userid=" + jq(this).val() + "&directUrl=" + directUrl;
|
||||
});
|
||||
|
||||
|
||||
if (directUrl)
|
||||
jq("#directUrl").prop("checked", directUrl);
|
||||
else
|
||||
directUrl = jq("#directUrl").prop("checked");
|
||||
|
||||
jq("#directUrl").change(function() {
|
||||
window.location = "?lang=" + language + "&userid=" + userid + "&directUrl=" + jq(this).prop("checked");
|
||||
});
|
||||
|
||||
|
||||
jq(function () {
|
||||
jq('#fileupload').fileupload({
|
||||
dataType: 'json',
|
||||
@ -228,7 +240,7 @@ if (typeof jQuery != "undefined") {
|
||||
if (UrlEditor == "wopi-action"){
|
||||
var url = UrlEditor + "/" + fileId + "?action=edit";
|
||||
}else{
|
||||
var url = UrlEditor + "?fileName=" + fileId + "&lang=" + language + "&userid=" + userid;
|
||||
var url = UrlEditor + "?fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
|
||||
}
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
@ -241,7 +253,7 @@ if (typeof jQuery != "undefined") {
|
||||
if (UrlEditor == "wopi-action"){
|
||||
var url = UrlEditor + "/" + fileId + "?action=view";
|
||||
}else{
|
||||
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&lang=" + language + "&userid=" + userid;
|
||||
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
|
||||
}
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
@ -251,7 +263,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?type=embedded&fileName=" + fileId + "&lang=" + language + "&userid=" + userid;
|
||||
var url = UrlEditor + "?type=embedded&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
|
||||
@ -165,7 +165,7 @@ label .checkbox {
|
||||
background-image: url("../images/file_docxf.svg");
|
||||
}
|
||||
|
||||
.create-sample {
|
||||
.side-option {
|
||||
color: #666666;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
"document": {
|
||||
"directUrl": "<%- file.directUrl %>",
|
||||
"fileType": "<%- file.ext %>",
|
||||
"info": {
|
||||
"owner": "Me",
|
||||
@ -28,6 +29,7 @@
|
||||
"editorConfig": {
|
||||
"actionLink": <%- editor.actionData %>,
|
||||
"callbackUrl": "<%- editor.callbackUrl %>",
|
||||
"coEditing": <%- JSON.stringify(editor.coEditing) %>,
|
||||
"createUrl": <%- JSON.stringify(editor.createUrl) %>,
|
||||
"customization": {
|
||||
"about": true,
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
<a class="try-editor form reload-page" target="_blank" href="editor?fileExt=docxf<%= params %>" title="Create new form template">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="create-sample">
|
||||
<label class="side-option">
|
||||
<input id="createSample" type="checkbox" class="checkbox" />With sample content
|
||||
</label>
|
||||
</div>
|
||||
@ -95,6 +95,14 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<label class="side-option">
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
|
||||
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="images/info.svg" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
@ -48,11 +48,14 @@ $GLOBALS['ExtsDocument'] = array(".doc", ".docx", ".docm",
|
||||
|
||||
$GLOBALS['LANGUAGES'] = array(
|
||||
'en' => 'English',
|
||||
'hy' => 'Armenian',
|
||||
'az' => 'Azerbaijani',
|
||||
'eu' => 'Basque',
|
||||
'be' => 'Belarusian',
|
||||
'bg' => 'Bulgarian',
|
||||
'ca' => 'Catalan',
|
||||
'zh' => 'Chinese',
|
||||
'zh' => 'Chinese (People\'s Republic of China)',
|
||||
'zh-TW' => 'Chinese (Traditional, Taiwan)',
|
||||
'cs' => 'Czech',
|
||||
'da' => 'Danish',
|
||||
'nl' => 'Dutch',
|
||||
@ -68,9 +71,11 @@ $GLOBALS['LANGUAGES'] = array(
|
||||
'ko' => 'Korean',
|
||||
'lv' => 'Latvian',
|
||||
'lo' => 'Lao',
|
||||
'ms' => 'Malay (Malaysia)',
|
||||
'nb' => 'Norwegian',
|
||||
'pl' => 'Polish',
|
||||
'pt' => 'Portuguese',
|
||||
'pt' => 'Portuguese (Brazil)',
|
||||
'pt-PT' => 'Portuguese (Portugal)',
|
||||
'ro' => 'Romanian',
|
||||
'ru' => 'Russian',
|
||||
'sk' => 'Slovak',
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
|
||||
$fileuri = FileUri($filename, true);
|
||||
$fileuriUser = realpath($GLOBALS['STORAGE_PATH']) === $GLOBALS['STORAGE_PATH'] ? getDownloadUrl($filename) . "&dmode=emb" : FileUri($filename);
|
||||
$directUrl = getDownloadUrl($filename, FALSE);
|
||||
$docKey = getDocEditorKey($filename);
|
||||
$filetype = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
@ -89,6 +90,7 @@
|
||||
"document" => [
|
||||
"title" => $filename,
|
||||
"url" => getDownloadUrl($filename),
|
||||
"directUrl" => $directUrl,
|
||||
"fileType" => $filetype,
|
||||
"key" => $docKey,
|
||||
"info" => [
|
||||
@ -117,6 +119,10 @@
|
||||
"mode" => $mode,
|
||||
"lang" => empty($_COOKIE["ulang"]) ? "en" : $_COOKIE["ulang"],
|
||||
"callbackUrl" => getCallbackUrl($filename), // absolute URL to the document storage service
|
||||
"coEditing" => $editorsMode == "view" && $user->id == "uid-0" ? [
|
||||
"mode" => "strict",
|
||||
"change" => false
|
||||
] : null,
|
||||
"createUrl" => $user->id != "uid-0" ? $createUrl : null,
|
||||
"templates" => $user->templates ? $templates : null,
|
||||
"user" => [ // the user currently viewing or editing the document
|
||||
@ -125,9 +131,9 @@
|
||||
"group" => $user->group
|
||||
],
|
||||
"embedded" => [ // the parameters for the embedded document type
|
||||
"saveUrl" => $fileuriUser, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
"embedUrl" => $fileuriUser, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
"shareUrl" => $fileuriUser, // the absolute URL that will allow other users to share this document
|
||||
"saveUrl" => $directUrl, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
"embedUrl" => $directUrl, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
"shareUrl" => $directUrl, // the absolute URL that will allow other users to share this document
|
||||
"toolbarDocked" => "top", // the place for the embedded viewer toolbar (top or bottom)
|
||||
],
|
||||
"customization" => [ // the parameters for the editor interface
|
||||
@ -146,19 +152,22 @@
|
||||
// an image for inserting
|
||||
$dataInsertImage = [
|
||||
"fileType" => "png",
|
||||
"url" => serverPath(true) . "/css/images/logo.png"
|
||||
"url" => serverPath(true) . "/css/images/logo.png",
|
||||
"directUrl" => serverPath(false) . "/css/images/logo.png"
|
||||
];
|
||||
|
||||
// a document for comparing
|
||||
$dataCompareFile = [
|
||||
"fileType" => "docx",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=assets&name=sample.docx"
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=assets&name=sample.docx",
|
||||
"directUrl" => serverPath(false) . "/webeditor-ajax.php?type=assets&name=sample.docx"
|
||||
];
|
||||
|
||||
// recipients data for mail merging
|
||||
$dataMailMergeRecipients = [
|
||||
"fileType" =>"csv",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=csv"
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=csv",
|
||||
"directUrl" => serverPath(false) . "/webeditor-ajax.php?type=csv"
|
||||
];
|
||||
|
||||
// users data for mentions
|
||||
@ -209,23 +218,25 @@
|
||||
. "&type=" . $type;
|
||||
}
|
||||
|
||||
function getHistoryDownloadUrl($fileName, $version, $file) {
|
||||
return serverPath(TRUE) . '/'
|
||||
function getHistoryDownloadUrl($fileName, $version, $file, $isServer = TRUE) {
|
||||
$userAddress = $isServer ? "&userAddress=" . getClientIp() : "";
|
||||
return serverPath($isServer) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=history"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "&ver=" . $version
|
||||
. "&file=" . urlencode($file)
|
||||
. "&userAddress=" . getClientIp();
|
||||
. $userAddress;
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
function getDownloadUrl($fileName) {
|
||||
return serverPath(TRUE) . '/'
|
||||
function getDownloadUrl($fileName, $isServer = TRUE) {
|
||||
$userAddress = $isServer ? "&userAddress=" . getClientIp() : "";
|
||||
return serverPath($isServer) . '/'
|
||||
. "webeditor-ajax.php"
|
||||
. "?type=download"
|
||||
. "&fileName=" . urlencode($fileName)
|
||||
. "&userAddress=" . getClientIp();
|
||||
. $userAddress;
|
||||
}
|
||||
|
||||
// get document history
|
||||
@ -267,12 +278,15 @@
|
||||
$dataObj["fileType"] = $fileExe;
|
||||
$dataObj["key"] = $key;
|
||||
|
||||
$directUrl = $i == $curVer ? FileUri($filename, FALSE) : getHistoryDownloadUrl($filename, $i, "prev.".$fileExe, FALSE);
|
||||
$prevFileUrl = $i == $curVer ? $fileuri : getHistoryDownloadUrl($filename, $i, "prev.".$fileExe);
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$prevFileUrl = $i == $curVer ? getDownloadUrl($filename) : getHistoryDownloadUrl($filename, $i, "prev.".$fileExe);
|
||||
$prevFileUrl = $i == $curVer ? getDownloadUrl($filename) : getHistoryDownloadUrl($filename, $i, "prev.".$fileExe);
|
||||
$directUrl = $i == $curVer ? getDownloadUrl($filename, FALSE) : getHistoryDownloadUrl($filename, $i, "prev.".$fileExe, FALSE);
|
||||
}
|
||||
|
||||
$dataObj["url"] = $prevFileUrl; // write file url to the data object
|
||||
$dataObj["directUrl"] = $directUrl; // write direct url to the data object
|
||||
$dataObj["version"] = $i;
|
||||
|
||||
if ($i > 1) { // check if the version number is greater than 1 (the document was modified)
|
||||
@ -288,7 +302,8 @@
|
||||
$dataObj["previous"] = [ // write information about previous file version to the data object
|
||||
"fileType" => $prev["fileType"],
|
||||
"key" => $prev["key"],
|
||||
"url" => $prev["url"]
|
||||
"url" => $prev["url"],
|
||||
"directUrl" => $prev["directUrl"]
|
||||
];
|
||||
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
|
||||
@ -76,6 +76,7 @@ $descr_user_0 = [
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
];
|
||||
|
||||
$users = [
|
||||
|
||||
@ -55,11 +55,14 @@ EXT_DOCUMENT = [
|
||||
|
||||
LANGUAGES = {
|
||||
'en': 'English',
|
||||
'hy': 'Armenian',
|
||||
'az': 'Azerbaijani',
|
||||
'eu': 'Basque',
|
||||
'be': 'Belarusian',
|
||||
'bg': 'Bulgarian',
|
||||
'ca': 'Catalan',
|
||||
'zh': 'Chinese',
|
||||
'zh' : 'Chinese (People\'s Republic of China)',
|
||||
'zh-TW' : 'Chinese (Traditional, Taiwan)',
|
||||
'cs': 'Czech',
|
||||
'da': 'Danish',
|
||||
'nl': 'Dutch',
|
||||
@ -75,9 +78,11 @@ LANGUAGES = {
|
||||
'ko': 'Korean',
|
||||
'lv': 'Latvian',
|
||||
'lo': 'Lao',
|
||||
'ms': 'Malay (Malaysia)',
|
||||
'nb': 'Norwegian',
|
||||
'pl': 'Polish',
|
||||
'pt': 'Portuguese',
|
||||
'pt' : 'Portuguese (Brazil)',
|
||||
'pt-PT' : 'Portuguese (Portugal)',
|
||||
'ro': 'Romanian',
|
||||
'ru': 'Russian',
|
||||
'sk': 'Slovak',
|
||||
|
||||
@ -118,10 +118,10 @@ def getCreateUrl(fileType, req):
|
||||
return f'{host}/create?fileType={fileType}'
|
||||
|
||||
# get url to download a file
|
||||
def getDownloadUrl(filename, req):
|
||||
host = getServerUrl(True, req)
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
return f'{host}/download?fileName={filename}&userAddress={curAdr}'
|
||||
def getDownloadUrl(filename, req, isServerUrl = True):
|
||||
host = getServerUrl(isServerUrl, req)
|
||||
curAdr = f'&userAddress={req.META["REMOTE_ADDR"]}' if isServerUrl else ""
|
||||
return f'{host}/download?fileName={filename}{curAdr}'
|
||||
|
||||
# get root folder for the current file
|
||||
def getRootFolder(req):
|
||||
|
||||
@ -135,10 +135,10 @@ def readFile(path):
|
||||
return stream.read()
|
||||
|
||||
# get the url to the history file version with a given extension
|
||||
def getPublicHistUri(filename, ver, file, req):
|
||||
host = docManager.getServerUrl(True, req)
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
return f'{host}/downloadhistory?fileName={filename}&ver={ver}&file={file}&userAddress={curAdr}'
|
||||
def getPublicHistUri(filename, ver, file, req, isServerUrl=True):
|
||||
host = docManager.getServerUrl(isServerUrl, req)
|
||||
curAdr = f'&userAddress={req.META["REMOTE_ADDR"]}' if isServerUrl else ''
|
||||
return f'{host}/downloadhistory?fileName={filename}&ver={ver}&file={file}{curAdr}'
|
||||
|
||||
# get the meta data of the file
|
||||
def getMeta(storagePath):
|
||||
@ -184,6 +184,7 @@ def getHistoryObject(storagePath, filename, docKey, docUrl, req):
|
||||
}
|
||||
|
||||
dataObj['url'] = docUrl if i == version else getPublicHistUri(filename, i, "prev" + fileUtils.getFileExt(filename), req) # write file url to the data object
|
||||
dataObj['directUrl'] = docManager.getDownloadUrl(filename, req, False) if i == version else getPublicHistUri(filename, i, "prev" + fileUtils.getFileExt(filename), req, False) # write file direct url to the data object
|
||||
|
||||
if i > 1: # check if the version number is greater than 1 (the file was modified)
|
||||
changes = json.loads(readFile(getChangesHistoryPath(prevVerDir))) # get the path to the changes.json file
|
||||
@ -198,7 +199,8 @@ def getHistoryObject(storagePath, filename, docKey, docUrl, req):
|
||||
prevInfo = { # write key and url information about previous file version
|
||||
'fileType': prev['fileType'],
|
||||
'key': prev['key'],
|
||||
'url': prev['url']
|
||||
'url': prev['url'],
|
||||
'directUrl': prev['directUrl']
|
||||
}
|
||||
dataObj['previous'] = prevInfo # write information about previous file version to the data object
|
||||
dataObj['changesUrl'] = getPublicHistUri(filename, i - 1, "diff.zip", req) # write the path to the diff.zip archive with differences in this file version
|
||||
|
||||
@ -82,6 +82,7 @@ descr_user_0 = [
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
]
|
||||
|
||||
USERS = [
|
||||
|
||||
@ -176,6 +176,7 @@ def edit(request):
|
||||
|
||||
fileUri = docManager.getFileUri(filename, True, request)
|
||||
fileUriUser = docManager.getDownloadUrl(filename, request) + "&dmode=emb" if os.path.isabs(config.STORAGE_PATH) else docManager.getFileUri(filename, False, request)
|
||||
directUrl = docManager.getDownloadUrl(filename, request, False)
|
||||
docKey = docManager.generateFileKey(filename, request)
|
||||
fileType = fileUtils.getFileType(filename)
|
||||
user = users.getUserFromReq(request) # get user
|
||||
@ -233,6 +234,7 @@ def edit(request):
|
||||
'document': {
|
||||
'title': filename,
|
||||
'url': docManager.getDownloadUrl(filename, request),
|
||||
'directUrl': directUrl,
|
||||
'fileType': ext[1:],
|
||||
'key': docKey,
|
||||
'info': infObj,
|
||||
@ -257,6 +259,11 @@ def edit(request):
|
||||
'mode': mode,
|
||||
'lang': lang,
|
||||
'callbackUrl': docManager.getCallbackUrl(filename, request), # absolute URL to the document storage service
|
||||
'coEditing': {
|
||||
"mode": "strict",
|
||||
"change": False
|
||||
}
|
||||
if edMode == 'view' and user.id =='uid-0' else None,
|
||||
'createUrl' : createUrl if user.id !='uid-0' else None,
|
||||
'templates' : templates if user.templates else None,
|
||||
'user': { # the user currently viewing or editing the document
|
||||
@ -265,9 +272,9 @@ def edit(request):
|
||||
'group': user.group
|
||||
},
|
||||
'embedded': { # the parameters for the embedded document type
|
||||
'saveUrl': fileUriUser, # the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
'embedUrl': fileUriUser, # the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
'shareUrl': fileUriUser, # the absolute URL that will allow other users to share this document
|
||||
'saveUrl': directUrl, # the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
'embedUrl': directUrl, # the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
'shareUrl': directUrl, # the absolute URL that will allow other users to share this document
|
||||
'toolbarDocked': 'top' # the place for the embedded viewer toolbar (top or bottom)
|
||||
},
|
||||
'customization': { # the parameters for the editor interface
|
||||
@ -286,19 +293,22 @@ def edit(request):
|
||||
# an image which will be inserted into the document
|
||||
dataInsertImage = {
|
||||
'fileType': 'png',
|
||||
'url': docManager.getServerUrl(True, request) + 'static/images/logo.png'
|
||||
'url': docManager.getServerUrl(True, request) + 'static/images/logo.png',
|
||||
'directUrl': docManager.getServerUrl(False, request) + 'static/images/logo.png'
|
||||
}
|
||||
|
||||
# a document which will be compared with the current document
|
||||
dataCompareFile = {
|
||||
'fileType': 'docx',
|
||||
'url': docManager.getServerUrl(True, request) + 'static/sample.docx'
|
||||
'url': docManager.getServerUrl(True, request) + 'static/sample.docx',
|
||||
'directUrl': docManager.getServerUrl(False, request) + 'static/sample.docx'
|
||||
}
|
||||
|
||||
# recipient data for mail merging
|
||||
dataMailMergeRecipients = {
|
||||
'fileType': 'csv',
|
||||
'url': docManager.getServerUrl(True, request) + 'csv'
|
||||
'url': docManager.getServerUrl(True, request) + 'csv',
|
||||
'directUrl': docManager.getServerUrl(False, request) + 'csv'
|
||||
}
|
||||
|
||||
# users data for mentions
|
||||
|
||||
@ -236,9 +236,10 @@ class DocumentHelper
|
||||
end
|
||||
|
||||
# get history path url
|
||||
def get_historypath_uri(file_name,version,file)
|
||||
def get_historypath_uri(file_name,version,file,is_serverUrl=true)
|
||||
# for redirection to my link
|
||||
uri = get_server_url(true) + '/downloadhistory/?fileName=' + ERB::Util.url_encode(file_name) + '&ver='+ version.to_s + '&file='+ ERB::Util.url_encode(file) + '&userAddress=' + cur_user_host_address(nil)
|
||||
user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : ""
|
||||
uri = get_server_url(is_serverUrl) + '/downloadhistory/?fileName=' + ERB::Util.url_encode(file_name) + '&ver='+ version.to_s + '&file='+ ERB::Util.url_encode(file) + user_host
|
||||
return uri
|
||||
end
|
||||
|
||||
@ -266,9 +267,10 @@ class DocumentHelper
|
||||
end
|
||||
|
||||
# get url to download a file
|
||||
def get_download_url(file_name)
|
||||
def get_download_url(file_name, is_serverUrl=true)
|
||||
|
||||
get_server_url(true) + '/download?fileName=' + ERB::Util.url_encode(file_name) + '&userAddress=' + cur_user_host_address(nil)
|
||||
user_host = is_serverUrl ? '&userAddress=' + cur_user_host_address(nil) : ""
|
||||
get_server_url(is_serverUrl) + '/download?fileName=' + ERB::Util.url_encode(file_name) + user_host
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -71,8 +71,8 @@ class FileModel
|
||||
end
|
||||
|
||||
# get url to download a file
|
||||
def download_url
|
||||
DocumentHelper.get_download_url(@file_name)
|
||||
def download_url(is_serverUrl=true)
|
||||
DocumentHelper.get_download_url(@file_name, is_serverUrl)
|
||||
end
|
||||
|
||||
# get current user host address
|
||||
@ -110,6 +110,7 @@ class FileModel
|
||||
:document => {
|
||||
:title => @file_name,
|
||||
:url => download_url,
|
||||
:directUrl => download_url(false),
|
||||
:fileType => file_ext.delete("."),
|
||||
:key => key,
|
||||
:info => {
|
||||
@ -138,6 +139,10 @@ class FileModel
|
||||
:mode => mode,
|
||||
:lang => @lang ? @lang : "en",
|
||||
:callbackUrl => callback_url, # absolute URL to the document storage service
|
||||
:coEditing => editorsmode.eql?("view") && @user.id.eql?("uid-0") ? {
|
||||
:mode => "strict",
|
||||
:change => false
|
||||
} : nil,
|
||||
:createUrl => !@user.id.eql?("uid-0") ? create_url : nil,
|
||||
:templates => @user.templates ? templates : nil,
|
||||
:user => { # the user currently viewing or editing the document
|
||||
@ -146,9 +151,9 @@ class FileModel
|
||||
:group => @user.group
|
||||
},
|
||||
:embedded => { # the parameters for the embedded document type
|
||||
:saveUrl => file_uri_user, # the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
:embedUrl => file_uri_user, # the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
:shareUrl => file_uri_user, # the absolute URL that will allow other users to share this document
|
||||
:saveUrl => download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
:embedUrl => download_url(false), # the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
:shareUrl => download_url(false), # the absolute URL that will allow other users to share this document
|
||||
:toolbarDocked => "top" # the place for the embedded viewer toolbar (top or bottom)
|
||||
},
|
||||
:customization => { # the parameters for the editor interface
|
||||
@ -219,6 +224,7 @@ class FileModel
|
||||
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["directUrl"] = i == cur_ver ? download_url(false) : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}", false)
|
||||
dataObj["version"] = i
|
||||
|
||||
if (i > 1) # check if the version number is greater than 1
|
||||
@ -240,7 +246,8 @@ class FileModel
|
||||
dataObj["previous"] = { # write key and url information about previous file version
|
||||
:fileType => prev["fileType"],
|
||||
:key => prev["key"],
|
||||
:url => prev["url"]
|
||||
:url => prev["url"],
|
||||
:directUrl => prev["directUrl"]
|
||||
}
|
||||
|
||||
# write the path to the diff.zip archive with differences in this file version
|
||||
@ -272,7 +279,8 @@ class FileModel
|
||||
def get_insert_image
|
||||
insert_image = {
|
||||
:fileType => "png", # image file type
|
||||
:url => DocumentHelper.get_server_url(true) + "/assets/logo.png" # server url to the image
|
||||
:url => DocumentHelper.get_server_url(true) + "/assets/logo.png", # server url to the image
|
||||
:directUrl => DocumentHelper.get_server_url(false) + "/assets/logo.png" # direct url to the image
|
||||
}
|
||||
|
||||
if JwtHelper.is_enabled # check if a secret key to generate token exists or not
|
||||
@ -286,7 +294,8 @@ class FileModel
|
||||
def get_compare_file
|
||||
compare_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) + "/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
|
||||
}
|
||||
|
||||
if JwtHelper.is_enabled # check if a secret key to generate token exists or not
|
||||
@ -300,7 +309,8 @@ class FileModel
|
||||
def dataMailMergeRecipients
|
||||
dataMailMergeRecipients = {
|
||||
:fileType => "csv", # file type
|
||||
:url => DocumentHelper.get_server_url(true) + "/csv" # server url to the mail merge recipients file
|
||||
:url => DocumentHelper.get_server_url(true) + "/csv", # server url to the mail merge recipients file
|
||||
:directUrl => DocumentHelper.get_server_url(false) + "/csv" # direct url to the mail merge recipients file
|
||||
}
|
||||
|
||||
if JwtHelper.is_enabled # check if a secret key to generate token exists or not
|
||||
|
||||
@ -74,7 +74,8 @@ class Users
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat"
|
||||
"Can't view chat",
|
||||
"View file without collaboration"
|
||||
];
|
||||
|
||||
@@users = [
|
||||
|
||||
@ -52,11 +52,14 @@ module OnlineEditorsExampleRuby
|
||||
|
||||
Rails.configuration.languages={
|
||||
'en' => 'English',
|
||||
'hy' => 'Armenian',
|
||||
'az' => 'Azerbaijani',
|
||||
'eu' => 'Basque',
|
||||
'be' => 'Belarusian',
|
||||
'bg' => 'Bulgarian',
|
||||
'ca' => 'Catalan',
|
||||
'zh' => 'Chinese',
|
||||
'zh' => 'Chinese (People\'s Republic of China)',
|
||||
'zh-TW' => 'Chinese (Traditional, Taiwan)',
|
||||
'cs' => 'Czech',
|
||||
'da' => 'Danish',
|
||||
'nl' => 'Dutch',
|
||||
@ -72,9 +75,11 @@ module OnlineEditorsExampleRuby
|
||||
'ko' => 'Korean',
|
||||
'lv' => 'Latvian',
|
||||
'lo' => 'Lao',
|
||||
'ms' => 'Malay (Malaysia)',
|
||||
'nb' => 'Norwegian',
|
||||
'pl' => 'Polish',
|
||||
'pt' => 'Portuguese',
|
||||
'pt' => 'Portuguese (Brazil)',
|
||||
'pt-PT' => 'Portuguese (Portugal)',
|
||||
'ro' => 'Romanian',
|
||||
'ru' => 'Russian',
|
||||
'sk' => 'Slovak',
|
||||
|
||||
Reference in New Issue
Block a user