Compare commits

...

280 Commits

Author SHA1 Message Date
cda8a86c2a Merge remote-tracking branch 'remotes/origin/release/1.4.0' into develop 2022-10-26 13:40:30 +03:00
16584c0abb Merge remote-tracking branch 'remotes/origin/hotfix/1.3.1' into release/1.4.0
# Conflicts:
#	CHANGELOG.md
#	web/documentserver-example/csharp/settings.config
#	web/documentserver-example/ruby/config/application.rb
2022-10-26 13:39:29 +03:00
5b76d798fb 1.3.1 2022-10-26 13:28:18 +03:00
1bdb3c03bc Merge remote-tracking branch 'remotes/origin/feature/referenceData' into develop 2022-10-14 10:22:24 +03:00
111dc14f2b nodejs: referenceData 2022-10-14 10:20:45 +03:00
4a656c025f 1.4.0 2022-10-14 10:12:48 +03:00
ce9930e5bc java-spring: fixed footer positioning 2022-10-12 11:12:59 +03:00
9da22d7803 java-spring: fixed sorting of the list of languages 2022-10-12 11:00:01 +03:00
d78c677c99 java: fixed sorting of the list of languages 2022-10-12 10:59:41 +03:00
b204142c13 csharp: include assets 2022-10-11 18:04:21 +03:00
fd1c26ab9f csharp-mvc: reload refs 2022-10-11 17:53:14 +03:00
5993d10bee csharp-mvc: fix ref 2022-10-11 17:23:16 +03:00
c5771c9008 sharp-mvc: Fix merge 24aee6d194 2022-10-11 17:22:49 +03:00
2fad227272 Merge remote-tracking branch 'remotes/origin/release/v7.2.0' into develop 2022-10-05 13:33:43 +03:00
ada438ff0b Merge remote-tracking branch 'remotes/origin/develop' into release/v7.2.0 2022-09-28 09:13:23 +03:00
0dbd65a577 ruby: rails 7.0.3.1 2022-09-27 19:03:26 +03:00
48e5b8d4e0 Merge pull request #304 from ONLYOFFICE/dependabot/nuget/web/documentserver-example/csharp/Newtonsoft.Json-13.0.1
build(deps): bump Newtonsoft.Json from 10.0.3 to 13.0.1 in /web/documentserver-example/csharp
2022-09-27 18:26:31 +03:00
7f08a96681 Merge remote-tracking branch 'remotes/origin/develop' into dependabot/nuget/web/documentserver-example/csharp/Newtonsoft.Json-13.0.1
# Conflicts:
#	web/documentserver-example/csharp/packages.config
2022-09-27 18:26:07 +03:00
3549b4bc2a csharp: Newtonsoft.Json update 2022-09-27 18:24:53 +03:00
c9265d9ddc csharp-mvc: fix dep path 2022-09-27 18:08:47 +03:00
44d9ca88c6 build(deps): bump Newtonsoft.Json in /web/documentserver-example/csharp
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 10.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/10.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-27 14:59:15 +00:00
d964b43087 Merge pull request #303 from ONLYOFFICE/develop
Release/v1.3.0
2022-09-27 17:58:46 +03:00
5a0debd9e8 Merge remote-tracking branch 'remotes/origin/develop' into release/v7.2.0 2022-09-27 17:55:26 +03:00
3b0f942eee Merge pull request #302 from ONLYOFFICE/feature/ruby-3.0.0
support ruby v.3
2022-09-27 17:54:59 +03:00
4ee110c2d5 Merge remote-tracking branch 'remotes/origin/develop' into release/v7.2.0
# Conflicts:
#	web/documentserver-example/nodejs/views/config.ejs
#	web/documentserver-example/ruby/app/models/document_helper.rb
2022-09-15 17:17:24 +03:00
ad1d93dd20 Merge pull request #301 from ONLYOFFICE/bugfix/file-request
added request status check for file
2022-09-15 14:43:19 +03:00
d2d98df5ab support ruby v.3 2022-09-01 16:56:38 +03:00
7805f7dc91 added request status check for file 2022-09-01 09:34:30 +03:00
51ec27d67c nodejs: removed trailing comma 2022-08-25 15:47:10 +03:00
9e94716df0 nodejs: reorder config items 2022-08-16 10:15:39 +03:00
988a8339b1 ruby: ERB::Util.url instead URI::encode 2022-08-15 11:10:02 +03:00
a482635e3f Merge branch 'feature/directUrl' into release/v7.2.0 2022-08-03 12:20:57 +03:00
d2c679f6b1 nodejs: option to send directUrl 2022-08-03 12:20:39 +03:00
1da452d857 Merge branch 'feature/directUrl' into release/v7.2.0 2022-08-03 12:20:18 +03:00
d9b8d2b7e9 directUrl to changelog 2022-08-03 12:14:16 +03:00
24aee6d194 Merge branch 'release/v7.2.0' into feature/directUrl
# Conflicts:
#	web/documentserver-example/csharp-mvc/Helpers/DocManagerHelper.cs
#	web/documentserver-example/csharp/DocEditor.aspx.cs
2022-08-03 12:13:12 +03:00
bd108a9c77 fix changelog 2022-08-03 12:11:01 +03:00
e737e8ed48 Merge remote-tracking branch 'remotes/origin/develop' into release/v7.2.0 2022-08-03 12:10:20 +03:00
b425d15f0a Merge branch 'feature/tooltip' into develop 2022-08-03 12:09:47 +03:00
0f8dec1e6e nodejs: revert tooltip for language (e1753a154d) 2022-08-03 12:08:10 +03:00
193b31fe75 nodejs: id to info block 2022-08-03 11:59:58 +03:00
583403cf78 update empty files (Fix Bug 58202) 2022-08-02 16:50:01 +03:00
641e45e24f 1.3.0 2022-08-02 15:35:18 +03:00
53c30fbb7d Merge branch 'develop' into release/v7.2.0
# Conflicts:
#	CHANGELOG.md
#	web/documentserver-example/csharp-mvc/Helpers/Users.cs
#	web/documentserver-example/csharp/Users.cs
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java
#	web/documentserver-example/java/src/main/java/helpers/Users.java
#	web/documentserver-example/nodejs/app.js
#	web/documentserver-example/nodejs/helpers/users.js
#	web/documentserver-example/php/users.php
#	web/documentserver-example/python/src/utils/users.py
#	web/documentserver-example/ruby/app/models/users.rb
2022-08-02 15:04:09 +03:00
87a1755729 Merge pull request #300 from ONLYOFFICE/feature/ruby-bundle-update
ruby: bundle update
2022-08-02 14:32:40 +03:00
752a2a2364 Merge pull request #298 from ONLYOFFICE/fix/notification-incorrect-file-size
Fix/notification incorrect file size
2022-08-02 14:32:40 +03:00
d1affa2911 Merge pull request #297 from ONLYOFFICE/feature/refactoring-jwt-manager
Feature/refactoring jwt manager
# Conflicts:
#	CHANGELOG.md
2022-08-02 14:32:31 +03:00
0ef2a4f3fd Merge pull request #292 from ONLYOFFICE/Build(deps)/bot-recommendations
changes - ruby - raise gem version
2022-08-02 14:25:18 +03:00
675d3f318a Merge pull request #294 from ONLYOFFICE/dependabot/nuget/web/documentserver-example/csharp-mvc/Newtonsoft.Json-13.0.1
build(deps): bump Newtonsoft.Json from 12.0.3 to 13.0.1 in /web/documentserver-example/csharp-mvc
2022-08-02 14:25:18 +03:00
05512ffa23 Merge pull request #288 from ONLYOFFICE/feature/localhost-for-client
Localhost for client urls
2022-08-02 14:25:17 +03:00
2eeed5d26d Fix #287 Fix #285 Fix #284 Fix #280
Build(deps)/bot recommendations
2022-08-02 14:24:11 +03:00
9e3dbd5eb5 Merge pull request #290 from ONLYOFFICE/fix/php-convert-manager
fix - php - add substrings to string
2022-08-02 14:21:09 +03:00
efbab7c113 nodejs: fix embed link for client request 2022-08-02 14:20:48 +03:00
b8f0f6447c nodejs: remove getlocalFileUri 2022-08-02 14:20:48 +03:00
8779a90433 nodejs: fix history url for server request 2022-08-02 14:20:48 +03:00
b3162ee410 Merge pull request #278 from ONLYOFFICE/dependabot/maven/web/documentserver-example/java-spring/com.fasterxml.jackson.core-jackson-databind-2.12.6.1
build(deps): bump jackson-databind from 2.12.2 to 2.12.6.1 in /web/documentserver-example/java-spring
2022-08-02 14:18:23 +03:00
42edd5e208 Merge pull request #276 from ONLYOFFICE/dependabot/bundler/web/documentserver-example/ruby/nokogiri-1.13.4
build(deps): bump nokogiri from 1.12.5 to 1.13.4 in /web/documentserver-example/ruby
2022-08-02 14:18:23 +03:00
e041baeef7 Merge branch 'feature/extension-on-rename' into develop 2022-08-02 14:18:22 +03:00
5bf682a007 nodejs: package lock 2022-08-02 14:18:22 +03:00
6dacf49faa ruby: fix (23e616aade) 2022-08-02 14:18:22 +03:00
63c9c4242e Merge pull request #291 from ONLYOFFICE/feature/chat
Feature/chat
# Conflicts:
#	CHANGELOG.md
2022-08-02 14:18:21 +03:00
b5e345ed50 Merge branch 'feature/chat' into develop 2022-08-02 14:18:21 +03:00
33f8436d42 changelog 2022-08-02 14:18:20 +03:00
c5217242ab Merge pull request #300 from ONLYOFFICE/feature/ruby-bundle-update
ruby: bundle update
2022-08-01 14:34:39 +03:00
c910d5193b Merge remote-tracking branch 'remotes/origin/dependabot/bundler/web/documentserver-example/ruby/rails-html-sanitizer-1.4.3' into feature/ruby-bundle-update
# Conflicts:
#	web/documentserver-example/ruby/Gemfile.lock
2022-08-01 14:34:05 +03:00
58c27f8f2f ruby: bundle update 2022-08-01 12:56:57 +03:00
1ec831789b Merge pull request #298 from ONLYOFFICE/fix/notification-incorrect-file-size
Fix/notification incorrect file size
2022-07-29 17:37:36 +03:00
0510fd1354 [fix] - node.js - don't send file size limit to incoming form
Revert "nodejs: upload big file"
This reverts commit fa4c3e3258.
2022-07-29 17:31:22 +03:00
25238b5614 Merge pull request #293 from ONLYOFFICE/feature/liveview
Feature/liveview
2022-07-29 17:23:48 +03:00
901bb61883 Merge remote-tracking branch 'remotes/origin/develop' into feature/liveview
# Conflicts:
#	CHANGELOG.md
2022-07-29 17:21:54 +03:00
7f3e6c6364 Merge pull request #291 from ONLYOFFICE/feature/chat
Feature/chat
2022-07-29 17:18:24 +03:00
b3512ea0ce Merge remote-tracking branch 'remotes/origin/develop' into feature/chat
# Conflicts:
#	CHANGELOG.md
2022-07-29 17:16:54 +03:00
642a1bd19a Merge pull request #297 from ONLYOFFICE/feature/refactoring-jwt-manager
Feature/refactoring jwt manager
2022-07-29 17:13:08 +03:00
ac471588de jwt to changelog 2022-07-29 17:12:20 +03:00
17674ef5bc ruby: licenses 2022-07-29 17:12:12 +03:00
dc2ee2a997 php: jwt 2022-07-29 17:12:02 +03:00
c358fa814a csharp-mvc: jwt 2022-07-29 17:11:05 +03:00
143a73e083 csharp: jwt 2022-07-29 17:10:37 +03:00
c266592434 Merge pull request #292 from ONLYOFFICE/Build(deps)/bot-recommendations
changes - ruby - raise gem version
2022-07-29 11:55:36 +03:00
19ed666d56 Merge pull request #294 from ONLYOFFICE/dependabot/nuget/web/documentserver-example/csharp-mvc/Newtonsoft.Json-13.0.1
build(deps): bump Newtonsoft.Json from 12.0.3 to 13.0.1 in /web/documentserver-example/csharp-mvc
2022-07-29 11:53:18 +03:00
84b9202af0 Merge pull request #288 from ONLYOFFICE/feature/localhost-for-client
Localhost for client urls
2022-07-29 11:51:09 +03:00
8fb698bb75 Basque (Spain), Armenian and Malay (Malaysia) lang 2022-07-29 11:38:25 +03:00
00f46ef080 build(deps): bump rails-html-sanitizer
Bumps [rails-html-sanitizer](https://github.com/rails/rails-html-sanitizer) from 1.4.2 to 1.4.3.
- [Release notes](https://github.com/rails/rails-html-sanitizer/releases)
- [Changelog](https://github.com/rails/rails-html-sanitizer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rails/rails-html-sanitizer/compare/v1.4.2...v1.4.3)

---
updated-dependencies:
- dependency-name: rails-html-sanitizer
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-06 12:11:57 +00:00
5c194da95d [add] - java - directUrl 2022-07-04 19:46:34 +03:00
0d5cebe28e [add] - java spring - directUrl 2022-07-04 19:45:37 +03:00
dacf72cae2 [add] - csharp mvc - directUrl 2022-07-01 19:29:52 +03:00
208b8926be [add] - csharp - directUrl 2022-07-01 19:28:55 +03:00
55c4853f04 [add] - php - directUrl 2022-07-01 17:30:18 +03:00
ccae7c6a06 [add] - python - directUrl 2022-06-30 20:29:04 +03:00
dc84dd3b29 [add] - ruby - fix 2022-06-30 19:53:44 +03:00
65d3671b09 [add] - ruby - directUrl 2022-06-30 19:15:15 +03:00
1fb5ef8bfd build(deps): bump Newtonsoft.Json
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 12.0.3 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/12.0.3...13.0.1)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-23 00:47:07 +00:00
b630c3802b fix - ruby - coEditing from permissions to editorConfig 2022-06-16 16:56:18 +03:00
ad3993b532 fix - ruby - coEditing from permissions to editorConfig 2022-06-16 16:52:51 +03:00
35ee61e011 fix - python - checking mode view insert edit 2022-06-16 16:48:01 +03:00
ee59ab3dfd fix - python - coEditing from permissions to editorConfig 2022-06-16 16:43:48 +03:00
500f076e38 fix - csharp - coEditing from permissions to editorConfig 2022-06-16 16:36:51 +03:00
e578f29d9d fix - csharp mvc - coEditing from permissions to editorConfig 2022-06-16 16:35:57 +03:00
9de9bc90a4 fix - java - checking mode view insert edit 2022-06-16 16:32:36 +03:00
7a9ebdbbe5 fix - java - coEditing from permissions to editorConfig 2022-06-16 16:26:03 +03:00
887089bcad add - java spring - anonymous without liveview 2022-06-16 16:11:29 +03:00
680e53823a add - java - anonymous without liveview 2022-06-15 21:08:18 +03:00
33e1489cd6 add - charp mvc - anonymous without liveview 2022-06-15 20:41:32 +03:00
8c90737bf6 add - charp - anonymous without liveview 2022-06-15 20:38:16 +03:00
e5f1bc8ed6 add - php - anonymous without liveview 2022-06-15 20:23:52 +03:00
985b179475 add - python - anonymous without liveview 2022-06-15 20:03:07 +03:00
775d15132f add - ruby - json transform 2022-06-15 19:39:00 +03:00
4a4298ca10 add - ruby - anonymous without liveview 2022-06-15 19:30:36 +03:00
cdbd264ed5 Merge branch 'feature/chat' into feature/liveview
# Conflicts:
#	CHANGELOG.md
2022-06-15 19:21:30 +03:00
e61f6cae89 changes - ruby - raise gem version 2022-06-15 19:10:58 +03:00
22039078ef Merge remote-tracking branch 'remotes/origin/develop' into feature/chat 2022-06-15 18:38:12 +03:00
62793a42ab add - java spring - anonymous without permissions.chat 2022-06-15 18:09:14 +03:00
f49f96a2c2 add - java - anonymous without permissions.chat 2022-06-14 20:16:06 +03:00
2031d65adb add - csharp mvc - anonymous without permissions.chat 2022-06-14 19:53:12 +03:00
7f54659d3b add - csharp - anonymous without permissions.chat 2022-06-14 19:50:44 +03:00
a3bc13bb6e add - php - anonymous without permissions.chat 2022-06-14 19:45:46 +03:00
29ea16c124 add - python - anonymous without permissions.chat 2022-06-14 19:37:42 +03:00
6d4c8b926e add - ruby - anonymous without permissions.chat 2022-06-14 19:25:53 +03:00
22d2031426 fix - csharp - replace with regex 2022-06-14 18:10:18 +03:00
fcc51e8154 fix - csharp-mvc - check if '/' exist + replace with regex 2022-06-14 18:08:46 +03:00
8cd85ad63c Fix #287 Fix #285 Fix #284 Fix #280
Build(deps)/bot recommendations
2022-06-14 17:20:47 +03:00
1d51688884 Merge pull request #290 from ONLYOFFICE/fix/php-convert-manager
fix - php - add substrings to string
2022-06-14 17:05:02 +03:00
2c63a85b00 fix - php - add substrings to string 2022-06-14 16:55:12 +03:00
d1545c4db4 csharp-mvc-fix folder display for localhost 2022-06-10 18:37:17 +03:00
bd8e4d6ec7 csharp-fix goback 2022-06-10 18:31:22 +03:00
e1c815b574 Fix folder display for localhost 2022-06-10 18:29:44 +03:00
4042d2bb8a Merge remote-tracking branch 'remotes/origin/dependabot/maven/web/documentserver-example/java-spring/com.google.code.gson-gson-2.8.9' into build(deps)/bot-recommendations 2022-06-10 16:14:14 +03:00
8c9d2d80bd Merge remote-tracking branch 'remotes/origin/dependabot/maven/web/documentserver-example/java/com.google.code.gson-gson-2.8.9' into build(deps)/bot-recommendations 2022-06-10 16:13:53 +03:00
3a9259d713 Merge remote-tracking branch 'remotes/origin/dependabot/bundler/web/documentserver-example/ruby/rack-2.2.3.1' into build(deps)/bot-recommendations
# Conflicts:
#	web/documentserver-example/ruby/Gemfile.lock
2022-06-10 16:13:02 +03:00
39129a537e Merge remote-tracking branch 'remotes/origin/dependabot/bundler/web/documentserver-example/ruby/nokogiri-1.13.6' into build(deps)/bot-recommendations
# Conflicts:
#	web/documentserver-example/ruby/Gemfile.lock
2022-06-10 16:07:32 +03:00
dfaf552bf8 ruby-fix - use client URL in goBack 2022-06-09 19:30:43 +03:00
cc8b6f3716 nodejs: directUrl 2022-06-09 13:23:43 +03:00
13726b3c2f nodejs: fix embed link for client request 2022-06-09 13:18:06 +03:00
8bcc15e320 nodejs: remove getlocalFileUri 2022-06-09 13:07:02 +03:00
8fca045dd7 nodejs: fix history url for server request 2022-06-09 12:15:04 +03:00
a018cc5787 Merge remote-tracking branch 'remotes/origin/master' into develop 2022-06-03 11:09:35 +03:00
054236ef8a build(deps): bump rack in /web/documentserver-example/ruby
Bumps [rack](https://github.com/rack/rack) from 2.2.3 to 2.2.3.1.
- [Release notes](https://github.com/rack/rack/releases)
- [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rack/rack/compare/2.2.3...2.2.3.1)

---
updated-dependencies:
- dependency-name: rack
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-27 16:45:08 +00:00
05a3110c99 Remove workflow and disable build nodejs docker (#286)
* Remove workflow and disable build

* Remove Dockerfile
2022-05-27 15:34:59 +03:00
e662c765e6 build(deps): bump gson in /web/documentserver-example/java-spring
Bumps [gson](https://github.com/google/gson) from 2.8.5 to 2.8.9.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.8.5...gson-parent-2.8.9)

---
updated-dependencies:
- dependency-name: com.google.code.gson:gson
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-20 22:07:08 +00:00
058bb0d2e2 build(deps): bump gson in /web/documentserver-example/java
Bumps [gson](https://github.com/google/gson) from 2.8.5 to 2.8.9.
- [Release notes](https://github.com/google/gson/releases)
- [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md)
- [Commits](https://github.com/google/gson/compare/gson-parent-2.8.5...gson-parent-2.8.9)

---
updated-dependencies:
- dependency-name: com.google.code.gson:gson
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-20 20:58:39 +00:00
8bafa3ff3a Add submodule-init (#283) 2022-05-19 17:02:51 +03:00
56679a3b75 Change target repo (#282)
* Change target repo

* Add latest tag
2022-05-19 15:59:11 +03:00
d4d758770f Add docs-example multiarch build (#281)
* Add multiarch build

* Cosmetic changes

* Cosmetic changes
2022-05-19 14:17:28 +03:00
ac78d1fc08 build(deps): bump nokogiri in /web/documentserver-example/ruby
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.3 to 1.13.6.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.3...v1.13.6)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-19 03:44:52 +00:00
874ebff886 Fix the launch of the example container (#279)
* Fix the launch of the example container

* Change the user home directory

* Change the command for create a user
2022-05-16 17:26:24 +03:00
070dac6878 Merge remote-tracking branch 'remotes/origin/master' into develop 2022-05-12 13:22:41 +03:00
4f2f877f0e docxf update 2022-05-12 13:22:15 +03:00
cfa0fb1b74 Merge pull request #278 from ONLYOFFICE/dependabot/maven/web/documentserver-example/java-spring/com.fasterxml.jackson.core-jackson-databind-2.12.6.1
build(deps): bump jackson-databind from 2.12.2 to 2.12.6.1 in /web/documentserver-example/java-spring
2022-04-25 16:57:39 +03:00
1d624e6831 Merge pull request #276 from ONLYOFFICE/dependabot/bundler/web/documentserver-example/ruby/nokogiri-1.13.4
build(deps): bump nokogiri from 1.12.5 to 1.13.4 in /web/documentserver-example/ruby
2022-04-25 16:56:55 +03:00
fe83e98b37 Merge branch 'feature/extension-on-rename' into develop 2022-04-25 14:27:32 +03:00
f9ea7f7b50 nodejs: package lock 2022-04-25 14:27:28 +03:00
328ea46693 format 2022-04-25 14:20:41 +03:00
41ec2742a7 csharp-mvc: with ext 2022-04-25 14:06:27 +03:00
76fc55c2d4 csharp: with ext 2022-04-25 14:04:01 +03:00
e10f3962b6 java: with ext 2022-04-25 13:28:35 +03:00
b9859ef5ca java-spring: with ext 2022-04-25 12:53:28 +03:00
1cb2b586b1 ruby: with ext 2022-04-25 11:45:21 +03:00
e5d31eebbf nodejs: fix 2022-04-25 11:43:52 +03:00
1ac40c539f python: with ext 2022-04-25 11:13:09 +03:00
371366befa nodejs: with ext 2022-04-25 10:41:59 +03:00
0bee4817e7 php: with ext 2022-04-25 09:38:12 +03:00
ad941e0ba4 ruby: fix (23e616aade) 2022-04-20 10:19:34 +03:00
93c69e51ed changelog: offline viewer for anonymous 2022-04-18 15:37:45 +03:00
8b8b7d3938 Merge branch 'feature/liveview' into develop 2022-04-18 15:35:36 +03:00
f8f01a033e nodejs: anonymous without liveview 2022-04-18 15:34:18 +03:00
f497f10913 changelog: anonymous without chat 2022-04-18 15:26:44 +03:00
8b2478ac71 Merge branch 'feature/chat' into develop 2022-04-18 15:25:42 +03:00
391c347419 nodejs: anonymous without permissions.chat 2022-04-18 15:25:04 +03:00
5a08009b7b changelog: zh-TW, pt-PT 2022-04-18 15:24:31 +03:00
4e5b65f673 changelog 2022-04-18 15:23:43 +03:00
13e3d7673b Merge pull request #275 from ONLYOFFICE/feature/new-langs-7.2
added langs
2022-04-18 15:20:53 +03:00
c0a46866ce build(deps): bump nokogiri in /web/documentserver-example/ruby
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.12.5 to 1.13.4.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/v1.13.4/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.12.5...v1.13.4)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-18 11:18:07 +00:00
e7b76729a4 build(deps): bump jackson-databind
Bumps [jackson-databind](https://github.com/FasterXML/jackson) from 2.12.2 to 2.12.6.1.
- [Release notes](https://github.com/FasterXML/jackson/releases)
- [Commits](https://github.com/FasterXML/jackson/commits)

---
updated-dependencies:
- dependency-name: com.fasterxml.jackson.core:jackson-databind
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-18 11:17:36 +00:00
5cc6b4cb15 Merge pull request #277 from ONLYOFFICE/develop
Release/1.2.0
2022-04-18 14:16:23 +03:00
7a70a44bcb 1.2.0 2022-04-18 13:59:07 +03:00
ce2e7f97d6 added langs 2022-04-11 15:28:55 +03:00
e42bd53664 Merge pull request #274 from ONLYOFFICE/feature/languages-fix
languages sort fix
2022-04-11 10:42:55 +03:00
23e616aade languages sort fix 2022-04-11 10:38:26 +03:00
f035da0db4 nodejs: disable X-Powered-By 2022-04-05 15:16:45 +03:00
3e12ec4ebe Merge pull request #272 from ONLYOFFICE/feature/ignore-self-signed-certificate
Feature/ignore self signed certificate
2022-03-30 14:34:02 +03:00
589ca9b601 Merge branch 'develop' into feature/ignore-self-signed-certificate 2022-03-28 16:00:59 +03:00
32f1ec82d1 Merge pull request #271 from ONLYOFFICE/feature/uid-0-fix
Feature/uid 0 fix
2022-03-28 13:26:38 +03:00
54bb5b0a24 format 2022-03-28 13:26:17 +03:00
8274c16f6d Merge pull request #273 from ONLYOFFICE/feature/update-readme
Update README.md
2022-03-28 13:09:24 +03:00
7a982fc785 format 2022-03-28 13:09:13 +03:00
6f5800fbde Updated Readme files in examples 2022-03-28 12:05:45 +03:00
8ec632eebd csharp-mvc: function created 2022-03-28 10:12:46 +03:00
b6ca4535ce csharp: function created 2022-03-28 09:58:59 +03:00
089fc8bfa0 ruby: function created 2022-03-28 09:31:01 +03:00
0b4c17ea0a Update README.md 2022-03-25 17:57:11 +03:00
405be2847b java-spring: ignoring self-signed certificate was added 2022-03-25 16:54:04 +03:00
f809c7e525 python: certificate ignore was added 2022-03-25 13:26:00 +03:00
44061c82a9 csharp-mvc: ignore certificate in config 2022-03-24 11:24:46 +03:00
ef4e283804 csharp: ignore certificate in config 2022-03-24 10:26:31 +03:00
4b0ad1a192 csharp + csharp-mvc 2022-03-23 16:56:41 +03:00
60469b0dba java: ignore certificate in config 2022-03-23 15:39:11 +03:00
f5ac95e1cc nodejs: ignore certificate in config 2022-03-23 15:11:30 +03:00
c4c2fbb945 ruby: certificate was ignored 2022-03-23 14:25:53 +03:00
99b5fcd562 python 2022-03-23 13:29:24 +03:00
7e34067410 java 2022-03-23 12:38:38 +03:00
a44787c625 java-spring 2022-03-23 11:11:03 +03:00
105afb2c34 php 2022-03-23 10:57:33 +03:00
002f9b958e nodejs 2022-03-23 10:53:51 +03:00
56d5913808 ruby 2022-03-23 10:48:28 +03:00
6664864bed nodejs 2022-03-22 13:52:28 +03:00
6c9e6e9304 Merge pull request #268 from ONLYOFFICE/feature/language-update
Feature/language update
2022-03-22 12:21:43 +03:00
416b1fde8c Merge pull request #270 from ONLYOFFICE/feature/hide-history-for-anonymous
Feature/hide history for anonymous
2022-03-22 11:54:12 +03:00
383f240825 Merge pull request #269 from ONLYOFFICE/feature/ban-renaming-for-anonymous
Feature/ban renaming for anonymous
2022-03-22 11:48:57 +03:00
642e145142 php: certificate was ignored 2022-03-22 11:15:09 +03:00
8f09dadfa0 ruby: java-spring: bugfix 2022-03-21 17:10:11 +03:00
495f1cf49a nodejs: split filename 2022-03-21 11:18:30 +03:00
cf01b5e0ae csharp: csharp-mvc: version history button was hidden 2022-03-21 09:38:48 +03:00
0673fed928 java: java-spring: version history button was hidden 2022-03-21 09:35:58 +03:00
9b0b30a0b0 nodejs: version history button was hidden 2022-03-21 09:32:27 +03:00
200187edce python: version history button was hidden 2022-03-21 09:29:32 +03:00
23176ddf07 ruby: version history button was hidden 2022-03-21 09:27:26 +03:00
9857cef8fc php: version history button was hidden 2022-03-21 09:22:31 +03:00
204f770401 java-spring: bugfix 2022-03-18 15:58:02 +03:00
61834e3ec6 Merge branch 'feature/language-update' of github.com:ONLYOFFICE/document-server-integration into feature/language-update 2022-03-18 15:24:45 +03:00
2ca6185ac4 php: bugfix 2022-03-18 15:24:30 +03:00
e818bb978b csharp: removed rename action for anonymous 2022-03-18 15:08:20 +03:00
3a4cf5e6e6 csharp-mvc: removed rename action for anonymous 2022-03-18 15:06:46 +03:00
7ec16b90e3 java: removed rename action for anonymous 2022-03-18 15:04:28 +03:00
fcfb6efda7 java-spring: removed rename action for anonymous 2022-03-18 15:02:45 +03:00
e4c72c98d1 nodejs: removed rename action for anonymous 2022-03-18 14:59:27 +03:00
c2bbda542a python: removed rename action for anonymous 2022-03-18 14:56:17 +03:00
2c12393c78 ruby: removed rename action for anonymous 2022-03-18 14:52:59 +03:00
4e93f6ebac php: fix 2022-03-18 14:47:59 +03:00
d10ba9f773 Merge branch 'develop' into feature/ban-renaming-for-anonymous 2022-03-18 14:40:38 +03:00
a0bf7db118 php: removed rename action 2022-03-18 14:36:46 +03:00
e40e7cc41c csharp-mvc: move languages to config 2022-03-18 11:25:54 +03:00
f616655f4c csharp: move languages to config 2022-03-18 11:14:49 +03:00
4ba708631e Merge pull request #266 from ONLYOFFICE/feature/renaming-files
Feature/renaming files
2022-03-18 10:31:19 +03:00
b9c1bc0f42 java-spring: changing arguments 2022-03-18 09:50:59 +03:00
215ade01a3 java: changing arguments 2022-03-18 09:32:34 +03:00
4d25418fc8 java: move languages to config 2022-03-17 14:05:56 +03:00
4539bac5db Merge pull request #267 from ONLYOFFICE/feature/customization
Feature/customization
2022-03-17 11:10:14 +03:00
eb196613e7 format 2022-03-17 10:36:38 +03:00
7ac788f589 csharp: jwt in body 2022-03-17 10:27:47 +03:00
55119458af java-spring: move languages to config 2022-03-17 10:14:02 +03:00
3c18add1fc Merge remote-tracking branch 'remotes/origin/release/v7.1.0' into develop 2022-03-17 09:56:20 +03:00
6bf63b7166 nodejs: move languages to config 2022-03-16 16:30:56 +03:00
32df2d3e34 php: move languages to config 2022-03-16 15:41:45 +03:00
97c7859db5 ruby: move languages to config 2022-03-16 15:32:47 +03:00
492f9c7baa python: config 2022-03-16 14:58:16 +03:00
e0c0595796 removed chat 2022-03-16 13:06:37 +03:00
40b8fb88a8 Merge branch 'feature/renaming-files' of github.com:ONLYOFFICE/document-server-integration into feature/renaming-files 2022-03-16 11:36:17 +03:00
b0df0d72df java-spring: refactoring 2022-03-16 10:48:43 +03:00
1053add1d9 csharp-mvc: refactoring 2022-03-16 09:47:49 +03:00
f1fc0e5fae csharp: refactoring 2022-03-16 09:38:30 +03:00
a192c6ce1f ruby: refactoring 2022-03-15 18:45:35 +03:00
e8aec0b68c java: php: python: refactoring 2022-03-15 18:10:02 +03:00
d9667f9757 nodejs: fix 2022-03-15 15:17:19 +03:00
3a985da120 Merge branch 'feature/renaming-files' of github.com:ONLYOFFICE/document-server-integration into feature/renaming-files 2022-03-15 14:19:34 +03:00
a88f84ddac nodejs: use commandRequest 2022-03-15 14:19:16 +03:00
6525d7210f micro fix 2022-03-15 13:33:33 +03:00
6b93311ce5 customization change 2022-03-15 13:10:34 +03:00
999561ffd6 Merge branch 'feature/renaming-files' of github.com:ONLYOFFICE/document-server-integration into feature/renaming-files 2022-03-15 10:51:43 +03:00
e539c1205f python: nodejs: jwt fix 2022-03-15 10:51:26 +03:00
9a52a538cb csharp-mvc: jwt fix 2022-03-15 08:24:11 +03:00
e8038a8e88 csharp: jwt fix 2022-03-15 08:18:34 +03:00
1045b314b6 Merge pull request #265 from ONLYOFFICE/bugfix/wopi
fix wopi
2022-03-14 17:50:35 +03:00
1636732521 nodejs: fix userHost in wopi 2022-03-14 17:48:32 +03:00
daa9a5f3fa fix wopi 2022-03-14 15:49:24 +03:00
9bf3973215 csharp-mvc: meta command 2022-03-14 14:00:05 +03:00
cad2a20cdf csharp: meta command 2022-03-14 13:41:12 +03:00
82a5a68e6c java: meta command 2022-03-11 14:59:10 +03:00
0e1a580a86 refactoring 2022-03-11 14:13:09 +03:00
c09f3fc4b9 Merge branch 'feature/renaming-files' of github.com:ONLYOFFICE/document-server-integration into feature/renaming-files 2022-03-11 11:02:39 +03:00
d4d7c4e222 java-spring: meta command 2022-03-11 10:58:54 +03:00
14429c5b05 php: rename refactoring 2022-03-11 09:45:42 +03:00
131e33c6af Merge pull request #264 from ONLYOFFICE/feature/fix-mentions
Feature/fix mentions
2022-03-10 16:19:50 +03:00
8a04e5fbc4 ruby:meta command 2022-03-09 13:50:47 +03:00
1b6435a7dc python:meta command 2022-03-08 10:50:05 +03:00
b8eecab45f nodejs:meta command 2022-03-07 22:01:03 +03:00
f7259409a2 php:jwt 2022-03-04 14:34:50 +03:00
0ea9e68c7c meta command 2022-03-04 11:15:43 +03:00
4b72e0a664 php: add request rename in doceditor + add function renamefile() in webeditor 2022-03-03 14:34:57 +03:00
935377a941 all: fix link in mentions 2022-03-02 17:42:12 +03:00
3690aacb66 nodejs: fix link in mentions 2022-03-02 17:10:41 +03:00
148 changed files with 4814 additions and 1462 deletions

41
CHANGELOG.md Normal file
View File

@ -0,0 +1,41 @@
# Change Log
- nodejs: referenceData
## 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

View File

@ -67,6 +67,15 @@ The methods described below are available for all of the test examples.
| **Response** | **Code:** 200 OK <br />**Content on success:**<br /> `[{ "version": <file_version>, "id": <file_id>, "contentLength": <file_size_in_kilobytes>, "pureContentLength": <file_size_in_bytes>, "title": <file_name>, "updated": <last_change_date>}]`<br />**Content on error:**<br /> `"File not found"` |
| **Sample** | `curl -X GET http://localhost/files/{fileId}` |
## Important security info
Please keep in mind the following security aspects when you are using test examples:
* There is no protection of the storage from unauthorized access since there is no need for authorization.
* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts.
* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server.
* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain.
## Project Information
Official website: [https://www.onlyoffice.com](https://www.onlyoffice.com/?utm_source=github&utm_medium=cpc&utm_campaign=GitHubIntegrationEx)

View File

@ -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

View File

@ -25,6 +25,7 @@ using System.Web;
using System.Web.Configuration;
using System.Web.Script.Serialization;
using OnlineEditorsExampleMVC.Models;
using System.Net;
namespace OnlineEditorsExampleMVC.Helpers
{
@ -241,7 +242,8 @@ namespace OnlineEditorsExampleMVC.Helpers
{
var uri = new UriBuilder(GetServerUrl(forDocumentServer))
{
Path = HttpRuntime.AppDomainAppVirtualPath + "/"
Path = HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ CurUserHostAddress() + "/"
+ fileName,
Query = ""
@ -291,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();
}
@ -311,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
@ -321,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
};
@ -329,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
@ -339,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();
}
@ -416,5 +420,27 @@ namespace OnlineEditorsExampleMVC.Helpers
return files;
}
// enable certificate ignore
public static void VerifySSL()
{
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if(WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("true")) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
}
public static Dictionary<string, string> GetLanguages()
{
var languages = new Dictionary<string, string>();
String[] couples = (WebConfigurationManager.AppSettings["files.docservice.languages"] ?? "").Split('|');
foreach (string couple in couples)
{
String[] tmp = couple.Split(':');
languages.Add(tmp[0],tmp[1]);
}
return languages;
}
}
}

View File

@ -143,6 +143,8 @@ namespace OnlineEditorsExampleMVC.Helpers
requestStream.Write(bytes, 0, bytes.Length); // and write the serialized body object to it
}
DocManagerHelper.VerifySSL();
string dataResponse;
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream()) // get the response stream

View File

@ -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);
}
}
}

View File

@ -76,7 +76,9 @@ namespace OnlineEditorsExampleMVC.Helpers
if (token != null && !token.Equals("")) // invalid signature error
{
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(token)["payload"];
fileData = jss.Deserialize<Dictionary<string, object>>(token);
if (fileData.ContainsKey("payload"))
fileData = (Dictionary<string, object>)fileData["payload"];
}
else
{
@ -126,6 +128,8 @@ namespace OnlineEditorsExampleMVC.Helpers
}
}
DocManagerHelper.VerifySSL();
var storagePath = DocManagerHelper.StoragePath(newFileName, userAddress); // get the file path
var histDir = DocManagerHelper.HistoryDir(storagePath); // get the path to the history directory
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
@ -201,6 +205,8 @@ namespace OnlineEditorsExampleMVC.Helpers
}
}
DocManagerHelper.VerifySSL();
string forcesavePath = "";
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
@ -243,8 +249,10 @@ namespace OnlineEditorsExampleMVC.Helpers
}
// create a command request
public static void commandRequest(string method, string key)
public static void commandRequest(string method, string key, object meta = null)
{
DocManagerHelper.VerifySSL();
string documentCommandUrl = WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.command"];
var request = (HttpWebRequest)WebRequest.Create(documentCommandUrl);
@ -256,6 +264,11 @@ namespace OnlineEditorsExampleMVC.Helpers
{ "key", key }
};
if (meta != null)
{
body.Add("meta", meta);
}
// check if a secret key to generate token exists or not
if (JwtManager.Enabled)
{

View File

@ -66,7 +66,10 @@ namespace OnlineEditorsExampleMVC.Helpers
"The file favorite state is undefined",
"Can't mention others in comments",
"Can't create new files from the editor",
"Cant see anyones information"
"Cant see anyones information",
"Can't rename files from the editor",
"Can't view chat",
"View file without collaboration",
};
private static List<User> users = new List<User>() {

View File

@ -97,6 +97,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 +126,7 @@ namespace OnlineEditorsExampleMVC.Models
{
{ "title", FileName },
{ "url", DownloadUrl },
{ "directUrl", directUrl },
{ "fileType", ext.Trim('.') },
{ "key", Key },
{
@ -148,6 +150,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 +165,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 +185,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)
}
},
@ -188,13 +196,14 @@ namespace OnlineEditorsExampleMVC.Models
"customization", new Dictionary<string, object>
{
{ "about", true }, // the About section display
{ "comments", true },
{ "feedback", true }, // the Feedback & Support menu button display
{ "forcesave", false }, // adds the request for the forced file saving to the callback handler
{ "submitForm", submitForm }, // if the Submit form button is displayed or not
{
"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
}
}
}
@ -261,17 +270,23 @@ 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);
dataObj.Add("directUrl", directPrevFileUrl);
dataObj.Add("version", i);
if (i > 1) // check if the version number is greater than 1 (the file was modified)
{
@ -293,6 +308,7 @@ namespace OnlineEditorsExampleMVC.Models
{ "fileType", prev["fileType"] },
{ "key", prev["key"] }, // write key and url information about previous file version
{ "url", prev["url"] },
{ "directUrl", prev["directUrl"] },
});
// write the path to the diff.zip archive with differences in this file version
var changesUrl = DocManagerHelper.GetHistoryDownloadUrl(FileName, (i - 1).ToString(), "diff.zip");
@ -331,11 +347,20 @@ 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>
{
{ "fileType", "docx" },
{ "url", compareFileUrl.ToString() }
{ "url", compareFileUrl.ToString() },
{ "directUrl", directCompareFileUrl.ToString()}
};
if (JwtManager.Enabled) // if the secret key to generate token exists
@ -360,11 +385,19 @@ 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>
{
{ "fileType", "png"},
{ "url", mailMergeUrl.ToString()}
{ "url", mailMergeUrl.ToString()},
{ "directUrl", directMailMergeUrl.ToString()}
};
if (JwtManager.Enabled) // if the secret key to generate token exists
@ -391,11 +424,21 @@ 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>
{
{ "fileType", "csv" },
{ "url", mailMergeUrl.ToString()}
{ "url", mailMergeUrl.ToString()},
{ "directUrl", directMailMergeUrl.ToString()}
};
if (JwtManager.Enabled) // if the secret key to generate token exists

