mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Compare commits
238 Commits
v7.2.0.107
...
v99.99.99.
| Author | SHA1 | Date | |
|---|---|---|---|
| be85920ce4 | |||
| 7d7c10b3bc | |||
| 1cbc6eca2e | |||
| 63f032d924 | |||
| e0d7e416d3 | |||
| 806aba967c | |||
| 96d3bf2e63 | |||
| daf4f62acd | |||
| ade8a07e95 | |||
| 8b613627d1 | |||
| 3d3a10005c | |||
| 801c451899 | |||
| df034c2af2 | |||
| 9726c06c84 | |||
| 3a45e1b0f3 | |||
| ed8d0194b7 | |||
| a59da2d5df | |||
| f5c9a9e924 | |||
| 7b12b970c0 | |||
| 87a11c8633 | |||
| 01e0cefae5 | |||
| 98d42249fa | |||
| fd9454dd5f | |||
| fbf4153dea | |||
| 83b0411a4d | |||
| c60e4e25e2 | |||
| 4ebbecf580 | |||
| 6dbf383e2d | |||
| 1012bf13a6 | |||
| a24e081564 | |||
| 187ee212a9 | |||
| 106d9bfed3 | |||
| 13e243f900 | |||
| 4ccc3fa35e | |||
| be1fa2da14 | |||
| b6645427a8 | |||
| 39d7c366e3 | |||
| 075f464701 | |||
| 9414dff70c | |||
| 05b8989a87 | |||
| 43b6f53652 | |||
| c22c0d72aa | |||
| d61c112aa2 | |||
| ae3def67f5 | |||
| 7c22ba4e9e | |||
| 320881f1cf | |||
| 90c31eb887 | |||
| 702d0f1aa8 | |||
| dbf1047f29 | |||
| 0d27d142d4 | |||
| 807cbbf236 | |||
| e6b0bfd0be | |||
| 943d059c7c | |||
| 399ab0714d | |||
| 8cabbe9c71 | |||
| e40b6b2e28 | |||
| 0a390094e5 | |||
| f7bb668f8b | |||
| 808712ad34 | |||
| 2b0ba914dc | |||
| 249adaab48 | |||
| ee99a80ead | |||
| e9721dd655 | |||
| 5319e18fb5 | |||
| 6054bffb3f | |||
| 30481005a1 | |||
| 5544768500 | |||
| 14e53970c8 | |||
| 2b184972dc | |||
| 0fb9da4d89 | |||
| 1593df6aec | |||
| 16584c0abb | |||
| 1ddda89001 | |||
| 5b76d798fb | |||
| 59e17079ff | |||
| 4a656c025f | |||
| ce9930e5bc | |||
| 9da22d7803 | |||
| d78c677c99 | |||
| b204142c13 | |||
| fd1c26ab9f | |||
| 5993d10bee | |||
| c5771c9008 | |||
| 2fad227272 | |||
| ada438ff0b | |||
| 0dbd65a577 | |||
| 48e5b8d4e0 | |||
| 7f08a96681 | |||
| 3549b4bc2a | |||
| c9265d9ddc | |||
| 44d9ca88c6 | |||
| d964b43087 | |||
| 5a0debd9e8 | |||
| 3b0f942eee | |||
| 4ee110c2d5 | |||
| ad1d93dd20 | |||
| d2d98df5ab | |||
| 7805f7dc91 | |||
| 51ec27d67c | |||
| 9e94716df0 | |||
| 988a8339b1 | |||
| a482635e3f | |||
| d2c679f6b1 | |||
| 1da452d857 | |||
| d9b8d2b7e9 | |||
| 24aee6d194 | |||
| bd108a9c77 | |||
| e737e8ed48 | |||
| b425d15f0a | |||
| 0f8dec1e6e | |||
| 193b31fe75 | |||
| 583403cf78 | |||
| 641e45e24f | |||
| 53c30fbb7d | |||
| 87a1755729 | |||
| 752a2a2364 | |||
| d1affa2911 | |||
| 0ef2a4f3fd | |||
| 675d3f318a | |||
| 05512ffa23 | |||
| 2eeed5d26d | |||
| 9e3dbd5eb5 | |||
| efbab7c113 | |||
| b8f0f6447c | |||
| 8779a90433 | |||
| b3162ee410 | |||
| 42edd5e208 | |||
| e041baeef7 | |||
| 5bf682a007 | |||
| 6dacf49faa | |||
| 63c9c4242e | |||
| b5e345ed50 | |||
| 33f8436d42 | |||
| c5217242ab | |||
| c910d5193b | |||
| 58c27f8f2f | |||
| 1ec831789b | |||
| 0510fd1354 | |||
| 25238b5614 | |||
| 901bb61883 | |||
| 7f3e6c6364 | |||
| b3512ea0ce | |||
| 642a1bd19a | |||
| ac471588de | |||
| 17674ef5bc | |||
| dc2ee2a997 | |||
| c358fa814a | |||
| 143a73e083 | |||
| c266592434 | |||
| 19ed666d56 | |||
| 84b9202af0 | |||
| 8fb698bb75 | |||
| 00f46ef080 | |||
| 5c194da95d | |||
| 0d5cebe28e | |||
| dacf72cae2 | |||
| 208b8926be | |||
| 55c4853f04 | |||
| ccae7c6a06 | |||
| dc84dd3b29 | |||
| 65d3671b09 | |||
| 1fb5ef8bfd | |||
| b630c3802b | |||
| ad3993b532 | |||
| 35ee61e011 | |||
| ee59ab3dfd | |||
| 500f076e38 | |||
| e578f29d9d | |||
| 9de9bc90a4 | |||
| 7a9ebdbbe5 | |||
| 887089bcad | |||
| 680e53823a | |||
| 33e1489cd6 | |||
| 8c90737bf6 | |||
| e5f1bc8ed6 | |||
| 985b179475 | |||
| 775d15132f | |||
| 4a4298ca10 | |||
| cdbd264ed5 | |||
| e61f6cae89 | |||
| 22039078ef | |||
| 62793a42ab | |||
| f49f96a2c2 | |||
| 2031d65adb | |||
| 7f54659d3b | |||
| a3bc13bb6e | |||
| 29ea16c124 | |||
| 6d4c8b926e | |||
| 22d2031426 | |||
| fcc51e8154 | |||
| 8cd85ad63c | |||
| 1d51688884 | |||
| 2c63a85b00 | |||
| d1545c4db4 | |||
| bd8e4d6ec7 | |||
| e1c815b574 | |||
| 4042d2bb8a | |||
| 8c9d2d80bd | |||
| 3a9259d713 | |||
| 39129a537e | |||
| dfaf552bf8 | |||
| cc8b6f3716 | |||
| 13726b3c2f | |||
| 8bcc15e320 | |||
| 8fca045dd7 | |||
| a018cc5787 | |||
| 054236ef8a | |||
| e662c765e6 | |||
| 058bb0d2e2 | |||
| ac78d1fc08 | |||
| 070dac6878 | |||
| cfa0fb1b74 | |||
| 1d624e6831 | |||
| fe83e98b37 | |||
| f9ea7f7b50 | |||
| 328ea46693 | |||
| 41ec2742a7 | |||
| 76fc55c2d4 | |||
| e10f3962b6 | |||
| b9859ef5ca | |||
| 1cb2b586b1 | |||
| e5d31eebbf | |||
| 1ac40c539f | |||
| 371366befa | |||
| 0bee4817e7 | |||
| ad941e0ba4 | |||
| 93c69e51ed | |||
| 8b8b7d3938 | |||
| f8f01a033e | |||
| f497f10913 | |||
| 8b2478ac71 | |||
| 391c347419 | |||
| 5a08009b7b | |||
| 4e5b65f673 | |||
| 13e3d7673b | |||
| c0a46866ce | |||
| e7b76729a4 | |||
| ce2e7f97d6 |
31
.github/workflows/lint-java.yml
vendored
Normal file
31
.github/workflows/lint-java.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: Lint Java
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
pull_request:
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/java
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Java 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
|
||||
- name: Run linter
|
||||
run: |
|
||||
mvn -version
|
||||
mvn package
|
||||
35
.github/workflows/lint-nodejs.yml
vendored
Normal file
35
.github/workflows/lint-nodejs.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: ESLint
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
pull_request:
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
|
||||
env:
|
||||
NODE_VERSION: 16
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/nodejs
|
||||
steps:
|
||||
- name: Install NodeJS
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Code Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Code Linting
|
||||
run: npm run lint
|
||||
29
.github/workflows/lint-php.yml
vendored
Normal file
29
.github/workflows/lint-php.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
name: PHPCs
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
pull_request:
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/php
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
tools: cs2pr, phpcs
|
||||
|
||||
- name: Run phpcs
|
||||
run: phpcs -q --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml --ignore=node_modules,bower_components,vendor ./
|
||||
40
.github/workflows/lint-python.yml
vendored
Normal file
40
.github/workflows/lint-python.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
name: PyLint
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
pull_request:
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/python
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Install Dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flake8
|
||||
pip install pylint
|
||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
|
||||
- name: Lint Flake8
|
||||
run: |
|
||||
flake8 ./**/*.py --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
flake8 ./**/*.py --count --max-complexity=10 --max-line-length=79 --statistics
|
||||
|
||||
- name: Lint Pylint
|
||||
run: |
|
||||
pylint ./**/*.py
|
||||
31
.github/workflows/lint-ruby.yml
vendored
Normal file
31
.github/workflows/lint-ruby.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: Rubocop
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
pull_request:
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/ruby
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '3.0'
|
||||
bundler-cache: true
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
bundle install
|
||||
- name: Rubocop
|
||||
run: |
|
||||
gem install rubocop
|
||||
rubocop
|
||||
31
.github/workflows/lint-spring.yml
vendored
Normal file
31
.github/workflows/lint-spring.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: Lint Spring
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
pull_request:
|
||||
branches: [master, main, develop]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./web/documentserver-example/java-spring
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Java 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
|
||||
- name: Run linter
|
||||
run: |
|
||||
mvn -version
|
||||
mvn package
|
||||
44
CHANGELOG.md
Normal file
44
CHANGELOG.md
Normal file
@ -0,0 +1,44 @@
|
||||
# Change Log
|
||||
|
||||
- nodejs: wopi editnew action for exisiting file
|
||||
- nodejs: fix wopi actions after restart
|
||||
- setting an unavailable language
|
||||
- description in the tooltip on the main page
|
||||
- option to send directUrl
|
||||
|
||||
## 1.4.0
|
||||
- nodejs: option to send directUrl
|
||||
- opening file on client by directUrl
|
||||
- offline viewer for anonymous
|
||||
- added hy, eu, zh-TW, ms, pt-PT
|
||||
|
||||
## 1.3.1
|
||||
- charp: fix references
|
||||
- ruby: update rails
|
||||
|
||||
## 1.3.0
|
||||
- update empty files
|
||||
- anonymous without chat
|
||||
- changed jwt implementation in csharp, csharp-mvc, php, ruby
|
||||
|
||||
## 1.2.0
|
||||
- ruby v3.0
|
||||
- set filetype in setHistoryData
|
||||
- read filetype from input request
|
||||
- creating file on WOPI
|
||||
- upload on WOPI page
|
||||
- fix xss
|
||||
- set userInfoGroups
|
||||
- check JWT on downloading history
|
||||
- upload dialog on mobile
|
||||
- anonymous without id
|
||||
- renaming from editor
|
||||
- new skin languages
|
||||
- ignore certificate
|
||||
|
||||
## 1.1.0
|
||||
- creating docxf
|
||||
- opening docxf, oform
|
||||
|
||||
## 1.0.0
|
||||
- added java spring
|
||||
@ -24,11 +24,15 @@ jQuery.UI - jQuery UI is an open source library of interface components —
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Microsoft.Web.Infrastructure - This package contains the Microsoft.Web.Infrastructure assembly that lets you dynamically register HTTP modules at run time. (https://www.microsoft.com/web/webpi/eula/aspnetmvc3update-eula.htm)
|
||||
License: MS-EULA License
|
||||
License File: Microsoft.Web.Infrastructure.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://licenses.nuget.org/MIT)
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ label .checkbox {
|
||||
background-image: url("images/file_docxf.svg");
|
||||
}
|
||||
|
||||
.create-sample {
|
||||
.side-option {
|
||||
color: #666666;
|
||||
line-height: 24px;
|
||||
}
|
||||
@ -740,3 +740,28 @@ html {
|
||||
.user-descr > b {
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
background: #FFFFFF;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0px 7px 25px rgba(85, 85, 85, 0.15);
|
||||
color: #666666;
|
||||
line-height: 160%;
|
||||
max-width: 455px;
|
||||
padding: 14px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.tooltip ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
border-top: 8px solid transparent;
|
||||
border-bottom: 8px solid transparent;
|
||||
border-right: 8px solid #FFFFFF;
|
||||
left: -4px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web.Mvc;
|
||||
using OnlineEditorsExampleMVC.Helpers;
|
||||
@ -31,13 +32,14 @@ namespace OnlineEditorsExampleMVC.Controllers
|
||||
}
|
||||
|
||||
// viewing file in the editor
|
||||
public ActionResult Editor(string fileName, string editorsMode, string editorsType)
|
||||
public ActionResult Editor(string fileName, string editorsMode, string editorsType, string directUrl)
|
||||
{
|
||||
var file = new FileModel
|
||||
{
|
||||
Mode = editorsMode, // editor mode: edit or view
|
||||
Type = editorsType, // editor type: desktop, mobile, embedded
|
||||
FileName = Path.GetFileName(fileName) // file name
|
||||
FileName = Path.GetFileName(fileName), // file name
|
||||
IsEnabledDirectUrl = directUrl != null ? Convert.ToBoolean(directUrl) : false
|
||||
};
|
||||
|
||||
return View("Editor", file);
|
||||
|
||||
@ -242,7 +242,8 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
var uri = new UriBuilder(GetServerUrl(forDocumentServer))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath + "/"
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ CurUserHostAddress() + "/"
|
||||
+ fileName,
|
||||
Query = ""
|
||||
@ -292,7 +293,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=track"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))
|
||||
};
|
||||
return callbackUrl.ToString();
|
||||
}
|
||||
@ -312,9 +313,10 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
|
||||
// create the public history url
|
||||
public static string GetHistoryDownloadUrl(string filename, string version, string file)
|
||||
public static string GetHistoryDownloadUrl(string filename, string version, string file, Boolean isServer = true)
|
||||
{
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(true))
|
||||
var userAddress = "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress));
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(isServer))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
@ -322,7 +324,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=downloadhistory"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(filename)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
|
||||
+ userAddress
|
||||
+ "&ver=" + version
|
||||
+ "&file="+ file
|
||||
};
|
||||
@ -330,9 +332,10 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
public static string GetDownloadUrl(string fileName)
|
||||
public static string GetDownloadUrl(string fileName, Boolean isServer = true)
|
||||
{
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(true))
|
||||
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
|
||||
var downloadUrl = new UriBuilder(GetServerUrl(isServer))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
@ -340,7 +343,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=download"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress)
|
||||
+ userAddress
|
||||
};
|
||||
return downloadUrl.ToString();
|
||||
}
|
||||
@ -439,5 +442,11 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
}
|
||||
return languages;
|
||||
}
|
||||
|
||||
public static string GetDirectUrl()
|
||||
{
|
||||
string isEnabledDirectUrl = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query).Get("directUrl");
|
||||
return isEnabledDirectUrl != null ? isEnabledDirectUrl : "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,7 +130,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
var payloadToken = JwtManager.Encode(payload); // encode the payload object to the payload token
|
||||
var bodyToken = JwtManager.Encode(body); // encode the body object to the body token
|
||||
// create header token
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken);
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using JWT;
|
||||
using JWT.Algorithms;
|
||||
using JWT.Builder;
|
||||
using JWT.Serializers;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
@ -30,31 +30,19 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
private static readonly string Secret;
|
||||
public static readonly bool Enabled;
|
||||
|
||||
private static readonly JavaScriptSerializer Serializer;
|
||||
|
||||
static JwtManager()
|
||||
{
|
||||
Secret = WebConfigurationManager.AppSettings["files.docservice.secret"] ?? ""; // get token secret from the config parameters
|
||||
Enabled = !string.IsNullOrEmpty(Secret); // check if the token is enabled
|
||||
Serializer = new JavaScriptSerializer(); // define java script serializer
|
||||
}
|
||||
|
||||
// encode a payload object into a token using a secret key
|
||||
public static string Encode(IDictionary<string, object> payload)
|
||||
{
|
||||
// define the hashing algorithm and the token type
|
||||
var header = new Dictionary<string, object>
|
||||
{
|
||||
{ "alg", "HS256" },
|
||||
{ "typ", "JWT" }
|
||||
};
|
||||
|
||||
// three parts of token
|
||||
var encHeader = Base64UrlEncode(Serializer.Serialize(header)); // header
|
||||
var encPayload = Base64UrlEncode(Serializer.Serialize(payload)); // payload
|
||||
var hashSum = Base64UrlEncode(CalculateHash(encHeader, encPayload)); // signature
|
||||
|
||||
return string.Format("{0}.{1}.{2}", encHeader, encPayload, hashSum);
|
||||
var encoder = new JwtEncoder(new HMACSHA256Algorithm(),
|
||||
new JsonNetSerializer(),
|
||||
new JwtBase64UrlEncoder());
|
||||
return encoder.Encode(payload, Secret);
|
||||
}
|
||||
|
||||
// decode a token into a payload object using a secret key
|
||||
@ -62,52 +50,11 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
{
|
||||
if (!Enabled || string.IsNullOrEmpty(token)) return "";
|
||||
|
||||
var split = token.Split('.');
|
||||
if (split.Length != 3) return "";
|
||||
|
||||
var hashSum = Base64UrlEncode(CalculateHash(split[0], split[1])); // get signature
|
||||
if (hashSum != split[2]) return ""; // and check if it is equal to the signature from the token
|
||||
return Base64UrlDecode(split[1]); // decode payload
|
||||
}
|
||||
|
||||
// generate a hash code based on a key using the HMAC method
|
||||
private static byte[] CalculateHash(string encHeader, string encPayload)
|
||||
{
|
||||
using (var hasher = new HMACSHA256(Encoding.UTF8.GetBytes(Secret)))
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(string.Format("{0}.{1}", encHeader, encPayload));
|
||||
return hasher.ComputeHash(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
// encode a string into the base64 value
|
||||
private static string Base64UrlEncode(string str)
|
||||
{
|
||||
return Base64UrlEncode(Encoding.UTF8.GetBytes(str));
|
||||
}
|
||||
|
||||
// encode bytes into the base64 value
|
||||
private static string Base64UrlEncode(byte[] bytes)
|
||||
{
|
||||
return Convert.ToBase64String(bytes)
|
||||
.TrimEnd('=').Replace('+', '-').Replace('/', '_');
|
||||
}
|
||||
|
||||
// decode a base64 value into the string
|
||||
private static string Base64UrlDecode(string payload)
|
||||
{
|
||||
var b64 = payload.Replace('_', '/').Replace('-', '+');
|
||||
switch (b64.Length%4)
|
||||
{
|
||||
case 2:
|
||||
b64 += "==";
|
||||
break;
|
||||
case 3:
|
||||
b64 += "=";
|
||||
break;
|
||||
}
|
||||
var bytes = Convert.FromBase64String(b64);
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
return JwtBuilder.Create()
|
||||
.WithAlgorithm(new HMACSHA256Algorithm())
|
||||
.WithSecret(Secret)
|
||||
.MustVerifySignature()
|
||||
.Decode(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -55,7 +55,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// check if the document token is enabled
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
string token = null;
|
||||
|
||||
@ -92,7 +92,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// file saving process
|
||||
public static int processSave(Dictionary<string, object> fileData, string fileName, string userAddress)
|
||||
{
|
||||
if (fileData["url"].Equals(null)) {
|
||||
if (string.IsNullOrEmpty((string)fileData["url"])) {
|
||||
throw new Exception("DownloadUrl is null");
|
||||
}
|
||||
var downloadUri = (string)fileData["url"];
|
||||
@ -169,7 +169,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// file force saving process
|
||||
public static int processForceSave(Dictionary<string, object> fileData, string fileName, string userAddress)
|
||||
{
|
||||
if (fileData["url"].Equals(null)) {
|
||||
if ( string.IsNullOrEmpty((string)fileData["url"])) {
|
||||
throw new Exception("DownloadUrl is null");
|
||||
}
|
||||
var downloadUri = (string)fileData["url"];
|
||||
@ -228,7 +228,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
fileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
|
||||
}
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false);
|
||||
if (forcesavePath.Equals("")) // create forcesave path if it doesn't exist
|
||||
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
|
||||
{
|
||||
forcesavePath = DocManagerHelper.ForcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
@ -279,7 +279,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
|
||||
var payloadToken = JwtManager.Encode(payload); // encode a payload object into a header token
|
||||
var bodyToken = JwtManager.Encode(body); // encode body into a body token
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken); // add a header Authorization with a header token and Authorization prefix in it
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
@ -321,6 +321,7 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path"); // file isn't specified
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Timeout = 5000;
|
||||
using (var stream = req.GetResponse().GetResponseStream()) // get input stream of the file information from the url
|
||||
{
|
||||
if (stream == null) throw new Exception("stream is null");
|
||||
|
||||
@ -67,7 +67,9 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
"Can't mention others in comments",
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor"
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
};
|
||||
|
||||
private static List<User> users = new List<User>() {
|
||||
|
||||
@ -33,6 +33,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
public string Mode { get; set; } // editor mode
|
||||
public string Type { get; set; } // editor type
|
||||
public bool IsEnabledDirectUrl { get; set; } // is enabled direct url
|
||||
|
||||
// get file url for Document Server
|
||||
public string FileUri
|
||||
@ -97,6 +98,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
var actionLink = request.GetOrDefault("actionLink", null); // get the action link (comment or bookmark) if it exists
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink); // get action data for the action link
|
||||
|
||||
var directUrl = DocManagerHelper.GetDownloadUrl(FileName, false);
|
||||
var createUrl = DocManagerHelper.GetCreateUrl(FileUtility.GetFileType(FileName));
|
||||
var templatesImageUrl = DocManagerHelper.GetTemplateImageUrl(FileUtility.GetFileType(FileName)); // image url for templates
|
||||
var templates = new List<Dictionary<string, string>>
|
||||
@ -125,6 +127,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
{ "title", FileName },
|
||||
{ "url", DownloadUrl },
|
||||
{ "directUrl", IsEnabledDirectUrl ? directUrl : "" },
|
||||
{ "fileType", ext.Trim('.') },
|
||||
{ "key", Key },
|
||||
{
|
||||
@ -148,6 +151,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "modifyFilter", editorsMode != "filter" },
|
||||
{ "modifyContentControl", editorsMode != "blockcontent" },
|
||||
{ "review", canEdit && (editorsMode == "edit" || editorsMode == "review") },
|
||||
{ "chat", !user.id.Equals("uid-0") },
|
||||
{ "reviewGroups", user.reviewGroups },
|
||||
{ "commentGroups", user.commentGroups },
|
||||
{ "userInfoGroups", user.userInfoGroups }
|
||||
@ -162,6 +166,11 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "mode", mode },
|
||||
{ "lang", request.Cookies.GetOrDefault("ulang", "en") },
|
||||
{ "callbackUrl", CallbackUrl }, // absolute URL to the document storage service
|
||||
{ "coEditing", editorsMode == "view" && user.id.Equals("uid-0") ?
|
||||
new Dictionary<string, object>{
|
||||
{"mode", "strict"},
|
||||
{"change", false}
|
||||
} : null },
|
||||
{ "createUrl", !user.id.Equals("uid-0") ? createUrl : null },
|
||||
{ "templates", user.templates ? templates : null },
|
||||
{
|
||||
@ -177,9 +186,9 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
// the parameters for the embedded document type
|
||||
"embedded", new Dictionary<string, object>
|
||||
{
|
||||
{ "saveUrl", FileUriUser }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", FileUriUser }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", FileUriUser }, // the absolute URL that will allow other users to share this document
|
||||
{ "saveUrl", directUrl }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", directUrl }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", directUrl }, // the absolute URL that will allow other users to share this document
|
||||
{ "toolbarDocked", "top" } // the place for the embedded viewer toolbar (top or bottom)
|
||||
}
|
||||
},
|
||||
@ -195,7 +204,7 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{
|
||||
"goback", new Dictionary<string, object> // settings for the Open file location menu button and upper right corner button
|
||||
{
|
||||
{ "url", url.Action("Index", "Home") } // the absolute URL to the website address which will be opened when clicking the Open file location menu button
|
||||
{ "url", DocManagerHelper.GetServerUrl(false) } // the absolute URL to the website address which will be opened when clicking the Open file location menu button
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,17 +271,26 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
dataObj.Add("key", key);
|
||||
// write file url to the data object
|
||||
string prevFileUrl;
|
||||
string directPrevFileUrl;
|
||||
if (Path.IsPathRooted(storagePath) && !string.IsNullOrEmpty(storagePath))
|
||||
{
|
||||
prevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
|
||||
directPrevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext, false)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
|
||||
}
|
||||
else {
|
||||
prevFileUrl = i == currentVersion ? FileUri
|
||||
: DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext);
|
||||
prevFileUrl = i == currentVersion ? FileUri
|
||||
: DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext);
|
||||
directPrevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext, false)
|
||||
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
|
||||
}
|
||||
|
||||
dataObj.Add("url", prevFileUrl);
|
||||
if (IsEnabledDirectUrl)
|
||||
{
|
||||
dataObj.Add("directUrl", directPrevFileUrl);
|
||||
}
|
||||
dataObj.Add("version", i);
|
||||
if (i > 1) // check if the version number is greater than 1 (the file was modified)
|
||||
{
|
||||
@ -290,7 +308,12 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
obj.Add("user", change.Count > 0 ? change["user"] : null);
|
||||
|
||||
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()]; // get the history data from the previous file version
|
||||
dataObj.Add("previous", new Dictionary<string, object>() { // write information about previous file version to the data object
|
||||
dataObj.Add("previous", IsEnabledDirectUrl ? new Dictionary<string, object>() { // write information about previous file version to the data object with direct url
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
{ "directUrl", prev["directUrl"] },
|
||||
} : new Dictionary<string, object>() { // write information about previous file version to the data object without direct url
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
@ -332,6 +355,14 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx")
|
||||
};
|
||||
|
||||
var directCompareFileUrl = new UriBuilder(DocManagerHelper.GetServerUrl(false))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx")
|
||||
};
|
||||
|
||||
// create an object with the information about the compared file
|
||||
var dataCompareFile = new Dictionary<string, object>
|
||||
{
|
||||
@ -339,6 +370,11 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "url", compareFileUrl.ToString() }
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl)
|
||||
{
|
||||
dataCompareFile.Add("directUrl", directCompareFileUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var compareFileToken = JwtManager.Encode(dataCompareFile); // encode the dataCompareFile object into the token
|
||||
@ -361,6 +397,13 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
+ "Content\\images\\logo.png"
|
||||
};
|
||||
|
||||
var directMailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(false))
|
||||
{
|
||||
Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "Content\\images\\logo.png"
|
||||
};
|
||||
|
||||
// create a logo config
|
||||
var logoConfig = new Dictionary<string, object>
|
||||
{
|
||||
@ -368,6 +411,11 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "url", mailMergeUrl.ToString()}
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl)
|
||||
{
|
||||
logoConfig.Add("directUrl", directMailMergeUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var token = JwtManager.Encode(logoConfig); // encode logoConfig into the token
|
||||
@ -392,6 +440,15 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
Query = "type=csv"
|
||||
};
|
||||
|
||||
var directMailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(false))
|
||||
{
|
||||
Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx",
|
||||
Query = "type=csv"
|
||||
};
|
||||
|
||||
// create a mail merge config
|
||||
var mailMergeConfig = new Dictionary<string, object>
|
||||
{
|
||||
@ -399,6 +456,11 @@ namespace OnlineEditorsExampleMVC.Models
|
||||
{ "url", mailMergeUrl.ToString()}
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl)
|
||||
{
|
||||
mailMergeConfig.Add("directUrl", directMailMergeUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var mailmergeToken = JwtManager.Encode(mailMergeConfig); // encode mailMergeConfig into the token
|
||||
|
||||
@ -43,6 +43,9 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="JWT, Version=9.0.0.0, Culture=neutral, PublicKeyToken=6f98bca0f40f2ecf, processorArchitecture=MSIL">
|
||||
<HintPath>packages\JWT.9.0.3\lib\net46\JWT.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
@ -50,49 +53,49 @@
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="Antlr3.Runtime">
|
||||
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework">
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure">
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.Formatting">
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Helpers">
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http">
|
||||
<Reference Include="System.Web.Http, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost">
|
||||
<Reference Include="System.Web.Http.WebHost, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebApi.WebHost.5.2.7\lib\net45\System.Web.Http.WebHost.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc">
|
||||
<Reference Include="System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Optimization">
|
||||
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor">
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages">
|
||||
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment">
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor">
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WebGrease">
|
||||
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
@ -182,10 +185,12 @@
|
||||
<Content Include="assets\AUTHORS.md" />
|
||||
<Content Include="assets\LICENSE" />
|
||||
<Content Include="assets\new\new.docx" />
|
||||
<Content Include="assets\new\new.docxf" />
|
||||
<Content Include="assets\new\new.pptx" />
|
||||
<Content Include="assets\new\new.xlsx" />
|
||||
<Content Include="assets\sample\csv.csv" />
|
||||
<Content Include="assets\sample\sample.docx" />
|
||||
<Content Include="assets\sample\sample.docxf" />
|
||||
<Content Include="assets\sample\sample.pptx" />
|
||||
<Content Include="assets\sample\sample.xlsx" />
|
||||
<None Include="packages.config" />
|
||||
|
||||
@ -16,11 +16,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var directUrl;
|
||||
|
||||
if (typeof jQuery != "undefined") {
|
||||
jq = jQuery.noConflict();
|
||||
|
||||
directUrl = getUrlVars()["directUrl"] == "true";
|
||||
|
||||
mustReload = false;
|
||||
|
||||
if (directUrl)
|
||||
jq("#directUrl").prop("checked", directUrl);
|
||||
else
|
||||
directUrl = jq("#directUrl").prop("checked");
|
||||
|
||||
jq("#directUrl").change(function () {
|
||||
window.location = "?directUrl=" + jq(this).prop("checked");
|
||||
});
|
||||
|
||||
jq(function () {
|
||||
jq('#fileupload').fileupload({
|
||||
dataType: 'json',
|
||||
@ -219,7 +232,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?fileName=" + fileId;
|
||||
var url = UrlEditor + "?fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -227,7 +240,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?editorsMode=view&fileName=" + fileId;
|
||||
var url = UrlEditor + "?editorsMode=view&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -235,7 +248,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = UrlEditor + "?editorsType=embedded&editorsMode=embedded&fileName=" + fileId;
|
||||
var url = UrlEditor + "?editorsType=embedded&editorsMode=embedded&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
@ -289,6 +302,17 @@ if (typeof jQuery != "undefined") {
|
||||
}
|
||||
};
|
||||
|
||||
function getUrlVars() {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
};
|
||||
|
||||
var fileList = jq("tr.tableRow");
|
||||
|
||||
var mouseIsOverTooltip = false;
|
||||
@ -299,12 +323,12 @@ if (typeof jQuery != "undefined") {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
}
|
||||
jq(".info").on("touchend", function () {
|
||||
jq("#info").on("touchend", function () {
|
||||
showUserTooltip(true);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
jq(".info").mouseover(function (event) {
|
||||
jq("#info").mouseover(function (event) {
|
||||
if (fileList.length > 0) {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
@ -328,4 +352,18 @@ if (typeof jQuery != "undefined") {
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
jq(".info-tooltip").mouseover(function (event) {
|
||||
var target = event.target;
|
||||
var id = target.dataset.id ? target.dataset.id : target.id;
|
||||
var tooltip = target.dataset.tooltip;
|
||||
|
||||
jq("<div class='tooltip'>" + tooltip + "<div class='arrow'></div></div>").appendTo("body");
|
||||
|
||||
var top = jq("#" + id).offset().top + jq("#" + id).outerHeight() / 2 - jq("div.tooltip").outerHeight() / 2;
|
||||
var left = jq("#" + id).offset().left + jq("#" + id).outerWidth() + 20;
|
||||
jq("div.tooltip").css({ "top": top, "left": left });
|
||||
}).mouseout(function () {
|
||||
jq("div.tooltip").remove();
|
||||
});
|
||||
}
|
||||
@ -166,6 +166,7 @@
|
||||
var data = {
|
||||
newfilename: newfilename,
|
||||
dockey: config.document.key,
|
||||
ext: config.document.fileType
|
||||
};
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
<a class="try-editor form" data-type="docxf">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="create-sample">
|
||||
<label class="side-option">
|
||||
<input id="createSample" class="checkbox" type="checkbox" />With sample content
|
||||
</label>
|
||||
</div>
|
||||
@ -86,7 +86,7 @@
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Username</span>
|
||||
<img class="info" src="content/images/info.svg" />
|
||||
<img id="info" class="info" src="content/images/info.svg" />
|
||||
<select class="select-user" id="user">
|
||||
<% foreach (User user in Users.getAllUsers())
|
||||
{ %>
|
||||
@ -97,7 +97,10 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Language editors interface</span>
|
||||
<span class="select-user">Language</span>
|
||||
<img class="info info-tooltip" data-id="language"
|
||||
data-tooltip="Choose the language for ONLYOFFICE editors interface"
|
||||
src="content/images/info.svg" />
|
||||
<select class="select-user" id="language">
|
||||
<% Dictionary<string, string> languages = DocManagerHelper.GetLanguages();
|
||||
foreach (var lang in languages)
|
||||
@ -107,6 +110,14 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<label class="side-option">
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
|
||||
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="content/images/info.svg" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -156,51 +167,52 @@
|
||||
<tbody>
|
||||
<% foreach (var storedFile in storedFiles)
|
||||
{
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
|
||||
var isEnabledDirectUrl = DocManagerHelper.GetDirectUrl();
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
|
||||
var docType = FileUtility.GetFileType(storedFile.Name).ToString().ToLower();
|
||||
var ext = Path.GetExtension(storedFile.Name).ToLower();
|
||||
var canEdit = DocManagerHelper.EditedExts.Contains(ext);
|
||||
var isFillFormDoc = DocManagerHelper.FillFormExts.Contains(ext);
|
||||
%>
|
||||
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= DocManagerHelper.GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress) %>]">
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= DocManagerHelper.GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress.Replace(':', '_')) %>]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name }) %>" target="_blank">
|
||||
<a class="stored-edit <%= docType %>" href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<span><%= storedFile.Name %></span>
|
||||
</a>
|
||||
</td>
|
||||
<% if (canEdit) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "edit" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "edit", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/desktop.svg" alt="Open in editor for full size screens" title="Open in editor for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "edit" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "edit", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/mobile.svg" alt="Open in editor for mobile devices" title="Open in editor for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "comment" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "comment", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/comment.svg" alt="Open in editor for comment" title="Open in editor for comment"/>
|
||||
</a>
|
||||
</td>
|
||||
<% if (docType == "word") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "review" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "review", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/review.svg" alt="Open in editor for review" title="Open in editor for review"/>
|
||||
</a>
|
||||
</td>
|
||||
<% } else if (docType == "cell") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "filter" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "filter", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" />
|
||||
</a>
|
||||
</td>
|
||||
<% } %>
|
||||
<% if (docType == "word") { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "blockcontent" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "blockcontent", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/block-content.svg" alt="Open in editor without content control modification" title="Open in editor without content control modification"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -212,7 +224,7 @@
|
||||
<% } %>
|
||||
<% if (isFillFormDoc) { %>
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -222,7 +234,7 @@
|
||||
<% } else if (isFillFormDoc) { %>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "fillForms" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "fillForms", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/mobile-fill-forms.svg" alt="Open in editor for filling in forms for mobile devices" title="Open in editor for filling in forms for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -230,7 +242,7 @@
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -238,17 +250,17 @@
|
||||
<td class="contentCells contentCells-shift contentCells-icon contentCellsEmpty" colspan="6"></td>
|
||||
<% } %>
|
||||
<td class="contentCells contentCells-icon firstContentCellViewers">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "view" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "view", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/desktop.svg" alt="Open in viewer for full size screens" title="Open in viewer for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "view" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "view", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/mobile.svg" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon contentCells-shift">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "embedded", editorsMode = "embedded" }) %>" target="_blank">
|
||||
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "embedded", editorsMode = "embedded", directUrl = isEnabledDirectUrl }) %>" target="_blank">
|
||||
<img src="content/images/embeded.svg" alt="Open in embedded mode" title="Open in embedded mode"/>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
For more information on how to configure your ASP.NET application, please visit
|
||||
http://go.microsoft.com/fwlink/?LinkId=152368
|
||||
@ -26,11 +26,11 @@
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<validation validateIntegratedModeConfiguration="false" />
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<handlers>
|
||||
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
|
||||
<remove name="OPTIONSVerbHandler" />
|
||||
@ -46,13 +46,21 @@
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
|
||||
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
|
||||
@ -63,7 +71,4 @@
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<entityFramework>
|
||||
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
|
||||
</entityFramework>
|
||||
</configuration>
|
||||
@ -463,13 +463,13 @@ namespace OnlineEditorsExampleMVC
|
||||
|
||||
if (JwtManager.Enabled && isEmbedded == null)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
|
||||
string token = JwtManager.Decode(headerToken);
|
||||
if (token == null || token.Equals(""))
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
@ -479,7 +479,7 @@ namespace OnlineEditorsExampleMVC
|
||||
}
|
||||
|
||||
var filePath = DocManagerHelper.ForcesavePath(fileName, userAddress, false); // get the path to the force saved document version
|
||||
if (filePath.Equals(""))
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
filePath = DocManagerHelper.StoragePath(fileName, userAddress); // or to the original document
|
||||
}
|
||||
@ -520,14 +520,14 @@ namespace OnlineEditorsExampleMVC
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
|
||||
string token = JwtManager.Decode(headerToken);
|
||||
|
||||
if (token == null || token.Equals(""))
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
@ -575,7 +575,15 @@ namespace OnlineEditorsExampleMVC
|
||||
var jss = new JavaScriptSerializer();
|
||||
var body = jss.Deserialize<Dictionary<string, object>>(fileData);
|
||||
var newFileName = (string) body["newfilename"];
|
||||
var docKey = (string) body["dockey"];
|
||||
var docKey = (string) body["dockey"];
|
||||
|
||||
var origExt = '.' + (string) body["ext"];
|
||||
var curExt = Path.GetExtension(newFileName).ToLower();
|
||||
|
||||
if (string.Compare(origExt, curExt, true) != 0)
|
||||
{
|
||||
newFileName += origExt;
|
||||
}
|
||||
var meta = new Dictionary<string, object>() {
|
||||
{ "title", newFileName }
|
||||
};
|
||||
|
||||
Submodule web/documentserver-example/csharp-mvc/assets updated: 1d601d84c4...1fc823afa9
@ -24,11 +24,15 @@ jQuery.UI - jQuery UI is an open source library of interface components —
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Microsoft.Web.Infrastructure - This package contains the Microsoft.Web.Infrastructure assembly that lets you dynamically register HTTP modules at run time. (https://www.microsoft.com/web/webpi/eula/aspnetmvc3update-eula.htm)
|
||||
License: MS-EULA License
|
||||
License File: Microsoft.Web.Infrastructure.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://licenses.nuget.org/MIT)
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
|
||||
|
||||
21
web/documentserver-example/csharp-mvc/licenses/JWT.license
Normal file
21
web/documentserver-example/csharp-mvc/licenses/JWT.license
Normal file
@ -0,0 +1,21 @@
|
||||
# Public Domain
|
||||
|
||||
Written by John Sheehan (http://john-sheehan.com)
|
||||
|
||||
This work is public domain.
|
||||
|
||||
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.
|
||||
|
||||
For more information, please visit: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
# MIT
|
||||
|
||||
Copyright (c) 2019 Jwt.Net Maintainers and Contributors.
|
||||
|
||||
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.
|
||||
|
||||
For more information, please visit: https://opensource.org/licenses/MIT
|
||||
@ -1,16 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net45" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net45" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
|
||||
<package id="Antlr" version="3.5.0.2" targetFramework="net48" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net48" />
|
||||
<package id="JWT" version="9.0.3" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
<package id="WebGrease" version="1.6.0" targetFramework="net48" />
|
||||
</packages>
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.2.0"/>
|
||||
<add key="version" value="1.4.0"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
<add key="files.docservice.verify-peer-off" value="true"/>
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
@ -19,3 +19,11 @@ License File: jQuery.iframe-transport.license
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
@ -167,7 +167,7 @@ label .checkbox {
|
||||
background-image: url("images/file_docxf.svg");
|
||||
}
|
||||
|
||||
.create-sample {
|
||||
.side-option {
|
||||
color: #666666;
|
||||
line-height: 24px;
|
||||
}
|
||||
@ -744,3 +744,28 @@ html {
|
||||
.user-descr > b {
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
background: #FFFFFF;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0px 7px 25px rgba(85, 85, 85, 0.15);
|
||||
color: #666666;
|
||||
line-height: 160%;
|
||||
max-width: 455px;
|
||||
padding: 14px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.tooltip ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
border-top: 8px solid transparent;
|
||||
border-bottom: 8px solid transparent;
|
||||
border-right: 8px solid #FFFFFF;
|
||||
left: -4px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
<a class="try-editor form" data-type="docxf">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="create-sample">
|
||||
<label class="side-option">
|
||||
<input id="createSample" class="checkbox" type="checkbox" />With sample content
|
||||
</label>
|
||||
</div>
|
||||
@ -88,7 +88,7 @@
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Username</span>
|
||||
<img class="info" src="app_themes/images/info.svg" />
|
||||
<img id="info" class="info" src="app_themes/images/info.svg" />
|
||||
<select class="select-user" id="user">
|
||||
<% foreach (User user in Users.getAllUsers())
|
||||
{ %>
|
||||
@ -99,7 +99,10 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Language editors interface</span>
|
||||
<span class="select-user">Language</span>
|
||||
<img class="info info-tooltip" data-id="language"
|
||||
data-tooltip="Choose the language for ONLYOFFICE editors interface"
|
||||
src="app_themes/images/info.svg" />
|
||||
<select class="select-user" id="language">
|
||||
<% Dictionary<string, string> languages = GetLanguages();
|
||||
foreach (var lang in languages)
|
||||
@ -109,6 +112,14 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<label class="side-option">
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
|
||||
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="app_themes/images/info.svg" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -158,14 +169,15 @@
|
||||
<tbody>
|
||||
<% foreach (var storedFile in storedFiles)
|
||||
{
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
|
||||
var directUrlParam = GetDirectUrlParam();
|
||||
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name) + directUrlParam;
|
||||
var ext = Path.GetExtension(storedFile.Name).ToLower();
|
||||
var docType = DocumentType(storedFile.Name);
|
||||
var canEdit = EditedExts.Contains(ext);
|
||||
var isFillFormDoc = FillFormsExts.Contains(ext);
|
||||
%>
|
||||
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress) %>]">
|
||||
<tr class="tableRow" title="<%= storedFile.Name %> [<%= GetFileVersion(storedFile.Name, HttpContext.Current.Request.UserHostAddress.Replace(':','_')) %>]">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="<%= editUrl %>" target="_blank">
|
||||
<span><%= storedFile.Name %></span>
|
||||
|
||||
@ -485,7 +485,7 @@ namespace OnlineEditorsExample
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
fileUrl.Query = "type=download&fileName=" + HttpUtility.UrlEncode(_fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(CurUserHostAddress(HttpContext.Current.Request.UserHostAddress));
|
||||
|
||||
// get the url to the converted file
|
||||
string newFileUri;
|
||||
@ -626,5 +626,11 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
return languages;
|
||||
}
|
||||
|
||||
public static string GetDirectUrlParam()
|
||||
{
|
||||
string isEnabledDirectUrl = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query).Get("directUrl");
|
||||
return "&directUrl=" + (isEnabledDirectUrl != null ? isEnabledDirectUrl : "false");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,6 +178,7 @@
|
||||
var data = {
|
||||
newfilename: newfilename,
|
||||
dockey: config.document.key,
|
||||
ext: config.document.fileType
|
||||
};
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
|
||||
@ -81,7 +81,7 @@ namespace OnlineEditorsExample
|
||||
+ "webeditor.ashx";
|
||||
callbackUrl.Query = "type=track"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(FileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress));
|
||||
return callbackUrl.ToString();
|
||||
}
|
||||
}
|
||||
@ -100,16 +100,17 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
public static string getDownloadUrl(string fileName)
|
||||
public static string getDownloadUrl(string fileName, Boolean isServer = true)
|
||||
{
|
||||
var downloadUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
|
||||
var downloadUrl = new UriBuilder(_Default.GetServerUrl(isServer));
|
||||
downloadUrl.Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
downloadUrl.Query = "type=download"
|
||||
+ "&fileName=" + HttpUtility.UrlEncode(fileName)
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
+ userAddress;
|
||||
return downloadUrl.ToString();
|
||||
}
|
||||
|
||||
@ -165,6 +166,7 @@ namespace OnlineEditorsExample
|
||||
var actionLink = Request.GetOrDefault("actionLink", null); // get the action link (comment or bookmark) if it exists
|
||||
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink); // get action data for the action link
|
||||
|
||||
var directUrl = getDownloadUrl(FileName, false);
|
||||
var createUrl = getCreateUrl(DocumentType, editorsType);
|
||||
var templatesImageUrl = GetTemplateImageUrl(ext); // image url for templates
|
||||
var templates = new List<Dictionary<string, string>>
|
||||
@ -193,6 +195,7 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
{ "title", FileName },
|
||||
{ "url", getDownloadUrl(FileName) },
|
||||
{ "directUrl", IsEnabledDirectUrl() ? directUrl : "" },
|
||||
{ "fileType", ext.Trim('.') },
|
||||
{ "key", Key },
|
||||
{
|
||||
@ -216,6 +219,7 @@ namespace OnlineEditorsExample
|
||||
{ "modifyFilter", editorsMode != "filter" },
|
||||
{ "modifyContentControl", editorsMode != "blockcontent" },
|
||||
{ "review", canEdit && (editorsMode == "edit" || editorsMode == "review") },
|
||||
{ "chat", !user.id.Equals("uid-0") },
|
||||
{ "reviewGroups", user.reviewGroups },
|
||||
{ "commentGroups", user.commentGroups },
|
||||
{ "userInfoGroups", user.userInfoGroups }
|
||||
@ -230,6 +234,11 @@ namespace OnlineEditorsExample
|
||||
{ "mode", mode },
|
||||
{ "lang", Request.Cookies.GetOrDefault("ulang", "en") },
|
||||
{ "callbackUrl", CallbackUrl }, // absolute URL to the document storage service
|
||||
{ "coEditing", editorsMode == "view" && user.id.Equals("uid-0") ?
|
||||
new Dictionary<string, object>{
|
||||
{"mode", "strict"},
|
||||
{"change", false}
|
||||
} : null },
|
||||
{ "createUrl", !user.id.Equals("uid-0") ? createUrl : null },
|
||||
{ "templates", user.templates ? templates : null },
|
||||
{
|
||||
@ -245,9 +254,9 @@ namespace OnlineEditorsExample
|
||||
// the parameters for the embedded document type
|
||||
"embedded", new Dictionary<string, object>
|
||||
{
|
||||
{ "saveUrl", FileUriUser }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", FileUriUser }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", FileUriUser }, // the absolute URL that will allow other users to share this document
|
||||
{ "saveUrl", directUrl }, // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
{ "embedUrl", directUrl }, // the absolute URL to the document serving as a source file for the document embedded into the web page
|
||||
{ "shareUrl", directUrl }, // the absolute URL that will allow other users to share this document
|
||||
{ "toolbarDocked", "top" } // the place for the embedded viewer toolbar (top or bottom)
|
||||
}
|
||||
},
|
||||
@ -359,13 +368,21 @@ namespace OnlineEditorsExample
|
||||
dataObj.Add("fileType", ext.Replace(".", ""));
|
||||
dataObj.Add("key", key);
|
||||
// write file url to the data object
|
||||
var directPrevFileUrl = i == currentVersion ? _Default.FileUri(FileName, false) : MakePublicHistoryUrl(FileName, i.ToString(), "prev" + ext, false);
|
||||
var prevFileUrl = i == currentVersion ? FileUri : MakePublicHistoryUrl(FileName, i.ToString(), "prev" + ext);
|
||||
if (Path.IsPathRooted(storagePath))
|
||||
{
|
||||
prevFileUrl = i == currentVersion ? getDownloadUrl(FileName) : getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
|
||||
directPrevFileUrl = i == currentVersion ? getDownloadUrl(FileName, false) : getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
|
||||
}
|
||||
|
||||
dataObj.Add("url", prevFileUrl); // write file url to the data object
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
dataObj.Add("directUrl", directPrevFileUrl); // write direct url to the data object
|
||||
}
|
||||
|
||||
dataObj.Add("version", i);
|
||||
if (i > 1) // check if the version number is greater than 1 (the file was modified)
|
||||
{
|
||||
@ -383,11 +400,19 @@ namespace OnlineEditorsExample
|
||||
obj.Add("user", change.Count > 0 ? change["user"] : null);
|
||||
|
||||
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()]; // get the history data from the previous file version
|
||||
dataObj.Add("previous", new Dictionary<string, object>() { // write information about previous file version to the data object
|
||||
|
||||
Dictionary<string, object> dataPrev = new Dictionary<string, object>() { // write information about previous file version to the data object
|
||||
{ "fileType", prev["fileType"] },
|
||||
{ "key", prev["key"] }, // write key and url information about previous file version
|
||||
{ "url", prev["url"] },
|
||||
});
|
||||
{ "url", prev["url"] }
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
dataPrev.Add("directUrl", prev["directUrl"]);
|
||||
}
|
||||
|
||||
dataObj.Add("previous", dataPrev);
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
var changesUrl = MakePublicHistoryUrl(FileName, (i - 1).ToString(), "diff.zip");
|
||||
dataObj.Add("changesUrl", changesUrl);
|
||||
@ -420,6 +445,11 @@ namespace OnlineEditorsExample
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "App_Themes\\images\\logo.png";
|
||||
|
||||
var DirectImageUrl = new UriBuilder(_Default.GetServerUrl(false));
|
||||
DirectImageUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "App_Themes\\images\\logo.png";
|
||||
|
||||
// create a logo config
|
||||
Dictionary<string, object> logoConfig = new Dictionary<string, object>
|
||||
{
|
||||
@ -427,6 +457,11 @@ namespace OnlineEditorsExample
|
||||
{ "url", InsertImageUrl.ToString()}
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
logoConfig.Add("directUrl", DirectImageUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var insImageToken = JwtManager.Encode(logoConfig); // encode logoConfig into the token
|
||||
@ -446,6 +481,12 @@ namespace OnlineEditorsExample
|
||||
+ "webeditor.ashx";
|
||||
compareFileUrl.Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx");
|
||||
|
||||
var DirectFileUrl = new UriBuilder(_Default.GetServerUrl(false));
|
||||
DirectFileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
DirectFileUrl.Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx");
|
||||
|
||||
// create an object with the information about the compared file
|
||||
Dictionary<string, object> dataCompareFile = new Dictionary<string, object>
|
||||
{
|
||||
@ -453,6 +494,11 @@ namespace OnlineEditorsExample
|
||||
{ "url", compareFileUrl.ToString() }
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
dataCompareFile.Add("directUrl", DirectFileUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var compareFileToken = JwtManager.Encode(dataCompareFile); // encode the dataCompareFile object into the token
|
||||
@ -473,6 +519,13 @@ namespace OnlineEditorsExample
|
||||
+ "webeditor.ashx";
|
||||
mailmergeUrl.Query = "type=csv";
|
||||
|
||||
var DirectMailMergeUrl = new UriBuilder(_Default.GetServerUrl(false));
|
||||
DirectMailMergeUrl.Path =
|
||||
HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
DirectMailMergeUrl.Query = "type=csv";
|
||||
|
||||
// create a mail merge config
|
||||
Dictionary<string, object> mailMergeConfig = new Dictionary<string, object>
|
||||
{
|
||||
@ -480,6 +533,11 @@ namespace OnlineEditorsExample
|
||||
{ "url", mailmergeUrl.ToString() }
|
||||
};
|
||||
|
||||
if (IsEnabledDirectUrl())
|
||||
{
|
||||
mailMergeConfig.Add("directUrl", DirectMailMergeUrl.ToString());
|
||||
}
|
||||
|
||||
if (JwtManager.Enabled) // if the secret key to generate token exists
|
||||
{
|
||||
var mailmergeToken = JwtManager.Encode(mailMergeConfig); // encode mailMergeConfig into the token
|
||||
@ -521,15 +579,16 @@ namespace OnlineEditorsExample
|
||||
|
||||
|
||||
// create the public history url
|
||||
private string MakePublicHistoryUrl(string filename, string version, string file)
|
||||
private string MakePublicHistoryUrl(string filename, string version, string file, Boolean isServer = true)
|
||||
{
|
||||
var fileUrl = new UriBuilder(_Default.GetServerUrl(true));
|
||||
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
|
||||
var fileUrl = new UriBuilder(_Default.GetServerUrl(isServer));
|
||||
fileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
|
||||
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
|
||||
+ "webeditor.ashx";
|
||||
fileUrl.Query = "type=downloadhistory&fileName=" + HttpUtility.UrlEncode(filename)
|
||||
+ "&ver=" + version + "&file=" + file
|
||||
+ "&userAddress=" + HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress);
|
||||
+ userAddress;
|
||||
return fileUrl.ToString();
|
||||
}
|
||||
|
||||
@ -580,5 +639,12 @@ namespace OnlineEditorsExample
|
||||
{ "name", uname }
|
||||
}));
|
||||
}
|
||||
|
||||
// get direct url flag
|
||||
private static bool IsEnabledDirectUrl()
|
||||
{
|
||||
string isEnabledDirectUrl = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query).Get("directUrl");
|
||||
return isEnabledDirectUrl != null ? Convert.ToBoolean(isEnabledDirectUrl) : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -132,7 +132,7 @@ namespace ASC.Api.DocumentConverter
|
||||
var payloadToken = JwtManager.Encode(payload); // encode the payload object to the payload token
|
||||
var bodyToken = JwtManager.Encode(body); // encode the body object to the body token
|
||||
// create header token
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken); // and add it to the request headers with the Bearer prefix
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
using System;
|
||||
using JWT;
|
||||
using JWT.Algorithms;
|
||||
using JWT.Builder;
|
||||
using JWT.Serializers;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web.Configuration;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace OnlineEditorsExample
|
||||
{
|
||||
@ -30,31 +30,19 @@ namespace OnlineEditorsExample
|
||||
private static readonly string Secret;
|
||||
public static readonly bool Enabled;
|
||||
|
||||
private static readonly JavaScriptSerializer Serializer;
|
||||
|
||||
static JwtManager()
|
||||
{
|
||||
Secret = WebConfigurationManager.AppSettings["files.docservice.secret"] ?? ""; // get token secret from the config parameters
|
||||
Enabled = !string.IsNullOrEmpty(Secret); // check if the token is enabled
|
||||
Serializer = new JavaScriptSerializer(); // define java script serializer
|
||||
}
|
||||
|
||||
// encode a payload object into a token using a secret key
|
||||
public static string Encode(IDictionary<string, object> payload)
|
||||
{
|
||||
// define the hashing algorithm and the token type
|
||||
var header = new Dictionary<string, object>
|
||||
{
|
||||
{ "alg", "HS256" },
|
||||
{ "typ", "JWT" }
|
||||
};
|
||||
|
||||
// three parts of token
|
||||
var encHeader = Base64UrlEncode(Serializer.Serialize(header)); // header
|
||||
var encPayload = Base64UrlEncode(Serializer.Serialize(payload)); // payload
|
||||
var hashSum = Base64UrlEncode(CalculateHash(encHeader, encPayload)); // signature
|
||||
|
||||
return string.Format("{0}.{1}.{2}", encHeader, encPayload, hashSum);
|
||||
var encoder = new JwtEncoder(new HMACSHA256Algorithm(),
|
||||
new JsonNetSerializer(),
|
||||
new JwtBase64UrlEncoder());
|
||||
return encoder.Encode(payload, Secret);
|
||||
}
|
||||
|
||||
// decode a token into a payload object using a secret key
|
||||
@ -62,52 +50,11 @@ namespace OnlineEditorsExample
|
||||
{
|
||||
if (!Enabled || string.IsNullOrEmpty(token)) return "";
|
||||
|
||||
var split = token.Split('.');
|
||||
if (split.Length != 3) return "";
|
||||
|
||||
var hashSum = Base64UrlEncode(CalculateHash(split[0], split[1])); // get signature
|
||||
if (hashSum != split[2]) return ""; // and check if it is equal to the signature from the token
|
||||
return Base64UrlDecode(split[1]); // decode payload
|
||||
}
|
||||
|
||||
// generate a hash code based on a key using the HMAC method
|
||||
private static byte[] CalculateHash(string encHeader, string encPayload)
|
||||
{
|
||||
using (var hasher = new HMACSHA256(Encoding.UTF8.GetBytes(Secret)))
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(string.Format("{0}.{1}", encHeader, encPayload));
|
||||
return hasher.ComputeHash(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
// encode a string into the base64 value
|
||||
private static string Base64UrlEncode(string str)
|
||||
{
|
||||
return Base64UrlEncode(Encoding.UTF8.GetBytes(str));
|
||||
}
|
||||
|
||||
// encode bytes into the base64 value
|
||||
private static string Base64UrlEncode(byte[] bytes)
|
||||
{
|
||||
return Convert.ToBase64String(bytes)
|
||||
.TrimEnd('=').Replace('+', '-').Replace('/', '_');
|
||||
}
|
||||
|
||||
// decode a base64 value into the string
|
||||
private static string Base64UrlDecode(string payload)
|
||||
{
|
||||
var b64 = payload.Replace('_', '/').Replace('-', '+');
|
||||
switch (b64.Length%4)
|
||||
{
|
||||
case 2:
|
||||
b64 += "==";
|
||||
break;
|
||||
case 3:
|
||||
b64 += "=";
|
||||
break;
|
||||
}
|
||||
var bytes = Convert.FromBase64String(b64);
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
return JwtBuilder.Create()
|
||||
.WithAlgorithm(new HMACSHA256Algorithm())
|
||||
.WithSecret(Secret)
|
||||
.MustVerifySignature()
|
||||
.Decode(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,8 @@
|
||||
<IISExpressWindowsAuthentication />
|
||||
<IISExpressUseClassicPipelineMode />
|
||||
<TargetFrameworkProfile />
|
||||
<Use64BitIISExpress />
|
||||
<UseGlobalApplicationHostFile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@ -44,27 +46,33 @@
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="JWT, Version=9.0.0.0, Culture=neutral, PublicKeyToken=6f98bca0f40f2ecf, processorArchitecture=MSIL">
|
||||
<HintPath>packages\JWT.9.0.3\lib\net46\JWT.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Microsoft.Web.Infrastructure">
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Web.Helpers">
|
||||
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor">
|
||||
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Services" />
|
||||
<Reference Include="System.Web.WebPages">
|
||||
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment">
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor">
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
@ -153,10 +161,12 @@
|
||||
<Content Include="assets\AUTHORS.md" />
|
||||
<Content Include="assets\LICENSE" />
|
||||
<Content Include="assets\new\new.docx" />
|
||||
<Content Include="assets\new\new.docxf" />
|
||||
<Content Include="assets\new\new.pptx" />
|
||||
<Content Include="assets\new\new.xlsx" />
|
||||
<Content Include="assets\sample\csv.csv" />
|
||||
<Content Include="assets\sample\sample.docx" />
|
||||
<Content Include="assets\sample\sample.docxf" />
|
||||
<Content Include="assets\sample\sample.pptx" />
|
||||
<Content Include="assets\sample\sample.xlsx" />
|
||||
<None Include="packages.config" />
|
||||
|
||||
@ -57,7 +57,7 @@ namespace OnlineEditorsExample
|
||||
// check if the document token is enabled
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
string token = null;
|
||||
|
||||
@ -76,7 +76,7 @@ namespace OnlineEditorsExample
|
||||
context.Response.Write("{\"error\":1,\"message\":\"JWT expected\"}");
|
||||
}
|
||||
|
||||
if (token != null && !token.Equals("")) // invalid signature error
|
||||
if (!string.IsNullOrEmpty(token)) // invalid signature error
|
||||
{
|
||||
fileData = jss.Deserialize<Dictionary<string, object>>(token);
|
||||
if (fileData.ContainsKey("payload"))
|
||||
@ -160,7 +160,7 @@ namespace OnlineEditorsExample
|
||||
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]); // write the key value to the key.txt file
|
||||
|
||||
string forcesavePath = _Default.ForcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file version
|
||||
if (!forcesavePath.Equals("")) // if the forcesaved file version exists
|
||||
if (!string.IsNullOrEmpty(forcesavePath)) // if the forcesaved file version exists
|
||||
{
|
||||
File.Delete(forcesavePath); // remove it
|
||||
}
|
||||
@ -231,7 +231,7 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
|
||||
forcesavePath = _Default.ForcesavePath(fileName, userAddress, false);
|
||||
if (forcesavePath.Equals("")) // create forcesave path if it doesn't exist
|
||||
if (string.IsNullOrEmpty(forcesavePath)) // create forcesave path if it doesn't exist
|
||||
{
|
||||
forcesavePath = _Default.ForcesavePath(fileName, userAddress, true);
|
||||
}
|
||||
@ -282,7 +282,7 @@ namespace OnlineEditorsExample
|
||||
|
||||
var payloadToken = JwtManager.Encode(payload); // encode a payload object into a header token
|
||||
var bodyToken = JwtManager.Encode(body); // encode body into a body token
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
request.Headers.Add(JWTheader, "Bearer " + payloadToken); // add a header Authorization with a header token and Authorization prefix in it
|
||||
|
||||
body.Add("token", bodyToken);
|
||||
@ -324,6 +324,7 @@ namespace OnlineEditorsExample
|
||||
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path"); // file isn't specified
|
||||
|
||||
var req = (HttpWebRequest)WebRequest.Create(url);
|
||||
req.Timeout = 5000;
|
||||
using (var stream = req.GetResponse().GetResponseStream()) // get input stream of the file information from the url
|
||||
{
|
||||
if (stream == null) throw new Exception("stream is null");
|
||||
|
||||
@ -66,7 +66,9 @@ namespace OnlineEditorsExample
|
||||
"Can't mention others in comments",
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor"
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
};
|
||||
|
||||
private static List<User> users = new List<User>() {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<appSettings configSource="settings.config" />
|
||||
<system.web>
|
||||
@ -9,9 +9,9 @@
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
<customHeaders>
|
||||
<add name="Access-Control-Allow-Origin" value="*" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
<security>
|
||||
<requestFiltering>
|
||||
@ -25,4 +25,20 @@
|
||||
</requestFiltering>
|
||||
</security>
|
||||
</system.webServer>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@ -207,7 +207,7 @@ namespace OnlineEditorsExample
|
||||
try
|
||||
{
|
||||
var fileName = Path.GetFileName(context.Request["fileName"]);
|
||||
var path = _Default.StoragePath(fileName, HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress));
|
||||
var path = _Default.StoragePath(fileName, HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)));
|
||||
var histDir = _Default.HistoryDir(path);
|
||||
|
||||
if (File.Exists(path)) File.Delete(path); // delete file
|
||||
@ -283,14 +283,14 @@ namespace OnlineEditorsExample
|
||||
|
||||
if (JwtManager.Enabled && isEmbedded == null)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
|
||||
string token = JwtManager.Decode(headerToken);
|
||||
|
||||
if (token == null || token.Equals(""))
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
@ -300,7 +300,7 @@ namespace OnlineEditorsExample
|
||||
}
|
||||
|
||||
var filePath = _Default.ForcesavePath(fileName, userAddress, false); // get the path to the force saved document version
|
||||
if (filePath.Equals(""))
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
filePath = _Default.StoragePath(fileName, userAddress); // or to the original document
|
||||
}
|
||||
@ -340,14 +340,14 @@ namespace OnlineEditorsExample
|
||||
|
||||
if (JwtManager.Enabled)
|
||||
{
|
||||
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
string JWTheader = string.IsNullOrEmpty(WebConfigurationManager.AppSettings["files.docservice.header"]) ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
|
||||
|
||||
if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
|
||||
string token = JwtManager.Decode(headerToken);
|
||||
|
||||
if (token == null || token.Equals(""))
|
||||
if (string.IsNullOrEmpty(token))
|
||||
{
|
||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||
context.Response.Write("JWT validation failed");
|
||||
@ -394,6 +394,15 @@ namespace OnlineEditorsExample
|
||||
var body = jss.Deserialize<Dictionary<string, object>>(fileData);
|
||||
var newFileName = (string) body["newfilename"];
|
||||
var docKey = (string) body["dockey"];
|
||||
|
||||
var origExt = '.' + (string) body["ext"];
|
||||
var curExt = Path.GetExtension(newFileName).ToLower();
|
||||
|
||||
if (string.Compare(origExt, curExt, true) != 0)
|
||||
{
|
||||
newFileName += origExt;
|
||||
}
|
||||
|
||||
var meta = new Dictionary<string, object>() {
|
||||
{ "title", newFileName }
|
||||
};
|
||||
|
||||
Submodule web/documentserver-example/csharp/assets updated: 1d601d84c4...1fc823afa9
@ -19,3 +19,11 @@ License File: jQuery.iframe-transport.license
|
||||
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
|
||||
License: MIT
|
||||
License File: jQuery.UI.license
|
||||
|
||||
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
|
||||
License: MIT
|
||||
License File: JWT.license
|
||||
|
||||
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
|
||||
License: MIT
|
||||
License File: Newtonsoft.Json.license
|
||||
21
web/documentserver-example/csharp/licenses/JWT.license
Normal file
21
web/documentserver-example/csharp/licenses/JWT.license
Normal file
@ -0,0 +1,21 @@
|
||||
# Public Domain
|
||||
|
||||
Written by John Sheehan (http://john-sheehan.com)
|
||||
|
||||
This work is public domain.
|
||||
|
||||
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law.
|
||||
|
||||
For more information, please visit: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
# MIT
|
||||
|
||||
Copyright (c) 2019 Jwt.Net Maintainers and Contributors.
|
||||
|
||||
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.
|
||||
|
||||
For more information, please visit: https://opensource.org/licenses/MIT
|
||||
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007 James Newton-King
|
||||
|
||||
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.
|
||||
@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net45" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
<package id="JWT" version="9.0.3" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net48" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
|
||||
</packages>
|
||||
@ -16,11 +16,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var directUrl;
|
||||
|
||||
if (typeof jQuery != "undefined") {
|
||||
jq = jQuery.noConflict();
|
||||
|
||||
directUrl = getUrlVars()["directUrl"] == "true";
|
||||
|
||||
mustReload = false;
|
||||
|
||||
if (directUrl)
|
||||
jq("#directUrl").prop("checked", directUrl);
|
||||
else
|
||||
directUrl = jq("#directUrl").prop("checked");
|
||||
|
||||
jq("#directUrl").change(function () {
|
||||
window.location = "?directUrl=" + jq(this).prop("checked");
|
||||
});
|
||||
|
||||
jq(function () {
|
||||
jq('#fileupload').fileupload({
|
||||
dataType: 'json',
|
||||
@ -219,7 +232,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.aspx?fileID=" + fileId;
|
||||
var url = "doceditor.aspx?fileID=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -227,7 +240,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.aspx?editorsMode=view&fileID=" + fileId;
|
||||
var url = "doceditor.aspx?editorsMode=view&fileID=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq('#hiddenFileName').val("");
|
||||
jq.unblockUI();
|
||||
@ -235,7 +248,7 @@ if (typeof jQuery != "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
|
||||
var url = "doceditor.aspx?editorsType=embedded&editorsMode=embedded&fileID=" + fileId;
|
||||
var url = "doceditor.aspx?editorsType=embedded&editorsMode=embedded&fileID=" + fileId + "&directUrl=" + directUrl;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
@ -288,6 +301,17 @@ if (typeof jQuery != "undefined") {
|
||||
}
|
||||
};
|
||||
|
||||
function getUrlVars() {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
};
|
||||
|
||||
var fileList = jq("tr.tableRow");
|
||||
|
||||
var mouseIsOverTooltip = false;
|
||||
@ -298,12 +322,12 @@ if (typeof jQuery != "undefined") {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
}
|
||||
jq(".info").on("touchend", function () {
|
||||
jq("#info").on("touchend", function () {
|
||||
showUserTooltip(true);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
jq(".info").mouseover(function (event) {
|
||||
jq("#info").mouseover(function (event) {
|
||||
if (fileList.length > 0) {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
@ -327,4 +351,18 @@ if (typeof jQuery != "undefined") {
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
jq(".info-tooltip").mouseover(function (event) {
|
||||
var target = event.target;
|
||||
var id = target.dataset.id ? target.dataset.id : target.id;
|
||||
var tooltip = target.dataset.tooltip;
|
||||
|
||||
jq("<div class='tooltip'>" + tooltip + "<div class='arrow'></div></div>").appendTo("body");
|
||||
|
||||
var top = jq("#" + id).offset().top + jq("#" + id).outerHeight() / 2 - jq("div.tooltip").outerHeight() / 2;
|
||||
var left = jq("#" + id).offset().left + jq("#" + id).outerWidth() + 20;
|
||||
jq("div.tooltip").css({ "top": top, "left": left });
|
||||
}).mouseout(function () {
|
||||
jq("div.tooltip").remove();
|
||||
});
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<appSettings>
|
||||
<clear />
|
||||
<add key="version" value="1.2.0"/>
|
||||
<add key="version" value="1.4.0"/>
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
@ -15,7 +15,7 @@
|
||||
<add key="files.docservice.header" value="Authorization" />
|
||||
<add key="files.docservice.verify-peer-off" value="true"/>
|
||||
|
||||
<add key="files.docservice.languages" value="en:English|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese"/>
|
||||
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
|
||||
|
||||
<add key="files.docservice.url.site" value="http://documentserver/"/>
|
||||
|
||||
|
||||
34
web/documentserver-example/java-spring/pom.xml
Executable file → Normal file
34
web/documentserver-example/java-spring/pom.xml
Executable file → Normal file
@ -48,7 +48,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.inversoft</groupId>
|
||||
@ -61,10 +61,15 @@
|
||||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.13.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<version>2.13.4.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.modelmapper</groupId>
|
||||
@ -78,6 +83,31 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>validate</id>
|
||||
<phase>validate</phase>
|
||||
<configuration>
|
||||
<configLocation>google_checks.xml</configLocation>
|
||||
<encoding>UTF-8</encoding>
|
||||
<failsOnError>true</failsOnError>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
<logViolationsToConsole>true</logViolationsToConsole>
|
||||
<violationSeverity>warning</violationSeverity>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<includeTestSourceDirectory>true
|
||||
</includeTestSourceDirectory>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@ -42,7 +42,9 @@ public class ExampleData {
|
||||
"Can't mention others in comments",
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor"
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration"
|
||||
);
|
||||
List<String> description_user_1 = List.of( // the description for user 1
|
||||
"File author by default",
|
||||
@ -51,7 +53,8 @@ public class ExampleData {
|
||||
"He can do everything with the comments",
|
||||
"The file favorite state is undefined",
|
||||
"Can create a file from a template with data from the editor",
|
||||
"Can see the information about all users"
|
||||
"Can see the information about all users",
|
||||
"Can view chat"
|
||||
);
|
||||
List<String> description_user_2 = List.of( // the description for user 2
|
||||
"He belongs to Group2",
|
||||
@ -59,7 +62,8 @@ public class ExampleData {
|
||||
"He can view every comment, edit his comments and the comments left by the users who don't belong to any of the groups and remove only his comments",
|
||||
"This file is favorite",
|
||||
"Can create a file from an editor",
|
||||
"Can see the information about users from Group2 and users who don’t belong to any group"
|
||||
"Can see the information about users from Group2 and users who don’t belong to any group",
|
||||
"Can view chat"
|
||||
);
|
||||
List<String> description_user_3 = List.of( // the description for user 3
|
||||
"He belongs to Group3",
|
||||
@ -70,7 +74,8 @@ public class ExampleData {
|
||||
"He can’t download the file",
|
||||
"He can’t print the file",
|
||||
"Can create a file from an editor",
|
||||
"Can see the information about Group2 users"
|
||||
"Can see the information about Group2 users",
|
||||
"Can view chat"
|
||||
);
|
||||
userService.createUser("John Smith", "smith@example.com", // create user 1 with the specified parameters
|
||||
description_user_1, "", List.of(FilterState.NULL.toString()),
|
||||
@ -78,15 +83,18 @@ public class ExampleData {
|
||||
List.of(FilterState.NULL.toString()),
|
||||
List.of(FilterState.NULL.toString()),
|
||||
List.of(FilterState.NULL.toString()),
|
||||
null);
|
||||
null, true);
|
||||
userService.createUser("Mark Pottato", "pottato@example.com", // create user 2 with the specified parameters
|
||||
description_user_2, "group-2", List.of("","group-2"), List.of(FilterState.NULL.toString()),
|
||||
List.of("group-2", ""), List.of("group-2"), List.of("group-2", ""), true);
|
||||
List.of("group-2", ""), List.of("group-2"), List.of("group-2", ""), true,
|
||||
true);
|
||||
userService.createUser("Hamish Mitchell", "mitchell@example.com", // create user 3 with the specified parameters
|
||||
description_user_3, "group-3", List.of("group-2"), List.of("group-2", "group-3"),
|
||||
List.of("group-2"), new ArrayList<>(), List.of("group-2"), false);
|
||||
List.of("group-2"), new ArrayList<>(), List.of("group-2"), false,
|
||||
true);
|
||||
userService.createUser("Anonymous",null, // create user 0 with the specified parameters
|
||||
description_user_0,"", List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
|
||||
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), new ArrayList<>(),null);
|
||||
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()), new ArrayList<>(),null,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,6 @@ import com.onlyoffice.integration.documentserver.models.enums.Action;
|
||||
import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder;
|
||||
import com.onlyoffice.integration.entities.User;
|
||||
import com.onlyoffice.integration.dto.Mentions;
|
||||
import com.onlyoffice.integration.documentserver.models.enums.Language;
|
||||
import com.onlyoffice.integration.documentserver.models.enums.Type;
|
||||
import com.onlyoffice.integration.documentserver.models.filemodel.FileModel;
|
||||
import com.onlyoffice.integration.services.UserServices;
|
||||
@ -53,6 +52,9 @@ public class EditorController {
|
||||
@Value("${files.docservice.url.api}")
|
||||
private String docserviceApiUrl;
|
||||
|
||||
@Value("${files.docservice.languages}")
|
||||
private String langs;
|
||||
|
||||
@Autowired
|
||||
private FileStoragePathBuilder storagePathBuilder;
|
||||
|
||||
@ -77,16 +79,25 @@ public class EditorController {
|
||||
@RequestParam(value = "action", required = false) String actionParam,
|
||||
@RequestParam(value = "type", required = false) String typeParam,
|
||||
@RequestParam(value = "actionLink", required = false) String actionLink,
|
||||
@RequestParam(value = "directUrl", required = false, defaultValue = "false") Boolean directUrl,
|
||||
@CookieValue(value = "uid") String uid,
|
||||
@CookieValue(value = "ulang") String lang,
|
||||
Model model) throws JsonProcessingException {
|
||||
Action action = Action.edit;
|
||||
Type type = Type.desktop;
|
||||
Language language = Language.en;
|
||||
Locale locale = new Locale("en");
|
||||
|
||||
if(actionParam != null) action = Action.valueOf(actionParam);
|
||||
if(typeParam != null) type = Type.valueOf(typeParam);
|
||||
if(lang != null) language = Language.valueOf(lang);
|
||||
|
||||
List<String> langsAndKeys = Arrays.asList(langs.split("\\|"));
|
||||
for (String langAndKey : langsAndKeys) {
|
||||
String[] couple = langAndKey.split(":");
|
||||
if (couple[0].equals(lang)) {
|
||||
String[] langAndCountry = couple[0].split("-");
|
||||
locale = new Locale(langAndCountry[0], langAndCountry.length > 1 ? langAndCountry[1] : "");
|
||||
}
|
||||
}
|
||||
|
||||
Optional<User> optionalUser = userService.findUserById(Integer.parseInt(uid));
|
||||
|
||||
@ -101,10 +112,11 @@ public class EditorController {
|
||||
.builder()
|
||||
.fileName(fileName)
|
||||
.type(type)
|
||||
.lang(language)
|
||||
.lang(locale.toLanguageTag())
|
||||
.action(action)
|
||||
.user(user)
|
||||
.actionData(actionLink)
|
||||
.isEnableDirectUrl(directUrl)
|
||||
.build()
|
||||
);
|
||||
|
||||
@ -112,9 +124,9 @@ public class EditorController {
|
||||
model.addAttribute("model", fileModel); // add file model with the default parameters to the original model
|
||||
model.addAttribute("fileHistory", historyManager.getHistory(fileModel.getDocument())); // get file history and add it to the model
|
||||
model.addAttribute("docserviceApiUrl",docserviceSite + docserviceApiUrl); // create the document service api URL and add it to the model
|
||||
model.addAttribute("dataInsertImage", getInsertImage()); // get an image and add it to the model
|
||||
model.addAttribute("dataCompareFile", getCompareFile()); // get a document for comparison and add it to the model
|
||||
model.addAttribute("dataMailMergeRecipients", getMailMerge()); // get recipients data for mail merging and add it to the model
|
||||
model.addAttribute("dataInsertImage", getInsertImage(directUrl)); // get an image and add it to the model
|
||||
model.addAttribute("dataCompareFile", getCompareFile(directUrl)); // get a document for comparison and add it to the model
|
||||
model.addAttribute("dataMailMergeRecipients", getMailMerge(directUrl)); // get recipients data for mail merging and add it to the model
|
||||
model.addAttribute("usersForMentions", getUserMentions(uid)); // get user data for mentions and add it to the model
|
||||
return "editor.html";
|
||||
}
|
||||
@ -134,10 +146,13 @@ public class EditorController {
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private String getInsertImage() { // get an image that will be inserted into the document
|
||||
private String getInsertImage(Boolean directUrl) { // get an image that will be inserted into the document
|
||||
Map<String, Object> dataInsertImage = new HashMap<>();
|
||||
dataInsertImage.put("fileType", "png");
|
||||
dataInsertImage.put("url", storagePathBuilder.getServerUrl(true) + "/css/img/logo.png");
|
||||
if (directUrl) {
|
||||
dataInsertImage.put("directUrl", storagePathBuilder.getServerUrl(false) + "/css/img/logo.png");
|
||||
}
|
||||
|
||||
// check if the document token is enabled
|
||||
if(jwtManager.tokenEnabled()){
|
||||
@ -148,10 +163,13 @@ public class EditorController {
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private String getCompareFile(){ // get a document that will be compared with the current document
|
||||
private String getCompareFile(Boolean directUrl) { // get a document that will be compared with the current document
|
||||
Map<String, Object> dataCompareFile = new HashMap<>();
|
||||
dataCompareFile.put("fileType", "docx");
|
||||
dataCompareFile.put("url", storagePathBuilder.getServerUrl(true) + "/assets?name=sample.docx");
|
||||
if (directUrl) {
|
||||
dataCompareFile.put("directUrl", storagePathBuilder.getServerUrl(false) + "/assets?name=sample.docx");
|
||||
}
|
||||
|
||||
// check if the document token is enabled
|
||||
if(jwtManager.tokenEnabled()){
|
||||
@ -162,10 +180,13 @@ public class EditorController {
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private String getMailMerge(){
|
||||
private String getMailMerge(Boolean directUrl) {
|
||||
Map<String, Object> dataMailMergeRecipients = new HashMap<>(); // get recipients data for mail merging
|
||||
dataMailMergeRecipients.put("fileType", "csv");
|
||||
dataMailMergeRecipients.put("url", storagePathBuilder.getServerUrl(true) + "/csv");
|
||||
if (directUrl) {
|
||||
dataMailMergeRecipients.put("directUrl", storagePathBuilder.getServerUrl(false) + "/csv");
|
||||
}
|
||||
|
||||
// check if the document token is enabled
|
||||
if(jwtManager.tokenEnabled()){
|
||||
|
||||
@ -164,7 +164,7 @@ public class FileController {
|
||||
public String convert(@RequestBody Converter body, // convert a file
|
||||
@CookieValue("uid") String uid, @CookieValue("ulang") String lang){
|
||||
String fileName = body.getFileName(); // get file name
|
||||
String fileUri = documentManager.getDownloadUrl(fileName); // get URL for downloading a file with the specified name
|
||||
String fileUri = documentManager.getDownloadUrl(fileName, true); // get URL for downloading a file with the specified name
|
||||
String filePass = body.getFilePass() != null ? body.getFilePass() : null; // get file password if it exists
|
||||
String fileExt = fileUtility.getFileExtension(fileName); // get file extension
|
||||
DocumentType type = fileUtility.getDocumentType(fileName); // get document type (word, cell or slide)
|
||||
@ -371,6 +371,16 @@ public class FileController {
|
||||
public String rename(@RequestBody JSONObject body) {
|
||||
String newfilename = (String) body.get("newfilename");
|
||||
String dockey = (String) body.get("dockey");
|
||||
String origExt = "." + (String) body.get("ext");
|
||||
String curExt = newfilename;
|
||||
|
||||
if(newfilename.indexOf(".") != -1) {
|
||||
curExt = (String) fileUtility.getFileExtension(newfilename);
|
||||
}
|
||||
|
||||
if(origExt.compareTo(curExt) != 0) {
|
||||
newfilename += origExt;
|
||||
}
|
||||
|
||||
HashMap<String, String> meta = new HashMap<>();
|
||||
meta.put("title", newfilename);
|
||||
|
||||
@ -68,7 +68,8 @@ public class IndexController {
|
||||
private String langs;
|
||||
|
||||
@GetMapping("${url.index}")
|
||||
public String index(Model model){
|
||||
public String index(@RequestParam(value = "directUrl", required = false) Boolean directUrl,
|
||||
Model model){
|
||||
java.io.File[] files = storageMutator.getStoredFiles(); // get all the stored files from the storage
|
||||
List<String> docTypes = new ArrayList<>();
|
||||
List<Boolean> filesEditable = new ArrayList<>();
|
||||
@ -76,7 +77,7 @@ public class IndexController {
|
||||
List<Boolean> isFillFormDoc = new ArrayList<>();
|
||||
List<String> langsAndKeys = Arrays.asList(langs.split("\\|"));
|
||||
|
||||
Map<String, String> languages = new HashMap<>();
|
||||
Map<String, String> languages = new LinkedHashMap<>();
|
||||
|
||||
langsAndKeys.forEach((str) -> {
|
||||
String[] couple = str.split(":");
|
||||
@ -107,6 +108,7 @@ public class IndexController {
|
||||
model.addAttribute("tooltip", tooltip);
|
||||
model.addAttribute("users", users);
|
||||
model.addAttribute("languages", languages);
|
||||
model.addAttribute("directUrl", directUrl);
|
||||
|
||||
return "index.html";
|
||||
}
|
||||
|
||||
@ -76,8 +76,15 @@ public class DefaultCallbackManager implements CallbackManager {
|
||||
|
||||
URL uri = new URL(url);
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) uri.openConnection();
|
||||
connection.setConnectTimeout(5000);
|
||||
InputStream stream = connection.getInputStream(); // get input stream of the file information from the URL
|
||||
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != 200) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new RuntimeException("Document editing service returned status: " + statusCode);
|
||||
}
|
||||
|
||||
if (stream == null) {
|
||||
connection.disconnect();
|
||||
throw new RuntimeException("Input stream is null");
|
||||
|
||||
@ -118,10 +118,10 @@ public class DefaultDocumentManager implements DocumentManager {
|
||||
String hostAddress = storagePathBuilder.getStorageLocation(); // get the storage directory
|
||||
String filePathDownload = !fileName.contains(InetAddress.getLocalHost().getHostAddress()) ? fileName
|
||||
: fileName.substring(fileName.indexOf(InetAddress.getLocalHost().getHostAddress()) + InetAddress.getLocalHost().getHostAddress().length() + 1);
|
||||
|
||||
String userAddress = forDocumentServer ? "&userAddress" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
|
||||
String filePath = serverPath + "/downloadhistory?fileName=" + URLEncoder.encode(filePathDownload, java.nio.charset.StandardCharsets.UTF_8.toString())
|
||||
+ "&ver=" + version + "&file="+file
|
||||
+ "&userAddress" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
+ userAddress;
|
||||
return filePath;
|
||||
}
|
||||
catch (UnsupportedEncodingException | UnknownHostException e)
|
||||
@ -149,15 +149,15 @@ public class DefaultDocumentManager implements DocumentManager {
|
||||
}
|
||||
|
||||
// get URL to download a file
|
||||
public String getDownloadUrl(String fileName) {
|
||||
String serverPath = storagePathBuilder.getServerUrl(true);
|
||||
public String getDownloadUrl(String fileName, Boolean isServer) {
|
||||
String serverPath = storagePathBuilder.getServerUrl(isServer);
|
||||
String storageAddress = storagePathBuilder.getStorageLocation();
|
||||
try
|
||||
{
|
||||
String userAddress = isServer ? "&userAddress=" + URLEncoder.encode(storageAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
|
||||
String query = downloadUrl+"?fileName="
|
||||
+ URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString())
|
||||
+ "&userAddress="
|
||||
+ URLEncoder.encode(storageAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
+ userAddress;
|
||||
|
||||
return serverPath + query;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public interface DocumentManager {
|
||||
String getFileUri(String fileName, Boolean forDocumentServer); // get file URL
|
||||
String getHistoryFileUrl(String fileName, Integer version, String file, Boolean forDocumentServer); // get file URL
|
||||
String getCallback(String fileName); // get the callback URL
|
||||
String getDownloadUrl(String fileName); // get URL to download a file
|
||||
String getDownloadUrl(String fileName, Boolean forDocumentServer); // get URL to download a file
|
||||
ArrayList<Map<String, Object>> getFilesInfo(); // get file information
|
||||
ArrayList<Map<String, Object>> getFilesInfo(String fileId); // get file information by its ID
|
||||
String versionDir(String path, Integer version, boolean historyPath); // get the path to the file version by the history path and file version
|
||||
|
||||
@ -91,6 +91,10 @@ public class DefaultHistoryManager implements HistoryManager {
|
||||
dataObj.put("key", key);
|
||||
dataObj.put("url", i == curVer ? document.getUrl() :
|
||||
documentManager.getHistoryFileUrl(document.getTitle(), i, "prev" + fileUtility.getFileExtension(document.getTitle()), true));
|
||||
if (!document.getDirectUrl().equals("")) {
|
||||
dataObj.put("directUrl", i == curVer ? document.getDirectUrl() :
|
||||
documentManager.getHistoryFileUrl(document.getTitle(), i, "prev" + fileUtility.getFileExtension(document.getTitle()), false));
|
||||
}
|
||||
dataObj.put("version", i);
|
||||
|
||||
if (i > 1) { //check if the version number is greater than 1
|
||||
@ -109,6 +113,9 @@ public class DefaultHistoryManager implements HistoryManager {
|
||||
prevInfo.put("fileType", prev.get("fileType"));
|
||||
prevInfo.put("key", prev.get("key")); // write key and URL information about previous file version
|
||||
prevInfo.put("url", prev.get("url"));
|
||||
if (!document.getDirectUrl().equals("")) {
|
||||
prevInfo.put("directUrl", prev.get("directUrl"));
|
||||
}
|
||||
dataObj.put("previous", prevInfo); // write information about previous file version to the data object
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
Integer verdiff = i - 1;
|
||||
|
||||
@ -25,6 +25,7 @@ public enum Action {
|
||||
embedded,
|
||||
filter,
|
||||
comment,
|
||||
chat,
|
||||
fillForms,
|
||||
blockcontent
|
||||
}
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2021
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.onlyoffice.integration.documentserver.models.enums;
|
||||
|
||||
public enum Language {
|
||||
en,
|
||||
de,
|
||||
ru,
|
||||
pl,
|
||||
be,
|
||||
bg,
|
||||
ca,
|
||||
zh,
|
||||
cs,
|
||||
da,
|
||||
nl,
|
||||
fi,
|
||||
fr,
|
||||
el,
|
||||
hu,
|
||||
id,
|
||||
it,
|
||||
ja,
|
||||
ko,
|
||||
lv,
|
||||
lo,
|
||||
nb,
|
||||
pt,
|
||||
ro,
|
||||
sk,
|
||||
sl,
|
||||
sv,
|
||||
es,
|
||||
tr,
|
||||
uk,
|
||||
vi,
|
||||
gl,
|
||||
az
|
||||
}
|
||||
@ -39,4 +39,5 @@ public class Document { // the parameters pertaining to the document (title, ur
|
||||
private String urlUser; // the absolute URL that will allow the document to be saved onto the user personal computer
|
||||
private String title; // the desired file name for the viewed or edited document which will also be used as file name when the document is downloaded
|
||||
private String url; // the absolute URL where the source viewed or edited document is stored
|
||||
private String directUrl;
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ package com.onlyoffice.integration.documentserver.models.filemodel;
|
||||
|
||||
import com.onlyoffice.integration.documentserver.models.configurations.Customization;
|
||||
import com.onlyoffice.integration.documentserver.models.configurations.Embedded;
|
||||
import com.onlyoffice.integration.documentserver.models.enums.Language;
|
||||
import com.onlyoffice.integration.documentserver.models.enums.Mode;
|
||||
import lombok.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -38,12 +37,13 @@ import java.util.List;
|
||||
public class EditorConfig { // the parameters pertaining to the editor interface: opening mode (viewer or editor), interface language, additional buttons, etc.
|
||||
private HashMap<String, Object> actionLink = null; // the data which contains the information about the action in the document that will be scrolled to
|
||||
private String callbackUrl; // the absolute URL to the document storage service
|
||||
private HashMap<String, Object> coEditing = null;
|
||||
private String createUrl; // the absolute URL of the document where it will be created and available after creation
|
||||
@Autowired
|
||||
private Customization customization; // the parameters which allow to customize the editor interface so that it looked like your other products (if there are any) and change the presence or absence of the additional buttons, links, change logos and editor owner details
|
||||
@Autowired
|
||||
private Embedded embedded; // the parameters which allow to change the settings which define the behavior of the buttons in the embedded mode
|
||||
private Language lang; // the editor interface language
|
||||
private String lang; // the editor interface language
|
||||
private Mode mode; // the editor opening mode
|
||||
@Autowired
|
||||
private User user; // the user currently viewing or editing the document
|
||||
|
||||
@ -43,6 +43,7 @@ public class Permission extends AbstractModel { // the permission for the docum
|
||||
private Boolean modifyFilter = true; // if the filter can applied globally (true) affecting all the other users, or locally (false)
|
||||
private Boolean modifyContentControl = true; // if the content control settings can be changed
|
||||
private Boolean review = true; // if the document can be reviewed or not
|
||||
private Boolean chat = true; // if a chat can be used
|
||||
@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = SerializerFilter.class)
|
||||
private List<String> reviewGroups; // the groups whose changes the user can accept/reject
|
||||
@Autowired
|
||||
|
||||
@ -95,6 +95,13 @@ public class DefaultServiceConverter implements ServiceConverter
|
||||
}
|
||||
|
||||
connection.connect();
|
||||
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != 200) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new RuntimeException("Convertation service returned status: " + statusCode);
|
||||
}
|
||||
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte); // write bytes to the output stream
|
||||
os.flush(); // force write data to the output stream that can be cached in the current thread
|
||||
|
||||
@ -38,6 +38,7 @@ public class Permission extends AbstractEntity {
|
||||
private Boolean modifyFilter = true;
|
||||
private Boolean modifyContentControl = true;
|
||||
private Boolean review = true;
|
||||
private Boolean chat = true;
|
||||
private Boolean templates=true;
|
||||
@ManyToMany
|
||||
private List<Group> reviewGroups;
|
||||
|
||||
@ -37,7 +37,8 @@ public class PermissionServices {
|
||||
List<Group> commentViewGroups,
|
||||
List<Group> commentEditGroups,
|
||||
List<Group> commentRemoveGroups,
|
||||
List<Group> userInfoGroups){
|
||||
List<Group> userInfoGroups,
|
||||
Boolean chat){
|
||||
|
||||
Permission permission = new Permission();
|
||||
permission.setReviewGroups(reviewGroups); // define the groups whose changes the user can accept/reject
|
||||
@ -45,6 +46,7 @@ public class PermissionServices {
|
||||
permission.setCommentsEditGroups(commentEditGroups); // defines the groups whose comments the user can edit
|
||||
permission.setCommentsRemoveGroups(commentRemoveGroups); // defines the groups whose comments the user can remove
|
||||
permission.setUserInfoGroups(userInfoGroups);
|
||||
permission.setChat(chat);
|
||||
|
||||
permissionRepository.save(permission); // save new permissions
|
||||
|
||||
|
||||
@ -56,7 +56,9 @@ public class UserServices {
|
||||
List<String> reviewGroups,
|
||||
List<String> viewGroups,
|
||||
List<String> editGroups,
|
||||
List<String> removeGroups, List<String> userInfoGroups, Boolean favoriteDoc){
|
||||
List<String> removeGroups,
|
||||
List<String> userInfoGroups, Boolean favoriteDoc,
|
||||
Boolean chat){
|
||||
User newUser = new User();
|
||||
newUser.setName(name); // set the user name
|
||||
newUser.setEmail(email); // set the user email
|
||||
@ -71,7 +73,7 @@ public class UserServices {
|
||||
List<Group> usInfoGroups = groupServices.createGroups(userInfoGroups);
|
||||
|
||||
Permission permission = permissionService
|
||||
.createPermission(groupsReview, commentGroupsView, commentGroupsEdit, commentGroupsRemove, usInfoGroups); // specify permissions for the current user
|
||||
.createPermission(groupsReview, commentGroupsView, commentGroupsEdit, commentGroupsRemove, usInfoGroups, chat); // specify permissions for the current user
|
||||
newUser.setPermissions(permission);
|
||||
|
||||
userRepository.save(newUser); // save a new user
|
||||
|
||||
@ -53,8 +53,9 @@ public class DefaultDocumentConfigurer implements DocumentConfigurer<DefaultDocu
|
||||
Permission permission = wrapper.getPermission(); // get the permission parameter from the document wrapper
|
||||
|
||||
document.setTitle(fileName); // set the title to the document config
|
||||
document.setUrl(documentManager.getDownloadUrl(fileName)); // set the URL to download a file to the document config
|
||||
document.setUrl(documentManager.getDownloadUrl(fileName, true)); // set the URL to download a file to the document config
|
||||
document.setUrlUser(documentManager.getFileUri(fileName, false)); // set the file URL to the document config
|
||||
document.setDirectUrl(wrapper.getIsEnableDirectUrl() ? documentManager.getDownloadUrl(fileName, false) : "");
|
||||
document.setFileType(fileUtility.getFileExtension(fileName).replace(".","")); // set the file type to the document config
|
||||
document.getInfo().setFavorite(wrapper.getFavorite()); // set the favorite parameter to the document config
|
||||
|
||||
|
||||
@ -82,6 +82,10 @@ public class DefaultEditorConfigConfigurer implements EditorConfigConfigurer<Def
|
||||
config.setLang(wrapper.getLang()); // set the language to the editorConfig
|
||||
Boolean canEdit = wrapper.getCanEdit(); // check if the file of the specified type can be edited or not
|
||||
Action action = wrapper.getAction(); // get the action parameter from the editorConfig wrapper
|
||||
config.setCoEditing(action.equals(Action.view) && userIsAnon ? new HashMap<String, Object>() {{
|
||||
put("mode", "strict");
|
||||
put("change", false);
|
||||
}} : null);
|
||||
|
||||
defaultCustomizationConfigurer.configure(config.getCustomization(), DefaultCustomizationWrapper.builder() // define the customization configurer
|
||||
.action(action)
|
||||
|
||||
@ -37,7 +37,7 @@ public class DefaultEmbeddedConfigurer implements EmbeddedConfigurer<DefaultEmbe
|
||||
|
||||
public void configure(Embedded embedded, DefaultEmbeddedWrapper wrapper){ // define the embedded configurer
|
||||
if(wrapper.getType().equals(Type.embedded)) { // check if the type from the embedded wrapper is embedded
|
||||
String url = documentManager.getFileUri(wrapper.getFileName(), false); // get file URL of the specified file
|
||||
String url = documentManager.getDownloadUrl(wrapper.getFileName(), false); // get file URL of the specified file
|
||||
embedded.setEmbedUrl(url); // set the embedURL parameter to the embedded config (the absolute URL to the document serving as a source file for the document embedded into the web page)
|
||||
embedded.setSaveUrl(url); // set the saveURL parameter to the embedded config (the absolute URL that will allow the document to be saved onto the user personal computer)
|
||||
embedded.setShareUrl(url); // set the shareURL parameter to the embedded config (the absolute URL that will allow other users to share this document)
|
||||
|
||||
@ -80,6 +80,7 @@ public class DefaultFileConfigurer implements FileConfigurer<DefaultFileWrapper>
|
||||
.fileName(fileName)
|
||||
.permission(updatePermissions(userPermissions, action, canEdit))
|
||||
.favorite(wrapper.getUser().getFavorite())
|
||||
.isEnableDirectUrl(wrapper.getIsEnableDirectUrl())
|
||||
.build();
|
||||
|
||||
defaultDocumentConfigurer.configure(fileModel.getDocument(), documentWrapper); // define the document configurer
|
||||
|
||||
@ -28,4 +28,5 @@ public class DefaultDocumentWrapper {
|
||||
private Permission permission;
|
||||
private String fileName;
|
||||
private Boolean favorite;
|
||||
private Boolean isEnableDirectUrl;
|
||||
}
|
||||
|
||||
@ -20,7 +20,6 @@ package com.onlyoffice.integration.services.configurers.wrappers;
|
||||
|
||||
import com.onlyoffice.integration.documentserver.models.enums.Action;
|
||||
import com.onlyoffice.integration.entities.User;
|
||||
import com.onlyoffice.integration.documentserver.models.enums.Language;
|
||||
import com.onlyoffice.integration.documentserver.models.enums.Type;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
@ -33,8 +32,9 @@ public class DefaultFileWrapper {
|
||||
private String fileName;
|
||||
private Type type;
|
||||
private User user;
|
||||
private Language lang;
|
||||
private String lang;
|
||||
private Action action;
|
||||
private String actionData;
|
||||
private Boolean canEdit;
|
||||
private Boolean isEnableDirectUrl;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
server.version=1.2.0
|
||||
server.version=1.4.0
|
||||
|
||||
server.address=
|
||||
server.port=4000
|
||||
@ -27,7 +27,7 @@ files.docservice.header=Authorization
|
||||
|
||||
files.docservice.verify-peer-off=true
|
||||
|
||||
files.docservice.languages=en:English|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
|
||||
spring.datasource.url=jdbc:h2:mem:usersdb
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
|
||||
@ -72,6 +72,7 @@ header img {
|
||||
}
|
||||
|
||||
.main{
|
||||
display: table;
|
||||
height: calc(100% - 112px);
|
||||
min-height: 536px;
|
||||
}
|
||||
@ -166,7 +167,7 @@ label .checkbox {
|
||||
background-image: url("img/file_docxf.svg");
|
||||
}
|
||||
|
||||
.create-sample {
|
||||
.side-option {
|
||||
color: #666666;
|
||||
line-height: 24px;
|
||||
}
|
||||
@ -750,3 +751,28 @@ html {
|
||||
.user-descr > b {
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
background: #FFFFFF;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0px 7px 25px rgba(85, 85, 85, 0.15);
|
||||
color: #666666;
|
||||
line-height: 160%;
|
||||
max-width: 455px;
|
||||
padding: 14px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.tooltip ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
border-top: 8px solid transparent;
|
||||
border-bottom: 8px solid transparent;
|
||||
border-right: 8px solid #FFFFFF;
|
||||
left: -4px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
@ -16,11 +16,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var directUrl;
|
||||
|
||||
if (typeof jQuery !== "undefined") {
|
||||
jq = jQuery.noConflict();
|
||||
|
||||
directUrl = getUrlVars()["directUrl"] == "true";
|
||||
|
||||
mustReload = false;
|
||||
|
||||
if (directUrl)
|
||||
jq("#directUrl").prop("checked", directUrl);
|
||||
else
|
||||
directUrl = jq("#directUrl").prop("checked");
|
||||
|
||||
jq("#directUrl").change(function() {
|
||||
window.location = "?directUrl=" + jq(this).prop("checked");
|
||||
});
|
||||
|
||||
jq(function () {
|
||||
jq("#fileupload").fileupload({
|
||||
dataType: "json",
|
||||
@ -228,7 +241,7 @@ if (typeof jQuery !== "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq("#hiddenFileName").val());
|
||||
var url = UrlEditor + "?action=edit&fileName=" + fileId;
|
||||
var url = UrlEditor + "?action=edit&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq("#hiddenFileName").val("");
|
||||
jq.unblockUI();
|
||||
@ -236,7 +249,7 @@ if (typeof jQuery !== "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq("#hiddenFileName").val());
|
||||
var url = UrlEditor + "?action=view&fileName=" + fileId;
|
||||
var url = UrlEditor + "?action=view&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq("#hiddenFileName").val("");
|
||||
jq.unblockUI();
|
||||
@ -244,7 +257,7 @@ if (typeof jQuery !== "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq("#hiddenFileName").val());
|
||||
var url = UrlEditor + "?type=embedded&action=embedded&fileName=" + fileId;
|
||||
var url = UrlEditor + "?type=embedded&action=embedded&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
@ -300,6 +313,17 @@ if (typeof jQuery !== "undefined") {
|
||||
}
|
||||
};
|
||||
|
||||
function getUrlVars() {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
};
|
||||
|
||||
jq("#portal-info")[0].innerHTML += jq("#portal-info")[0].attributes.tooltip.value;
|
||||
|
||||
var fileList = jq("tr.tableRow");
|
||||
@ -312,12 +336,12 @@ if (typeof jQuery !== "undefined") {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
}
|
||||
jq(".info").on("touchend", function () {
|
||||
jq("#info").on("touchend", function () {
|
||||
showUserTooltip(true);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
jq(".info").mouseover(function (event) {
|
||||
jq("#info").mouseover(function (event) {
|
||||
if (fileList.length > 0) {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
@ -342,4 +366,18 @@ if (typeof jQuery !== "undefined") {
|
||||
});
|
||||
}
|
||||
|
||||
jq(".info-tooltip").mouseover(function (event) {
|
||||
var target = event.target;
|
||||
var id = target.dataset.id ? target.dataset.id : target.id;
|
||||
var tooltip = target.dataset.tooltip;
|
||||
|
||||
jq("<div class='tooltip'>" + tooltip + "<div class='arrow'></div></div>").appendTo("body");
|
||||
|
||||
var top = jq("#" + id).offset().top + jq("#" + id).outerHeight() / 2 - jq("div.tooltip").outerHeight() / 2;
|
||||
var left = jq("#" + id).offset().left + jq("#" + id).outerWidth() + 20;
|
||||
jq("div.tooltip").css({"top": top, "left": left});
|
||||
}).mouseout(function () {
|
||||
jq("div.tooltip").remove();
|
||||
});
|
||||
|
||||
}
|
||||
@ -149,6 +149,7 @@
|
||||
var data = {
|
||||
newfilename: newfilename,
|
||||
dockey: config.document.key,
|
||||
ext: config.document.fileType
|
||||
};
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "rename");
|
||||
|
||||
@ -59,7 +59,7 @@
|
||||
<a class="try-editor form" data-type="docxf">Form template</a>
|
||||
</li>
|
||||
</ul>
|
||||
<label class="create-sample">
|
||||
<label class="side-option">
|
||||
<input id="createSample" class="checkbox" type="checkbox" />With sample content
|
||||
</label>
|
||||
</div>
|
||||
@ -75,7 +75,7 @@
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Username</span>
|
||||
<img class="info" src="css/img/info.svg"/>
|
||||
<img id="info" class="info" src="css/img/info.svg"/>
|
||||
<select class="select-user" id="user">
|
||||
<option th:each="user : ${users}"
|
||||
th:value="${user.id}"
|
||||
@ -85,7 +85,10 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Language editors interface</span>
|
||||
<span class="select-user">Language</span>
|
||||
<img class="info info-tooltip" data-id="language"
|
||||
data-tooltip="Choose the language for ONLYOFFICE editors interface"
|
||||
src="css/img/info.svg" />
|
||||
<select class="select-user" id="language">
|
||||
<option th:each="language: ${languages}"
|
||||
th:value="${language.key}"
|
||||
@ -93,6 +96,14 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<label class="side-option">
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
|
||||
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="css/img/info.svg" />
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -129,43 +140,50 @@
|
||||
<tr th:each="file,iState : ${files}" class="tableRow" th:title="${files[iState.index].getName() + versions[iState.index]}">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit" th:classappend="${docTypes[iState.index]}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()})}" target="_blank">
|
||||
th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()}, __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<span th:text="${files[iState.index].getName()}"></span>
|
||||
</a>
|
||||
</td>
|
||||
<th:block th:if="${filesEditable[iState.index]}">
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='edit')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='edit', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/desktop.svg" alt="Open in editor for full size screens" title="Open in editor for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='mobile',action='edit')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='mobile',action='edit', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/mobile.svg" alt="Open in editor for mobile devices" title="Open in editor for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='comment')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='comment', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/comment.svg" alt="Open in editor for comment" title="Open in editor for comment"/>
|
||||
</a>
|
||||
</td>
|
||||
<div th:if="${docTypes[iState.index]} eq 'word'">
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='review')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='review', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/review.svg" alt="Open in editor for review" title="Open in editor for review"/>
|
||||
</a>
|
||||
</td>
|
||||
</div>
|
||||
<div th:if="${docTypes[iState.index]} eq 'cell'">
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='filter')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='filter', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" />
|
||||
</a>
|
||||
</td>
|
||||
</div>
|
||||
<div th:if="${docTypes[iState.index]} eq 'word'">
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='blockcontent')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='blockcontent', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/block-content.svg" alt="Open in editor without content control modification" title="Open in editor without content control modification"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -178,7 +196,8 @@
|
||||
</div>
|
||||
<div th:if="${isFillFormDoc[iState.index]}">
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='fillForms')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='fillForms', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -190,7 +209,8 @@
|
||||
<th:block th:if="${isFillFormDoc[iState.index] and not filesEditable[iState.index]}">
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='mobile',action='fillForms')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='mobile',action='fillForms', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/mobile-fill-forms.svg" alt="Open in editor for filling in forms for mobile devices" title="Open in editor for filling in forms for mobile devices" />
|
||||
</a>
|
||||
</td>
|
||||
@ -198,7 +218,8 @@
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='fillForms')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='fillForms', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -207,17 +228,20 @@
|
||||
<td class="contentCells contentCells-shift contentCells-icon contentCellsEmpty" colspan="6"></td>
|
||||
</th:block>
|
||||
<td class="contentCells contentCells-icon firstContentCellViewers">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='view')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='desktop',action='view', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/desktop.svg" alt="Open in viewer for full size screens" title="Open in viewer for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='mobile',action='view')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='mobile',action='view', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/mobile.svg" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon contentCells-shift">
|
||||
<a th:href="@{/editor(fileName=${files[iState.index].getName()},type='embedded',action='embedded')}" target="_blank">
|
||||
<a th:with="directUrl=${directUrl}"
|
||||
th:href="@{/editor(fileName=${files[iState.index].getName()},type='embedded',action='embedded', __(${#strings.isEmpty(directUrl)} ? '' : ('directUrl=' + ${directUrl}))__)}" target="_blank">
|
||||
<img src="css/img/embeded.svg" alt="Open in embedded mode" title="Open in embedded mode"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -318,8 +342,19 @@
|
||||
<script type="text/javascript" src="scripts/jscript.js"></script>
|
||||
<script type="text/javascript" src="scripts/converter.js"></script>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
document.getElementById("language").value="en";
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var lang = document.cookie
|
||||
.split('; ')
|
||||
.find((row) => row.startsWith('ulang='))
|
||||
?.split('=')[1];
|
||||
|
||||
var languages = Array.from(document.getElementById("language").options).map(e => e.value)
|
||||
|
||||
if (!languages.includes(lang)) {
|
||||
lang = "en";
|
||||
}
|
||||
|
||||
document.getElementById("language").value=lang;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
<version>2.8.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.inversoft</groupId>
|
||||
@ -85,6 +85,31 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>validate</id>
|
||||
<phase>validate</phase>
|
||||
<configuration>
|
||||
<configLocation>google_checks.xml</configLocation>
|
||||
<encoding>UTF-8</encoding>
|
||||
<failsOnError>true</failsOnError>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
<logViolationsToConsole>true</logViolationsToConsole>
|
||||
<violationSeverity>warning</violationSeverity>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<includeTestSourceDirectory>true
|
||||
</includeTestSourceDirectory>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@ public class EditorServlet extends HttpServlet
|
||||
String fileName = FileUtility.GetFileName(request.getParameter("fileName"));
|
||||
String fileExt = request.getParameter("fileExt");
|
||||
String sample = request.getParameter("sample");
|
||||
Boolean isEnableDirectUrl = Boolean.valueOf(request.getParameter("directUrl"));
|
||||
|
||||
// check if there is sample data in the request
|
||||
Boolean sampleData = (sample == null || sample.isEmpty()) ? false : sample.toLowerCase().equals("true");
|
||||
@ -70,7 +71,7 @@ public class EditorServlet extends HttpServlet
|
||||
}
|
||||
|
||||
// create file model (get all the necessary parameters from cookies)
|
||||
FileModel file = new FileModel(fileName, cm.getCookie("ulang"), request.getParameter("actionLink"), user);
|
||||
FileModel file = new FileModel(fileName, cm.getCookie("ulang"), request.getParameter("actionLink"), user, isEnableDirectUrl);
|
||||
// change type parameter if needed
|
||||
file.changeType(request.getParameter("mode"), request.getParameter("type"), user, fileName);
|
||||
|
||||
@ -78,16 +79,25 @@ public class EditorServlet extends HttpServlet
|
||||
Map<String, Object> dataInsertImage = new HashMap<>();
|
||||
dataInsertImage.put("fileType", "png");
|
||||
dataInsertImage.put("url", DocumentManager.GetServerUrl(true) + "/css/img/logo.png");
|
||||
if (isEnableDirectUrl) {
|
||||
dataInsertImage.put("directUrl", DocumentManager.GetServerUrl(false) + "/css/img/logo.png");
|
||||
}
|
||||
|
||||
// a document that will be compared with the current document
|
||||
Map<String, Object> dataCompareFile = new HashMap<>();
|
||||
dataCompareFile.put("fileType", "docx");
|
||||
dataCompareFile.put("url", DocumentManager.GetServerUrl(true) + "/IndexServlet?type=assets&name=sample.docx");
|
||||
if (isEnableDirectUrl) {
|
||||
dataCompareFile.put("directUrl", DocumentManager.GetServerUrl(false) + "/IndexServlet?type=assets&name=sample.docx");
|
||||
}
|
||||
|
||||
// recipients data for mail merging
|
||||
Map<String, Object> dataMailMergeRecipients = new HashMap<>();
|
||||
dataMailMergeRecipients.put("fileType", "csv");
|
||||
dataMailMergeRecipients.put("url", DocumentManager.GetServerUrl(true) + "/IndexServlet?type=csv");
|
||||
if (isEnableDirectUrl) {
|
||||
dataMailMergeRecipients.put("directUrl", DocumentManager.GetServerUrl(false) + "/IndexServlet?type=csv");
|
||||
}
|
||||
|
||||
// users data for mentions
|
||||
List<Map<String, Object>> usersForMentions = Users.getUsersForMentions(user.id);
|
||||
|
||||
@ -234,7 +234,7 @@ public class IndexServlet extends HttpServlet
|
||||
String fileName = FileUtility.GetFileName((String) body.get("filename"));
|
||||
String lang = cm.getCookie("ulang");
|
||||
String filePass = body.get("filePass") != null ? (String) body.get("filePass") : null;
|
||||
String fileUri = DocumentManager.GetDownloadUrl(fileName);
|
||||
String fileUri = DocumentManager.GetDownloadUrl(fileName, true);
|
||||
String fileExt = FileUtility.GetFileExtension(fileName);
|
||||
FileType fileType = FileUtility.GetFileType(fileName);
|
||||
String internalFileExt = DocumentManager.GetInternalExtension(fileType);
|
||||
@ -573,6 +573,17 @@ public class IndexServlet extends HttpServlet
|
||||
String newfilename = (String) body.get("newfilename");
|
||||
String dockey = (String) body.get("dockey");
|
||||
|
||||
String origExt = "." + (String) body.get("ext");
|
||||
String curExt = newfilename;
|
||||
|
||||
if(newfilename.indexOf(".") != -1) {
|
||||
curExt = (String) FileUtility.GetFileExtension(newfilename);
|
||||
}
|
||||
|
||||
if(origExt.compareTo(curExt) != 0) {
|
||||
newfilename += origExt;
|
||||
}
|
||||
|
||||
HashMap<String, String> meta = new HashMap<>();
|
||||
meta.put("title", newfilename);
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ public class FileModel
|
||||
public String token;
|
||||
|
||||
// create file model
|
||||
public FileModel(String fileName, String lang, String actionData, User user)
|
||||
public FileModel(String fileName, String lang, String actionData, User user, Boolean isEnableDirectUrl)
|
||||
{
|
||||
if (fileName == null) fileName = "";
|
||||
fileName = fileName.trim(); // remove extra spaces in the file name
|
||||
@ -51,7 +51,8 @@ public class FileModel
|
||||
// set the document parameters
|
||||
document = new Document();
|
||||
document.title = fileName;
|
||||
document.url = DocumentManager.GetDownloadUrl(fileName); // get file url
|
||||
document.url = DocumentManager.GetDownloadUrl(fileName, true); // get file url
|
||||
document.directUrl = isEnableDirectUrl ? DocumentManager.GetDownloadUrl(fileName, false) : ""; // get direct url
|
||||
document.fileType = FileUtility.GetFileExtension(fileName).replace(".", ""); // get file extension from the file name
|
||||
// generate document key
|
||||
document.key = ServiceConverter.GenerateRevisionId(DocumentManager.CurUserHostAddress(null) + "/" + fileName + "/" + Long.toString(new File(DocumentManager.StoragePath(fileName, null)).lastModified()));
|
||||
@ -77,6 +78,12 @@ public class FileModel
|
||||
// set the editor config parameters
|
||||
editorConfig = new EditorConfig(actionData);
|
||||
editorConfig.callbackUrl = DocumentManager.GetCallback(fileName); // get callback url
|
||||
|
||||
editorConfig.coEditing = mode.equals("view") && user.id.equals("uid-0") ?
|
||||
new HashMap<String, Object>() {{
|
||||
put("mode", "strict");
|
||||
put("change", false);
|
||||
}} : null;
|
||||
|
||||
if (lang != null) editorConfig.lang = lang; // write language parameter to the config
|
||||
|
||||
@ -121,7 +128,7 @@ public class FileModel
|
||||
|
||||
public void InitDesktop(String fileName)
|
||||
{
|
||||
editorConfig.InitDesktop(DocumentManager.GetDownloadUrl(fileName) + "&dmode=emb");
|
||||
editorConfig.InitDesktop(DocumentManager.GetDownloadUrl(fileName, false) + "&dmode=emb");
|
||||
}
|
||||
|
||||
// generate document token
|
||||
@ -177,7 +184,10 @@ public class FileModel
|
||||
|
||||
dataObj.put("fileType", FileUtility.GetFileExtension(document.title).substring(1));
|
||||
dataObj.put("key", key);
|
||||
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetDownloadHistoryUrl(document.title, i, "prev" + FileUtility.GetFileExtension(document.title)));
|
||||
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetDownloadHistoryUrl(document.title, i, "prev" + FileUtility.GetFileExtension(document.title), true));
|
||||
if (!document.directUrl.equals("")) {
|
||||
dataObj.put("directUrl", i == curVer ? document.url : DocumentManager.GetDownloadHistoryUrl(document.title, i, "prev" + FileUtility.GetFileExtension(document.title), false));
|
||||
}
|
||||
dataObj.put("version", i);
|
||||
|
||||
if (i > 1) { //check if the version number is greater than 1
|
||||
@ -199,7 +209,7 @@ public class FileModel
|
||||
dataObj.put("previous", prevInfo); // write information about previous file version to the data object
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
Integer verdiff = i - 1;
|
||||
String changesUrl = DocumentManager.GetDownloadHistoryUrl(document.title, verdiff, "diff.zip");
|
||||
String changesUrl = DocumentManager.GetDownloadHistoryUrl(document.title, verdiff, "diff.zip", true);
|
||||
dataObj.put("changesUrl", changesUrl);
|
||||
}
|
||||
|
||||
@ -247,6 +257,7 @@ public class FileModel
|
||||
{
|
||||
public String title;
|
||||
public String url;
|
||||
public String directUrl;
|
||||
public String fileType;
|
||||
public String key;
|
||||
public Info info;
|
||||
@ -265,9 +276,11 @@ public class FileModel
|
||||
public Boolean modifyFilter;
|
||||
public Boolean modifyContentControl;
|
||||
public Boolean review;
|
||||
public Boolean chat;
|
||||
public List<String> reviewGroups;
|
||||
public CommentGroups commentGroups;
|
||||
public List<String> userInfoGroups;
|
||||
//public Gson gson = new Gson();
|
||||
|
||||
// defines what can be done with a document
|
||||
public Permissions(String mode, String type, Boolean canEdit, User user)
|
||||
@ -281,6 +294,7 @@ public class FileModel
|
||||
modifyFilter = !mode.equals("filter");
|
||||
modifyContentControl = !mode.equals("blockcontent");
|
||||
review = canEdit && (mode.equals("edit") || mode.equals("review"));
|
||||
chat = !user.id.equals("uid-0");
|
||||
reviewGroups = user.reviewGroups;
|
||||
commentGroups = user.commentGroups;
|
||||
userInfoGroups = user.userInfoGroups;
|
||||
@ -305,6 +319,7 @@ public class FileModel
|
||||
public HashMap<String, Object> actionLink = null;
|
||||
public String mode = "edit";
|
||||
public String callbackUrl;
|
||||
public HashMap<String, Object> coEditing = null;
|
||||
public String lang = "en";
|
||||
public String createUrl;
|
||||
public List<Map<String, String>> templates;
|
||||
|
||||
@ -354,7 +354,7 @@ public class DocumentManager
|
||||
|
||||
String filePath = serverPath + "/" + storagePath + "/" + hostAddress + "/" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()).replace("+", "%20");
|
||||
if (f.isAbsolute() && f.isFile()) {
|
||||
filePath = GetDownloadUrl(fileName);
|
||||
filePath = GetDownloadUrl(fileName, true);
|
||||
if (!Files.isWritable(f.toPath())) {
|
||||
throw new SecurityException("No write permission to path: " + f.toPath());
|
||||
}
|
||||
@ -450,12 +450,13 @@ public class DocumentManager
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
public static String GetDownloadUrl(String fileName) {
|
||||
String serverPath = GetServerUrl(true);
|
||||
public static String GetDownloadUrl(String fileName, Boolean forDocumentServer) {
|
||||
String serverPath = GetServerUrl(forDocumentServer);
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
try
|
||||
{
|
||||
String query = "?type=download&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
String userAddress = forDocumentServer ? "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
|
||||
String query = "?type=download&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + userAddress;
|
||||
|
||||
return serverPath + "/IndexServlet" + query;
|
||||
}
|
||||
@ -466,12 +467,13 @@ public class DocumentManager
|
||||
}
|
||||
|
||||
// get url to download a file to History prev.*
|
||||
public static String GetDownloadHistoryUrl(String fileName, Integer version, String file) {
|
||||
String serverPath = GetServerUrl(true);
|
||||
public static String GetDownloadHistoryUrl(String fileName, Integer version, String file, Boolean forDocumentServer) {
|
||||
String serverPath = GetServerUrl(forDocumentServer);
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
try
|
||||
{
|
||||
String query = "?type=downloadhistory&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
String userAddress = forDocumentServer ? "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString()) : "";
|
||||
String query = "?type=downloadhistory&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + userAddress;
|
||||
query = query + "&ver=" + version + "&file=" + URLEncoder.encode(file, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
|
||||
return serverPath + "/IndexServlet" + query;
|
||||
@ -575,7 +577,7 @@ public class DocumentManager
|
||||
String langs = ConfigManager.GetProperty("files.docservice.languages");
|
||||
List<String> langsAndKeys = Arrays.asList(langs.split("\\|"));
|
||||
|
||||
Map<String, String> languages = new HashMap<>();
|
||||
Map<String, String> languages = new LinkedHashMap<>();
|
||||
|
||||
langsAndKeys.forEach((str) -> {
|
||||
String[] couple = str.split(":");
|
||||
|
||||
@ -143,6 +143,12 @@ public class ServiceConverter
|
||||
}
|
||||
|
||||
connection.connect();
|
||||
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != 200) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new Exception("Conversion service returned status: " + statusCode);
|
||||
}
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(bodyByte);
|
||||
}
|
||||
|
||||
@ -253,6 +253,14 @@ public class TrackManager {
|
||||
|
||||
URL uri = new URL(url);
|
||||
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) uri.openConnection();
|
||||
connection.setConnectTimeout(5000);
|
||||
|
||||
int statusCode = connection.getResponseCode();
|
||||
if (statusCode != 200) { // checking status code
|
||||
connection.disconnect();
|
||||
throw new RuntimeException("Document editing service returned status: " + statusCode);
|
||||
}
|
||||
|
||||
InputStream stream = connection.getInputStream(); // get input stream of the file information from the url
|
||||
|
||||
if (stream == null)
|
||||
|
||||
@ -65,6 +65,8 @@ public class Users {
|
||||
add("Can't create new files from the editor");
|
||||
add("Can’t see anyone’s information");
|
||||
add("Can't rename files from the editor");
|
||||
add("Can't view chat");
|
||||
add("View file without collaboration");
|
||||
}};
|
||||
|
||||
private static List<User> users = new ArrayList<User>() {{
|
||||
|
||||
Submodule web/documentserver-example/java/src/main/resources/assets updated: 1d601d84c4...1fc823afa9
@ -1,4 +1,4 @@
|
||||
version=1.2.0
|
||||
version=1.4.0
|
||||
|
||||
filesize-max=5242880
|
||||
storage-folder=app_data
|
||||
@ -16,7 +16,7 @@ files.docservice.url.api=web-apps/apps/api/documents/api.js
|
||||
files.docservice.url.preloader=web-apps/apps/api/documents/cache-scripts.html
|
||||
files.docservice.url.example=
|
||||
|
||||
files.docservice.languages=en:English|az:Azerbaijani|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|nb:Norwegian|pl:Polish|pt:Portuguese|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese
|
||||
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (People's Republic of China)|zh-TW:Chinese (Traditional, Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lv:Latvian|lo:Lao|ms:Malay (Malaysia)|nb:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
|
||||
|
||||
files.docservice.secret=
|
||||
files.docservice.header=Authorization
|
||||
|
||||
@ -167,7 +167,7 @@ label .checkbox {
|
||||
background-image: url("img/file_docxf.svg");
|
||||
}
|
||||
|
||||
.create-sample {
|
||||
.side-option {
|
||||
color: #666666;
|
||||
line-height: 24px;
|
||||
}
|
||||
@ -747,3 +747,28 @@ html {
|
||||
.user-descr > b {
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
.tooltip {
|
||||
background: #FFFFFF;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0px 7px 25px rgba(85, 85, 85, 0.15);
|
||||
color: #666666;
|
||||
line-height: 160%;
|
||||
max-width: 455px;
|
||||
padding: 14px;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.tooltip ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
border-top: 8px solid transparent;
|
||||
border-bottom: 8px solid transparent;
|
||||
border-right: 8px solid #FFFFFF;
|
||||
left: -4px;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
@ -150,6 +150,7 @@
|
||||
var data = {
|
||||
newfilename: newfilename,
|
||||
dockey: config.document.key,
|
||||
ext: config.document.fileType
|
||||
};
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "IndexServlet?type=rename");
|
||||
|
||||
@ -87,7 +87,7 @@
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Username</span>
|
||||
<img class="info" src="css/img/info.svg" />
|
||||
<img id="info" class="info" src="css/img/info.svg" />
|
||||
<select class="select-user" id="user">
|
||||
<% for (User user : Users.getAllUsers()) { %>
|
||||
<option value="<%= user.id %>"><%= user.name == null ? "Anonymous" : user.name %></option>
|
||||
@ -97,7 +97,10 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="middle">
|
||||
<span class="select-user">Language editors interface</span>
|
||||
<span class="select-user">Language</span>
|
||||
<img class="info info-tooltip" data-id="language"
|
||||
data-tooltip="Choose the language for ONLYOFFICE editors interface"
|
||||
src="css/img/info.svg" />
|
||||
<select class="select-user" id="language">
|
||||
<% Map<String, String> languages = DocumentManager.GetLanguages(); %>
|
||||
<% for (Map.Entry<String, String> language : languages.entrySet()) { %>
|
||||
@ -106,6 +109,12 @@
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<td valign="middle">
|
||||
<label class="side-option">
|
||||
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
|
||||
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="css/img/info.svg" />
|
||||
</label>
|
||||
</td>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -159,42 +168,44 @@
|
||||
%>
|
||||
<tr class="tableRow" title="<%= files[i].getName() %><%= version %>">
|
||||
<td class="contentCells">
|
||||
<a class="stored-edit <%= docType %>" href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>" target="_blank">
|
||||
<a class="stored-edit <%= docType %>" href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8").concat(request.getParameter("directUrl") != null ? "&directUrl=".concat(request.getParameter("directUrl")) : "") %>" target="_blank">
|
||||
<span><%= files[i].getName() %></span>
|
||||
</a>
|
||||
</td>
|
||||
<% if (canEdit) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=edit" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8").concat(request.getParameter("directUrl") != null ? "&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=desktop&mode=edit" target="_blank">
|
||||
<img src="css/img/desktop.svg" alt="Open in editor for full size screens" title="Open in editor for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=mobile&mode=edit" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8").concat(request.getParameter("directUrl") != null ? "&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=mobile&mode=edit" target="_blank">
|
||||
<img src="css/img/mobile.svg" alt="Open in editor for mobile devices" title="Open in editor for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=comment" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8").concat(request.getParameter("directUrl") != null ? "&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=desktop&mode=comment" target="_blank">
|
||||
<img src="css/img/comment.svg" alt="Open in editor for comment" title="Open in editor for comment"/>
|
||||
</a>
|
||||
</td>
|
||||
<% if (docType.equals("word")) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=review" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8").concat(request.getParameter("directUrl") != null ? "&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=desktop&mode=review" target="_blank">
|
||||
<img src="css/img/review.svg" alt="Open in editor for review" title="Open in editor for review"/>
|
||||
</a>
|
||||
</td>
|
||||
<% } else if (docType.equals("cell")) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=filter" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8").concat(request.getParameter("directUrl") != null ? "&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=desktop&mode=filter" target="_blank">
|
||||
<img src="css/img/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter"/>
|
||||
</a>
|
||||
</td>
|
||||
<% } %>
|
||||
<% if (docType.equals("word")) { %>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=blockcontent" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8")
|
||||
.concat(request.getParameter("directUrl") != null ?
|
||||
"&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=desktop&mode=blockcontent" target="_blank">
|
||||
<img src="css/img/block-content.svg" alt="Open in editor without content control modification" title="Open in editor without content control modification"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -206,7 +217,9 @@
|
||||
<% } %>
|
||||
<% if (isFillFormDoc) { %>
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=fillForms" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8")
|
||||
.concat(request.getParameter("directUrl") != null ?
|
||||
"&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=desktop&mode=fillForms" target="_blank">
|
||||
<img src="css/img/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -216,7 +229,9 @@
|
||||
<% } else if (isFillFormDoc) {%>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=mobile&mode=fillForms" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8")
|
||||
.concat(request.getParameter("directUrl") != null ?
|
||||
"&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=mobile&mode=fillForms" target="_blank">
|
||||
<img src="css/img/mobile-fill-forms.svg" alt="Open in editor for filling in forms for mobile devices" title="Open in editor for filling in forms for mobile devices" />
|
||||
</a>
|
||||
</td>
|
||||
@ -224,24 +239,32 @@
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-icon "></td>
|
||||
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=fillForms" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8")
|
||||
.concat(request.getParameter("directUrl") != null ?
|
||||
"&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=desktop&mode=fillForms" target="_blank">
|
||||
<img src="css/img/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
|
||||
</a>
|
||||
<% } else { %>
|
||||
<td class="contentCells contentCells-shift contentCells-icon contentCellsEmpty" colspan="6"></td>
|
||||
<% } %>
|
||||
<td class="contentCells contentCells-icon firstContentCellViewers">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=view" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8")
|
||||
.concat(request.getParameter("directUrl") != null ?
|
||||
"&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=desktop&mode=view" target="_blank">
|
||||
<img src="css/img/desktop.svg" alt="Open in viewer for full size screens" title="Open in viewer for full size screens"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=mobile&mode=view" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8")
|
||||
.concat(request.getParameter("directUrl") != null ?
|
||||
"&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=mobile&mode=view" target="_blank">
|
||||
<img src="css/img/mobile.svg" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices"/>
|
||||
</a>
|
||||
</td>
|
||||
<td class="contentCells contentCells-icon contentCells-shift">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=embedded&mode=embedded" target="_blank">
|
||||
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8")
|
||||
.concat(request.getParameter("directUrl") != null ?
|
||||
"&directUrl=".concat(request.getParameter("directUrl")) : "") %>&type=embedded&mode=embedded" target="_blank">
|
||||
<img src="css/img/embeded.svg" alt="Open in embedded mode" title="Open in embedded mode"/>
|
||||
</a>
|
||||
</td>
|
||||
@ -349,8 +372,19 @@
|
||||
var UrlConverter = "IndexServlet?type=convert";
|
||||
var UrlEditor = "EditorServlet";
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
document.getElementById("language").value="en";
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var lang = document.cookie
|
||||
.split('; ')
|
||||
.find((row) => row.startsWith('ulang='))
|
||||
?.split('=')[1];
|
||||
|
||||
var languages = Array.from(document.getElementById("language").options).map(e => e.value)
|
||||
|
||||
if (!languages.includes(lang)) {
|
||||
lang = "en";
|
||||
}
|
||||
|
||||
document.getElementById("language").value=lang;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@ -16,11 +16,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
var directUrl;
|
||||
|
||||
if (typeof jQuery !== "undefined") {
|
||||
jq = jQuery.noConflict();
|
||||
|
||||
directUrl = getUrlVars()["directUrl"] == "true";
|
||||
|
||||
mustReload = false;
|
||||
|
||||
if (directUrl)
|
||||
jq("#directUrl").prop("checked", directUrl);
|
||||
else
|
||||
directUrl = jq("#directUrl").prop("checked");
|
||||
|
||||
jq("#directUrl").change(function() {
|
||||
window.location = "?directUrl=" + jq(this).prop("checked");
|
||||
});
|
||||
|
||||
jq(function () {
|
||||
jq("#fileupload").fileupload({
|
||||
dataType: "json",
|
||||
@ -218,7 +231,7 @@ if (typeof jQuery !== "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEdit:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq("#hiddenFileName").val());
|
||||
var url = UrlEditor + "?mode=edit&fileName=" + fileId;
|
||||
var url = UrlEditor + "?mode=edit&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq("#hiddenFileName").val("");
|
||||
jq.unblockUI();
|
||||
@ -226,7 +239,7 @@ if (typeof jQuery !== "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginView:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq("#hiddenFileName").val());
|
||||
var url = UrlEditor + "?mode=view&fileName=" + fileId;
|
||||
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
window.open(url, "_blank");
|
||||
jq("#hiddenFileName").val("");
|
||||
jq.unblockUI();
|
||||
@ -234,7 +247,7 @@ if (typeof jQuery !== "undefined") {
|
||||
|
||||
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
|
||||
var fileId = encodeURIComponent(jq("#hiddenFileName").val());
|
||||
var url = UrlEditor + "?type=embedded&mode=embedded&fileName=" + fileId;
|
||||
var url = UrlEditor + "?type=embedded&mode=embedded&fileName=" + fileId + "&directUrl=" + directUrl;
|
||||
|
||||
jq("#mainProgress").addClass("embedded");
|
||||
jq("#beginEmbedded").addClass("disable");
|
||||
@ -287,6 +300,17 @@ if (typeof jQuery !== "undefined") {
|
||||
}
|
||||
};
|
||||
|
||||
function getUrlVars() {
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for (var i = 0; i < hashes.length; i++) {
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
return vars;
|
||||
};
|
||||
|
||||
var fileList = jq("tr.tableRow");
|
||||
|
||||
var mouseIsOverTooltip = false;
|
||||
@ -297,12 +321,12 @@ if (typeof jQuery !== "undefined") {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
}
|
||||
jq(".info").on("touchend", function () {
|
||||
jq("#info").on("touchend", function () {
|
||||
showUserTooltip(true);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
jq(".info").mouseover(function (event) {
|
||||
jq("#info").mouseover(function (event) {
|
||||
if (fileList.length > 0) {
|
||||
if (hideTooltipTimeout != null) {
|
||||
clearTimeout(hideTooltipTimeout);
|
||||
@ -326,4 +350,18 @@ if (typeof jQuery !== "undefined") {
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
|
||||
jq(".info-tooltip").mouseover(function (event) {
|
||||
var target = event.target;
|
||||
var id = target.dataset.id ? target.dataset.id : target.id;
|
||||
var tooltip = target.dataset.tooltip;
|
||||
|
||||
jq("<div class='tooltip'>" + tooltip + "<div class='arrow'></div></div>").appendTo("body");
|
||||
|
||||
var top = jq("#" + id).offset().top + jq("#" + id).outerHeight() / 2 - jq("div.tooltip").outerHeight() / 2;
|
||||
var left = jq("#" + id).offset().left + jq("#" + id).outerWidth() + 20;
|
||||
jq("div.tooltip").css({"top": top, "left": left});
|
||||
}).mouseout(function () {
|
||||
jq("div.tooltip").remove();
|
||||
});
|
||||
}
|
||||
1
web/documentserver-example/nodejs/.eslintignore
Normal file
1
web/documentserver-example/nodejs/.eslintignore
Normal file
@ -0,0 +1 @@
|
||||
public
|
||||
15
web/documentserver-example/nodejs/.eslintrc.js
Normal file
15
web/documentserver-example/nodejs/.eslintrc.js
Normal file
@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
commonjs: true,
|
||||
es2021: true,
|
||||
},
|
||||
extends: ['airbnb-base'],
|
||||
overrides: [
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
},
|
||||
rules: {
|
||||
},
|
||||
};
|
||||
@ -44,6 +44,7 @@ const cfgSignatureAuthorizationHeaderPrefix = configServer.get('token.authorizat
|
||||
const cfgSignatureSecretExpiresIn = configServer.get('token.expiresIn');
|
||||
const cfgSignatureSecret = configServer.get('token.secret');
|
||||
const urllib = require("urllib");
|
||||
const { emitWarning } = require("process");
|
||||
const verifyPeerOff = configServer.get('verify_peer_off');
|
||||
|
||||
if(verifyPeerOff) {
|
||||
@ -128,9 +129,8 @@ app.get("/download", function(req, res) { // define a handler for downloading f
|
||||
|
||||
var fileName = fileUtility.getFileName(req.query.fileName);
|
||||
var userAddress = req.query.useraddress;
|
||||
var isEmbedded = req.query.dmode;
|
||||
|
||||
if ((cfgSignatureEnable && cfgSignatureUseForRequest) && isEmbedded == null ) {
|
||||
if ((cfgSignatureEnable && cfgSignatureUseForRequest)) {
|
||||
var authorization = req.get(cfgSignatureAuthorizationHeader);
|
||||
if (authorization && authorization.startsWith(cfgSignatureAuthorizationHeaderPrefix)) {
|
||||
var token = authorization.substring(cfgSignatureAuthorizationHeaderPrefix.length);
|
||||
@ -212,7 +212,6 @@ app.post("/upload", function (req, res) { // define a handler for uploading fil
|
||||
const form = new formidable.IncomingForm(); // create a new incoming form
|
||||
form.uploadDir = uploadDirTmp; // and write there all the necessary parameters
|
||||
form.keepExtensions = true;
|
||||
form.maxFileSize = configServer.get("maxFileSize");
|
||||
|
||||
form.parse(req, function (err, fields, files) { // parse this form
|
||||
if (err) { // if an error occurs
|
||||
@ -325,7 +324,7 @@ app.post("/convert", function (req, res) { // define a handler for converting f
|
||||
var fileName = fileUtility.getFileName(req.body.filename);
|
||||
var filePass = req.body.filePass ? req.body.filePass : null;
|
||||
var lang = req.body.lang ? req.body.lang : null;
|
||||
var fileUri = req.docManager.getFileUri(fileName);
|
||||
var fileUri = req.docManager.getDownloadUrl(fileName, true);
|
||||
var fileExt = fileUtility.getFileExtension(fileName);
|
||||
var fileType = fileUtility.getFileType(fileName);
|
||||
var internalFileExt = req.docManager.getInternalExtension(fileType);
|
||||
@ -349,7 +348,7 @@ app.post("/convert", function (req, res) { // define a handler for converting f
|
||||
response.end();
|
||||
};
|
||||
|
||||
var callback = function (err, data) {
|
||||
var callback = async function (err, res) {
|
||||
if (err) { // if an error occurs
|
||||
if (err.name === "ConnectionTimeoutError" || err.name === "ResponseTimeoutError") { // check what type of error it is
|
||||
writeResult(fileName, 0, null); // despite the timeout errors, write the file to the result object
|
||||
@ -360,7 +359,7 @@ app.post("/convert", function (req, res) { // define a handler for converting f
|
||||
}
|
||||
|
||||
try {
|
||||
var responseUri = documentService.getResponseUri(data.toString());
|
||||
var responseUri = documentService.getResponseUri(res.toString());
|
||||
var result = responseUri.key;
|
||||
var newFileUri = responseUri.value; // get the callback url
|
||||
|
||||
@ -371,10 +370,11 @@ app.post("/convert", function (req, res) { // define a handler for converting f
|
||||
|
||||
var correctName = req.docManager.getCorrectName(fileUtility.getFileName(fileName, true) + internalFileExt); // get the file name with a new extension
|
||||
|
||||
urllib.request(newFileUri, {method: "GET"},function(err, data) {
|
||||
fileSystem.writeFileSync(req.docManager.storagePath(correctName), data); // write a file with a new extension, but with the content from the origin file
|
||||
});
|
||||
const {status, data} = await urllib.request(newFileUri, {method: "GET"});
|
||||
|
||||
if (status != 200) throw new Error("Conversion service returned status: " + status);
|
||||
|
||||
fileSystem.writeFileSync(req.docManager.storagePath(correctName), data); // write a file with a new extension, but with the content from the origin file
|
||||
fileSystem.unlinkSync(req.docManager.storagePath(fileName)); // remove file with the origin extension
|
||||
|
||||
var userAddress = req.docManager.curUserHostAddress();
|
||||
@ -469,7 +469,7 @@ app.get("/csv", function (req, res) { // define a handler for downloading csv f
|
||||
filestream.pipe(res); // send file information to the response by streams
|
||||
})
|
||||
|
||||
app.post("/track", function (req, res) { // define a handler for tracking file changes
|
||||
app.post("/track", async function (req, res) { // define a handler for tracking file changes
|
||||
|
||||
req.docManager = new docManager(req, res);
|
||||
|
||||
@ -478,11 +478,15 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
var version = 0;
|
||||
|
||||
// track file changes
|
||||
var processTrack = function (response, body, fileName, userAddress) {
|
||||
var processTrack = async function (response, body, fileName, userAddress) {
|
||||
|
||||
// callback file saving process
|
||||
var callbackProcessSave = function (downloadUri, body, fileName, userAddress, newFileName) {
|
||||
var callbackProcessSave = async function (downloadUri, body, fileName, userAddress, newFileName) {
|
||||
try {
|
||||
const {status, data} = await urllib.request(downloadUri, {method: "GET"});
|
||||
|
||||
if (status != 200) throw new Error("Document editing service returned status: " + status);
|
||||
|
||||
var storagePath = req.docManager.storagePath(newFileName, userAddress);
|
||||
|
||||
var historyPath = req.docManager.historyPath(newFileName, userAddress); // get the path to the history data
|
||||
@ -499,9 +503,12 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
var downloadZip = body.changesurl;
|
||||
if (downloadZip) {
|
||||
var path_changes = req.docManager.diffPath(newFileName, userAddress, version); // get the path to the file with document versions differences
|
||||
urllib.request(downloadZip, {method: "GET"},function(err, data) {
|
||||
const {status, data} = await urllib.request(downloadZip, {method: "GET"});
|
||||
if (status == 200) {
|
||||
fileSystem.writeFileSync(path_changes, data); // write the document version differences to the archive
|
||||
});
|
||||
} else {
|
||||
emitWarning("Document editing service returned status: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
var changeshistory = body.changeshistory || JSON.stringify(body.history);
|
||||
@ -516,9 +523,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
var path_prev = path.join(versionPath, "prev" + fileUtility.getFileExtension(fileName)); // get the path to the previous file version
|
||||
fileSystem.renameSync(req.docManager.storagePath(fileName, userAddress), path_prev); // and write it to the current path
|
||||
|
||||
urllib.request(downloadUri, {method: "GET"},function(err, data) {
|
||||
fileSystem.writeFileSync(storagePath, data);
|
||||
});
|
||||
fileSystem.writeFileSync(storagePath, data);
|
||||
|
||||
var forcesavePath = req.docManager.forcesavePath(newFileName, userAddress, false); // get the path to the forcesaved file
|
||||
if (forcesavePath != "") { // if this path is empty
|
||||
@ -526,6 +531,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
response.write("{\"error\":1}");
|
||||
response.end();
|
||||
return;
|
||||
@ -536,7 +542,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
|
||||
// file saving process
|
||||
var processSave = function (downloadUri, body, fileName, userAddress) {
|
||||
var processSave = async function (downloadUri, body, fileName, userAddress) {
|
||||
|
||||
if (!downloadUri) {
|
||||
response.write("{\"error\":1}");
|
||||
@ -557,18 +563,18 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
var key = documentService.generateRevisionId(downloadUri);
|
||||
newFileName = req.docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress); // get the correct file name if it already exists
|
||||
try {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (err, data) {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, async function (err, data) {
|
||||
if (err) {
|
||||
callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
await callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var res = documentService.getResponseUri(data);
|
||||
callbackProcessSave(res.value, body, fileName, userAddress, fileName);
|
||||
await callbackProcessSave(res.value, body, fileName, userAddress, fileName);
|
||||
return;
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
await callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
return;
|
||||
}
|
||||
});
|
||||
@ -577,12 +583,16 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
console.log(ex);
|
||||
}
|
||||
}
|
||||
callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
await callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
|
||||
};
|
||||
|
||||
// callback file force saving process
|
||||
var callbackProcessForceSave = function (downloadUri, body, fileName, userAddress, newFileName = false){
|
||||
var callbackProcessForceSave = async function (downloadUri, body, fileName, userAddress, newFileName = false){
|
||||
try {
|
||||
const {status, data} = await urllib.request(downloadUri, {method: "GET"});
|
||||
|
||||
if (status != 200) throw new Error("Document editing service returned status: " + status);
|
||||
|
||||
var downloadExt = "." + body.fileType;
|
||||
|
||||
/// TODO [Delete in version 7.0 or higher]
|
||||
@ -610,9 +620,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
}
|
||||
|
||||
urllib.request(downloadUri, {method: "GET"},function(err, data) {
|
||||
fileSystem.writeFileSync(forcesavePath, data);
|
||||
});
|
||||
fileSystem.writeFileSync(forcesavePath, data);
|
||||
|
||||
if (isSubmitForm) {
|
||||
var uid =body.actions[0].userid
|
||||
@ -629,7 +637,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
|
||||
// file force saving process
|
||||
var processForceSave = function (downloadUri, body, fileName, userAddress) {
|
||||
var processForceSave = async function (downloadUri, body, fileName, userAddress) {
|
||||
|
||||
if (!downloadUri) {
|
||||
response.write("{\"error\":1}");
|
||||
@ -647,18 +655,18 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
if (downloadExt != curExt) {
|
||||
var key = documentService.generateRevisionId(downloadUri);
|
||||
try {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (err, data) {
|
||||
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, async function (err, data) {
|
||||
if (err) {
|
||||
callbackProcessForceSave(downloadUri, body, fileName, userAddress, true);
|
||||
await callbackProcessForceSave(downloadUri, body, fileName, userAddress, true);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
var res = documentService.getResponseUri(data);
|
||||
callbackProcessForceSave(res.value, body, fileName, userAddress, false);
|
||||
await callbackProcessForceSave(res.value, body, fileName, userAddress, false);
|
||||
return;
|
||||
} catch (ex) {
|
||||
console.log(ex);
|
||||
callbackProcessForceSave(downloadUri, body, fileName, userAddress, true);
|
||||
await callbackProcessForceSave(downloadUri, body, fileName, userAddress, true);
|
||||
return;
|
||||
}
|
||||
});
|
||||
@ -667,7 +675,7 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
console.log(ex);
|
||||
}
|
||||
}
|
||||
callbackProcessForceSave (downloadUri, body, fileName, userAddress, false);
|
||||
await callbackProcessForceSave (downloadUri, body, fileName, userAddress, false);
|
||||
};
|
||||
|
||||
if (body.status == 1) { // editing
|
||||
@ -683,10 +691,10 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
}
|
||||
}
|
||||
} else if (body.status == 2 || body.status == 3) { // MustSave, Corrupted
|
||||
processSave(body.url, body, fileName, userAddress); // save file
|
||||
await processSave(body.url, body, fileName, userAddress); // save file
|
||||
return;
|
||||
} else if (body.status == 6 || body.status == 7) { // MustForceSave, CorruptedForceSave
|
||||
processForceSave(body.url, body, fileName, userAddress); // force save file
|
||||
await processForceSave(body.url, body, fileName, userAddress); // force save file
|
||||
return;
|
||||
}
|
||||
|
||||
@ -695,14 +703,14 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
};
|
||||
|
||||
// read request body
|
||||
var readbody = function (request, response, fileName, userAddress) {
|
||||
var readbody = async function (request, response, fileName, userAddress) {
|
||||
var content = "";
|
||||
request.on('data', function (data) { // get data from the request
|
||||
request.on('data', async function (data) { // get data from the request
|
||||
content += data;
|
||||
});
|
||||
request.on('end', function () {
|
||||
request.on('end', async function () {
|
||||
var body = JSON.parse(content);
|
||||
processTrack(response, body, fileName, userAddress); // and track file changes
|
||||
await processTrack(response, body, fileName, userAddress); // and track file changes
|
||||
});
|
||||
};
|
||||
|
||||
@ -734,14 +742,14 @@ app.post("/track", function (req, res) { // define a handler for tracking file
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
processTrack(res, body, fileName, userAddress);
|
||||
await processTrack(res, body, fileName, userAddress);
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.body.hasOwnProperty("status")) { // if the request body has status parameter
|
||||
processTrack(res, req.body, fileName, userAddress); // track file changes
|
||||
await processTrack(res, req.body, fileName, userAddress); // track file changes
|
||||
} else {
|
||||
readbody(req, res, fileName, userAddress); // otherwise, read request body first
|
||||
await readbody(req, res, fileName, userAddress); // otherwise, read request body first
|
||||
}
|
||||
});
|
||||
|
||||
@ -756,6 +764,7 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
var historyData = [];
|
||||
var lang = req.docManager.getLang();
|
||||
var user = users.getUser(req.query.userid);
|
||||
var userDirectUrl = req.query.directUrl == "true";
|
||||
|
||||
var userid = user.id;
|
||||
var name = user.name;
|
||||
@ -770,6 +779,14 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
}
|
||||
}
|
||||
|
||||
var type = req.query.type || ""; // type: embedded/mobile/desktop
|
||||
if (type == "") {
|
||||
type = new RegExp(configServer.get("mobileRegEx"), "i").test(req.get('User-Agent')) ? "mobile" : "desktop";
|
||||
} else if (type != "mobile"
|
||||
&& type != "embedded") {
|
||||
type = "desktop";
|
||||
}
|
||||
|
||||
var templatesImageUrl = req.docManager.getTemplateImageUrl(fileUtility.getFileType(fileName));
|
||||
var createUrl = req.docManager.getCreateUrl(fileUtility.getFileType(fileName), userid, type, lang);
|
||||
var templates = [
|
||||
@ -807,18 +824,10 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
};
|
||||
}
|
||||
var key = req.docManager.getKey(fileName);
|
||||
var url = req.docManager.getDownloadUrl(fileName);
|
||||
var urlUser = path.isAbsolute(storageFolder) ? req.docManager.getDownloadUrl(fileName) + "&dmode=emb" : req.docManager.getlocalFileUri(fileName, 0, false);
|
||||
var url = req.docManager.getDownloadUrl(fileName, true);
|
||||
var directUrl = req.docManager.getDownloadUrl(fileName);
|
||||
var mode = req.query.mode || "edit"; // mode: view/edit/review/comment/fillForms/embedded
|
||||
|
||||
var type = req.query.type || ""; // type: embedded/mobile/desktop
|
||||
if (type == "") {
|
||||
type = new RegExp(configServer.get("mobileRegEx"), "i").test(req.get('User-Agent')) ? "mobile" : "desktop";
|
||||
} else if (type != "mobile"
|
||||
&& type != "embedded") {
|
||||
type = "desktop";
|
||||
}
|
||||
|
||||
var canEdit = configServer.get('editedDocs').indexOf(fileExt) != -1; // check if this file can be edited
|
||||
if ((!canEdit && mode == "edit" || mode == "fillForms") && configServer.get('fillDocs').indexOf(fileExt) != -1) {
|
||||
mode = "fillForms";
|
||||
@ -852,7 +861,8 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
fileType: fileExt.slice(1),
|
||||
version: i,
|
||||
key: keyVersion,
|
||||
url: i == countVersion ? url : (`${req.docManager.getServerUrl(false)}/history?fileName=${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}&useraddress=${userAddress}`),
|
||||
url: i == countVersion ? url : (`${req.docManager.getServerUrl(true)}/history?fileName=${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}&useraddress=${userAddress}`),
|
||||
directUrl: !userDirectUrl ? null : i == countVersion ? directUrl : (`${req.docManager.getServerUrl(false)}/history?fileName=${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}`),
|
||||
};
|
||||
|
||||
if (i > 1 && req.docManager.existsSync(req.docManager.diffPath(fileName, userAddress, i-1))) { // check if the path to the file with document versions differences exists
|
||||
@ -860,8 +870,9 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
fileType: historyData[i-2].fileType,
|
||||
key: historyData[i-2].key,
|
||||
url: historyData[i-2].url,
|
||||
directUrl: !userDirectUrl ? null : historyData[i-2].directUrl,
|
||||
};
|
||||
let changesUrl = `${req.docManager.getServerUrl(false)}/history?fileName=${encodeURIComponent(fileName)}&file=diff.zip&ver=${i-1}&useraddress=${userAddress}`;
|
||||
let changesUrl = `${req.docManager.getServerUrl(true)}/history?fileName=${encodeURIComponent(fileName)}&file=diff.zip&ver=${i-1}&useraddress=${userAddress}`;
|
||||
historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object
|
||||
}
|
||||
|
||||
@ -877,7 +888,8 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
historyData.push({
|
||||
version: countVersion,
|
||||
key: key,
|
||||
url: url
|
||||
url: url,
|
||||
directUrl: !userDirectUrl ? null : directUrl,
|
||||
});
|
||||
}
|
||||
|
||||
@ -894,7 +906,8 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
name: fileName,
|
||||
ext: fileUtility.getFileExtension(fileName, true),
|
||||
uri: url,
|
||||
uriUser: urlUser,
|
||||
directUrl: !userDirectUrl ? null : directUrl,
|
||||
uriUser: directUrl,
|
||||
version: countVersion,
|
||||
created: new Date().toDateString(),
|
||||
favorite: user.favorite != null ? user.favorite : "null"
|
||||
@ -909,6 +922,8 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
templates: user.templates ? templates : null,
|
||||
isEdit: canEdit && (mode == "edit" || mode == "view" || mode == "filter" || mode == "blockcontent"),
|
||||
review: canEdit && (mode == "edit" || mode == "review"),
|
||||
chat: userid != "uid-0",
|
||||
coEditing: mode == "view" && userid == "uid-0" ? {mode: "strict", change: false} : null,
|
||||
comment: mode != "view" && mode != "fillForms" && mode != "embedded" && mode != "blockcontent",
|
||||
fillForms: mode != "view" && mode != "comment" && mode != "embedded" && mode != "blockcontent",
|
||||
modifyFilter: mode != "filter",
|
||||
@ -936,15 +951,18 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
historyData: historyData,
|
||||
dataInsertImage: {
|
||||
fileType: "png",
|
||||
url: req.docManager.getServerUrl(true) + "/images/logo.png"
|
||||
url: req.docManager.getServerUrl(true) + "/images/logo.png",
|
||||
directUrl: !userDirectUrl ? null : req.docManager.getServerUrl() + "/images/logo.png",
|
||||
},
|
||||
dataCompareFile: {
|
||||
fileType: "docx",
|
||||
url: req.docManager.getServerUrl(true) + "/assets/sample/sample.docx"
|
||||
url: req.docManager.getServerUrl(true) + "/assets/sample/sample.docx",
|
||||
directUrl: !userDirectUrl ? null : req.docManager.getServerUrl() + "/assets/sample/sample.docx",
|
||||
},
|
||||
dataMailMergeRecipients: {
|
||||
fileType: "csv",
|
||||
url: req.docManager.getServerUrl(true) + "/csv"
|
||||
url: req.docManager.getServerUrl(true) + "/csv",
|
||||
directUrl: !userDirectUrl ? null : req.docManager.getServerUrl() + "/csv",
|
||||
},
|
||||
usersForMentions: user.id != "uid-0" ? users.getUsersForMentions(user.id) : null,
|
||||
};
|
||||
@ -976,6 +994,12 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
|
||||
app.post("/rename", function (req, res) { //define a handler for renaming file
|
||||
|
||||
var newfilename = req.body.newfilename;
|
||||
var origExt = req.body.ext;
|
||||
var curExt = fileUtility.getFileExtension(newfilename, true);
|
||||
if (curExt !== origExt) {
|
||||
newfilename += '.' + origExt;
|
||||
}
|
||||
|
||||
var dockey = req.body.dockey;
|
||||
var meta = {title: newfilename};
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.2.0",
|
||||
"version": "1.4.0",
|
||||
"log": {
|
||||
"appenders": [
|
||||
{
|
||||
@ -48,11 +48,14 @@
|
||||
"verify_peer_off": true,
|
||||
"languages": {
|
||||
"en": "English",
|
||||
"hy": "Armenian",
|
||||
"az": "Azerbaijani",
|
||||
"eu": "Basque",
|
||||
"be": "Belarusian",
|
||||
"bg": "Bulgarian",
|
||||
"ca": "Catalan",
|
||||
"zh": "Chinese",
|
||||
"zh" : "Chinese (People's Republic of China)",
|
||||
"zh-TW" : "Chinese (Traditional, Taiwan)",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
"nl": "Dutch",
|
||||
@ -68,9 +71,11 @@
|
||||
"ko": "Korean",
|
||||
"lv": "Latvian",
|
||||
"lo": "Lao",
|
||||
"ms": "Malay (Malaysia)",
|
||||
"nb": "Norwegian",
|
||||
"pl": "Polish",
|
||||
"pt": "Portuguese",
|
||||
"pt" : "Portuguese (Brazil)",
|
||||
"pt-PT" : "Portuguese (Portugal)",
|
||||
"ro": "Romanian",
|
||||
"ru": "Russian",
|
||||
"sk": "Slovak",
|
||||
@ -79,7 +84,8 @@
|
||||
"sv": "Swedish",
|
||||
"tr": "Turkish",
|
||||
"uk": "Ukrainian",
|
||||
"vi": "Vietnamese"
|
||||
"vi": "Vietnamese",
|
||||
"aa-AA": "Test Language"
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
|
||||
@ -66,6 +66,9 @@ docManager.prototype.getCustomParams = function () {
|
||||
const lang = this.req.query.lang; // language
|
||||
params += (lang ? "&lang=" + this.getLang() : "");
|
||||
|
||||
const directUrl = this.req.query.directUrl; // directUrl
|
||||
params += (directUrl ? "&directUrl=" + (directUrl == "true") : "");
|
||||
|
||||
const fileName = this.req.query.fileName; // file name
|
||||
params += (fileName ? "&fileName=" + fileName : "");
|
||||
|
||||
@ -163,22 +166,6 @@ docManager.prototype.getFileData = function (fileName, userAddress) {
|
||||
return ((fileSystem.readFileSync(history)).toString()).split(",");
|
||||
};
|
||||
|
||||
// get url to the original file
|
||||
docManager.prototype.getFileUri = function (fileName) {
|
||||
return this.getlocalFileUri(fileName, 0, true);
|
||||
};
|
||||
|
||||
// get local file url
|
||||
docManager.prototype.getlocalFileUri = function (fileName, version, forDocumentServer) {
|
||||
const serverPath = this.getServerUrl(forDocumentServer);
|
||||
const hostAddress = this.curUserHostAddress();
|
||||
let url = serverPath + configServer.get("storagePath") + "/" + hostAddress + "/" + encodeURIComponent(fileName); // get full url address to the file
|
||||
if (!version) {
|
||||
return url;
|
||||
}
|
||||
return url + "-history/" + version; // return history path to the specified file version
|
||||
};
|
||||
|
||||
// get server url
|
||||
docManager.prototype.getServerUrl = function (forDocumentServer) {
|
||||
return (forDocumentServer && !!configServer.get("exampleUrl")) ? configServer.get("exampleUrl") : this.getServerPath();
|
||||
@ -218,10 +205,13 @@ docManager.prototype.getCreateUrl = function (docType, userid, type, lang) {
|
||||
}
|
||||
|
||||
// get url to download a file
|
||||
docManager.prototype.getDownloadUrl = function (fileName) {
|
||||
const server = this.getServerUrl(true);
|
||||
const hostAddress = this.curUserHostAddress();
|
||||
const handler = "/download?fileName=" + encodeURIComponent(fileName) + "&useraddress=" + encodeURIComponent(hostAddress);
|
||||
docManager.prototype.getDownloadUrl = function (fileName, forDocumentServer) {
|
||||
const server = this.getServerUrl(forDocumentServer);
|
||||
var handler = "/download?fileName=" + encodeURIComponent(fileName);
|
||||
if (forDocumentServer) {
|
||||
const hostAddress = this.curUserHostAddress();
|
||||
handler += "&useraddress=" + encodeURIComponent(hostAddress);
|
||||
}
|
||||
|
||||
return server + handler;
|
||||
};
|
||||
@ -387,7 +377,7 @@ docManager.prototype.getTemplateImageUrl = function (fileType) {
|
||||
// get document key
|
||||
docManager.prototype.getKey = function (fileName, userAddress) {
|
||||
userAddress = userAddress || this.curUserHostAddress();
|
||||
let key = userAddress + this.getlocalFileUri(fileName); // get document key by adding local file url to the current user host address
|
||||
let key = userAddress + fileName; // get document key by adding local file url to the current user host address
|
||||
|
||||
let historyPath = this.historyPath(fileName, userAddress); // get the path to the file history
|
||||
if (historyPath != ""){ // if the path to the file history exists
|
||||
|
||||
@ -60,6 +60,8 @@ var descr_user_0 = [
|
||||
"Can't create new files from the editor",
|
||||
"Can’t see anyone’s information",
|
||||
"Can't rename files from the editor",
|
||||
"Can't view chat",
|
||||
"View file without collaboration",
|
||||
//"Can’t submit forms"
|
||||
];
|
||||
|
||||
|
||||
@ -22,9 +22,20 @@ var urlModule = require("url");
|
||||
var urllib = require("urllib");
|
||||
const xmlParser = require("fast-xml-parser");
|
||||
const he = require("he");
|
||||
const siteUrl = configServer.get("siteUrl"); // the path to the editors installation
|
||||
|
||||
var cache = null;
|
||||
|
||||
async function initWopi(docManager) {
|
||||
let absSiteUrl = siteUrl;
|
||||
if (absSiteUrl.indexOf("/") === 0) {
|
||||
absSiteUrl = docManager.getServerHost() + siteUrl;
|
||||
}
|
||||
|
||||
// get the wopi discovery information
|
||||
await getDiscoveryInfo(absSiteUrl);
|
||||
}
|
||||
|
||||
// get the wopi discovery information
|
||||
async function getDiscoveryInfo(siteUrl) {
|
||||
let actions = [];
|
||||
@ -125,6 +136,7 @@ function getActionUrl(host, userAddress, action, filename) {
|
||||
return action.urlsrc.replace(/<.*&>/g, "") + "WOPISrc=" + host + "/wopi/files/" + filename + "@" + userAddress;
|
||||
}
|
||||
|
||||
exports.initWopi = initWopi;
|
||||
exports.getDiscoveryInfo = getDiscoveryInfo;
|
||||
exports.getAction = getAction;
|
||||
exports.getActions = getActions;
|
||||
|
||||
@ -23,7 +23,7 @@ const docManager = require("../docManager");
|
||||
const fileUtility = require("../fileUtility");
|
||||
const config = require('config');
|
||||
const configServer = config.get('server');
|
||||
const siteUrl = configServer.get('siteUrl'); // the path to the editors installation
|
||||
const siteUrl = configServer.get("siteUrl"); // the path to the editors installation
|
||||
const users = require("../users");
|
||||
|
||||
exports.registerRoutes = function(app) {
|
||||
@ -33,24 +33,10 @@ exports.registerRoutes = function(app) {
|
||||
|
||||
req.docManager = new docManager(req, res);
|
||||
|
||||
let absSiteUrl = siteUrl;
|
||||
if (absSiteUrl.indexOf("/") === 0) {
|
||||
absSiteUrl = req.docManager.getServerHost() + siteUrl;
|
||||
|
||||
//todo: remove
|
||||
if (absSiteUrl.indexOf("example") !== -1) {
|
||||
let host = req.get("host");
|
||||
let pos = host.indexOf("/", "https://".length);
|
||||
if (pos > -1)
|
||||
{
|
||||
host = host.substring(0, pos);
|
||||
}
|
||||
absSiteUrl = req.docManager.getProtocol() + "://" + host + siteUrl;
|
||||
}
|
||||
}
|
||||
await utils.initWopi(req.docManager);
|
||||
|
||||
// get the wopi discovery information
|
||||
let actions = await utils.getDiscoveryInfo(absSiteUrl);
|
||||
let actions = await utils.getDiscoveryInfo();
|
||||
let wopiEnable = actions.length != 0 ? true : false;
|
||||
let docsExtEdit = []; // Supported extensions for WOPI
|
||||
|
||||
@ -111,6 +97,8 @@ exports.registerRoutes = function(app) {
|
||||
try {
|
||||
req.docManager = new docManager(req, res);
|
||||
|
||||
await utils.initWopi(req.docManager);
|
||||
|
||||
var fileName = req.docManager.getCorrectName(req.params['id'])
|
||||
var fileExt = fileUtility.getFileExtension(fileName, true); // get the file extension from the request
|
||||
var user = users.getUser(req.query.userid); // get a user by the id
|
||||
|
||||
5373
web/documentserver-example/nodejs/npm-shrinkwrap.json
generated
5373
web/documentserver-example/nodejs/npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user