Compare commits
219 Commits
v6.2.0.133
...
v99.99.99.
| Author | SHA1 | Date | |
|---|---|---|---|
| 37e36f7fef | |||
| ec90b2ff98 | |||
| 758f0c08e5 | |||
| b76c532569 | |||
| 856613d644 | |||
| 75c11f4ee8 | |||
| 1e023e58b2 | |||
| f9f757bd0d | |||
| a213b635f2 | |||
| 96d6c521ef | |||
| 7d2469cfe9 | |||
| 2f7352c296 | |||
| 5fdbd2954b | |||
| 758291fd71 | |||
| 2a856c6919 | |||
| f026d0ef60 | |||
| 506b55a201 | |||
| 90dd2c837f | |||
| 75d828a6ae | |||
| fe3b5558df | |||
| 3d49eabaf0 | |||
| 51f712b900 | |||
| a565da4035 | |||
| 7db6983167 | |||
| b7262ff874 | |||
| 50921b278b | |||
| 9d16bee672 | |||
| 1a63a7f65f | |||
| f8f15d2191 | |||
| 2b217de9b4 | |||
| 6f64d40e5d | |||
| 9759839cd0 | |||
| e6ee57e09b | |||
| 50daec31b4 | |||
| bcd114d089 | |||
| 49592f66bf | |||
| e854b78884 | |||
| 4dd5f9d9f6 | |||
| abee34981b | |||
| 768f45f4fb | |||
| e53dac1e2b | |||
| 71ab72299a | |||
| eb4e6b4bc0 | |||
| 4f02a4957f | |||
| 469c2b6ced | |||
| 8b9a2d2481 | |||
| e921c936b8 | |||
| a5929897ad | |||
| 00a1c64353 | |||
| 6c18acdf97 | |||
| c0f459132e | |||
| d780a61e52 | |||
| 361b8bd0f4 | |||
| 48694f0f31 | |||
| 9ed7b0e96e | |||
| a2a094a22c | |||
| 9d9afce3ce | |||
| bb19ea1a6f | |||
| d667a62a24 | |||
| a92907135d | |||
| 71fde6f7b9 | |||
| 9ac78b77dc | |||
| dae246e8a2 | |||
| 7f95d59394 | |||
| 7bfa4229de | |||
| 1c6c45606b | |||
| 1c0a742f54 | |||
| 4eb4753c01 | |||
| 979f001fd0 | |||
| d0edb368ac | |||
| ac36df16d1 | |||
| e845cc498b | |||
| 606ce23228 | |||
| dcd4adf5ad | |||
| 6e81fa8996 | |||
| 15580ee144 | |||
| 422bb36b53 | |||
| e74811a755 | |||
| 4c987fbfce | |||
| e90ba356fe | |||
| 54c6025bc5 | |||
| b867d75bac | |||
| 2748dbf5b3 | |||
| 8b5aab3c63 | |||
| ee23e7948e | |||
| badcd6e110 | |||
| 53e1fbe9ef | |||
| c28e12e31e | |||
| b94704adf8 | |||
| 1fc1fb2b76 | |||
| 267fe7d260 | |||
| b8f5485201 | |||
| d19eaf0ef4 | |||
| 9ee379e8df | |||
| a4b75554bd | |||
| 854f5e7045 | |||
| 8cf4eb2fc2 | |||
| eba3f15587 | |||
| 3f52fd5563 | |||
| b439a5f729 | |||
| 848229f79c | |||
| 491f600dc0 | |||
| 0e3c759806 | |||
| 6427db4ea6 | |||
| d624cdf0f6 | |||
| 930338f5fc | |||
| 0875ca8d89 | |||
| 193bbe2cb7 | |||
| 533ee1af91 | |||
| db0339d4e4 | |||
| 1a46b8a215 | |||
| 022f1bb16d | |||
| c01afdec17 | |||
| b2ee170ecb | |||
| a104aa6c61 | |||
| 3f13590f55 | |||
| aa7132e467 | |||
| 60ddcb433c | |||
| 14840847bf | |||
| 06cf08822b | |||
| c4e2921040 | |||
| ea455421f7 | |||
| 90abe267bf | |||
| a92963aed1 | |||
| d19ee9d4c1 | |||
| 1a7fbe656b | |||
| 500be4f8e4 | |||
| 1b2cec44ac | |||
| ecfe99f7ed | |||
| 81450a883f | |||
| fec328ad9d | |||
| b197f4c258 | |||
| 0b03093c53 | |||
| 3bf8952b1a | |||
| 23b42ed070 | |||
| 25906383e2 | |||
| c597e914a9 | |||
| 125d9a2ab4 | |||
| 4dd4453599 | |||
| 7e2d83f04e | |||
| b7d2775733 | |||
| aa5f1e3df4 | |||
| 4193089de4 | |||
| 18a4dc20eb | |||
| 7ced0591bd | |||
| a010088395 | |||
| d5a6c1e605 | |||
| ab68d95f5d | |||
| 301775aafd | |||
| 51c180726c | |||
| aee637b980 | |||
| 63af540fe8 | |||
| 2819cbc5e3 | |||
| 02db6fa76a | |||
| 1feb56e397 | |||
| 502f001cfa | |||
| 7c10a0fe82 | |||
| aa16df8de7 | |||
| bbff0206c1 | |||
| e08e6f5f27 | |||
| 38cc631e2e | |||
| 6250902a55 | |||
| 7b017c15f8 | |||
| b21d179f4b | |||
| c75f9166c5 | |||
| 0f2695fba0 | |||
| aca8e94f2a | |||
| 9876e745e5 | |||
| eb8cf75bc0 | |||
| 62060d2538 | |||
| 0ad9907eb6 | |||
| 2090bad807 | |||
| 2368354c6d | |||
| 31337cc9c9 | |||
| 17cad4a0dc | |||
| 48fa83b850 | |||
| 2017c45c19 | |||
| 74505f5c44 | |||
| 6f6e80cf68 | |||
| d5a8cdc760 | |||
| ca5ba06506 | |||
| 720c61c7b7 | |||
| 6e03e71b59 | |||
| ea22efdac8 | |||
| 5521cd44dd | |||
| 773aa62478 | |||
| 280d9e3dba | |||
| ee5fe30010 | |||
| c0b520e440 | |||
| fd95aca32b | |||
| 791f2b53a9 | |||
| 9f806aa48a | |||
| 85dd8f8b77 | |||
| e91beb5518 | |||
| 39fbf43019 | |||
| e8eb607325 | |||
| 974840bbac | |||
| be5f6e3a6e | |||
| 19debed4d1 | |||
| 4903c017f4 | |||
| 6c3f31c32a | |||
| 73d79c1f61 | |||
| 4ef5f7d290 | |||
| 9b7d54fdfb | |||
| 4e17421c7e | |||
| 2b4513d68b | |||
| 47c0b04de1 | |||
| ee077978b9 | |||
| 1dc5e67da6 | |||
| 0512243be0 | |||
| ba3b3b4ce6 | |||
| 57e813d0ce | |||
| 1d24a4a309 | |||
| fe7e7640b5 | |||
| 67b93909ac | |||
| 17f651c47a | |||
| 928cc7480a | |||
| bf8e59ddee | |||
| fa0aad779d |
28
.gitmodules
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
[submodule "web/documentserver-example/nodejs/public/assets"]
|
||||
path = web/documentserver-example/nodejs/public/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/java/src/main/resources/assets"]
|
||||
path = web/documentserver-example/java/src/main/resources/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/php/assets"]
|
||||
path = web/documentserver-example/php/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/python/assets"]
|
||||
path = web/documentserver-example/python/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/csharp-mvc/assets"]
|
||||
path = web/documentserver-example/csharp-mvc/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/csharp/assets"]
|
||||
path = web/documentserver-example/csharp/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
[submodule "web/documentserver-example/ruby/public/assets"]
|
||||
path = web/documentserver-example/ruby/public/assets
|
||||
url = https://github.com/ONLYOFFICE/document-templates
|
||||
branch = main/en
|
||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,15 @@
|
||||
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
|
||||
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
|
||||
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
|
||||
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
|
||||
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
|
||||
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
|
||||
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
|
||||
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
|
||||
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
|
||||
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
|
||||
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
@ -44,10 +44,13 @@ a, a:hover, a:visited {
|
||||
|
||||
|
||||
.top-panel {
|
||||
background: url("images/logo.png") no-repeat 30px center #3D4A6B;
|
||||
background: #3D4A6B;
|
||||
height: 80px;
|
||||
width: 100%;
|
||||
}
|
||||
.top-panel img {
|
||||
margin: 12px 0 0 16px;
|
||||
}
|
||||
.main-panel {
|
||||
margin: 80px auto;
|
||||
width: 600px;
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using System.Web.Mvc;
|
||||
using OnlineEditorsExampleMVC.Helpers;
|
||||
using OnlineEditorsExampleMVC.Models;
|
||||
@ -35,7 +36,7 @@ namespace OnlineEditorsExampleMVC.Controllers
|
||||
{
|
||||
Mode = editorsMode,
|
||||
Type = editorsType,
|
||||
FileName = fileName
|
||||
FileName = Path.GetFileName(fileName)
|
||||
};
|
||||
|
||||
return View("Editor", file);
|
||||
|
||||
@ -72,7 +72,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
return directory + fileName;
|
||||
return directory + Path.GetFileName(fileName);
|
||||
}
|
||||
|
||||
public static string HistoryDir(string storagePath)
|
||||
@ -93,7 +93,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
public static int GetFileVersion(string historyPath)
|
||||
{
|
||||
if (!Directory.Exists(historyPath)) return 0;
|
||||
return Directory.EnumerateDirectories(historyPath).Count();
|
||||
return Directory.EnumerateDirectories(historyPath).Count() + 1;
|
||||
}
|
||||
|
||||
public static int GetFileVersion(string fileName, string userAddress)
|
||||
@ -114,24 +114,26 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
return name;
|
||||
}
|
||||
|
||||
public static List<string> GetStoredFiles()
|
||||
public static List<FileInfo> GetStoredFiles()
|
||||
{
|
||||
var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
|
||||
if (!Directory.Exists(directory)) return new List<string>();
|
||||
if (!Directory.Exists(directory)) return new List<FileInfo>();
|
||||
|
||||
var directoryInfo = new DirectoryInfo(directory);
|
||||
|
||||
var storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Select(fileInfo => fileInfo.Name).ToList();
|
||||
List<FileInfo> storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).ToList();
|
||||
|
||||
return storedFiles;
|
||||
}
|
||||
|
||||
public static string CreateDemo(string fileExt, bool withContent)
|
||||
{
|
||||
var demoName = (withContent ? "sample." : "new.") + fileExt;
|
||||
var demoPath = "assets\\" + (withContent ? "sample\\" : "new\\");
|
||||
|
||||
var fileName = GetCorrectName(demoName);
|
||||
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + "app_data\\" + demoName, StoragePath(fileName));
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, StoragePath(fileName));
|
||||
|
||||
return fileName;
|
||||
}
|
||||
@ -141,15 +143,15 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
var histDir = HistoryDir(StoragePath(fileName, null));
|
||||
Directory.CreateDirectory(histDir);
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString() },
|
||||
{ "created", DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss") },
|
||||
{ "id", string.IsNullOrEmpty(uid) ? "uid-1" : uid },
|
||||
{ "name", string.IsNullOrEmpty(uname) ? "John Smith" : uname }
|
||||
}));
|
||||
}
|
||||
|
||||
public static string GetFileUri(string fileName)
|
||||
public static string GetFileUri(string fileName, Boolean forDocumentServer)
|
||||
{
|
||||
var uri = new UriBuilder(HttpContext.Current.Request.Url)
|
||||
var uri = new UriBuilder(GetServerUrl(forDocumentServer))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath + "/"
|
||||
+ CurUserHostAddress() + "/"
|
||||
@ -162,7 +164,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
|
||||
public static string GetPathUri(string path)
|
||||
{
|
||||
var uri = new UriBuilder(HttpContext.Current.Request.Url)
|
||||
var uri = new UriBuilder(GetServerUrl(true))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath + "/"
|
||||
+ path,
|
||||
@ -172,9 +174,26 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
return uri.ToString();
|
||||
}
|
||||
|
||||
public static string GetServerUrl(Boolean forDocumentServer)
|
||||
{
|
||||
if (forDocumentServer && !WebConfigurationManager.AppSettings["files.docservice.url.example"].Equals(""))
|
||||
{
|
||||
return WebConfigurationManager.AppSettings["files.docservice.url.example"];
|
||||
}
|
||||
else
|
||||
{
|
||||
var uri = new UriBuilder(HttpContext.Current.Request.Url) { Query = "" };
|
||||
var requestHost = HttpContext.Current.Request.Headers["Host"];
|
||||
if (!string.IsNullOrEmpty(requestHost))
|
||||
uri = new UriBuilder(uri.Scheme + "://" + requestHost);
|
||||
|
||||
return uri.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetCallback(string fileName)
|
||||
{
|
||||
var callbackUrl = new UriBuilder(HttpContext.Current.Request.Url)
|
||||
var callbackUrl = new UriBuilder(GetServerUrl(true))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
@ -201,5 +220,36 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
return ".docx";
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Dictionary<string, object>> GetFilesInfo(string fileId = null)
|
||||
{
|
||||
var files = new List<Dictionary<string, object>>();
|
||||
|
||||
foreach (var file in GetStoredFiles())
|
||||
{
|
||||
var dictionary = new Dictionary<string, object>();
|
||||
dictionary.Add("version", GetFileVersion(file.Name, null));
|
||||
dictionary.Add("id", ServiceConverter.GenerateRevisionId(DocManagerHelper.CurUserHostAddress() + "/" + file.Name + "/" + File.GetLastWriteTime(DocManagerHelper.StoragePath(file.Name, null)).GetHashCode()));
|
||||
dictionary.Add("contentLength", Math.Round(file.Length / 1024.0, 2) + " KB");
|
||||
dictionary.Add("pureContentLength", file.Length);
|
||||
dictionary.Add("title", file.Name);
|
||||
dictionary.Add("updated", file.LastWriteTime.ToString());
|
||||
|
||||
if (fileId != null)
|
||||
{
|
||||
if (fileId.Equals(dictionary["id"]))
|
||||
{
|
||||
files.Add(dictionary);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
files.Add(dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
/// </summary>
|
||||
static ServiceConverter()
|
||||
{
|
||||
DocumentConverterUrl = WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "";
|
||||
DocumentConverterUrl = (WebConfigurationManager.AppSettings["files.docservice.url.site"] ?? "") + (WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "");
|
||||
|
||||
Int32.TryParse(WebConfigurationManager.AppSettings["files.docservice.timeout"], out ConvertTimeout);
|
||||
ConvertTimeout = ConvertTimeout > 0 ? ConvertTimeout : 120000;
|
||||
@ -119,7 +119,8 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
|
||||
var payloadToken = JwtManager.Encode(payload);
|
||||
var bodyToken = JwtManager.Encode(body);
|
||||
request.Headers.Add("Authorization", "Bearer " + payloadToken);
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken);
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
}
|
||||
|
||||
@ -34,7 +34,12 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
|
||||
public string FileUri
|
||||
{
|
||||
get { return DocManagerHelper.GetFileUri(FileName); }
|
||||
get { return DocManagerHelper.GetFileUri(FileName, true); }
|
||||
}
|
||||
|
||||
public string FileUriUser
|
||||
{
|
||||
get { return DocManagerHelper.GetFileUri(FileName, false); }
|
||||
}
|
||||
|
||||
public string FileName { get; set; }
|
||||
@ -64,6 +69,12 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
var canEdit = DocManagerHelper.EditedExts.Contains(ext);
|
||||
var mode = canEdit && editorsMode != "view" ? "edit" : "view";
|
||||
|
||||
object favorite = null;
|
||||
if (!string.IsNullOrEmpty(request.Cookies.GetOrDefault("uid", null)))
|
||||
{
|
||||
favorite = request.Cookies.GetOrDefault("uid", null).Equals("uid-2");
|
||||
}
|
||||
|
||||
var actionLink = request.GetOrDefault("actionLink", null);
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink);
|
||||
|
||||
@ -81,8 +92,9 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
"info", new Dictionary<string, object>
|
||||
{
|
||||
{ "author", "Me" },
|
||||
{ "created", DateTime.Now.ToShortDateString() }
|
||||
{ "owner", "Me" },
|
||||
{ "uploaded", DateTime.Now.ToShortDateString() },
|
||||
{ "favorite", favorite}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -116,9 +128,9 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
"embedded", new Dictionary<string, object>
|
||||
{
|
||||
{ "saveUrl", FileUri },
|
||||
{ "embedUrl", FileUri },
|
||||
{ "shareUrl", FileUri },
|
||||
{ "saveUrl", FileUriUser },
|
||||
{ "embedUrl", FileUriUser },
|
||||
{ "shareUrl", FileUriUser },
|
||||
{ "toolbarDocked", "top" }
|
||||
}
|
||||
},
|
||||
@ -162,18 +174,18 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
var hist = new List<Dictionary<string, object>>();
|
||||
var histData = new Dictionary<string, object>();
|
||||
|
||||
for (var i = 0; i <= currentVersion; i++)
|
||||
for (var i = 1; i <= currentVersion; i++)
|
||||
{
|
||||
var obj = new Dictionary<string, object>();
|
||||
var dataObj = new Dictionary<string, object>();
|
||||
var verDir = DocManagerHelper.VersionDir(histDir, i + 1);
|
||||
var verDir = DocManagerHelper.VersionDir(histDir, i);
|
||||
|
||||
var key = i == currentVersion ? Key : File.ReadAllText(Path.Combine(verDir, "key.txt"));
|
||||
|
||||
obj.Add("key", key);
|
||||
obj.Add("version", i);
|
||||
|
||||
if (i == 0)
|
||||
if (i == 1)
|
||||
{
|
||||
var infoPath = Path.Combine(histDir, "createdInfo.json");
|
||||
|
||||
@ -191,9 +203,9 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
dataObj.Add("key", key);
|
||||
dataObj.Add("url", i == currentVersion ? FileUri : DocManagerHelper.GetPathUri(Directory.GetFiles(verDir, "prev.*")[0].Substring(HttpRuntime.AppDomainAppPath.Length)));
|
||||
dataObj.Add("version", i);
|
||||
if (i > 0)
|
||||
if (i > 1)
|
||||
{
|
||||
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(DocManagerHelper.VersionDir(histDir, i), "changes.json")));
|
||||
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(DocManagerHelper.VersionDir(histDir, i - 1), "changes.json")));
|
||||
var change = ((Dictionary<string, object>)((ArrayList)changes["changes"])[0]);
|
||||
|
||||
obj.Add("changes", changes["changes"]);
|
||||
@ -201,16 +213,20 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
obj.Add("created", change["created"]);
|
||||
obj.Add("user", change["user"]);
|
||||
|
||||
var prev = (Dictionary<string, object>)histData[(i - 1).ToString()];
|
||||
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()];
|
||||
dataObj.Add("previous", new Dictionary<string, object>() {
|
||||
{ "key", prev["key"] },
|
||||
{ "url", prev["url"] },
|
||||
});
|
||||
dataObj.Add("changesUrl", DocManagerHelper.GetPathUri(Path.Combine(DocManagerHelper.VersionDir(histDir, i), "diff.zip").Substring(HttpRuntime.AppDomainAppPath.Length)));
|
||||
dataObj.Add("changesUrl", DocManagerHelper.GetPathUri(Path.Combine(DocManagerHelper.VersionDir(histDir, i - 1), "diff.zip").Substring(HttpRuntime.AppDomainAppPath.Length)));
|
||||
}
|
||||
if(JwtManager.Enabled)
|
||||
{
|
||||
var token = JwtManager.Encode(dataObj);
|
||||
dataObj.Add("token", token);
|
||||
}
|
||||
|
||||
hist.Add(obj);
|
||||
histData.Add(i.ToString(), dataObj);
|
||||
histData.Add((i - 1).ToString(), dataObj);
|
||||
}
|
||||
|
||||
history = jss.Serialize(new Dictionary<string, object>()
|
||||
@ -221,5 +237,86 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
historyData = jss.Serialize(histData);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetCompareFileData(out string compareConfig)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
|
||||
var compareFileUrl = new UriBuilder(DocManagerHelper.GetServerUrl(true))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=download&fileName=" + HttpUtility.UrlEncode("sample.docx")
|
||||
};
|
||||
|
||||
var dataCompareFile = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "docx" },
|
||||
{ "url", compareFileUrl.ToString() }
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
var compareFileToken = JwtManager.Encode(dataCompareFile);
|
||||
dataCompareFile.Add("token", compareFileToken);
|
||||
}
|
||||
|
||||
compareConfig = jss.Serialize(dataCompareFile);
|
||||
}
|
||||
|
||||
public void GetLogoConfig(out string logoUrl)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
|
||||
var mailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(true))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "Content\\images\\logo.png"
|
||||
};
|
||||
|
||||
var logoConfig = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "png"},
|
||||
{ "url", mailMergeUrl.ToString()}
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
var token = JwtManager.Encode(logoConfig);
|
||||
logoConfig.Add("token", token);
|
||||
}
|
||||
|
||||
logoUrl = jss.Serialize(logoConfig).Replace("{", "").Replace("}", "");
|
||||
}
|
||||
|
||||
public void GetMailMergeConfig(out string dataMailMergeRecipients)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
|
||||
var mailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(true))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=csv"
|
||||
};
|
||||
|
||||
var mailMergeConfig = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "csv" },
|
||||
{ "url", mailMergeUrl.ToString()}
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
var mailmergeToken = JwtManager.Encode(mailMergeConfig);
|
||||
mailMergeConfig.Add("token", mailmergeToken);
|
||||
}
|
||||
|
||||
dataMailMergeRecipients = jss.Serialize(mailMergeConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,9 +168,15 @@
|
||||
<Content Include="WebEditor.ashx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="assets\AUTHORS.md" />
|
||||
<Content Include="assets\LICENSE" />
|
||||
<Content Include="assets\new\new.docx" />
|
||||
<Content Include="assets\new\new.pptx" />
|
||||
<Content Include="assets\new\new.xlsx" />
|
||||
<Content Include="assets\sample\csv.csv" />
|
||||
<Content Include="assets\sample\sample.docx" />
|
||||
<Content Include="assets\sample\sample.pptx" />
|
||||
<Content Include="assets\sample\sample.xlsx" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%: Scripts.Render(new []{ WebConfigurationManager.AppSettings["files.docservice.url.api"] }) %>
|
||||
<%: Scripts.Render(new []{ WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.api"] }) %>
|
||||
|
||||
<script type="text/javascript" language="javascript">
|
||||
|
||||
@ -96,6 +96,34 @@
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var onMetaChange = function (event) {
|
||||
var favorite = !!event.data.favorite;
|
||||
var title = document.title.replace(/^\☆/g, "");
|
||||
document.title = (favorite ? "☆" : "") + title;
|
||||
docEditor.setFavorite(favorite);
|
||||
};
|
||||
|
||||
var onRequestInsertImage = function (event) {
|
||||
<% string logoUrl;%>
|
||||
<% Model.GetLogoConfig(out logoUrl); %>
|
||||
docEditor.insertImage({
|
||||
"c": event.data.c,
|
||||
<%= logoUrl%>
|
||||
})
|
||||
};
|
||||
|
||||
var onRequestCompareFile = function () {
|
||||
<% string compareFileData; %>
|
||||
<% Model.GetCompareFileData(out compareFileData); %>
|
||||
docEditor.setRevisedFile(<%=compareFileData%>);
|
||||
};
|
||||
|
||||
var onRequestMailMergeRecipients = function (event) {
|
||||
<% string dataMailMergeRecipients; %>
|
||||
<% Model.GetMailMergeConfig(out dataMailMergeRecipients); %>
|
||||
docEditor.setMailMergeRecipients(<%= dataMailMergeRecipients%>);
|
||||
};
|
||||
|
||||
var config = <%= Model.GetDocConfig(Request, Url) %>;
|
||||
|
||||
config.width = "100%";
|
||||
@ -108,6 +136,10 @@
|
||||
'onError': onError,
|
||||
'onOutdatedVersion': onOutdatedVersion,
|
||||
"onMakeActionLink": onMakeActionLink,
|
||||
"onMetaChange": onMetaChange,
|
||||
"onRequestInsertImage": onRequestInsertImage,
|
||||
"onRequestCompareFile": onRequestCompareFile,
|
||||
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
|
||||
};
|
||||
|
||||
<% string hist, histData; %>
|
||||
@ -120,7 +152,7 @@
|
||||
config.events['onRequestHistoryData'] = function (event) {
|
||||
var ver = event.data;
|
||||
var histData = <%= histData %>;
|
||||
docEditor.setHistoryData(histData[ver]);
|
||||
docEditor.setHistoryData(histData[ver - 1]);
|
||||
};
|
||||
config.events['onRequestHistoryClose '] = function () {
|
||||
document.location.reload();
|
||||
|
||||
@ -37,7 +37,11 @@
|
||||
<%: Styles.Render("~/Content/css") %>
|
||||
</head>
|
||||
<body>
|
||||
<div class="top-panel"></div>
|
||||
<div class="top-panel">
|
||||
<a href="">
|
||||
<img src ="content/images/logo.svg" alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors</span>
|
||||
<br />
|
||||
@ -148,75 +152,75 @@
|
||||
<% foreach (var storedFile in storedFiles)
|
||||
{ %>
|
||||
<%
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile);
|
||||
var docType = FileUtility.GetFileType(storedFile).ToString().ToLower();
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
|
||||
var docType = FileUtility.GetFileType(storedFile.Name).ToString().ToLower();
|
||||
%>
|
||||
<tr class="tableRow" title="<%= storedFile %>">
|
||||
<tr class="tableRow" title="<%= storedFile.Name %>">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="<%= Url.Action("Editor", "Home", new { fileName = storedFile }) %>" target="_blank">
|
||||
<span title="<%= storedFile %>"><%= storedFile %></span>
|
||||
<a class="stored-edit <%= docType %>" href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name }) %>" target="_blank">
|
||||
<span title="<%= storedFile.Name %>"><%= storedFile.Name %></span>
|
||||
</a>
|
||||
<a href="<%= Url.Content(DocManagerHelper.CurUserHostAddress() + "/" + storedFile) %>">
|
||||
<img class="icon-download" src="content/images/download-24.png" alt="Download" title="Download" />
|
||||
</a>
|
||||
<a class="delete-file" data-filename="<%= storedFile %>">
|
||||
<a class="delete-file" data-filename="<%= storedFile.Name %>">
|
||||
<img class="icon-delete" src="content/images/delete-24.png" alt="Delete" title="Delete" />
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "edit" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "edit" }) %>" target="_blank">
|
||||
<img src="content/images/desktop-24.png" alt="Open in editor for full size screens" title="Open in editor for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "mobile", editorsMode = "edit" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "edit" }) %>" target="_blank">
|
||||
<img src="content/images/mobile-24.png" alt="Open in editor for mobile devices" title="Open in editor for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<% if (docType == "text") { %>
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "review" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "review" }) %>" target="_blank">
|
||||
<img src="content/images/review-24.png" alt="Open in editor for review" title="Open in editor for review"/>
|
||||
</a>
|
||||
<% } else if (docType == "spreadsheet") { %>
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "filter" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "filter" }) %>" target="_blank">
|
||||
<img src="content/images/filter-24.png" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" />
|
||||
</a>
|
||||
<% } %>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "comment" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "comment" }) %>" target="_blank">
|
||||
<img src="content/images/comment-24.png" alt="Open in editor for comment" title="Open in editor for comment"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<% if (docType == "text") { %>
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "fillForms" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms" }) %>" target="_blank">
|
||||
<img src="content/images/fill-forms-24.png" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
|
||||
</a>
|
||||
<% } %>
|
||||
</td>
|
||||
<td class="contentCells contentCells-shift contentCells-icon">
|
||||
<% if (docType == "text") { %>
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "blockcontent" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "blockcontent" }) %>" target="_blank">
|
||||
<img src="content/images/block-content-24.png" alt="Open in editor without content control modification" title="Open in editor without content control modification"/>
|
||||
</a>
|
||||
<% } %>
|
||||
</td>
|
||||
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "view" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "view" }) %>" target="_blank">
|
||||
<img src="content/images/desktop-24.png" alt="Open in viewer for full size screens" title="Open in viewer for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "mobile", editorsMode = "view" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "view" }) %>" target="_blank">
|
||||
<img src="content/images/mobile-24.png" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "embedded", editorsMode = "embedded" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "embedded", editorsMode = "embedded" }) %>" target="_blank">
|
||||
<img src="content/images/embeded-24.png" alt="Open in embedded mode" title="Open in embedded mode"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -281,7 +285,7 @@
|
||||
<div id="cancelEdit" class="button gray">Cancel</div>
|
||||
</div>
|
||||
|
||||
<span id="loadScripts" data-docs="<%= WebConfigurationManager.AppSettings["files.docservice.url.preloader"] %>"></span>
|
||||
<span id="loadScripts" data-docs="<%= WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.preloader"] %>"></span>
|
||||
|
||||
<div class="bottom-panel">© Ascensio System SIA <%= DateTime.Now.Year.ToString() %>. All rights reserved.</div>
|
||||
|
||||
|
||||
@ -26,6 +26,11 @@
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false" />
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<handlers>
|
||||
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
|
||||
<remove name="OPTIONSVerbHandler" />
|
||||
@ -47,6 +52,10 @@
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
|
||||
@ -22,9 +22,9 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Services;
|
||||
using System.Web.Configuration;
|
||||
using OnlineEditorsExampleMVC.Helpers;
|
||||
using OnlineEditorsExampleMVC.Models;
|
||||
|
||||
@ -50,6 +50,15 @@ namespace OnlineEditorsExampleMVC
|
||||
case "remove":
|
||||
Remove(context);
|
||||
break;
|
||||
case "download":
|
||||
Download(context);
|
||||
break;
|
||||
case "csv":
|
||||
GetCsv(context);
|
||||
break;
|
||||
case "files":
|
||||
Files(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,8 +111,8 @@ namespace OnlineEditorsExampleMVC
|
||||
context.Response.ContentType = "text/plain";
|
||||
try
|
||||
{
|
||||
var fileName = context.Request["filename"];
|
||||
var fileUri = DocManagerHelper.GetFileUri(fileName);
|
||||
var fileName = Path.GetFileName(context.Request["filename"]);
|
||||
var fileUri = DocManagerHelper.GetFileUri(fileName, true);
|
||||
|
||||
var extension = (Path.GetExtension(fileUri) ?? "").Trim('.');
|
||||
var internalExtension = DocManagerHelper.GetInternalExtension(FileUtility.GetFileType(fileName)).Trim('.');
|
||||
@ -166,7 +175,7 @@ namespace OnlineEditorsExampleMVC
|
||||
private static void Track(HttpContext context)
|
||||
{
|
||||
var userAddress = context.Request["userAddress"];
|
||||
var fileName = context.Request["fileName"];
|
||||
var fileName = Path.GetFileName(context.Request["fileName"]);
|
||||
|
||||
string body;
|
||||
try
|
||||
@ -188,18 +197,31 @@ namespace OnlineEditorsExampleMVC
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
string token = null;
|
||||
|
||||
if (fileData.ContainsKey("token"))
|
||||
{
|
||||
fileData = jss.Deserialize<Dictionary<string, object>>(JwtManager.Decode(fileData["token"].ToString()));
|
||||
token = JwtManager.Decode(fileData["token"].ToString());
|
||||
}
|
||||
else if (context.Request.Headers.AllKeys.Contains("Authorization", StringComparer.InvariantCultureIgnoreCase))
|
||||
else if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var headerToken = context.Request.Headers.Get("Authorization").Substring("Bearer ".Length);
|
||||
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(JwtManager.Decode(headerToken))["payload"];
|
||||
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
|
||||
token = JwtManager.Decode(headerToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Expected JWT");
|
||||
context.Response.Write("{\"error\":1,\"message\":\"JWT expected\"}");
|
||||
}
|
||||
|
||||
if (token != null && !token.Equals(""))
|
||||
{
|
||||
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(token)["payload"];
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Write("{\"error\":1,\"message\":\"JWT validation failed\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,7 +238,7 @@ namespace OnlineEditorsExampleMVC
|
||||
{
|
||||
var storagePath = DocManagerHelper.StoragePath(fileName, userAddress);
|
||||
var histDir = DocManagerHelper.HistoryDir(storagePath);
|
||||
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir) + 1);
|
||||
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir));
|
||||
|
||||
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir);
|
||||
|
||||
@ -253,7 +275,7 @@ namespace OnlineEditorsExampleMVC
|
||||
context.Response.ContentType = "text/plain";
|
||||
try
|
||||
{
|
||||
var fileName = context.Request["fileName"];
|
||||
var fileName = Path.GetFileName(context.Request["fileName"]);
|
||||
Remove(fileName);
|
||||
|
||||
context.Response.Write("{ \"success\": true }");
|
||||
@ -273,6 +295,64 @@ namespace OnlineEditorsExampleMVC
|
||||
if (Directory.Exists(histDir)) Directory.Delete(histDir, true);
|
||||
}
|
||||
|
||||
private static void Files(HttpContext context)
|
||||
{
|
||||
List<Dictionary<string, object>> files = null;
|
||||
|
||||
try
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
context.Response.ContentType = "application/json";
|
||||
|
||||
if (context.Request["fileId"] == null)
|
||||
{
|
||||
files = DocManagerHelper.GetFilesInfo();
|
||||
context.Response.Write(jss.Serialize(files));
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileId = context.Request["fileId"];
|
||||
files = DocManagerHelper.GetFilesInfo(fileId);
|
||||
if (files.Count == 0)
|
||||
{
|
||||
context.Response.Write("\"File not found\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Write(jss.Serialize(files));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.Response.Write("{ \"error\": \"" + e.Message + "\"}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void Download(HttpContext context)
|
||||
{
|
||||
var fileName = "sample/" + Path.GetFileName(context.Request["filename"]);
|
||||
download(fileName, context);
|
||||
}
|
||||
|
||||
private static void GetCsv(HttpContext context)
|
||||
{
|
||||
var fileName = "sample/" + "csv.csv";
|
||||
download(fileName, context);
|
||||
}
|
||||
|
||||
private static void download(string fileName, HttpContext context)
|
||||
{
|
||||
var csvPath = HttpRuntime.AppDomainAppPath + "assets/" + fileName;
|
||||
var fileinf = new FileInfo(csvPath);
|
||||
context.Response.AddHeader("Content-Length", fileinf.Length.ToString());
|
||||
context.Response.AddHeader("Content-Type", MimeMapping.GetMimeMapping(csvPath));
|
||||
var tmp = HttpUtility.UrlEncode(Path.GetFileName(csvPath));
|
||||
tmp = tmp.Replace("+", "%20");
|
||||
context.Response.AddHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + tmp);
|
||||
context.Response.TransmitFile(csvPath);
|
||||
}
|
||||
|
||||
private static void DownloadToFile(string url, string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url");
|
||||
|
||||
1
web/documentserver-example/csharp-mvc/assets
Submodule
@ -11,11 +11,17 @@
|
||||
|
||||
<add key="files.docservice.viewed-docs" value=".pdf|.djvu|.xps"/>
|
||||
<add key="files.docservice.edited-docs" value=".docx|.xlsx|.csv|.pptx|.txt"/>
|
||||
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub"/>
|
||||
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub|.fb2"/>
|
||||
<add key="files.docservice.timeout" value="120000" />
|
||||
<add key="files.docservice.secret" value="" />
|
||||
<add key="files.docservice.header" value="Authorization" />
|
||||
|
||||
<add key="files.docservice.url.converter" value="https://documentserver/ConvertService.ashx"/>
|
||||
<add key="files.docservice.url.api" value="https://documentserver/web-apps/apps/api/documents/api.js"/>
|
||||
<add key="files.docservice.url.preloader" value="https://documentserver/web-apps/apps/api/documents/cache-scripts.html"/>
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
<add key="files.docservice.url.converter" value="ConvertService.ashx"/>
|
||||
<add key="files.docservice.url.api" value="web-apps/apps/api/documents/api.js"/>
|
||||
<add key="files.docservice.url.preloader" value="web-apps/apps/api/documents/cache-scripts.html"/>
|
||||
|
||||
<add key="files.docservice.url.example" value=""/>
|
||||
|
||||
</appSettings>
|
||||
|
||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.0 KiB |
15
web/documentserver-example/csharp/App_Themes/images/logo.svg
Normal file
@ -0,0 +1,15 @@
|
||||
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
|
||||
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
|
||||
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
|
||||
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
|
||||
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
|
||||
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
|
||||
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
|
||||
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
|
||||
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
|
||||
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
|
||||
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
@ -44,10 +44,13 @@ a, a:hover, a:visited {
|
||||
|
||||
|
||||
.top-panel {
|
||||
background: url("images/logo.png") no-repeat 30px center #3D4A6B;
|
||||
background: #3D4A6B;
|
||||
height: 80px;
|
||||
width: 100%;
|
||||
}
|
||||
.top-panel img {
|
||||
margin: 12px 0 0 16px;
|
||||
}
|
||||
.main-panel {
|
||||
margin: 80px auto;
|
||||
width: 600px;
|
||||
|
||||
@ -57,7 +57,11 @@
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
|
||||
<div class="top-panel"></div>
|
||||
<div class="top-panel">
|
||||
<a href="">
|
||||
<img src ="app_themes/images/logo.svg" alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors</span>
|
||||
<br />
|
||||
@ -168,18 +172,18 @@
|
||||
<% foreach (var storedFile in storedFiles)
|
||||
{ %>
|
||||
<%
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile);
|
||||
var docType = DocumentType(storedFile);
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
|
||||
var docType = DocumentType(storedFile.Name);
|
||||
%>
|
||||
<tr class="tableRow" title="<%= storedFile %>">
|
||||
<tr class="tableRow" title="<%= storedFile.Name %>">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="<%= editUrl %>" target="_blank">
|
||||
<span title="<%= storedFile %>"><%= storedFile %></span>
|
||||
<span title="<%= storedFile.Name %>"><%= storedFile.Name %></span>
|
||||
</a>
|
||||
<a href="<%= VirtualPath + WebConfigurationManager.AppSettings["storage-path"] + storedFile %>">
|
||||
<a href="<%= VirtualPath + WebConfigurationManager.AppSettings["storage-path"] + storedFile.Name %>">
|
||||
<img class="icon-download" src="app_themes/images/download-24.png" alt="Download" title="Download" />
|
||||
</a>
|
||||
<a class="delete-file" data-filename="<%= storedFile %>">
|
||||
<a class="delete-file" data-filename="<%= storedFile.Name %>">
|
||||
<img class="icon-delete" src="app_themes/images/delete-24.png" alt="Delete" title="Delete" />
|
||||
</a>
|
||||
</td>
|
||||
@ -254,7 +258,7 @@
|
||||
<div class="help-block">
|
||||
<span>Want to learn how it works?</span>
|
||||
|
||||
<% var examples = new DirectoryInfo(HttpRuntime.AppDomainAppPath + "App_Data")
|
||||
<% var examples = new DirectoryInfo(HttpRuntime.AppDomainAppPath + "assets")
|
||||
.GetFiles("*.zip", SearchOption.TopDirectoryOnly)
|
||||
.Select(fileInfo => fileInfo.Name).ToList();
|
||||
if (examples.Any())
|
||||
|
||||
@ -68,18 +68,6 @@ namespace OnlineEditorsExample
|
||||
|
||||
public partial class _Default : Page
|
||||
{
|
||||
public static UriBuilder Host
|
||||
{
|
||||
get
|
||||
{
|
||||
var uri = new UriBuilder(HttpContext.Current.Request.Url) {Query = ""};
|
||||
var requestHost = HttpContext.Current.Request.Headers["Host"];
|
||||
if (!string.IsNullOrEmpty(requestHost))
|
||||
uri = new UriBuilder(uri.Scheme + "://" + requestHost);
|
||||
|
||||
return uri;
|
||||
}
|
||||
}
|
||||
|
||||
public static string VirtualPath
|
||||
{
|
||||
@ -144,7 +132,7 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
return directory + fileName;
|
||||
return directory + Path.GetFileName(fileName);
|
||||
}
|
||||
|
||||
public static string HistoryDir(string storagePath)
|
||||
@ -165,7 +153,7 @@ namespace OnlineEditorsExample
|
||||
public static int GetFileVersion(string historyPath)
|
||||
{
|
||||
if (!Directory.Exists(historyPath)) return 0;
|
||||
return Directory.EnumerateDirectories(historyPath).Count();
|
||||
return Directory.EnumerateDirectories(historyPath).Count() + 1;
|
||||
}
|
||||
|
||||
public static int GetFileVersion(string fileName, string userAddress)
|
||||
@ -173,13 +161,30 @@ namespace OnlineEditorsExample
|
||||
return GetFileVersion(HistoryDir(StoragePath(fileName, userAddress)));
|
||||
}
|
||||
|
||||
public static string FileUri(string fileName)
|
||||
public static string FileUri(string fileName, Boolean forDocumentServer)
|
||||
{
|
||||
var uri = Host;
|
||||
var uri = new UriBuilder(GetServerUrl(forDocumentServer));
|
||||
uri.Path = VirtualPath + fileName;
|
||||
return uri.ToString();
|
||||
}
|
||||
|
||||
public static string GetServerUrl(Boolean forDocumentServer)
|
||||
{
|
||||
if (forDocumentServer && !WebConfigurationManager.AppSettings["files.docservice.url.example"].Equals(""))
|
||||
{
|
||||
return WebConfigurationManager.AppSettings["files.docservice.url.example"];
|
||||
}
|
||||
else
|
||||
{
|
||||
var uri = new UriBuilder(HttpContext.Current.Request.Url) { Query = "" };
|
||||
var requestHost = HttpContext.Current.Request.Headers["Host"];
|
||||
if (!string.IsNullOrEmpty(requestHost))
|
||||
uri = new UriBuilder(uri.Scheme + "://" + requestHost);
|
||||
|
||||
return uri.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static string DocumentType(string fileName)
|
||||
{
|
||||
var ext = Path.GetExtension(fileName).ToLower();
|
||||
@ -191,7 +196,7 @@ namespace OnlineEditorsExample
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
protected string UrlPreloadScripts = WebConfigurationManager.AppSettings["files.docservice.url.preloader"];
|
||||
protected string UrlPreloadScripts = WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.preloader"];
|
||||
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
@ -232,7 +237,7 @@ namespace OnlineEditorsExample
|
||||
var histDir = HistoryDir(savedFileName);
|
||||
Directory.CreateDirectory(histDir);
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString() },
|
||||
{ "created", DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss") },
|
||||
{ "id", context.Request.Cookies.GetOrDefault("uid", "uid-1") },
|
||||
{ "name", context.Request.Cookies.GetOrDefault("uname", "John Smith") }
|
||||
}));
|
||||
@ -279,7 +284,7 @@ namespace OnlineEditorsExample
|
||||
var histDir = HistoryDir(StoragePath(_fileName, null));
|
||||
Directory.CreateDirectory(histDir);
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString() },
|
||||
{ "created", DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss") },
|
||||
{ "id", request.Cookies.GetOrDefault("uid", "uid-1") },
|
||||
{ "name", request.Cookies.GetOrDefault("uname", "John Smith") }
|
||||
}));
|
||||
@ -293,7 +298,7 @@ namespace OnlineEditorsExample
|
||||
|
||||
public static string DoConvert(HttpContext context)
|
||||
{
|
||||
_fileName = context.Request["filename"];
|
||||
_fileName = Path.GetFileName(context.Request["filename"]);
|
||||
|
||||
var extension = (Path.GetExtension(_fileName) ?? "").Trim('.');
|
||||
var internalExtension = FileType.GetInternalExtension(_fileName).Trim('.');
|
||||
@ -301,10 +306,10 @@ namespace OnlineEditorsExample
|
||||
if (ConvertExts.Contains("." + extension)
|
||||
&& !string.IsNullOrEmpty(internalExtension))
|
||||
{
|
||||
var key = ServiceConverter.GenerateRevisionId(FileUri(_fileName));
|
||||
var key = ServiceConverter.GenerateRevisionId(FileUri(_fileName, true));
|
||||
|
||||
string newFileUri;
|
||||
var result = ServiceConverter.GetConvertedUri(FileUri(_fileName), extension, internalExtension, key, true, out newFileUri);
|
||||
var result = ServiceConverter.GetConvertedUri(FileUri(_fileName, true), extension, internalExtension, key, true, out newFileUri);
|
||||
if (result != 100)
|
||||
{
|
||||
return "{ \"step\" : \"" + result + "\", \"filename\" : \"" + _fileName + "\"}";
|
||||
@ -367,15 +372,45 @@ namespace OnlineEditorsExample
|
||||
return name;
|
||||
}
|
||||
|
||||
protected static List<string> GetStoredFiles()
|
||||
protected static List<FileInfo> GetStoredFiles()
|
||||
{
|
||||
var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
|
||||
if (!Directory.Exists(directory)) return new List<string>();
|
||||
if (!Directory.Exists(directory)) return new List<FileInfo>();
|
||||
|
||||
var directoryInfo = new DirectoryInfo(directory);
|
||||
|
||||
var storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Select(fileInfo => fileInfo.Name).ToList();
|
||||
List<FileInfo> storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).ToList();
|
||||
return storedFiles;
|
||||
}
|
||||
|
||||
public static List<Dictionary<string, object>> GetFilesInfo(string fileId = null)
|
||||
{
|
||||
var files = new List<Dictionary<string, object>>();
|
||||
|
||||
foreach (var file in GetStoredFiles())
|
||||
{
|
||||
var dictionary = new Dictionary<string, object>();
|
||||
dictionary.Add("version", GetFileVersion(file.Name, null));
|
||||
dictionary.Add("id", ServiceConverter.GenerateRevisionId(_Default.CurUserHostAddress(null) + "/" + file.Name + "/" + File.GetLastWriteTime(_Default.StoragePath(file.Name, null)).GetHashCode()));
|
||||
dictionary.Add("contentLength", Math.Round(file.Length / 1024.0, 2) + " KB");
|
||||
dictionary.Add("pureContentLength", file.Length);
|
||||
dictionary.Add("title", file.Name);
|
||||
dictionary.Add("updated", file.LastWriteTime.ToString());
|
||||
if (fileId != null)
|
||||
{
|
||||
if (fileId.Equals(dictionary["id"]))
|
||||
{
|
||||
files.Add(dictionary);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
files.Add(dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,6 +114,28 @@
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var onMetaChange = function (event) {
|
||||
var favorite = !!event.data.favorite;
|
||||
var title = document.title.replace(/^\☆/g, "");
|
||||
document.title = (favorite ? "☆" : "") + title;
|
||||
docEditor.setFavorite(favorite);
|
||||
};
|
||||
|
||||
var onRequestInsertImage = function (event) {
|
||||
docEditor.insertImage({
|
||||
"c": event.data.c,
|
||||
<%= InsertImageConfig%>
|
||||
})
|
||||
};
|
||||
|
||||
var onRequestCompareFile = function () {
|
||||
docEditor.setRevisedFile(<%= compareFileData%>);
|
||||
};
|
||||
|
||||
var onRequestMailMergeRecipients = function (event) {
|
||||
docEditor.setMailMergeRecipients(<%= dataMailMergeRecipients%>);
|
||||
};
|
||||
|
||||
var config = <%= DocConfig %>;
|
||||
|
||||
config.width = "100%";
|
||||
@ -126,6 +148,10 @@
|
||||
'onError': onError,
|
||||
'onOutdatedVersion': onOutdatedVersion,
|
||||
'onMakeActionLink': onMakeActionLink,
|
||||
'onMetaChange': onMetaChange,
|
||||
'onRequestInsertImage': onRequestInsertImage,
|
||||
'onRequestCompareFile': onRequestCompareFile,
|
||||
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
|
||||
};
|
||||
|
||||
<% if (!string.IsNullOrEmpty(History) && !string.IsNullOrEmpty(HistoryData))
|
||||
@ -136,7 +162,7 @@
|
||||
config.events['onRequestHistoryData'] = function (event) {
|
||||
var ver = event.data;
|
||||
var histData = <%= HistoryData %>;
|
||||
docEditor.setHistoryData(histData[ver]);
|
||||
docEditor.setHistoryData(histData[ver - 1]);
|
||||
};
|
||||
config.events['onRequestHistoryClose '] = function () {
|
||||
document.location.reload();
|
||||
|
||||
@ -34,7 +34,12 @@ namespace OnlineEditorsExample
|
||||
|
||||
public static string FileUri
|
||||
{
|
||||
get { return _Default.FileUri(FileName); }
|
||||
get { return _Default.FileUri(FileName, true); }
|
||||
}
|
||||
|
||||
public static string FileUriUser
|
||||
{
|
||||
get { return _Default.FileUri(FileName, false); }
|
||||
}
|
||||
|
||||
protected string Key
|
||||
@ -49,18 +54,21 @@ namespace OnlineEditorsExample
|
||||
|
||||
protected string DocServiceApiUri
|
||||
{
|
||||
get { return WebConfigurationManager.AppSettings["files.docservice.url.api"] ?? string.Empty; }
|
||||
get { return (WebConfigurationManager.AppSettings["files.docservice.url.site"] ?? string.Empty) + (WebConfigurationManager.AppSettings["files.docservice.url.api"] ?? string.Empty); }
|
||||
}
|
||||
|
||||
protected string DocConfig { get; private set; }
|
||||
protected string History { get; private set; }
|
||||
protected string HistoryData { get; private set; }
|
||||
protected string InsertImageConfig { get; private set; }
|
||||
protected string compareFileData { get; private set; }
|
||||
protected string dataMailMergeRecipients { get; private set; }
|
||||
|
||||
public static string CallbackUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
var callbackUrl = _Default.Host;
|
||||
var callbackUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
callbackUrl.Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
@ -81,7 +89,7 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
else
|
||||
{
|
||||
FileName = Request["fileID"];
|
||||
FileName = Path.GetFileName(Request["fileID"]);
|
||||
}
|
||||
|
||||
var type = Request["type"];
|
||||
@ -100,6 +108,12 @@ namespace OnlineEditorsExample
|
||||
|
||||
var jss = new JavaScriptSerializer();
|
||||
|
||||
object favorite = null;
|
||||
if (!string.IsNullOrEmpty(Request.Cookies.GetOrDefault("uid", null)))
|
||||
{
|
||||
favorite = Request.Cookies.GetOrDefault("uid", null).Equals("uid-2");
|
||||
}
|
||||
|
||||
var actionLink = Request.GetOrDefault("actionLink", null);
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink);
|
||||
|
||||
@ -117,8 +131,9 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
"info", new Dictionary<string, object>
|
||||
{
|
||||
{ "author", "Me" },
|
||||
{ "created", DateTime.Now.ToShortDateString() }
|
||||
{ "owner", "Me" },
|
||||
{ "uploaded", DateTime.Now.ToShortDateString() },
|
||||
{ "favorite", favorite }
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -152,9 +167,9 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
"embedded", new Dictionary<string, object>
|
||||
{
|
||||
{ "saveUrl", FileUri },
|
||||
{ "embedUrl", FileUri },
|
||||
{ "shareUrl", FileUri },
|
||||
{ "saveUrl", FileUriUser },
|
||||
{ "embedUrl", FileUriUser },
|
||||
{ "shareUrl", FileUriUser },
|
||||
{ "toolbarDocked", "top" }
|
||||
}
|
||||
},
|
||||
@ -166,7 +181,7 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
"goback", new Dictionary<string, object>
|
||||
{
|
||||
{ "url", _Default.Host + "default.aspx" }
|
||||
{ "url", _Default.GetServerUrl(false) + "default.aspx" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,8 +200,19 @@ namespace OnlineEditorsExample
|
||||
|
||||
try
|
||||
{
|
||||
Dictionary<string, object> logoConfig = GetLogoConfig();
|
||||
InsertImageConfig = jss.Serialize(logoConfig).Replace("{", "").Replace("}", "");
|
||||
|
||||
Dictionary<string, object> compareFile = GetCompareFile();
|
||||
compareFileData = jss.Serialize(compareFile);
|
||||
|
||||
Dictionary<string, object> mailMergeConfig = GetMailMergeConfig();
|
||||
dataMailMergeRecipients = jss.Serialize(mailMergeConfig);
|
||||
|
||||
|
||||
Dictionary<string, object> hist;
|
||||
Dictionary<string, object> histData;
|
||||
|
||||
GetHistory(out hist, out histData);
|
||||
if (hist != null && histData != null)
|
||||
{
|
||||
@ -211,18 +237,18 @@ namespace OnlineEditorsExample
|
||||
var hist = new List<Dictionary<string, object>>();
|
||||
var histData = new Dictionary<string, object>();
|
||||
|
||||
for (var i = 0; i <= currentVersion; i++)
|
||||
for (var i = 1; i <= currentVersion; i++)
|
||||
{
|
||||
var obj = new Dictionary<string, object>();
|
||||
var dataObj = new Dictionary<string, object>();
|
||||
var verDir = _Default.VersionDir(histDir, i + 1);
|
||||
var verDir = _Default.VersionDir(histDir, i);
|
||||
|
||||
var key = i == currentVersion ? Key : File.ReadAllText(Path.Combine(verDir, "key.txt"));
|
||||
|
||||
obj.Add("key", key);
|
||||
obj.Add("version", i);
|
||||
|
||||
if (i == 0)
|
||||
if (i == 1)
|
||||
{
|
||||
var infoPath = Path.Combine(histDir, "createdInfo.json");
|
||||
|
||||
@ -239,9 +265,9 @@ namespace OnlineEditorsExample
|
||||
dataObj.Add("key", key);
|
||||
dataObj.Add("url", i == currentVersion ? FileUri : MakePublicUrl(Directory.GetFiles(verDir, "prev.*")[0]));
|
||||
dataObj.Add("version", i);
|
||||
if (i > 0)
|
||||
if (i > 1)
|
||||
{
|
||||
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(_Default.VersionDir(histDir, i), "changes.json")));
|
||||
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(_Default.VersionDir(histDir, i - 1), "changes.json")));
|
||||
var change = ((Dictionary<string, object>)((ArrayList)changes["changes"])[0]);
|
||||
|
||||
obj.Add("changes", changes["changes"]);
|
||||
@ -249,16 +275,20 @@ namespace OnlineEditorsExample
|
||||
obj.Add("created", change["created"]);
|
||||
obj.Add("user", change["user"]);
|
||||
|
||||
var prev = (Dictionary<string, object>)histData[(i - 1).ToString()];
|
||||
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()];
|
||||
dataObj.Add("previous", new Dictionary<string, object>() {
|
||||
{ "key", prev["key"] },
|
||||
{ "url", prev["url"] },
|
||||
});
|
||||
dataObj.Add("changesUrl", MakePublicUrl(Path.Combine(_Default.VersionDir(histDir, i), "diff.zip")));
|
||||
dataObj.Add("changesUrl", MakePublicUrl(Path.Combine(_Default.VersionDir(histDir, i - 1), "diff.zip")));
|
||||
}
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
var token = JwtManager.Encode(dataObj);
|
||||
dataObj.Add("token", token);
|
||||
}
|
||||
|
||||
hist.Add(obj);
|
||||
histData.Add(i.ToString(), dataObj);
|
||||
histData.Add((i - 1).ToString(), dataObj);
|
||||
}
|
||||
|
||||
history = new Dictionary<string, object>()
|
||||
@ -270,10 +300,79 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, object> GetLogoConfig()
|
||||
{
|
||||
var InsertImageUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
InsertImageUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "App_Themes\\images\\logo.png";
|
||||
|
||||
Dictionary<string, object> logoConfig = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "png"},
|
||||
{ "url", InsertImageUrl.ToString()}
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
var insImageToken = JwtManager.Encode(logoConfig);
|
||||
logoConfig.Add("token", insImageToken);
|
||||
}
|
||||
|
||||
return logoConfig;
|
||||
}
|
||||
|
||||
private Dictionary<string, object> GetCompareFile()
|
||||
{
|
||||
var compareFileUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
compareFileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
compareFileUrl.Query = "type=download&fileName=" + HttpUtility.UrlEncode("sample.docx");
|
||||
|
||||
Dictionary<string, object> dataCompareFile = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "docx" },
|
||||
{ "url", compareFileUrl.ToString() }
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
var compareFileToken = JwtManager.Encode(dataCompareFile);
|
||||
dataCompareFile.Add("token", compareFileToken);
|
||||
}
|
||||
|
||||
return dataCompareFile;
|
||||
}
|
||||
|
||||
private Dictionary<string, object> GetMailMergeConfig()
|
||||
{
|
||||
var mailmergeUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
mailmergeUrl.Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
mailmergeUrl.Query = "type=csv";
|
||||
|
||||
Dictionary<string, object> mailMergeConfig = new Dictionary<string, object>
|
||||
{
|
||||
{ "fileType", "csv" },
|
||||
{ "url", mailmergeUrl.ToString() }
|
||||
};
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
var mailmergeToken = JwtManager.Encode(mailMergeConfig);
|
||||
mailMergeConfig.Add("token", mailmergeToken);
|
||||
}
|
||||
|
||||
return mailMergeConfig;
|
||||
}
|
||||
|
||||
private string MakePublicUrl(string fullPath)
|
||||
{
|
||||
var root = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"];
|
||||
return _Default.Host + fullPath.Substring(root.Length).Replace(Path.DirectorySeparatorChar, '/');
|
||||
return _Default.GetServerUrl(true) + fullPath.Substring(root.Length).Replace(Path.DirectorySeparatorChar, '/');
|
||||
}
|
||||
|
||||
private static void Try(string type, string sample, HttpRequest request)
|
||||
@ -293,16 +392,18 @@ namespace OnlineEditorsExample
|
||||
default:
|
||||
return;
|
||||
}
|
||||
var demoName = (string.IsNullOrEmpty(sample) ? "new" : "demo") + ext;
|
||||
var demoName = (string.IsNullOrEmpty(sample) ? "new" : "sample") + ext;
|
||||
var demoPath = "assets\\" + (string.IsNullOrEmpty(sample) ? "new\\" : "sample\\");
|
||||
|
||||
FileName = _Default.GetCorrectName(demoName);
|
||||
|
||||
var filePath = _Default.StoragePath(FileName, null);
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + "app_data/" + demoName, filePath);
|
||||
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, filePath);
|
||||
|
||||
var histDir = _Default.HistoryDir(filePath);
|
||||
Directory.CreateDirectory(histDir);
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString() },
|
||||
{ "created", DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss") },
|
||||
{ "id", request.Cookies.GetOrDefault("uid", "uid-1") },
|
||||
{ "name", request.Cookies.GetOrDefault("uname", "John Smith") }
|
||||
}));
|
||||
|
||||
@ -40,7 +40,7 @@ namespace ASC.Api.DocumentConverter
|
||||
/// </summary>
|
||||
static ServiceConverter()
|
||||
{
|
||||
DocumentConverterUrl = WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "";
|
||||
DocumentConverterUrl = (WebConfigurationManager.AppSettings["files.docservice.url.site"] ?? "") + (WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "");
|
||||
|
||||
Int32.TryParse(WebConfigurationManager.AppSettings["files.docservice.timeout"], out ConvertTimeout);
|
||||
ConvertTimeout = ConvertTimeout > 0 ? ConvertTimeout : 120000;
|
||||
@ -121,7 +121,8 @@ namespace ASC.Api.DocumentConverter
|
||||
|
||||
var payloadToken = JwtManager.Encode(payload);
|
||||
var bodyToken = JwtManager.Encode(body);
|
||||
request.Headers.Add("Authorization", "Bearer " + payloadToken);
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken);
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
}
|
||||
|
||||
@ -142,16 +142,15 @@
|
||||
<Content Include="WebEditor.ashx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="App_Data\demo.docx" />
|
||||
<Content Include="App_Data\demo.pptx" />
|
||||
<Content Include="App_Data\demo.xlsx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="App_Data\new.docx" />
|
||||
<Content Include="App_Data\new.pptx" />
|
||||
<Content Include="App_Data\new.xlsx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="assets\AUTHORS.md" />
|
||||
<Content Include="assets\LICENSE" />
|
||||
<Content Include="assets\new\new.docx" />
|
||||
<Content Include="assets\new\new.pptx" />
|
||||
<Content Include="assets\new\new.xlsx" />
|
||||
<Content Include="assets\sample\csv.csv" />
|
||||
<Content Include="assets\sample\sample.docx" />
|
||||
<Content Include="assets\sample\sample.pptx" />
|
||||
<Content Include="assets\sample\sample.xlsx" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
|
||||
@ -8,6 +8,11 @@
|
||||
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<security>
|
||||
<requestFiltering>
|
||||
<requestLimits maxAllowedContentLength="1073741824"/>
|
||||
|
||||
@ -25,6 +25,7 @@ using System.Net;
|
||||
using System.Web;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.Web.Services;
|
||||
using System.Web.Configuration;
|
||||
|
||||
namespace OnlineEditorsExample
|
||||
{
|
||||
@ -48,6 +49,15 @@ namespace OnlineEditorsExample
|
||||
case "remove":
|
||||
Remove(context);
|
||||
break;
|
||||
case "download":
|
||||
Download(context);
|
||||
break;
|
||||
case "csv":
|
||||
GetCsv(context);
|
||||
break;
|
||||
case "files":
|
||||
Files(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +99,7 @@ namespace OnlineEditorsExample
|
||||
private static void Track(HttpContext context)
|
||||
{
|
||||
var userAddress = context.Request["userAddress"];
|
||||
var fileName = context.Request["fileName"];
|
||||
var fileName = Path.GetFileName(context.Request["fileName"]);
|
||||
|
||||
string body;
|
||||
try
|
||||
@ -111,18 +121,31 @@ namespace OnlineEditorsExample
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
string token = null;
|
||||
|
||||
if (fileData.ContainsKey("token"))
|
||||
{
|
||||
fileData = jss.Deserialize<Dictionary<string, object>>(JwtManager.Decode(fileData["token"].ToString()));
|
||||
token = JwtManager.Decode(fileData["token"].ToString());
|
||||
}
|
||||
else if (context.Request.Headers.AllKeys.Contains("Authorization", StringComparer.InvariantCultureIgnoreCase))
|
||||
else if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var headerToken = context.Request.Headers.Get("Authorization").Substring("Bearer ".Length);
|
||||
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(JwtManager.Decode(headerToken))["payload"];
|
||||
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
|
||||
token = JwtManager.Decode(headerToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Expected JWT");
|
||||
context.Response.Write("{\"error\":1,\"message\":\"JWT expected\"}");
|
||||
}
|
||||
|
||||
if (token != null && !token.Equals(""))
|
||||
{
|
||||
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(token)["payload"];
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Write("{\"error\":1,\"message\":\"JWT validation failed\"}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +186,7 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
var storagePath = _Default.StoragePath(fileName, userAddress);
|
||||
var histDir = _Default.HistoryDir(storagePath);
|
||||
var versionDir = _Default.VersionDir(histDir, _Default.GetFileVersion(histDir) + 1);
|
||||
var versionDir = _Default.VersionDir(histDir, _Default.GetFileVersion(histDir));
|
||||
|
||||
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir);
|
||||
|
||||
@ -200,7 +223,7 @@ namespace OnlineEditorsExample
|
||||
context.Response.ContentType = "text/plain";
|
||||
try
|
||||
{
|
||||
var fileName = context.Request["fileName"];
|
||||
var fileName = Path.GetFileName(context.Request["fileName"]);
|
||||
var path = _Default.StoragePath(fileName, HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress));
|
||||
var histDir = _Default.HistoryDir(path);
|
||||
|
||||
@ -215,6 +238,64 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
}
|
||||
|
||||
private static void Files(HttpContext context)
|
||||
{
|
||||
List<Dictionary<string, object>> files = null;
|
||||
|
||||
try
|
||||
{
|
||||
context.Response.ContentType = "application/json";
|
||||
var jss = new JavaScriptSerializer();
|
||||
|
||||
if (context.Request["fileId"] == null)
|
||||
{
|
||||
files = _Default.GetFilesInfo();
|
||||
context.Response.Write(jss.Serialize(files));
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileId = context.Request["fileId"];
|
||||
files = _Default.GetFilesInfo(fileId);
|
||||
if (files.Count == 0)
|
||||
{
|
||||
context.Response.Write("\"File not found\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Response.Write(jss.Serialize(files));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
context.Response.Write("{ \"error\": \"" + e.Message + "\"}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void Download(HttpContext context)
|
||||
{
|
||||
var fileName = "sample/" + Path.GetFileName(context.Request["filename"]);
|
||||
download(fileName, context);
|
||||
}
|
||||
|
||||
private static void GetCsv(HttpContext context)
|
||||
{
|
||||
var fileName = "sample/" + "csv.csv";
|
||||
download(fileName, context);
|
||||
}
|
||||
|
||||
private static void download(string fileName, HttpContext context)
|
||||
{
|
||||
var csvPath = HttpRuntime.AppDomainAppPath + "assets/" + fileName;
|
||||
FileInfo fileinf = new FileInfo(csvPath);
|
||||
context.Response.AddHeader("Content-Length", "" + fileinf.Length);
|
||||
context.Response.AddHeader("Content-Type", MimeMapping.GetMimeMapping(csvPath));
|
||||
var tmp = HttpUtility.UrlEncode(Path.GetFileName(csvPath));
|
||||
tmp = tmp.Replace("+", "%20");
|
||||
context.Response.AddHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + tmp);
|
||||
context.Response.TransmitFile(csvPath);
|
||||
}
|
||||
|
||||
private static void DownloadToFile(string url, string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url");
|
||||
|
||||
1
web/documentserver-example/csharp/assets
Submodule
@ -7,11 +7,17 @@
|
||||
|
||||
<add key="files.docservice.viewed-docs" value=".pdf|.djvu|.xps"/>
|
||||
<add key="files.docservice.edited-docs" value=".docx|.xlsx|.csv|.pptx|.txt"/>
|
||||
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub"/>
|
||||
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub|.fb2"/>
|
||||
<add key="files.docservice.timeout" value="120000" />
|
||||
<add key="files.docservice.secret" value="" />
|
||||
<add key="files.docservice.header" value="Authorization" />
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
<add key="files.docservice.url.converter" value="https://documentserver/ConvertService.ashx"/>
|
||||
<add key="files.docservice.url.api" value="https://documentserver/web-apps/apps/api/documents/api.js"/>
|
||||
<add key="files.docservice.url.preloader" value="https://documentserver/web-apps/apps/api/documents/cache-scripts.html"/>
|
||||
<add key="files.docservice.url.converter" value="ConvertService.ashx"/>
|
||||
<add key="files.docservice.url.api" value="web-apps/apps/api/documents/api.js"/>
|
||||
<add key="files.docservice.url.preloader" value="web-apps/apps/api/documents/cache-scripts.html"/>
|
||||
|
||||
<add key="files.docservice.url.example" value=""/>
|
||||
|
||||
</appSettings>
|
||||
@ -14,13 +14,10 @@ Edit the **settings.properties** configuration file. Specify the name of your lo
|
||||
nano src/main/resources/settings.properties
|
||||
```
|
||||
|
||||
Edit the following lines:
|
||||
Edit the following line:
|
||||
|
||||
```
|
||||
files.docservice.url.converter=https://documentserver/ConvertService.ashx
|
||||
files.docservice.url.tempstorage=https://documentserver/ResourceService.ashx
|
||||
files.docservice.url.api=https://documentserver/web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=https://documentserver/web-apps/apps/api/documents/cache-scripts.html
|
||||
files.docservice.url.site=https://documentserver/
|
||||
```
|
||||
|
||||
Install Maven:
|
||||
@ -44,13 +41,10 @@ Edit the **settings.properties** configuration file. Specify the name of your lo
|
||||
nano src/main/resources/settings.properties
|
||||
```
|
||||
|
||||
Edit the following lines. You need to change `documentserver` to your documentserver:
|
||||
Edit the following line. You need to change `documentserver` to your documentserver:
|
||||
|
||||
```
|
||||
files.docservice.url.converter=https://documentserver/ConvertService.ashx
|
||||
files.docservice.url.tempstorage=https://documentserver/ResourceService.ashx
|
||||
files.docservice.url.api=https://documentserver/web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=https://documentserver/web-apps/apps/api/documents/cache-scripts.html
|
||||
files.docservice.url.site=https://documentserver/
|
||||
```
|
||||
|
||||
Run next command in java example directory:
|
||||
|
||||
@ -18,11 +18,14 @@
|
||||
|
||||
package controllers;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import helpers.ConfigManager;
|
||||
import helpers.CookieManager;
|
||||
import helpers.DocumentManager;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
@ -30,6 +33,7 @@ import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import entities.FileModel;
|
||||
import helpers.FileUtility;
|
||||
|
||||
|
||||
@WebServlet(name = "EditorServlet", urlPatterns = {"/EditorServlet"})
|
||||
@ -39,7 +43,7 @@ public class EditorServlet extends HttpServlet
|
||||
{
|
||||
DocumentManager.Init(request, response);
|
||||
|
||||
String fileName = request.getParameter("fileName");
|
||||
String fileName = FileUtility.GetFileName(request.getParameter("fileName"));
|
||||
String fileExt = request.getParameter("fileExt");
|
||||
String sample = request.getParameter("sample");
|
||||
|
||||
@ -64,13 +68,32 @@ public class EditorServlet extends HttpServlet
|
||||
FileModel file = new FileModel(fileName, cm.getCookie("ulang"), cm.getCookie("uid"), cm.getCookie("uname"), request.getParameter("actionLink"));
|
||||
file.changeType(request.getParameter("mode"), request.getParameter("type"));
|
||||
|
||||
Map<String, Object> dataInsertImage = new HashMap<>();
|
||||
dataInsertImage.put("fileType", "png");
|
||||
dataInsertImage.put("url", DocumentManager.GetServerUrl(true) + "/css/img/logo.png");
|
||||
|
||||
Map<String, Object> dataCompareFile = new HashMap<>();
|
||||
dataCompareFile.put("fileType", "docx");
|
||||
dataCompareFile.put("url", DocumentManager.GetServerUrl(true) + "/IndexServlet?type=download&name=sample.docx");
|
||||
|
||||
Map<String, Object> dataMailMergeRecipients = new HashMap<>();
|
||||
dataMailMergeRecipients.put("fileType", "csv");
|
||||
dataMailMergeRecipients.put("url", DocumentManager.GetServerUrl(true) + "/IndexServlet?type=csv");
|
||||
|
||||
if (DocumentManager.TokenEnabled())
|
||||
{
|
||||
file.BuildToken();
|
||||
dataInsertImage.put("token", DocumentManager.CreateToken(dataInsertImage));
|
||||
dataCompareFile.put("token", DocumentManager.CreateToken(dataCompareFile));
|
||||
dataMailMergeRecipients.put("token", DocumentManager.CreateToken(dataMailMergeRecipients));
|
||||
}
|
||||
|
||||
Gson gson = new Gson();
|
||||
request.setAttribute("file", file);
|
||||
request.setAttribute("docserviceApiUrl", ConfigManager.GetProperty("files.docservice.url.api"));
|
||||
request.setAttribute("docserviceApiUrl", ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.api"));
|
||||
request.setAttribute("dataInsertImage", gson.toJson(dataInsertImage).substring(1, gson.toJson(dataInsertImage).length()-1));
|
||||
request.setAttribute("dataCompareFile", gson.toJson(dataCompareFile));
|
||||
request.setAttribute("dataMailMergeRecipients", gson.toJson(dataMailMergeRecipients));
|
||||
request.getRequestDispatcher("editor.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
|
||||
@ -18,19 +18,19 @@
|
||||
|
||||
package controllers;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import helpers.ConfigManager;
|
||||
import helpers.CookieManager;
|
||||
import helpers.DocumentManager;
|
||||
import helpers.ServiceConverter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Scanner;
|
||||
import java.util.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.MultipartConfig;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
@ -78,6 +78,15 @@ public class IndexServlet extends HttpServlet
|
||||
case "remove":
|
||||
Remove(request, response, writer);
|
||||
break;
|
||||
case "download":
|
||||
Download(request, response, writer);
|
||||
break;
|
||||
case "csv":
|
||||
CSV(request, response, writer);
|
||||
break;
|
||||
case "files":
|
||||
Files(request, response, writer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,8 +159,8 @@ public class IndexServlet extends HttpServlet
|
||||
|
||||
try
|
||||
{
|
||||
String fileName = request.getParameter("filename");
|
||||
String fileUri = DocumentManager.GetFileUri(fileName);
|
||||
String fileName = FileUtility.GetFileName(request.getParameter("filename"));
|
||||
String fileUri = DocumentManager.GetFileUri(fileName, true);
|
||||
String fileExt = FileUtility.GetFileExtension(fileName);
|
||||
FileType fileType = FileUtility.GetFileType(fileName);
|
||||
String internalFileExt = DocumentManager.GetInternalExtension(fileType);
|
||||
@ -216,7 +225,7 @@ public class IndexServlet extends HttpServlet
|
||||
private static void Track(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
|
||||
{
|
||||
String userAddress = request.getParameter("userAddress");
|
||||
String fileName = request.getParameter("fileName");
|
||||
String fileName = FileUtility.GetFileName(request.getParameter("fileName"));
|
||||
|
||||
String storagePath = DocumentManager.StoragePath(fileName, userAddress);
|
||||
String body = "";
|
||||
@ -314,7 +323,7 @@ public class IndexServlet extends HttpServlet
|
||||
try
|
||||
{
|
||||
String histDir = DocumentManager.HistoryDir(storagePath);
|
||||
String versionDir = DocumentManager.VersionDir(histDir, DocumentManager.GetFileVersion(histDir) + 1);
|
||||
String versionDir = DocumentManager.VersionDir(histDir, DocumentManager.GetFileVersion(histDir));
|
||||
File ver = new File(versionDir);
|
||||
File toSave = new File(storagePath);
|
||||
|
||||
@ -352,7 +361,7 @@ public class IndexServlet extends HttpServlet
|
||||
{
|
||||
try
|
||||
{
|
||||
String fileName = request.getParameter("filename");
|
||||
String fileName = FileUtility.GetFileName(request.getParameter("filename"));
|
||||
String path = DocumentManager.StoragePath(fileName, null);
|
||||
|
||||
File f = new File(path);
|
||||
@ -369,6 +378,45 @@ public class IndexServlet extends HttpServlet
|
||||
}
|
||||
}
|
||||
|
||||
private static void Files(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
|
||||
{
|
||||
ArrayList<Map<String, Object>> files = null;
|
||||
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
response.setContentType("application/json");
|
||||
|
||||
if (request.getParameter("fileId") == null) {
|
||||
files = DocumentManager.GetFilesInfo();
|
||||
writer.write(gson.toJson(files));
|
||||
}else {
|
||||
String fileId = request.getParameter("fileId");
|
||||
files = DocumentManager.GetFilesInfo(fileId);
|
||||
if(files.isEmpty()) {
|
||||
writer.write("\"File not found\"");
|
||||
}else {
|
||||
writer.write(gson.toJson(files));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
writer.write("{ \"error\": \"" + e.getMessage() + "\"}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void CSV(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
|
||||
{
|
||||
String fileName = "assets/sample/csv.csv";
|
||||
download(fileName, response, writer);
|
||||
}
|
||||
|
||||
private static void Download(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
|
||||
{
|
||||
String fileName = "assets/sample/" + FileUtility.GetFileName(request.getParameter("name"));
|
||||
download(fileName, response, writer);
|
||||
}
|
||||
|
||||
private static void delete(File f) throws Exception {
|
||||
if (f.isDirectory()) {
|
||||
for (File c : f.listFiles())
|
||||
@ -378,6 +426,41 @@ public class IndexServlet extends HttpServlet
|
||||
throw new Exception("Failed to delete file: " + f);
|
||||
}
|
||||
|
||||
private static void download(String fileName, HttpServletResponse response, PrintWriter writer) {
|
||||
URL fileUrl = Thread.currentThread().getContextClassLoader().getResource(fileName);
|
||||
Path filePath = null;
|
||||
String fileType = null;
|
||||
try {
|
||||
filePath = Paths.get(fileUrl.toURI());
|
||||
fileType = Files.probeContentType(filePath);
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
File file = new File(String.valueOf(filePath));
|
||||
|
||||
response.setHeader("Content-Length", String.valueOf(file.length()));
|
||||
response.setHeader("Content-Type", fileType);
|
||||
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + file.getName());
|
||||
|
||||
BufferedInputStream inputStream = null;
|
||||
try {
|
||||
FileInputStream fileInputStream = new FileInputStream(file);
|
||||
inputStream = new BufferedInputStream(fileInputStream);
|
||||
int readBytes = 0;
|
||||
while ((readBytes = inputStream.read()) != -1)
|
||||
writer.write(readBytes);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void downloadToFile(String url, File file) throws Exception {
|
||||
if (url == null || url.isEmpty()) throw new Exception("argument url");
|
||||
if (file == null) throw new Exception("argument path");
|
||||
|
||||
@ -20,11 +20,7 @@ package entities;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import helpers.DocumentManager;
|
||||
import helpers.ServiceConverter;
|
||||
@ -54,9 +50,12 @@ public class FileModel
|
||||
|
||||
document = new Document();
|
||||
document.title = fileName;
|
||||
document.url = DocumentManager.GetFileUri(fileName);
|
||||
document.url = DocumentManager.GetFileUri(fileName, true);
|
||||
document.urlUser = DocumentManager.GetFileUri(fileName, false);
|
||||
document.fileType = FileUtility.GetFileExtension(fileName).replace(".", "");
|
||||
document.key = ServiceConverter.GenerateRevisionId(DocumentManager.CurUserHostAddress(null) + "/" + fileName + "/" + Long.toString(new File(DocumentManager.StoragePath(fileName, null)).lastModified()));
|
||||
document.info = new Info();
|
||||
document.info.favorite = uid != null && !uid.isEmpty() ? uid.equals("uid-2") : null;
|
||||
|
||||
editorConfig = new EditorConfig(actionData);
|
||||
editorConfig.callbackUrl = DocumentManager.GetCallback(fileName);
|
||||
@ -65,7 +64,7 @@ public class FileModel
|
||||
if (uid != null) editorConfig.user.id = uid;
|
||||
if (uname != null) editorConfig.user.name = uname;
|
||||
|
||||
editorConfig.customization.goback.url = DocumentManager.GetServerUrl() + "/IndexServlet";
|
||||
editorConfig.customization.goback.url = DocumentManager.GetServerUrl(false) + "/IndexServlet";
|
||||
|
||||
changeType(mode, type);
|
||||
}
|
||||
@ -86,7 +85,7 @@ public class FileModel
|
||||
|
||||
public void InitDesktop()
|
||||
{
|
||||
editorConfig.InitDesktop(document.url);
|
||||
editorConfig.InitDesktop(document.urlUser);
|
||||
}
|
||||
|
||||
public void BuildToken()
|
||||
@ -107,13 +106,13 @@ public class FileModel
|
||||
if (DocumentManager.GetFileVersion(histDir) > 0) {
|
||||
Integer curVer = DocumentManager.GetFileVersion(histDir);
|
||||
|
||||
Set<Object> hist = new HashSet<Object>();
|
||||
List<Object> hist = new ArrayList<>();
|
||||
Map<String, Object> histData = new HashMap<String, Object>();
|
||||
|
||||
for (Integer i = 0; i <= curVer; i++) {
|
||||
for (Integer i = 1; i <= curVer; i++) {
|
||||
Map<String, Object> obj = new HashMap<String, Object>();
|
||||
Map<String, Object> dataObj = new HashMap<String, Object>();
|
||||
String verDir = DocumentManager.VersionDir(histDir, i + 1);
|
||||
String verDir = DocumentManager.VersionDir(histDir, i);
|
||||
|
||||
try {
|
||||
String key = null;
|
||||
@ -123,7 +122,7 @@ public class FileModel
|
||||
obj.put("key", key);
|
||||
obj.put("version", i);
|
||||
|
||||
if (i == 0) {
|
||||
if (i == 1) {
|
||||
String createdInfo = readFileToEnd(new File(histDir + File.separator + "createdInfo.json"));
|
||||
JSONObject json = (JSONObject) parser.parse(createdInfo);
|
||||
|
||||
@ -138,8 +137,8 @@ public class FileModel
|
||||
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetPathUri(verDir + File.separator + "prev" + FileUtility.GetFileExtension(document.title)));
|
||||
dataObj.put("version", i);
|
||||
|
||||
if (i > 0) {
|
||||
JSONObject changes = (JSONObject) parser.parse(readFileToEnd(new File(DocumentManager.VersionDir(histDir, i) + File.separator + "changes.json")));
|
||||
if (i > 1) {
|
||||
JSONObject changes = (JSONObject) parser.parse(readFileToEnd(new File(DocumentManager.VersionDir(histDir, i - 1) + File.separator + "changes.json")));
|
||||
JSONObject change = (JSONObject) ((JSONArray) changes.get("changes")).get(0);
|
||||
|
||||
obj.put("changes", changes.get("changes"));
|
||||
@ -147,16 +146,21 @@ public class FileModel
|
||||
obj.put("created", change.get("created"));
|
||||
obj.put("user", change.get("user"));
|
||||
|
||||
Map<String, Object> prev = (Map<String, Object>) histData.get(Integer.toString(i - 1));
|
||||
Map<String, Object> prev = (Map<String, Object>) histData.get(Integer.toString(i - 2));
|
||||
Map<String, Object> prevInfo = new HashMap<String, Object>();
|
||||
prevInfo.put("key", prev.get("key"));
|
||||
prevInfo.put("url", prev.get("url"));
|
||||
dataObj.put("previous", prevInfo);
|
||||
dataObj.put("changesUrl", DocumentManager.GetPathUri(DocumentManager.VersionDir(histDir, i) + File.separator + "diff.zip"));
|
||||
dataObj.put("changesUrl", DocumentManager.GetPathUri(DocumentManager.VersionDir(histDir, i - 1) + File.separator + "diff.zip"));
|
||||
}
|
||||
|
||||
if (DocumentManager.TokenEnabled())
|
||||
{
|
||||
dataObj.put("token", DocumentManager.CreateToken(dataObj));
|
||||
}
|
||||
|
||||
hist.add(obj);
|
||||
histData.put(Integer.toString(i), dataObj);
|
||||
histData.put(Integer.toString(i - 1), dataObj);
|
||||
|
||||
} catch (Exception ex) { }
|
||||
}
|
||||
@ -191,8 +195,10 @@ public class FileModel
|
||||
{
|
||||
public String title;
|
||||
public String url;
|
||||
public String urlUser;
|
||||
public String fileType;
|
||||
public String key;
|
||||
public Info info;
|
||||
public Permissions permissions;
|
||||
}
|
||||
|
||||
@ -218,6 +224,11 @@ public class FileModel
|
||||
}
|
||||
}
|
||||
|
||||
public class Info
|
||||
{
|
||||
Boolean favorite;
|
||||
}
|
||||
|
||||
public class EditorConfig
|
||||
{
|
||||
public HashMap<String, Object> actionLink = null;
|
||||
|
||||
@ -24,14 +24,12 @@ import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import entities.FileType;
|
||||
@ -134,7 +132,7 @@ public class DocumentManager
|
||||
public static String StoragePath(String fileName, String userAddress)
|
||||
{
|
||||
String directory = FilesRootPath(userAddress);
|
||||
return directory + fileName;
|
||||
return directory + FileUtility.GetFileName(fileName);
|
||||
}
|
||||
|
||||
public static String HistoryDir(String storagePath)
|
||||
@ -165,7 +163,7 @@ public class DocumentManager
|
||||
}
|
||||
});
|
||||
|
||||
return dirs.length;
|
||||
return dirs.length + 1;
|
||||
}
|
||||
|
||||
public static int GetFileVersion(String fileName, String userAddress)
|
||||
@ -224,9 +222,10 @@ public class DocumentManager
|
||||
public static String CreateDemo(String fileExt, Boolean sample, String uid, String uname) throws Exception
|
||||
{
|
||||
String demoName = (sample ? "sample." : "new.") + fileExt;
|
||||
String demoPath = "assets" + File.separator + (sample ? "sample" : "new") + File.separator;
|
||||
String fileName = GetCorrectName(demoName);
|
||||
|
||||
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(demoName);
|
||||
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(demoPath + demoName);
|
||||
|
||||
File file = new File(StoragePath(fileName, null));
|
||||
|
||||
@ -246,11 +245,11 @@ public class DocumentManager
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public static String GetFileUri(String fileName)
|
||||
public static String GetFileUri(String fileName, Boolean forDocumentServer)
|
||||
{
|
||||
try
|
||||
{
|
||||
String serverPath = GetServerUrl();
|
||||
String serverPath = GetServerUrl(forDocumentServer);
|
||||
String storagePath = ConfigManager.GetProperty("storage-folder");
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
|
||||
@ -264,9 +263,39 @@ public class DocumentManager
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Map<String, Object>> GetFilesInfo(){
|
||||
ArrayList<Map<String, Object>> files = new ArrayList<>();
|
||||
|
||||
for(File file : GetStoredFiles(null)){
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("version", GetFileVersion(file.getName(), null));
|
||||
map.put("id", ServiceConverter.GenerateRevisionId(CurUserHostAddress(null) + "/" + file.getName() + "/" + Long.toString(new File(StoragePath(file.getName(), null)).lastModified())));
|
||||
map.put("contentLength", new BigDecimal(String.valueOf((file.length()/1024.0))).setScale(2, RoundingMode.HALF_UP) + " KB");
|
||||
map.put("pureContentLength", file.length());
|
||||
map.put("title", file.getName());
|
||||
map.put("updated", String.valueOf(new Date(file.lastModified())));
|
||||
files.add(map);
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
public static ArrayList<Map<String, Object>> GetFilesInfo(String fileId){
|
||||
ArrayList<Map<String, Object>> file = new ArrayList<>();
|
||||
|
||||
for (Map<String, Object> map : GetFilesInfo()){
|
||||
if (map.get("id").equals(fileId)){
|
||||
file.add(map);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
public static String GetPathUri(String path)
|
||||
{
|
||||
String serverPath = GetServerUrl();
|
||||
String serverPath = GetServerUrl(true);
|
||||
String storagePath = ConfigManager.GetProperty("storage-folder");
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
|
||||
@ -276,14 +305,17 @@ public class DocumentManager
|
||||
}
|
||||
|
||||
|
||||
public static String GetServerUrl()
|
||||
{
|
||||
return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
|
||||
public static String GetServerUrl(Boolean forDocumentServer) {
|
||||
if (forDocumentServer && !ConfigManager.GetProperty("files.docservice.url.example").equals("")) {
|
||||
return ConfigManager.GetProperty("files.docservice.url.example");
|
||||
} else {
|
||||
return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
|
||||
}
|
||||
}
|
||||
|
||||
public static String GetCallback(String fileName)
|
||||
{
|
||||
String serverPath = GetServerUrl();
|
||||
String serverPath = GetServerUrl(true);
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
try
|
||||
{
|
||||
|
||||
@ -72,10 +72,10 @@ public class FileUtility
|
||||
|
||||
public static String GetFileName(String url)
|
||||
{
|
||||
if (url == null) return null;
|
||||
if (url == null) return "";
|
||||
|
||||
//for external file url
|
||||
String tempstorage = ConfigManager.GetProperty("files.docservice.url.tempstorage");
|
||||
String tempstorage = ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.tempstorage");
|
||||
if (!tempstorage.isEmpty() && url.startsWith(tempstorage))
|
||||
{
|
||||
Map<String, String> params = GetUrlParams(url);
|
||||
|
||||
@ -40,7 +40,7 @@ import org.json.simple.parser.ParseException;
|
||||
public class ServiceConverter
|
||||
{
|
||||
private static int ConvertTimeout = 120000;
|
||||
private static final String DocumentConverterUrl = ConfigManager.GetProperty("files.docservice.url.converter");
|
||||
private static final String DocumentConverterUrl = ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.converter");
|
||||
private static final String DocumentJwtHeader = ConfigManager.GetProperty("files.docservice.header");
|
||||
|
||||
public static class ConvertBody
|
||||
@ -125,7 +125,7 @@ public class ServiceConverter
|
||||
|
||||
if (DocumentManager.TokenEnabled())
|
||||
{
|
||||
connection.setRequestProperty(DocumentJwtHeader == "" ? "Authorization" : DocumentJwtHeader, "Bearer " + headerToken);
|
||||
connection.setRequestProperty(DocumentJwtHeader.equals("") ? "Authorization" : DocumentJwtHeader, "Bearer " + headerToken);
|
||||
}
|
||||
|
||||
connection.connect();
|
||||
|
||||
@ -3,12 +3,15 @@ storage-folder=app_data
|
||||
|
||||
files.docservice.viewed-docs=.pdf|.djvu|.xps
|
||||
files.docservice.edited-docs=.docx|.xlsx|.csv|.pptx|.txt
|
||||
files.docservice.convert-docs=.docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub
|
||||
files.docservice.convert-docs=.docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub|.fb2
|
||||
files.docservice.timeout=120000
|
||||
|
||||
files.docservice.url.converter=https://documentserver/ConvertService.ashx
|
||||
files.docservice.url.tempstorage=https://documentserver/ResourceService.ashx
|
||||
files.docservice.url.api=https://documentserver/web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=https://documentserver/web-apps/apps/api/documents/cache-scripts.html
|
||||
files.docservice.url.site=https://documentserver/
|
||||
files.docservice.url.converter=ConvertService.ashx
|
||||
files.docservice.url.tempstorage=ResourceService.ashx
|
||||
files.docservice.url.api=web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=web-apps/apps/api/documents/cache-scripts.html
|
||||
files.docservice.url.example=
|
||||
|
||||
files.docservice.secret=
|
||||
files.docservice.header=Authorization
|
||||
@ -1,13 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
|
||||
<filter>
|
||||
<filter-name>CorsFilter</filter-name>
|
||||
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>cors.allowed.origins</param-name>
|
||||
<param-value>*</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>cors.allowed.methods</param-name>
|
||||
<param-value>GET</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>cors.support.credentials</param-name>
|
||||
<param-value>false</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>cors.exposed.headers</param-name>
|
||||
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Methods</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>CorsFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
<session-timeout>30</session-timeout>
|
||||
</session-config>
|
||||
<listener>
|
||||
<listener-class>
|
||||
controllers.GlobalServletContextListener
|
||||
</listener-class>
|
||||
<listener-class>controllers.GlobalServletContextListener</listener-class>
|
||||
</listener>
|
||||
</web-app>
|
||||
</web-app>
|
||||
|
||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,15 @@
|
||||
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
|
||||
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
|
||||
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
|
||||
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
|
||||
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
|
||||
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
|
||||
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
|
||||
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
|
||||
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
|
||||
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
|
||||
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
@ -44,10 +44,13 @@ a, a:hover, a:visited {
|
||||
|
||||
|
||||
.top-panel {
|
||||
background: url("img/logo.png") no-repeat 30px center #3D4A6B;
|
||||
background: #3D4A6B;
|
||||
height: 80px;
|
||||
width: 100%;
|
||||
}
|
||||
.top-panel img {
|
||||
margin: 12px 0 0 16px;
|
||||
}
|
||||
.main-panel {
|
||||
margin: 80px auto;
|
||||
width: 600px;
|
||||
|
||||
@ -86,6 +86,28 @@
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var onMetaChange = function (event) {
|
||||
var favorite = !!event.data.favorite;
|
||||
var title = document.title.replace(/^\☆/g, "");
|
||||
document.title = (favorite ? "☆" : "") + title;
|
||||
docEditor.setFavorite(favorite);
|
||||
};
|
||||
|
||||
var onRequestInsertImage = function(event) {
|
||||
docEditor.insertImage({
|
||||
"c": event.data.c,
|
||||
${dataInsertImage}
|
||||
})
|
||||
};
|
||||
|
||||
var onRequestCompareFile = function() {
|
||||
docEditor.setRevisedFile(${dataCompareFile});
|
||||
};
|
||||
|
||||
var onRequestMailMergeRecipients = function (event) {
|
||||
docEditor.setMailMergeRecipients(${dataMailMergeRecipients});
|
||||
};
|
||||
|
||||
var config = JSON.parse('<%= FileModel.Serialize(Model) %>');
|
||||
config.width = "100%";
|
||||
config.height = "100%";
|
||||
@ -96,6 +118,10 @@
|
||||
"onError": onError,
|
||||
"onOutdatedVersion": onOutdatedVersion,
|
||||
"onMakeActionLink": onMakeActionLink,
|
||||
"onMetaChange": onMetaChange,
|
||||
"onRequestInsertImage": onRequestInsertImage,
|
||||
"onRequestCompareFile": onRequestCompareFile,
|
||||
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
|
||||
};
|
||||
|
||||
<%
|
||||
@ -111,7 +137,7 @@
|
||||
config.events['onRequestHistoryData'] = function (event) {
|
||||
var ver = event.data;
|
||||
var histData = <%= historyData %>;
|
||||
docEditor.setHistoryData(histData[ver]);
|
||||
docEditor.setHistoryData(histData[ver - 1]);
|
||||
};
|
||||
config.events['onRequestHistoryClose'] = function () {
|
||||
document.location.reload();
|
||||
|
||||
@ -35,7 +35,11 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="top-panel"></div>
|
||||
<div class="top-panel">
|
||||
<a href="">
|
||||
<img src ="css/img/logo.svg" alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors</span>
|
||||
@ -152,7 +156,7 @@
|
||||
<a class="stored-edit <%= docType %>" href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>" target="_blank">
|
||||
<span title="<%= files[i].getName() %>"><%= files[i].getName() %></span>
|
||||
</a>
|
||||
<a href="<%= DocumentManager.GetFileUri(files[i].getName()) %>">
|
||||
<a href="<%= DocumentManager.GetFileUri(files[i].getName(), false) %>">
|
||||
<img class="icon-download" src="css/img/download-24.png" alt="Download" title="Download" />
|
||||
</a>
|
||||
<a class="delete-file" data-filename="<%= files[i].getName() %>">
|
||||
@ -278,7 +282,7 @@
|
||||
<div id="cancelEdit" class="button gray">Cancel</div>
|
||||
</div>
|
||||
|
||||
<span id="loadScripts" data-docs="<%= ConfigManager.GetProperty("files.docservice.url.preloader") %>"></span>
|
||||
<span id="loadScripts" data-docs="<%= ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.preloader") %>"></span>
|
||||
|
||||
<div class="bottom-panel">
|
||||
© Ascensio System SIA <%= Calendar.getInstance().get(Calendar.YEAR) %>. All rights reserved.
|
||||
|
||||
@ -31,7 +31,11 @@
|
||||
|
||||
<body>
|
||||
<div id="page">
|
||||
<div class="top-panel"></div>
|
||||
<div class="top-panel">
|
||||
<a href="">
|
||||
<img src ="logo.svg" alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</div>
|
||||
<div id="mainPanel" class="main-panel">
|
||||
<span class="portal-name">ONLYOFFICE Document Editors</span>
|
||||
<br />
|
||||
|
||||
|
Before Width: | Height: | Size: 5.4 KiB |
15
web/documentserver-example/js/logo.svg
Normal file
@ -0,0 +1,15 @@
|
||||
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
|
||||
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
|
||||
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
|
||||
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
|
||||
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
|
||||
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
|
||||
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
|
||||
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
|
||||
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
|
||||
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
|
||||
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
@ -41,10 +41,13 @@ div {
|
||||
|
||||
|
||||
.top-panel {
|
||||
background: url("logo.png") no-repeat 30px center #3D4A6B;
|
||||
background: #3D4A6B;
|
||||
height: 80px;
|
||||
width: 100%;
|
||||
}
|
||||
.top-panel img{
|
||||
margin: 12px 0 0 16px;
|
||||
}
|
||||
.main-panel {
|
||||
margin: 105px auto 0;
|
||||
width: 350px;
|
||||
|
||||
@ -292,6 +292,7 @@ app.get("/files", function(req, res) {
|
||||
try {
|
||||
docManager.init(storageFolder, req, res);
|
||||
const filesInDirectoryInfo = docManager.getFilesInfo();
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.write(JSON.stringify(filesInDirectoryInfo));
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
@ -305,6 +306,7 @@ app.get("/files/file/:fileId", function(req, res) {
|
||||
docManager.init(storageFolder, req, res);
|
||||
const fileId = req.params.fileId;
|
||||
const fileInfoById = docManager.getFilesInfo(fileId);
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
res.write(JSON.stringify(fileInfoById));
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
@ -338,6 +340,19 @@ app.delete("/file", function (req, res) {
|
||||
res.end();
|
||||
});
|
||||
|
||||
app.get("/csv", function (req, res) {
|
||||
var fileName = "csv.csv";
|
||||
var csvPath = path.join(__dirname, "public", "assets", "sample", fileName);
|
||||
|
||||
res.setHeader("Content-Length", fileSystem.statSync(csvPath).size);
|
||||
res.setHeader("Content-Type", mime.getType(csvPath));
|
||||
|
||||
res.setHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + encodeURIComponent(fileName));
|
||||
|
||||
var filestream = fileSystem.createReadStream(csvPath);
|
||||
filestream.pipe(res);
|
||||
})
|
||||
|
||||
app.post("/track", function (req, res) {
|
||||
|
||||
docManager.init(storageFolder, req, res);
|
||||
@ -542,7 +557,7 @@ app.get("/editor", function (req, res) {
|
||||
var actionData = req.query.action ? req.query.action : "null";
|
||||
|
||||
if (fileExt != null) {
|
||||
var fileName = docManager.createDemo((req.query.sample ? "sample." : "new.") + fileExt, userid, name);
|
||||
var fileName = docManager.createDemo(!!req.query.sample, fileExt, userid, name);
|
||||
|
||||
var redirectPath = docManager.getServerUrl() + "/editor?fileName=" + encodeURIComponent(fileName) + docManager.getCustomParams();
|
||||
res.redirect(redirectPath);
|
||||
@ -558,6 +573,7 @@ app.get("/editor", function (req, res) {
|
||||
}
|
||||
var key = docManager.getKey(fileName);
|
||||
var url = docManager.getFileUri(fileName);
|
||||
var urlUser = 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 == "") {
|
||||
@ -626,8 +642,10 @@ app.get("/editor", function (req, res) {
|
||||
name: fileName,
|
||||
ext: fileUtility.getFileExtension(fileName, true),
|
||||
uri: url,
|
||||
uriUser: urlUser,
|
||||
version: countVersion,
|
||||
created: new Date().toDateString()
|
||||
created: new Date().toDateString(),
|
||||
favorite: req.query.userid ? req.query.userid === "uid-2" : "null"
|
||||
},
|
||||
editor: {
|
||||
type: type,
|
||||
@ -653,7 +671,19 @@ app.get("/editor", function (req, res) {
|
||||
actionData: actionData
|
||||
},
|
||||
history: history,
|
||||
historyData: historyData
|
||||
historyData: historyData,
|
||||
dataInsertImage: {
|
||||
fileType: "png",
|
||||
url: docManager.getServerUrl(true) + "/images/logo.png"
|
||||
},
|
||||
dataCompareFile: {
|
||||
fileType: "docx",
|
||||
url: docManager.getServerUrl(true) + "/assets/sample/sample.docx"
|
||||
},
|
||||
dataMailMergeRecipients: {
|
||||
fileType: "csv",
|
||||
url: docManager.getServerUrl(true) + "/csv"
|
||||
}
|
||||
};
|
||||
|
||||
if (cfgSignatureEnable) {
|
||||
@ -662,6 +692,9 @@ app.get("/editor", function (req, res) {
|
||||
console.log(err);
|
||||
} else {
|
||||
argss.editor.token = jwt.sign(JSON.parse("{"+html+"}"), cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
|
||||
argss.dataInsertImage.token = jwt.sign(argss.dataInsertImage, cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
|
||||
argss.dataCompareFile.token = jwt.sign(argss.dataCompareFile, cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
|
||||
argss.dataMailMergeRecipients.token = jwt.sign(argss.dataMailMergeRecipients, cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
|
||||
}
|
||||
res.render("editor", argss);
|
||||
});
|
||||
|
||||
@ -99,10 +99,11 @@ docManager.getCorrectName = function (fileName, userAddress) {
|
||||
return name;
|
||||
};
|
||||
|
||||
docManager.createDemo = function (demoName, userid, username) {
|
||||
docManager.createDemo = function (isSample, fileExt, userid, username) {
|
||||
const demoName = (isSample ? "sample" : "new") + "." + fileExt;
|
||||
const fileName = docManager.getCorrectName(demoName);
|
||||
|
||||
docManager.copyFile(path.join(__dirname, "..","public", "samples", demoName), docManager.storagePath(fileName));
|
||||
docManager.copyFile(path.join(__dirname, "..","public", "assets", isSample ? "sample" : "new", demoName), docManager.storagePath(fileName));
|
||||
|
||||
docManager.saveFileData(fileName, userid, username);
|
||||
|
||||
|
||||
1
web/documentserver-example/nodejs/public/assets
Submodule
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.0 KiB |
15
web/documentserver-example/nodejs/public/images/logo.svg
Normal file
@ -0,0 +1,15 @@
|
||||
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
|
||||
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
|
||||
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
|
||||
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
|
||||
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
|
||||
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
|
||||
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
|
||||
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
|
||||
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
|
||||
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
|
||||
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
@ -9,8 +9,9 @@
|
||||
"fileType": "<%- file.ext %>",
|
||||
"key": "<%- editor.key %>",
|
||||
"info": {
|
||||
"author": "Me",
|
||||
"created": "<%- file.created %>"
|
||||
"owner": "Me",
|
||||
"uploaded": "<%- file.created %>",
|
||||
"favorite": <%- file.favorite %>
|
||||
},
|
||||
"permissions": {
|
||||
"comment": <%- editor.comment %>,
|
||||
@ -32,9 +33,9 @@
|
||||
"name": "<%- editor.name %>"
|
||||
},
|
||||
"embedded": {
|
||||
"saveUrl": "<%- file.uri %>",
|
||||
"embedUrl": "<%- file.uri %>",
|
||||
"shareUrl": "<%- file.uri %>",
|
||||
"saveUrl": "<%- file.uriUser %>",
|
||||
"embedUrl": "<%- file.uriUser %>",
|
||||
"shareUrl": "<%- file.uriUser %>",
|
||||
"toolbarDocked": "top"
|
||||
},
|
||||
"customization": {
|
||||
|
||||
@ -53,6 +53,13 @@
|
||||
document.title = title + (event.data ? "*" : "");
|
||||
};
|
||||
|
||||
var onMetaChange = function (event) {
|
||||
var favorite = !!event.data.favorite;
|
||||
var title = document.title.replace(/^\☆/g, "");
|
||||
document.title = (favorite ? "☆" : "") + title;
|
||||
docEditor.setFavorite(favorite);
|
||||
};
|
||||
|
||||
var onRequestEditRights = function () {
|
||||
location.href = location.href.replace(RegExp("mode=view\&?", "i"), "");
|
||||
};
|
||||
@ -109,6 +116,21 @@
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var onRequestInsertImage = function(event) {
|
||||
docEditor.insertImage({
|
||||
"c": event.data.c,
|
||||
<%- JSON.stringify(dataInsertImage).substring(1, JSON.stringify(dataInsertImage).length - 1)%>
|
||||
})
|
||||
};
|
||||
|
||||
var onRequestCompareFile = function() {
|
||||
docEditor.setRevisedFile(<%- JSON.stringify(dataCompareFile) %>);
|
||||
};
|
||||
|
||||
var onRequestMailMergeRecipients = function (event) {
|
||||
docEditor.setMailMergeRecipients(<%- JSON.stringify(dataMailMergeRecipients) %>);
|
||||
};
|
||||
|
||||
var connectEditor = function () {
|
||||
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor", {<%- include("config") %>,
|
||||
@ -122,6 +144,10 @@
|
||||
"onRequestHistoryClose": onRequestHistoryClose,
|
||||
"onOutdatedVersion": onOutdatedVersion,
|
||||
"onMakeActionLink": onMakeActionLink,
|
||||
"onMetaChange": onMetaChange,
|
||||
"onRequestInsertImage": onRequestInsertImage,
|
||||
"onRequestCompareFile": onRequestCompareFile,
|
||||
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
<body>
|
||||
<header>
|
||||
<a href="">
|
||||
<img src ="images/logo.png" alt="ONLYOFFICE" />
|
||||
<img src ="images/logo.svg" alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</header>
|
||||
<div class="main-panel">
|
||||
|
||||
1
web/documentserver-example/php/assets
Submodule
@ -194,8 +194,8 @@ function getStoragePath($fileName, $userAddress = NULL) {
|
||||
if (!file_exists($directory) && !is_dir($directory)) {
|
||||
mkdir($directory);
|
||||
}
|
||||
sendlog("getStoragePath result: " . $directory . $fileName, "common.log");
|
||||
return $directory . $fileName;
|
||||
sendlog("getStoragePath result: " . $directory . basename($fileName), "common.log");
|
||||
return $directory . basename($fileName);
|
||||
}
|
||||
|
||||
function getHistoryDir($storagePath) {
|
||||
@ -214,7 +214,7 @@ function getFileVersion($histDir) {
|
||||
if (!file_exists($histDir) || !is_dir($histDir)) return 0;
|
||||
|
||||
$cdir = scandir($histDir);
|
||||
$ver = 0;
|
||||
$ver = 1;
|
||||
foreach($cdir as $key => $fileName) {
|
||||
if (!in_array($fileName,array(".", ".."))) {
|
||||
if (is_dir($histDir . DIRECTORY_SEPARATOR . $fileName)) {
|
||||
@ -304,6 +304,36 @@ function FileUri($file_name, $forDocumentServer = NULL) {
|
||||
return $uri;
|
||||
}
|
||||
|
||||
function getFileInfo($fileId){
|
||||
$storedFiles = getStoredFiles();
|
||||
$result = array();
|
||||
$resultID = array();
|
||||
|
||||
foreach ($storedFiles as $key => $value){
|
||||
$result[$key] = (object) array(
|
||||
"version" => getFileVersion(getHistoryDir(getStoragePath($value->name))),
|
||||
"id" => getDocEditorKey($value->name),
|
||||
"contentLength" => number_format( filesize(getStoragePath($value->name)) / 1024, 2 )." KB",
|
||||
"pureContentLength" => filesize(getStoragePath($value->name)),
|
||||
"title" => $value->name,
|
||||
"updated" => date( DATE_ATOM, filemtime(getStoragePath($value->name))),
|
||||
);
|
||||
if ($fileId != null){
|
||||
if ($fileId == getDocEditorKey($value->name)){
|
||||
$resultID[count($resultID)] = $result[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($fileId != null){
|
||||
if (count($resultID) != 0) return $resultID;
|
||||
else return "File not found";
|
||||
}
|
||||
else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
function getFileExts() {
|
||||
return array_merge($GLOBALS['DOC_SERV_VIEWD'], $GLOBALS['DOC_SERV_EDITED'], $GLOBALS['DOC_SERV_CONVERT']);
|
||||
}
|
||||
|
||||
@ -6,16 +6,19 @@ $GLOBALS['ALONE'] = FALSE;
|
||||
|
||||
$GLOBALS['DOC_SERV_VIEWD'] = array(".pdf", ".djvu", ".xps");
|
||||
$GLOBALS['DOC_SERV_EDITED'] = array(".docx", ".xlsx", ".csv", ".pptx", ".txt");
|
||||
$GLOBALS['DOC_SERV_CONVERT'] = array(".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt", ".fodt", ".ott", ".xlsm", ".xls", ".xltx", ".xltm", ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsx", ".ppsm", ".pps", ".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".epub");
|
||||
$GLOBALS['DOC_SERV_CONVERT'] = array(".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt", ".fodt", ".ott", ".xlsm", ".xls", ".xltx", ".xltm", ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsx", ".ppsm", ".pps", ".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".epub", ".fb2");
|
||||
|
||||
$GLOBALS['DOC_SERV_TIMEOUT'] = "120000";
|
||||
|
||||
$GLOBALS['DOC_SERV_CONVERTER_URL'] = "https://documentserver/ConvertService.ashx";
|
||||
$GLOBALS['DOC_SERV_API_URL'] = "https://documentserver/web-apps/apps/api/documents/api.js";
|
||||
|
||||
$GLOBALS['DOC_SERV_PRELOADER_URL'] = "https://documentserver/web-apps/apps/api/documents/cache-scripts.html";
|
||||
$GLOBALS['DOC_SERV_SITE_URL'] = "https://documentserver/";
|
||||
|
||||
$GLOBALS['DOC_SERV_CONVERTER_URL'] = "ConvertService.ashx";
|
||||
$GLOBALS['DOC_SERV_API_URL'] = "web-apps/apps/api/documents/api.js";
|
||||
$GLOBALS['DOC_SERV_PRELOADER_URL'] = "web-apps/apps/api/documents/cache-scripts.html";
|
||||
|
||||
$GLOBALS['DOC_SERV_JWT_SECRET'] = "";
|
||||
$GLOBALS['DOC_SERV_JWT_HEADER'] = "Authorization";
|
||||
|
||||
$GLOBALS['EXAMPLE_URL'] = "";
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.0 KiB |
15
web/documentserver-example/php/css/images/logo.svg
Normal file
@ -0,0 +1,15 @@
|
||||
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
|
||||
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
|
||||
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
|
||||
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
|
||||
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
|
||||
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
|
||||
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
|
||||
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
|
||||
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
|
||||
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
|
||||
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.5 KiB |
@ -76,8 +76,9 @@
|
||||
"fileType" => $filetype,
|
||||
"key" => $docKey,
|
||||
"info" => [
|
||||
"author" => "Me",
|
||||
"created" => date('d.m.y')
|
||||
"owner" => "Me",
|
||||
"uploaded" => date('d.m.y'),
|
||||
"favorite" => isset($_GET["user"]) ? $_GET["user"] == 1 : null
|
||||
],
|
||||
"permissions" => [
|
||||
"comment" => $editorsMode != "view" && $editorsMode != "fillForms" && $editorsMode != "embedded" && $editorsMode != "blockcontent",
|
||||
@ -114,15 +115,34 @@
|
||||
]
|
||||
];
|
||||
|
||||
$dataInsertImage = [
|
||||
"fileType" => "png",
|
||||
"url" => serverPath(true) . "/css/images/logo.png"
|
||||
];
|
||||
|
||||
$dataCompareFile = [
|
||||
"fileType" => "docx",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=download&name=sample.docx"
|
||||
];
|
||||
|
||||
$dataMailMergeRecipients = [
|
||||
"fileType" =>"csv",
|
||||
"url" => serverPath(true) . "/webeditor-ajax.php?type=csv"
|
||||
];
|
||||
|
||||
if (isJwtEnabled()) {
|
||||
$config["token"] = jwtEncode($config);
|
||||
$dataInsertImage["token"] = jwtEncode($dataInsertImage);
|
||||
$dataCompareFile["token"] = jwtEncode($dataCompareFile);
|
||||
$dataMailMergeRecipients["token"] = jwtEncode($dataMailMergeRecipients);
|
||||
}
|
||||
|
||||
function tryGetDefaultByType($createExt) {
|
||||
$demoName = ($_GET["sample"] ? "demo." : "new.") . $createExt;
|
||||
$demoName = ($_GET["sample"] ? "sample." : "new.") . $createExt;
|
||||
$demoPath = "assets" . DIRECTORY_SEPARATOR . ($_GET["sample"] ? "sample" : "new") . DIRECTORY_SEPARATOR;
|
||||
$demoFilename = GetCorrectName($demoName);
|
||||
|
||||
if(!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . "app_data" . DIRECTORY_SEPARATOR . $demoName, getStoragePath($demoFilename)))
|
||||
if(!@copy(dirname(__FILE__) . DIRECTORY_SEPARATOR . $demoPath . $demoName, getStoragePath($demoFilename)))
|
||||
{
|
||||
sendlog("Copy file error to ". getStoragePath($demoFilename), "common.log");
|
||||
//Copy error!!!
|
||||
@ -150,16 +170,16 @@
|
||||
$hist = [];
|
||||
$histData = [];
|
||||
|
||||
for ($i = 0; $i <= $curVer; $i++) {
|
||||
for ($i = 1; $i <= $curVer; $i++) {
|
||||
$obj = [];
|
||||
$dataObj = [];
|
||||
$verDir = getVersionDir($histDir, $i + 1);
|
||||
$verDir = getVersionDir($histDir, $i);
|
||||
|
||||
$key = $i == $curVer ? $docKey : file_get_contents($verDir . DIRECTORY_SEPARATOR . "key.txt");
|
||||
$obj["key"] = $key;
|
||||
$obj["version"] = $i;
|
||||
|
||||
if ($i == 0) {
|
||||
if ($i == 1) {
|
||||
$createdInfo = file_get_contents($histDir . DIRECTORY_SEPARATOR . "createdInfo.json");
|
||||
$json = json_decode($createdInfo, true);
|
||||
|
||||
@ -176,8 +196,8 @@
|
||||
$dataObj["url"] = $i == $curVer ? $fileuri : getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($prevFileName));
|
||||
$dataObj["version"] = $i;
|
||||
|
||||
if ($i > 0) {
|
||||
$changes = json_decode(file_get_contents(getVersionDir($histDir, $i) . DIRECTORY_SEPARATOR . "changes.json"), true);
|
||||
if ($i > 1) {
|
||||
$changes = json_decode(file_get_contents(getVersionDir($histDir, $i - 1) . DIRECTORY_SEPARATOR . "changes.json"), true);
|
||||
$change = $changes["changes"][0];
|
||||
|
||||
$obj["changes"] = $changes["changes"];
|
||||
@ -185,19 +205,23 @@
|
||||
$obj["created"] = $change["created"];
|
||||
$obj["user"] = $change["user"];
|
||||
|
||||
$prev = $histData[$i -1];
|
||||
$prev = $histData[$i - 2];
|
||||
$dataObj["previous"] = [
|
||||
"key" => $prev["key"],
|
||||
"url" => $prev["url"]
|
||||
];
|
||||
$changesUrl = getVersionDir($histDir, $i) . DIRECTORY_SEPARATOR . "diff.zip";
|
||||
$changesUrl = getVersionDir($histDir, $i - 1) . DIRECTORY_SEPARATOR . "diff.zip";
|
||||
$changesUrl = substr($changesUrl, strlen(getStoragePath("")));
|
||||
|
||||
$dataObj["changesUrl"] = getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($changesUrl));
|
||||
}
|
||||
|
||||
if (isJwtEnabled()) {
|
||||
$dataObj["token"] = jwtEncode($dataObj);
|
||||
}
|
||||
|
||||
array_push($hist, $obj);
|
||||
$histData[$i] = $dataObj;
|
||||
$histData[$i - 1] = $dataObj;
|
||||
}
|
||||
|
||||
$out = [];
|
||||
@ -251,7 +275,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript" src="<?php echo $GLOBALS["DOC_SERV_API_URL"] ?>"></script>
|
||||
<script type="text/javascript" src="<?php echo $GLOBALS["DOC_SERV_SITE_URL"].$GLOBALS["DOC_SERV_API_URL"] ?>"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
@ -308,6 +332,28 @@
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var onMetaChange = function (event) {
|
||||
var favorite = !!event.data.favorite;
|
||||
var title = document.title.replace(/^\☆/g, "");
|
||||
document.title = (favorite ? "☆" : "") + title;
|
||||
docEditor.setFavorite(favorite);
|
||||
};
|
||||
|
||||
var onRequestInsertImage = function(event) {
|
||||
docEditor.insertImage({
|
||||
"c": event.data.c,
|
||||
<?php echo mb_strimwidth(json_encode($dataInsertImage), 1, strlen(json_encode($dataInsertImage)) - 2)?>
|
||||
})
|
||||
};
|
||||
|
||||
var onRequestCompareFile = function() {
|
||||
docEditor.setRevisedFile(<?php echo json_encode($dataCompareFile)?>);
|
||||
};
|
||||
|
||||
var onRequestMailMergeRecipients = function (event) {
|
||||
docEditor.setMailMergeRecipients(<?php echo json_encode($dataMailMergeRecipients) ?>);
|
||||
};
|
||||
|
||||
var сonnectEditor = function () {
|
||||
|
||||
<?php
|
||||
@ -328,6 +374,10 @@
|
||||
'onError': onError,
|
||||
'onOutdatedVersion': onOutdatedVersion,
|
||||
'onMakeActionLink': onMakeActionLink,
|
||||
'onMetaChange': onMetaChange,
|
||||
'onRequestInsertImage': onRequestInsertImage,
|
||||
'onRequestCompareFile': onRequestCompareFile,
|
||||
'onRequestMailMergeRecipients': onRequestMailMergeRecipients,
|
||||
};
|
||||
|
||||
<?php
|
||||
@ -342,7 +392,7 @@
|
||||
config.events['onRequestHistoryData'] = function (event) {
|
||||
var ver = event.data;
|
||||
var histData = <?php echo json_encode($historyData) ?>;
|
||||
docEditor.setHistoryData(histData[ver]);
|
||||
docEditor.setHistoryData(histData[ver - 1]);
|
||||
};
|
||||
config.events['onRequestHistoryClose'] = function () {
|
||||
document.location.reload();
|
||||
|
||||
@ -133,7 +133,7 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
|
||||
|
||||
$document_revision_id = GenerateRevisionId($document_revision_id);
|
||||
|
||||
$urlToConverter = $GLOBALS['DOC_SERV_CONVERTER_URL'];
|
||||
$urlToConverter = $GLOBALS['DOC_SERV_SITE_URL'].$GLOBALS['DOC_SERV_CONVERTER_URL'];
|
||||
|
||||
$arr = [
|
||||
"async" => $is_async,
|
||||
@ -145,6 +145,8 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
|
||||
];
|
||||
|
||||
$headerToken = "";
|
||||
$jwtHeader = $GLOBALS['DOC_SERV_JWT_HEADER'] == "" ? "Authorization" : $GLOBALS['DOC_SERV_JWT_HEADER'];
|
||||
|
||||
if (isJwtEnabled()) {
|
||||
$headerToken = jwtEncode([ "payload" => $arr ]);
|
||||
$arr["token"] = jwtEncode($arr);
|
||||
@ -157,7 +159,7 @@ function SendRequestToConvertService($document_uri, $from_extension, $to_extensi
|
||||
'timeout' => $GLOBALS['DOC_SERV_TIMEOUT'],
|
||||
'header'=> "Content-type: application/json\r\n" .
|
||||
"Accept: application/json\r\n" .
|
||||
(empty($headerToken) ? "" : "Authorization: $headerToken\r\n"),
|
||||
(empty($headerToken) ? "" : $jwtHeader.": Bearer $headerToken\r\n"),
|
||||
'content' => $data
|
||||
)
|
||||
);
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
<form id="form1">
|
||||
<header>
|
||||
<a href="">
|
||||
<img src ="css/images/logo.png" alt="ONLYOFFICE" />
|
||||
<img src ="css/images/logo.svg" alt="ONLYOFFICE" />
|
||||
</a>
|
||||
</header>
|
||||
<div class="main-panel">
|
||||
@ -314,7 +314,7 @@
|
||||
<div id="cancelEdit" class="button gray">Cancel</div>
|
||||
</div>
|
||||
|
||||
<span id="loadScripts" data-docs="<?php echo $GLOBALS['DOC_SERV_PRELOADER_URL'] ?>"></span>
|
||||
<span id="loadScripts" data-docs="<?php echo $GLOBALS['DOC_SERV_SITE_URL'].$GLOBALS['DOC_SERV_PRELOADER_URL'] ?>"></span>
|
||||
<footer>© Ascensio Systems Inc <?php echo date("Y") ?>. All rights reserved.</footer>
|
||||
|
||||
<script type="text/javascript" src="js/jscript.js"></script>
|
||||
|
||||
@ -7,5 +7,10 @@
|
||||
<defaultDocument enabled="true" />
|
||||
<httpErrors errorMode="Detailed"/>
|
||||
<urlCompression doDynamicCompression="false"/>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
||||
@ -64,6 +64,17 @@ if (isset($_GET["type"]) && !empty($_GET["type"])) { //Checks if type value exis
|
||||
$response_array = delete();
|
||||
$response_array['status'] = 'success';
|
||||
die (json_encode($response_array));
|
||||
case "download":
|
||||
$response_array = download();
|
||||
$response_array['status'] = 'success';
|
||||
die (json_encode($response_array));
|
||||
case "csv":
|
||||
$response_array = csv();
|
||||
$response_array['status'] = 'success';
|
||||
die (json_encode($response_array));
|
||||
case "files":
|
||||
$response_array = files();
|
||||
die (json_encode($response_array));
|
||||
default:
|
||||
$response_array['status'] = 'error';
|
||||
$response_array['error'] = '404 Method not found';
|
||||
@ -144,10 +155,12 @@ function track() {
|
||||
|
||||
$inHeader = false;
|
||||
$token = "";
|
||||
$jwtHeader = $GLOBALS['DOC_SERV_JWT_HEADER'] == "" ? "Authorization" : $GLOBALS['DOC_SERV_JWT_HEADER'];
|
||||
|
||||
if (!empty($data["token"])) {
|
||||
$token = jwtDecode($data["token"]);
|
||||
} elseif (!empty($_SERVER['HTTP_AUTHORIZATION'])) {
|
||||
$token = jwtDecode(substr($_SERVER['HTTP_AUTHORIZATION'], strlen("Bearer ")));
|
||||
} elseif (!empty(apache_request_headers()[$jwtHeader])) {
|
||||
$token = jwtDecode(substr(apache_request_headers()[$jwtHeader], strlen("Bearer ")));
|
||||
$inHeader = true;
|
||||
} else {
|
||||
sendlog("jwt token wasn't found in body or headers", "webedior-ajax.log");
|
||||
@ -171,7 +184,7 @@ function track() {
|
||||
case "Corrupted":
|
||||
|
||||
$userAddress = $_GET["userAddress"];
|
||||
$fileName = $_GET["fileName"];
|
||||
$fileName = basename($_GET["fileName"]);
|
||||
|
||||
$downloadUri = $data["url"];
|
||||
|
||||
@ -200,7 +213,7 @@ function track() {
|
||||
} else {
|
||||
$storagePath = getStoragePath($fileName, $userAddress);
|
||||
$histDir = getHistoryDir($storagePath);
|
||||
$verDir = getVersionDir($histDir, getFileVersion($histDir) + 1);
|
||||
$verDir = getVersionDir($histDir, getFileVersion($histDir));
|
||||
|
||||
mkdir($verDir);
|
||||
|
||||
@ -231,7 +244,7 @@ function track() {
|
||||
}
|
||||
|
||||
function convert() {
|
||||
$fileName = $_GET["filename"];
|
||||
$fileName = basename($_GET["filename"]);
|
||||
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||
$internalExtension = trim(getInternalExtension($fileName),'.');
|
||||
|
||||
@ -288,7 +301,7 @@ function convert() {
|
||||
|
||||
function delete() {
|
||||
try {
|
||||
$fileName = $_GET["fileName"];
|
||||
$fileName = basename($_GET["fileName"]);
|
||||
|
||||
$filePath = getStoragePath($fileName);
|
||||
|
||||
@ -302,6 +315,53 @@ function delete() {
|
||||
}
|
||||
}
|
||||
|
||||
function files() {
|
||||
try {
|
||||
@header( "Content-Type", "application/json" );
|
||||
|
||||
$fileId = $_GET["fileId"];
|
||||
$result = getFileInfo($fileId);
|
||||
|
||||
return $result;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
sendlog("Files ".$e->getMessage(), "webedior-ajax.log");
|
||||
$result["error"] = "error: " . $e->getMessage();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
function download() {
|
||||
$fileName = "sample" . DIRECTORY_SEPARATOR . basename($_GET["name"]);
|
||||
downloadFile($fileName);
|
||||
}
|
||||
|
||||
function csv() {
|
||||
$fileName = "sample" . DIRECTORY_SEPARATOR . "csv.csv";
|
||||
downloadFile($fileName);
|
||||
}
|
||||
|
||||
function downloadFile($fileName) {
|
||||
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . $fileName;
|
||||
if (file_exists($file)) {
|
||||
if (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
@header('Content-Length: ' . filesize($file));
|
||||
@header('Content-Disposition: attachment; filename*=UTF-8\'\'' . urldecode(basename($file)));
|
||||
@header('Content-Type: ' . mime_content_type($file));
|
||||
|
||||
if ($fd = fopen($file, 'rb')) {
|
||||
while (!feof($fd)) {
|
||||
print fread($fd, 1024);
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function delTree($dir) {
|
||||
if (!file_exists($dir) || !is_dir($dir)) return;
|
||||
|
||||
|
||||
1
web/documentserver-example/python/assets
Submodule
@ -10,19 +10,21 @@ DOC_SERV_CONVERT = [
|
||||
".fodt", ".ott", ".xlsm", ".xls", ".xltx", ".xltm",
|
||||
".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt",
|
||||
".ppsx", ".ppsm", ".pps", ".potx", ".potm", ".pot",
|
||||
".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".epub"
|
||||
".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".epub", ".fb2"
|
||||
]
|
||||
|
||||
DOC_SERV_TIMEOUT = 120000
|
||||
|
||||
DOC_SERV_CONVERTER_URL = 'https://documentserver/ConvertService.ashx'
|
||||
DOC_SERV_API_URL = 'https://documentserver/web-apps/apps/api/documents/api.js'
|
||||
DOC_SERV_PRELOADER_URL = 'https://documentserver/web-apps/apps/api/documents/cache-scripts.html'
|
||||
DOC_SERV_SITE_URL = 'https://documentserver/'
|
||||
|
||||
EXAMPLE_DOMAIN = 'https://exampleserver/'
|
||||
DOC_SERV_CONVERTER_URL = 'ConvertService.ashx'
|
||||
DOC_SERV_API_URL = 'web-apps/apps/api/documents/api.js'
|
||||
DOC_SERV_PRELOADER_URL = 'web-apps/apps/api/documents/cache-scripts.html'
|
||||
|
||||
EXAMPLE_DOMAIN = None
|
||||
|
||||
DOC_SERV_JWT_SECRET = ''
|
||||
|
||||
DOC_SERV_JWT_HEADER = 'Authorization'
|
||||
|
||||
EXT_SPREADSHEET = [
|
||||
".xls", ".xlsx", ".xlsm",
|
||||
@ -45,11 +47,7 @@ EXT_DOCUMENT = [
|
||||
".pdf", ".djvu", ".fb2", ".epub", ".xps"
|
||||
]
|
||||
|
||||
|
||||
if os.environ.get("EXAMPLE_DOMAIN"):
|
||||
EXAMPLE_DOMAIN = os.environ.get("EXAMPLE_DOMAIN")
|
||||
if os.environ.get("DOC_SERV"):
|
||||
base = os.environ.get("DOC_SERV").rstrip('/')
|
||||
DOC_SERV_CONVERTER_URL = base + '/ConvertService.ashx'
|
||||
DOC_SERV_API_URL = base + '/web-apps/apps/api/documents/api.js'
|
||||
DOC_SERV_PRELOADER_URL = base + '/web-apps/apps/api/documents/cache-scripts.html'
|
||||
DOC_SERV_SITE_URL = os.environ.get("DOC_SERV")
|
||||
@ -4,9 +4,9 @@ Example is written for Python 3.6+
|
||||
|
||||
You should also install following dependencies:
|
||||
```
|
||||
pip install Django==2.2.6
|
||||
pip install requests==2.22.0
|
||||
pip install pyjwt==1.7.1
|
||||
pip install Django==3.1.6
|
||||
pip install requests==2.25.1
|
||||
pip install pyjwt==2.0.1
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||