View File

@ -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" />

View File

@ -70,3 +70,12 @@ Configure the IIS components for the server to work correctly:
In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files.
Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files.
## Important security info
Please keep in mind the following security aspects when you are using test examples:
* There is no protection of the storage from unauthorized access since there is no need for authorization.
* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts.
* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server.
* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain.

View File

@ -46,6 +46,7 @@
<script type="text/javascript" language="javascript">
var docEditor;
var config;
var innerAlert = function (message, inEditor) {
if (console && console.log)
@ -107,10 +108,14 @@
// the meta information of the document is changed via the meta command
var onMetaChange = function (event) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
if (event.data.favorite) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
}
innerAlert("onMetaChange: " + JSON.stringify(event.data));
};
// the user is trying to insert an image by clicking the Image from Storage button
@ -146,7 +151,7 @@
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "webeditor.ashx?type=saveas");
xhr.setRequestHeader( 'Content-Type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
@ -154,7 +159,26 @@
}
};
var config = <%= Model.GetDocConfig(Request, Url) %>;
var onRequestRename = function(event) { // the user is trying to rename file by clicking Rename... button
innerAlert("onRequestRename: " + JSON.stringify(event.data));
var newfilename = event.data;
var data = {
newfilename: newfilename,
dockey: config.document.key,
ext: config.document.fileType
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "webeditor.ashx?type=rename");
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
}
};
config = <%= Model.GetDocConfig(Request, Url) %>;
config.width = "100%";
config.height = "100%";
@ -174,42 +198,49 @@
<% string hist, histData; %>
<% Model.GetHistory(out hist, out histData); %>
<% if (!string.IsNullOrEmpty(hist) && !string.IsNullOrEmpty(histData))
{ %>
// the user is trying to show the document version history
config.events['onRequestHistory'] = function () {
docEditor.refreshHistory(<%= hist %>); // show the document version history
};
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = <%= histData %>;
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
};
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose '] = function () {
document.location.reload();
};
<% } %>
<% string usersForMentions; %>
<% Model.GetUsersMentions(Request, out usersForMentions); %>
<% if (!string.IsNullOrEmpty(usersForMentions))
// add mentions for not anonymous users
{ %>
config.events['onRequestUsers'] = function () {
docEditor.setUsers({ // set a list of users to mention in the comments
"users": <%= usersForMentions%>
});
};
// the user is mentioned in a comment
config.events['onRequestSendNotify'] = function (event) {
event.data.actionLink = replaceActionLink(location.href, event.data.actionLink);
var data = JSON.stringify(event.data);
innerAlert("onRequestSendNotify: " + data);
};
<% } %>
if (config.editorConfig.user.id) {
<% if (!string.IsNullOrEmpty(hist) && !string.IsNullOrEmpty(histData))
{ %>
// the user is trying to show the document version history
config.events['onRequestHistory'] = function () {
docEditor.refreshHistory(<%= hist %>); // show the document version history
};
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = <%= histData %>;
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
};
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose '] = function () {
document.location.reload();
};
<% } %>
// add mentions for not anonymous users
<% if (!string.IsNullOrEmpty(usersForMentions))
{ %>
config.events['onRequestUsers'] = function () {
docEditor.setUsers({ // set a list of users to mention in the comments
"users": <%= usersForMentions %>
});
};
<% } %>
// the user is mentioned in a comment
config.events['onRequestSendNotify'] = function (event) {
event.data.actionLink = replaceActionLink(location.href, JSON.stringify(event.data.actionLink));
var data = JSON.stringify(event.data);
innerAlert("onRequestSendNotify: " + data);
};
// prevent file renaming for anonymous users
config.events['onRequestRename'] = onRequestRename;
}
if (config.editorConfig.createUrl) {
config.events.onRequestSaveAs = onRequestSaveAs;
};

