mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Compare commits
68 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fb039100e1 | |||
| 4a6b549eaa | |||
| 5cefe5c3b2 | |||
| 0cf0171721 | |||
| f8a1587109 | |||
| 44142da370 | |||
| ecbae22fcc | |||
| b3a79deef8 | |||
| c4f278d58a | |||
| b0ea8ed388 | |||
| 220516c930 | |||
| 3be28877ab | |||
| b3a96f15ab | |||
| 14a68befd2 | |||
| b1af12a78d | |||
| 83bab147d0 | |||
| 80670a0d64 | |||
| 75f137470b | |||
| 870a3ee799 | |||
| c3c1689170 | |||
| a271b847d5 | |||
| 45ea1a8c1d | |||
| 1b90f16eb5 | |||
| 422429e742 | |||
| 29072e3d5c | |||
| b82c2c68d5 | |||
| 67d6eaa18b | |||
| cb91ba1620 | |||
| 0e91256847 | |||
| ce16625091 | |||
| 4d538fc35d | |||
| 36c9583a2c | |||
| 1bde1f66d3 | |||
| fddc08c24b | |||
| 06305ee262 | |||
| e55e27cee8 | |||
| 8fa77cb9ba | |||
| f038327928 | |||
| 0adaf8a84b | |||
| 85cb88b0fc | |||
| 4c8ac0457f | |||
| 3ba6072b3e | |||
| ad966cfc28 | |||
| 1f9b2b8230 | |||
| 61826dc813 | |||
| 3dc4a6d6a3 | |||
| 4de89aa858 | |||
| 8b9f07e46e | |||
| af7101844a | |||
| b58bf412fa | |||
| a1c524df00 | |||
| be25001479 | |||
| 7466aba10f | |||
| c4fc8c85e2 | |||
| 007efef742 | |||
| a4bf9d76f6 | |||
| 7c5faa7c8a | |||
| 3497eeea9f | |||
| 7717cb35f8 | |||
| 1c59409ce2 | |||
| 5545568e04 | |||
| 6ba9b33606 | |||
| 8d657a0101 | |||
| c1454eff13 | |||
| f7867e4bc3 | |||
| f94e057492 | |||
| a5371faa27 | |||
| 34527f0b3e |
3
.gitignore
vendored
3
.gitignore
vendored
@ -5,8 +5,9 @@
|
||||
/build/deploy
|
||||
/build/*.log
|
||||
/web/documentserver-example/nodejs/node_modules
|
||||
/web/documentserver-example/nodejs/public/files
|
||||
/web/documentserver-example/nodejs/files
|
||||
/web/documentserver-example/nodejs/config/local.json
|
||||
/web/documentserver-example/nodejs/example
|
||||
**/.vscode/
|
||||
**/.idea
|
||||
/web/documentserver-example/java/target/
|
||||
@ -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
|
||||
|
||||
30
Readme.md
30
Readme.md
@ -1,5 +1,5 @@
|
||||
|
||||
[](https://opensource.org/licenses/MIT) 
|
||||
[](https://opensource.org/licenses/MIT) 
|
||||
|
||||
## Document Server integration example
|
||||
|
||||
@ -15,6 +15,34 @@ You should change `http://documentserver` to your server address in these files:
|
||||
|
||||
More information on how to use these examples can be found here: [http://api.onlyoffice.com/editors/demopreview](http://api.onlyoffice.com/editors/demopreview "http://api.onlyoffice.com/editors/demopreview")
|
||||
|
||||
## API methods for test examples
|
||||
|
||||
The methods described below are available for all of the test examples.
|
||||
|
||||
### POST `/upload`
|
||||
|
||||
| | |
|
||||
| ---------------------- | ------------------------------------------------------------ |
|
||||
| **Summary** | Upload file to test example via request |
|
||||
| **URL** | /upload |
|
||||
| **Method** | POST |
|
||||
| **Request<br>Headers** | `Content-Type: multipart/form-data` |
|
||||
| **Request<br>Body** | `uploadedFile=@<filepath>`<br> `filepath` - file for uploading<br />Multipart body with the file binary contents |
|
||||
| **Response** | **Code:** 200 OK <br />**Content on success:**<br /> `{ "filename": <filename>}`<br />**Content on error:**<br /> `{ "error": "Uploaded file not found"}` <br /> Or <br /> `{ "error": "File size is incorrect"}` |
|
||||
| **Sample** | `curl -X POST -F uploadedFile=@filename.docx http://localhost/upload` |
|
||||
|
||||
|
||||
### DELETE `/file`
|
||||
|
||||
| | |
|
||||
| ------------------ | ------------------------------------------------------------ |
|
||||
| **Summary** | Delete one file or all files
|
||||
| **URL** | /file |
|
||||
| **Method** | DELETE |
|
||||
| ****URL Params**** | **Optional:**<br /> `filename=[string]` - file for deleting. <br /> *WARNING! Without this parameter, all files will be deleted* |
|
||||
| **Response** | **Code:** 200 OK <br /> **Success:**<br /> `{"success":true}` |
|
||||
| **Sample** | **Delete one file:**<br />`curl -X DELETE http://localhost/file?filename=filename.docx`<br />**Delete all files:**<br />`curl -X DELETE http://localhost/file`<br /> |
|
||||
|
||||
## Project Information
|
||||
|
||||
Official website: [https://www.onlyoffice.com](https://www.onlyoffice.com/?utm_source=github&utm_medium=cpc&utm_campaign=GitHubIntegrationEx)
|
||||
|
||||
@ -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)
|
||||
*
|
||||
@ -64,12 +64,17 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
|
||||
public string GetDocConfig(HttpRequest request, UrlHelper url)
|
||||
{
|
||||
var jss = new JavaScriptSerializer();
|
||||
|
||||
var ext = Path.GetExtension(FileName);
|
||||
var editorsMode = Mode ?? "edit";
|
||||
|
||||
var canEdit = DocManagerHelper.EditedExts.Contains(ext);
|
||||
var mode = canEdit && editorsMode != "view" ? "edit" : "view";
|
||||
|
||||
var actionLink = request.GetOrDefault("actionLink", null);
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink);
|
||||
|
||||
var config = new Dictionary<string, object>
|
||||
{
|
||||
{ "type", Type ?? "desktop" },
|
||||
@ -105,14 +110,15 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
"editorConfig", new Dictionary<string, object>
|
||||
{
|
||||
{ "actionLink", actionData },
|
||||
{ "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") }
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -147,7 +153,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
config.Add("token", token);
|
||||
}
|
||||
|
||||
return new JavaScriptSerializer().Serialize(config);
|
||||
return jss.Serialize(config);
|
||||
}
|
||||
|
||||
public void GetHistory(out string history, out string historyData)
|
||||
|
||||
@ -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)
|
||||
*
|
||||
@ -83,6 +83,28 @@
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var replaceActionLink = function(href, linkParam) {
|
||||
var link;
|
||||
var actionIndex = href.indexOf("&actionLink=");
|
||||
if (actionIndex != -1) {
|
||||
var endIndex = href.indexOf("&", actionIndex + "&actionLink=".length);
|
||||
if (endIndex != -1) {
|
||||
link = href.substring(0, actionIndex) + href.substring(endIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
} else {
|
||||
link = href.substring(0, actionIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
} else {
|
||||
link = href + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
var onMakeActionLink = function (event) {
|
||||
var actionData = event.data;
|
||||
var linkParam = JSON.stringify(actionData);
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var config = <%= Model.GetDocConfig(Request, Url) %>;
|
||||
|
||||
config.width = "100%";
|
||||
@ -94,6 +116,7 @@
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
'onError': onError,
|
||||
'onOutdatedVersion': onOutdatedVersion,
|
||||
"onMakeActionLink": onMakeActionLink,
|
||||
};
|
||||
|
||||
<% string hist, histData; %>
|
||||
|
||||
@ -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") }
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@
|
||||
};
|
||||
|
||||
var onRequestEditRights = function () {
|
||||
location.href = location.href.replace(RegExp("action=view\&?", "i"), "");
|
||||
location.href = location.href.replace(RegExp("editorsMode=view\&?", "i"), "");
|
||||
};
|
||||
|
||||
var onError = function (event) {
|
||||
@ -76,6 +76,28 @@
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var replaceActionLink = function(href, linkParam) {
|
||||
var link;
|
||||
var actionIndex = href.indexOf("&actionLink=");
|
||||
if (actionIndex != -1) {
|
||||
var endIndex = href.indexOf("&", actionIndex + "&actionLink=".length);
|
||||
if (endIndex != -1) {
|
||||
link = href.substring(0, actionIndex) + href.substring(endIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
} else {
|
||||
link = href.substring(0, actionIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
} else {
|
||||
link = href + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
var onMakeActionLink = function (event) {
|
||||
var actionData = event.data;
|
||||
var linkParam = JSON.stringify(actionData);
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var config = <%= DocConfig %>;
|
||||
|
||||
config.width = "100%";
|
||||
@ -87,6 +109,7 @@
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
'onError': onError,
|
||||
'onOutdatedVersion': onOutdatedVersion,
|
||||
'onMakeActionLink': onMakeActionLink,
|
||||
};
|
||||
|
||||
<% if (!string.IsNullOrEmpty(History) && !string.IsNullOrEmpty(HistoryData))
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -101,14 +101,19 @@ 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 jss = new JavaScriptSerializer();
|
||||
|
||||
var actionLink = Request.GetOrDefault("actionLink", null);
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink);
|
||||
|
||||
var config = new Dictionary<string, object>
|
||||
{
|
||||
{ "type", Request["editorsType"] ?? "desktop" },
|
||||
{ "type", Request.GetOrDefault("editorsType", "desktop") },
|
||||
{ "documentType", _Default.DocumentType(FileName) },
|
||||
{
|
||||
"document", new Dictionary<string, object>
|
||||
@ -141,14 +146,15 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
"editorConfig", new Dictionary<string, object>
|
||||
{
|
||||
{ "actionLink", actionData },
|
||||
{ "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") }
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -183,13 +189,13 @@ namespace OnlineEditorsExample
|
||||
config.Add("token", token);
|
||||
}
|
||||
|
||||
var jss = new JavaScriptSerializer();
|
||||
|
||||
DocConfig = jss.Serialize(config);
|
||||
|
||||
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 +311,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)
|
||||
*
|
||||
@ -69,7 +69,7 @@ public class EditorServlet extends HttpServlet
|
||||
}
|
||||
}
|
||||
|
||||
FileModel file = new FileModel(fileName, cm.getCookie("ulang"), cm.getCookie("uid"), cm.getCookie("uname"));
|
||||
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"));
|
||||
|
||||
if (DocumentManager.TokenEnabled())
|
||||
|
||||
@ -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)
|
||||
*
|
||||
@ -38,6 +38,7 @@ import helpers.DocumentManager;
|
||||
import helpers.ServiceConverter;
|
||||
import helpers.FileUtility;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
@ -52,7 +53,7 @@ public class FileModel
|
||||
public EditorConfig editorConfig;
|
||||
public String token;
|
||||
|
||||
public FileModel(String fileName, String lang, String uid, String uname)
|
||||
public FileModel(String fileName, String lang, String uid, String uname, String actionData)
|
||||
{
|
||||
if (fileName == null) fileName = "";
|
||||
fileName = fileName.trim();
|
||||
@ -65,7 +66,7 @@ public class FileModel
|
||||
document.fileType = FileUtility.GetFileExtension(fileName).replace(".", "");
|
||||
document.key = ServiceConverter.GenerateRevisionId(DocumentManager.CurUserHostAddress(null) + "/" + fileName + "/" + Long.toString(new File(DocumentManager.StoragePath(fileName, null)).lastModified()));
|
||||
|
||||
editorConfig = new EditorConfig();
|
||||
editorConfig = new EditorConfig(actionData);
|
||||
editorConfig.callbackUrl = DocumentManager.GetCallback(fileName);
|
||||
if (lang != null) editorConfig.lang = lang;
|
||||
|
||||
@ -227,6 +228,7 @@ public class FileModel
|
||||
|
||||
public class EditorConfig
|
||||
{
|
||||
public HashMap<String, Object> actionLink = null;
|
||||
public String mode = "edit";
|
||||
public String callbackUrl;
|
||||
public String lang = "en";
|
||||
@ -234,8 +236,12 @@ public class FileModel
|
||||
public Customization customization;
|
||||
public Embedded embedded;
|
||||
|
||||
public EditorConfig()
|
||||
public EditorConfig(String actionData)
|
||||
{
|
||||
if (actionData != null) {
|
||||
Gson gson = new Gson();
|
||||
actionLink = gson.fromJson(actionData, new TypeToken<HashMap<String, Object>>() { }.getType());
|
||||
}
|
||||
user = new User();
|
||||
customization = new Customization();
|
||||
}
|
||||
|
||||
@ -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)
|
||||
*
|
||||
@ -73,6 +73,28 @@
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var replaceActionLink = function(href, linkParam) {
|
||||
var link;
|
||||
var actionIndex = href.indexOf("&actionLink=");
|
||||
if (actionIndex != -1) {
|
||||
var endIndex = href.indexOf("&", actionIndex + "&actionLink=".length);
|
||||
if (endIndex != -1) {
|
||||
link = href.substring(0, actionIndex) + href.substring(endIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
} else {
|
||||
link = href.substring(0, actionIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
} else {
|
||||
link = href + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
var onMakeActionLink = function (event) {
|
||||
var actionData = event.data;
|
||||
var linkParam = JSON.stringify(actionData);
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var config = JSON.parse('<%= FileModel.Serialize(Model) %>');
|
||||
config.width = "100%";
|
||||
config.height = "100%";
|
||||
@ -82,6 +104,7 @@
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
"onError": onError,
|
||||
"onOutdatedVersion": onOutdatedVersion,
|
||||
"onMakeActionLink": onMakeActionLink,
|
||||
};
|
||||
|
||||
<%
|
||||
|
||||
@ -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)
|
||||
*
|
||||
@ -35,6 +35,7 @@ const syncRequest = require("sync-request");
|
||||
const jwt = require('jsonwebtoken');
|
||||
const config = require('config');
|
||||
const configServer = config.get('server');
|
||||
const storageFolder = configServer.get("storageFolder");
|
||||
const mime = require("mime");
|
||||
const docManager = require("./helpers/docManager");
|
||||
const documentService = require("./helpers/documentService");
|
||||
@ -99,7 +100,7 @@ app.use(bodyParser.urlencoded({ extended: false }));
|
||||
app.get("/", function (req, res) {
|
||||
try {
|
||||
|
||||
docManager.init(__dirname, req, res);
|
||||
docManager.init(storageFolder, req, res);
|
||||
|
||||
res.render("index", {
|
||||
preloaderUrl: siteUrl + configServer.get('preloaderUrl'),
|
||||
@ -119,7 +120,7 @@ app.get("/", function (req, res) {
|
||||
});
|
||||
|
||||
app.get("/download", function(req, res) {
|
||||
docManager.init(__dirname, req, res);
|
||||
docManager.init(storageFolder, req, res);
|
||||
|
||||
var fileName = fileUtility.getFileName(req.query.fileName);
|
||||
var userAddress = docManager.curUserHostAddress();
|
||||
@ -140,11 +141,11 @@ app.get("/download", function(req, res) {
|
||||
|
||||
app.post("/upload", function (req, res) {
|
||||
|
||||
docManager.init(__dirname, req, res);
|
||||
docManager.init(storageFolder, req, res);
|
||||
docManager.storagePath(""); //mkdir if not exist
|
||||
|
||||
const userIp = docManager.curUserHostAddress();
|
||||
const uploadDir = path.join("./public", configServer.get('storageFolder'), userIp);
|
||||
const uploadDir = path.join(storageFolder, userIp);
|
||||
const uploadDirTmp = path.join(uploadDir, 'tmp');
|
||||
docManager.createDirectory(uploadDirTmp);
|
||||
|
||||
@ -201,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);
|
||||
}
|
||||
@ -297,7 +298,7 @@ app.get("/convert", function (req, res) {
|
||||
|
||||
app.delete("/file", function (req, res) {
|
||||
try {
|
||||
docManager.init(__dirname, req, res);
|
||||
docManager.init(storageFolder, req, res);
|
||||
let fileName = req.query.filename;
|
||||
if (fileName) {
|
||||
fileName = fileUtility.getFileName(fileName);
|
||||
@ -322,7 +323,7 @@ app.delete("/file", function (req, res) {
|
||||
|
||||
app.post("/track", function (req, res) {
|
||||
|
||||
docManager.init(__dirname, req, res);
|
||||
docManager.init(storageFolder, req, res);
|
||||
|
||||
var userAddress = req.query.useraddress;
|
||||
var fileName = fileUtility.getFileName(req.query.filename);
|
||||
@ -513,14 +514,15 @@ app.post("/track", function (req, res) {
|
||||
app.get("/editor", function (req, res) {
|
||||
try {
|
||||
|
||||
docManager.init(__dirname, req, res);
|
||||
docManager.init(storageFolder, req, res);
|
||||
|
||||
var fileExt = req.query.fileExt;
|
||||
var history = [];
|
||||
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";
|
||||
var actionData = req.query.action ? req.query.action : "null";
|
||||
|
||||
if (fileExt != null) {
|
||||
var fileName = docManager.createDemo((req.query.sample ? "sample." : "new.") + fileExt, userid, name);
|
||||
@ -630,7 +632,8 @@ app.get("/editor", function (req, res) {
|
||||
userid: userid,
|
||||
name: name,
|
||||
fileChoiceUrl: fileChoiceUrl,
|
||||
plugins: JSON.stringify(plugins)
|
||||
plugins: JSON.stringify(plugins),
|
||||
actionData: actionData
|
||||
},
|
||||
history: history,
|
||||
historyData: historyData
|
||||
|
||||
@ -22,13 +22,14 @@
|
||||
"viewedDocs": [".pdf", ".djvu", ".xps"],
|
||||
"editedDocs": [".docx", ".xlsx", ".csv", ".pptx", ".txt"],
|
||||
"convertedDocs": [".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"],
|
||||
"storageFolder": "files",
|
||||
"storageFolder": "./files",
|
||||
"storagePath": "/files",
|
||||
"maxFileSize": 1073741824,
|
||||
"mobileRegEx": "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",
|
||||
"static":[
|
||||
{
|
||||
"name": "/public",
|
||||
"path": "public"
|
||||
"name": "/files",
|
||||
"path": "./files"
|
||||
}
|
||||
],
|
||||
"token": {
|
||||
|
||||
@ -1,6 +1,13 @@
|
||||
{
|
||||
"server": {
|
||||
"siteUrl": "/",
|
||||
"maxFileSize": 104857600
|
||||
"maxFileSize": 104857600,
|
||||
"storageFolder": "/var/lib/onlyoffice/documentserver-example/files",
|
||||
"static":[
|
||||
{
|
||||
"name": "/files",
|
||||
"path": "/var/lib/onlyoffice/documentserver-example/files"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
"maxFileSize": 104857600,
|
||||
"static":[
|
||||
{
|
||||
"name": "/public",
|
||||
"path": "public",
|
||||
"name": "/files",
|
||||
"path": "./files",
|
||||
"options": {"maxAge": "7d"}
|
||||
}
|
||||
]
|
||||
|
||||
@ -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)
|
||||
*
|
||||
@ -32,7 +32,6 @@ const documentService = require("./documentService");
|
||||
const cacheManager = require("./cacheManager");
|
||||
const guidManager = require("./guidManager");
|
||||
const configServer = require('config').get('server');
|
||||
const storageFolder = configServer.get('storageFolder');
|
||||
const os = require("os");
|
||||
|
||||
let docManager = {};
|
||||
@ -60,8 +59,6 @@ docManager.init = function (dir, req, res) {
|
||||
docManager.dir = dir;
|
||||
docManager.req = req;
|
||||
docManager.res = res;
|
||||
|
||||
this.createDirectory(path.join(docManager.dir, "public", storageFolder));
|
||||
};
|
||||
|
||||
docManager.getLang = function () {
|
||||
@ -113,7 +110,7 @@ docManager.getCorrectName = function (fileName, userAddress) {
|
||||
docManager.createDemo = function (demoName, userid, username) {
|
||||
const fileName = docManager.getCorrectName(demoName);
|
||||
|
||||
docManager.copyFile(path.join(docManager.dir, "public", "samples", demoName), docManager.storagePath(fileName));
|
||||
docManager.copyFile(path.join(__dirname, "..","public", "samples", demoName), docManager.storagePath(fileName));
|
||||
|
||||
docManager.saveFileData(fileName, userid, username);
|
||||
|
||||
@ -149,9 +146,8 @@ docManager.getFileUri = function (fileName) {
|
||||
|
||||
docManager.getlocalFileUri = function (fileName, version, forDocumentServer) {
|
||||
const serverPath = docManager.getServerUrl(forDocumentServer);
|
||||
const storagePath = storageFolder.length ? storageFolder + "/" : "";
|
||||
const hostAddress = docManager.curUserHostAddress();
|
||||
const url = serverPath + "/" + storagePath + hostAddress + "/" + encodeURIComponent(fileName);
|
||||
const url = serverPath + configServer.get("storagePath") + "/" + hostAddress + "/" + encodeURIComponent(fileName);
|
||||
if (!version) {
|
||||
return url;
|
||||
}
|
||||
@ -172,13 +168,13 @@ docManager.getCallback = function (fileName) {
|
||||
|
||||
docManager.storagePath = function (fileName, userAddress) {
|
||||
fileName = fileUtility.getFileName(fileName);
|
||||
const directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
|
||||
const directory = path.join(docManager.dir, docManager.curUserHostAddress(userAddress));
|
||||
this.createDirectory(directory);
|
||||
return path.join(directory, fileName);
|
||||
};
|
||||
|
||||
docManager.forcesavePath = function (fileName, userAddress, create) {
|
||||
let directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
|
||||
let directory = path.join(docManager.dir, docManager.curUserHostAddress(userAddress));
|
||||
if (!this.existsSync(directory)) {
|
||||
return "";
|
||||
}
|
||||
@ -195,7 +191,7 @@ docManager.forcesavePath = function (fileName, userAddress, create) {
|
||||
};
|
||||
|
||||
docManager.historyPath = function (fileName, userAddress, create) {
|
||||
let directory = path.join(docManager.dir, "public", storageFolder, docManager.curUserHostAddress(userAddress));
|
||||
let directory = path.join(docManager.dir, docManager.curUserHostAddress(userAddress));
|
||||
if (!this.existsSync(directory)) {
|
||||
return "";
|
||||
}
|
||||
@ -233,7 +229,7 @@ docManager.changesUser = function (fileName, userAddress, version) {
|
||||
|
||||
docManager.getStoredFiles = function () {
|
||||
const userAddress = docManager.curUserHostAddress();
|
||||
const directory = path.join(docManager.dir, "public", storageFolder, userAddress);
|
||||
const directory = path.join(docManager.dir, userAddress);
|
||||
this.createDirectory(directory);
|
||||
const result = [];
|
||||
const storedFiles = fileSystem.readdirSync(directory);
|
||||
|
||||
@ -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)
|
||||
*
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
"scripts": {
|
||||
"start": "node ./bin/www"
|
||||
},
|
||||
"bin": "bin/www",
|
||||
"description": "OnlineEditorsExampleNodeJS",
|
||||
"author": {
|
||||
"name": "ONLYOFFICE",
|
||||
@ -32,5 +33,11 @@
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ONLYOFFICE/document-server-integration.git"
|
||||
},
|
||||
"pkg": {
|
||||
"assets": [
|
||||
"public/**/*",
|
||||
"views/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -23,6 +23,7 @@
|
||||
}
|
||||
},
|
||||
"editorConfig": {
|
||||
"actionLink": <%- editor.actionData %>,
|
||||
"mode": "<%- editor.mode %>",
|
||||
"lang": "<%- editor.lang %>",
|
||||
"callbackUrl": "<%- editor.callbackUrl %>",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<!--*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2019
|
||||
* (c) Copyright Ascensio System SIA 2020
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
@ -96,6 +96,28 @@
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var replaceActionLink = function(href, linkParam) {
|
||||
var link;
|
||||
var actionIndex = href.indexOf("&action=");
|
||||
if (actionIndex != -1) {
|
||||
var endIndex = href.indexOf("&", actionIndex + "&action=".length);
|
||||
if (endIndex != -1) {
|
||||
link = href.substring(0, actionIndex) + href.substring(endIndex) + "&action=" + encodeURIComponent(linkParam);
|
||||
} else {
|
||||
link = href.substring(0, actionIndex) + "&action=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
} else {
|
||||
link = href + "&action=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
var onMakeActionLink = function (event) {
|
||||
var actionData = event.data;
|
||||
var linkParam = JSON.stringify(actionData);
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var connectEditor = function () {
|
||||
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor", {<% include config %>,
|
||||
@ -108,6 +130,7 @@
|
||||
"onRequestHistoryData": onRequestHistoryData,
|
||||
"onRequestHistoryClose": onRequestHistoryClose,
|
||||
"onOutdatedVersion": onOutdatedVersion,
|
||||
"onMakeActionLink": onMakeActionLink,
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -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";
|
||||
@ -100,6 +100,7 @@
|
||||
]
|
||||
],
|
||||
"editorConfig" => [
|
||||
"actionLink" => empty($_GET["actionLink"]) ? null : json_decode($_GET["actionLink"]),
|
||||
"mode" => $mode,
|
||||
"lang" => empty($_COOKIE["ulang"]) ? "en" : $_COOKIE["ulang"],
|
||||
"callbackUrl" => getCallbackUrl($filename),
|
||||
@ -295,6 +296,28 @@
|
||||
location.reload(true);
|
||||
};
|
||||
|
||||
var replaceActionLink = function(href, linkParam) {
|
||||
var link;
|
||||
var actionIndex = href.indexOf("&actionLink=");
|
||||
if (actionIndex != -1) {
|
||||
var endIndex = href.indexOf("&", actionIndex + "&actionLink=".length);
|
||||
if (endIndex != -1) {
|
||||
link = href.substring(0, actionIndex) + href.substring(endIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
} else {
|
||||
link = href.substring(0, actionIndex) + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
} else {
|
||||
link = href + "&actionLink=" + encodeURIComponent(linkParam);
|
||||
}
|
||||
return link;
|
||||
}
|
||||
|
||||
var onMakeActionLink = function (event) {
|
||||
var actionData = event.data;
|
||||
var linkParam = JSON.stringify(actionData);
|
||||
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
|
||||
};
|
||||
|
||||
var сonnectEditor = function () {
|
||||
|
||||
<?php
|
||||
@ -314,6 +337,7 @@
|
||||
'onRequestEditRights': onRequestEditRights,
|
||||
'onError': onError,
|
||||
'onOutdatedVersion': onOutdatedVersion,
|
||||
'onMakeActionLink': onMakeActionLink,
|
||||
};
|
||||
|
||||
<?php
|
||||
|
||||
@ -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.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user