mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Compare commits
70 Commits
v7.1.0.12
...
v99.99.99.
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f3882f892 | |||
| 727418277f | |||
| 2f795de6ad | |||
| bb28257a2d | |||
| 05ea165f77 | |||
| 7a61fac6b7 | |||
| 6efa357c19 | |||
| 15b7a07963 | |||
| ef1c53d330 | |||
| 8d194b78a1 | |||
| b8e726a7be | |||
| fbe0c18315 | |||
| ec6ea72069 | |||
| c6e3af5d3b | |||
| 63c3337938 | |||
| 0268298f2b | |||
| 32ea01784c | |||
| 71041fea9f | |||
| 8b25a7a869 | |||
| dd20d79236 | |||
| 299a68e0bd | |||
| 9ad27d2cf0 | |||
| 828115e5b0 | |||
| c0d240728d | |||
| 89c0f03318 | |||
| bc1c9f455c | |||
| df1a5f38c1 | |||
| 6559c76fbd | |||
| a7db14811f | |||
| abffa3e75f | |||
| 631f70148f | |||
| c7e7c9c19d | |||
| f2d4eb2a42 | |||
| b453aa19f0 | |||
| 7841822c54 | |||
| f3e24a8b5e | |||
| d3b962dcb8 | |||
| 95ea50210f | |||
| 40016395a8 | |||
| 8f2c2f96d2 | |||
| f9dbe89fd9 | |||
| c3a4c0a66b | |||
| edd423cd87 | |||
| e026a7027b | |||
| 11e8f40f8c | |||
| bf18854ec0 | |||
| 08d1080527 | |||
| 9ca242fe82 | |||
| b3c02a5afd | |||
| ec65ebbfb8 | |||
| 8544974202 | |||
| 90eeae5334 | |||
| 970cfa6dd0 | |||
| f04a26a0f4 | |||
| 53a58e2666 | |||
| 0ab0762aa5 | |||
| 4aeef2b873 | |||
| 60c03c1403 | |||
| a597c37684 | |||
| 5206171a70 | |||
| 375d916fe2 | |||
| 35afb7a8fe | |||
| 8d1c4d8042 | |||
| b969944ede | |||
| da7450c732 | |||
| 1db5e865a6 | |||
| 69ac7771d5 | |||
| 04f5cac85d | |||
| ccdd2a4cdc | |||
| 33140a2ca6 |
@ -87,10 +87,6 @@
|
||||
}
|
||||
|
||||
@media (max-width: 1008px) {
|
||||
#portal-info {
|
||||
width: 65vw;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
margin-left: 0;
|
||||
}
|
||||
@ -312,6 +308,9 @@
|
||||
.tableRow td:first-child {
|
||||
max-width: 17%;
|
||||
}
|
||||
#portal-info {
|
||||
max-width: 60vw;
|
||||
}
|
||||
}
|
||||
|
||||
.downloadContentCellShift:after {
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
}
|
||||
|
||||
body {
|
||||
display: inline-table;
|
||||
background: #FFFFFF;
|
||||
color: #333333;
|
||||
font-family: Open Sans;
|
||||
@ -71,6 +72,7 @@ header img {
|
||||
}
|
||||
|
||||
.main {
|
||||
display: table;
|
||||
height: calc(100% - 112px);
|
||||
min-height: 536px;
|
||||
}
|
||||
@ -97,6 +99,10 @@ header img {
|
||||
width: 896px;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 65vw;
|
||||
}
|
||||
|
||||
.portal-name {
|
||||
color: #FF6F3D;
|
||||
font-size: 24px;
|
||||
|
||||
@ -79,19 +79,37 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// get the storage path of the file
|
||||
public static string StoragePath(string fileName, string userAddress = null)
|
||||
{
|
||||
var directory = HttpRuntime.AppDomainAppPath + CurUserHostAddress(userAddress) + "\\";
|
||||
var directory = "";
|
||||
if (!string.IsNullOrEmpty(WebConfigurationManager.AppSettings["storage-path"]) && Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
return directory + Path.GetFileName(fileName);
|
||||
return directory + (fileName.Contains("\\") ? fileName : Path.GetFileName(fileName));
|
||||
}
|
||||
|
||||
// get the path to the forcesaved file version
|
||||
public static string ForcesavePath(string fileName, string userAddress, Boolean create)
|
||||
{
|
||||
// create the directory to this file version
|
||||
var directory = HttpRuntime.AppDomainAppPath + CurUserHostAddress(userAddress) + "\\";
|
||||
var directory = "";
|
||||
if (!string.IsNullOrEmpty(WebConfigurationManager.AppSettings["storage-path"]) && Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
return "";
|
||||
@ -172,7 +190,16 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// get all the stored files from the user host address
|
||||
public static List<FileInfo> GetStoredFiles()
|
||||
{
|
||||
var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
|
||||
var directory = "";
|
||||
if (!string.IsNullOrEmpty(WebConfigurationManager.AppSettings["storage-path"]) && Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(directory)) return new List<FileInfo>();
|
||||
|
||||
var directoryInfo = new DirectoryInfo(directory);
|
||||
@ -228,8 +255,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
var uri = new UriBuilder(GetServerUrl(true))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath + "/"
|
||||
+ path,
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath + "/" + path,
|
||||
Query = ""
|
||||
};
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
"uid-1",
|
||||
"John Smith",
|
||||
"smith@example.com",
|
||||
null,
|
||||
"",
|
||||
null,
|
||||
new Dictionary<string, object>(),
|
||||
null,
|
||||
@ -116,7 +116,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
"uid-0",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"",
|
||||
null,
|
||||
new Dictionary<string,object>(),
|
||||
null,
|
||||
|
||||
@ -21,6 +21,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Script.Serialization;
|
||||
using OnlineEditorsExampleMVC.Helpers;
|
||||
@ -42,7 +43,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
// get file url for user
|
||||
public string FileUriUser
|
||||
{
|
||||
get { return DocManagerHelper.GetFileUri(FileName, false); }
|
||||
get { return Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]) ? DownloadUrl + "&dmode=emb" : DocManagerHelper.GetFileUri(FileName, false); }
|
||||
}
|
||||
|
||||
public string FileName { get; set; } // file name
|
||||
@ -214,7 +215,8 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
|
||||
// get the document history
|
||||
public void GetHistory(out string history, out string historyData)
|
||||
{
|
||||
{
|
||||
var storagePath = WebConfigurationManager.AppSettings["storage-path"];
|
||||
var jss = new JavaScriptSerializer();
|
||||
var histDir = DocManagerHelper.HistoryDir(DocManagerHelper.StoragePath(FileName, null));
|
||||
|
||||
@ -253,9 +255,22 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
}
|
||||
}
|
||||
|
||||
var ext = Path.GetExtension(FileName).ToLower();
|
||||
dataObj.Add("fileType", ext.Replace(".", ""));
|
||||
dataObj.Add("key", key);
|
||||
// write file url to the data object
|
||||
dataObj.Add("url", i == currentVersion ? FileUri : DocManagerHelper.GetPathUri(Directory.GetFiles(verDir, "prev.*")[0].Substring(HttpRuntime.AppDomainAppPath.Length)));
|
||||
string prevFileUrl;
|
||||
if (Path.IsPathRooted(storagePath) && !string.IsNullOrEmpty(storagePath))
|
||||
{
|
||||
prevFileUrl = i == currentVersion ? DocManagerHelper.GetDownloadUrl(FileName)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
|
||||
}
|
||||
else {
|
||||
prevFileUrl = i == currentVersion ? FileUri
|
||||
: DocManagerHelper.GetPathUri(Directory.GetFiles(verDir, "prev.*")[0].Substring(HttpRuntime.AppDomainAppPath.Length));
|
||||
}
|
||||
|
||||
dataObj.Add("url", prevFileUrl);
|
||||
dataObj.Add("version", i);
|
||||
if (i > 1) // check if the version number is greater than 1 (the file was modified)
|
||||
{
|
||||
@ -274,11 +289,14 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
|
||||
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()]; // get the history data from the previous file version
|
||||
dataObj.Add("previous", new Dictionary<string, object>() { // write information about previous file version to the data object
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
});
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
dataObj.Add("changesUrl", DocManagerHelper.GetPathUri(Path.Combine(DocManagerHelper.VersionDir(histDir, i - 1), "diff.zip").Substring(HttpRuntime.AppDomainAppPath.Length)));
|
||||
var changesUrl = Path.IsPathRooted(storagePath) ? DocManagerHelper.GetDownloadUrl(Path.Combine(DocManagerHelper.VersionDir(histDir, i - 1), "diff.zip").Replace(storagePath + "\\", ""))
|
||||
: DocManagerHelper.GetPathUri(Path.Combine(DocManagerHelper.VersionDir(histDir, i - 1), "diff.zip").Substring(HttpRuntime.AppDomainAppPath.Length));
|
||||
dataObj.Add("changesUrl", changesUrl);
|
||||
}
|
||||
if(JwtManager.Enabled)
|
||||
{
|
||||
|
||||
@ -13,11 +13,14 @@ See the detailed guide to learn how to install Document Server [for Windows](htt
|
||||
## Step 2. Download the .Net (C# MVC) code for the editors integration
|
||||
|
||||
Download the [.Net (C# MVC) example](https://api.onlyoffice.com/editors/demopreview) from our site.
|
||||
You need to connnect the editors to your website. Specify path to the editors installation in the *settings.config* file:
|
||||
|
||||
To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *settings.config* file:
|
||||
```
|
||||
<add key="storage-path" value=""/>
|
||||
<add key="files.docservice.url.site" value="https://documentserver/" />
|
||||
```
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storage-path** is the path where files will be created and stored. You can set an absolute path.
|
||||
|
||||
If you want to experiment with the editor configuration, modify the [parameters](https://api.onlyoffice.com/editors/advanced) in the *DocEditor.aspx* file.
|
||||
|
||||
## Step 3. Install the prerequisites
|
||||
@ -25,6 +28,16 @@ If you want to experiment with the editor configuration, modify the [parameters]
|
||||
* **Microsoft .NET Framework**: version 4.5 (download it from the [official Microsoft website](https://www.microsoft.com/en-US/download/details.aspx?id=30653));
|
||||
* **Internet Information Services**: version 7 or later.
|
||||
|
||||
Configure the IIS components for the server to work correctly:
|
||||
1. Open Windows features:
|
||||
|
||||
**Start** -> **Control Panel** -> **Programs** -> **Programs and Features** -> **Turn Windows features on or off**
|
||||
|
||||
2. In the opened window, find **Internet Information Services** and choose all the necessary features. To do this, open the **World Wide Web Services** list and check the following components:
|
||||
* **Application Development Features**: .NET Extensibility 4.8, ASP.NET 4.8, ISAPI Extensions, ISAPI Filters,
|
||||
* **Common HTTP Features**: Default Document,
|
||||
* **Security**: Request Filtering.
|
||||
|
||||
## Step 4. Run your website with the editors
|
||||
1. Run the Internet Information Service (IIS) Manager:
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@
|
||||
<td class="section">
|
||||
<div class="main-panel">
|
||||
<% var storedFiles = DocManagerHelper.GetStoredFiles(); %>
|
||||
<div id="portal-info" style="display: <%= storedFiles.Any() ? "none" : "block" %>">
|
||||
<div id="portal-info" style="display: <%= storedFiles.Any() ? "none" : "table-cell" %>">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<span class="portal-descr">
|
||||
Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors.
|
||||
@ -222,9 +222,6 @@
|
||||
</a>
|
||||
</td>
|
||||
<% } %>
|
||||
<% if (docType != "word" && docType != "cell") { %>
|
||||
<td class="contentCells contentCells-icon contentCellsEmpty"></td>
|
||||
<% } %>
|
||||
<% if (docType == "word") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "blockcontent" }) %>" target="_blank">
|
||||
|
||||
@ -443,10 +443,12 @@ namespace OnlineEditorsExampleMVC
|
||||
{
|
||||
try
|
||||
{
|
||||
var fileName = Path.GetFileName(context.Request["fileName"]);
|
||||
var fileName = Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]) ? context.Request["fileName"]
|
||||
: Path.GetFileName(context.Request["fileName"]);
|
||||
var userAddress = context.Request["userAddress"];
|
||||
var isEmbedded = context.Request["dmode"];
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
if (JwtManager.Enabled && isEmbedded == null)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
|
||||
Submodule web/documentserver-example/csharp-mvc/assets updated: 2f519764cf...d66cdf5b05
@ -4,7 +4,8 @@
|
||||
<add key="version" value="1.1.0"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
|
||||
<add key="storage-path" value=""/>
|
||||
|
||||
<add key="files.docservice.fillform-docs" value=".oform|.docx"/>
|
||||
<add key="files.docservice.viewed-docs" value=".pdf|.djvu|.xps|.oxps"/>
|
||||
<add key="files.docservice.edited-docs" value=".docx|.xlsx|.csv|.pptx|.txt|.docxf"/>
|
||||
|
||||
@ -87,10 +87,6 @@
|
||||
}
|
||||
|
||||
@media (max-width: 1008px) {
|
||||
#portal-info {
|
||||
width: 65vw;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
margin-left: 0;
|
||||
}
|
||||
@ -312,6 +308,9 @@
|
||||
.tableRow td:first-child {
|
||||
max-width: 17%;
|
||||
}
|
||||
#portal-info {
|
||||
max-width: 60vw;
|
||||
}
|
||||
}
|
||||
|
||||
.downloadContentCellShift:after {
|
||||
|
||||
@ -22,6 +22,7 @@ html {
|
||||
}
|
||||
|
||||
body {
|
||||
display: inline-table;
|
||||
background: #FFFFFF;
|
||||
color: #333333;
|
||||
font-family: Open Sans;
|
||||
@ -71,6 +72,7 @@ header img {
|
||||
}
|
||||
|
||||
.main {
|
||||
display: table;
|
||||
height: calc(100% - 112px);
|
||||
min-height: 536px;
|
||||
}
|
||||
@ -97,6 +99,10 @@ header img {
|
||||
width: 896px;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 65vw;
|
||||
}
|
||||
|
||||
.portal-name {
|
||||
color: #FF6F3D;
|
||||
font-size: 24px;
|
||||
|
||||
@ -140,7 +140,7 @@
|
||||
<td class="section">
|
||||
<% var storedFiles = GetStoredFiles(); %>
|
||||
<div class="main-panel">
|
||||
<div id="portal-info" style="display: <%= storedFiles.Any() ? "none" : "block" %>">
|
||||
<div id="portal-info" style="display: <%= storedFiles.Any() ? "none" : "table-cell" %>">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<span class="portal-descr">
|
||||
Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors.
|
||||
@ -223,9 +223,6 @@
|
||||
</a>
|
||||
</td>
|
||||
<% } %>
|
||||
<%if (docType != "word" && docType != "cell") { %>
|
||||
<td class="contentCells contentCells-icon contentCellsEmpty"></td>
|
||||
<% } %>
|
||||
<% if (docType == "word") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= editUrl + "&editorsType=desktop&editorsMode=blockcontent" %>" target="_blank">
|
||||
|
||||
@ -78,7 +78,9 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
return Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]) ?
|
||||
WebConfigurationManager.AppSettings["storage-path"] + "/"
|
||||
:
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ WebConfigurationManager.AppSettings["storage-path"]
|
||||
@ -144,18 +146,36 @@ namespace OnlineEditorsExample
|
||||
// get the storage path of the given file
|
||||
public static string StoragePath(string fileName, string userAddress)
|
||||
{
|
||||
var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
|
||||
var directory = "";
|
||||
if (Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory); // if the file directory doesn't exist, make it
|
||||
}
|
||||
return directory + Path.GetFileName(fileName);
|
||||
return directory + (fileName.Contains("\\") ? fileName : Path.GetFileName(fileName));
|
||||
}
|
||||
|
||||
// get the path to the forcesaved file version
|
||||
public static string ForcesavePath(string fileName, string userAddress, Boolean create)
|
||||
{
|
||||
var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
|
||||
var directory = "";
|
||||
if (Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(directory)) // the directory with host address doesn't exist
|
||||
{
|
||||
return "";
|
||||
@ -528,7 +548,16 @@ namespace OnlineEditorsExample
|
||||
// get all the stored files from the folder
|
||||
protected static List<FileInfo> GetStoredFiles()
|
||||
{
|
||||
var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
|
||||
var directory = "";
|
||||
if (Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]))
|
||||
{
|
||||
directory = WebConfigurationManager.AppSettings["storage-path"] + "\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(directory)) return new List<FileInfo>();
|
||||
|
||||
var directoryInfo = new DirectoryInfo(directory); // read the user host directory contents
|
||||
|
||||
@ -41,7 +41,7 @@ namespace OnlineEditorsExample
|
||||
// get url to the original file for Document Server
|
||||
public static string FileUriUser
|
||||
{
|
||||
get { return _Default.FileUri(FileName, false); }
|
||||
get { return Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]) ? getDownloadUrl(FileName) + "&dmode=emb" : _Default.FileUri(FileName, false); }
|
||||
}
|
||||
|
||||
protected string Key
|
||||
@ -100,20 +100,17 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
public static string getDownloadUrl
|
||||
public static string getDownloadUrl(string fileName)
|
||||
{
|
||||
get
|
||||
{
|
||||
var downloadUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
var downloadUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
downloadUrl.Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
downloadUrl.Query = "type=download"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(FileName)
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
return downloadUrl.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
// loading a page
|
||||
@ -195,7 +192,7 @@ namespace OnlineEditorsExample
|
||||
"document", new Dictionary<string, object>
|
||||
{
|
||||
{ "title", FileName },
|
||||
{ "url", getDownloadUrl },
|
||||
{ "url", getDownloadUrl(FileName) },
|
||||
{ "fileType", ext.Trim('.') },
|
||||
{ "key", Key },
|
||||
{
|
||||
@ -318,6 +315,7 @@ namespace OnlineEditorsExample
|
||||
// get the document history
|
||||
private void GetHistory(out Dictionary<string, object> history, out Dictionary<string, object> historyData)
|
||||
{
|
||||
var storagePath = WebConfigurationManager.AppSettings["storage-path"];
|
||||
var jss = new JavaScriptSerializer();
|
||||
var histDir = _Default.HistoryDir(_Default.StoragePath(FileName, null));
|
||||
|
||||
@ -355,8 +353,16 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
}
|
||||
|
||||
var ext = Path.GetExtension(FileName).ToLower();
|
||||
dataObj.Add("fileType", ext.Replace(".", ""));
|
||||
dataObj.Add("key", key);
|
||||
dataObj.Add("url", i == currentVersion ? FileUri : MakePublicUrl(Directory.GetFiles(verDir, "prev.*")[0])); // write file url to the data object
|
||||
var prevFileUrl = i == currentVersion ? FileUri : MakePublicUrl(Directory.GetFiles(verDir, "prev.*")[0]);
|
||||
if (Path.IsPathRooted(storagePath))
|
||||
{
|
||||
prevFileUrl = i == currentVersion ? getDownloadUrl(FileName) : getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
|
||||
}
|
||||
|
||||
dataObj.Add("url", prevFileUrl); // write file 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)
|
||||
{
|
||||
@ -375,11 +381,14 @@ namespace OnlineEditorsExample
|
||||
|
||||
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()]; // get the history data from the previous file version
|
||||
dataObj.Add("previous", new Dictionary<string, object>() { // write information about previous file version to the data object
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
});
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
dataObj.Add("changesUrl", MakePublicUrl(Path.Combine(_Default.VersionDir(histDir, i - 1), "diff.zip")));
|
||||
var changesUrl = Path.IsPathRooted(storagePath) ? getDownloadUrl(Path.Combine(_Default.VersionDir(histDir, i - 1), "diff.zip").Replace(storagePath + "\\", ""))
|
||||
: MakePublicUrl(Path.Combine(_Default.VersionDir(histDir, i - 1), "diff.zip"));
|
||||
dataObj.Add("changesUrl", changesUrl);
|
||||
}
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
@ -503,7 +512,8 @@ namespace OnlineEditorsExample
|
||||
// create the public url
|
||||
private string MakePublicUrl(string fullPath)
|
||||
{
|
||||
var root = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"];
|
||||
var root = Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]) ? WebConfigurationManager.AppSettings["storage-path"]
|
||||
: HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"];
|
||||
return _Default.GetServerUrl(true) + fullPath.Substring(root.Length).Replace(Path.DirectorySeparatorChar, '/');
|
||||
}
|
||||
|
||||
|
||||
@ -14,11 +14,12 @@ See the detailed guide to learn how to install Document Server [for Windows](htt
|
||||
|
||||
Download the [.Net (C#) example](https://api.onlyoffice.com/editors/demopreview) from our site.
|
||||
|
||||
Connect the editors to your website by specifying the path to the editors installation in the *settings.config* file:
|
||||
To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *settings.config* file:
|
||||
```
|
||||
<add key="storage-path" value=""/>
|
||||
<add key="files.docservice.url.site" value="https://documentserver/" />
|
||||
```
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storage-path** is the path where files will be created and stored. You can set an absolute path.
|
||||
|
||||
If you want to experiment with the editor configuration, modify the [parameters](https://api.onlyoffice.com/editors/advanced) in the *DocEditor.aspx* file.
|
||||
|
||||
@ -28,6 +29,16 @@ Check that your system meets the requirements:
|
||||
* **Microsoft .NET Framework**: version 4.5 (download it from the [official Microsoft website](https://www.microsoft.com/en-US/download/details.aspx?id=30653));
|
||||
* **Internet Information Services**: version 7 or later.
|
||||
|
||||
Configure the IIS components for the server to work correctly:
|
||||
1. Open Windows features:
|
||||
|
||||
**Start** -> **Control Panel** -> **Programs** -> **Programs and Features** -> **Turn Windows features on or off**
|
||||
|
||||
2. In the opened window, find **Internet Information Services** and choose all the necessary features. To do this, open the **World Wide Web Services** list and check the following components:
|
||||
* **Application Development Features**: .NET Extensibility 4.8, ASP.NET 4.8, ISAPI Extensions, ISAPI Filters,
|
||||
* **Common HTTP Features**: Default Document,
|
||||
* **Security**: Request Filtering.
|
||||
|
||||
## Step 4. Run your website with the editors
|
||||
1. Run the Internet Information Service (IIS) Manager:
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ namespace OnlineEditorsExample
|
||||
"uid-1",
|
||||
"John Smith",
|
||||
"smith@example.com",
|
||||
null,
|
||||
"",
|
||||
null,
|
||||
new Dictionary<string, object>(),
|
||||
null,
|
||||
@ -115,7 +115,7 @@ namespace OnlineEditorsExample
|
||||
"uid-0",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"",
|
||||
null,
|
||||
new Dictionary<string, object>(),
|
||||
null,
|
||||
|
||||
@ -271,10 +271,11 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
try
|
||||
{
|
||||
var fileName = Path.GetFileName(context.Request["fileName"]);
|
||||
var fileName = Path.IsPathRooted(WebConfigurationManager.AppSettings["storage-path"]) ? context.Request["fileName"] : Path.GetFileName(context.Request["fileName"]);
|
||||
var userAddress = Path.GetFileName(context.Request["userAddress"]);
|
||||
var isEmbedded = context.Request["dmode"];
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
if (JwtManager.Enabled && isEmbedded == null)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
|
||||
Submodule web/documentserver-example/csharp/assets updated: 2f519764cf...d66cdf5b05
@ -19,16 +19,15 @@ See the detailed guide to learn how to install Document Server [for Windows](htt
|
||||
|
||||
Download the [Java-Spring example](https://api.onlyoffice.com/editors/demopreview) from our site.
|
||||
|
||||
To connect the editors to your website, specify the path to the editors installation, server address and port in the *\src\main\resources\application.properties* file:
|
||||
To connect the editors to your website, specify the path to the editors installation, server port and the path to the storage folder in the *\src\main\resources\application.properties* file:
|
||||
|
||||
```
|
||||
server.address=address
|
||||
files.storage=
|
||||
server.port=port
|
||||
files.docservice.url.site=https://documentserver/
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
**address** is the address of the server or comment this line to use localhost, **port** is the any available port.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Docs installed, **port** is any available port and **files.storage** is the path where files will be created and stored (in the project folder by default). You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator.
|
||||
|
||||
If you want to experiment with the editor configuration, modify the [parameters](https://api.onlyoffice.com/editors/advanced) it the *\src\main\resources\editor.html* file.
|
||||
|
||||
@ -112,8 +111,6 @@ To run the Java example code, install the Java version 11 appropriate for your O
|
||||
```
|
||||
http://server.address:server.port/
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Step 6. Check accessibility
|
||||
|
||||
@ -173,13 +170,13 @@ See the detailed guide to learn how to install Document Server [for Linux](https
|
||||
Edit the following lines:
|
||||
|
||||
```
|
||||
server.address=address
|
||||
files.storage=
|
||||
server.port=port
|
||||
files.docservice.url.site=https://documentserver/
|
||||
```
|
||||
|
||||
Where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
**address** is the address of the server or comment this line to use localhost, **port** is the any available port.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Docs installed, **port** is any available port and **files.storage** is the path where files will be created and stored (in the project folder by default). You can set an absolute path.
|
||||
|
||||
|
||||
5. Install **Maven**:
|
||||
|
||||
@ -204,7 +201,6 @@ See the detailed guide to learn how to install Document Server [for Linux](https
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Step 3. Check accessibility
|
||||
|
||||
In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files.
|
||||
@ -222,13 +218,12 @@ Make sure that the Document Server has access to the server with the example ins
|
||||
2. Edit the following lines:
|
||||
|
||||
```
|
||||
server.address=address
|
||||
files.storage=
|
||||
server.port=port
|
||||
files.docservice.url.site=https://documentserver/
|
||||
```
|
||||
|
||||
Where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
**address** is the address of the server or comment this line to use localhost, **port** is the any available port.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Docs installed, **port** is any available port and **files.storage** is the path where files will be created and stored (in the project folder by default). You can set an absolute path.
|
||||
|
||||
3. Run the next command in the java example directory:
|
||||
|
||||
|
||||
@ -7,7 +7,9 @@ services:
|
||||
image: maven:3.8.1
|
||||
working_dir: /java-spring
|
||||
volumes:
|
||||
- .:/java-spring
|
||||
- .:/java-spring
|
||||
ports:
|
||||
- 4000:4000
|
||||
command: mvn clean spring-boot:run
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ public class ExampleData {
|
||||
"Can create a file from an editor"
|
||||
);
|
||||
userService.createUser("John Smith", "smith@example.com", // create user 1 with the specified parameters
|
||||
description_user_1, null, List.of(FilterState.NULL.toString()),
|
||||
description_user_1, "", List.of(FilterState.NULL.toString()),
|
||||
List.of(FilterState.NULL.toString()),
|
||||
List.of(FilterState.NULL.toString()),
|
||||
List.of(FilterState.NULL.toString()), null);
|
||||
@ -79,7 +79,7 @@ public class ExampleData {
|
||||
description_user_3, "group-3", List.of("group-2"), List.of("group-2", "group-3"),
|
||||
List.of("group-2"), new ArrayList<>(), false);
|
||||
userService.createUser("Anonymous",null, // create user 0 with the specified parameters
|
||||
description_user_0,null, List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
|
||||
description_user_0,"", List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
|
||||
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +45,8 @@ public class DefaultDocumentManager implements DocumentManager {
|
||||
|
||||
@Value("${files.storage.folder}")
|
||||
private String storageFolder;
|
||||
@Value("${files.storage}")
|
||||
private String filesStorage;
|
||||
@Value("${url.track}")
|
||||
private String trackUrl;
|
||||
@Value("${url.download}")
|
||||
@ -93,6 +95,9 @@ 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);
|
||||
if (!filesStorage.isEmpty() && filePathDownload.contains(filesStorage)) {
|
||||
filePathDownload = filePathDownload.substring(filesStorage.length() + 1);
|
||||
}
|
||||
|
||||
String filePath = serverPath + "/download?fileName=" + URLEncoder.encode(filePathDownload, java.nio.charset.StandardCharsets.UTF_8.toString())
|
||||
+ "&userAddress" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
|
||||
@ -87,6 +87,7 @@ public class DefaultHistoryManager implements HistoryManager {
|
||||
obj.put("user", user);
|
||||
}
|
||||
|
||||
dataObj.put("fileType", fileUtility.getFileExtension(document.getTitle()).replace(".", ""));
|
||||
dataObj.put("key", key);
|
||||
dataObj.put("url", i == curVer ? document.getUrl() :
|
||||
documentManager.getFileUri(documentManager.versionDir(histDir, i, true) + File.separator + "prev" + fileUtility.getFileExtension(document.getTitle()), true));
|
||||
@ -105,6 +106,7 @@ public class DefaultHistoryManager implements HistoryManager {
|
||||
|
||||
Map<String, Object> prev = (Map<String, Object>) histData.get(Integer.toString(i - 2)); // get the history data from the previous file version
|
||||
Map<String, Object> prevInfo = new HashMap<String, Object>();
|
||||
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"));
|
||||
dataObj.put("previous", prevInfo); // write information about previous file version to the data object
|
||||
|
||||
@ -85,10 +85,18 @@ public class LocalFileStorage implements FileStorageMutator, FileStoragePathBuil
|
||||
// get the storage directory
|
||||
public String getStorageLocation(){
|
||||
String serverPath = System.getProperty("user.dir"); // get the path to the server
|
||||
String directory = serverPath // create the storage directory
|
||||
+ File.separator + storageFolder
|
||||
+ File.separator + this.storageAddress
|
||||
+ File.separator;
|
||||
String directory; // create the storage directory
|
||||
if (Paths.get(this.storageAddress).isAbsolute()) {
|
||||
directory = this.storageAddress + File.separator;
|
||||
} else {
|
||||
directory = serverPath
|
||||
+ File.separator + storageFolder
|
||||
+ File.separator + this.storageAddress
|
||||
+ File.separator;
|
||||
}
|
||||
if (!Files.exists(Paths.get(directory))) {
|
||||
createDirectory(Paths.get(directory));
|
||||
}
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
server.version=1.1.0
|
||||
|
||||
server.address=127.0.0.1
|
||||
server.address=
|
||||
server.port=4000
|
||||
|
||||
filesize-max=5242880
|
||||
|
||||
@ -98,6 +98,10 @@ header img {
|
||||
width: 896px;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 65vw;
|
||||
}
|
||||
|
||||
.portal-name {
|
||||
color: #FF6F3D;
|
||||
font-size: 24px;
|
||||
|
||||
@ -127,7 +127,7 @@
|
||||
</td>
|
||||
<td class="section">
|
||||
<div class="main-panel">
|
||||
<div id="portal-info" th:attr="tooltip=${tooltip}" th:style="${not #lists.isEmpty(files)} ? 'display: none' : 'display: block' ">
|
||||
<div id="portal-info" th:attr="tooltip=${tooltip}" th:style="${not #lists.isEmpty(files)} ? 'display: none' : 'display: table-cell' ">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<span class="portal-descr">
|
||||
Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors.
|
||||
@ -189,9 +189,6 @@
|
||||
</a>
|
||||
</td>
|
||||
</div>
|
||||
<div th:if="${docTypes[iState.index]} eq 'slide'">
|
||||
<td class="contentCells contentCells-icon contentCellsEmpty"></td>
|
||||
</div>
|
||||
<div th:if="${docTypes[iState.index]} eq 'word'">
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='blockcontent')}" target="_blank">
|
||||
|
||||
9
web/documentserver-example/java/Dockerfile
Normal file
9
web/documentserver-example/java/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
||||
FROM maven:3.6.1-jdk-8-alpine AS MVN_BLDR
|
||||
COPY pom.xml /tmp/
|
||||
COPY src /tmp/src/
|
||||
WORKDIR /tmp/
|
||||
RUN mvn package
|
||||
|
||||
FROM tomcat:alpine
|
||||
RUN rm -fr /usr/local/tomcat/webapps/ROOT
|
||||
COPY --from=MVN_BLDR /tmp/target/*.war $CATALINA_HOME/webapps/ROOT.war
|
||||
@ -16,13 +16,14 @@ See the detailed guide to learn how to [install Document Server for Windows](htt
|
||||
|
||||
Download the [Java example](https://api.onlyoffice.com/editors/demopreview) from our site.
|
||||
|
||||
To connect the editors to your website, specify the path to the editors installation in the *\src\main\resources\settings.properties* file:
|
||||
To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *\src\main\resources\settings.properties* file:
|
||||
|
||||
```
|
||||
storage-folder = app_data
|
||||
files.docservice.url.site=https://documentserver/
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storage-folder** is the path where files will be created and stored. You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator.
|
||||
|
||||
If you want to experiment with the editor configuration, modify the [parameters](https://api.onlyoffice.com/editors/advanced) in the *\src\main\webapp\editor.jsp* file.
|
||||
|
||||
@ -163,13 +164,17 @@ See the detailed guide to learn how to [install Document Server for Linux](https
|
||||
nano src/main/resources/settings.properties
|
||||
```
|
||||
|
||||
Edit the following line:
|
||||
Edit the following lines:
|
||||
|
||||
```
|
||||
storage-folder = app_data
|
||||
files.docservice.url.site=https://documentserver/
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storage-folder** is the path where files will be created and stored. Please note that you must have read and write permissions to the folder. If you do not have them, please use the next command:
|
||||
```
|
||||
sudo chmod -R ugo+rw /{path}
|
||||
```
|
||||
|
||||
5. Install **Maven**:
|
||||
|
||||
@ -238,13 +243,14 @@ Make sure that the Document Server has access to the server with the example ins
|
||||
nano src/main/resources/settings.properties
|
||||
```
|
||||
|
||||
2. Edit the following line:
|
||||
2. Edit the following lines:
|
||||
|
||||
```
|
||||
storage-folder = app_data
|
||||
files.docservice.url.site=https://documentserver/
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storage-folder** is the path where files will be created and stored.
|
||||
|
||||
3. Run the next command in the Java example directory:
|
||||
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
version: '3'
|
||||
services:
|
||||
build:
|
||||
image: maven:3.6
|
||||
volumes:
|
||||
- .:/java
|
||||
command: mvn -f /java package
|
||||
java-intg-ex:
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- 8080:8080
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ public class EditorServlet extends HttpServlet
|
||||
// create file model (get all the necessary parameters from cookies)
|
||||
FileModel file = new FileModel(fileName, cm.getCookie("ulang"), request.getParameter("actionLink"), user);
|
||||
// change type parameter if needed
|
||||
file.changeType(request.getParameter("mode"), request.getParameter("type"), user);
|
||||
file.changeType(request.getParameter("mode"), request.getParameter("type"), user, fileName);
|
||||
|
||||
// an image that will be inserted into the document
|
||||
Map<String, Object> dataInsertImage = new HashMap<>();
|
||||
|
||||
@ -436,8 +436,9 @@ public class IndexServlet extends HttpServlet
|
||||
try {
|
||||
String fileName = FileUtility.GetFileName(request.getParameter("fileName"));
|
||||
String userAddress = request.getParameter("userAddress");
|
||||
String isEmbedded = request.getParameter("dmode");
|
||||
|
||||
if (DocumentManager.TokenEnabled()) {
|
||||
if (DocumentManager.TokenEnabled() && isEmbedded == null) {
|
||||
|
||||
String DocumentJwtHeader = ConfigManager.GetProperty("files.docservice.header");
|
||||
|
||||
|
||||
@ -20,16 +20,14 @@ package entities;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import helpers.DocumentManager;
|
||||
import helpers.FileUtility;
|
||||
import helpers.ServiceConverter;
|
||||
import helpers.Users;
|
||||
import helpers.*;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class FileModel
|
||||
@ -54,7 +52,6 @@ public class FileModel
|
||||
document = new Document();
|
||||
document.title = fileName;
|
||||
document.url = DocumentManager.GetDownloadUrl(fileName); // get file url
|
||||
document.urlUser = DocumentManager.GetFileUri(fileName, false);
|
||||
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()));
|
||||
@ -94,11 +91,11 @@ public class FileModel
|
||||
// write the absolute URL to the file location
|
||||
editorConfig.customization.goback.url = DocumentManager.GetServerUrl(false) + "/IndexServlet";
|
||||
|
||||
changeType(mode, type, user);
|
||||
changeType(mode, type, user, fileName);
|
||||
}
|
||||
|
||||
// change the document type
|
||||
public void changeType(String _mode, String _type, User user)
|
||||
public void changeType(String _mode, String _type, User user, String fileName)
|
||||
{
|
||||
if (_mode != null) mode = _mode;
|
||||
if (_type != null) type = _type;
|
||||
@ -119,12 +116,12 @@ public class FileModel
|
||||
// set document permissions
|
||||
document.permissions = new Permissions(mode, type, canEdit, user);
|
||||
|
||||
if (type.equals("embedded")) InitDesktop(); // set parameters for the embedded document
|
||||
if (type.equals("embedded")) InitDesktop(fileName); // set parameters for the embedded document
|
||||
}
|
||||
|
||||
public void InitDesktop()
|
||||
public void InitDesktop(String fileName)
|
||||
{
|
||||
editorConfig.InitDesktop(document.urlUser);
|
||||
editorConfig.InitDesktop(DocumentManager.GetDownloadUrl(fileName) + "&dmode=emb");
|
||||
}
|
||||
|
||||
// generate document token
|
||||
@ -178,6 +175,7 @@ public class FileModel
|
||||
obj.put("user", user);
|
||||
}
|
||||
|
||||
dataObj.put("fileType", FileUtility.GetFileExtension(document.title).substring(1));
|
||||
dataObj.put("key", key);
|
||||
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetPathUri(verDir + File.separator + "prev" + FileUtility.GetFileExtension(document.title)));
|
||||
dataObj.put("version", i);
|
||||
@ -195,11 +193,17 @@ public class FileModel
|
||||
|
||||
Map<String, Object> prev = (Map<String, Object>) histData.get(Integer.toString(i - 2)); // get the history data from the previous file version
|
||||
Map<String, Object> prevInfo = new HashMap<String, Object>();
|
||||
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"));
|
||||
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
|
||||
dataObj.put("changesUrl", DocumentManager.GetPathUri(DocumentManager.VersionDir(histDir, i - 1) + File.separator + "diff.zip"));
|
||||
String storagePath = ConfigManager.GetProperty("storage-folder");
|
||||
String changesUrl = DocumentManager.GetPathUri(DocumentManager.VersionDir(histDir, i - 1) + File.separator + "diff.zip");
|
||||
if (new File(storagePath).isAbsolute()) {
|
||||
changesUrl = DocumentManager.GetDownloadUrl((DocumentManager.VersionDir(histDir, i - 1) + File.separator + "diff.zip").replace(storagePath, ""));
|
||||
}
|
||||
dataObj.put("changesUrl", changesUrl);
|
||||
}
|
||||
|
||||
if (DocumentManager.TokenEnabled())
|
||||
@ -246,7 +250,6 @@ public class FileModel
|
||||
{
|
||||
public String title;
|
||||
public String url;
|
||||
public String urlUser;
|
||||
public String fileType;
|
||||
public String key;
|
||||
public Info info;
|
||||
@ -288,7 +291,14 @@ public class FileModel
|
||||
// the Favorite icon state
|
||||
public class Info
|
||||
{
|
||||
public String owner = "Me";
|
||||
public Boolean favorite;
|
||||
public String uploaded = getDate();
|
||||
|
||||
private String getDate() {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE MMM dd yyyy", Locale.US);
|
||||
return simpleDateFormat.format(new Date());
|
||||
}
|
||||
}
|
||||
// the editor config parameters
|
||||
public class EditorConfig
|
||||
|
||||
@ -130,7 +130,20 @@ public class DocumentManager
|
||||
String hostAddress = CurUserHostAddress(userAddress); // get current user host address
|
||||
String serverPath = request.getSession().getServletContext().getRealPath(""); // get the server url
|
||||
String storagePath = ConfigManager.GetProperty("storage-folder"); // get the storage directory
|
||||
String directory = serverPath + storagePath + File.separator + hostAddress + File.separator;
|
||||
File f = new File(storagePath);
|
||||
|
||||
if (f.isAbsolute()) {
|
||||
if (!f.exists()) {
|
||||
if (Files.isWritable(Paths.get(storagePath.substring(0, storagePath.lastIndexOf(File.separator))))) {
|
||||
f.mkdirs();
|
||||
} else {
|
||||
throw new SecurityException("No write permission to path: " + f.toPath());
|
||||
}
|
||||
} else if (f.exists() && f.isFile()) {
|
||||
throw new SecurityException("The path to the file is specified instead of the folder");
|
||||
}
|
||||
}
|
||||
String directory = !f.isAbsolute() ? serverPath + storagePath + File.separator + hostAddress + File.separator : storagePath + File.separator;
|
||||
|
||||
File file = new File(directory);
|
||||
|
||||
@ -320,13 +333,20 @@ public class DocumentManager
|
||||
{
|
||||
String serverPath = GetServerUrl(forDocumentServer);
|
||||
String storagePath = ConfigManager.GetProperty("storage-folder");
|
||||
File f = new File(storagePath);
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
|
||||
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);
|
||||
if (!Files.isWritable(f.toPath())) {
|
||||
throw new SecurityException("No write permission to path: " + f.toPath());
|
||||
}
|
||||
}
|
||||
|
||||
return filePath;
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ public class Users {
|
||||
|
||||
private static List<User> users = new ArrayList<User>() {{
|
||||
add(new User("uid-1", "John Smith", "smith@example.com",
|
||||
null, null, new CommentGroups(),
|
||||
"", null, new CommentGroups(),
|
||||
null, new ArrayList<String>(), descr_user_1, true));
|
||||
add(new User("uid-2", "Mark Pottato", "pottato@example.com",
|
||||
"group-2", Arrays.asList("group-2", ""), new CommentGroups(null, Arrays.asList("group-2", ""), Arrays.asList("group-2")),
|
||||
@ -73,7 +73,7 @@ public class Users {
|
||||
"group-3", Arrays.asList("group-2"), new CommentGroups(Arrays.asList("group-3", "group-2"), Arrays.asList("group-2"), new ArrayList<String>()),
|
||||
false, Arrays.asList("copy", "download", "print"), descr_user_3, false));
|
||||
add(new User("uid-0", null, null,
|
||||
null, null, new CommentGroups(),
|
||||
"", null, new CommentGroups(),
|
||||
null, new ArrayList<String>(), descr_user_0, false));
|
||||
}};
|
||||
|
||||
|
||||
Submodule web/documentserver-example/java/src/main/resources/assets updated: 2f519764cf...d66cdf5b05
@ -86,10 +86,6 @@
|
||||
}
|
||||
|
||||
@media (max-width: 1008px) {
|
||||
#portal-info {
|
||||
width: 65vw;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
margin-left: 0;
|
||||
}
|
||||
@ -299,6 +295,9 @@
|
||||
.tableRow td:first-child {
|
||||
max-width: 17%;
|
||||
}
|
||||
#portal-info {
|
||||
max-width: 60vw;
|
||||
}
|
||||
}
|
||||
|
||||
.downloadContentCellShift:after {
|
||||
|
||||
@ -22,6 +22,7 @@ html {
|
||||
}
|
||||
|
||||
body {
|
||||
display: inline-table;
|
||||
background: #FFFFFF;
|
||||
color: #333333;
|
||||
font-family: Open Sans;
|
||||
@ -71,6 +72,7 @@ header img {
|
||||
}
|
||||
|
||||
.main{
|
||||
display: table;
|
||||
height: calc(100% - 112px);
|
||||
min-height: 536px;
|
||||
}
|
||||
@ -97,6 +99,10 @@ header img {
|
||||
width: 896px;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 65vw;
|
||||
}
|
||||
|
||||
.portal-name {
|
||||
color: #FF6F3D;
|
||||
font-size: 24px;
|
||||
|
||||
@ -139,7 +139,7 @@
|
||||
<% DocumentManager.Init(request, response); %>
|
||||
<% File[] files = DocumentManager.GetStoredFiles(null); %>
|
||||
<div class="main-panel">
|
||||
<div id="portal-info" style="display: <%= files.length > 0 ? "none" : "block" %>">
|
||||
<div id="portal-info" style="display: <%= files.length > 0 ? "none" : "table-cell" %>">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<span class="portal-descr">
|
||||
Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors.
|
||||
@ -180,7 +180,7 @@
|
||||
Boolean canEdit = DocumentManager.GetEditedExts().contains(FileUtility.GetFileExtension(files[i].getName()));
|
||||
String version=" ["+DocumentManager.GetFileVersion(DocumentManager.HistoryDir(DocumentManager.StoragePath(files[i].getName(), null)))+"]";
|
||||
%>
|
||||
<tr class="tableRow" title="<%= files[i].getName() %> [<%= version %>]">
|
||||
<tr class="tableRow" title="<%= files[i].getName() %><%= version %>">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>" target="_blank">
|
||||
<span><%= files[i].getName() %></span>
|
||||
@ -215,9 +215,6 @@
|
||||
</a>
|
||||
</td>
|
||||
<% } %>
|
||||
<% if (!docType.equals("cell") && !docType.equals("word")) { %>
|
||||
<td class="contentCells contentCells-icon contentCellsEmpty"></td>
|
||||
<% } %>
|
||||
<% if (docType.equals("word")) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=blockcontent" target="_blank">
|
||||
|
||||
@ -16,13 +16,15 @@ See the detailed guide to learn how to [install Document Server for Windows](htt
|
||||
|
||||
Download the [Node.js example](https://api.onlyoffice.com/editors/demopreview) from our site.
|
||||
|
||||
You need to connect the editors to your website. Specify the path to the editors installation in the *config/default.json* file:
|
||||
To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *config/default.json* file:
|
||||
|
||||
```
|
||||
"storageFolder": "./files"
|
||||
"storagePath": "/files"
|
||||
"siteUrl": "https://documentserver/"
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed, the **storageFolder** and **storagePath** are the paths where files will be created and stored. You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator.
|
||||
|
||||
If you want to experiment with the editor configuration, modify the [parameters](https://api.onlyoffice.com/editors/advanced) in the *\views\editor.ejs* file.
|
||||
|
||||
@ -114,13 +116,18 @@ See the detailed guide to learn how to [install Document Server for Linux](https
|
||||
nano config/default.json
|
||||
```
|
||||
|
||||
Edit the following line:
|
||||
Edit the following lines:
|
||||
|
||||
```
|
||||
"storageFolder": "./files"
|
||||
"storagePath": "/files"
|
||||
"siteUrl": "https://documentserver/"
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed, the **storageFolder** and **storagePath** are the paths where files will be created and stored. Please note that you must have read and write permissions to the folder. If you do not have them, please use the next command:
|
||||
```
|
||||
sudo chmod -R ugo+rw /{path}
|
||||
```
|
||||
|
||||
6. Run the project with Node.js:
|
||||
|
||||
|
||||
@ -124,8 +124,9 @@ app.get("/download", function(req, res) { // define a handler for downloading f
|
||||
|
||||
var fileName = fileUtility.getFileName(req.query.fileName);
|
||||
var userAddress = req.query.useraddress;
|
||||
var isEmbedded = req.query.dmode;
|
||||
|
||||
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
|
||||
if ((cfgSignatureEnable && cfgSignatureUseForRequest) && isEmbedded == null ) {
|
||||
var authorization = req.get(cfgSignatureAuthorizationHeader);
|
||||
if (authorization && authorization.startsWith(cfgSignatureAuthorizationHeaderPrefix)) {
|
||||
var token = authorization.substring(cfgSignatureAuthorizationHeaderPrefix.length);
|
||||
@ -159,7 +160,7 @@ app.post("/upload", function (req, res) { // define a handler for uploading fil
|
||||
docManager.storagePath(""); // mkdir if not exist
|
||||
|
||||
const userIp = docManager.curUserHostAddress(); // get the path to the user host
|
||||
const uploadDir = path.join(storageFolder, userIp);
|
||||
const uploadDir = path.isAbsolute(storageFolder) ? storageFolder : path.join(storageFolder, userIp);
|
||||
const uploadDirTmp = path.join(uploadDir, 'tmp'); // and create directory for temporary files if it doesn't exist
|
||||
docManager.createDirectory(uploadDirTmp);
|
||||
|
||||
@ -745,7 +746,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
}
|
||||
var key = docManager.getKey(fileName);
|
||||
var url = docManager.getDownloadUrl(fileName);
|
||||
var urlUser = docManager.getlocalFileUri(fileName, 0, false)
|
||||
var urlUser = path.isAbsolute(storageFolder) ? docManager.getDownloadUrl(fileName) + "&dmode=emb" : docManager.getlocalFileUri(fileName, 0, false);
|
||||
var mode = req.query.mode || "edit"; // mode: view/edit/review/comment/fillForms/embedded
|
||||
var type = req.query.type || ""; // type: embedded/mobile/desktop
|
||||
if (type == "") {
|
||||
@ -779,6 +780,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
history.push(docManager.getHistory(fileName, changes, keyVersion, i)); // write all the file history information
|
||||
|
||||
var historyD = {
|
||||
fileType: fileUtility.getFileExtension(fileName).slice(1),
|
||||
version: i,
|
||||
key: keyVersion,
|
||||
url: i == countVersion ? url : (docManager.getlocalFileUri(fileName, i, true) + "/prev" + fileExt),
|
||||
@ -786,10 +788,12 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
|
||||
if (i > 1 && docManager.existsSync(docManager.diffPath(fileName, userAddress, i-1))) { // check if the path to the file with document versions differences exists
|
||||
historyD.previous = { // write information about previous file version
|
||||
fileType: historyData[i-2].fileType,
|
||||
key: historyData[i-2].key,
|
||||
url: historyData[i-2].url,
|
||||
};
|
||||
historyD.changesUrl = docManager.getlocalFileUri(fileName, i-1) + "/diff.zip"; // get the path to the diff.zip file and write it to the history object
|
||||
let changesUrl = docManager.getlocalFileUri(fileName, i-1);
|
||||
historyD.changesUrl = changesUrl.includes("diff.zip") ? changesUrl : changesUrl + "/diff.zip"; // get the path to the diff.zip file and write it to the history object
|
||||
}
|
||||
|
||||
historyData.push(historyD);
|
||||
|
||||
@ -151,7 +151,12 @@ docManager.getFileUri = function (fileName) {
|
||||
docManager.getlocalFileUri = function (fileName, version, forDocumentServer) {
|
||||
const serverPath = docManager.getServerUrl(forDocumentServer);
|
||||
const hostAddress = docManager.curUserHostAddress();
|
||||
const url = serverPath + configServer.get("storagePath") + "/" + hostAddress + "/" + encodeURIComponent(fileName); // get full url address to the file
|
||||
let url = serverPath + configServer.get("storagePath") + "/" + hostAddress + "/" + encodeURIComponent(fileName); // get full url address to the file
|
||||
if (path.isAbsolute(configServer.get("storageFolder"))) {
|
||||
let separator = configServer.get("storagePath").includes("/") ? "/" : "\\";
|
||||
url = docManager.getDownloadUrl(fileName + "-history" + separator + version + separator + "diff.zip");
|
||||
return url;
|
||||
}
|
||||
if (!version) {
|
||||
return url;
|
||||
}
|
||||
@ -208,14 +213,14 @@ docManager.getDownloadUrl = function (fileName) {
|
||||
// get the storage path of the given file
|
||||
docManager.storagePath = function (fileName, userAddress) {
|
||||
fileName = fileUtility.getFileName(fileName); // get the file name with extension
|
||||
const directory = path.join(docManager.dir, docManager.curUserHostAddress(userAddress)); // get the path to the directory for the host address
|
||||
const directory = path.isAbsolute(docManager.dir) ? docManager.dir : path.join(docManager.dir, docManager.curUserHostAddress(userAddress)); // get the path to the directory for the host address
|
||||
this.createDirectory(directory); // create a new directory if it doesn't exist
|
||||
return path.join(directory, fileName); // put the given file to this directory
|
||||
};
|
||||
|
||||
// get the path to the forcesaved file version
|
||||
docManager.forcesavePath = function (fileName, userAddress, create) {
|
||||
let directory = path.join(docManager.dir, docManager.curUserHostAddress(userAddress));
|
||||
let directory = path.isAbsolute(docManager.dir) ? docManager.dir : path.join(docManager.dir, docManager.curUserHostAddress(userAddress));
|
||||
if (!this.existsSync(directory)) { // the directory with host address doesn't exist
|
||||
return "";
|
||||
}
|
||||
@ -233,7 +238,7 @@ docManager.forcesavePath = function (fileName, userAddress, create) {
|
||||
|
||||
// create the path to the file history
|
||||
docManager.historyPath = function (fileName, userAddress, create) {
|
||||
let directory = path.join(docManager.dir, docManager.curUserHostAddress(userAddress));
|
||||
let directory = path.isAbsolute(docManager.dir) ? docManager.dir : path.join(docManager.dir, userAddress);
|
||||
if (!this.existsSync(directory)) {
|
||||
return "";
|
||||
}
|
||||
@ -278,7 +283,7 @@ docManager.changesUser = function (fileName, userAddress, version) {
|
||||
// get all the stored files
|
||||
docManager.getStoredFiles = function () {
|
||||
const userAddress = docManager.curUserHostAddress();
|
||||
const directory = path.join(docManager.dir, userAddress);
|
||||
const directory = path.isAbsolute(docManager.dir) ? docManager.dir : path.join(docManager.dir, userAddress);
|
||||
this.createDirectory(directory);
|
||||
const result = [];
|
||||
const storedFiles = fileSystem.readdirSync(directory); // read the user host directory contents
|
||||
@ -451,7 +456,7 @@ docManager.cleanFolderRecursive = function (folder, me) {
|
||||
// get files information
|
||||
docManager.getFilesInfo = function (fileId) {
|
||||
const userAddress = docManager.curUserHostAddress();
|
||||
const directory = path.join(docManager.dir, userAddress);
|
||||
const directory = path.isAbsolute(docManager.dir) ? docManager.dir : path.join(docManager.dir, userAddress);
|
||||
const filesInDirectory = this.getStoredFiles(); // get all the stored files from the folder
|
||||
let responseArray = [];
|
||||
let responseObject;
|
||||
|
||||
Submodule web/documentserver-example/nodejs/public/assets updated: 2f519764cf...d66cdf5b05
@ -87,10 +87,6 @@
|
||||
}
|
||||
|
||||
@media (max-width: 1008px) {
|
||||
#portal-info {
|
||||
width: 65vw;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
margin-left: 0;
|
||||
}
|
||||
@ -312,6 +308,9 @@
|
||||
.tableRow td:first-child {
|
||||
max-width: 17%;
|
||||
}
|
||||
#portal-info {
|
||||
max-width: 60vw;
|
||||
}
|
||||
}
|
||||
|
||||
.downloadContentCellShift:after {
|
||||
|
||||
@ -97,6 +97,10 @@ header img {
|
||||
width: 896px;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 65vw;
|
||||
}
|
||||
|
||||
.portal-name {
|
||||
color: #FF6F3D;
|
||||
font-size: 24px;
|
||||
|
||||
@ -133,7 +133,7 @@
|
||||
</td>
|
||||
<td class="section">
|
||||
<div class="main-panel">
|
||||
<div id="portal-info" style="display: <%= storedFiles.length > 0 ? "none" : "block" %>">
|
||||
<div id="portal-info" style="display: <%= storedFiles.length > 0 ? "none" : "table-cell" %>">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<span class="portal-descr">
|
||||
Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors.
|
||||
@ -200,9 +200,6 @@
|
||||
<img src="images/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" /></a>
|
||||
</td>
|
||||
<% } %>
|
||||
<% if (storedFiles[i].documentType !== "word" && storedFiles[i].documentType !== "cell") {%>
|
||||
<td class="contentCells contentCells-icon contentCellsEmpty"></td>
|
||||
<% } %>
|
||||
<% if (storedFiles[i].documentType == "word") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="editor?type=desktop&mode=blockcontent&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
|
||||
|
||||
@ -16,13 +16,14 @@ See the detailed guide to learn how to [install Document Server for Windows](htt
|
||||
|
||||
Download the [PHP example](https://api.onlyoffice.com/editors/demopreview) from our site.
|
||||
|
||||
You need to connect the editors to your website. Specify the path to the editors installation in the *config.php* file:
|
||||
To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *config.php* file:
|
||||
|
||||
```
|
||||
$GLOBALS['STORAGE_PATH'] = "";
|
||||
$GLOBALS['DOC_SERV_SITE_URL'] = "https://documentserver/";
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **STORAGE_PATH** is the path where files will be created and stored. You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator.
|
||||
|
||||
If you want to experiment with the editor configuration, modify the [parameters](https://api.onlyoffice.com/editors/advanced) in the *doceditor.php* file.
|
||||
|
||||
@ -147,13 +148,14 @@ See the detailed guide to learn how to [install Document Server for Linux](https
|
||||
nano config.php
|
||||
```
|
||||
|
||||
Edit the following line:
|
||||
Edit the following lines:
|
||||
|
||||
```
|
||||
$GLOBALS['STORAGE_PATH'] = "";
|
||||
$GLOBALS['DOC_SERV_SITE_URL'] = "https://documentserver/";
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **STORAGE_PATH** is the path where files will be created and stored. You can set an absolute path.
|
||||
|
||||
5. Set permission for site:
|
||||
|
||||
|
||||
Submodule web/documentserver-example/php/assets updated: 2f519764cf...d66cdf5b05
@ -200,7 +200,15 @@ function getScheme() {
|
||||
// get the storage path of the given file
|
||||
function getStoragePath($fileName, $userAddress = NULL) {
|
||||
$storagePath = trim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath;
|
||||
if (!empty($storagePath) && !file_exists($storagePath) && !is_dir($storagePath)) {
|
||||
mkdir($storagePath);
|
||||
}
|
||||
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$directory = $storagePath;
|
||||
} else {
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath;
|
||||
}
|
||||
|
||||
if ($storagePath != "")
|
||||
{
|
||||
@ -212,20 +220,27 @@ function getStoragePath($fileName, $userAddress = NULL) {
|
||||
}
|
||||
}
|
||||
|
||||
$directory = $directory . getCurUserHostAddress($userAddress) . DIRECTORY_SEPARATOR;
|
||||
if (realpath($storagePath) !== $storagePath) {
|
||||
$directory = $directory . getCurUserHostAddress($userAddress) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
}
|
||||
sendlog("getStoragePath result: " . $directory . basename($fileName), "common.log");
|
||||
return $directory . basename($fileName);
|
||||
return realpath($storagePath) === $storagePath ? $directory . $fileName : $directory . basename($fileName);
|
||||
}
|
||||
|
||||
// get the path to the forcesaved file version
|
||||
function getForcesavePath($fileName, $userAddress, $create) {
|
||||
$storagePath = trim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
|
||||
// create the directory to this file version
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath . getCurUserHostAddress($userAddress) . DIRECTORY_SEPARATOR;
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$directory = $storagePath . DIRECTORY_SEPARATOR;
|
||||
} else {
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath . getCurUserHostAddress($userAddress) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if (!is_dir($directory)) return "";
|
||||
|
||||
@ -233,8 +248,9 @@ function getForcesavePath($fileName, $userAddress, $create) {
|
||||
$directory = $directory . $fileName . "-hist" . DIRECTORY_SEPARATOR;
|
||||
if (!$create && !is_dir($directory)) return "";
|
||||
|
||||
mkdir($directory);
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
}
|
||||
$directory = $directory . $fileName;
|
||||
if (!$create && !file_exists($directory)) return "";
|
||||
|
||||
@ -275,7 +291,15 @@ function getFileVersion($histDir) {
|
||||
// get all the stored files from the folder
|
||||
function getStoredFiles() {
|
||||
$storagePath = trim(str_replace(array('/','\\'), DIRECTORY_SEPARATOR, $GLOBALS['STORAGE_PATH']), DIRECTORY_SEPARATOR);
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath;
|
||||
if (!empty($storagePath) && !file_exists($storagePath) && !is_dir($storagePath)) {
|
||||
mkdir($storagePath);
|
||||
}
|
||||
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$directory = $storagePath;
|
||||
} else {
|
||||
$directory = __DIR__ . DIRECTORY_SEPARATOR . $storagePath;
|
||||
}
|
||||
|
||||
// get the storage path and check if it exists
|
||||
$result = array();
|
||||
@ -288,7 +312,9 @@ function getStoredFiles() {
|
||||
}
|
||||
}
|
||||
|
||||
$directory = $directory . getCurUserHostAddress() . DIRECTORY_SEPARATOR;
|
||||
if (realpath($storagePath) !== $storagePath) {
|
||||
$directory = $directory . getCurUserHostAddress() . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
return $result;
|
||||
@ -320,7 +346,11 @@ function getVirtualPath($forDocumentServer) {
|
||||
$storagePath = $storagePath != "" ? $storagePath . '/' : "";
|
||||
|
||||
|
||||
$virtPath = serverPath($forDocumentServer) . '/' . $storagePath . getCurUserHostAddress() . '/';
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$virtPath = serverPath($forDocumentServer) . '/' . $storagePath . '/';
|
||||
} else {
|
||||
$virtPath = serverPath($forDocumentServer) . '/' . $storagePath . getCurUserHostAddress() . '/';
|
||||
}
|
||||
sendlog("getVirtualPath virtPath: " . $virtPath, "common.log");
|
||||
return $virtPath;
|
||||
}
|
||||
|
||||
@ -87,10 +87,6 @@
|
||||
}
|
||||
|
||||
@media (max-width: 1008px) {
|
||||
#portal-info {
|
||||
width: 65vw;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
margin-left: 0;
|
||||
}
|
||||
@ -312,6 +308,10 @@
|
||||
.tableRow td:first-child {
|
||||
max-width: 17%;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 60vw;
|
||||
}
|
||||
}
|
||||
|
||||
.downloadContentCellShift:after {
|
||||
|
||||
@ -22,6 +22,7 @@ html {
|
||||
}
|
||||
|
||||
body {
|
||||
display: inline-table;
|
||||
background: #FFFFFF;
|
||||
color: #333333;
|
||||
font-family: Open Sans;
|
||||
@ -70,6 +71,7 @@ header img {
|
||||
}
|
||||
|
||||
.main{
|
||||
display: table;
|
||||
height: calc(100% - 112px);
|
||||
min-height: 536px;
|
||||
}
|
||||
@ -96,6 +98,10 @@ header img {
|
||||
width: 896px;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 65vw;
|
||||
}
|
||||
|
||||
.portal-name {
|
||||
color: #FF6F3D;
|
||||
font-size: 24px;
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
}
|
||||
|
||||
$fileuri = FileUri($filename, true);
|
||||
$fileuriUser = FileUri($filename);
|
||||
$fileuriUser = realpath($GLOBALS['STORAGE_PATH']) === $GLOBALS['STORAGE_PATH'] ? getDownloadUrl($filename) . "&dmode=emb" : FileUri($filename);
|
||||
$docKey = getDocEditorKey($filename);
|
||||
$filetype = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
|
||||
@ -217,6 +217,7 @@
|
||||
|
||||
// get document history
|
||||
function getHistory($filename, $filetype, $docKey, $fileuri) {
|
||||
$storagePath = $GLOBALS['STORAGE_PATH'];
|
||||
$histDir = getHistoryDir(getStoragePath($filename)); // get the path to the file history
|
||||
|
||||
if (getFileVersion($histDir) > 0) { // check if the file was modified (the file version is greater than 0)
|
||||
@ -245,31 +246,40 @@
|
||||
];
|
||||
}
|
||||
|
||||
$fileT = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
||||
$prevFileName = $verDir . DIRECTORY_SEPARATOR . "prev." . $filetype;
|
||||
$prevFileName = substr($prevFileName, strlen(getStoragePath("")));
|
||||
$dataObj["fileType"] = $fileT;
|
||||
$dataObj["key"] = $key;
|
||||
$dataObj["url"] = $i == $curVer ? $fileuri : getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($prevFileName)); // write file url to the data object
|
||||
|
||||
$prevFileUrl = $i == $curVer ? $fileuri : getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($prevFileName));
|
||||
if (realpath($storagePath) === $storagePath) {
|
||||
$prevFileUrl = $i == $curVer ? getDownloadUrl($filename) : getDownloadUrl($prevFileName);
|
||||
}
|
||||
$dataObj["url"] = $prevFileUrl; // write file url to the data object
|
||||
$dataObj["version"] = $i;
|
||||
|
||||
if ($i > 1) { // check if the version number is greater than 1 (the document was modified)
|
||||
$changes = json_decode(file_get_contents(getVersionDir($histDir, $i - 1) . DIRECTORY_SEPARATOR . "changes.json"), true); // get the path to the changes.json file
|
||||
$change = $changes["changes"][0];
|
||||
|
||||
$obj["changes"] = $change ? $changes["changes"][0] : null; // write information about changes to the object
|
||||
$obj["changes"] = $changes ? $changes["changes"] : null; // write information about changes to the object
|
||||
$obj["serverVersion"] = $changes["serverVersion"];
|
||||
$obj["created"] = $change ? $change["created"] : null;
|
||||
$obj["user"] = $change ? $change["user"] : null;
|
||||
|
||||
$prev = $histData[$i - 2]; // get the history data from the previous file version
|
||||
$dataObj["previous"] = [ // write information about previous file version to the data object
|
||||
"fileType" => $prev["fileType"],
|
||||
"key" => $prev["key"],
|
||||
"url" => $prev["url"]
|
||||
];
|
||||
$changesUrl = getVersionDir($histDir, $i - 1) . DIRECTORY_SEPARATOR . "diff.zip";
|
||||
$changesUrl = substr($changesUrl, strlen(getStoragePath("")));
|
||||
$changesPath = getVersionDir($histDir, $i - 1) . DIRECTORY_SEPARATOR . "diff.zip";
|
||||
$changesPath = substr($changesPath, strlen(getStoragePath("")));
|
||||
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
$dataObj["changesUrl"] = getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($changesUrl));
|
||||
$changesUrl = realpath($storagePath) === $storagePath ? getDownloadUrl($changesPath) : getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($changesPath)) ;
|
||||
$dataObj["changesUrl"] = $changesUrl;
|
||||
}
|
||||
|
||||
if (isJwtEnabled()) {
|
||||
|
||||
@ -144,7 +144,7 @@
|
||||
if (!empty($storedFiles)): ?>
|
||||
<div id="portal-info" style="display: none">
|
||||
<?php else: ?>
|
||||
<div id="portal-info" style="display: block">
|
||||
<div id="portal-info" style="display: table-cell">
|
||||
<?php endif; ?>
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<span class="portal-descr">
|
||||
@ -213,9 +213,6 @@
|
||||
echo ' <img src="css/images/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" /></a>';
|
||||
echo ' </td>';
|
||||
}
|
||||
if($storeFile->documentType!="word" && $storeFile->documentType!="cell"){
|
||||
echo ' <td class="contentCells contentCells-icon contentCellsEmpty"></td>';
|
||||
}
|
||||
if ($storeFile->documentType == "word") {
|
||||
echo ' <td class="contentCells contentCells-icon ">';
|
||||
echo ' <a href="doceditor.php?fileID=' . urlencode($storeFile->name) . '&user=' . htmlentities($user) . '&action=blockcontent&type=desktop" target="_blank">';
|
||||
|
||||
@ -73,7 +73,7 @@ $descr_user_0 = [
|
||||
|
||||
$users = [
|
||||
new User("uid-1", "John Smith", "smith@example.com",
|
||||
null, null, [],
|
||||
"", null, [],
|
||||
null, [], $descr_user_1, true),
|
||||
new User("uid-2", "Mark Pottato", "pottato@example.com",
|
||||
"group-2", ["group-2", ""], [
|
||||
@ -90,7 +90,7 @@ $users = [
|
||||
],
|
||||
false, ["copy", "download", "print"], $descr_user_3, false),
|
||||
new User("uid-0", null, null,
|
||||
null, null, [],
|
||||
"", null, [],
|
||||
null, [], $descr_user_0, false)
|
||||
];
|
||||
|
||||
|
||||
@ -353,10 +353,11 @@ function csv() {
|
||||
// download a file
|
||||
function download() {
|
||||
try {
|
||||
$fileName = basename($_GET["fileName"]); // get the file name
|
||||
$fileName = realpath($GLOBALS['STORAGE_PATH']) === $GLOBALS['STORAGE_PATH'] ? $_GET["fileName"] : basename($_GET["fileName"]); // get the file name
|
||||
$userAddress = $_GET["userAddress"];
|
||||
$isEmbedded = $_GET["&dmode"];
|
||||
|
||||
if (isJwtEnabled()) {
|
||||
if (isJwtEnabled() && $isEmbedded == null) {
|
||||
$jwtHeader = $GLOBALS['DOC_SERV_JWT_HEADER'] == "" ? "Authorization" : $GLOBALS['DOC_SERV_JWT_HEADER'];
|
||||
if (!empty(apache_request_headers()[$jwtHeader])) {
|
||||
$token = jwtDecode(substr(apache_request_headers()[$jwtHeader], strlen("Bearer ")));
|
||||
|
||||
Submodule web/documentserver-example/python/assets updated: 2f519764cf...d66cdf5b05
@ -45,13 +45,14 @@ See the detailed guide to learn how to install Document Server [for Windows](htt
|
||||
nano config.py
|
||||
```
|
||||
|
||||
Edit the following line:
|
||||
Edit the following lines:
|
||||
|
||||
```
|
||||
STORAGE_PATH = 'app_data'
|
||||
DOC_SERV_SITE_URL = 'https://documentserver/'
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **STORAGE_PATH** is the path where files will be created and stored. You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator.
|
||||
|
||||
6. Run the **Python** server:
|
||||
|
||||
|
||||
@ -164,7 +164,7 @@ def getRootFolder(req):
|
||||
else:
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
|
||||
directory = os.path.join(config.STORAGE_PATH, curAdr)
|
||||
directory = config.STORAGE_PATH if os.path.isabs(config.STORAGE_PATH) else os.path.join(config.STORAGE_PATH, curAdr)
|
||||
|
||||
if not os.path.exists(directory): # if such a directory does not exist, make it
|
||||
os.makedirs(directory)
|
||||
|
||||
@ -176,6 +176,7 @@ def getHistoryObject(storagePath, filename, docKey, docUrl, req):
|
||||
|
||||
obj['key'] = key
|
||||
obj['version'] = i
|
||||
dataObj['fileType'] = fileUtils.getFileExt(filename)[1:]
|
||||
dataObj['key'] = key
|
||||
dataObj['version'] = i
|
||||
|
||||
@ -201,6 +202,7 @@ def getHistoryObject(storagePath, filename, docKey, docUrl, req):
|
||||
|
||||
prev = histData[str(i - 2)] # get the history data from the previous file version
|
||||
prevInfo = { # write key and url information about previous file version
|
||||
'fileType': prev['fileType'],
|
||||
'key': prev['key'],
|
||||
'url': prev['url']
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ descr_user_0 = [
|
||||
|
||||
USERS = [
|
||||
User('uid-1', 'John Smith', 'smith@example.com',
|
||||
None, None, {},
|
||||
'', None, {},
|
||||
None, [], descr_user_1, True),
|
||||
User('uid-2', 'Mark Pottato', 'pottato@example.com',
|
||||
'group-2', ['group-2', ''], {
|
||||
@ -96,7 +96,7 @@ USERS = [
|
||||
},
|
||||
False, ["copy", "download", "print"], descr_user_3, False),
|
||||
User('uid-0', None, None,
|
||||
None, None, {},
|
||||
'', None, {},
|
||||
None, [], descr_user_0, False)
|
||||
]
|
||||
|
||||
|
||||
@ -154,7 +154,7 @@ def edit(request):
|
||||
ext = fileUtils.getFileExt(filename)
|
||||
|
||||
fileUri = docManager.getFileUri(filename, True, request)
|
||||
fileUriUser = docManager.getFileUri(filename, False, request)
|
||||
fileUriUser = docManager.getDownloadUrl(filename, request) + "&dmode=emb" if os.path.isabs(config.STORAGE_PATH) else docManager.getFileUri(filename, False, request)
|
||||
docKey = docManager.generateFileKey(filename, request)
|
||||
fileType = fileUtils.getFileType(filename)
|
||||
user = users.getUserFromReq(request) # get user
|
||||
@ -361,8 +361,9 @@ def download(request):
|
||||
try:
|
||||
fileName = fileUtils.getFileName(request.GET['fileName']) # get the file name
|
||||
userAddress = request.GET.get('userAddress') if request.GET.get('userAddress') else request
|
||||
isEmbedded = request.GET.get('dmode')
|
||||
|
||||
if (jwtManager.isEnabled()):
|
||||
if (jwtManager.isEnabled() and isEmbedded == None):
|
||||
jwtHeader = 'Authorization' if config.DOC_SERV_JWT_HEADER is None or config.DOC_SERV_JWT_HEADER == '' else config.DOC_SERV_JWT_HEADER
|
||||
token = request.headers.get(jwtHeader)
|
||||
if token:
|
||||
|
||||
@ -87,10 +87,6 @@
|
||||
}
|
||||
|
||||
@media (max-width: 1008px) {
|
||||
#portal-info {
|
||||
width: 65vw;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
margin-left: 0;
|
||||
}
|
||||
@ -312,6 +308,10 @@
|
||||
.tableRow td:first-child {
|
||||
max-width: 17%;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 60vw;
|
||||
}
|
||||
}
|
||||
|
||||
.downloadContentCellShift:after {
|
||||
|
||||
@ -30,6 +30,7 @@ html {
|
||||
}
|
||||
|
||||
body {
|
||||
display: inline-table;
|
||||
background: #FFFFFF;
|
||||
color: #333333;
|
||||
font-family: Open Sans;
|
||||
@ -79,6 +80,7 @@ header img {
|
||||
}
|
||||
|
||||
.main{
|
||||
display: table;
|
||||
height: calc(100% - 112px);
|
||||
min-height: 536px;
|
||||
}
|
||||
@ -105,6 +107,10 @@ header img {
|
||||
width: 896px;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 65vw;
|
||||
}
|
||||
|
||||
.portal-name {
|
||||
color: #FF6F3D;
|
||||
font-size: 24px;
|
||||
|
||||
@ -113,7 +113,7 @@
|
||||
{% if files %}
|
||||
<div id="portal-info" style="display: none">
|
||||
{% else %}
|
||||
<div id="portal-info" style="display: block">
|
||||
<div id="portal-info" style="display: table-cell">
|
||||
{% endif %}
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<span class="portal-descr">
|
||||
@ -185,9 +185,6 @@
|
||||
</a>
|
||||
</td>
|
||||
{% endif %}
|
||||
{% if file.type == 'slide' %}
|
||||
<td class="contentCells contentCells-icon contentCellsEmpty"></td>
|
||||
{% endif %}
|
||||
{% if file.type == 'word' %}
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="edit?filename={{ file.title }}&type=desktop&mode=blockcontent" target="_blank">
|
||||
|
||||
@ -36,6 +36,10 @@ jquery-rails - This gem provides jQuery and the jQuery-ujs driver for your Rail
|
||||
License: MIT
|
||||
License File: jquery-rails.license
|
||||
|
||||
mimemagic - А library to detect the mime type of a file by extension or by content. (https://github.com/mimemagicrb/mimemagic/blob/master/LICENSE)
|
||||
License: MIT
|
||||
License File: mimemagic.license
|
||||
|
||||
rails - Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern. (https://github.com/rails/rails/blob/v6.0.3.2/MIT-LICENSE)
|
||||
License: MIT
|
||||
License File: rails.license
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
|
||||
gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f'
|
||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails', '6.0.3.5'
|
||||
# Use sqlite3 as the database for Active Record
|
||||
@ -45,4 +45,6 @@ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
||||
|
||||
gem 'uuid'
|
||||
|
||||
gem 'rack-cors'
|
||||
gem 'rack-cors'
|
||||
|
||||
gem 'webrick'
|
||||
@ -12,14 +12,14 @@ See the detailed guide to learn how to install Document Server [for Windows](htt
|
||||
|
||||
## Step 2. Install the prerequisites and run the website with the editors
|
||||
|
||||
1. Install **Ruby Version Manager (RVM)** and the stable 2.7 **Ruby** version:
|
||||
1. Install **Ruby Version Manager (RVM)** and the latest stable **Ruby** version:
|
||||
|
||||
```
|
||||
gpg --keyserver "hkp://keys.gnupg.net" --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
|
||||
```
|
||||
|
||||
```
|
||||
\curl -sSL https://get.rvm.io | bash -s stable --ruby=2.7.0
|
||||
\curl -sSL https://get.rvm.io | bash -s stable --ruby
|
||||
```
|
||||
|
||||
2. Download the archive with the Ruby example and unpack the archive:
|
||||
@ -50,17 +50,19 @@ See the detailed guide to learn how to install Document Server [for Windows](htt
|
||||
nano config/application.rb
|
||||
```
|
||||
|
||||
Edit the following line:
|
||||
Edit the following lines:
|
||||
|
||||
```
|
||||
Rails.configuration.storagePath="app_data"
|
||||
Rails.configuration.urlSite="https://documentserver/"
|
||||
```
|
||||
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed.
|
||||
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storagePath** is the path where files will be created and stored. You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator.
|
||||
|
||||
6. Run the **Rails** application:
|
||||
|
||||
```
|
||||
rails server -u webrick
|
||||
rails s -b 0.0.0.0 -p 80
|
||||
```
|
||||
|
||||
|
||||
@ -87,10 +87,6 @@
|
||||
}
|
||||
|
||||
@media (max-width: 1008px) {
|
||||
#portal-info {
|
||||
width: 65vw;
|
||||
}
|
||||
|
||||
.left-panel {
|
||||
margin-left: 0;
|
||||
}
|
||||
@ -312,6 +308,10 @@
|
||||
.tableRow td:first-child {
|
||||
max-width: 17%;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 60vw;
|
||||
}
|
||||
}
|
||||
|
||||
.downloadContentCellShift:after {
|
||||
|
||||
@ -22,6 +22,7 @@ html {
|
||||
}
|
||||
|
||||
body {
|
||||
display: inline-table;
|
||||
background: #FFFFFF;
|
||||
color: #333333;
|
||||
font-family: Open Sans;
|
||||
@ -34,6 +35,7 @@ body {
|
||||
padding: 0;
|
||||
text-decoration: none;
|
||||
overflow-x: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
form {
|
||||
@ -71,6 +73,7 @@ header img {
|
||||
}
|
||||
|
||||
.main{
|
||||
display: table;
|
||||
height: calc(100% - 112px);
|
||||
min-height: 536px;
|
||||
}
|
||||
@ -97,6 +100,10 @@ header img {
|
||||
width: 896px;
|
||||
}
|
||||
|
||||
#portal-info {
|
||||
max-width: 65vw;
|
||||
}
|
||||
|
||||
.portal-name {
|
||||
color: #FF6F3D;
|
||||
font-size: 24px;
|
||||
|
||||
@ -236,8 +236,9 @@ class HomeController < ApplicationController
|
||||
begin
|
||||
file_name = File.basename(params[:fileName])
|
||||
user_address = params[:userAddress]
|
||||
isEmbedded = params[:dmode]
|
||||
|
||||
if JwtHelper.is_enabled
|
||||
if JwtHelper.is_enabled && isEmbedded == nil
|
||||
jwtHeader = Rails.configuration.header.empty? ? "Authorization" : Rails.configuration.header;
|
||||
if request.headers[jwtHeader]
|
||||
hdr = request.headers[jwtHeader]
|
||||
|
||||
@ -83,7 +83,8 @@ class DocumentHelper
|
||||
|
||||
# get the storage path of the given file
|
||||
def storage_path(file_name, user_address)
|
||||
directory = Rails.root.join('public', Rails.configuration.storagePath, cur_user_host_address(user_address)) # get the path to the directory for the host address
|
||||
directory = File.absolute_path?(Rails.configuration.storagePath) ? Rails.configuration.storagePath
|
||||
: Rails.root.join('public', Rails.configuration.storagePath, cur_user_host_address(user_address)) # get the path to the directory for the host address
|
||||
|
||||
# create a new directory if it doesn't exist
|
||||
unless File.directory?(directory)
|
||||
@ -91,19 +92,20 @@ class DocumentHelper
|
||||
end
|
||||
|
||||
# put the given file to this directory
|
||||
directory.join(File.basename(file_name)).to_s
|
||||
File.join(directory, File.basename(file_name))
|
||||
end
|
||||
|
||||
# get the path to the forcesaved file version
|
||||
def forcesave_path(file_name, user_address, create)
|
||||
directory = Rails.root.join('public', Rails.configuration.storagePath, cur_user_host_address(user_address))
|
||||
directory = File.absolute_path?(Rails.configuration.storagePath) ? Rails.configuration.storagePath
|
||||
: Rails.root.join('public', Rails.configuration.storagePath, cur_user_host_address(user_address))
|
||||
|
||||
# the directory with host address doesn't exist
|
||||
unless File.directory?(directory)
|
||||
return ""
|
||||
end
|
||||
|
||||
directory = directory.join("#{File.basename(file_name)}-hist") # get the path to the history of the given file
|
||||
directory = File.join(directory,"#{File.basename(file_name)}-hist") # get the path to the history of the given file
|
||||
unless File.directory?(directory)
|
||||
if create
|
||||
FileUtils.mkdir_p(directory) # create history directory if it doesn't exist
|
||||
@ -112,7 +114,7 @@ class DocumentHelper
|
||||
end
|
||||
end
|
||||
|
||||
directory = directory.join(File.basename(file_name)) # get the path to the given file
|
||||
directory = File.join(directory, File.basename(file_name)) # get the path to the given file
|
||||
unless File.file?(directory)
|
||||
if !create
|
||||
return ""
|
||||
@ -174,7 +176,8 @@ class DocumentHelper
|
||||
|
||||
# get all the stored files from the folder
|
||||
def get_stored_files(user_address)
|
||||
directory = Rails.root.join('public', Rails.configuration.storagePath, cur_user_host_address(user_address))
|
||||
directory = File.absolute_path?(Rails.configuration.storagePath) ? Rails.configuration.storagePath
|
||||
: Rails.root.join('public', Rails.configuration.storagePath, cur_user_host_address(user_address))
|
||||
|
||||
arr = [];
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ class FileModel
|
||||
|
||||
# get file uri for document server
|
||||
def file_uri_user
|
||||
DocumentHelper.get_file_uri(@file_name, false)
|
||||
File.absolute_path?(Rails.configuration.storagePath) ? download_url + "&dmode=emb" : DocumentHelper.get_file_uri(@file_name, false)
|
||||
end
|
||||
|
||||
# get document type from its name (word, cell or slide)
|
||||
@ -208,6 +208,7 @@ class FileModel
|
||||
end
|
||||
|
||||
# get the history data from the previous file version and write key and url information about it
|
||||
dataObj["fileType"] = file_ext[1..file_ext.length]
|
||||
dataObj["key"] = cur_key
|
||||
dataObj["url"] = i == cur_ver ? doc_uri : DocumentHelper.get_path_uri(File.join("#{file_name}-hist", i.to_s, "prev#{file_ext}"))
|
||||
dataObj["version"] = i
|
||||
@ -229,6 +230,7 @@ class FileModel
|
||||
|
||||
prev = histData[(i - 2).to_s] # get the history data from the previous file version
|
||||
dataObj["previous"] = { # write key and url information about previous file version
|
||||
:fileType => prev["fileType"],
|
||||
:key => prev["key"],
|
||||
:url => prev["url"]
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ class Users
|
||||
|
||||
@@users = [
|
||||
User.new("uid-1", "John Smith", "smith@example.com",
|
||||
nil, nil, {},
|
||||
"", nil, {},
|
||||
nil, [], @@descr_user_1, true),
|
||||
User.new("uid-2", "Mark Pottato", "pottato@example.com",
|
||||
"group-2", ["group-2", ""], {
|
||||
@ -89,7 +89,7 @@ class Users
|
||||
},
|
||||
false, ["copy", "download", "print"], @@descr_user_3, false),
|
||||
User.new("uid-0", nil, nil,
|
||||
nil, nil, {},
|
||||
"", nil, {},
|
||||
nil, [], @@descr_user_0, false)
|
||||
]
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@
|
||||
docs = DocumentHelper.get_stored_files(nil)
|
||||
%>
|
||||
<div class="main-panel">
|
||||
<div id="portal-info" style="display: <%= docs.length > 0 ? "none" : "block" %>">
|
||||
<div id="portal-info" style="display: <%= docs.length > 0 ? "none" : "table-cell" %>">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors – Welcome!</span>
|
||||
<span class="portal-descr">
|
||||
Get started with a demo-sample of ONLYOFFICE Document Editors, the first html5-based editors.
|
||||
@ -192,9 +192,6 @@
|
||||
<img src="assets/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" />
|
||||
</a>
|
||||
</td>
|
||||
<% end %>
|
||||
<% if !docType.eql?("word") && !docType.eql?("cell")%>
|
||||
<td class="contentCells contentCells-icon contentCellsEmpty"></td>
|
||||
<% end %>
|
||||
<% if docType.eql?("word") %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
|
||||
@ -5,6 +5,7 @@ Rails.application.config.assets.version = '1.0'
|
||||
Rails.application.config.assets.precompile += %w( editor.css )
|
||||
Rails.application.config.assets.precompile += %w( jquery-ui.css )
|
||||
Rails.application.config.assets.precompile += %w( stylesheet.css )
|
||||
Rails.application.config.assets.precompile += %w( media.css )
|
||||
|
||||
# Add additional assets to the asset load path
|
||||
# Rails.application.config.assets.paths << Emoji.images_path
|
||||
|
||||
21
web/documentserver-example/ruby/licenses/mimemagic.license
Normal file
21
web/documentserver-example/ruby/licenses/mimemagic.license
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2011 Daniel Mendler
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Reference in New Issue
Block a user