View File

@ -4,6 +4,7 @@
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="OnlineEditorsExampleMVC.Helpers" %>
<%@ Import Namespace="OnlineEditorsExampleMVC.Models" %>
<%@ Import Namespace="System.Collections.Generic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -89,7 +90,7 @@
<select class="select-user" id="user">
<% foreach (User user in Users.getAllUsers())
{ %>
<option value=<%= user.id %> ><%= user.name.IsEmpty() ? "Anonymous" : user.name %></option>
<option value="<%= user.id %>"><%= user.name.IsEmpty() ? "Anonymous" : user.name %></option>
<% } %>
</select>
</td>
@ -98,37 +99,11 @@
<td valign="middle">
<span class="select-user">Language editors interface</span>
<select class="select-user" id="language">
<option value="en">English</option>
<option value="be">Belarusian</option>
<option value="bg">Bulgarian</option>
<option value="ca">Catalan</option>
<option value="zh">Chinese</option>
<option value="cs">Czech</option>
<option value="da">Danish</option>
<option value="nl">Dutch</option>
<option value="fi">Finnish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="el">Greek</option>
<option value="hu">Hungarian</option>
<option value="id">Indonesian</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="lv">Latvian</option>
<option value="lo">Lao</option>
<option value="nb">Norwegian</option>
<option value="pl">Polish</option>
<option value="pt">Portuguese</option>
<option value="ro">Romanian</option>
<option value="ru">Russian</option>
<option value="sk">Slovak</option>
<option value="sl">Slovenian</option>
<option value="sv">Swedish</option>
<option value="es">Spanish</option>
<option value="tr">Turkish</option>
<option value="uk">Ukrainian</option>
<option value="vi">Vietnamese</option>
<% Dictionary<string, string> languages = DocManagerHelper.GetLanguages();
foreach (var lang in languages)
{ %>
<option value="<%= lang.Key %>"><%= lang.Value %></option>
<% } %>
</select>
</td>
</tr>
@ -188,7 +163,7 @@
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">
<span><%= storedFile.Name %></span>

