mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Compare commits
52 Commits
v5.5.1.10
...
v5.5.99.19
| Author | SHA1 | Date | |
|---|---|---|---|
| f8a1587109 | |||
| 44142da370 | |||
| 14a68befd2 | |||
| b1af12a78d | |||
| 83bab147d0 | |||
| 80670a0d64 | |||
| 870a3ee799 | |||
| c3c1689170 | |||
| a271b847d5 | |||
| 45ea1a8c1d | |||
| 1b90f16eb5 | |||
| 29072e3d5c | |||
| b82c2c68d5 | |||
| 67d6eaa18b | |||
| cb91ba1620 | |||
| 0e91256847 | |||
| ce16625091 | |||
| 4d538fc35d | |||
| 36c9583a2c | |||
| 1bde1f66d3 | |||
| fddc08c24b | |||
| 06305ee262 | |||
| e55e27cee8 | |||
| 8fa77cb9ba | |||
| f038327928 | |||
| 0adaf8a84b | |||
| 85cb88b0fc | |||
| 4c8ac0457f | |||
| 3ba6072b3e | |||
| ad966cfc28 | |||
| 1f9b2b8230 | |||
| 8b9f07e46e | |||
| af7101844a | |||
| b58bf412fa | |||
| a1c524df00 | |||
| be25001479 | |||
| 7466aba10f | |||
| c4fc8c85e2 | |||
| 007efef742 | |||
| a4bf9d76f6 | |||
| 7c5faa7c8a | |||
| 3497eeea9f | |||
| 7717cb35f8 | |||
| 1c59409ce2 | |||
| 5545568e04 | |||
| 6ba9b33606 | |||
| 8d657a0101 | |||
| c1454eff13 | |||
| f7867e4bc3 | |||
| f94e057492 | |||
| a5371faa27 | |||
| 34527f0b3e |
@ -28,3 +28,17 @@ Steve Matteson
|
||||
|
||||
License: Apache License, version 2.0
|
||||
|
||||
|
||||
6. requests - Requests is an elegant and simple HTTP library for Python
|
||||
|
||||
License: Apache License, version 2.0
|
||||
|
||||
|
||||
7. pyjwt - JSON Web Token implementation in Python
|
||||
|
||||
License: MIT
|
||||
|
||||
|
||||
8. django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design
|
||||
|
||||
License: BSD
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 ONLYOFFICE
|
||||
Copyright (c) 2020 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
<DirPHP>$(RootDir)web\documentserver-example\php\</DirPHP>
|
||||
<NameRuby>$(To)Ruby Example</NameRuby>
|
||||
<DirRuby>$(RootDir)web\documentserver-example\ruby\</DirRuby>
|
||||
<NamePython>$(To)Python Example</NamePython>
|
||||
<DirPython>$(RootDir)web\documentserver-example\python\</DirPython>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="Build">
|
||||
@ -56,6 +58,12 @@
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(ZipFilesRuby)" DestinationFiles="@(ZipFilesRuby->'$(NameRuby)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NameRuby)" WorkingDirectory="$(To)" ZipFileName="$(NameRuby).zip" />
|
||||
|
||||
<ItemGroup>
|
||||
<ZipFilesPython Include="$(DirPython)**" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(ZipFilesPython)" DestinationFiles="@(ZipFilesPython->'$(NamePython)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Zip Files="$(NamePython)" WorkingDirectory="$(To)" ZipFileName="$(NamePython).zip" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
@ -25,3 +25,18 @@ License: MIT
|
||||
5. Prime JWT - Prime JWT is intended to be fast and easy to use. Prime JWT has a single external dependency on Jackson.
|
||||
|
||||
License: Apache-2.0
|
||||
|
||||
|
||||
6. requests - Requests is an elegant and simple HTTP library for Python
|
||||
|
||||
License: Apache License, version 2.0
|
||||
|
||||
|
||||
7. pyjwt - JSON Web Token implementation in Python
|
||||
|
||||
License: MIT
|
||||
|
||||
|
||||
8. django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design
|
||||
|
||||
License: BSD
|
||||
27
licences/django.license
Normal file
27
licences/django.license
Normal file
@ -0,0 +1,27 @@
|
||||
Copyright (c) Django Software Foundation and individual contributors.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of Django nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
21
licences/pyjwt.license
Normal file
21
licences/pyjwt.license
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 José Padilla
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
13
licences/requests.license
Normal file
13
licences/requests.license
Normal file
@ -0,0 +1,13 @@
|
||||
Copyright 2019 Kenneth Reitz
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -52,7 +52,7 @@ namespace OnlineEditorsExampleMVC.Controllers
|
||||
public ActionResult Sample(string fileExt, bool? sample)
|
||||
{
|
||||
var fileName = DocManagerHelper.CreateDemo(fileExt, sample ?? false);
|
||||
DocManagerHelper.CreateMeta(fileName, Request.Cookies["uid"]?.Value, Request.Cookies["uname"]?.Value);
|
||||
DocManagerHelper.CreateMeta(fileName, Request.Cookies.GetOrDefault("uid", ""), Request.Cookies.GetOrDefault("uname", ""));
|
||||
Response.Redirect(Url.Action("Editor", "Home", new { fileName = fileName }));
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
21
web/documentserver-example/csharp-mvc/Helpers/Utils.cs
Normal file
21
web/documentserver-example/csharp-mvc/Helpers/Utils.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Web;
|
||||
|
||||
namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
public static string GetOrDefault(this HttpRequest request, string header, string def)
|
||||
{
|
||||
var value = request[header];
|
||||
if (value != null) return value;
|
||||
return def;
|
||||
}
|
||||
|
||||
public static string GetOrDefault(this HttpCookieCollection cookies, string cookie, string def)
|
||||
{
|
||||
var cook = cookies[cookie];
|
||||
if (cook != null && !string.IsNullOrEmpty(cook.Value)) return cook.Value;
|
||||
return def;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 ONLYOFFICE
|
||||
Copyright (c) 2020 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -106,13 +106,13 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
"editorConfig", new Dictionary<string, object>
|
||||
{
|
||||
{ "mode", mode },
|
||||
{ "lang", request.Cookies["ulang"]?.Value ?? "en" },
|
||||
{ "lang", request.Cookies.GetOrDefault("ulang", "en") },
|
||||
{ "callbackUrl", CallbackUrl },
|
||||
{
|
||||
"user", new Dictionary<string, object>
|
||||
{
|
||||
{ "id", request.Cookies["uid"]?.Value ?? "uid-1" },
|
||||
{ "name", request.Cookies["uname"]?.Value ?? "John Smith" }
|
||||
{ "id", request.Cookies.GetOrDefault("uid", "uid-1") },
|
||||
{ "name", request.Cookies.GetOrDefault("uname", "John Smith") }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -137,6 +137,7 @@
|
||||
<Compile Include="Helpers\DocManagerHelper.cs" />
|
||||
<Compile Include="Helpers\DocumentConverter.cs" />
|
||||
<Compile Include="Helpers\JwtManager.cs" />
|
||||
<Compile Include="Helpers\Utils.cs" />
|
||||
<Compile Include="Models\FileModel.cs" />
|
||||
<Compile Include="Models\FileUtility.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Ascensio System SIA")]
|
||||
[assembly: AssemblyProduct("OnlineEditorsExampleMVC")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA 2019")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -59,7 +59,7 @@
|
||||
<td width="30%" valign="middle">
|
||||
<span class="select-user">Username:</span>
|
||||
<select class="select-user" id="user">
|
||||
<option value="uid-1">Jonn Smith</option>
|
||||
<option value="uid-1">John Smith</option>
|
||||
<option value="uid-2">Mark Pottato</option>
|
||||
<option value="uid-3">Hamish Mitchell</option>
|
||||
</select>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -95,7 +95,7 @@ namespace OnlineEditorsExampleMVC
|
||||
|
||||
var savedFileName = DocManagerHelper.StoragePath(fileName);
|
||||
httpPostedFile.SaveAs(savedFileName);
|
||||
DocManagerHelper.CreateMeta(fileName, context.Request.Cookies["uid"]?.Value, context.Request.Cookies["uname"]?.Value);
|
||||
DocManagerHelper.CreateMeta(fileName, context.Request.Cookies.GetOrDefault("uid", ""), context.Request.Cookies.GetOrDefault("uname", ""));
|
||||
|
||||
context.Response.Write("{ \"filename\": \"" + fileName + "\"}");
|
||||
}
|
||||
@ -151,7 +151,7 @@ namespace OnlineEditorsExampleMVC
|
||||
|
||||
Remove(fileName);
|
||||
fileName = correctName;
|
||||
DocManagerHelper.CreateMeta(fileName, context.Request.Cookies["uid"]?.Value, context.Request.Cookies["uname"]?.Value);
|
||||
DocManagerHelper.CreateMeta(fileName, context.Request.Cookies.GetOrDefault("uid", ""), context.Request.Cookies.GetOrDefault("uname", ""));
|
||||
}
|
||||
|
||||
context.Response.Write("{ \"filename\" : \"" + fileName + "\"}");
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -54,7 +54,7 @@
|
||||
<td width="30%" valign="middle">
|
||||
<span class="select-user">Username:</span>
|
||||
<select class="select-user" id="user">
|
||||
<option value="uid-1">Jonn Smith</option>
|
||||
<option value="uid-1">John Smith</option>
|
||||
<option value="uid-2">Mark Pottato</option>
|
||||
<option value="uid-3">Hamish Mitchell</option>
|
||||
</select>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -241,8 +241,8 @@ namespace OnlineEditorsExample
|
||||
Directory.CreateDirectory(histDir);
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString() },
|
||||
{ "id", context.Request.Cookies["uid"]?.Value ?? "uid-1" },
|
||||
{ "name", context.Request.Cookies["uname"]?.Value ?? "John Smith" }
|
||||
{ "id", context.Request.Cookies.GetOrDefault("uid", "uid-1") },
|
||||
{ "name", context.Request.Cookies.GetOrDefault("uname", "John Smith") }
|
||||
}));
|
||||
|
||||
return _fileName;
|
||||
@ -288,8 +288,8 @@ namespace OnlineEditorsExample
|
||||
Directory.CreateDirectory(histDir);
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString() },
|
||||
{ "id", request.Cookies["uid"]?.Value ?? "uid-1" },
|
||||
{ "name", request.Cookies["uname"]?.Value ?? "John Smith" }
|
||||
{ "id", request.Cookies.GetOrDefault("uid", "uid-1") },
|
||||
{ "name", request.Cookies.GetOrDefault("uname", "John Smith") }
|
||||
}));
|
||||
}
|
||||
catch (Exception)
|
||||
@ -354,8 +354,8 @@ namespace OnlineEditorsExample
|
||||
Directory.CreateDirectory(histDir);
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString() },
|
||||
{ "id", context.Request.Cookies["uid"]?.Value ?? "uid-1" },
|
||||
{ "name", context.Request.Cookies["uname"]?.Value ?? "John Smith" }
|
||||
{ "id", context.Request.Cookies.GetOrDefault("uid", "uid-1") },
|
||||
{ "name", context.Request.Cookies.GetOrDefault("uname", "John Smith") }
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -101,14 +101,14 @@ namespace OnlineEditorsExample
|
||||
|
||||
var ext = Path.GetExtension(FileName);
|
||||
|
||||
var editorsMode = Request["editorsMode"] ?? "edit";
|
||||
var editorsMode = Request.GetOrDefault("editorsMode", "edit");
|
||||
|
||||
var canEdit = _Default.EditedExts.Contains(ext);
|
||||
var mode = canEdit && editorsMode != "view" ? "edit" : "view";
|
||||
|
||||
var config = new Dictionary<string, object>
|
||||
{
|
||||
{ "type", Request["editorsType"] ?? "desktop" },
|
||||
{ "type", Request.GetOrDefault("editorsType", "desktop") },
|
||||
{ "documentType", _Default.DocumentType(FileName) },
|
||||
{
|
||||
"document", new Dictionary<string, object>
|
||||
@ -142,13 +142,13 @@ namespace OnlineEditorsExample
|
||||
"editorConfig", new Dictionary<string, object>
|
||||
{
|
||||
{ "mode", mode },
|
||||
{ "lang", Request.Cookies["ulang"]?.Value ?? "en" },
|
||||
{ "lang", Request.Cookies.GetOrDefault("ulang", "en") },
|
||||
{ "callbackUrl", CallbackUrl },
|
||||
{
|
||||
"user", new Dictionary<string, object>
|
||||
{
|
||||
{ "id", Request.Cookies["uid"]?.Value ?? "uid-1" },
|
||||
{ "name", Request.Cookies["uname"]?.Value ?? "John Smith" }
|
||||
{ "id", Request.Cookies.GetOrDefault("uid", "uid-1") },
|
||||
{ "name", Request.Cookies.GetOrDefault("uname", "John Smith") }
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -189,7 +189,9 @@ namespace OnlineEditorsExample
|
||||
|
||||
try
|
||||
{
|
||||
GetHistory(out var hist, out var histData);
|
||||
Dictionary<string, object> hist;
|
||||
Dictionary<string, object> histData;
|
||||
GetHistory(out hist, out histData);
|
||||
if (hist != null && histData != null)
|
||||
{
|
||||
History = jss.Serialize(hist);
|
||||
@ -305,8 +307,8 @@ namespace OnlineEditorsExample
|
||||
Directory.CreateDirectory(histDir);
|
||||
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
|
||||
{ "created", DateTime.Now.ToString() },
|
||||
{ "id", request.Cookies["uid"]?.Value ?? "uid-1" },
|
||||
{ "name", request.Cookies["uname"]?.Value ?? "John Smith" }
|
||||
{ "id", request.Cookies.GetOrDefault("uid", "uid-1") },
|
||||
{ "name", request.Cookies.GetOrDefault("uname", "John Smith") }
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 ONLYOFFICE
|
||||
Copyright (c) 2020 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -92,6 +92,7 @@
|
||||
<Compile Include="Default.aspx.designer.cs">
|
||||
<DependentUpon>Default.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utils.cs" />
|
||||
<Compile Include="WebEditor.ashx.cs">
|
||||
<DependentUpon>WebEditor.ashx</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@ -7,7 +7,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Ascensio System SIA")]
|
||||
[assembly: AssemblyProduct("OnlineEditorsExample")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA 2019")]
|
||||
[assembly: AssemblyCopyright("Ascensio System SIA 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
21
web/documentserver-example/csharp/Utils.cs
Normal file
21
web/documentserver-example/csharp/Utils.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Web;
|
||||
|
||||
namespace OnlineEditorsExample
|
||||
{
|
||||
public static class Utils
|
||||
{
|
||||
public static string GetOrDefault(this HttpRequest request, string header, string def)
|
||||
{
|
||||
var value = request[header];
|
||||
if (value != null) return value;
|
||||
return def;
|
||||
}
|
||||
|
||||
public static string GetOrDefault(this HttpCookieCollection cookies, string cookie, string def)
|
||||
{
|
||||
var cook = cookies[cookie];
|
||||
if (cook != null && !string.IsNullOrEmpty(cook.Value)) return cook.Value;
|
||||
return def;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 ONLYOFFICE
|
||||
Copyright (c) 2020 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -58,7 +58,7 @@
|
||||
<td width="30%" valign="middle">
|
||||
<span class="select-user">Username:</span>
|
||||
<select class="select-user" id="user">
|
||||
<option value="uid-1">Jonn Smith</option>
|
||||
<option value="uid-1">John Smith</option>
|
||||
<option value="uid-2">Mark Pottato</option>
|
||||
<option value="uid-3">Hamish Mitchell</option>
|
||||
</select>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 ONLYOFFICE
|
||||
Copyright (c) 2020 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 ONLYOFFICE
|
||||
Copyright (c) 2020 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -202,7 +202,7 @@ app.post("/upload", function (req, res) {
|
||||
res.write("{ \"filename\": \"" + file.name + "\"}");
|
||||
|
||||
const userid = req.query.userid ? req.query.userid : "uid-1";
|
||||
const name = req.query.name ? req.query.name : "Jonn Smith";
|
||||
const name = req.query.name ? req.query.name : "John Smith";
|
||||
|
||||
docManager.saveFileData(file.name, userid, name);
|
||||
}
|
||||
@ -521,7 +521,7 @@ app.get("/editor", function (req, res) {
|
||||
var historyData = [];
|
||||
var lang = docManager.getLang();
|
||||
var userid = req.query.userid ? req.query.userid : "uid-1";
|
||||
var name = req.query.name ? req.query.name : "Jonn Smith";
|
||||
var name = req.query.name ? req.query.name : "John Smith";
|
||||
|
||||
if (fileExt != null) {
|
||||
var fileName = docManager.createDemo((req.query.sample ? "sample." : "new.") + fileExt, userid, name);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
19
web/documentserver-example/nodejs/run-develop.py
Normal file
19
web/documentserver-example/nodejs/run-develop.py
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
sys.path.append('../../../../build_tools/scripts')
|
||||
import os
|
||||
import base
|
||||
|
||||
def install_module():
|
||||
base.print_info('Install')
|
||||
base.cmd('npm', ['install'])
|
||||
|
||||
def run_integration_example():
|
||||
install_module()
|
||||
base.set_env('NODE_CONFIG_DIR', './config')
|
||||
base.print_info('run integration example')
|
||||
base.run_nodejs(['bin/www'])
|
||||
|
||||
base.set_env('NODE_ENV', 'development-' + base.host_platform())
|
||||
|
||||
run_integration_example()
|
||||
@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEDIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
cd $BASEDIR
|
||||
|
||||
echo "----------------------------------------"
|
||||
echo "Install nodejs modules "
|
||||
echo "----------------------------------------"
|
||||
|
||||
npm install
|
||||
|
||||
|
||||
echo "----------------------------------------"
|
||||
echo "Run server "
|
||||
echo "----------------------------------------"
|
||||
|
||||
export NODE_CONFIG_DIR=$BASEDIR/config && export NODE_ENV=development-mac && node bin/www
|
||||
@ -1,15 +0,0 @@
|
||||
ECHO OFF
|
||||
|
||||
ECHO.
|
||||
ECHO ----------------------------------------
|
||||
ECHO Install node.js modules
|
||||
ECHO ----------------------------------------
|
||||
call npm install
|
||||
|
||||
ECHO.
|
||||
ECHO ----------------------------------------
|
||||
ECHO Run server
|
||||
ECHO ----------------------------------------
|
||||
SET NODE_CONFIG_DIR=%~dp0\config
|
||||
SET NODE_ENV=development-windows
|
||||
start /min /b node bin/www
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -53,7 +53,7 @@
|
||||
<td valign="middle" width="30%">
|
||||
<span class="select-user">Username:</span>
|
||||
<select class="select-user" id="user">
|
||||
<option value="uid-1">Jonn Smith</option>
|
||||
<option value="uid-1">John Smith</option>
|
||||
<option value="uid-2">Mark Pottato</option>
|
||||
<option value="uid-3">Hamish Mitchell</option>
|
||||
</select>
|
||||
@ -86,7 +86,7 @@
|
||||
<option value="vi">Vietnamese</option>
|
||||
</select>
|
||||
</td>
|
||||
<td valign="middle" width="70%">Choose the language for ONLYOFFICE™ editors interface.</td>
|
||||
<td valign="middle" width="70%">Choose the language for ONLYOFFICE editors interface.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
@ -263,7 +263,7 @@
|
||||
|
||||
<span id="loadScripts" data-docs="<%= preloaderUrl %>"></span>
|
||||
|
||||
<footer>© Ascensio Systems SIA 2019. All rights reserved.</footer>
|
||||
<footer>© Ascensio Systems SIA 2020. All rights reserved.</footer>
|
||||
|
||||
<script type="text/javascript" src="javascripts/jquery-1.8.2.js"></script>
|
||||
<script type="text/javascript" src="javascripts/jquery-ui.js"></script>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 ONLYOFFICE
|
||||
Copyright (c) 2020 ONLYOFFICE
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -291,7 +291,7 @@ function createMeta($fileName, $uid = "0") {
|
||||
$name = "";
|
||||
switch ($uid) {
|
||||
case 0:
|
||||
$name = "Jonn Smith";
|
||||
$name = "John Smith";
|
||||
break;
|
||||
case 1:
|
||||
$name = "Mark Pottato";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -63,7 +63,7 @@
|
||||
$uname = "";
|
||||
switch ($uid) {
|
||||
case 0:
|
||||
$uname = "Jonn Smith";
|
||||
$uname = "John Smith";
|
||||
break;
|
||||
case 1:
|
||||
$uname = "Mark Pottato";
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -84,7 +84,7 @@
|
||||
<td valign="middle" width="30%">
|
||||
<span class="select-user">Username:</span>
|
||||
<select class="select-user" id="user">
|
||||
<option value="0">Jonn Smith</option>
|
||||
<option value="0">John Smith</option>
|
||||
<option value="1">Mark Pottato</option>
|
||||
<option value="2">Hamish Mitchell</option>
|
||||
</select>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
|
||||
55
web/documentserver-example/python/config.py
Normal file
55
web/documentserver-example/python/config.py
Normal file
@ -0,0 +1,55 @@
|
||||
import os
|
||||
|
||||
FILE_SIZE_MAX = 5242880
|
||||
STORAGE_PATH = 'app_data'
|
||||
|
||||
DOC_SERV_VIEWED = [".pdf", ".djvu", ".xps"]
|
||||
DOC_SERV_EDITED = [".docx", ".xlsx", ".csv", ".pptx", ".txt"]
|
||||
DOC_SERV_CONVERT = [
|
||||
".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"
|
||||
]
|
||||
|
||||
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'
|
||||
|
||||
EXAMPLE_DOMAIN = 'https://exampleserver/'
|
||||
|
||||
DOC_SERV_JWT_SECRET = ''
|
||||
|
||||
|
||||
EXT_SPREADSHEET = [
|
||||
".xls", ".xlsx", ".xlsm",
|
||||
".xlt", ".xltx", ".xltm",
|
||||
".ods", ".fods", ".ots", ".csv"
|
||||
]
|
||||
|
||||
EXT_PRESENTATION = [
|
||||
".pps", ".ppsx", ".ppsm",
|
||||
".ppt", ".pptx", ".pptm",
|
||||
".pot", ".potx", ".potm",
|
||||
".odp", ".fodp", ".otp"
|
||||
]
|
||||
|
||||
EXT_DOCUMENT = [
|
||||
".doc", ".docx", ".docm",
|
||||
".dot", ".dotx", ".dotm",
|
||||
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
||||
".html", ".htm", ".mht",
|
||||
".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'
|
||||
21
web/documentserver-example/python/manage.py
Normal file
21
web/documentserver-example/python/manage.py
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
18
web/documentserver-example/python/readme.md
Normal file
18
web/documentserver-example/python/readme.md
Normal file
@ -0,0 +1,18 @@
|
||||
## Requirements
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Configuration located inside `config.py`
|
||||
|
||||
## Launch
|
||||
|
||||
`python manage.py runserver 0.0.0.0:8000`
|
||||
BIN
web/documentserver-example/python/samples/new.docx
Normal file
BIN
web/documentserver-example/python/samples/new.docx
Normal file
Binary file not shown.
BIN
web/documentserver-example/python/samples/new.pptx
Normal file
BIN
web/documentserver-example/python/samples/new.pptx
Normal file
Binary file not shown.
BIN
web/documentserver-example/python/samples/new.xlsx
Normal file
BIN
web/documentserver-example/python/samples/new.xlsx
Normal file
Binary file not shown.
BIN
web/documentserver-example/python/samples/sample.docx
Normal file
BIN
web/documentserver-example/python/samples/sample.docx
Normal file
Binary file not shown.
BIN
web/documentserver-example/python/samples/sample.pptx
Normal file
BIN
web/documentserver-example/python/samples/sample.pptx
Normal file
Binary file not shown.
BIN
web/documentserver-example/python/samples/sample.xlsx
Normal file
BIN
web/documentserver-example/python/samples/sample.xlsx
Normal file
Binary file not shown.
99
web/documentserver-example/python/src/settings.py
Normal file
99
web/documentserver-example/python/src/settings.py
Normal file
@ -0,0 +1,99 @@
|
||||
"""
|
||||
Django settings for example project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 2.2.6.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.2/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/2.2/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
import config
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '7a5qnm_bv)iskjhx%4cbwwdmjev03%zewm=3@4s*uz)el#ds5o'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
'*'
|
||||
]
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'src.utils.historyManager.CorsHeaderMiddleware',
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'src.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [ 'templates' ],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'src.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||
|
||||
DATABASES = {}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = []
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||
|
||||
STATIC_ROOT = ''
|
||||
STATIC_URL = '/static/'
|
||||
STATICFILES_DIRS = ( os.path.join('static'), os.path.join(config.STORAGE_PATH) )
|
||||
42
web/documentserver-example/python/src/urls.py
Normal file
42
web/documentserver-example/python/src/urls.py
Normal file
@ -0,0 +1,42 @@
|
||||
"""
|
||||
|
||||
(c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
|
||||
from django.urls import path
|
||||
|
||||
from src.views import index, actions
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
|
||||
urlpatterns = [
|
||||
path('', index.default),
|
||||
path('upload', actions.upload),
|
||||
path('convert', actions.convert),
|
||||
path('create', actions.createNew),
|
||||
path('edit', actions.edit),
|
||||
path('track', actions.track),
|
||||
path('remove', actions.remove)
|
||||
]
|
||||
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
185
web/documentserver-example/python/src/utils/docManager.py
Normal file
185
web/documentserver-example/python/src/utils/docManager.py
Normal file
@ -0,0 +1,185 @@
|
||||
"""
|
||||
|
||||
(c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import config
|
||||
import os
|
||||
import shutil
|
||||
import io
|
||||
import re
|
||||
import requests
|
||||
|
||||
from src import settings
|
||||
from . import fileUtils, historyManager
|
||||
|
||||
LANGUAGES = {
|
||||
'en': 'English',
|
||||
'bg': 'Bulgarian',
|
||||
'zh': 'Chinese',
|
||||
'cs': 'Czech',
|
||||
'nl': 'Dutch',
|
||||
'fr': 'French',
|
||||
'de': 'German',
|
||||
'hu': 'Hungarian',
|
||||
'it': 'Italian',
|
||||
'ja': 'Japanese',
|
||||
'ko': 'Korean',
|
||||
'lv': 'Latvian',
|
||||
'pl': 'Polish',
|
||||
'pt': 'Portuguese',
|
||||
'ru': 'Russian',
|
||||
'sk': 'Slovak',
|
||||
'sl': 'Slovenian',
|
||||
'es': 'Spanish',
|
||||
'tr': 'Turkish',
|
||||
'uk': 'Ukrainian',
|
||||
'vi': 'Vietnamese'
|
||||
}
|
||||
|
||||
def isCanView(ext):
|
||||
return ext in config.DOC_SERV_VIEWED
|
||||
|
||||
def isCanEdit(ext):
|
||||
return ext in config.DOC_SERV_EDITED
|
||||
|
||||
def isCanConvert(ext):
|
||||
return ext in config.DOC_SERV_CONVERT
|
||||
|
||||
def isSupportedExt(ext):
|
||||
return isCanView(ext) | isCanEdit(ext) | isCanConvert(ext)
|
||||
|
||||
def getInternalExtension(fileType):
|
||||
mapping = {
|
||||
'text': '.docx',
|
||||
'spreadsheet': '.xlsx',
|
||||
'presentation': '.pptx'
|
||||
}
|
||||
|
||||
return mapping.get(fileType, '.docx')
|
||||
|
||||
def getCorrectName(filename, req):
|
||||
basename = fileUtils.getFileNameWithoutExt(filename)
|
||||
ext = fileUtils.getFileExt(filename)
|
||||
name = f'{basename}{ext}'
|
||||
|
||||
i = 1
|
||||
while os.path.exists(getStoragePath(name, req)):
|
||||
name = f'{basename} ({i}){ext}'
|
||||
i += 1
|
||||
|
||||
return name
|
||||
|
||||
def getFileUri(filename, req):
|
||||
host = config.EXAMPLE_DOMAIN.rstrip('/')
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
return f'{host}{settings.STATIC_URL}{curAdr}/{filename}'
|
||||
|
||||
def getCallbackUrl(filename, req):
|
||||
host = config.EXAMPLE_DOMAIN
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
return f'{host}track?filename={filename}&userAddress={curAdr}'
|
||||
|
||||
def getRootFolder(req):
|
||||
if isinstance(req, str):
|
||||
curAdr = req
|
||||
else:
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
|
||||
directory = os.path.join(config.STORAGE_PATH, curAdr)
|
||||
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
|
||||
return directory
|
||||
|
||||
def getStoragePath(filename, req):
|
||||
directory = getRootFolder(req)
|
||||
|
||||
return os.path.join(directory, filename)
|
||||
|
||||
def getStoredFiles(req):
|
||||
directory = getRootFolder(req)
|
||||
|
||||
files = os.listdir(directory)
|
||||
files.sort(key=lambda x: os.path.getmtime(os.path.join(directory, x)), reverse=True)
|
||||
|
||||
fileInfos = []
|
||||
|
||||
for f in files:
|
||||
if os.path.isfile(os.path.join(directory, f)):
|
||||
fileInfos.append({ 'type': fileUtils.getFileType(f), 'title': f, 'url': getFileUri(f, req) })
|
||||
|
||||
return fileInfos
|
||||
|
||||
def createFile(stream, path, req = None, meta = False):
|
||||
bufSize = 8196
|
||||
with io.open(path, 'wb') as out:
|
||||
read = stream.read(bufSize)
|
||||
|
||||
while len(read) > 0:
|
||||
out.write(read)
|
||||
read = stream.read(bufSize)
|
||||
|
||||
if meta:
|
||||
historyManager.createMeta(path, req)
|
||||
return
|
||||
|
||||
def saveFileFromUri(uri, path, req = None, meta = False):
|
||||
resp = requests.get(uri, stream=True)
|
||||
createFile(resp.raw, path, req, meta)
|
||||
return
|
||||
|
||||
def createSample(fileType, sample, req):
|
||||
ext = getInternalExtension(fileType)
|
||||
|
||||
if not sample:
|
||||
sample = 'false'
|
||||
|
||||
sampleName = 'sample' if sample == 'true' else 'new'
|
||||
|
||||
filename = getCorrectName(f'{sampleName}{ext}', req)
|
||||
path = getStoragePath(filename, req)
|
||||
|
||||
with io.open(os.path.join('samples', f'{sampleName}{ext}'), 'rb') as stream:
|
||||
createFile(stream, path, req, True)
|
||||
return filename
|
||||
|
||||
def removeFile(filename, req):
|
||||
path = getStoragePath(filename, req)
|
||||
if os.path.exists(path):
|
||||
os.remove(path)
|
||||
histDir = historyManager.getHistoryDir(path)
|
||||
if os.path.exists(histDir):
|
||||
shutil.rmtree(histDir)
|
||||
|
||||
def generateFileKey(filename, req):
|
||||
path = getStoragePath(filename, req)
|
||||
uri = getFileUri(filename, req)
|
||||
stat = os.stat(path)
|
||||
|
||||
h = str(hash(f'{uri}_{stat.st_mtime_ns}'))
|
||||
replaced = re.sub(r'[^0-9-.a-zA-Z_=]', '_', h)
|
||||
return replaced[:20]
|
||||
52
web/documentserver-example/python/src/utils/fileUtils.py
Normal file
52
web/documentserver-example/python/src/utils/fileUtils.py
Normal file
@ -0,0 +1,52 @@
|
||||
"""
|
||||
|
||||
(c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
|
||||
import config
|
||||
|
||||
def getFileName(str):
|
||||
ind = str.rfind('/')
|
||||
return str[ind+1:]
|
||||
|
||||
def getFileNameWithoutExt(str):
|
||||
fn = getFileName(str)
|
||||
ind = fn.rfind('.')
|
||||
return fn[:ind]
|
||||
|
||||
def getFileExt(str):
|
||||
fn = getFileName(str)
|
||||
ind = fn.rfind('.')
|
||||
return fn[ind:].lower()
|
||||
|
||||
def getFileType(str):
|
||||
ext = getFileExt(str)
|
||||
if ext in config.EXT_DOCUMENT:
|
||||
return 'text'
|
||||
if ext in config.EXT_SPREADSHEET:
|
||||
return 'spreadsheet'
|
||||
if ext in config.EXT_PRESENTATION:
|
||||
return 'presentation'
|
||||
|
||||
return 'text'
|
||||
196
web/documentserver-example/python/src/utils/historyManager.py
Normal file
196
web/documentserver-example/python/src/utils/historyManager.py
Normal file
@ -0,0 +1,196 @@
|
||||
"""
|
||||
|
||||
(c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
import io
|
||||
import json
|
||||
import config
|
||||
|
||||
from . import users, fileUtils
|
||||
from datetime import datetime
|
||||
from src import settings
|
||||
|
||||
def getHistoryDir(storagePath):
|
||||
return f'{storagePath}-hist'
|
||||
|
||||
def getVersionDir(histDir, version):
|
||||
return os.path.join(histDir, str(version))
|
||||
|
||||
def getFileVersion(histDir):
|
||||
if not os.path.exists(histDir):
|
||||
return 0
|
||||
|
||||
cnt = 0
|
||||
|
||||
for f in os.listdir(histDir):
|
||||
if not os.path.isfile(os.path.join(histDir, f)):
|
||||
cnt += 1
|
||||
|
||||
return cnt
|
||||
|
||||
def getNextVersionDir(histDir):
|
||||
v = getFileVersion(histDir)
|
||||
path = getVersionDir(histDir, v + 1)
|
||||
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
return path
|
||||
|
||||
def getChangesZipPath(verDir):
|
||||
return os.path.join(verDir, 'diff.zip')
|
||||
|
||||
def getChangesHistoryPath(verDir):
|
||||
return os.path.join(verDir, 'changes.json')
|
||||
|
||||
def getPrevFilePath(verDir, ext):
|
||||
return os.path.join(verDir, f'prev{ext}')
|
||||
|
||||
def getKeyPath(verDir):
|
||||
return os.path.join(verDir, 'key.txt')
|
||||
|
||||
def getMetaPath(histDir):
|
||||
return os.path.join(histDir, 'createdInfo.json')
|
||||
|
||||
def createMeta(storagePath, req):
|
||||
histDir = getHistoryDir(storagePath)
|
||||
path = getMetaPath(histDir)
|
||||
|
||||
if not os.path.exists(histDir):
|
||||
os.makedirs(histDir)
|
||||
|
||||
user = users.getUserFromReq(req)
|
||||
|
||||
obj = {
|
||||
'created': datetime.today().strftime('%d.%m.%Y %H:%M:%S'),
|
||||
'uid': user['uid'],
|
||||
'uname': user['uname']
|
||||
}
|
||||
|
||||
writeFile(path, json.dumps(obj))
|
||||
|
||||
return
|
||||
|
||||
def writeFile(path, content):
|
||||
with io.open(path, 'w') as out:
|
||||
out.write(content)
|
||||
return
|
||||
|
||||
def readFile(path):
|
||||
with io.open(path, 'r') as stream:
|
||||
return stream.read()
|
||||
|
||||
def getPrevUri(filename, ver, ext, req):
|
||||
host = config.EXAMPLE_DOMAIN.rstrip('/')
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
return f'{host}{settings.STATIC_URL}{curAdr}/{filename}-hist/{ver}/prev{ext}'
|
||||
|
||||
def getZipUri(filename, ver, req):
|
||||
host = config.EXAMPLE_DOMAIN.rstrip('/')
|
||||
curAdr = req.META['REMOTE_ADDR']
|
||||
return f'{host}{settings.STATIC_URL}{curAdr}/{filename}-hist/{ver}/diff.zip'
|
||||
|
||||
def getMeta(storagePath):
|
||||
histDir = getHistoryDir(storagePath)
|
||||
path = getMetaPath(histDir)
|
||||
|
||||
if os.path.exists(path):
|
||||
with io.open(path, 'r') as stream:
|
||||
return json.loads(stream.read())
|
||||
|
||||
return None
|
||||
|
||||
def getHistoryObject(storagePath, filename, docKey, docUrl, req):
|
||||
histDir = getHistoryDir(storagePath)
|
||||
version = getFileVersion(histDir)
|
||||
if version > 0:
|
||||
hist = []
|
||||
histData = {}
|
||||
|
||||
for i in range(version + 1):
|
||||
obj = {}
|
||||
dataObj = {}
|
||||
prevVerDir = getVersionDir(histDir, i)
|
||||
verDir = getVersionDir(histDir, i + 1)
|
||||
|
||||
try:
|
||||
key = docKey if i == version else readFile(getKeyPath(verDir))
|
||||
|
||||
obj['key'] = key
|
||||
obj['version'] = i
|
||||
dataObj['key'] = key
|
||||
dataObj['version'] = i
|
||||
|
||||
if i == 0:
|
||||
meta = getMeta(storagePath)
|
||||
if meta:
|
||||
obj['created'] = meta['created']
|
||||
obj['user'] = {
|
||||
'id': meta['uid'],
|
||||
'name': meta['uname']
|
||||
}
|
||||
|
||||
dataObj['url'] = docUrl if i == version else getPrevUri(filename, i + 1, fileUtils.getFileExt(filename), req)
|
||||
|
||||
if i > 0:
|
||||
changes = json.loads(readFile(getChangesHistoryPath(prevVerDir)))
|
||||
change = changes['changes'][0]
|
||||
|
||||
obj['changes'] = changes['changes']
|
||||
obj['serverVersion'] = changes['serverVersion']
|
||||
obj['created'] = change['created']
|
||||
obj['user'] = change['user']
|
||||
|
||||
prev = histData[str(i - 1)]
|
||||
prevInfo = {
|
||||
'key': prev['key'],
|
||||
'url': prev['url']
|
||||
}
|
||||
dataObj['previous'] = prevInfo
|
||||
dataObj['changesUrl'] = getZipUri(filename, i, req)
|
||||
|
||||
hist.append(obj)
|
||||
histData[str(i)] = dataObj
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
histObj = {
|
||||
'currentVersion': version,
|
||||
'history': hist
|
||||
}
|
||||
|
||||
return { 'history': histObj, 'historyData': histData }
|
||||
return {}
|
||||
|
||||
|
||||
class CorsHeaderMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
resp = self.get_response(request)
|
||||
if request.path.endswith('.zip'):
|
||||
resp['Access-Control-Allow-Origin'] = '*'
|
||||
return resp
|
||||
37
web/documentserver-example/python/src/utils/jwtManager.py
Normal file
37
web/documentserver-example/python/src/utils/jwtManager.py
Normal file
@ -0,0 +1,37 @@
|
||||
"""
|
||||
|
||||
(c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
|
||||
import config
|
||||
import jwt
|
||||
|
||||
def isEnabled():
|
||||
return bool(config.DOC_SERV_JWT_SECRET)
|
||||
|
||||
def encode(payload):
|
||||
return jwt.encode(payload, config.DOC_SERV_JWT_SECRET, algorithm='HS256').decode('utf-8')
|
||||
|
||||
def decode(string):
|
||||
return jwt.decode(string, config.DOC_SERV_JWT_SECRET, algorithms=['HS256'])
|
||||
@ -0,0 +1,85 @@
|
||||
"""
|
||||
|
||||
(c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
"""
|
||||
|
||||
import json
|
||||
import requests
|
||||
import config
|
||||
|
||||
from . import fileUtils, jwtManager
|
||||
|
||||
def getConverterUri(docUri, fromExt, toExt, docKey, isAsync):
|
||||
if not fromExt:
|
||||
fromExt = fileUtils.getFileExt(docUri)
|
||||
|
||||
title = fileUtils.getFileName(docUri)
|
||||
|
||||
payload = {
|
||||
'url': docUri,
|
||||
'outputtype': toExt.replace('.', ''),
|
||||
'filetype': fromExt.replace('.', ''),
|
||||
'title': title,
|
||||
'key': docKey
|
||||
}
|
||||
|
||||
headers={'accept': 'application/json'}
|
||||
|
||||
if (isAsync):
|
||||
payload.setdefault('async', True)
|
||||
|
||||
if jwtManager.isEnabled():
|
||||
headerToken = jwtManager.encode({'payload': payload})
|
||||
payload['token'] = jwtManager.encode(payload)
|
||||
headers['Authorization'] = f'Bearer {headerToken}'
|
||||
|
||||
response = requests.post(config.DOC_SERV_CONVERTER_URL, json=payload, headers=headers )
|
||||
json = response.json()
|
||||
|
||||
return getResponseUri(json)
|
||||
|
||||
def getResponseUri(json):
|
||||
isEnd = json.get('endConvert')
|
||||
error = json.get('error')
|
||||
if error:
|
||||
processError(error)
|
||||
|
||||
if isEnd:
|
||||
return json.get('fileUrl')
|
||||
|
||||
def processError(error):
|
||||
prefix = 'Error occurred in the ConvertService: '
|
||||
|
||||
mapping = {
|
||||
'-8': f'{prefix}Error document VKey',
|
||||
'-7': f'{prefix}Error document request',
|
||||
'-6': f'{prefix}Error database',
|
||||
'-5': f'{prefix}Error unexpected guid',
|
||||
'-4': f'{prefix}Error download error',
|
||||
'-3': f'{prefix}Error convertation error',
|
||||
'-2': f'{prefix}Error convertation timeout',
|
||||
'-1': f'{prefix}Error convertation unknown'
|
||||
}
|
||||
|
||||
raise Exception(mapping.get(str(error), f'Error Code: {error}'))
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user