View File

@ -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>

View File

@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using System.Net;
using System.Web;
@ -70,6 +71,9 @@ namespace OnlineEditorsExampleMVC
case "saveas":
SaveAs(context);
break;
case "rename":
Rename(context);
break;
}
}
@ -113,6 +117,8 @@ namespace OnlineEditorsExampleMVC
var req = (HttpWebRequest)WebRequest.Create(fileUrl);
DocManagerHelper.VerifySSL();
using (var stream = req.GetResponse().GetResponseStream())
{
@ -151,6 +157,8 @@ namespace OnlineEditorsExampleMVC
context.Response.ContentType = "text/plain";
try
{
DocManagerHelper.VerifySSL();
var httpPostedFile = context.Request.Files[0];
string fileName;
@ -250,6 +258,8 @@ namespace OnlineEditorsExampleMVC
var req = (HttpWebRequest)WebRequest.Create(newFileUri);
DocManagerHelper.VerifySSL();
using (var stream = req.GetResponse().GetResponseStream()) // get response stream of the converting file
{
if (stream == null) throw new Exception("Stream is null");
@ -541,5 +551,44 @@ namespace OnlineEditorsExampleMVC
context.Response.Write("{ \"error\": \"File not found!\"}");
}
}
// rename a file
private static void Rename(HttpContext context)
{
// read request body
context.Response.ContentType = "text/plain";
string fileData;
try
{
using (var receiveStream = context.Request.InputStream)
using (var readStream = new StreamReader(receiveStream))
{
fileData = readStream.ReadToEnd();
if (string.IsNullOrEmpty(fileData)) context.Response.Write("{\"error\":\"Request stream is empty\"}");
}
}
catch (Exception e)
{
throw new HttpException((int)HttpStatusCode.BadRequest, e.Message);
}
var jss = new JavaScriptSerializer();
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 }
};
TrackManager.commandRequest("meta", docKey, meta);
context.Response.Write("{ \"result\": \"OK\"}");
}
}
}

View File

@ -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

View 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

View File

@ -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>

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<?xml version="1.0"?>
<appSettings>
<clear />
<add key="version" value="1.1.0"/>
<add key="version" value="1.4.0"/>
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>
@ -14,6 +14,10 @@
<add key="files.docservice.secret" value="" />
<add key="files.docservice.header" value="Authorization" />
<add key="files.docservice.verify-peer-off" value="true"/>
<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"/>
<add key="files.docservice.url.site" value="http://documentserver/"/>
<add key="files.docservice.url.converter" value="ConvertService.ashx"/>

View File

@ -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

View File

@ -5,6 +5,7 @@
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="System.Web.Configuration" %>
<%@ Import Namespace="OnlineEditorsExample" %>
<%@ Import Namespace="System.Collections.Generic" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -100,37 +101,11 @@
<td valign="middle">
<span class="select-user">Language editors interface</span>
<select class="select-user" id="language">
<option value="en">English</option>
<option value="be">Belarusian</option>
<option value="bg">Bulgarian</option>
<option value="ca">Catalan</option>
<option value="zh">Chinese</option>
<option value="cs">Czech</option>
<option value="da">Danish</option>
<option value="nl">Dutch</option>
<option value="fi">Finnish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="el">Greek</option>
<option value="hu">Hungarian</option>
<option value="id">Indonesian</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="lv">Latvian</option>
<option value="lo">Lao</option>
<option value="nb">Norwegian</option>
<option value="pl">Polish</option>
<option value="pt">Portuguese</option>
<option value="ro">Romanian</option>
<option value="ru">Russian</option>
<option value="sk">Slovak</option>
<option value="sl">Slovenian</option>
<option value="sv">Swedish</option>
<option value="es">Spanish</option>
<option value="tr">Turkish</option>
<option value="uk">Ukrainian</option>
<option value="vi">Vietnamese</option>
<% Dictionary<string, string> languages = GetLanguages();
foreach (var lang in languages)
{ %>
<option value="<%= lang.Key %>"><%= lang.Value %></option>
<% } %>
</select>
</td>
</tr>
@ -190,7 +165,7 @@
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>

View File

@ -353,11 +353,7 @@ namespace OnlineEditorsExample
try
{
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
VerifySSL();
using (var stream = req.GetResponse().GetResponseStream()) // get response stream of the uploading file
{
@ -420,11 +416,7 @@ namespace OnlineEditorsExample
var req = (HttpWebRequest)WebRequest.Create(fileUrl);
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
VerifySSL();
using (var stream = req.GetResponse().GetResponseStream())
{
@ -493,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;
@ -508,11 +500,7 @@ namespace OnlineEditorsExample
var req = (HttpWebRequest)WebRequest.Create(newFileUri);
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
VerifySSL();
using (var stream = req.GetResponse().GetResponseStream()) // get response stream of the converting file
{
@ -616,5 +604,27 @@ namespace OnlineEditorsExample
return files;
}
// enable certificate ignore
public static void VerifySSL()
{
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if(WebConfigurationManager.AppSettings["files.docservice.verify-peer-off"].Equals("true")) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
}
}
public static Dictionary<string, string> GetLanguages()
{
var languages = new Dictionary<string, string>();
String[] couples = (WebConfigurationManager.AppSettings["files.docservice.languages"] ?? "").Split('|');
foreach (string couple in couples)
{
String[] tmp = couple.Split(':');
languages.Add(tmp[0],tmp[1]);
}
return languages;
}
}
}

View File

@ -64,6 +64,7 @@
<script type="text/javascript" language="javascript">
var docEditor;
var config;
var innerAlert = function (message, inEditor) {
if (console && console.log)
@ -125,10 +126,14 @@
// the meta information of the document is changed via the meta command
var onMetaChange = function (event) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
if (event.data.favorite) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
}
innerAlert("onMetaChange: " + JSON.stringify(event.data));
};
// the user is trying to insert an image by clicking the Image from Storage button
@ -158,7 +163,7 @@
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "webeditor.ashx?type=saveas");
xhr.setRequestHeader( 'Content-Type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
@ -166,7 +171,26 @@
}
};
var config = <%= DocConfig %>;
var onRequestRename = function(event) { // the user is trying to rename file by clicking Rename... button
innerAlert("onRequestRename: " + JSON.stringify(event.data));
var newfilename = event.data;
var data = {
newfilename: newfilename,
dockey: config.document.key,
ext: config.document.fileType
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "webeditor.ashx?type=rename");
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
}
};
config = <%= DocConfig %>;
config.width = "100%";
config.height = "100%";
@ -184,37 +208,42 @@
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
};
<% if (!string.IsNullOrEmpty(History) && !string.IsNullOrEmpty(HistoryData))
{ %>
config.events['onRequestHistory'] = function () { // the user is trying to show the document version history
docEditor.refreshHistory(<%= History %>); // show the document version history
};
config.events['onRequestHistoryData'] = function (event) { // the user is trying to click the specific document version in the document version history
var ver = event.data;
var histData = <%= HistoryData %>;
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
};
config.events['onRequestHistoryClose '] = function () { // the user is trying to go back to the document from viewing the document version history
document.location.reload();
};
<% } %>
if (config.editorConfig.user.id) {
<% if (!string.IsNullOrEmpty(History) && !string.IsNullOrEmpty(HistoryData))
{ %>
config.events['onRequestHistory'] = function () { // the user is trying to show the document version history
docEditor.refreshHistory(<%= History %>); // show the document version history
};
config.events['onRequestHistoryData'] = function (event) { // the user is trying to click the specific document version in the document version history
var ver = event.data;
var histData = <%= HistoryData %>;
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
};
config.events['onRequestHistoryClose '] = function () { // the user is trying to go back to the document from viewing the document version history
document.location.reload();
};
<% } %>
// add mentions for not anonymous users
<% if (!string.IsNullOrEmpty(UsersForMentions))
{ %>
config.events['onRequestUsers'] = function () {
docEditor.setUsers({ // set a list of users to mention in the comments
"users": <%= UsersForMentions %>
});
};
<% } %>
// the user is mentioned in a comment
config.events['onRequestSendNotify'] = function (event) {
event.data.actionLink = replaceActionLink(location.href, JSON.stringify(event.data.actionLink));
var data = JSON.stringify(event.data);
innerAlert("onRequestSendNotify: " + data);
};
// prevent file renaming for anonymous users
config.events['onRequestRename'] = onRequestRename;
}
<% if (!string.IsNullOrEmpty(UsersForMentions))
{ %>
// add mentions for not anonymous users
config.events['onRequestUsers'] = function () {
docEditor.setUsers({ // set a list of users to mention in the comments
"users": <%= UsersForMentions %>
});
};
// the user is mentioned in a comment
config.events['onRequestSendNotify'] = function (event) {
event.data.actionLink = replaceActionLink(location.href, event.data.actionLink);
var data = JSON.stringify(event.data);
innerAlert("onRequestSendNotify: " + data);
};
<% } %>
if (config.editorConfig.createUrl) {
config.events.onRequestSaveAs = onRequestSaveAs;
};

62
web/documentserver-example/csharp/DocEditor.aspx.cs Normal file → Executable file
View File

@ -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", 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)
}
},
@ -256,6 +265,7 @@ namespace OnlineEditorsExample
"customization", new Dictionary<string, object>
{
{ "about", true }, // the About section display
{ "comments", true },
{ "feedback", true }, // the Feedback & Support menu button display
{ "forcesave", false }, // adds the request for the forced file saving to the callback handler
{ "submitForm", submitForm }, // if the Submit form button is displayed or not
@ -358,13 +368,16 @@ 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
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)
{
@ -386,6 +399,7 @@ namespace OnlineEditorsExample
{ "fileType", prev["fileType"] },
{ "key", prev["key"] }, // write key and url information about previous file version
{ "url", prev["url"] },
{ "directUrl", prev["directUrl"] },
});
// write the path to the diff.zip archive with differences in this file version
var changesUrl = MakePublicHistoryUrl(FileName, (i - 1).ToString(), "diff.zip");
@ -419,11 +433,17 @@ 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>
{
{ "fileType", "png"},
{ "url", InsertImageUrl.ToString()}
{ "url", InsertImageUrl.ToString()},
{ "directUrl", DirectImageUrl.ToString()}
};
if (JwtManager.Enabled) // if the secret key to generate token exists
@ -445,11 +465,18 @@ 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>
{
{ "fileType", "docx" },
{ "url", compareFileUrl.ToString() }
{ "url", compareFileUrl.ToString() },
{ "directUrl", DirectFileUrl.ToString() }
};
if (JwtManager.Enabled) // if the secret key to generate token exists
@ -472,11 +499,19 @@ 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>
{
{ "fileType", "csv" },
{ "url", mailmergeUrl.ToString() }
{ "url", mailmergeUrl.ToString() },
{ "directUrl", DirectMailMergeUrl.ToString() }
};
if (JwtManager.Enabled) // if the secret key to generate token exists
@ -520,15 +555,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();
}

View File

@ -145,11 +145,7 @@ namespace ASC.Api.DocumentConverter
requestStream.Write(bytes, 0, bytes.Length); // and write the serialized body object to it
}
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (_Default.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
_Default.VerifySSL();
string dataResponse;
using (var response = request.GetResponse())

View File

@ -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);
}
}
}

View File

@ -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" />

View File

@ -72,3 +72,12 @@ Configure the IIS components for the server to work correctly:
In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files.
Make sure that the Document Server in its turn has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files.
## Important security info
Please keep in mind the following security aspects when you are using test examples:
* There is no protection of the storage from unauthorized access since there is no need for authorization.
* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts.
* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server.
* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain.

View File

@ -78,7 +78,9 @@ namespace OnlineEditorsExample
if (token != null && !token.Equals("")) // invalid signature error
{
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(token)["payload"];
fileData = jss.Deserialize<Dictionary<string, object>>(token);
if (fileData.ContainsKey("payload"))
fileData = (Dictionary<string, object>)fileData["payload"];
}
else
{
@ -128,11 +130,7 @@ namespace OnlineEditorsExample
}
}
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (_Default.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
_Default.VerifySSL();
var storagePath = _Default.StoragePath(newFileName, userAddress); // get the file path
var histDir = _Default.HistoryDir(storagePath); // get the path to the history directory
@ -209,11 +207,7 @@ namespace OnlineEditorsExample
}
}
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (_Default.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
_Default.VerifySSL();
string forcesavePath = "";
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3"); // SubmitForm
@ -258,8 +252,10 @@ namespace OnlineEditorsExample
}
// create a command request
public static void commandRequest(string method, string key)
public static void commandRequest(string method, string key, object meta = null)
{
_Default.VerifySSL();
string documentCommandUrl = WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.command"];
var request = (HttpWebRequest)WebRequest.Create(documentCommandUrl);
@ -271,13 +267,18 @@ namespace OnlineEditorsExample
{ "key", key }
};
if (meta != null)
{
body.Add("meta", meta);
}
// check if a secret key to generate token exists or not
if (JwtManager.Enabled)
{
var payload = new Dictionary<string, object>
{
{ "payload", body }
};
{
{ "payload", body }
};
var payloadToken = JwtManager.Encode(payload); // encode a payload object into a header token
var bodyToken = JwtManager.Encode(body); // encode body into a body token

View File

@ -65,7 +65,10 @@ namespace OnlineEditorsExample
"The file favorite state is undefined",
"Can't mention others in comments",
"Can't create new files from the editor",
"Cant see anyones information"
"Cant see anyones information",
"Can't rename files from the editor",
"Can't view chat",
"View file without collaboration",
};
private static List<User> users = new List<User>() {

View File

@ -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>

View File

@ -68,6 +68,9 @@ namespace OnlineEditorsExample
case "saveas":
SaveAs(context);
break;
case "rename":
Rename(context);
break;
}
}
@ -204,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
@ -368,5 +371,43 @@ namespace OnlineEditorsExample
context.Response.Write("{ \"error\": \"File not found!\"}");
}
}
// rename a file
private static void Rename(HttpContext context)
{
string fileData;
try
{
using (var receiveStream = context.Request.InputStream)
using (var readStream = new StreamReader(receiveStream))
{
fileData = readStream.ReadToEnd();
if (string.IsNullOrEmpty(fileData)) return;
}
}
catch (Exception e)
{
throw new HttpException((int)HttpStatusCode.BadRequest, e.Message);
}
var jss = new JavaScriptSerializer();
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 }
};
TrackManager.commandRequest("meta", docKey, meta);
context.Response.Write("{ \"result\": \"OK\"}");
}
}
}

View File

@ -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

View 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

View File

@ -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.

View File

@ -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>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<clear />
<add key="version" value="1.1.0"/>
<add key="version" value="1.4.0"/>
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>
@ -13,6 +13,9 @@
<add key="files.docservice.timeout" value="120000" />
<add key="files.docservice.secret" value="" />
<add key="files.docservice.header" value="Authorization" />
<add key="files.docservice.verify-peer-off" value="true"/>
<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"/>
<add key="files.docservice.url.site" value="http://documentserver/"/>

View File

@ -236,3 +236,12 @@ Make sure that the Document Server has access to the server with the example ins
```
http://server.address:server.port/
```
## Important security info
Please keep in mind the following security aspects when you are using test examples:
* There is no protection of the storage from unauthorized access since there is no need for authorization.
* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts.
* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server.
* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain.

4
web/documentserver-example/java-spring/pom.xml Executable file → Normal file
View 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>
@ -64,7 +64,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.2</version>
<version>2.12.6.1</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>

View File

@ -41,7 +41,10 @@ public class ExampleData {
"The file favorite state is undefined",
"Can't mention others in comments",
"Can't create new files from the editor",
"Cant see anyones information"
"Cant see anyones information",
"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",
@ -50,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",
@ -58,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 dont belong to any group"
"Can see the information about users from Group2 and users who dont belong to any group",
"Can view chat"
);
List<String> description_user_3 = List.of( // the description for user 3
"He belongs to Group3",
@ -69,7 +74,8 @@ public class ExampleData {
"He cant download the file",
"He cant 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()),
@ -77,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);
}
}

View File

@ -30,15 +30,23 @@ import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import com.onlyoffice.integration.documentserver.util.SSLUtils;
@Configuration
public class IntegrationConfiguration {
@Value("${files.storage}")
private String storageAddress;
@Value("${files.docservice.verify-peer-off}")
private String verifyPerrOff;
@Autowired
private FileStoragePathBuilder storagePathBuilder;
@Autowired
private SSLUtils ssl;
@Bean
public ModelMapper mapper(){ // create the model mapper
ModelMapper mapper = new ModelMapper();
@ -58,6 +66,17 @@ public class IntegrationConfiguration {
@PostConstruct
public void init(){ // initialize the storage path builder
storagePathBuilder.configure(storageAddress.isBlank() ? null : storageAddress);
if(!verifyPerrOff.isEmpty()) {
try{
if(verifyPerrOff.equals("true")) {
ssl.turnOffSslChecking(); //the certificate will be ignored
} else {
ssl.turnOnSslChecking(); //the certificate will be verified
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
@Bean

View File

@ -138,6 +138,7 @@ public class EditorController {
Map<String, Object> dataInsertImage = new HashMap<>();
dataInsertImage.put("fileType", "png");
dataInsertImage.put("url", storagePathBuilder.getServerUrl(true) + "/css/img/logo.png");
dataInsertImage.put("directUrl", storagePathBuilder.getServerUrl(false) + "/css/img/logo.png");
// check if the document token is enabled
if(jwtManager.tokenEnabled()){
@ -152,6 +153,7 @@ public class EditorController {
Map<String, Object> dataCompareFile = new HashMap<>();
dataCompareFile.put("fileType", "docx");
dataCompareFile.put("url", storagePathBuilder.getServerUrl(true) + "/assets?name=sample.docx");
dataCompareFile.put("directUrl", storagePathBuilder.getServerUrl(false) + "/assets?name=sample.docx");
// check if the document token is enabled
if(jwtManager.tokenEnabled()){
@ -166,6 +168,7 @@ public class EditorController {
Map<String, Object> dataMailMergeRecipients = new HashMap<>(); // get recipients data for mail merging
dataMailMergeRecipients.put("fileType", "csv");
dataMailMergeRecipients.put("url", storagePathBuilder.getServerUrl(true) + "/csv");
dataMailMergeRecipients.put("directUrl", storagePathBuilder.getServerUrl(false) + "/csv");
// check if the document token is enabled
if(jwtManager.tokenEnabled()){

View File

@ -31,6 +31,7 @@ import com.onlyoffice.integration.services.UserServices;
import com.onlyoffice.integration.documentserver.util.file.FileUtility;
import com.onlyoffice.integration.documentserver.util.service.ServiceConverter;
import com.onlyoffice.integration.documentserver.managers.document.DocumentManager;
import com.onlyoffice.integration.documentserver.managers.callback.CallbackManager;
import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -61,6 +62,12 @@ public class FileController {
@Value("${filesize-max}")
private String filesizeMax;
@Value("${files.docservice.url.site}")
private String docserviceUrlSite;
@Value("${files.docservice.url.command}")
private String docserviceUrlCommand;
@Autowired
private FileUtility fileUtility;
@Autowired
@ -79,6 +86,8 @@ public class FileController {
private ObjectMapper objectMapper;
@Autowired
private ServiceConverter serviceConverter;
@Autowired
private CallbackManager callbackManager;
// create user metadata
private String createUserMetadata(String uid, String fullFileName) {
@ -155,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)
@ -356,4 +365,32 @@ public class FileController {
return "{ \"error\" : 1, \"message\" : \"" + e.getMessage() + "\"}";
}
}
@PostMapping("/rename")
@ResponseBody
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);
try {
callbackManager.commandRequest("meta", dockey, meta);
return "result ok";
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
}

View File

@ -64,6 +64,9 @@ public class IndexController {
@Value("${url.editor}")
private String urlEditor;
@Value("${files.docservice.languages}")
private String langs;
@GetMapping("${url.index}")
public String index(Model model){
java.io.File[] files = storageMutator.getStoredFiles(); // get all the stored files from the storage
@ -71,6 +74,14 @@ public class IndexController {
List<Boolean> filesEditable = new ArrayList<>();
List<String> versions = new ArrayList<>();
List<Boolean> isFillFormDoc = new ArrayList<>();
List<String> langsAndKeys = Arrays.asList(langs.split("\\|"));
Map<String, String> languages = new LinkedHashMap<>();
langsAndKeys.forEach((str) -> {
String[] couple = str.split(":");
languages.put(couple[0], couple[1]);
});
List<User> users = userService.findAll(); // get a list of all the users
@ -95,6 +106,7 @@ public class IndexController {
model.addAttribute("datadocs", docserviceSite+docservicePreloader);
model.addAttribute("tooltip", tooltip);
model.addAttribute("users", users);
model.addAttribute("languages", languages);
return "index.html";
}

View File

@ -39,7 +39,7 @@ public class EditCallback implements Callback {
if (!body.getUsers().contains(user)) { // if this user is not specified in the body
String key = body.getKey(); // get document key
try {
callbackManager.commandRequest("forcesave", key); // create a command request to forcibly save the document being edited without closing it
callbackManager.commandRequest("forcesave", key, null); // create a command request to forcibly save the document being edited without closing it
} catch (Exception e) {
e.printStackTrace();
result = 1;

View File

@ -19,9 +19,10 @@
package com.onlyoffice.integration.documentserver.managers.callback;
import com.onlyoffice.integration.dto.Track;
import java.util.HashMap;
public interface CallbackManager { // specify the callback manager functions
void processSave(Track body, String fileName); // file saving process
void commandRequest(String method, String key); // create a command request
void commandRequest(String method, String key, HashMap meta); // create a command request
void processForceSave(Track body, String fileName); // file force saving process
}

View File

@ -153,16 +153,20 @@ public class DefaultCallbackManager implements CallbackManager {
//TODO: Replace (String method) with (Enum method)
@SneakyThrows
public void commandRequest(String method, String key) { // create a command request
public void commandRequest(String method, String key, HashMap meta) { // create a command request
String DocumentCommandUrl = docserviceUrlSite + docserviceUrlCommand;
URL url = new URL(DocumentCommandUrl);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
HashMap<String, Object> params = new HashMap<>();
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("c", method);
params.put("key", key);
if (meta != null) {
params.put("meta", meta);
}
String headerToken;
if (jwtManager.tokenEnabled()) // check if a secret key to generate token exists or not
{

View File

@ -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;
}

View File

@ -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

View File

@ -91,6 +91,8 @@ 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));
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 +111,7 @@ 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"));
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;

View File

@ -34,7 +34,6 @@ public class Customization { // the parameters which allow to customize the edi
@Autowired
private Goback goback; // the settings for the Open file location menu button and upper right corner button
private Boolean autosave = true; // if the Autosave menu option is enabled or disabled
private Boolean chat = true; // if the Chat menu button is displayed or hidden
private Boolean comments = true; // if the Comments menu button is displayed or hidden
private Boolean compactHeader = false; // if the additional action buttons are displayed in the upper part of the editor window header next to the logo (false) or in the toolbar (true)
private Boolean compactToolbar = false; // if the top toolbar type displayed is full (false) or compact (true)

View File

@ -25,6 +25,7 @@ public enum Action {
embedded,
filter,
comment,
chat,
fillForms,
blockcontent
}

View File

@ -49,5 +49,7 @@ public enum Language {
es,
tr,
uk,
vi
vi,
gl,
az
}

View File

@ -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;
}

View File

@ -38,6 +38,7 @@ 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

View File

@ -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

View File

@ -0,0 +1,59 @@
package com.onlyoffice.integration.documentserver.util;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.springframework.stereotype.Component;
/**
* Disables and enables certificate and host-name checking in
* HttpsURLConnection, the default JVM implementation of the HTTPS/TLS protocol.
* Has no effect on implementations such as Apache Http Client, Ok Http.
*/
@Component
public final class SSLUtils {
private final HostnameVerifier jvmHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
private final HostnameVerifier trivialHostnameVerifier = new HostnameVerifier() {
public boolean verify(String hostname, SSLSession sslSession) {
return true;
}
};
private final TrustManager[] UNQUESTIONING_TRUST_MANAGER = new TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(X509Certificate[] certs, String authType) {
}
} };
public void turnOffSslChecking() throws NoSuchAlgorithmException, KeyManagementException {
HttpsURLConnection.setDefaultHostnameVerifier(trivialHostnameVerifier);
// Install the all-trusting trust manager
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, UNQUESTIONING_TRUST_MANAGER, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
public void turnOnSslChecking() throws KeyManagementException, NoSuchAlgorithmException {
HttpsURLConnection.setDefaultHostnameVerifier(jvmHostnameVerifier);
// Return it to the initial state (discovered by reflection, now hardcoded)
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, null, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
}

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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(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

View File

@ -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)

View File

@ -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)

View File

@ -1,4 +1,4 @@
server.version=1.1.0
server.version=1.4.0
server.address=
server.port=4000
@ -25,6 +25,10 @@ files.docservice.url.example=
files.docservice.secret=
files.docservice.header=Authorization
files.docservice.verify-peer-off=true
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
spring.datasource.url=jdbc:h2:mem:usersdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa

View File

@ -72,6 +72,7 @@ header img {
}
.main{
display: table;
height: calc(100% - 112px);
min-height: 536px;
}

View File

@ -30,6 +30,7 @@
<script th:inline="javascript">
var docEditor;
var config;
var innerAlert = function (message, inEditor) {
if (console && console.log)
@ -90,10 +91,13 @@
// the meta information of the document is changed via the meta command
var onMetaChange = function (event) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite);
if (event.data.favorite) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite);
}
innerAlert("onMetaChange: " + JSON.stringify(event.data));
};
@ -115,7 +119,7 @@
docEditor.setMailMergeRecipients([[${dataMailMergeRecipients}]]);
};
var config = [[${model}]];
config = [[${model}]];
if (config.editorConfig.user.name == "Anonymous") {
config.editorConfig.user.name = "";
@ -130,7 +134,7 @@
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "saveas");
xhr.setRequestHeader( 'Content-Type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
@ -138,6 +142,24 @@
}
};
var onRequestRename = function(event) { // the user is trying to rename file by clicking Rename... button
innerAlert("onRequestRename: " + JSON.stringify(event.data));
var newfilename = event.data;
var data = {
newfilename: newfilename,
dockey: config.document.key,
ext: config.document.fileType
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "rename");
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
}
};
config.width = "100%";
config.height = "100%";
config.events = {
@ -158,24 +180,23 @@
var historyData = histArray[1];
var usersForMentions = [[${usersForMentions}]];
if (hist && historyData) {
// the user is trying to show the document version history
config.events['onRequestHistory'] = function () {
docEditor.refreshHistory(JSON.parse(hist)); // show the document version history
};
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = historyData;
docEditor.setHistoryData(JSON.parse(histData)[ver - 1]); // send the link to the document for viewing the version history
};
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose'] = function () {
document.location.reload();
};
}
if(usersForMentions){
if (config.editorConfig.user.id != 4) {
if (hist && historyData) {
// the user is trying to show the document version history
config.events['onRequestHistory'] = function () {
docEditor.refreshHistory(JSON.parse(hist)); // show the document version history
};
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = historyData;
docEditor.setHistoryData(JSON.parse(histData)[ver - 1]); // send the link to the document for viewing the version history
};
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose'] = function () {
document.location.reload();
};
}
// add mentions for not anonymous users
config.events['onRequestUsers'] = function () {
docEditor.setUsers({ // set a list of users to mention in the comments
@ -184,10 +205,12 @@
};
// the user is mentioned in a comment
config.events['onRequestSendNotify'] = function (event) {
event.data.actionLink = replaceActionLink(location.href, event.data.actionLink);
event.data.actionLink = replaceActionLink(location.href, JSON.stringify(event.data.actionLink));
var data = JSON.stringify(event.data);
innerAlert("onRequestSendNotify: " + data);
};
// prevent file renaming for anonymous users
config.events['onRequestRename'] = onRequestRename;
}
if (config.editorConfig.createUrl) {

View File

@ -87,37 +87,9 @@
<td valign="middle">
<span class="select-user">Language editors interface</span>
<select class="select-user" id="language">
<option value="en" selected="selected">English</option>
<option value="be">Belarusian</option>
<option value="bg">Bulgarian</option>
<option value="ca">Catalan</option>
<option value="zh">Chinese</option>
<option value="cs">Czech</option>
<option value="da">Danish</option>
<option value="nl">Dutch</option>
<option value="fi">Finnish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="el">Greek</option>
<option value="hu">Hungarian</option>
<option value="id">Indonesian</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="lv">Latvian</option>
<option value="lo">Lao</option>
<option value="nb">Norwegian</option>
<option value="pl">Polish</option>
<option value="pt">Portuguese</option>
<option value="ro">Romanian</option>
<option value="ru">Russian</option>
<option value="sk">Slovak</option>
<option value="sl">Slovenian</option>
<option value="sv">Swedish</option>
<option value="es">Spanish</option>
<option value="tr">Turkish</option>
<option value="uk">Ukrainian</option>
<option value="vi">Vietnamese</option>
<option th:each="language: ${languages}"
th:value="${language.key}"
th:text="${language.value}"/>
</select>
</td>
</tr>
@ -345,5 +317,10 @@
<script type="text/javascript" src="scripts/jquery.dropdownToggle.js"></script>
<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";
});
</script>
</body>
</html>

View File

@ -263,3 +263,12 @@ Make sure that the Document Server has access to the server with the example ins
```
4. After it, all the *bin* files will be passed to the *./target* folder.
## Important security info
Please keep in mind the following security aspects when you are using test examples:
* There is no protection of the storage from unauthorized access since there is no need for authorization.
* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts.
* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server.
* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain.

View File

@ -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>

View File

@ -78,16 +78,19 @@ 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");
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");
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");
dataMailMergeRecipients.put("directUrl", DocumentManager.GetServerUrl(false) + "/IndexServlet?type=csv");
// users data for mentions
List<Map<String, Object>> usersForMentions = Users.getUsersForMentions(user.id);

View File

@ -29,6 +29,7 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import helpers.*;
public class GlobalServletContextListener implements ServletContextListener
{
@ -70,16 +71,19 @@ public class GlobalServletContextListener implements ServletContextListener
SSLContext sc;
try
{
// register the all-trusting trust manager for HTTPS
sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
catch (NoSuchAlgorithmException | KeyManagementException ex)
{
if(!ConfigManager.GetProperty("files.docservice.verify-peer-off").isEmpty()) {
try
{
// register the all-trusting trust manager for HTTPS
sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
catch (NoSuchAlgorithmException | KeyManagementException ex)
{
}
}
// create all-trusting host name verifier
HostnameVerifier allHostsValid = new HostnameVerifier()

View File

@ -29,6 +29,8 @@ import java.util.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.charset.StandardCharsets;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
@ -36,7 +38,9 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import entities.FileType;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
@ -45,6 +49,7 @@ import org.primeframework.jwt.Verifier;
import org.primeframework.jwt.domain.JWT;
import org.primeframework.jwt.hmac.HMACVerifier;
@WebServlet(name = "IndexServlet", urlPatterns = {"/IndexServlet"})
@MultipartConfig
public class IndexServlet extends HttpServlet
@ -97,6 +102,9 @@ public class IndexServlet extends HttpServlet
case "saveas":
SaveAs(request, response, writer);
break;
case "rename":
Rename(request, response, writer);
break;
}
}
@ -226,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);
@ -321,7 +329,7 @@ public class IndexServlet extends HttpServlet
if (users.indexOf(user) == -1) {
String key = (String) body.get("key");
try {
TrackManager.commandRequest("forcesave", key); // create a command request with the forcesave method
TrackManager.commandRequest("forcesave", key, null); // create a command request with the forcesave method
} catch (Exception e) {
e.printStackTrace();
}
@ -551,6 +559,43 @@ public class IndexServlet extends HttpServlet
}
}
// rename a file
private static void Rename(HttpServletRequest request, HttpServletResponse response, PrintWriter writer) {
try {
Scanner scanner = new Scanner(request.getInputStream());
scanner.useDelimiter("\\A");
String bodyString = scanner.hasNext() ? scanner.next() : "";
scanner.close();
JSONParser parser = new JSONParser();
JSONObject body = (JSONObject) parser.parse(bodyString);
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);
TrackManager.commandRequest("meta", dockey, meta);
} catch (Exception e) {
e.printStackTrace();
writer.write("{ \"error\" : 1, \"message\" : \"" + e.getMessage() + "\"}");
}
}
// process get request
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

View File

@ -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 = 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,8 @@ 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));
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 +207,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 +255,7 @@ public class FileModel
{
public String title;
public String url;
public String directUrl;
public String fileType;
public String key;
public Info info;
@ -265,9 +274,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 +292,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 +317,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;
@ -348,14 +361,12 @@ public class FileModel
public Boolean forcesave;
public Boolean submitForm;
public Boolean about;
public Boolean chat;
public Boolean comments;
public Boolean feedback;
public Customization()
{
about = true;
chat = true;
comments = true;
feedback = true;
forcesave = false;

View File

@ -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;
@ -568,4 +570,19 @@ public class DocumentManager
{
return ConfigManager.GetProperty("files.docservice.secret");
}
// get languages
public static Map<String, String> GetLanguages()
{
String langs = ConfigManager.GetProperty("files.docservice.languages");
List<String> langsAndKeys = Arrays.asList(langs.split("\\|"));
Map<String, String> languages = new LinkedHashMap<>();
langsAndKeys.forEach((str) -> {
String[] couple = str.split(":");
languages.put(couple[0], couple[1]);
});
return languages;
}
}

View File

@ -277,7 +277,7 @@ public class TrackManager {
}
// create a command request
public static void commandRequest(String method, String key) throws Exception {
public static void commandRequest(String method, String key, HashMap meta) throws Exception {
String DocumentCommandUrl = ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.command");
URL url = new URL(DocumentCommandUrl);
@ -287,6 +287,10 @@ public class TrackManager {
params.put("c", method);
params.put("key", key);
if (meta != null) {
params.put("meta", meta);
}
String headerToken = "";
if (DocumentManager.TokenEnabled()) // check if a secret key to generate token exists or not
{
@ -314,7 +318,7 @@ public class TrackManager {
try (OutputStream os = connection.getOutputStream()) {
os.write(bodyByte); // write bytes to the output stream
}
InputStream stream = connection.getInputStream();; // get input stream
InputStream stream = connection.getInputStream(); // get input stream
if (stream == null)
throw new Exception("Could not get an answer");

View File

@ -64,6 +64,9 @@ public class Users {
add("Can't mention others in comments");
add("Can't create new files from the editor");
add("Cant see anyones 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>() {{

View File

@ -1,4 +1,4 @@
version=1.1.0
version=1.4.0
filesize-max=5242880
storage-folder=app_data
@ -16,5 +16,9 @@ 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|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
files.docservice.secret=
files.docservice.header=Authorization
files.docservice.header=Authorization
files.docservice.verify-peer-off=TRUE

View File

@ -36,6 +36,7 @@
<script type="text/javascript" language="javascript">
var docEditor;
var config;
var innerAlert = function (message, inEditor) {
if (console && console.log)
@ -97,10 +98,14 @@
// the meta information of the document is changed via the meta command
var onMetaChange = function (event) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
if (event.data.favorite) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
}
innerAlert("onMetaChange: " + JSON.stringify(event.data));
};
// the user is trying to insert an image by clicking the Image from Storage button
@ -130,7 +135,7 @@
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "IndexServlet?type=saveas");
xhr.setRequestHeader( 'Content-Type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
@ -138,7 +143,25 @@
}
};
var config = JSON.parse('<%= FileModel.Serialize(Model) %>');
var onRequestRename = function(event) { // the user is trying to rename file by clicking Rename... button
innerAlert("onRequestRename: " + JSON.stringify(event.data));
var newfilename = event.data;
var data = {
newfilename: newfilename,
dockey: config.document.key,
ext: config.document.fileType
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "IndexServlet?type=rename");
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
}
};
config = JSON.parse('<%= FileModel.Serialize(Model) %>');
config.width = "100%";
config.height = "100%";
config.events = {
@ -161,37 +184,38 @@
String usersForMentions = (String) request.getAttribute("usersForMentions");
%>
<% if (!history.isEmpty() && !historyData.isEmpty()) { %>
// the user is trying to show the document version history
config.events['onRequestHistory'] = function () {
docEditor.refreshHistory(<%= history %>); // show the document version history
};
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = <%= historyData %>;
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
};
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose'] = function () {
document.location.reload();
};
<% } %>
<% if (usersForMentions != null) { %>
if (config.editorConfig.user.id) {
<% if (!history.isEmpty() && !historyData.isEmpty()) { %>
// the user is trying to show the document version history
config.events['onRequestHistory'] = function () {
docEditor.refreshHistory(<%= history %>); // show the document version history
};
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = <%= historyData %>;
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
};
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose'] = function () {
document.location.reload();
};
<% } %>
// add mentions for not anonymous users
config.events['onRequestUsers'] = function () {
docEditor.setUsers({ // set a list of users to mention in the comments
"users": ${usersForMentions}
"users": <%=usersForMentions%>
});
};
// the user is mentioned in a comment
config.events['onRequestSendNotify'] = function (event) {
event.data.actionLink = replaceActionLink(location.href, event.data.actionLink);
event.data.actionLink = replaceActionLink(location.href, JSON.stringify(event.data.actionLink));
var data = JSON.stringify(event.data);
innerAlert("onRequestSendNotify: " + data);
};
<% } %>
// prevent file renaming for anonymous users
config.events['onRequestRename'] = onRequestRename;
}
if (config.editorConfig.createUrl) {
config.events.onRequestSaveAs = onRequestSaveAs;

View File

@ -4,6 +4,8 @@
<%@page import="java.util.Calendar"%>
<%@page import="java.io.File"%>
<%@page import="java.net.URLEncoder"%>
<%@page import="java.util.Map.Entry"%>
<%@page import="java.util.Map"%>
<%@page import="helpers.Users"%>
<%@page import="entities.User"%>
@ -97,37 +99,10 @@
<td valign="middle">
<span class="select-user">Language editors interface</span>
<select class="select-user" id="language">
<option value="en">English</option>
<option value="be">Belarusian</option>
<option value="bg">Bulgarian</option>
<option value="ca">Catalan</option>
<option value="zh">Chinese</option>
<option value="cs">Czech</option>
<option value="da">Danish</option>
<option value="nl">Dutch</option>
<option value="fi">Finnish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="el">Greek</option>
<option value="hu">Hungarian</option>
<option value="id">Indonesian</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="lv">Latvian</option>
<option value="lo">Lao</option>
<option value="nb">Norwegian</option>
<option value="pl">Polish</option>
<option value="pt">Portuguese</option>
<option value="ro">Romanian</option>
<option value="ru">Russian</option>
<option value="sk">Slovak</option>
<option value="sl">Slovenian</option>
<option value="sv">Swedish</option>
<option value="es">Spanish</option>
<option value="tr">Turkish</option>
<option value="uk">Ukrainian</option>
<option value="vi">Vietnamese</option>
<% Map<String, String> languages = DocumentManager.GetLanguages(); %>
<% for (Map.Entry<String, String> language : languages.entrySet()) { %>
<option value="<%=language.getKey()%>"><%=language.getValue()%></option>
<% } %>
</select>
</td>
</tr>
@ -373,7 +348,10 @@
var EditedExtList = "<%= String.join(",", DocumentManager.GetEditedExts()) %>";
var UrlConverter = "IndexServlet?type=convert";
var UrlEditor = "EditorServlet";
</script>
document.addEventListener('DOMContentLoaded', function(){
document.getElementById("language").value="en";
});
</script>
</body>
</html>

View File

@ -1,28 +0,0 @@
FROM node:buster
LABEL maintainer Ascensio System SIA <support@onlyoffice.com>
ENV LANG=en_US.UTF-8 \
LANGUAGE=en_US:en \
LC_ALL=en_US.UTF-8 \
NODE_ENV=production-linux \
NODE_CONFIG_DIR=/etc/onlyoffice/documentserver-example/
WORKDIR /var/www/onlyoffice/documentserver-example/
COPY . /var/www/onlyoffice/documentserver-example/
RUN groupadd --system --gid 1001 ds && \
useradd --system -g ds --no-create-home --shell /sbin/nologin --uid 1001 ds && \
chown -R ds:ds /var/www/onlyoffice/documentserver-example/ && \
mkdir -p /var/lib/onlyoffice/documentserver-example/ && \
chown -R ds:ds /var/lib/onlyoffice/ && \
mv files /var/lib/onlyoffice/documentserver-example/ && \
mkdir -p /etc/onlyoffice/documentserver-example/ && \
chown -R ds:ds /etc/onlyoffice/ && \
mv config/* /etc/onlyoffice/documentserver-example/ && \
npm install
EXPOSE 3000
USER ds
ENTRYPOINT /var/www/onlyoffice/documentserver-example/docker-entrypoint.sh npm start

View File

@ -146,3 +146,12 @@ See the detailed guide to learn how to [install Document Server for Linux](https
In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files.
Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files.
## Important security info
Please keep in mind the following security aspects when you are using test examples:
* There is no protection of the storage from unauthorized access since there is no need for authorization.
* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts.
* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server.
* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain.

227
web/documentserver-example/nodejs/app.js Normal file → Executable file
View File

@ -29,6 +29,7 @@ const config = require('config');
const configServer = config.get('server');
const storageFolder = configServer.get("storageFolder");
const mime = require("mime");
const urlModule = require("url");
const docManager = require("./helpers/docManager");
const documentService = require("./helpers/documentService");
const fileUtility = require("./helpers/fileUtility");
@ -44,9 +45,12 @@ 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');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
if(verifyPeerOff) {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
}
String.prototype.hashCode = function () {
const len = this.length;
@ -70,6 +74,7 @@ String.prototype.format = function () {
const app = express(); // create an application object
app.disable("x-powered-by");
app.set("views", path.join(__dirname, "views")); // specify the path to the main template
app.set("view engine", "ejs"); // specify which template engine is used
@ -108,6 +113,7 @@ app.get("/", function (req, res) { // define a handler for default page
params: req.docManager.getCustomParams(),
users: users,
serverUrl: req.docManager.getServerUrl(),
languages: configServer.get('languages'),
});
}
@ -124,9 +130,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);
@ -208,7 +213,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
@ -321,7 +325,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);
@ -345,7 +349,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
@ -356,7 +360,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
@ -367,10 +371,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();
@ -465,7 +470,76 @@ 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("/reference", function (req, res) { //define a handler for renaming file
req.docManager = new docManager(req, res);
var result = function(data) {
res.writeHead(200, {"Content-Type": "application/json" });
res.write(JSON.stringify(data));
res.end();
};
var referenceData = req.body.referenceData;
if (!!referenceData) {
var portalName = referenceData.portalName;
if (portalName != req.docManager.getServerUrl()) {
result({ "error": "You do not have access to this site" });
return;
}
var fileId = JSON.parse(referenceData.fileId);
var userAddress = fileId.userAddress;
if (userAddress != req.docManager.curUserHostAddress()) {
result({ "error": "You do not have access to this file" });
return;
}
var fileName = fileId.fileName;
if (!req.docManager.existsSync(req.docManager.storagePath(fileName, userAddress))) {
result({ "error": "File is not exist" });
return;
}
} else if (!!req.body.link) {
if (req.body.link.indexOf(req.docManager.curUserHostAddress()) != -1) {
result({ "error": "You do not have access to this site" });
return;
}
var urlObj = urlModule.parse(req.body.link, true);
var fileName = urlObj.query.fileName;
if (!req.docManager.existsSync(req.docManager.storagePath(fileName, userAddress))) {
result({ "error": "File is not exist" });
return;
}
} else if (!!req.body.path) {
var fileName = fileUtility.getFileName(req.body.path);
if (!req.docManager.existsSync(req.docManager.storagePath(fileName, userAddress))) {
result({ "error": "File is not exist" });
return;
}
}
if (!fileName) {
result({ "error": "File is not found" });
return;
}
result({
key: req.docManager.getKey(fileName),
url: req.docManager.getDownloadUrl(fileName, true),
directUrl: req.docManager.getDownloadUrl(fileName),
referenceData: {
fileId: JSON.stringify({ fileName: fileName, userAddress: req.docManager.curUserHostAddress()}),
portalName: req.docManager.getServerUrl()
},
link: req.docManager.getServerUrl() + "/editor?fileName=" + encodeURIComponent(fileName),
path: fileName,
});
});
app.post("/track", async function (req, res) { // define a handler for tracking file changes
req.docManager = new docManager(req, res);
@ -474,11 +548,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
@ -495,9 +573,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);
@ -512,9 +593,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
@ -522,6 +601,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;
@ -532,7 +612,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}");
@ -553,18 +633,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;
}
});
@ -573,12 +653,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]
@ -606,9 +690,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
@ -625,7 +707,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}");
@ -643,18 +725,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;
}
});
@ -663,7 +745,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
@ -679,10 +761,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;
}
@ -691,14 +773,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
});
};
@ -730,14 +812,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
}
});
@ -752,6 +834,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;
@ -766,6 +849,11 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
}
}
var referenceData = {
fileId: JSON.stringify({ fileName: fileName, userAddress: req.docManager.curUserHostAddress()}),
portalName: req.docManager.getServerUrl()
};
var templatesImageUrl = req.docManager.getTemplateImageUrl(fileUtility.getFileType(fileName));
var createUrl = req.docManager.getCreateUrl(fileUtility.getFileType(fileName), userid, type, lang);
var templates = [
@ -803,8 +891,8 @@ 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
@ -848,7 +936,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
@ -856,8 +945,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
}
@ -873,7 +963,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,
});
}
@ -890,7 +981,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"
@ -905,6 +997,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",
@ -926,21 +1020,25 @@ app.get("/editor", function (req, res) { // define a handler for editing docume
fileChoiceUrl: fileChoiceUrl,
submitForm: submitForm,
plugins: JSON.stringify(plugins),
actionData: actionData
actionData: actionData,
referenceData: userid != "uid-0" ? referenceData : null
},
history: history,
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,
};
@ -969,6 +1067,27 @@ 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};
var result = function(err, data, ress) {
res.writeHead(200, {"Content-Type": "application/json" });
res.write(JSON.stringify({ "result": ress }));
res.end();
};
documentService.commandRequest("meta", dockey, meta, result);
});
wopiApp.registerRoutes(app);
// "Not found" error with 404 status

View File

@ -1,5 +1,5 @@
{
"version": "1.1.0",
"version": "1.4.0",
"log": {
"appenders": [
{
@ -44,6 +44,47 @@
"authorizationHeaderPrefix": "Bearer ",
"secret": "secret",
"expiresIn": "5m"
},
"verify_peer_off": true,
"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"
}
},
"plugins": {

View File

@ -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;
};
@ -385,9 +375,9 @@ docManager.prototype.getTemplateImageUrl = function (fileType) {
}
// get document key
docManager.prototype.getKey = function (fileName) {
const userAddress = this.curUserHostAddress();
let key = userAddress + this.getlocalFileUri(fileName); // get document key by adding local file url to the current user host address
docManager.prototype.getKey = function (fileName, userAddress) {
userAddress = userAddress || this.curUserHostAddress();
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

View File

@ -168,13 +168,18 @@ documentService.getResponseUri = function (json) {
};
// create a command request
documentService.commandRequest = function (method, documentRevisionId, callback) {
documentService.commandRequest = function (method, documentRevisionId, meta = null, callback) {
documentRevisionId = documentService.generateRevisionId(documentRevisionId); // generate the document key value
var params = { // create a parameter object with command method and the document key value in it
params = { // create a parameter object with command method and the document key value in it
c: method,
key: documentRevisionId
};
if (meta) {
params.meta = meta;
}
var uri = siteUrl + configServer.get('commandUrl'); // get the absolute command url
var headers = { // create a headers object
'Content-Type': 'application/json'

View File

@ -22,7 +22,9 @@ var fileUtility = {};
fileUtility.getFileName = function (url, withoutExtension) {
if (!url) return "";
var parts = url.split("/");
var parts = url.split("\\");
parts = parts.pop();
parts = parts.split("/");
var fileName = parts.pop(); // get the file name from the last part of the url
fileName = fileName.split("?")[0];

View File

@ -59,6 +59,9 @@ var descr_user_0 = [
"Can't mention others in comments",
"Can't create new files from the editor",
"Cant see anyones information",
"Can't rename files from the editor",
"Can't view chat",
"View file without collaboration",
//"Cant submit forms"
];

View File

@ -23,6 +23,7 @@ const fileSystem = require("fs");
const mime = require("mime");
const path = require("path");
const users = require("../users");
const docManager = require("../docManager");
const actionMapping = {};
actionMapping[reqConsts.requestType.GetFile] = getFile;
@ -255,8 +256,8 @@ function putFile(wopi, req, res, userHost) {
// return information about the file properties, access rights and editor settings
function checkFileInfo(wopi, req, res, userHost) {
let userAddress = req.docManager.curUserHostAddress(userHost);
let version = req.docManager.getKey(wopi.id);
let version = req.docManager.getKey(wopi.id, userAddress);
let path = req.docManager.storagePath(wopi.id, userAddress);
// add wopi query
var query = new URLSearchParams(wopi.accessToken);
@ -289,6 +290,7 @@ function returnLockMismatch(res, lock, reason) {
exports.fileRequestHandler = (req, res) => {
let userAddress = null;
req.docManager = new docManager(req, res);
if (req.params['id'].includes("@")) { // if there is the "@" sign in the id parameter
let split = req.params['id'].split("@"); // split this parameter by "@"
req.params['id'] = split[0]; // rewrite id with the first part of the split parameter
@ -310,5 +312,5 @@ exports.fileRequestHandler = (req, res) => {
return;
}
action(wopiData, req, res);
action(wopiData, req, res, userAddress);
}

View File

@ -83,6 +83,7 @@ exports.registerRoutes = function(app) {
convertExts: configServer.get('convertedDocs'),
editedExts: editedExts,
fillExts: fillExts,
languages: configServer.get('languages'),
});
} catch (ex) {

File diff suppressed because it is too large Load Diff

View File

@ -18,12 +18,14 @@
var language;
var userid;
var directUrl;
if (typeof jQuery != "undefined") {
jq = jQuery.noConflict();
userid = getUrlVars()["userid"];
language = getUrlVars()["lang"];
directUrl = getUrlVars()["directUrl"] == "true";
mustReload = false;
@ -34,19 +36,29 @@ if (typeof jQuery != "undefined") {
jq("#language").change(function() {
window.location = "?lang=" + jq(this).val() + "&userid=" + userid;
window.location = "?lang=" + jq(this).val() + "&userid=" + userid + "&directUrl=" + directUrl;
});
if ("" != userid && undefined != userid)
jq("#user").val(userid);
else
userid = jq("#user").val();
jq("#user").change(function() {
window.location = "?lang=" + language + "&userid=" + jq(this).val();
window.location = "?lang=" + language + "&userid=" + jq(this).val() + "&directUrl=" + directUrl;
});
if (directUrl)
jq("#directUrl").prop("checked", directUrl);
else
directUrl = jq("#directUrl").prop("checked");
jq("#directUrl").change(function() {
window.location = "?lang=" + language + "&userid=" + userid + "&directUrl=" + jq(this).prop("checked");
});
jq(function () {
jq('#fileupload').fileupload({
dataType: 'json',
@ -228,7 +240,7 @@ if (typeof jQuery != "undefined") {
if (UrlEditor == "wopi-action"){
var url = UrlEditor + "/" + fileId + "?action=edit";
}else{
var url = UrlEditor + "?fileName=" + fileId + "&lang=" + language + "&userid=" + userid;
var url = UrlEditor + "?fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
}
window.open(url, "_blank");
jq('#hiddenFileName').val("");
@ -241,7 +253,7 @@ if (typeof jQuery != "undefined") {
if (UrlEditor == "wopi-action"){
var url = UrlEditor + "/" + fileId + "?action=view";
}else{
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&lang=" + language + "&userid=" + userid;
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
}
window.open(url, "_blank");
jq('#hiddenFileName').val("");
@ -251,7 +263,7 @@ if (typeof jQuery != "undefined") {
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
var url = UrlEditor + "?type=embedded&fileName=" + fileId + "&lang=" + language + "&userid=" + userid;
var url = UrlEditor + "?type=embedded&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
jq("#mainProgress").addClass("embedded");
jq("#beginEmbedded").addClass("disable");
@ -328,12 +340,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);
@ -357,6 +369,20 @@ 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();
});
}
function getUrlVars() {

View File

@ -165,7 +165,7 @@ label .checkbox {
background-image: url("../images/file_docxf.svg");
}
.create-sample {
.side-option {
color: #666666;
line-height: 24px;
}
@ -620,6 +620,31 @@ footer table tr td:first-child {
margin: -2px 5px;
}
.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%);
}
.user-block-table {
height: 100%;
padding-top: 14px;

61
web/documentserver-example/nodejs/views/config.ejs Normal file → Executable file
View File

@ -1,54 +1,39 @@
"width": "100%",
"height": "100%",
"type": "<%- editor.type %>",
"documentType": "<%- editor.documentType %>",
"token": "<%- editor.token %>",
"document": {
"title": "<%- file.name %>",
"url": "<%- file.uri %>",
"document": {
"directUrl": "<%- file.directUrl %>",
"fileType": "<%- file.ext %>",
"key": "<%- editor.key %>",
"info": {
"owner": "Me",
"uploaded": "<%- file.created %>",
"favorite": <%- file.favorite %>
},
"key": "<%- editor.key %>",
"permissions": {
"chat": <%- editor.chat %>,
"comment": <%- editor.comment %>,
"copy": <%- editor.copy %>,
"download": <%- editor.download %>,
"edit": <%- editor.isEdit %>,
"print": <%- editor.print %>,
"fillForms": <%- editor.fillForms %>,
"modifyFilter": <%- editor.modifyFilter %>,
"modifyContentControl": <%- editor.modifyContentControl %>,
"modifyFilter": <%- editor.modifyFilter %>,
"print": <%- editor.print %>,
"review": <%- editor.review %>,
"reviewGroups": <%- editor.reviewGroups %>,
"commentGroups": <%- editor.commentGroups %>,
"userInfoGroups": <%- editor.userInfoGroups %>
}
},
"referenceData": <%- JSON.stringify(editor.referenceData) %>,
"title": "<%- file.name %>",
"url": "<%- file.uri %>"
},
"documentType": "<%- editor.documentType %>",
"editorConfig": {
"actionLink": <%- editor.actionData %>,
"mode": "<%- editor.mode %>",
"lang": "<%- editor.lang %>",
"callbackUrl": "<%- editor.callbackUrl %>",
"coEditing": <%- JSON.stringify(editor.coEditing) %>,
"createUrl": <%- JSON.stringify(editor.createUrl) %>,
"templates": <%- JSON.stringify(editor.templates) %>,
"user": {
"group": "<%- editor.userGroup %>",
"id": "<%- editor.userid %>",
"name": "<%- editor.name %>"
},
"embedded": {
"saveUrl": "<%- file.uriUser %>",
"embedUrl": "<%- file.uriUser %>",
"shareUrl": "<%- file.uriUser %>",
"toolbarDocked": "top"
},
"customization": {
"about": true,
"chat": true,
"comments": true,
"feedback": true,
"forcesave": false,
@ -57,6 +42,24 @@
},
"submitForm": <%- editor.submitForm %>
},
"embedded": {
"embedUrl": "<%- file.uriUser %>",
"saveUrl": "<%- file.uriUser %>",
"shareUrl": "<%- file.uriUser %>",
"toolbarDocked": "top"
},
"fileChoiceUrl": "<%- editor.fileChoiceUrl %>",
"plugins": <%- editor.plugins %>
}
"lang": "<%- editor.lang %>",
"mode": "<%- editor.mode %>",
"plugins": <%- editor.plugins %>,
"templates": <%- JSON.stringify(editor.templates) %>,
"user": {
"group": "<%- editor.userGroup %>",
"id": "<%- editor.userid %>",
"name": "<%- editor.name %>"
}
},
"height": "100%",
"token": "<%- editor.token %>",
"type": "<%- editor.type %>",
"width": "100%"

View File

@ -38,6 +38,7 @@
<script type="text/javascript" language="javascript">
var docEditor;
var config;
var innerAlert = function (message, inEditor) {
if (console && console.log)
@ -56,10 +57,14 @@
};
var onMetaChange = function (event) { // the meta information of the document is changed via the meta command
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
if (event.data.favorite) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite); // change the Favorite icon state
}
innerAlert("onMetaChange: " + JSON.stringify(event.data));
};
var onRequestEditRights = function () { // the user is trying to switch the document from the viewing into the editing mode
@ -141,11 +146,25 @@
};
var onRequestSendNotify = function(event) { // the user is mentioned in a comment
event.data.actionLink = replaceActionLink(location.href, event.data.actionLink);
event.data.actionLink = replaceActionLink(location.href, JSON.stringify(event.data.actionLink));
var data = JSON.stringify(event.data);
innerAlert("onRequestSendNotify: " + data);
};
var onRequestReferenceData = function(event) { // user refresh external data source
innerAlert("onRequestReferenceData");
innerAlert(event.data);
let xhr = new XMLHttpRequest();
xhr.open("POST", "reference");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(event.data));
xhr.onload = function () {
innerAlert(xhr.responseText);
docEditor.setReferenceData(JSON.parse(xhr.responseText));
}
};
var onRequestSaveAs = function (event) { // the user is trying to save file by clicking Save Copy as... button
var title = event.data.title;
var url = event.data.url;
@ -155,7 +174,7 @@
}
let xhr = new XMLHttpRequest();
xhr.open("POST", "create");
xhr.setRequestHeader( 'Content-Type', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
@ -163,27 +182,48 @@
}
}
var config = {<%- include("config") %>,
events: {
"onAppReady": onAppReady,
"onDocumentStateChange": onDocumentStateChange,
"onRequestEditRights": onRequestEditRights,
"onError": onError,
"onRequestHistory": onRequestHistory,
"onRequestHistoryData": onRequestHistoryData,
"onRequestHistoryClose": onRequestHistoryClose,
"onOutdatedVersion": onOutdatedVersion,
"onMakeActionLink": onMakeActionLink,
"onMetaChange": onMetaChange,
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
}
};
var onRequestRename = function(event) { // the user is trying to rename file by clicking Rename... button
innerAlert("onRequestRename: " + JSON.stringify(event.data));
if (<%- JSON.stringify(usersForMentions) %> != null) {
var newfilename = event.data;
var data = {
newfilename: newfilename,
dockey: config.document.key,
ext: config.document.fileType
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "rename");
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
}
};
config = {
<%- include("config") %>
};
config.events = {
"onAppReady": onAppReady,
"onDocumentStateChange": onDocumentStateChange,
"onRequestEditRights": onRequestEditRights,
"onError": onError,
"onOutdatedVersion": onOutdatedVersion,
"onMakeActionLink": onMakeActionLink,
"onMetaChange": onMetaChange,
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
};
if (<%- JSON.stringify(editor.userid) %> != null) {
config.events.onRequestHistory = onRequestHistory;
config.events.onRequestHistoryData = onRequestHistoryData;
config.events.onRequestHistoryClose = onRequestHistoryClose;
config.events.onRequestRename = onRequestRename;
config.events.onRequestUsers = onRequestUsers;
config.events.onRequestSendNotify = onRequestSendNotify;
config.events.onRequestReferenceData = onRequestReferenceData;
}
if (config.editorConfig.createUrl) {

49
web/documentserver-example/nodejs/views/index.ejs Normal file → Executable file
View File

@ -60,7 +60,7 @@
<a class="try-editor form reload-page" target="_blank" href="editor?fileExt=docxf<%= params %>" title="Create new form template">Form template</a>
</li>
</ul>
<label class="create-sample">
<label class="side-option">
<input id="createSample" type="checkbox" class="checkbox" />With sample content
</label>
</div>
@ -76,7 +76,7 @@
<tr>
<td valign="middle">
<span class="select-user">Username</span>
<img class="info" src="images/info.svg" />
<img id="info" class="info" src="images/info.svg" />
<select class="select-user" id="user">
<% users.forEach(user => { %>
<option value="<%= user.id %>"><%= user.name == null ? "Anonymous" : user.name %></option>
@ -86,42 +86,23 @@
</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="images/info.svg" />
<select class="select-user" id="language">
<option value="en">English</option>
<option value="be">Belarusian</option>
<option value="bg">Bulgarian</option>
<option value="ca">Catalan</option>
<option value="zh">Chinese</option>
<option value="cs">Czech</option>
<option value="da">Danish</option>
<option value="nl">Dutch</option>
<option value="fi">Finnish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="el">Greek</option>
<option value="hu">Hungarian</option>
<option value="id">Indonesian</option>
<option value="it">Italian</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="lv">Latvian</option>
<option value="lo">Lao</option>
<option value="nb">Norwegian</option>
<option value="pl">Polish</option>
<option value="pt">Portuguese</option>
<option value="ro">Romanian</option>
<option value="ru">Russian</option>
<option value="sk">Slovak</option>
<option value="sl">Slovenian</option>
<option value="sv">Swedish</option>
<option value="es">Spanish</option>
<option value="tr">Turkish</option>
<option value="uk">Ukrainian</option>
<option value="vi">Vietnamese</option>
<% Object.keys(languages).forEach(key => { %>
<option value="<%= key %>"><%= languages[key] %></option>
<% }) %>
</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="images/info.svg" />
</label>
</td>
</tr>
</tbody>
</table>

Some files were not shown because too many files have changed in this diff Show More