Compare commits

..

301 Commits

Author SHA1 Message Date
c38c3ab0d6 Merge branch hotfix/v6.3.1 into master 2021-06-08 11:53:18 +00:00
a9b82a299a [run] Port (#165)
Change develop port 8001 -> 8000
2021-05-31 09:25:59 +03:00
46961db654 Merge branch release/v6.3.0 into master 2021-05-20 11:58:44 +00:00
85255d878e Merge branch hotfix/v6.2.2 into release/v6.3.0 2021-05-07 11:59:45 +00:00
c8b17785e7 apache to license 2021-03-23 11:37:21 +03:00
988e336f43 forcesave is disabled by default (b541936473) 2021-03-05 11:20:12 +03:00
9ab94ee9c3 Merge remote-tracking branch 'origin/master' into release/v6.3.0 2021-03-04 11:12:08 +03:00
fe02c4914c converting xml 2021-03-01 14:26:43 +03:00
82981d3ce2 Merge remote-tracking branch 'remotes/origin/release/v6.2.0' into develop 2021-03-01 14:14:38 +03:00
6870923b94 Merge branch release/v6.2.0 into master 2021-03-01 08:43:26 +00:00
7d5c90e9cf python: set version pyjwt 1.7.1 2021-02-19 16:08:43 +03:00
b541936473 Merge pull request #126 from ONLYOFFICE/feature/submit-form
Feature/submit form
2021-02-19 15:45:20 +03:00
a2e59cf705 ruby: submit filled form 2021-02-19 15:01:32 +03:00
dc074d4baf python: submit filled form 2021-02-19 15:00:42 +03:00
1cf5b1eea5 php: submit filled form 2021-02-19 15:00:17 +03:00
2635306e2e csharp-mvc: submit filled form 2021-02-19 14:59:59 +03:00
f0cc80fd53 csharp: submit filled form 2021-02-19 14:59:36 +03:00
c9f58e3ca6 java: submit filled form 2021-02-19 14:59:14 +03:00
821e481734 nodejs: improved forcesave submit filled form 2021-02-19 14:58:21 +03:00
f0309615d6 Merge remote-tracking branch 'remotes/origin/develop' into feature/submit-form
# Conflicts:
#	web/documentserver-example/nodejs/app.js
2021-02-18 15:39:20 +03:00
47588d135e Merge pull request #115 from ONLYOFFICE/feature/reviewPermissions
Feature/review permissions
2021-02-18 15:33:56 +03:00
8e6ae3b915 Merge remote-tracking branch 'remotes/origin/develop' into feature/reviewPermissions
# Conflicts:
#	web/documentserver-example/csharp-mvc/Models/FileModel.cs
#	web/documentserver-example/csharp/DocEditor.aspx.cs
#	web/documentserver-example/java/src/main/java/entities/FileModel.java
#	web/documentserver-example/python/src/views/actions.py
#	web/documentserver-example/ruby/app/models/file_model.rb
2021-02-18 15:13:34 +03:00
8fc9d6125c Merge pull request #122 from ONLYOFFICE/feature/request-name
Feature/request name
2021-02-18 14:14:00 +03:00
b427594248 Merge pull request #125 from ONLYOFFICE/feature/favicon
Feature/favicon
2021-02-18 09:09:36 +03:00
5c43308e14 ruby: added dynamic favicon 2021-02-17 20:19:51 +03:00
c5b67b4b00 php: added dynamic favicon 2021-02-17 20:19:30 +03:00
8442def83c csharp-mvc: added dynamic favicon 2021-02-17 20:18:43 +03:00
2cb91eb8d5 csharp: added dynamic favicon 2021-02-17 20:18:15 +03:00
cf82b0ffc9 java: added dynamic favicon 2021-02-17 20:17:15 +03:00
ffcf787f94 python: renamed favicon 2021-02-17 20:16:32 +03:00
ce2714c684 nodejs: renamed favicon 2021-02-17 20:15:47 +03:00
4ccd78053f renamed parameter reviewGroup on reviewGroups 2021-02-17 10:11:36 +03:00
7602183cf9 Merge pull request #124 from ONLYOFFICE/feature/forcesave
Feature/forcesave
2021-02-17 09:48:34 +03:00
1a6744a814 Merge branch 'develop' into feature/forcesave
# Conflicts:
#	web/documentserver-example/java/src/main/resources/settings.properties
2021-02-16 15:07:23 +03:00
6a89a073fa ruby: download forcesaved file 2021-02-16 15:02:19 +03:00
353119145c python: download forcesaved file 2021-02-16 14:59:04 +03:00
0aaaedc4d6 php: download forcesaved file 2021-02-16 14:14:08 +03:00
246ddc9f9c csharp-mvc: download forcesaved file 2021-02-16 13:28:30 +03:00
3e8b6aaffa csharp: download forcesaved file 2021-02-16 13:28:14 +03:00
c95439c0db java: download forcesaved file 2021-02-16 13:27:53 +03:00
62873e4ce4 nodejs: fix forcesave conversion 2021-02-16 11:00:45 +03:00
e04155e7ad csharp: added forcesave 2021-02-15 17:27:29 +03:00
733f798968 csharp-mvc: added forcesave 2021-02-15 17:26:16 +03:00
f7f0a07239 ruby: added forcesave 2021-02-15 17:24:56 +03:00
ee79e02c54 python: added forcesave 2021-02-15 16:52:44 +03:00
d8afda9b56 php: added forcesave 2021-02-15 15:29:25 +03:00
0569dc7271 java: added forcesave 2021-02-15 13:37:40 +03:00
fef62baa2b Merge pull request #123 from ONLYOFFICE/feature/remove-resource
Feature/remove resource
2021-02-11 11:19:56 +03:00
be82ae7078 java: ResourceService.ashx is not used anymore 2021-02-11 11:15:57 +03:00
0a4fcc0cdc nodejs: ResourceService.ashx is not used anymore 2021-02-11 08:58:38 +03:00
823374e2fe csharp-mvc: request user name 2021-02-08 22:28:56 +03:00
3b89aae808 csharp: request user name 2021-02-08 22:28:19 +03:00
cc488187b4 php: request user name 2021-02-08 22:27:14 +03:00
0e191eed91 python: request user name 2021-02-08 22:26:24 +03:00
6d27c1866b ruby: request user name 2021-02-08 22:25:08 +03:00
845b111a85 java: request user name 2021-02-08 22:21:25 +03:00
79d12ecd02 Merge pull request #121 from ONLYOFFICE/feature/document-type
Feature/document type
2021-02-08 10:27:36 +03:00
61c388a7af csharp-mvc: reviewGroup instead reviewPermissions 2021-02-07 19:35:29 +03:00
c6deb13712 csharp: reviewGroup instead reviewPermissions 2021-02-07 19:30:32 +03:00
13250e18b3 php: reviewGroup instead reviewPermissions 2021-02-07 19:21:41 +03:00
7d373fa1a9 ruby: reviewGroup instead reviewPermissions 2021-02-07 19:11:09 +03:00
8af2607e62 python: reviewGroup instead reviewPermissions 2021-02-07 19:00:34 +03:00
c2db28fbcf java: reviewGroup instead reviewPermissions 2021-02-07 18:38:47 +03:00
212fd26807 csharp: word, cell, slide instead text, spreadsheet, presentation 2021-02-06 20:36:55 +03:00
c9ef51a361 csharp-mvc: word, cell, slide instead text, spreadsheet, presentation 2021-02-06 20:20:38 +03:00
f25e4ea614 php: word, cell, slide instead text, spreadsheet, presentation 2021-02-06 20:09:03 +03:00
e4eb8366bd ruby: word, cell, slide instead text, spreadsheet, presentation 2021-02-05 18:46:21 +03:00
bcfa08b43c python: word, cell, slide instead text, spreadsheet, presentation 2021-02-05 18:36:58 +03:00
193238fbdb java: word, cell, slide instead text, spreadsheet, presentation 2021-02-05 17:55:05 +03:00
37e36f7fef Merge pull request #120 from ONLYOFFICE/feature/fix-filename
Feature/fix filename
2021-02-05 14:00:19 +03:00
ec90b2ff98 ruby: check filename from url 2021-02-05 13:40:13 +03:00
758f0c08e5 java: add check filename for download 2021-02-05 13:33:57 +03:00
b76c532569 csharp-mvc: check filename from url 2021-02-05 13:29:08 +03:00
856613d644 csharp: check filename from url 2021-02-05 13:25:12 +03:00
75c11f4ee8 Merge remote-tracking branch 'remotes/origin/develop' into feature/fix-filename
# Conflicts:
#	web/documentserver-example/java/src/main/java/controllers/IndexServlet.java
#	web/documentserver-example/python/src/views/actions.py
2021-02-05 12:56:04 +03:00
1e023e58b2 Merge pull request #119 from ONLYOFFICE/feature/template-submodule
Feature/template submodule
2021-02-04 18:39:50 +03:00
f9f757bd0d ruby: added templates submodule 2021-02-04 17:42:56 +03:00
a213b635f2 csharp-mvc: changed path to sample 2021-02-04 17:05:40 +03:00
96d6c521ef csharp: changed path to sample 2021-02-04 16:56:28 +03:00
7d2469cfe9 php: changed path to sample 2021-02-04 16:36:17 +03:00
2f7352c296 java: changed path to sample 2021-02-04 16:26:05 +03:00
6ec262e221 nodejs: word, cell, slide instead text, spreadsheet, presentation 2021-02-04 16:10:00 +03:00
5fdbd2954b uploaded instead created 2021-02-04 16:06:40 +03:00
758291fd71 owner instead author 2021-02-04 15:43:09 +03:00
2a856c6919 python: changed path to sample 2021-02-04 15:25:28 +03:00
d075855065 nodejs: request user name 2021-02-04 15:24:09 +03:00
f026d0ef60 nodejs: changed path to sample 2021-02-04 15:15:26 +03:00
2ec0a3798d nodejs: reviewGroup instead reviewPermissions 2021-02-04 14:31:49 +03:00
506b55a201 update submodule (csharp-mvc, csharp, php, java, nodejs, python) 2021-02-04 14:26:15 +03:00
90dd2c837f Merge remote-tracking branch 'remotes/origin/develop' into feature/template-submodule 2021-02-04 11:00:08 +03:00
75d828a6ae Merge pull request #118 from ONLYOFFICE/feature/update-dependencies
python: update (django, requests, pyjwt)
2021-02-04 10:45:50 +03:00
fe3b5558df python: update (django, requests, pyjwt) 2021-02-04 10:41:41 +03:00
3d49eabaf0 Merge pull request #117 from ONLYOFFICE/feature/get-files
Feature/get files
2021-02-04 10:07:13 +03:00
51f712b900 ruby: improved get_files_info 2021-02-03 13:01:44 +03:00
a565da4035 php: improved GetFilesInfo 2021-02-03 12:52:11 +03:00
7db6983167 python: improved GetFilesInfo 2021-02-03 12:47:13 +03:00
b7262ff874 java: improved GetFilesInfo 2021-02-03 12:43:08 +03:00
50921b278b csharp: improved GetFilesInfo 2021-02-03 12:42:39 +03:00
9d16bee672 csharp-mvc: improved GetFilesInfo 2021-02-03 12:42:00 +03:00
1a63a7f65f nodejs: add Content-Type 2021-02-03 12:13:17 +03:00
f8f15d2191 Merge remote-tracking branch 'remotes/origin/develop' into feature/get-files
# Conflicts:
#	web/documentserver-example/csharp-mvc/WebEditor.ashx.cs
#	web/documentserver-example/csharp/WebEditor.ashx.cs
#	web/documentserver-example/java/src/main/java/controllers/IndexServlet.java
#	web/documentserver-example/php/webeditor-ajax.php
#	web/documentserver-example/python/src/urls.py
#	web/documentserver-example/python/src/views/actions.py
#	web/documentserver-example/ruby/app/controllers/home_controller.rb
#	web/documentserver-example/ruby/config/routes.rb
2021-02-02 22:12:21 +03:00
2b217de9b4 ruby: get-file 2021-02-02 22:01:48 +03:00
6f64d40e5d ruby: get-files 2021-02-02 21:44:50 +03:00
620a097faa Merge remote-tracking branch 'remotes/origin/develop' into feature/reviewPermissions
# Conflicts:
#	web/documentserver-example/csharp-mvc/Models/FileModel.cs
#	web/documentserver-example/java/src/main/java/entities/FileModel.java
#	web/documentserver-example/python/src/views/actions.py
2021-02-02 13:59:17 +03:00
9759839cd0 Merge pull request #114 from ONLYOFFICE/feature/fix-history
Feature/fix history
2021-02-02 13:09:41 +03:00
e6ee57e09b php: fix tabulation 2021-02-02 12:53:56 +03:00
50daec31b4 java: fix tabulation 2021-02-02 12:51:08 +03:00
bcd114d089 ruby: fix-history 2021-02-02 12:29:04 +03:00
49592f66bf Merge pull request #113 from ONLYOFFICE/feature/fix-history-cors
Feature/fix history cors
2021-02-02 11:13:40 +03:00
e854b78884 Merge pull request #112 from ONLYOFFICE/feature/add-jwt
Feature/add jwt
2021-02-02 11:06:12 +03:00
4dd5f9d9f6 Merge remote-tracking branch 'remotes/origin/develop' into feature/add-jwt
# Conflicts:
#	web/documentserver-example/python/src/utils/historyManager.py
2021-02-02 11:02:53 +03:00
abee34981b ruby: jwt for historyData 2021-02-02 10:57:52 +03:00
768f45f4fb Merge remote-tracking branch 'remotes/origin/release/v6.2.0' into develop 2021-02-02 09:54:22 +03:00
c3bb70aa9a nodejs: submit filled form 2021-02-02 09:52:24 +03:00
e53dac1e2b Merge pull request #111 from ONLYOFFICE/feature/mail-merge
Feature/mail merge
2021-02-02 09:51:22 +03:00
71ab72299a php: added function download 2021-02-01 23:16:47 +03:00
eb4e6b4bc0 csharp-mvc: added function download 2021-02-01 23:09:49 +03:00
4f02a4957f csharp: added function download 2021-02-01 23:05:25 +03:00
469c2b6ced java: added function download 2021-02-01 23:02:55 +03:00
8b9a2d2481 csharp: fix merge 2021-02-01 23:02:15 +03:00
e921c936b8 java: fix merge 2021-02-01 23:00:10 +03:00
a5929897ad php: fix merge 2021-02-01 22:59:17 +03:00
00a1c64353 python: fix merge 2021-02-01 22:58:42 +03:00
6c18acdf97 ruby: fix merge 2021-02-01 22:57:13 +03:00
c0f459132e csharp-mvc: fix merge 2021-02-01 21:07:49 +03:00
d780a61e52 ruby: jwt for mailmerge 2021-02-01 20:30:07 +03:00
361b8bd0f4 Merge remote-tracking branch 'remotes/origin/develop' into feature/mail-merge
# Conflicts:
#	web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx
#	web/documentserver-example/csharp-mvc/WebEditor.ashx.cs
#	web/documentserver-example/csharp/DocEditor.aspx
#	web/documentserver-example/csharp/DocEditor.aspx.cs
#	web/documentserver-example/csharp/WebEditor.ashx.cs
#	web/documentserver-example/java/src/main/java/controllers/EditorServlet.java
#	web/documentserver-example/java/src/main/java/controllers/IndexServlet.java
#	web/documentserver-example/java/src/main/webapp/editor.jsp
#	web/documentserver-example/nodejs/app.js
#	web/documentserver-example/nodejs/views/editor.ejs
#	web/documentserver-example/php/doceditor.php
#	web/documentserver-example/php/webeditor-ajax.php
#	web/documentserver-example/python/src/views/actions.py
#	web/documentserver-example/python/templates/editor.html
#	web/documentserver-example/ruby/app/models/file_model.rb
#	web/documentserver-example/ruby/app/views/home/editor.html.erb
2021-02-01 16:57:59 +03:00
48694f0f31 ruby: mailmerge 2021-02-01 12:33:23 +03:00
9ed7b0e96e ruby: fix cors 2021-01-31 16:02:57 +03:00
a2a094a22c Merge pull request #109 from ONLYOFFICE/feature/config-refactor
Feature/config refactor
2021-01-29 16:20:26 +03:00
9d9afce3ce GetServerUrl 2021-01-29 15:54:27 +03:00
bb19ea1a6f рhp: fix serverPath 2021-01-29 14:41:02 +03:00
d667a62a24 csharp: fix GetServerUrl 2021-01-29 14:28:56 +03:00
a92907135d csharp-mvc: fix GetServerUrl 2021-01-29 14:14:25 +03:00
71fde6f7b9 python: fix getServerUrl 2021-01-29 13:58:29 +03:00
9ac78b77dc ruby: fix get_server_url 2021-01-29 13:45:38 +03:00
dae246e8a2 Merge remote-tracking branch 'remotes/origin/develop' into feature/config-refactor
# Conflicts:
#	web/documentserver-example/java/src/main/java/controllers/EditorServlet.java
#	web/documentserver-example/python/src/views/actions.py
#	web/documentserver-example/ruby/config/application.rb
2021-01-29 12:49:30 +03:00
7f95d59394 java: fix jwtHeader 2021-01-29 12:38:23 +03:00
7bfa4229de ruby: add Rails.configuration.header 2021-01-29 12:35:10 +03:00
1c6c45606b ruby: add Rails.configuration.urlExample 2021-01-29 12:09:16 +03:00
1c0a742f54 ruby: config-refactor 2021-01-28 22:05:09 +03:00
4eb4753c01 Merge pull request #107 from ONLYOFFICE/feature/insert-image
Feature/insert image
2021-01-28 19:07:10 +03:00
979f001fd0 csharp: fixed tabulation 2021-01-28 17:47:48 +03:00
d0edb368ac csharp-mvc: fixed tabulation 2021-01-28 17:46:41 +03:00
ac36df16d1 csharp-mvc: moved functions 2021-01-28 17:35:34 +03:00
e845cc498b csharp: moved functions 2021-01-28 17:34:45 +03:00
606ce23228 nodejs: fix merge 2021-01-28 15:29:14 +03:00
dcd4adf5ad ruby: fix merge 2021-01-28 15:16:19 +03:00
6e81fa8996 Merge branch 'develop' into feature/insert-image
# Conflicts:
#	web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx
#	web/documentserver-example/csharp/DocEditor.aspx
#	web/documentserver-example/csharp/DocEditor.aspx.cs
#	web/documentserver-example/java/src/main/java/controllers/EditorServlet.java
#	web/documentserver-example/java/src/main/webapp/editor.jsp
#	web/documentserver-example/nodejs/app.js
#	web/documentserver-example/nodejs/views/editor.ejs
#	web/documentserver-example/php/doceditor.php
#	web/documentserver-example/python/src/views/actions.py
#	web/documentserver-example/python/templates/editor.html
#	web/documentserver-example/ruby/app/models/file_model.rb
#	web/documentserver-example/ruby/app/views/home/editor.html.erb
2021-01-28 15:12:36 +03:00
15580ee144 add logo.png csharp-mvc, csharp, java, nodejs, php, python, ruby 2021-01-28 14:48:44 +03:00
422bb36b53 delete logo.png csharp-mvc, csharp, java, nodejs, php, python, ruby 2021-01-28 14:46:00 +03:00
e74811a755 Merge pull request #108 from ONLYOFFICE/feature/compare-file
Feature/compare file
2021-01-28 14:11:57 +03:00
4c987fbfce nodejs: fix merge 2021-01-28 13:49:30 +03:00
e90ba356fe ruby: fix merge 2021-01-28 13:49:14 +03:00
54c6025bc5 Merge remote-tracking branch 'remotes/origin/develop' into feature/compare-file
# Conflicts:
#	web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx
#	web/documentserver-example/csharp/DocEditor.aspx
#	web/documentserver-example/java/src/main/webapp/editor.jsp
#	web/documentserver-example/nodejs/views/editor.ejs
#	web/documentserver-example/php/doceditor.php
#	web/documentserver-example/python/templates/editor.html
#	web/documentserver-example/ruby/app/views/home/editor.html.erb
2021-01-28 13:38:00 +03:00
b867d75bac ruby: compare-file 2021-01-28 13:28:28 +03:00
2748dbf5b3 csharp: fix tabulation 2021-01-28 11:28:24 +03:00
8b5aab3c63 Merge branch hotfix/v6.1.1 into develop 2021-01-28 08:15:33 +00:00
ee23e7948e ruby: jwt for insert-image 2021-01-28 11:13:10 +03:00
badcd6e110 ruby: fix merge 2021-01-28 10:50:24 +03:00
53e1fbe9ef nodejs fix merge 2021-01-28 10:49:44 +03:00
c28e12e31e add logo.png csharp-mvc, csharp, java, nodejs, php, python, ruby 2021-01-28 10:32:04 +03:00
b94704adf8 Merge remote-tracking branch 'remotes/origin/develop' into feature/insert-image
# Conflicts:
#	web/documentserver-example/csharp-mvc/Views/Home/Editor.aspx
#	web/documentserver-example/csharp/DocEditor.aspx
#	web/documentserver-example/java/src/main/webapp/editor.jsp
#	web/documentserver-example/nodejs/views/editor.ejs
#	web/documentserver-example/php/doceditor.php
#	web/documentserver-example/python/templates/editor.html
#	web/documentserver-example/ruby/app/views/home/editor.html.erb
2021-01-27 17:13:14 +03:00
255ec7afe9 python: reviewPermissions 2021-01-27 12:48:46 +03:00
7996ea4825 ruby: reviewPermissions 2021-01-27 12:31:26 +03:00
1fc1fb2b76 Merge pull request #106 from ONLYOFFICE/feature/add-format
Feature/add format
2021-01-27 11:51:38 +03:00
267fe7d260 Merge pull request #105 from ONLYOFFICE/feature/favorite
Feature/favorite
2021-01-27 11:49:21 +03:00
b8f5485201 Merge pull request #104 from ONLYOFFICE/feature/new-banner
Feature/new banner
2021-01-27 11:16:26 +03:00
d19eaf0ef4 js: new banner 2021-01-27 10:14:29 +03:00
9ee379e8df ruby: setFavorite 2021-01-26 17:04:38 +03:00
a4b75554bd csharp: fix banner 2021-01-26 16:18:00 +03:00
854f5e7045 csharp-mvc: fix banner 2021-01-26 16:14:31 +03:00
8cf4eb2fc2 Merge branch 'develop' into feature/new-banner 2021-01-26 16:06:46 +03:00
eba3f15587 ruby: fix banner 2021-01-26 16:02:48 +03:00
3f52fd5563 ruby: insert-image 2021-01-26 15:41:33 +03:00
b439a5f729 ruby: add fb2 to ConverExtList 2021-01-26 13:35:07 +03:00
848229f79c ruby: new banner 2021-01-26 13:22:17 +03:00
491f600dc0 csharp: added templates submodule 2021-01-25 12:22:42 +03:00
38055f0b85 csharp: reviewPermissions 2021-01-25 11:53:34 +03:00
0e3c759806 csharp: get-file 2021-01-25 01:45:57 +03:00
6427db4ea6 csharp: get-files 2021-01-25 01:39:28 +03:00
d624cdf0f6 csharp: fix-history 2021-01-25 00:50:04 +03:00
930338f5fc csharp: fix cors 2021-01-24 23:17:30 +03:00
0875ca8d89 csharp: add files.docservice.header 2021-01-24 23:11:43 +03:00
193bbe2cb7 csharp-mvc: fix files.docservice.header b2ee170ecb 2021-01-24 22:39:12 +03:00
533ee1af91 csharp-mvc: fix GetServerUrl a104aa6c61 2021-01-24 22:11:15 +03:00
db0339d4e4 csharp: add files.docservice.url.example 2021-01-24 22:10:19 +03:00
1a46b8a215 csharp: config-refactor 2021-01-24 16:41:07 +03:00
022f1bb16d csharp: setFavorite 2021-01-24 15:41:45 +03:00
c01afdec17 csharp-mvc: set favorite 2021-01-24 02:49:09 +03:00
b2ee170ecb csharp: add files.docservice.header 2021-01-22 14:43:51 +03:00
a104aa6c61 csharp: add files.docservice.url.example 2021-01-22 11:47:53 +03:00
3f13590f55 csharp-mvc: config-refactor 2021-01-21 14:48:25 +03:00
aa7132e467 csharp-mvc: fix-history 2021-01-20 22:31:01 +03:00
60ddcb433c Merge branch 'develop' into feature/fix-history 2021-01-20 21:58:27 +03:00
14840847bf csharp-mvc: get-file 2021-01-20 21:10:39 +03:00
06cf08822b csharp-mvc: get-files 2021-01-20 17:50:46 +03:00
c4e2921040 Merge branch 'develop' into feature/get-files 2021-01-20 14:52:30 +03:00
ea455421f7 csharp-mvc: fix cors 2021-01-20 12:10:22 +03:00
90abe267bf Merge branch 'develop' into feature/fix-history-cors 2021-01-20 12:04:38 +03:00
4e2a5fb175 csharp-mvc: reviewPermissions 2021-01-19 18:36:32 +03:00
c54b760526 Merge branch 'develop' into feature/reviewPermissions 2021-01-19 15:54:13 +03:00
a92963aed1 csharp-mvc: added templates submodule 2021-01-19 15:11:45 +03:00
d19ee9d4c1 python: added templates submodule 2021-01-16 21:19:36 +03:00
1a7fbe656b php: added templates submodule 2021-01-16 20:36:14 +03:00
500be4f8e4 java: added templates submodule 2021-01-16 20:02:54 +03:00
1b2cec44ac nodejs: mime v2 lookup renamed to getType (0a2056b1b1) 2020-12-25 10:03:42 +03:00
ecfe99f7ed Merge branch 'develop' into feature/mail-merge 2020-12-25 10:02:44 +03:00
81450a883f nodejs: mime v2 lookup renamed to getType (0a2056b1b1) 2020-12-25 10:02:29 +03:00
fec328ad9d python: setFavorite 2020-12-24 22:51:35 +03:00
b197f4c258 php: setFavorite 2020-12-24 22:50:28 +03:00
0b03093c53 java: setFavorite 2020-12-24 22:49:22 +03:00
3bf8952b1a nodejs: nodejs: templates submodule 2020-12-21 15:10:12 +03:00
23b42ed070 nodejs: restructured assets folder 2020-12-21 15:05:07 +03:00
25906383e2 nodejs: setFavorite 2020-12-16 09:57:29 +03:00
c597e914a9 nodejs: favorite 2020-12-15 17:33:00 +03:00
125d9a2ab4 Merge remote-tracking branch 'origin/release/v6.1.0' into develop 2020-12-07 12:45:21 +03:00
4dd4453599 csharp: jwt for HistoryData 2020-12-06 13:30:30 +03:00
7e2d83f04e csharp-mvc: jwt for HistoryData 2020-12-06 13:28:13 +03:00
b7d2775733 Merge branch 'feature/compare-file' of https://github.com/ONLYOFFICE/document-server-integration into feature/compare-file 2020-12-05 12:29:30 +03:00
aa5f1e3df4 csharp: compare-file 2020-12-05 12:22:35 +03:00
4193089de4 csharp-mvc: compare-file 2020-12-05 12:07:56 +03:00
18a4dc20eb csharp: insert-image 2020-12-04 19:03:02 +03:00
7ced0591bd csharp-mvc: insert-image 2020-12-04 18:19:54 +03:00
a010088395 csharp-mvc: fix mail-merge 2020-12-04 12:35:06 +03:00
d5a6c1e605 csharp: fix mail-merge 2020-12-04 12:33:22 +03:00
ab68d95f5d csharp-mvc: mail-merge 2020-12-02 19:22:20 +03:00
301775aafd csharp: mail-merge 2020-12-02 19:01:55 +03:00
51c180726c Merge remote-tracking branch 'remotes/origin/develop' into feature/mail-merge 2020-11-29 13:29:01 +03:00
aee637b980 python: check filename from url 2020-11-27 22:56:24 +03:00
63af540fe8 php: check filename from url 2020-11-27 22:55:01 +03:00
2819cbc5e3 java: check filename from url 2020-11-27 22:52:22 +03:00
02db6fa76a csharp: added .fb2 to ConverExtList 2020-11-27 17:16:06 +03:00
1feb56e397 csharp-mvc: added .fb2 to ConverExtList 2020-11-27 17:14:34 +03:00
502f001cfa Merge branch 'feature/csharp' into feature/add-format 2020-11-27 17:02:04 +03:00
7c10a0fe82 csharp-mvc: banner 2020-11-27 16:27:12 +03:00
aa16df8de7 java: fix filename (38cc631e2e) 2020-11-27 15:25:47 +03:00
bbff0206c1 php: fix filename (7b017c15f8) 2020-11-27 13:09:10 +03:00
e08e6f5f27 java: jwt for compare-file 2020-11-27 11:34:10 +03:00
38cc631e2e java: compare-file 2020-11-27 11:31:13 +03:00
6250902a55 php: jwt for compare-file 2020-11-27 11:00:16 +03:00
7b017c15f8 php: compare-file 2020-11-27 10:57:50 +03:00
b21d179f4b python: jwt for compare-file 2020-11-26 18:32:06 +03:00
c75f9166c5 python: compare-file 2020-11-26 18:30:27 +03:00
0f2695fba0 nodejs: jwt for compare-file 2020-11-26 18:16:44 +03:00
aca8e94f2a nodejs: compare-file 2020-11-26 18:13:01 +03:00
9876e745e5 python: jwt for insert-image 2020-11-26 17:27:01 +03:00
eb8cf75bc0 java: jwt for insert-image 2020-11-26 17:23:21 +03:00
62060d2538 php: jwt for insert-image 2020-11-26 17:20:57 +03:00
0ad9907eb6 nodejs: jwt for insert-image 2020-11-26 17:18:04 +03:00
2090bad807 nodejs: insert-image 2020-11-26 17:12:53 +03:00
2368354c6d php: insert-image 2020-11-26 16:10:09 +03:00
31337cc9c9 python: insert-image 2020-11-26 15:33:16 +03:00
17cad4a0dc java: insert-image 2020-11-26 14:54:09 +03:00
48fa83b850 php: jwt for mailmerge 2020-11-26 01:16:33 +03:00
2017c45c19 java: jwt for mailmerge 2020-11-26 01:07:23 +03:00
74505f5c44 nodejs: jwt for mailmerge 2020-11-26 00:31:42 +03:00
6f6e80cf68 python: jwt for mailmerge 2020-11-26 00:14:12 +03:00
d5a8cdc760 python: jwt for historyData 2020-11-25 18:54:46 +03:00
ca5ba06506 php: jwt for historyData 2020-11-25 18:47:12 +03:00
720c61c7b7 java: jwt for historyData 2020-11-25 18:40:30 +03:00
6e03e71b59 php: add DOC_SERV_JWT_HEADER 2020-11-25 10:20:29 +03:00
ea22efdac8 java: fix 773aa62478 2020-11-24 22:24:19 +03:00
5521cd44dd python: add DOC_SERV_JWT_HEADER 2020-11-24 13:27:54 +03:00
773aa62478 java: add files.docservice.url.example 2020-11-23 17:22:02 +03:00
280d9e3dba nodejs: fix config 2020-11-23 15:47:37 +03:00
ee5fe30010 python: fix 791f2b53a9 2020-11-23 15:19:38 +03:00
c0b520e440 php: config-refactor 2020-11-23 11:00:57 +03:00
fd95aca32b java: config-refactor 2020-11-23 10:42:32 +03:00
791f2b53a9 python: config-refactor 2020-11-20 18:16:26 +03:00
9f806aa48a java: fix banner 2020-11-19 17:48:51 +03:00
85dd8f8b77 java: add fb2 to ConverExtList 2020-11-19 17:18:13 +03:00
e91beb5518 php: add fb2 to ConverExtList 2020-11-19 16:45:10 +03:00
39fbf43019 python: add fb2 to ConverExtList 2020-11-19 13:59:09 +03:00
e8eb607325 python: fix-history 2020-11-19 12:17:04 +03:00
974840bbac python: new banner 2020-11-18 18:26:53 +03:00
be5f6e3a6e python: fix 4903c017f4 2020-11-18 18:14:59 +03:00
19debed4d1 php: fix 9b7d54fdfb 2020-11-18 17:50:41 +03:00
4903c017f4 python: mailmerge 2020-11-18 17:48:19 +03:00
6c3f31c32a python: get-file 2020-11-18 14:57:17 +03:00
73d79c1f61 python: get-files 2020-11-18 14:55:23 +03:00
4ef5f7d290 nodejs, java: add Content-Type, fix 2e3fd4725a, 1d24a4a309 2020-11-16 16:02:12 +03:00
9b7d54fdfb php: mailmerge 2020-11-16 15:45:28 +03:00
4e17421c7e php: get-file 2020-11-16 11:16:51 +03:00
2b4513d68b php: get-files 2020-11-15 20:53:04 +03:00
47c0b04de1 php: new banner 2020-11-13 14:38:45 +03:00
ee077978b9 php: fix-history 2020-11-13 14:32:14 +03:00
1dc5e67da6 php: fix cors 2020-11-13 11:48:40 +03:00
cf4dd454f6 php: reviewPermission 2020-11-13 11:43:10 +03:00
858b437e80 java: reviewPermissions 2020-11-12 16:46:25 +03:00
0512243be0 java: fix-history 2020-11-12 10:28:38 +03:00
ba3b3b4ce6 java: fix cors 2020-11-11 14:15:54 +03:00
57e813d0ce fixed tabulation 1d24a4a309 2020-11-10 15:35:34 +03:00
1d24a4a309 The GetFilesInfo () method has been improved. If the method is called without a parameter, then the entire list of files is returned, if the idFile parameter is specified, then information about the file with id: idFile is returned. 2020-11-09 18:15:45 +03:00
fe7e7640b5 method getFilesInFolderInfo() moved from nodejs example to java example 2020-11-09 15:23:48 +03:00
67b93909ac java: mailmerge 2020-11-09 11:10:34 +03:00
17f651c47a java: new banner 2020-11-06 11:29:47 +03:00
928cc7480a nodejs: new banner 2020-11-06 11:10:39 +03:00
bf8e59ddee csharp: new banner 2020-11-06 10:46:25 +03:00
715ab7d690 nodejs: reviewPermissions 2020-10-06 12:47:31 +03:00
fa0aad779d nodejs: mailmerge 2020-07-07 16:27:26 +03:00
182 changed files with 4259 additions and 1278 deletions

28
.gitmodules vendored Normal file
View File

@ -0,0 +1,28 @@
[submodule "web/documentserver-example/nodejs/public/assets"]
path = web/documentserver-example/nodejs/public/assets
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/java/src/main/resources/assets"]
path = web/documentserver-example/java/src/main/resources/assets
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/php/assets"]
path = web/documentserver-example/php/assets
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/python/assets"]
path = web/documentserver-example/python/assets
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/csharp-mvc/assets"]
path = web/documentserver-example/csharp-mvc/assets
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/csharp/assets"]
path = web/documentserver-example/csharp/assets
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/ruby/public/assets"]
path = web/documentserver-example/ruby/public/assets
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en

View File

@ -80,4 +80,4 @@ If you have any problems with or questions about [ONLYOFFICE Document Server][2]
## License
document-server-integration is released under the MIT License. See the LICENSE.txt file for more information.
document-server-integration is released under the Apache-2.0 License. See the LICENSE.txt file for more information.

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,15 @@
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -44,10 +44,13 @@ a, a:hover, a:visited {
.top-panel {
background: url("images/logo.png") no-repeat 30px center #3D4A6B;
background: #3D4A6B;
height: 80px;
width: 100%;
}
.top-panel img {
margin: 12px 0 0 16px;
}
.main-panel {
margin: 80px auto;
width: 600px;
@ -125,13 +128,13 @@ label .checkbox {
text-align: center;
text-decoration: none;
}
.try-editor.document {
.try-editor.word {
background-image: url("images/file_docx.png");
}
.try-editor.spreadsheet {
.try-editor.cell {
background-image: url("images/file_xlsx.png");
}
.try-editor.presentation {
.try-editor.slide {
background-image: url("images/file_pptx.png");
}
@ -324,26 +327,26 @@ label .checkbox {
white-space: nowrap;
}
.stored-edit.text {
background-image: url("images/icon_docx.png");
}
.stored-edit.word {
background-image: url("images/icon_docx.png");
}
.stored-edit.spreadsheet {
background-image: url("images/icon_xlsx.png");
}
.stored-edit.cell {
background-image: url("images/icon_xlsx.png");
}
.stored-edit.presentation {
background-image: url("images/icon_pptx.png");
}
.stored-edit.slide {
background-image: url("images/icon_pptx.png");
}
.stored-edit span {
font-size: 12px;
line-height: 12px;
}
.stored-edit span {
font-size: 12px;
line-height: 12px;
}
.stored-edit:hover span {
text-decoration: underline;
}
.stored-edit:hover span {
text-decoration: underline;
}
.blockTitle {

View File

@ -16,6 +16,7 @@
*
*/
using System.IO;
using System.Web.Mvc;
using OnlineEditorsExampleMVC.Helpers;
using OnlineEditorsExampleMVC.Models;
@ -35,7 +36,7 @@ namespace OnlineEditorsExampleMVC.Controllers
{
Mode = editorsMode,
Type = editorsType,
FileName = fileName
FileName = Path.GetFileName(fileName)
};
return View("Editor", file);

View File

@ -72,7 +72,40 @@ namespace OnlineEditorsExampleMVC.Helpers
{
Directory.CreateDirectory(directory);
}
return directory + fileName;
return directory + Path.GetFileName(fileName);
}
public static string ForcesavePath(string fileName, string userAddress, Boolean create)
{
var directory = HttpRuntime.AppDomainAppPath + CurUserHostAddress(userAddress) + "\\";
if (!Directory.Exists(directory))
{
return "";
}
directory = directory + Path.GetFileName(fileName) + "-hist" + "\\";
if (!Directory.Exists(directory))
{
if (create)
{
Directory.CreateDirectory(directory);
}
else
{
return "";
}
}
directory = directory + Path.GetFileName(fileName);
if (!File.Exists(directory))
{
if (!create)
{
return "";
}
}
return directory;
}
public static string HistoryDir(string storagePath)
@ -93,7 +126,7 @@ namespace OnlineEditorsExampleMVC.Helpers
public static int GetFileVersion(string historyPath)
{
if (!Directory.Exists(historyPath)) return 0;
return Directory.EnumerateDirectories(historyPath).Count();
return Directory.EnumerateDirectories(historyPath).Count() + 1;
}
public static int GetFileVersion(string fileName, string userAddress)
@ -101,55 +134,57 @@ namespace OnlineEditorsExampleMVC.Helpers
return GetFileVersion(HistoryDir(StoragePath(fileName, userAddress)));
}
public static string GetCorrectName(string fileName)
public static string GetCorrectName(string fileName, string userAddress = null)
{
var baseName = Path.GetFileNameWithoutExtension(fileName);
var ext = Path.GetExtension(fileName);
var name = baseName + ext;
for (var i = 1; File.Exists(StoragePath(name)); i++)
for (var i = 1; File.Exists(StoragePath(name, userAddress)); i++)
{
name = baseName + " (" + i + ")" + ext;
}
return name;
}
public static List<string> GetStoredFiles()
public static List<FileInfo> GetStoredFiles()
{
var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
if (!Directory.Exists(directory)) return new List<string>();
if (!Directory.Exists(directory)) return new List<FileInfo>();
var directoryInfo = new DirectoryInfo(directory);
var storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Select(fileInfo => fileInfo.Name).ToList();
List<FileInfo> storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).ToList();
return storedFiles;
}
public static string CreateDemo(string fileExt, bool withContent)
{
var demoName = (withContent ? "sample." : "new.") + fileExt;
var demoPath = "assets\\" + (withContent ? "sample\\" : "new\\");
var fileName = GetCorrectName(demoName);
File.Copy(HttpRuntime.AppDomainAppPath + "app_data\\" + demoName, StoragePath(fileName));
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, StoragePath(fileName));
return fileName;
}
public static void CreateMeta(string fileName, string uid, string uname)
public static void CreateMeta(string fileName, string uid, string uname, string userAddress = null)
{
var histDir = HistoryDir(StoragePath(fileName, null));
var histDir = HistoryDir(StoragePath(fileName, userAddress));
Directory.CreateDirectory(histDir);
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
{ "created", DateTime.Now.ToString() },
{ "created", DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss") },
{ "id", string.IsNullOrEmpty(uid) ? "uid-1" : uid },
{ "name", string.IsNullOrEmpty(uname) ? "John Smith" : uname }
}));
}
public static string GetFileUri(string fileName)
public static string GetFileUri(string fileName, Boolean forDocumentServer)
{
var uri = new UriBuilder(HttpContext.Current.Request.Url)
var uri = new UriBuilder(GetServerUrl(forDocumentServer))
{
Path = HttpRuntime.AppDomainAppVirtualPath + "/"
+ CurUserHostAddress() + "/"
@ -162,7 +197,7 @@ namespace OnlineEditorsExampleMVC.Helpers
public static string GetPathUri(string path)
{
var uri = new UriBuilder(HttpContext.Current.Request.Url)
var uri = new UriBuilder(GetServerUrl(true))
{
Path = HttpRuntime.AppDomainAppVirtualPath + "/"
+ path,
@ -172,9 +207,26 @@ namespace OnlineEditorsExampleMVC.Helpers
return uri.ToString();
}
public static string GetServerUrl(Boolean forDocumentServer)
{
if (forDocumentServer && !WebConfigurationManager.AppSettings["files.docservice.url.example"].Equals(""))
{
return WebConfigurationManager.AppSettings["files.docservice.url.example"];
}
else
{
var uri = new UriBuilder(HttpContext.Current.Request.Url) { Query = "" };
var requestHost = HttpContext.Current.Request.Headers["Host"];
if (!string.IsNullOrEmpty(requestHost))
uri = new UriBuilder(uri.Scheme + "://" + requestHost);
return uri.ToString();
}
}
public static string GetCallback(string fileName)
{
var callbackUrl = new UriBuilder(HttpContext.Current.Request.Url)
var callbackUrl = new UriBuilder(GetServerUrl(true))
{
Path =
HttpRuntime.AppDomainAppVirtualPath
@ -191,15 +243,46 @@ namespace OnlineEditorsExampleMVC.Helpers
{
switch (fileType)
{
case FileUtility.FileType.Text:
case FileUtility.FileType.Word:
return ".docx";
case FileUtility.FileType.Spreadsheet:
case FileUtility.FileType.Cell:
return ".xlsx";
case FileUtility.FileType.Presentation:
case FileUtility.FileType.Slide:
return ".pptx";
default:
return ".docx";
}
}
public static List<Dictionary<string, object>> GetFilesInfo(string fileId = null)
{
var files = new List<Dictionary<string, object>>();
foreach (var file in GetStoredFiles())
{
var dictionary = new Dictionary<string, object>();
dictionary.Add("version", GetFileVersion(file.Name, null));
dictionary.Add("id", ServiceConverter.GenerateRevisionId(DocManagerHelper.CurUserHostAddress() + "/" + file.Name + "/" + File.GetLastWriteTime(DocManagerHelper.StoragePath(file.Name, null)).GetHashCode()));
dictionary.Add("contentLength", Math.Round(file.Length / 1024.0, 2) + " KB");
dictionary.Add("pureContentLength", file.Length);
dictionary.Add("title", file.Name);
dictionary.Add("updated", file.LastWriteTime.ToString());
if (fileId != null)
{
if (fileId.Equals(dictionary["id"]))
{
files.Add(dictionary);
break;
}
}
else
{
files.Add(dictionary);
}
}
return files;
}
}
}

View File

@ -38,7 +38,7 @@ namespace OnlineEditorsExampleMVC.Helpers
/// </summary>
static ServiceConverter()
{
DocumentConverterUrl = WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "";
DocumentConverterUrl = (WebConfigurationManager.AppSettings["files.docservice.url.site"] ?? "") + (WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "");
Int32.TryParse(WebConfigurationManager.AppSettings["files.docservice.timeout"], out ConvertTimeout);
ConvertTimeout = ConvertTimeout > 0 ? ConvertTimeout : 120000;
@ -119,7 +119,8 @@ namespace OnlineEditorsExampleMVC.Helpers
var payloadToken = JwtManager.Encode(payload);
var bodyToken = JwtManager.Encode(body);
request.Headers.Add("Authorization", "Bearer " + payloadToken);
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
request.Headers.Add(JWTheader, "Bearer " + payloadToken);
body.Add("token", bodyToken);
}

View File

@ -0,0 +1,290 @@
/**
*
* (c) Copyright Ascensio System SIA 2020
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.IO;
using System.Net;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.Web.Configuration;
using System.Linq;
using System.Web;
using System.Text;
namespace OnlineEditorsExampleMVC.Helpers
{
public class TrackManager
{
public static Dictionary<string, object> readBody(HttpContext context)
{
string body;
try
{
using (var receiveStream = context.Request.InputStream)
using (var readStream = new StreamReader(receiveStream))
{
body = readStream.ReadToEnd();
if (string.IsNullOrEmpty(body)) context.Response.Write("{\"error\":1,\"message\":\"Request stream is empty\"}");
}
}
catch (Exception e)
{
throw new HttpException((int)HttpStatusCode.BadRequest, e.Message);
}
var jss = new JavaScriptSerializer();
var fileData = jss.Deserialize<Dictionary<string, object>>(body);
if (JwtManager.Enabled)
{
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
string token = null;
if (fileData.ContainsKey("token"))
{
token = JwtManager.Decode(fileData["token"].ToString());
}
else if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
{
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
token = JwtManager.Decode(headerToken);
}
else
{
context.Response.Write("{\"error\":1,\"message\":\"JWT expected\"}");
}
if (token != null && !token.Equals(""))
{
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(token)["payload"];
}
else
{
context.Response.Write("{\"error\":1,\"message\":\"JWT validation failed\"}");
}
}
return fileData;
}
public static int processSave(Dictionary<string, object> fileData, string fileName, string userAddress)
{
var downloadUri = (string)fileData["url"];
string curExt = Path.GetExtension(fileName);
string downloadExt = Path.GetExtension(downloadUri) ?? "";
var newFileName = fileName;
if (!curExt.Equals(downloadExt, StringComparison.InvariantCultureIgnoreCase))
{
try
{
string newFileUri;
var result = ServiceConverter.GetConvertedUri(downloadUri, downloadExt, curExt, ServiceConverter.GenerateRevisionId(downloadUri), false, out newFileUri);
if (string.IsNullOrEmpty(newFileUri))
{
newFileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
else
{
downloadUri = newFileUri;
}
}
catch (Exception)
{
newFileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
}
var storagePath = DocManagerHelper.StoragePath(newFileName, userAddress);
var histDir = DocManagerHelper.HistoryDir(storagePath);
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir));
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir);
File.Move(DocManagerHelper.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
DownloadToFile(downloadUri, storagePath);
DownloadToFile((string)fileData["changesurl"], Path.Combine(versionDir, "diff.zip"));
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
{
var jss = new JavaScriptSerializer();
hist = jss.Serialize(fileData["history"]);
}
if (!string.IsNullOrEmpty(hist))
{
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist);
}
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]);
string forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, false);
if (!forcesavePath.Equals(""))
{
File.Delete(forcesavePath);
}
return 0;
}
public static int processForceSave(Dictionary<string, object> fileData, string fileName, string userAddress)
{
var downloadUri = (string)fileData["url"];
string curExt = Path.GetExtension(fileName);
string downloadExt = Path.GetExtension(downloadUri);
var newFileName = fileName;
if (!curExt.Equals(downloadExt))
{
try
{
string newFileUri;
var result = ServiceConverter.GetConvertedUri(downloadUri, downloadExt, curExt, ServiceConverter.GenerateRevisionId(downloadUri), false, out newFileUri);
if (string.IsNullOrEmpty(newFileUri))
{
newFileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
else
{
downloadUri = newFileUri;
}
}
catch (Exception)
{
newFileName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
}
string forcesavePath = "";
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3");
if (isSubmitForm)
{
if (newFileName.Equals(fileName))
{
newFileName = DocManagerHelper.GetCorrectName(fileName, userAddress);
}
forcesavePath = DocManagerHelper.StoragePath(newFileName, userAddress);
}
else
{
forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, false);
if (forcesavePath.Equals(""))
{
forcesavePath = DocManagerHelper.ForcesavePath(newFileName, userAddress, true);
}
}
DownloadToFile(downloadUri, forcesavePath);
if (isSubmitForm)
{
var jss = new JavaScriptSerializer();
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
var user = action["userid"].ToString();
DocManagerHelper.CreateMeta(newFileName, user, "Filling Form", userAddress);
}
return 0;
}
public static void commandRequest(string method, string key)
{
string documentCommandUrl = WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.command"];
var request = (HttpWebRequest)WebRequest.Create(documentCommandUrl);
request.Method = "POST";
request.ContentType = "application/json";
var body = new Dictionary<string, object>() {
{ "c", method },
{ "key", key }
};
if (JwtManager.Enabled)
{
var payload = new Dictionary<string, object>
{
{ "payload", body }
};
var payloadToken = JwtManager.Encode(payload);
var bodyToken = JwtManager.Encode(body);
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
request.Headers.Add(JWTheader, "Bearer " + payloadToken);
body.Add("token", bodyToken);
}
var bytes = Encoding.UTF8.GetBytes(new JavaScriptSerializer().Serialize(body));
request.ContentLength = bytes.Length;
using (var requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
string dataResponse;
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
{
if (stream == null) throw new Exception("Response is null");
using (var reader = new StreamReader(stream))
{
dataResponse = reader.ReadToEnd();
}
}
var jss = new JavaScriptSerializer();
var responseObj = jss.Deserialize<Dictionary<string, object>>(dataResponse);
if (!responseObj["error"].ToString().Equals("0"))
{
throw new Exception(dataResponse);
}
}
private static void DownloadToFile(string url, string path)
{
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url");
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path");
var req = (HttpWebRequest)WebRequest.Create(url);
using (var stream = req.GetResponse().GetResponseStream())
{
if (stream == null) throw new Exception("stream is null");
const int bufferSize = 4096;
using (var fs = File.Open(path, FileMode.Create))
{
var buffer = new byte[bufferSize];
int readed;
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
{
fs.Write(buffer, 0, readed);
}
}
}
}
}
}

View File

@ -34,7 +34,12 @@ namespace OnlineEditorsExampleMVC.Models
public string FileUri
{
get { return DocManagerHelper.GetFileUri(FileName); }
get { return DocManagerHelper.GetFileUri(FileName, true); }
}
public string FileUriUser
{
get { return DocManagerHelper.GetFileUri(FileName, false); }
}
public string FileName { get; set; }
@ -63,6 +68,28 @@ namespace OnlineEditorsExampleMVC.Models
var canEdit = DocManagerHelper.EditedExts.Contains(ext);
var mode = canEdit && editorsMode != "view" ? "edit" : "view";
var submitForm = canEdit && (editorsMode.Equals("edit") || editorsMode.Equals("fillForms"));
var userId = request.Cookies.GetOrDefault("uid", "uid-1");
var uname = userId.Equals("uid-0") ? null : request.Cookies.GetOrDefault("uname", "John Smith");
string userGroup = null;
List<string> reviewGroups = null;
if (userId.Equals("uid-2"))
{
userGroup = "group-2";
reviewGroups = new List<string>() { "group-2", "" };
}
if (userId.Equals("uid-3"))
{
userGroup = "group-3";
reviewGroups = new List<string>() { "group-2" };
}
object favorite = null;
if (!string.IsNullOrEmpty(request.Cookies.GetOrDefault("uid", null)))
{
favorite = request.Cookies.GetOrDefault("uid", null).Equals("uid-2");
}
var actionLink = request.GetOrDefault("actionLink", null);
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink);
@ -81,8 +108,9 @@ namespace OnlineEditorsExampleMVC.Models
{
"info", new Dictionary<string, object>
{
{ "author", "Me" },
{ "created", DateTime.Now.ToShortDateString() }
{ "owner", "Me" },
{ "uploaded", DateTime.Now.ToShortDateString() },
{ "favorite", favorite}
}
},
{
@ -94,7 +122,8 @@ namespace OnlineEditorsExampleMVC.Models
{ "fillForms", editorsMode != "view" && editorsMode != "comment" && editorsMode != "embedded" && editorsMode != "blockcontent" },
{ "modifyFilter", editorsMode != "filter" },
{ "modifyContentControl", editorsMode != "blockcontent" },
{ "review", editorsMode == "edit" || editorsMode == "review" }
{ "review", editorsMode == "edit" || editorsMode == "review" },
{ "reviewGroups", reviewGroups }
}
}
}
@ -109,16 +138,17 @@ namespace OnlineEditorsExampleMVC.Models
{
"user", new Dictionary<string, object>
{
{ "id", request.Cookies.GetOrDefault("uid", "uid-1") },
{ "name", request.Cookies.GetOrDefault("uname", "John Smith") }
{ "id", userId },
{ "name", uname },
{ "group", userGroup }
}
},
{
"embedded", new Dictionary<string, object>
{
{ "saveUrl", FileUri },
{ "embedUrl", FileUri },
{ "shareUrl", FileUri },
{ "saveUrl", FileUriUser },
{ "embedUrl", FileUriUser },
{ "shareUrl", FileUriUser },
{ "toolbarDocked", "top" }
}
},
@ -127,6 +157,8 @@ namespace OnlineEditorsExampleMVC.Models
{
{ "about", true },
{ "feedback", true },
{ "forcesave", false },
{ "submitForm", submitForm },
{
"goback", new Dictionary<string, object>
{
@ -162,18 +194,18 @@ namespace OnlineEditorsExampleMVC.Models
var hist = new List<Dictionary<string, object>>();
var histData = new Dictionary<string, object>();
for (var i = 0; i <= currentVersion; i++)
for (var i = 1; i <= currentVersion; i++)
{
var obj = new Dictionary<string, object>();
var dataObj = new Dictionary<string, object>();
var verDir = DocManagerHelper.VersionDir(histDir, i + 1);
var verDir = DocManagerHelper.VersionDir(histDir, i);
var key = i == currentVersion ? Key : File.ReadAllText(Path.Combine(verDir, "key.txt"));
obj.Add("key", key);
obj.Add("version", i);
if (i == 0)
if (i == 1)
{
var infoPath = Path.Combine(histDir, "createdInfo.json");
@ -191,9 +223,9 @@ namespace OnlineEditorsExampleMVC.Models
dataObj.Add("key", key);
dataObj.Add("url", i == currentVersion ? FileUri : DocManagerHelper.GetPathUri(Directory.GetFiles(verDir, "prev.*")[0].Substring(HttpRuntime.AppDomainAppPath.Length)));
dataObj.Add("version", i);
if (i > 0)
if (i > 1)
{
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(DocManagerHelper.VersionDir(histDir, i), "changes.json")));
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(DocManagerHelper.VersionDir(histDir, i - 1), "changes.json")));
var change = ((Dictionary<string, object>)((ArrayList)changes["changes"])[0]);
obj.Add("changes", changes["changes"]);
@ -201,16 +233,20 @@ namespace OnlineEditorsExampleMVC.Models
obj.Add("created", change["created"]);
obj.Add("user", change["user"]);
var prev = (Dictionary<string, object>)histData[(i - 1).ToString()];
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()];
dataObj.Add("previous", new Dictionary<string, object>() {
{ "key", prev["key"] },
{ "url", prev["url"] },
});
dataObj.Add("changesUrl", DocManagerHelper.GetPathUri(Path.Combine(DocManagerHelper.VersionDir(histDir, i), "diff.zip").Substring(HttpRuntime.AppDomainAppPath.Length)));
dataObj.Add("changesUrl", DocManagerHelper.GetPathUri(Path.Combine(DocManagerHelper.VersionDir(histDir, i - 1), "diff.zip").Substring(HttpRuntime.AppDomainAppPath.Length)));
}
if(JwtManager.Enabled)
{
var token = JwtManager.Encode(dataObj);
dataObj.Add("token", token);
}
hist.Add(obj);
histData.Add(i.ToString(), dataObj);
histData.Add((i - 1).ToString(), dataObj);
}
history = jss.Serialize(new Dictionary<string, object>()
@ -221,5 +257,86 @@ namespace OnlineEditorsExampleMVC.Models
historyData = jss.Serialize(histData);
}
}
public void GetCompareFileData(out string compareConfig)
{
var jss = new JavaScriptSerializer();
var compareFileUrl = new UriBuilder(DocManagerHelper.GetServerUrl(true))
{
Path = HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "webeditor.ashx",
Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx")
};
var dataCompareFile = new Dictionary<string, object>
{
{ "fileType", "docx" },
{ "url", compareFileUrl.ToString() }
};
if (JwtManager.Enabled)
{
var compareFileToken = JwtManager.Encode(dataCompareFile);
dataCompareFile.Add("token", compareFileToken);
}
compareConfig = jss.Serialize(dataCompareFile);
}
public void GetLogoConfig(out string logoUrl)
{
var jss = new JavaScriptSerializer();
var mailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(true))
{
Path = HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "Content\\images\\logo.png"
};
var logoConfig = new Dictionary<string, object>
{
{ "fileType", "png"},
{ "url", mailMergeUrl.ToString()}
};
if (JwtManager.Enabled)
{
var token = JwtManager.Encode(logoConfig);
logoConfig.Add("token", token);
}
logoUrl = jss.Serialize(logoConfig).Replace("{", "").Replace("}", "");
}
public void GetMailMergeConfig(out string dataMailMergeRecipients)
{
var jss = new JavaScriptSerializer();
var mailMergeUrl = new UriBuilder(DocManagerHelper.GetServerUrl(true))
{
Path =
HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "webeditor.ashx",
Query = "type=csv"
};
var mailMergeConfig = new Dictionary<string, object>
{
{ "fileType", "csv" },
{ "url", mailMergeUrl.ToString()}
};
if (JwtManager.Enabled)
{
var mailmergeToken = JwtManager.Encode(mailMergeConfig);
mailMergeConfig.Add("token", mailmergeToken);
}
dataMailMergeRecipients = jss.Serialize(mailMergeConfig);
}
}
}

View File

@ -25,20 +25,20 @@ namespace OnlineEditorsExampleMVC.Models
{
public enum FileType
{
Text,
Spreadsheet,
Presentation
Word,
Cell,
Slide
}
public static FileType GetFileType(string fileName)
{
var ext = Path.GetExtension(fileName).ToLower();
if (ExtsDocument.Contains(ext)) return FileType.Text;
if (ExtsSpreadsheet.Contains(ext)) return FileType.Spreadsheet;
if (ExtsPresentation.Contains(ext)) return FileType.Presentation;
if (ExtsDocument.Contains(ext)) return FileType.Word;
if (ExtsSpreadsheet.Contains(ext)) return FileType.Cell;
if (ExtsPresentation.Contains(ext)) return FileType.Slide;
return FileType.Text;
return FileType.Word;
}
public static readonly List<string> ExtsDocument = new List<string>
@ -46,7 +46,7 @@ namespace OnlineEditorsExampleMVC.Models
".doc", ".docx", ".docm",
".dot", ".dotx", ".dotm",
".odt", ".fodt", ".ott", ".rtf", ".txt",
".html", ".htm", ".mht",
".html", ".htm", ".mht", ".xml",
".pdf", ".djvu", ".fb2", ".epub", ".xps"
};

View File

@ -105,6 +105,7 @@
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Helpers\TrackManager.cs" />
<Compile Include="Helpers\DocManagerHelper.cs" />
<Compile Include="Helpers\DocumentConverter.cs" />
<Compile Include="Helpers\JwtManager.cs" />
@ -120,6 +121,7 @@
<Content Include="Content\editor.css" />
<Content Include="Content\images\alert.png" />
<Content Include="Content\images\block-content-24.png" />
<Content Include="Content\images\cell.ico" />
<Content Include="Content\images\close.png" />
<Content Include="Content\images\comment-24.png" />
<Content Include="Content\images\corner.png" />
@ -139,6 +141,8 @@
<Content Include="Content\images\mobile-24.png" />
<Content Include="Content\images\question_small.png" />
<Content Include="Content\images\review-24.png" />
<Content Include="Content\images\slide.ico" />
<Content Include="Content\images\word.ico" />
<Content Include="Content\jquery-ui.css" />
<Content Include="Content\stylesheet.css" />
<Content Include="favicon.ico" />
@ -168,9 +172,15 @@
<Content Include="WebEditor.ashx" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
</ItemGroup>
<ItemGroup>
<Content Include="assets\AUTHORS.md" />
<Content Include="assets\LICENSE" />
<Content Include="assets\new\new.docx" />
<Content Include="assets\new\new.pptx" />
<Content Include="assets\new\new.xlsx" />
<Content Include="assets\sample\csv.csv" />
<Content Include="assets\sample\sample.docx" />
<Content Include="assets\sample\sample.pptx" />
<Content Include="assets\sample\sample.xlsx" />
<None Include="packages.config" />
</ItemGroup>
<PropertyGroup>

View File

@ -29,7 +29,7 @@
* limitations under the License.
*
-->
<link rel="icon" href="~/favicon.ico" type="image/x-icon" />
<link rel="icon" href="<%= "content/images/" + Model.DocumentType + ".ico" %>" type="image/x-icon" />
<title><%= Model.FileName + " - ONLYOFFICE" %></title>
<%: Styles.Render("~/Content/editor") %>
@ -41,7 +41,7 @@
</div>
</div>
<%: Scripts.Render(new []{ WebConfigurationManager.AppSettings["files.docservice.url.api"] }) %>
<%: Scripts.Render(new []{ WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.api"] }) %>
<script type="text/javascript" language="javascript">
@ -96,6 +96,34 @@
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
};
var onMetaChange = function (event) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite);
};
var onRequestInsertImage = function (event) {
<% string logoUrl;%>
<% Model.GetLogoConfig(out logoUrl); %>
docEditor.insertImage({
"c": event.data.c,
<%= logoUrl%>
})
};
var onRequestCompareFile = function () {
<% string compareFileData; %>
<% Model.GetCompareFileData(out compareFileData); %>
docEditor.setRevisedFile(<%=compareFileData%>);
};
var onRequestMailMergeRecipients = function (event) {
<% string dataMailMergeRecipients; %>
<% Model.GetMailMergeConfig(out dataMailMergeRecipients); %>
docEditor.setMailMergeRecipients(<%= dataMailMergeRecipients%>);
};
var config = <%= Model.GetDocConfig(Request, Url) %>;
config.width = "100%";
@ -108,6 +136,10 @@
'onError': onError,
'onOutdatedVersion': onOutdatedVersion,
"onMakeActionLink": onMakeActionLink,
"onMetaChange": onMetaChange,
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
};
<% string hist, histData; %>
@ -120,7 +152,7 @@
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = <%= histData %>;
docEditor.setHistoryData(histData[ver]);
docEditor.setHistoryData(histData[ver - 1]);
};
config.events['onRequestHistoryClose '] = function () {
document.location.reload();

View File

@ -37,7 +37,11 @@
<%: Styles.Render("~/Content/css") %>
</head>
<body>
<div class="top-panel"></div>
<div class="top-panel">
<a href="">
<img src ="content/images/logo.svg" alt="ONLYOFFICE" />
</a>
</div>
<div class="main-panel">
<span class="portal-name">ONLYOFFICE Document Editors</span>
<br />
@ -53,6 +57,7 @@
<option value="uid-1">John Smith</option>
<option value="uid-2">Mark Pottato</option>
<option value="uid-3">Hamish Mitchell</option>
<option value="uid-0">anonymous</option>
</select>
</td>
<td width="70%" valign="middle">Select user name before opening the document; you can open the same document using different users in different Web browser sessions, so you can check out multi-user editing functions.</td>
@ -116,9 +121,9 @@
</div>
<div class="create-panel">
<ul class="try-editor-list clearFix" data-link="<%= Url.Action("sample", "Home") %>">
<li><a class="try-editor document" data-type="docx">Create<br />Document</a></li>
<li><a class="try-editor spreadsheet" data-type="xlsx">Create<br />Spreadsheet</a></li>
<li><a class="try-editor presentation" data-type="pptx">Create<br />Presentation</a></li>
<li><a class="try-editor word" data-type="docx">Create<br />Document</a></li>
<li><a class="try-editor cell" data-type="xlsx">Create<br />Spreadsheet</a></li>
<li><a class="try-editor slide" data-type="pptx">Create<br />Presentation</a></li>
</ul>
<label class="create-sample">
<input id="createSample" class="checkbox" type="checkbox" />
@ -148,75 +153,75 @@
<% foreach (var storedFile in storedFiles)
{ %>
<%
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile);
var docType = FileUtility.GetFileType(storedFile).ToString().ToLower();
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
var docType = FileUtility.GetFileType(storedFile.Name).ToString().ToLower();
%>
<tr class="tableRow" title="<%= storedFile %>">
<tr class="tableRow" title="<%= storedFile.Name %>">
<td class="contentCells">
<a class="stored-edit <%= docType %>" href="<%= Url.Action("Editor", "Home", new { fileName = storedFile }) %>" target="_blank">
<span title="<%= storedFile %>"><%= storedFile %></span>
<a class="stored-edit <%= docType %>" href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name }) %>" target="_blank">
<span title="<%= storedFile.Name %>"><%= storedFile.Name %></span>
</a>
<a href="<%= Url.Content(DocManagerHelper.CurUserHostAddress() + "/" + storedFile) %>">
<a href="webeditor.ashx?type=download&filename=<%= HttpUtility.UrlEncode(storedFile.Name) %>">
<img class="icon-download" src="content/images/download-24.png" alt="Download" title="Download" />
</a>
<a class="delete-file" data-filename="<%= storedFile %>">
<a class="delete-file" data-filename="<%= storedFile.Name %>">
<img class="icon-delete" src="content/images/delete-24.png" alt="Delete" title="Delete" />
</a>
</td>
<td class="contentCells contentCells-icon">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "edit" }) %>" target="_blank">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "edit" }) %>" target="_blank">
<img src="content/images/desktop-24.png" alt="Open in editor for full size screens" title="Open in editor for full size screens"/>
</a>
</td>
<td class="contentCells contentCells-icon">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "mobile", editorsMode = "edit" }) %>" target="_blank">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "edit" }) %>" target="_blank">
<img src="content/images/mobile-24.png" alt="Open in editor for mobile devices" title="Open in editor for mobile devices"/>
</a>
</td>
<td class="contentCells contentCells-icon">
<% if (docType == "text") { %>
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "review" }) %>" target="_blank">
<% if (docType == "word") { %>
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "review" }) %>" target="_blank">
<img src="content/images/review-24.png" alt="Open in editor for review" title="Open in editor for review"/>
</a>
<% } else if (docType == "spreadsheet") { %>
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "filter" }) %>" target="_blank">
<% } else if (docType == "cell") { %>
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "filter" }) %>" target="_blank">
<img src="content/images/filter-24.png" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" />
</a>
<% } %>
</td>
<td class="contentCells contentCells-icon">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "comment" }) %>" target="_blank">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "comment" }) %>" target="_blank">
<img src="content/images/comment-24.png" alt="Open in editor for comment" title="Open in editor for comment"/>
</a>
</td>
<td class="contentCells contentCells-icon">
<% if (docType == "text") { %>
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "fillForms" }) %>" target="_blank">
<% if (docType == "word") { %>
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "fillForms" }) %>" target="_blank">
<img src="content/images/fill-forms-24.png" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
</a>
<% } %>
</td>
<td class="contentCells contentCells-shift contentCells-icon">
<% if (docType == "text") { %>
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "blockcontent" }) %>" target="_blank">
<% if (docType == "word") { %>
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "blockcontent" }) %>" target="_blank">
<img src="content/images/block-content-24.png" alt="Open in editor without content control modification" title="Open in editor without content control modification"/>
</a>
<% } %>
</td>
<td class="contentCells contentCells-icon">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "desktop", editorsMode = "view" }) %>" target="_blank">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "desktop", editorsMode = "view" }) %>" target="_blank">
<img src="content/images/desktop-24.png" alt="Open in viewer for full size screens" title="Open in viewer for full size screens"/>
</a>
</td>
<td class="contentCells contentCells-icon">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "mobile", editorsMode = "view" }) %>" target="_blank">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "mobile", editorsMode = "view" }) %>" target="_blank">
<img src="content/images/mobile-24.png" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices"/>
</a>
</td>
<td class="contentCells contentCells-icon">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile, editorsType = "embedded", editorsMode = "embedded" }) %>" target="_blank">
<a href="<%= Url.Action("Editor", "Home", new { fileName = storedFile.Name, editorsType = "embedded", editorsMode = "embedded" }) %>" target="_blank">
<img src="content/images/embeded-24.png" alt="Open in embedded mode" title="Open in embedded mode"/>
</a>
</td>
@ -281,7 +286,7 @@
<div id="cancelEdit" class="button gray">Cancel</div>
</div>
<span id="loadScripts" data-docs="<%= WebConfigurationManager.AppSettings["files.docservice.url.preloader"] %>"></span>
<span id="loadScripts" data-docs="<%= WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.preloader"] %>"></span>
<div class="bottom-panel">&copy; Ascensio System SIA <%= DateTime.Now.Year.ToString() %>. All rights reserved.</div>

View File

@ -26,6 +26,11 @@
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
@ -47,6 +52,10 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>

View File

@ -22,11 +22,12 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Configuration;
using System.Web.Script.Serialization;
using System.Web.Services;
using System.Web.Configuration;
using OnlineEditorsExampleMVC.Helpers;
using OnlineEditorsExampleMVC.Models;
using System.Diagnostics;
namespace OnlineEditorsExampleMVC
{
@ -41,6 +42,9 @@ namespace OnlineEditorsExampleMVC
case "upload":
Upload(context);
break;
case "download":
Download(context);
break;
case "convert":
Convert(context);
break;
@ -50,6 +54,15 @@ namespace OnlineEditorsExampleMVC
case "remove":
Remove(context);
break;
case "assets":
Assets(context);
break;
case "csv":
GetCsv(context);
break;
case "files":
Files(context);
break;
}
}
@ -102,8 +115,8 @@ namespace OnlineEditorsExampleMVC
context.Response.ContentType = "text/plain";
try
{
var fileName = context.Request["filename"];
var fileUri = DocManagerHelper.GetFileUri(fileName);
var fileName = Path.GetFileName(context.Request["filename"]);
var fileUri = DocManagerHelper.GetFileUri(fileName, true);
var extension = (Path.GetExtension(fileUri) ?? "").Trim('.');
var internalExtension = DocManagerHelper.GetInternalExtension(FileUtility.GetFileType(fileName)).Trim('.');
@ -161,90 +174,70 @@ namespace OnlineEditorsExampleMVC
MustSave = 2,
Corrupted = 3,
Closed = 4,
MustForceSave = 6,
CorruptedForceSave = 7
}
private static void Track(HttpContext context)
{
var fileData = TrackManager.readBody(context);
var userAddress = context.Request["userAddress"];
var fileName = context.Request["fileName"];
string body;
try
{
using (var receiveStream = context.Request.InputStream)
using (var readStream = new StreamReader(receiveStream))
{
body = readStream.ReadToEnd();
}
}
catch (Exception e)
{
throw new HttpException((int) HttpStatusCode.BadRequest, e.Message);
}
var jss = new JavaScriptSerializer();
if (string.IsNullOrEmpty(body)) return;
var fileData = jss.Deserialize<Dictionary<string, object>>(body);
if (JwtManager.Enabled)
{
if (fileData.ContainsKey("token"))
{
fileData = jss.Deserialize<Dictionary<string, object>>(JwtManager.Decode(fileData["token"].ToString()));
}
else if (context.Request.Headers.AllKeys.Contains("Authorization", StringComparer.InvariantCultureIgnoreCase))
{
var headerToken = context.Request.Headers.Get("Authorization").Substring("Bearer ".Length);
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(JwtManager.Decode(headerToken))["payload"];
}
else
{
throw new Exception("Expected JWT");
}
}
var fileName = Path.GetFileName(context.Request["fileName"]);
var status = (TrackerStatus) (int) fileData["status"];
var saved = 1;
switch (status)
{
case TrackerStatus.MustSave:
case TrackerStatus.Corrupted:
var downloadUri = (string) fileData["url"];
var saved = 1;
case TrackerStatus.Editing:
try
{
var storagePath = DocManagerHelper.StoragePath(fileName, userAddress);
var histDir = DocManagerHelper.HistoryDir(storagePath);
var versionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir) + 1);
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir);
File.Copy(storagePath, Path.Combine(versionDir, "prev" + Path.GetExtension(fileName)));
DownloadToFile(downloadUri, DocManagerHelper.StoragePath(fileName, userAddress));
DownloadToFile((string)fileData["changesurl"], Path.Combine(versionDir, "diff.zip"));
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
var jss = new JavaScriptSerializer();
var actions = jss.Deserialize <List<object>> (jss.Serialize(fileData["actions"]));
var action = jss.Deserialize <Dictionary<string, object>> (jss.Serialize(actions[0]));
if (action != null && action["type"].ToString().Equals("0"))
{
hist = jss.Serialize(fileData["history"]);
}
var user = action["userid"].ToString();
var users = jss.Deserialize<List<object>>(jss.Serialize(fileData["users"]));
if (!users.Contains(user))
{
TrackManager.commandRequest("forcesave", fileData["key"].ToString());
}
if (!string.IsNullOrEmpty(hist))
{
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist);
}
}
catch (Exception e)
{
Debug.Print(e.StackTrace);
}
break;
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]);
case TrackerStatus.MustSave:
case TrackerStatus.Corrupted:
try
{
saved = TrackManager.processSave(fileData, fileName, userAddress);
}
catch (Exception)
{
saved = 0;
saved = 1;
}
context.Response.Write("{\"error\":" + saved + "}");
return;
break;
case TrackerStatus.MustForceSave:
case TrackerStatus.CorruptedForceSave:
try
{
saved = TrackManager.processForceSave(fileData, fileName, userAddress);
}
catch (Exception)
{
saved = 1;
}
context.Response.Write("{\"error\":" + saved + "}");
return;
}
context.Response.Write("{\"error\":0}");
}
@ -253,7 +246,7 @@ namespace OnlineEditorsExampleMVC
context.Response.ContentType = "text/plain";
try
{
var fileName = context.Request["fileName"];
var fileName = Path.GetFileName(context.Request["fileName"]);
Remove(fileName);
context.Response.Write("{ \"success\": true }");
@ -273,27 +266,82 @@ namespace OnlineEditorsExampleMVC
if (Directory.Exists(histDir)) Directory.Delete(histDir, true);
}
private static void DownloadToFile(string url, string path)
private static void Files(HttpContext context)
{
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url");
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path");
List<Dictionary<string, object>> files = null;
var req = (HttpWebRequest)WebRequest.Create(url);
using (var stream = req.GetResponse().GetResponseStream())
try
{
if (stream == null) throw new Exception("stream is null");
const int bufferSize = 4096;
var jss = new JavaScriptSerializer();
context.Response.ContentType = "application/json";
using (var fs = File.Open(path, FileMode.Create))
if (context.Request["fileId"] == null)
{
var buffer = new byte[bufferSize];
int readed;
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
files = DocManagerHelper.GetFilesInfo();
context.Response.Write(jss.Serialize(files));
}
else
{
var fileId = context.Request["fileId"];
files = DocManagerHelper.GetFilesInfo(fileId);
if (files.Count == 0)
{
fs.Write(buffer, 0, readed);
context.Response.Write("\"File not found\"");
}
else
{
context.Response.Write(jss.Serialize(files));
}
}
}
catch (Exception e)
{
context.Response.Write("{ \"error\": \"" + e.Message + "\"}");
}
}
private static void Assets(HttpContext context)
{
var fileName = Path.GetFileName(context.Request["filename"]);
var filePath = HttpRuntime.AppDomainAppPath + "assets/sample/" + fileName;
download(filePath, context);
}
private static void GetCsv(HttpContext context)
{
var fileName = "csv.csv";
var filePath = HttpRuntime.AppDomainAppPath + "assets/sample/" + fileName;
download(filePath, context);
}
private static void Download(HttpContext context)
{
try
{
var fileName = Path.GetFileName(context.Request["filename"]);
var filePath = DocManagerHelper.ForcesavePath(fileName, null, false);
if (filePath.Equals(""))
{
filePath = DocManagerHelper.StoragePath(fileName, null);
}
download(filePath, context);
}
catch (Exception)
{
context.Response.Write("{ \"error\": \"File not found!\"}");
}
}
private static void download(string filePath, HttpContext context)
{
var fileinf = new FileInfo(filePath);
context.Response.AddHeader("Content-Length", fileinf.Length.ToString());
context.Response.AddHeader("Content-Type", MimeMapping.GetMimeMapping(filePath));
var tmp = HttpUtility.UrlEncode(Path.GetFileName(filePath));
tmp = tmp.Replace("+", "%20");
context.Response.AddHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + tmp);
context.Response.TransmitFile(filePath);
}
public bool IsReusable

View File

@ -11,11 +11,18 @@
<add key="files.docservice.viewed-docs" value=".pdf|.djvu|.xps"/>
<add key="files.docservice.edited-docs" value=".docx|.xlsx|.csv|.pptx|.txt"/>
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub"/>
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.xml|.epub|.fb2"/>
<add key="files.docservice.timeout" value="120000" />
<add key="files.docservice.secret" value="" />
<add key="files.docservice.header" value="Authorization" />
<add key="files.docservice.url.site" value="https://documentserver/"/>
<add key="files.docservice.url.converter" value="ConvertService.ashx"/>
<add key="files.docservice.url.api" value="web-apps/apps/api/documents/api.js"/>
<add key="files.docservice.url.preloader" value="web-apps/apps/api/documents/cache-scripts.html"/>
<add key="files.docservice.url.command" value="coauthoring/CommandService.ashx"/>
<add key="files.docservice.url.example" value=""/>
<add key="files.docservice.url.converter" value="https://documentserver/ConvertService.ashx"/>
<add key="files.docservice.url.api" value="https://documentserver/web-apps/apps/api/documents/api.js"/>
<add key="files.docservice.url.preloader" value="https://documentserver/web-apps/apps/api/documents/cache-scripts.html"/>
</appSettings>

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,15 @@
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -44,10 +44,13 @@ a, a:hover, a:visited {
.top-panel {
background: url("images/logo.png") no-repeat 30px center #3D4A6B;
background: #3D4A6B;
height: 80px;
width: 100%;
}
.top-panel img {
margin: 12px 0 0 16px;
}
.main-panel {
margin: 80px auto;
width: 600px;
@ -127,13 +130,13 @@ label .checkbox {
text-align: center;
text-decoration: none;
}
.try-editor.document {
.try-editor.word {
background-image: url("images/file_docx.png");
}
.try-editor.spreadsheet {
.try-editor.cell {
background-image: url("images/file_xlsx.png");
}
.try-editor.presentation {
.try-editor.slide {
background-image: url("images/file_pptx.png");
}
@ -322,13 +325,13 @@ label .checkbox {
text-overflow: ellipsis;
white-space: nowrap;
}
.stored-edit.text {
.stored-edit.word {
background-image: url("images/icon_docx.png");
}
.stored-edit.spreadsheet {
.stored-edit.cell {
background-image: url("images/icon_xlsx.png");
}
.stored-edit.presentation {
.stored-edit.slide {
background-image: url("images/icon_pptx.png");
}
.stored-edit span {

View File

@ -57,7 +57,11 @@
<body>
<form id="form1" runat="server">
<div class="top-panel"></div>
<div class="top-panel">
<a href="">
<img src ="app_themes/images/logo.svg" alt="ONLYOFFICE" />
</a>
</div>
<div class="main-panel">
<span class="portal-name">ONLYOFFICE Document Editors</span>
<br />
@ -73,6 +77,7 @@
<option value="uid-1">John Smith</option>
<option value="uid-2">Mark Pottato</option>
<option value="uid-3">Hamish Mitchell</option>
<option value="uid-0">anonymous</option>
</select>
</td>
<td width="70%" valign="middle">Select user name before opening the document; you can open the same document using different users in different Web browser sessions, so you can check out multi-user editing functions.</td>
@ -135,9 +140,9 @@
</div>
<div class="create-panel">
<ul class="try-editor-list clearFix">
<li><a class="try-editor document" data-type="document">Create<br />Document</a></li>
<li><a class="try-editor spreadsheet" data-type="spreadsheet">Create<br />Spreadsheet</a></li>
<li><a class="try-editor presentation" data-type="presentation">Create<br />Presentation</a></li>
<li><a class="try-editor word" data-type="word">Create<br />Document</a></li>
<li><a class="try-editor cell" data-type="cell">Create<br />Spreadsheet</a></li>
<li><a class="try-editor slide" data-type="slide">Create<br />Presentation</a></li>
</ul>
<label class="create-sample">
<input id="createSample" class="checkbox" type="checkbox" />
@ -168,18 +173,18 @@
<% foreach (var storedFile in storedFiles)
{ %>
<%
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile);
var docType = DocumentType(storedFile);
var editUrl = "doceditor.aspx?fileID=" + HttpUtility.UrlEncode(storedFile.Name);
var docType = DocumentType(storedFile.Name);
%>
<tr class="tableRow" title="<%= storedFile %>">
<tr class="tableRow" title="<%= storedFile.Name %>">
<td class="contentCells">
<a class="stored-edit <%= docType %>" href="<%= editUrl %>" target="_blank">
<span title="<%= storedFile %>"><%= storedFile %></span>
<span title="<%= storedFile.Name %>"><%= storedFile.Name %></span>
</a>
<a href="<%= VirtualPath + WebConfigurationManager.AppSettings["storage-path"] + storedFile %>">
<a href="webeditor.ashx?type=download&filename=<%= HttpUtility.UrlEncode(storedFile.Name) %>">
<img class="icon-download" src="app_themes/images/download-24.png" alt="Download" title="Download" />
</a>
<a class="delete-file" data-filename="<%= storedFile %>">
<a class="delete-file" data-filename="<%= storedFile.Name %>">
<img class="icon-delete" src="app_themes/images/delete-24.png" alt="Delete" title="Delete" />
</a>
</td>
@ -195,11 +200,11 @@
</a>
</td>
<td class="contentCells contentCells-icon">
<% if (docType == "text") { %>
<% if (docType == "word") { %>
<a href="<%= editUrl + "&editorsType=desktop&editorsMode=review" %>" target="_blank">
<img src="app_themes/images/review-24.png" alt="Open in editor for review" title="Open in editor for review"/>
</a>
<% } else if (docType == "spreadsheet") { %>
<% } else if (docType == "cell") { %>
<a href="<%= editUrl + "&editorsType=desktop&editorsMode=filter" %>" target="_blank">
<img src="app_themes/images/filter-24.png" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" />
</a>
@ -211,14 +216,14 @@
</a>
</td>
<td class="contentCells contentCells-icon">
<% if (docType == "text") { %>
<% if (docType == "word") { %>
<a href="<%= editUrl + "&editorsType=desktop&editorsMode=fillForms" %>" target="_blank">
<img src="app_themes/images/fill-forms-24.png" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
</a>
<% } %>
</td>
<td class="contentCells contentCells-icon contentCells-shift">
<% if (docType == "text") { %>
<% if (docType == "word") { %>
<a href="<%= editUrl + "&editorsType=desktop&editorsMode=blockcontent" %>" target="_blank">
<img src="app_themes/images/block-content-24.png" alt="Open in editor without content control modification" title="Open in editor without content control modification"/>
</a>
@ -254,7 +259,7 @@
<div class="help-block">
<span>Want to learn how it works?</span>
<% var examples = new DirectoryInfo(HttpRuntime.AppDomainAppPath + "App_Data")
<% var examples = new DirectoryInfo(HttpRuntime.AppDomainAppPath + "assets")
.GetFiles("*.zip", SearchOption.TopDirectoryOnly)
.Select(fileInfo => fileInfo.Name).ToList();
if (examples.Any())

View File

@ -52,7 +52,7 @@ namespace OnlineEditorsExample
".doc", ".docx", ".docm",
".dot", ".dotx", ".dotm",
".odt", ".fodt", ".ott", ".rtf", ".txt",
".html", ".htm", ".mht",
".html", ".htm", ".mht", ".xml",
".pdf", ".djvu", ".fb2", ".epub", ".xps"
};
@ -68,18 +68,6 @@ namespace OnlineEditorsExample
public partial class _Default : Page
{
public static UriBuilder Host
{
get
{
var uri = new UriBuilder(HttpContext.Current.Request.Url) {Query = ""};
var requestHost = HttpContext.Current.Request.Headers["Host"];
if (!string.IsNullOrEmpty(requestHost))
uri = new UriBuilder(uri.Scheme + "://" + requestHost);
return uri;
}
}
public static string VirtualPath
{
@ -144,7 +132,40 @@ namespace OnlineEditorsExample
{
Directory.CreateDirectory(directory);
}
return directory + fileName;
return directory + Path.GetFileName(fileName);
}
public static string ForcesavePath(string fileName, string userAddress, Boolean create)
{
var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(userAddress) + "\\";
if (!Directory.Exists(directory))
{
return "";
}
directory = directory + Path.GetFileName(fileName) + "-hist" + "\\";
if (!Directory.Exists(directory))
{
if (create)
{
Directory.CreateDirectory(directory);
}
else
{
return "";
}
}
directory = directory + Path.GetFileName(fileName);
if (!File.Exists(directory))
{
if (!create)
{
return "";
}
}
return directory;
}
public static string HistoryDir(string storagePath)
@ -165,7 +186,7 @@ namespace OnlineEditorsExample
public static int GetFileVersion(string historyPath)
{
if (!Directory.Exists(historyPath)) return 0;
return Directory.EnumerateDirectories(historyPath).Count();
return Directory.EnumerateDirectories(historyPath).Count() + 1;
}
public static int GetFileVersion(string fileName, string userAddress)
@ -173,25 +194,42 @@ namespace OnlineEditorsExample
return GetFileVersion(HistoryDir(StoragePath(fileName, userAddress)));
}
public static string FileUri(string fileName)
public static string FileUri(string fileName, Boolean forDocumentServer)
{
var uri = Host;
var uri = new UriBuilder(GetServerUrl(forDocumentServer));
uri.Path = VirtualPath + fileName;
return uri.ToString();
}
public static string GetServerUrl(Boolean forDocumentServer)
{
if (forDocumentServer && !WebConfigurationManager.AppSettings["files.docservice.url.example"].Equals(""))
{
return WebConfigurationManager.AppSettings["files.docservice.url.example"];
}
else
{
var uri = new UriBuilder(HttpContext.Current.Request.Url) { Query = "" };
var requestHost = HttpContext.Current.Request.Headers["Host"];
if (!string.IsNullOrEmpty(requestHost))
uri = new UriBuilder(uri.Scheme + "://" + requestHost);
return uri.ToString();
}
}
public static string DocumentType(string fileName)
{
var ext = Path.GetExtension(fileName).ToLower();
if (FileType.ExtsDocument.Contains(ext)) return "text";
if (FileType.ExtsSpreadsheet.Contains(ext)) return "spreadsheet";
if (FileType.ExtsPresentation.Contains(ext)) return "presentation";
if (FileType.ExtsDocument.Contains(ext)) return "word";
if (FileType.ExtsSpreadsheet.Contains(ext)) return "cell";
if (FileType.ExtsPresentation.Contains(ext)) return "slide";
return string.Empty;
return "word";
}
protected string UrlPreloadScripts = WebConfigurationManager.AppSettings["files.docservice.url.preloader"];
protected string UrlPreloadScripts = WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.preloader"];
protected void Page_Load(object sender, EventArgs e)
@ -229,13 +267,7 @@ namespace OnlineEditorsExample
var savedFileName = StoragePath(_fileName, null);
httpPostedFile.SaveAs(savedFileName);
var histDir = HistoryDir(savedFileName);
Directory.CreateDirectory(histDir);
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
{ "created", DateTime.Now.ToString() },
{ "id", context.Request.Cookies.GetOrDefault("uid", "uid-1") },
{ "name", context.Request.Cookies.GetOrDefault("uname", "John Smith") }
}));
DocEditor.CreateMeta(_fileName, context.Request.Cookies.GetOrDefault("uid", "uid-1"), context.Request.Cookies.GetOrDefault("uname", "John Smith"), null);
return _fileName;
}
@ -276,13 +308,7 @@ namespace OnlineEditorsExample
}
}
var histDir = HistoryDir(StoragePath(_fileName, null));
Directory.CreateDirectory(histDir);
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
{ "created", DateTime.Now.ToString() },
{ "id", request.Cookies.GetOrDefault("uid", "uid-1") },
{ "name", request.Cookies.GetOrDefault("uname", "John Smith") }
}));
DocEditor.CreateMeta(_fileName, request.Cookies.GetOrDefault("uid", "uid-1"), request.Cookies.GetOrDefault("uname", "John Smith"), null);
}
catch (Exception)
{
@ -293,7 +319,7 @@ namespace OnlineEditorsExample
public static string DoConvert(HttpContext context)
{
_fileName = context.Request["filename"];
_fileName = Path.GetFileName(context.Request["filename"]);
var extension = (Path.GetExtension(_fileName) ?? "").Trim('.');
var internalExtension = FileType.GetInternalExtension(_fileName).Trim('.');
@ -301,10 +327,10 @@ namespace OnlineEditorsExample
if (ConvertExts.Contains("." + extension)
&& !string.IsNullOrEmpty(internalExtension))
{
var key = ServiceConverter.GenerateRevisionId(FileUri(_fileName));
var key = ServiceConverter.GenerateRevisionId(FileUri(_fileName, true));
string newFileUri;
var result = ServiceConverter.GetConvertedUri(FileUri(_fileName), extension, internalExtension, key, true, out newFileUri);
var result = ServiceConverter.GetConvertedUri(FileUri(_fileName, true), extension, internalExtension, key, true, out newFileUri);
if (result != 100)
{
return "{ \"step\" : \"" + result + "\", \"filename\" : \"" + _fileName + "\"}";
@ -342,13 +368,7 @@ namespace OnlineEditorsExample
if (Directory.Exists(histDir)) Directory.Delete(histDir, true);
_fileName = fileName;
histDir = HistoryDir(StoragePath(_fileName, null));
Directory.CreateDirectory(histDir);
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
{ "created", DateTime.Now.ToString() },
{ "id", context.Request.Cookies.GetOrDefault("uid", "uid-1") },
{ "name", context.Request.Cookies.GetOrDefault("uname", "John Smith") }
}));
DocEditor.CreateMeta(_fileName, context.Request.Cookies.GetOrDefault("uid", "uid-1"), context.Request.Cookies.GetOrDefault("uname", "John Smith"), null);
}
return "{ \"filename\" : \"" + _fileName + "\"}";
@ -367,15 +387,45 @@ namespace OnlineEditorsExample
return name;
}
protected static List<string> GetStoredFiles()
protected static List<FileInfo> GetStoredFiles()
{
var directory = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"] + CurUserHostAddress(null) + "\\";
if (!Directory.Exists(directory)) return new List<string>();
if (!Directory.Exists(directory)) return new List<FileInfo>();
var directoryInfo = new DirectoryInfo(directory);
var storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).Select(fileInfo => fileInfo.Name).ToList();
List<FileInfo> storedFiles = directoryInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly).ToList();
return storedFiles;
}
public static List<Dictionary<string, object>> GetFilesInfo(string fileId = null)
{
var files = new List<Dictionary<string, object>>();
foreach (var file in GetStoredFiles())
{
var dictionary = new Dictionary<string, object>();
dictionary.Add("version", GetFileVersion(file.Name, null));
dictionary.Add("id", ServiceConverter.GenerateRevisionId(_Default.CurUserHostAddress(null) + "/" + file.Name + "/" + File.GetLastWriteTime(_Default.StoragePath(file.Name, null)).GetHashCode()));
dictionary.Add("contentLength", Math.Round(file.Length / 1024.0, 2) + " KB");
dictionary.Add("pureContentLength", file.Length);
dictionary.Add("title", file.Name);
dictionary.Add("updated", file.LastWriteTime.ToString());
if (fileId != null)
{
if (fileId.Equals(dictionary["id"]))
{
files.Add(dictionary);
break;
}
}
else
{
files.Add(dictionary);
}
}
return files;
}
}
}

View File

@ -11,7 +11,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<link rel="icon" href="~/favicon.ico" type="image/x-icon" />
<link rel="icon" href="<%= "app_themes/images/" + documentType + ".ico" %>" type="image/x-icon" />
<title>ONLYOFFICE</title>
<!--
*
@ -114,6 +114,28 @@
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
};
var onMetaChange = function (event) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite);
};
var onRequestInsertImage = function (event) {
docEditor.insertImage({
"c": event.data.c,
<%= InsertImageConfig%>
})
};
var onRequestCompareFile = function () {
docEditor.setRevisedFile(<%= compareFileData%>);
};
var onRequestMailMergeRecipients = function (event) {
docEditor.setMailMergeRecipients(<%= dataMailMergeRecipients%>);
};
var config = <%= DocConfig %>;
config.width = "100%";
@ -126,6 +148,10 @@
'onError': onError,
'onOutdatedVersion': onOutdatedVersion,
'onMakeActionLink': onMakeActionLink,
'onMetaChange': onMetaChange,
'onRequestInsertImage': onRequestInsertImage,
'onRequestCompareFile': onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
};
<% if (!string.IsNullOrEmpty(History) && !string.IsNullOrEmpty(HistoryData))
@ -136,7 +162,7 @@
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = <%= HistoryData %>;
docEditor.setHistoryData(histData[ver]);
docEditor.setHistoryData(histData[ver - 1]);
};
config.events['onRequestHistoryClose '] = function () {
document.location.reload();

View File

@ -34,7 +34,12 @@ namespace OnlineEditorsExample
public static string FileUri
{
get { return _Default.FileUri(FileName); }
get { return _Default.FileUri(FileName, true); }
}
public static string FileUriUser
{
get { return _Default.FileUri(FileName, false); }
}
protected string Key
@ -49,18 +54,22 @@ namespace OnlineEditorsExample
protected string DocServiceApiUri
{
get { return WebConfigurationManager.AppSettings["files.docservice.url.api"] ?? string.Empty; }
get { return (WebConfigurationManager.AppSettings["files.docservice.url.site"] ?? string.Empty) + (WebConfigurationManager.AppSettings["files.docservice.url.api"] ?? string.Empty); }
}
protected string DocConfig { get; private set; }
protected string History { get; private set; }
protected string HistoryData { get; private set; }
protected string InsertImageConfig { get; private set; }
protected string compareFileData { get; private set; }
protected string dataMailMergeRecipients { get; private set; }
protected string documentType { get { return _Default.DocumentType(FileName); } }
public static string CallbackUrl
{
get
{
var callbackUrl = _Default.Host;
var callbackUrl = new UriBuilder(_Default.GetServerUrl(true));
callbackUrl.Path =
HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
@ -81,7 +90,7 @@ namespace OnlineEditorsExample
}
else
{
FileName = Request["fileID"];
FileName = Path.GetFileName(Request["fileID"]);
}
var type = Request["type"];
@ -97,16 +106,38 @@ namespace OnlineEditorsExample
var canEdit = _Default.EditedExts.Contains(ext);
var mode = canEdit && editorsMode != "view" ? "edit" : "view";
var submitForm = canEdit && (editorsMode.Equals("edit") || editorsMode.Equals("fillForms"));
var userId = Request.Cookies.GetOrDefault("uid", "uid-1");
var uname = userId.Equals("uid-0") ? null : Request.Cookies.GetOrDefault("uname", "John Smith");
string userGroup = null;
List<string> reviewGroups = null;
if (userId.Equals("uid-2"))
{
userGroup = "group-2";
reviewGroups = new List<string>() { "group-2", "" };
}
if (userId.Equals("uid-3"))
{
userGroup = "group-3";
reviewGroups = new List<string>() { "group-2" };
}
var jss = new JavaScriptSerializer();
object favorite = null;
if (!string.IsNullOrEmpty(Request.Cookies.GetOrDefault("uid", null)))
{
favorite = Request.Cookies.GetOrDefault("uid", null).Equals("uid-2");
}
var actionLink = Request.GetOrDefault("actionLink", null);
var actionData = string.IsNullOrEmpty(actionLink) ? null : jss.DeserializeObject(actionLink);
var config = new Dictionary<string, object>
{
{ "type", Request.GetOrDefault("editorsType", "desktop") },
{ "documentType", _Default.DocumentType(FileName) },
{ "documentType", documentType },
{
"document", new Dictionary<string, object>
{
@ -117,8 +148,9 @@ namespace OnlineEditorsExample
{
"info", new Dictionary<string, object>
{
{ "author", "Me" },
{ "created", DateTime.Now.ToShortDateString() }
{ "owner", "Me" },
{ "uploaded", DateTime.Now.ToShortDateString() },
{ "favorite", favorite }
}
},
{
@ -130,7 +162,8 @@ namespace OnlineEditorsExample
{ "fillForms", editorsMode != "view" && editorsMode != "comment" && editorsMode != "embedded" && editorsMode != "blockcontent" },
{ "modifyFilter", editorsMode != "filter" },
{ "modifyContentControl", editorsMode != "blockcontent" },
{ "review", editorsMode == "edit" || editorsMode == "review" }
{ "review", editorsMode == "edit" || editorsMode == "review" },
{ "reviewGroups", reviewGroups }
}
}
}
@ -145,16 +178,17 @@ namespace OnlineEditorsExample
{
"user", new Dictionary<string, object>
{
{ "id", Request.Cookies.GetOrDefault("uid", "uid-1") },
{ "name", Request.Cookies.GetOrDefault("uname", "John Smith") }
{ "id", userId },
{ "name", uname },
{ "group", userGroup }
}
},
{
"embedded", new Dictionary<string, object>
{
{ "saveUrl", FileUri },
{ "embedUrl", FileUri },
{ "shareUrl", FileUri },
{ "saveUrl", FileUriUser },
{ "embedUrl", FileUriUser },
{ "shareUrl", FileUriUser },
{ "toolbarDocked", "top" }
}
},
@ -163,10 +197,12 @@ namespace OnlineEditorsExample
{
{ "about", true },
{ "feedback", true },
{ "forcesave", false },
{ "submitForm", submitForm },
{
"goback", new Dictionary<string, object>
{
{ "url", _Default.Host + "default.aspx" }
{ "url", _Default.GetServerUrl(false) + "default.aspx" }
}
}
}
@ -185,8 +221,19 @@ namespace OnlineEditorsExample
try
{
Dictionary<string, object> logoConfig = GetLogoConfig();
InsertImageConfig = jss.Serialize(logoConfig).Replace("{", "").Replace("}", "");
Dictionary<string, object> compareFile = GetCompareFile();
compareFileData = jss.Serialize(compareFile);
Dictionary<string, object> mailMergeConfig = GetMailMergeConfig();
dataMailMergeRecipients = jss.Serialize(mailMergeConfig);
Dictionary<string, object> hist;
Dictionary<string, object> histData;
GetHistory(out hist, out histData);
if (hist != null && histData != null)
{
@ -211,18 +258,18 @@ namespace OnlineEditorsExample
var hist = new List<Dictionary<string, object>>();
var histData = new Dictionary<string, object>();
for (var i = 0; i <= currentVersion; i++)
for (var i = 1; i <= currentVersion; i++)
{
var obj = new Dictionary<string, object>();
var dataObj = new Dictionary<string, object>();
var verDir = _Default.VersionDir(histDir, i + 1);
var verDir = _Default.VersionDir(histDir, i);
var key = i == currentVersion ? Key : File.ReadAllText(Path.Combine(verDir, "key.txt"));
obj.Add("key", key);
obj.Add("version", i);
if (i == 0)
if (i == 1)
{
var infoPath = Path.Combine(histDir, "createdInfo.json");
@ -239,9 +286,9 @@ namespace OnlineEditorsExample
dataObj.Add("key", key);
dataObj.Add("url", i == currentVersion ? FileUri : MakePublicUrl(Directory.GetFiles(verDir, "prev.*")[0]));
dataObj.Add("version", i);
if (i > 0)
if (i > 1)
{
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(_Default.VersionDir(histDir, i), "changes.json")));
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(_Default.VersionDir(histDir, i - 1), "changes.json")));
var change = ((Dictionary<string, object>)((ArrayList)changes["changes"])[0]);
obj.Add("changes", changes["changes"]);
@ -249,16 +296,20 @@ namespace OnlineEditorsExample
obj.Add("created", change["created"]);
obj.Add("user", change["user"]);
var prev = (Dictionary<string, object>)histData[(i - 1).ToString()];
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()];
dataObj.Add("previous", new Dictionary<string, object>() {
{ "key", prev["key"] },
{ "url", prev["url"] },
});
dataObj.Add("changesUrl", MakePublicUrl(Path.Combine(_Default.VersionDir(histDir, i), "diff.zip")));
dataObj.Add("changesUrl", MakePublicUrl(Path.Combine(_Default.VersionDir(histDir, i - 1), "diff.zip")));
}
if (JwtManager.Enabled)
{
var token = JwtManager.Encode(dataObj);
dataObj.Add("token", token);
}
hist.Add(obj);
histData.Add(i.ToString(), dataObj);
histData.Add((i - 1).ToString(), dataObj);
}
history = new Dictionary<string, object>()
@ -270,10 +321,79 @@ namespace OnlineEditorsExample
}
}
private Dictionary<string, object> GetLogoConfig()
{
var InsertImageUrl = new UriBuilder(_Default.GetServerUrl(true));
InsertImageUrl.Path = HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "App_Themes\\images\\logo.png";
Dictionary<string, object> logoConfig = new Dictionary<string, object>
{
{ "fileType", "png"},
{ "url", InsertImageUrl.ToString()}
};
if (JwtManager.Enabled)
{
var insImageToken = JwtManager.Encode(logoConfig);
logoConfig.Add("token", insImageToken);
}
return logoConfig;
}
private Dictionary<string, object> GetCompareFile()
{
var compareFileUrl = new UriBuilder(_Default.GetServerUrl(true));
compareFileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "webeditor.ashx";
compareFileUrl.Query = "type=assets&fileName=" + HttpUtility.UrlEncode("sample.docx");
Dictionary<string, object> dataCompareFile = new Dictionary<string, object>
{
{ "fileType", "docx" },
{ "url", compareFileUrl.ToString() }
};
if (JwtManager.Enabled)
{
var compareFileToken = JwtManager.Encode(dataCompareFile);
dataCompareFile.Add("token", compareFileToken);
}
return dataCompareFile;
}
private Dictionary<string, object> GetMailMergeConfig()
{
var mailmergeUrl = new UriBuilder(_Default.GetServerUrl(true));
mailmergeUrl.Path =
HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "webeditor.ashx";
mailmergeUrl.Query = "type=csv";
Dictionary<string, object> mailMergeConfig = new Dictionary<string, object>
{
{ "fileType", "csv" },
{ "url", mailmergeUrl.ToString() }
};
if (JwtManager.Enabled)
{
var mailmergeToken = JwtManager.Encode(mailMergeConfig);
mailMergeConfig.Add("token", mailmergeToken);
}
return mailMergeConfig;
}
private string MakePublicUrl(string fullPath)
{
var root = HttpRuntime.AppDomainAppPath + WebConfigurationManager.AppSettings["storage-path"];
return _Default.Host + fullPath.Substring(root.Length).Replace(Path.DirectorySeparatorChar, '/');
return _Default.GetServerUrl(true) + fullPath.Substring(root.Length).Replace(Path.DirectorySeparatorChar, '/');
}
private static void Try(string type, string sample, HttpRequest request)
@ -281,30 +401,37 @@ namespace OnlineEditorsExample
string ext;
switch (type)
{
case "document":
case "word":
ext = ".docx";
break;
case "spreadsheet":
case "cell":
ext = ".xlsx";
break;
case "presentation":
case "slide":
ext = ".pptx";
break;
default:
return;
}
var demoName = (string.IsNullOrEmpty(sample) ? "new" : "demo") + ext;
var demoName = (string.IsNullOrEmpty(sample) ? "new" : "sample") + ext;
var demoPath = "assets\\" + (string.IsNullOrEmpty(sample) ? "new\\" : "sample\\");
FileName = _Default.GetCorrectName(demoName);
var filePath = _Default.StoragePath(FileName, null);
File.Copy(HttpRuntime.AppDomainAppPath + "app_data/" + demoName, filePath);
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, filePath);
var histDir = _Default.HistoryDir(filePath);
CreateMeta(FileName, request.Cookies.GetOrDefault("uid", "uid-1"), request.Cookies.GetOrDefault("uname", "John Smith"), null);
}
public static void CreateMeta(string fileName, string uid, string uname, string userAddress)
{
var histDir = _Default.HistoryDir(_Default.StoragePath(fileName, userAddress));
Directory.CreateDirectory(histDir);
File.WriteAllText(Path.Combine(histDir, "createdInfo.json"), new JavaScriptSerializer().Serialize(new Dictionary<string, object> {
{ "created", DateTime.Now.ToString() },
{ "id", request.Cookies.GetOrDefault("uid", "uid-1") },
{ "name", request.Cookies.GetOrDefault("uname", "John Smith") }
{ "created", DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss") },
{ "id", uid },
{ "name", uname }
}));
}
}

View File

@ -40,7 +40,7 @@ namespace ASC.Api.DocumentConverter
/// </summary>
static ServiceConverter()
{
DocumentConverterUrl = WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "";
DocumentConverterUrl = (WebConfigurationManager.AppSettings["files.docservice.url.site"] ?? "") + (WebConfigurationManager.AppSettings["files.docservice.url.converter"] ?? "");
Int32.TryParse(WebConfigurationManager.AppSettings["files.docservice.timeout"], out ConvertTimeout);
ConvertTimeout = ConvertTimeout > 0 ? ConvertTimeout : 120000;
@ -121,7 +121,8 @@ namespace ASC.Api.DocumentConverter
var payloadToken = JwtManager.Encode(payload);
var bodyToken = JwtManager.Encode(body);
request.Headers.Add("Authorization", "Bearer " + payloadToken);
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
request.Headers.Add(JWTheader, "Bearer " + payloadToken);
body.Add("token", bodyToken);
}

View File

@ -70,6 +70,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="App_Themes\images\block-content-24.png" />
<Content Include="App_Themes\images\cell.ico" />
<Content Include="App_Themes\images\comment-24.png" />
<Content Include="App_Themes\images\delete-24.png" />
<Content Include="App_Themes\images\desktop-24.png" />
@ -86,6 +87,8 @@
<Content Include="App_Themes\images\icon_xlsx.png" />
<Content Include="App_Themes\images\mobile-24.png" />
<Content Include="App_Themes\images\review-24.png" />
<Content Include="App_Themes\images\slide.ico" />
<Content Include="App_Themes\images\word.ico" />
<Content Include="LICENSE" />
<Content Include="licenses\jquery.license" />
<Content Include="ReadMe.txt" />
@ -109,6 +112,7 @@
<Compile Include="Default.aspx.designer.cs">
<DependentUpon>Default.aspx</DependentUpon>
</Compile>
<Compile Include="TrackManager.cs" />
<Compile Include="Utils.cs" />
<Compile Include="WebEditor.ashx.cs">
<DependentUpon>WebEditor.ashx</DependentUpon>
@ -142,16 +146,15 @@
<Content Include="WebEditor.ashx" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Data\demo.docx" />
<Content Include="App_Data\demo.pptx" />
<Content Include="App_Data\demo.xlsx" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Data\new.docx" />
<Content Include="App_Data\new.pptx" />
<Content Include="App_Data\new.xlsx" />
</ItemGroup>
<ItemGroup>
<Content Include="assets\AUTHORS.md" />
<Content Include="assets\LICENSE" />
<Content Include="assets\new\new.docx" />
<Content Include="assets\new\new.pptx" />
<Content Include="assets\new\new.xlsx" />
<Content Include="assets\sample\csv.csv" />
<Content Include="assets\sample\sample.docx" />
<Content Include="assets\sample\sample.pptx" />
<Content Include="assets\sample\sample.xlsx" />
<None Include="packages.config" />
</ItemGroup>
<PropertyGroup>

View File

@ -0,0 +1,304 @@
/**
*
* (c) Copyright Ascensio System SIA 2020
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.IO;
using System.Net;
using System.Collections.Generic;
using System.Web.Script.Serialization;
using System.Web.Configuration;
using System.Linq;
using System.Web;
using System.Text;
using ASC.Api.DocumentConverter;
namespace OnlineEditorsExample
{
public class TrackManager
{
public static Dictionary<string, object> readBody(HttpContext context)
{
string body;
try
{
using (var receiveStream = context.Request.InputStream)
using (var readStream = new StreamReader(receiveStream))
{
body = readStream.ReadToEnd();
if (string.IsNullOrEmpty(body)) context.Response.Write("{\"error\":1,\"message\":\"Request stream is empty\"}");
}
}
catch (Exception e)
{
throw new HttpException((int)HttpStatusCode.BadRequest, e.Message);
}
var jss = new JavaScriptSerializer();
var fileData = jss.Deserialize<Dictionary<string, object>>(body);
if (JwtManager.Enabled)
{
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
string token = null;
if (fileData.ContainsKey("token"))
{
token = JwtManager.Decode(fileData["token"].ToString());
}
else if (context.Request.Headers.AllKeys.Contains(JWTheader, StringComparer.InvariantCultureIgnoreCase))
{
var headerToken = context.Request.Headers.Get(JWTheader).Substring("Bearer ".Length);
token = JwtManager.Decode(headerToken);
}
else
{
context.Response.Write("{\"error\":1,\"message\":\"JWT expected\"}");
}
if (token != null && !token.Equals(""))
{
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(token)["payload"];
}
else
{
context.Response.Write("{\"error\":1,\"message\":\"JWT validation failed\"}");
}
}
return fileData;
}
public static int processSave(Dictionary<string, object> fileData, string fileName, string userAddress)
{
var downloadUri = (string)fileData["url"];
var curExt = Path.GetExtension(fileName);
var downloadExt = Path.GetExtension(downloadUri) ?? "";
var newFileName = fileName;
if (!downloadExt.Equals(curExt, StringComparison.InvariantCultureIgnoreCase))
{
try
{
string newFileUri;
ServiceConverter.GetConvertedUri(downloadUri, downloadExt, curExt, ServiceConverter.GenerateRevisionId(downloadUri), false, out newFileUri);
if (string.IsNullOrEmpty(newFileUri))
{
newFileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
else
{
downloadUri = newFileUri;
}
}
catch (Exception)
{
newFileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
}
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (_Default.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
var storagePath = _Default.StoragePath(newFileName, userAddress);
var histDir = _Default.HistoryDir(storagePath);
if (!Directory.Exists(histDir)) Directory.CreateDirectory(histDir);
var versionDir = _Default.VersionDir(histDir, _Default.GetFileVersion(histDir));
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir);
File.Copy(_Default.StoragePath(fileName, userAddress), Path.Combine(versionDir, "prev" + curExt));
DownloadToFile(downloadUri, storagePath);
DownloadToFile((string)fileData["changesurl"], Path.Combine(versionDir, "diff.zip"));
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
{
var jss = new JavaScriptSerializer();
hist = jss.Serialize(fileData["history"]);
}
if (!string.IsNullOrEmpty(hist))
{
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist);
}
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]);
string forcesavePath = _Default.ForcesavePath(newFileName, userAddress, false);
if (!forcesavePath.Equals(""))
{
File.Delete(forcesavePath);
}
return 0;
}
public static int processForceSave(Dictionary<string, object> fileData, string fileName, string userAddress)
{
var downloadUri = (string)fileData["url"];
string curExt = Path.GetExtension(fileName);
string downloadExt = Path.GetExtension(downloadUri);
var newFileName = fileName;
if (!curExt.Equals(downloadExt))
{
try
{
string newFileUri;
var result = ServiceConverter.GetConvertedUri(downloadUri, downloadExt, curExt, ServiceConverter.GenerateRevisionId(downloadUri), false, out newFileUri);
if (string.IsNullOrEmpty(newFileUri))
{
newFileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
else
{
downloadUri = newFileUri;
}
}
catch (Exception)
{
newFileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
}
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (_Default.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
string forcesavePath = "";
Boolean isSubmitForm = fileData["forcesavetype"].ToString().Equals("3");
if (isSubmitForm)
{
if (newFileName.Equals(fileName))
{
newFileName = _Default.GetCorrectName(fileName, userAddress);
}
forcesavePath = _Default.StoragePath(newFileName, userAddress);
}
else
{
forcesavePath = _Default.ForcesavePath(newFileName, userAddress, false);
if (forcesavePath.Equals(""))
{
forcesavePath = _Default.ForcesavePath(newFileName, userAddress, true);
}
}
DownloadToFile(downloadUri, forcesavePath);
if (isSubmitForm)
{
var jss = new JavaScriptSerializer();
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
var user = action["userid"].ToString();
DocEditor.CreateMeta(newFileName, user, "Filling Form", userAddress);
}
return 0;
}
public static void commandRequest(string method, string key)
{
string documentCommandUrl = WebConfigurationManager.AppSettings["files.docservice.url.site"] + WebConfigurationManager.AppSettings["files.docservice.url.command"];
var request = (HttpWebRequest)WebRequest.Create(documentCommandUrl);
request.Method = "POST";
request.ContentType = "application/json";
var body = new Dictionary<string, object>() {
{ "c", method },
{ "key", key }
};
if (JwtManager.Enabled)
{
var payload = new Dictionary<string, object>
{
{ "payload", body }
};
var payloadToken = JwtManager.Encode(payload);
var bodyToken = JwtManager.Encode(body);
string JWTheader = WebConfigurationManager.AppSettings["files.docservice.header"].Equals("") ? "Authorization" : WebConfigurationManager.AppSettings["files.docservice.header"];
request.Headers.Add(JWTheader, "Bearer " + payloadToken);
body.Add("token", bodyToken);
}
var bytes = Encoding.UTF8.GetBytes(new JavaScriptSerializer().Serialize(body));
request.ContentLength = bytes.Length;
using (var requestStream = request.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
}
string dataResponse;
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
{
if (stream == null) throw new Exception("Response is null");
using (var reader = new StreamReader(stream))
{
dataResponse = reader.ReadToEnd();
}
}
var jss = new JavaScriptSerializer();
var responseObj = jss.Deserialize<Dictionary<string, object>>(dataResponse);
if (!responseObj["error"].ToString().Equals("0"))
{
throw new Exception(dataResponse);
}
}
private static void DownloadToFile(string url, string path)
{
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url");
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path");
var req = (HttpWebRequest)WebRequest.Create(url);
using (var stream = req.GetResponse().GetResponseStream())
{
if (stream == null) throw new Exception("stream is null");
const int bufferSize = 4096;
using (var fs = File.Open(path, FileMode.Create))
{
var buffer = new byte[bufferSize];
int readed;
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
{
fs.Write(buffer, 0, readed);
}
}
}
}
}
}

View File

@ -8,6 +8,11 @@
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824"/>

View File

@ -16,15 +16,13 @@
*
*/
using ASC.Api.DocumentConverter;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Services;
using System.Diagnostics;
namespace OnlineEditorsExample
{
@ -39,6 +37,9 @@ namespace OnlineEditorsExample
case "upload":
Upload(context);
break;
case "download":
Download(context);
break;
case "convert":
Convert(context);
break;
@ -48,6 +49,15 @@ namespace OnlineEditorsExample
case "remove":
Remove(context);
break;
case "assets":
Assets(context);
break;
case "csv":
GetCsv(context);
break;
case "files":
Files(context);
break;
}
}
@ -84,113 +94,68 @@ namespace OnlineEditorsExample
MustSave = 2,
Corrupted = 3,
Closed = 4,
MustForceSave = 6,
CorruptedForceSave = 7
}
private static void Track(HttpContext context)
{
var fileData = TrackManager.readBody(context);
var userAddress = context.Request["userAddress"];
var fileName = context.Request["fileName"];
string body;
try
{
using (var receiveStream = context.Request.InputStream)
using (var readStream = new StreamReader(receiveStream))
{
body = readStream.ReadToEnd();
}
}
catch (Exception e)
{
throw new HttpException((int) HttpStatusCode.BadRequest, e.Message);
}
var jss = new JavaScriptSerializer();
if (string.IsNullOrEmpty(body)) return;
var fileData = jss.Deserialize<Dictionary<string, object>>(body);
if (JwtManager.Enabled)
{
if (fileData.ContainsKey("token"))
{
fileData = jss.Deserialize<Dictionary<string, object>>(JwtManager.Decode(fileData["token"].ToString()));
}
else if (context.Request.Headers.AllKeys.Contains("Authorization", StringComparer.InvariantCultureIgnoreCase))
{
var headerToken = context.Request.Headers.Get("Authorization").Substring("Bearer ".Length);
fileData = (Dictionary<string, object>)jss.Deserialize<Dictionary<string, object>>(JwtManager.Decode(headerToken))["payload"];
}
else
{
throw new Exception("Expected JWT");
}
}
var fileName = Path.GetFileName(context.Request["fileName"]);
var status = (TrackerStatus) (int) fileData["status"];
var saved = 1;
switch (status)
{
case TrackerStatus.MustSave:
case TrackerStatus.Corrupted:
var downloadUri = (string) fileData["url"];
var curExt = Path.GetExtension(fileName);
var downloadExt = Path.GetExtension(downloadUri) ?? "";
if (!downloadExt.Equals(curExt, StringComparison.InvariantCultureIgnoreCase))
{
var key = ServiceConverter.GenerateRevisionId(downloadUri);
try
{
string newFileUri;
ServiceConverter.GetConvertedUri(downloadUri, downloadExt, curExt, key, false, out newFileUri);
downloadUri = newFileUri;
}
catch (Exception ex)
{
fileName = _Default.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
}
// hack. http://ubuntuforums.org/showthread.php?t=1841740
if (_Default.IsMono)
{
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
var saved = 1;
case TrackerStatus.Editing:
try
{
var storagePath = _Default.StoragePath(fileName, userAddress);
var histDir = _Default.HistoryDir(storagePath);
var versionDir = _Default.VersionDir(histDir, _Default.GetFileVersion(histDir) + 1);
if (!Directory.Exists(versionDir)) Directory.CreateDirectory(versionDir);
File.Copy(storagePath, Path.Combine(versionDir, "prev" + curExt));
DownloadToFile(downloadUri, _Default.StoragePath(fileName, userAddress));
DownloadToFile((string)fileData["changesurl"], Path.Combine(versionDir, "diff.zip"));
var hist = fileData.ContainsKey("changeshistory") ? (string)fileData["changeshistory"] : null;
if (string.IsNullOrEmpty(hist) && fileData.ContainsKey("history"))
var jss = new JavaScriptSerializer();
var actions = jss.Deserialize<List<object>>(jss.Serialize(fileData["actions"]));
var action = jss.Deserialize<Dictionary<string, object>>(jss.Serialize(actions[0]));
if (action != null && action["type"].ToString().Equals("0"))
{
hist = jss.Serialize(fileData["history"]);
}
var user = action["userid"].ToString();
var users = jss.Deserialize<List<object>>(jss.Serialize(fileData["users"]));
if (!users.Contains(user))
{
TrackManager.commandRequest("forcesave", fileData["key"].ToString());
}
if (!string.IsNullOrEmpty(hist))
{
File.WriteAllText(Path.Combine(versionDir, "changes.json"), hist);
}
}
catch (Exception e)
{
Debug.Print(e.StackTrace);
}
break;
File.WriteAllText(Path.Combine(versionDir, "key.txt"), (string)fileData["key"]);
case TrackerStatus.MustSave:
case TrackerStatus.Corrupted:
try
{
saved = TrackManager.processSave(fileData, fileName, userAddress);
}
catch (Exception e)
{
saved = 1;
}
context.Response.Write("{\"error\":" + saved + "}");
return;
case TrackerStatus.MustForceSave:
case TrackerStatus.CorruptedForceSave:
try
{
saved = TrackManager.processForceSave(fileData, fileName, userAddress);
}
catch (Exception)
{
saved = 0;
saved = 1;
}
break;
context.Response.Write("{\"error\":" + saved + "}");
return;
}
context.Response.Write("{\"error\":0}");
}
@ -200,7 +165,7 @@ namespace OnlineEditorsExample
context.Response.ContentType = "text/plain";
try
{
var fileName = context.Request["fileName"];
var fileName = Path.GetFileName(context.Request["fileName"]);
var path = _Default.StoragePath(fileName, HttpUtility.UrlEncode(HttpContext.Current.Request.UserHostAddress));
var histDir = _Default.HistoryDir(path);
@ -215,27 +180,82 @@ namespace OnlineEditorsExample
}
}
private static void DownloadToFile(string url, string path)
private static void Files(HttpContext context)
{
if (string.IsNullOrEmpty(url)) throw new ArgumentException("url");
if (string.IsNullOrEmpty(path)) throw new ArgumentException("path");
List<Dictionary<string, object>> files = null;
var req = (HttpWebRequest)WebRequest.Create(url);
using (var stream = req.GetResponse().GetResponseStream())
try
{
if (stream == null) throw new Exception("stream is null");
const int bufferSize = 4096;
context.Response.ContentType = "application/json";
var jss = new JavaScriptSerializer();
using (var fs = File.Open(path, FileMode.Create))
if (context.Request["fileId"] == null)
{
var buffer = new byte[bufferSize];
int readed;
while ((readed = stream.Read(buffer, 0, bufferSize)) != 0)
files = _Default.GetFilesInfo();
context.Response.Write(jss.Serialize(files));
}
else
{
var fileId = context.Request["fileId"];
files = _Default.GetFilesInfo(fileId);
if (files.Count == 0)
{
fs.Write(buffer, 0, readed);
context.Response.Write("\"File not found\"");
}
else
{
context.Response.Write(jss.Serialize(files));
}
}
}
catch (Exception e)
{
context.Response.Write("{ \"error\": \"" + e.Message + "\"}");
}
}
private static void Assets(HttpContext context)
{
var fileName = Path.GetFileName(context.Request["filename"]);
var filePath = HttpRuntime.AppDomainAppPath + "assets/sample/" + fileName;
download(filePath, context);
}
private static void GetCsv(HttpContext context)
{
var fileName = "csv.csv";
var filePath = HttpRuntime.AppDomainAppPath + "assets/sample/" + fileName;
download(filePath, context);
}
private static void Download(HttpContext context)
{
try
{
var fileName = Path.GetFileName(context.Request["filename"]);
var filePath = _Default.ForcesavePath(fileName, null, false);
if (filePath.Equals(""))
{
filePath = _Default.StoragePath(fileName, null);
}
download(filePath, context);
}
catch (Exception)
{
context.Response.Write("{ \"error\": \"File not found!\"}");
}
}
private static void download(string filePath, HttpContext context)
{
FileInfo fileinf = new FileInfo(filePath);
context.Response.AddHeader("Content-Length", "" + fileinf.Length);
context.Response.AddHeader("Content-Type", MimeMapping.GetMimeMapping(filePath));
var tmp = HttpUtility.UrlEncode(Path.GetFileName(filePath));
tmp = tmp.Replace("+", "%20");
context.Response.AddHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + tmp);
context.Response.TransmitFile(filePath);
}
public bool IsReusable

View File

@ -7,11 +7,18 @@
<add key="files.docservice.viewed-docs" value=".pdf|.djvu|.xps"/>
<add key="files.docservice.edited-docs" value=".docx|.xlsx|.csv|.pptx|.txt"/>
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub"/>
<add key="files.docservice.convert-docs" value=".docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.xml|.epub|.fb2"/>
<add key="files.docservice.timeout" value="120000" />
<add key="files.docservice.secret" value="" />
<add key="files.docservice.header" value="Authorization" />
<add key="files.docservice.url.site" value="https://documentserver/"/>
<add key="files.docservice.url.converter" value="ConvertService.ashx"/>
<add key="files.docservice.url.api" value="web-apps/apps/api/documents/api.js"/>
<add key="files.docservice.url.preloader" value="web-apps/apps/api/documents/cache-scripts.html"/>
<add key="files.docservice.url.command" value="coauthoring/CommandService.ashx"/>
<add key="files.docservice.url.example" value=""/>
<add key="files.docservice.url.converter" value="https://documentserver/ConvertService.ashx"/>
<add key="files.docservice.url.api" value="https://documentserver/web-apps/apps/api/documents/api.js"/>
<add key="files.docservice.url.preloader" value="https://documentserver/web-apps/apps/api/documents/cache-scripts.html"/>
</appSettings>

View File

@ -14,13 +14,10 @@ Edit the **settings.properties** configuration file. Specify the name of your lo
nano src/main/resources/settings.properties
```
Edit the following lines:
Edit the following line:
```
files.docservice.url.converter=https://documentserver/ConvertService.ashx
files.docservice.url.tempstorage=https://documentserver/ResourceService.ashx
files.docservice.url.api=https://documentserver/web-apps/apps/api/documents/api.js
files.docservice.url.preloader=https://documentserver/web-apps/apps/api/documents/cache-scripts.html
files.docservice.url.site=https://documentserver/
```
Install Maven:
@ -44,13 +41,10 @@ Edit the **settings.properties** configuration file. Specify the name of your lo
nano src/main/resources/settings.properties
```
Edit the following lines. You need to change `documentserver` to your documentserver:
Edit the following line. You need to change `documentserver` to your documentserver:
```
files.docservice.url.converter=https://documentserver/ConvertService.ashx
files.docservice.url.tempstorage=https://documentserver/ResourceService.ashx
files.docservice.url.api=https://documentserver/web-apps/apps/api/documents/api.js
files.docservice.url.preloader=https://documentserver/web-apps/apps/api/documents/cache-scripts.html
files.docservice.url.site=https://documentserver/
```
Run next command in java example directory:

View File

@ -54,7 +54,6 @@ Any value defined here will override the pom.xml file value but is only applicab
<word>ppsx</word>
<word>ppt</word>
<word>pptx</word>
<word>ResourceService</word>
<word>rtf</word>
<word>SIA</word>
<word>teamlab</word>

View File

@ -18,11 +18,14 @@
package controllers;
import com.google.gson.Gson;
import helpers.ConfigManager;
import helpers.CookieManager;
import helpers.DocumentManager;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
@ -30,6 +33,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import entities.FileModel;
import helpers.FileUtility;
@WebServlet(name = "EditorServlet", urlPatterns = {"/EditorServlet"})
@ -39,7 +43,7 @@ public class EditorServlet extends HttpServlet
{
DocumentManager.Init(request, response);
String fileName = request.getParameter("fileName");
String fileName = FileUtility.GetFileName(request.getParameter("fileName"));
String fileExt = request.getParameter("fileExt");
String sample = request.getParameter("sample");
@ -64,13 +68,32 @@ public class EditorServlet extends HttpServlet
FileModel file = new FileModel(fileName, cm.getCookie("ulang"), cm.getCookie("uid"), cm.getCookie("uname"), request.getParameter("actionLink"));
file.changeType(request.getParameter("mode"), request.getParameter("type"));
Map<String, Object> dataInsertImage = new HashMap<>();
dataInsertImage.put("fileType", "png");
dataInsertImage.put("url", DocumentManager.GetServerUrl(true) + "/css/img/logo.png");
Map<String, Object> dataCompareFile = new HashMap<>();
dataCompareFile.put("fileType", "docx");
dataCompareFile.put("url", DocumentManager.GetServerUrl(true) + "/IndexServlet?type=assets&name=sample.docx");
Map<String, Object> dataMailMergeRecipients = new HashMap<>();
dataMailMergeRecipients.put("fileType", "csv");
dataMailMergeRecipients.put("url", DocumentManager.GetServerUrl(true) + "/IndexServlet?type=csv");
if (DocumentManager.TokenEnabled())
{
file.BuildToken();
dataInsertImage.put("token", DocumentManager.CreateToken(dataInsertImage));
dataCompareFile.put("token", DocumentManager.CreateToken(dataCompareFile));
dataMailMergeRecipients.put("token", DocumentManager.CreateToken(dataMailMergeRecipients));
}
Gson gson = new Gson();
request.setAttribute("file", file);
request.setAttribute("docserviceApiUrl", ConfigManager.GetProperty("files.docservice.url.api"));
request.setAttribute("docserviceApiUrl", ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.api"));
request.setAttribute("dataInsertImage", gson.toJson(dataInsertImage).substring(1, gson.toJson(dataInsertImage).length()-1));
request.setAttribute("dataCompareFile", gson.toJson(dataCompareFile));
request.setAttribute("dataMailMergeRecipients", gson.toJson(dataMailMergeRecipients));
request.getRequestDispatcher("editor.jsp").forward(request, response);
}

View File

@ -18,19 +18,16 @@
package controllers;
import helpers.ConfigManager;
import helpers.CookieManager;
import helpers.DocumentManager;
import helpers.ServiceConverter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import com.google.gson.Gson;
import helpers.*;
import java.io.*;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.Scanner;
import java.util.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
@ -39,7 +36,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;
import entities.FileType;
import helpers.FileUtility;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
@ -49,8 +46,6 @@ import org.primeframework.jwt.domain.JWT;
@MultipartConfig
public class IndexServlet extends HttpServlet
{
private static final String DocumentJwtHeader = ConfigManager.GetProperty("files.docservice.header");
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String action = request.getParameter("type");
@ -69,6 +64,8 @@ public class IndexServlet extends HttpServlet
case "upload":
Upload(request, response, writer);
break;
case "download":
Download(request, response, writer);
case "convert":
Convert(request, response, writer);
break;
@ -78,6 +75,15 @@ public class IndexServlet extends HttpServlet
case "remove":
Remove(request, response, writer);
break;
case "assets":
Assets(request, response, writer);
break;
case "csv":
CSV(request, response, writer);
break;
case "files":
Files(request, response, writer);
break;
}
}
@ -115,7 +121,7 @@ public class IndexServlet extends HttpServlet
InputStream fileStream = httpPostedFile.getInputStream();
fileName = DocumentManager.GetCorrectName(fileName);
fileName = DocumentManager.GetCorrectName(fileName, null);
String fileStoragePath = DocumentManager.StoragePath(fileName, null);
File file = new File(fileStoragePath);
@ -133,7 +139,7 @@ public class IndexServlet extends HttpServlet
}
CookieManager cm = new CookieManager(request);
DocumentManager.CreateMeta(fileName, cm.getCookie("uid"), cm.getCookie("uname"));
DocumentManager.CreateMeta(fileName, cm.getCookie("uid"), cm.getCookie("uname"), null);
writer.write("{ \"filename\": \"" + fileName + "\"}");
@ -150,8 +156,8 @@ public class IndexServlet extends HttpServlet
try
{
String fileName = request.getParameter("filename");
String fileUri = DocumentManager.GetFileUri(fileName);
String fileName = FileUtility.GetFileName(request.getParameter("filename"));
String fileUri = DocumentManager.GetFileUri(fileName, true);
String fileExt = FileUtility.GetFileExtension(fileName);
FileType fileType = FileUtility.GetFileType(fileName);
String internalFileExt = DocumentManager.GetInternalExtension(fileType);
@ -168,7 +174,7 @@ public class IndexServlet extends HttpServlet
return;
}
String correctName = DocumentManager.GetCorrectName(FileUtility.GetFileNameWithoutExtension(fileName) + internalFileExt);
String correctName = DocumentManager.GetCorrectName(FileUtility.GetFileNameWithoutExtension(fileName) + internalFileExt, null);
URL url = new URL(newFileUri);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
@ -201,7 +207,7 @@ public class IndexServlet extends HttpServlet
fileName = correctName;
CookieManager cm = new CookieManager(request);
DocumentManager.CreateMeta(fileName, cm.getCookie("uid"), cm.getCookie("uname"));
DocumentManager.CreateMeta(fileName, cm.getCookie("uid"), cm.getCookie("uname"), null);
}
writer.write("{ \"filename\" : \"" + fileName + "\"}");
@ -215,132 +221,53 @@ public class IndexServlet extends HttpServlet
private static void Track(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
{
String userAddress = request.getParameter("userAddress");
String fileName = request.getParameter("fileName");
JSONObject body = null;
String storagePath = DocumentManager.StoragePath(fileName, userAddress);
String body = "";
try
{
Scanner scanner = new Scanner(request.getInputStream());
scanner.useDelimiter("\\A");
body = scanner.hasNext() ? scanner.next() : "";
scanner.close();
}
catch (Exception ex)
{
writer.write("get request.getInputStream error:" + ex.getMessage());
try {
body = TrackManager.readBody(request, writer);
} catch (Exception e) {
e.printStackTrace();
return;
}
if (body.isEmpty())
{
writer.write("empty request.getInputStream");
return;
}
JSONParser parser = new JSONParser();
JSONObject jsonObj;
try
{
Object obj = parser.parse(body);
jsonObj = (JSONObject) obj;
}
catch (Exception ex)
{
writer.write("JSONParser.parse error:" + ex.getMessage());
return;
}
int status;
String downloadUri;
String changesUri;
String key;
if (DocumentManager.TokenEnabled())
{
String token = (String) jsonObj.get("token");
if (token == null) {
String header = (String) request.getHeader(DocumentJwtHeader == null || DocumentJwtHeader.isEmpty() ? "Authorization" : DocumentJwtHeader);
if (header != null && !header.isEmpty()) {
token = header.startsWith("Bearer ") ? header.substring(7) : header;
}
}
if (token == null || token.isEmpty()) {
writer.write("{\"error\":1,\"message\":\"JWT expected\"}");
return;
}
JWT jwt = DocumentManager.ReadToken(token);
if (jwt == null)
{
writer.write("{\"error\":1,\"message\":\"JWT validation failed\"}");
return;
}
if (jwt.getObject("payload") != null) {
try {
@SuppressWarnings("unchecked") LinkedHashMap<String, Object> payload =
(LinkedHashMap<String, Object>)jwt.getObject("payload");
jwt.claims = payload;
}
catch (Exception ex) {
writer.write("{\"error\":1,\"message\":\"Wrong payload\"}");
return;
}
}
status = jwt.getInteger("status");
downloadUri = jwt.getString("url");
changesUri = jwt.getString("changesurl");
key = jwt.getString("key");
}
else
{
status = Math.toIntExact((long) jsonObj.get("status"));
downloadUri = (String) jsonObj.get("url");
changesUri = (String) jsonObj.get("changesurl");
key = (String) jsonObj.get("key");
}
int status = Math.toIntExact((long) body.get("status"));
int saved = 0;
if (status == 2 || status == 3)//MustSave, Corrupted
{
try
{
String histDir = DocumentManager.HistoryDir(storagePath);
String versionDir = DocumentManager.VersionDir(histDir, DocumentManager.GetFileVersion(histDir) + 1);
File ver = new File(versionDir);
File toSave = new File(storagePath);
if (!ver.exists()) ver.mkdirs();
toSave.renameTo(new File(versionDir + File.separator + "prev" + FileUtility.GetFileExtension(fileName)));
downloadToFile(downloadUri, toSave);
downloadToFile(changesUri, new File(versionDir + File.separator + "diff.zip"));
String history = (String) jsonObj.get("changeshistory");
if (history == null && jsonObj.containsKey("history")) {
history = ((JSONObject) jsonObj.get("history")).toJSONString();
if (status == 1) { //Editing
JSONArray actions = (JSONArray) body.get("actions");
JSONArray users = (JSONArray) body.get("users");
JSONObject action = (JSONObject) actions.get(0);
if (actions != null && action.get("type").toString().equals("0")) { //finished edit
String user = (String) action.get("userid");
if (users.indexOf(user) == -1) {
String key = (String) body.get("key");
try {
TrackManager.commandRequest("forcesave", key);
} catch (Exception e) {
e.printStackTrace();
}
}
if (history != null && !history.isEmpty()) {
FileWriter fw = new FileWriter(new File(versionDir + File.separator + "changes.json"));
fw.write(history);
fw.close();
}
FileWriter fw = new FileWriter(new File(versionDir + File.separator + "key.txt"));
fw.write(key);
fw.close();
}
catch (Exception ex)
{
}
String userAddress = request.getParameter("userAddress");
String fileName = FileUtility.GetFileName(request.getParameter("fileName"));
if (status == 2 || status == 3) { //MustSave, Corrupted
try {
TrackManager.processSave(body, fileName, userAddress);
} catch (Exception ex) {
ex.printStackTrace();
saved = 1;
}
}
if (status == 6 || status == 7) { //MustForceSave, CorruptedForceSave
try {
TrackManager.processForceSave(body, fileName, userAddress);
} catch (Exception ex) {
ex.printStackTrace();
saved = 1;
}
}
@ -352,7 +279,7 @@ public class IndexServlet extends HttpServlet
{
try
{
String fileName = request.getParameter("filename");
String fileName = FileUtility.GetFileName(request.getParameter("filename"));
String path = DocumentManager.StoragePath(fileName, null);
File f = new File(path);
@ -369,6 +296,73 @@ public class IndexServlet extends HttpServlet
}
}
private static void Files(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
{
ArrayList<Map<String, Object>> files = null;
try {
Gson gson = new Gson();
response.setContentType("application/json");
if (request.getParameter("fileId") == null) {
files = DocumentManager.GetFilesInfo();
writer.write(gson.toJson(files));
}else {
String fileId = request.getParameter("fileId");
files = DocumentManager.GetFilesInfo(fileId);
if(files.isEmpty()) {
writer.write("\"File not found\"");
}else {
writer.write(gson.toJson(files));
}
}
}
catch (Exception e)
{
writer.write("{ \"error\": \"" + e.getMessage() + "\"}");
}
}
private static void CSV(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
{
String fileName = "assets/sample/csv.csv";
URL fileUrl = Thread.currentThread().getContextClassLoader().getResource(fileName);
Path filePath = null;
try {
filePath = Paths.get(fileUrl.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
}
download(filePath.toString(), response, writer);
}
private static void Assets(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
{
String fileName = "assets/sample/" + FileUtility.GetFileName(request.getParameter("name"));
URL fileUrl = Thread.currentThread().getContextClassLoader().getResource(fileName);
Path filePath = null;
try {
filePath = Paths.get(fileUrl.toURI());
} catch (URISyntaxException e) {
e.printStackTrace();
}
download(filePath.toString(), response, writer);
}
private static void Download(HttpServletRequest request, HttpServletResponse response, PrintWriter writer)
{
try {
String fileName = FileUtility.GetFileName(request.getParameter("name"));
String filePath = DocumentManager.ForcesavePath(fileName, null, false);
if (filePath.equals("")) {
filePath = DocumentManager.StoragePath(fileName, null);
}
download(filePath, response, writer);
} catch (Exception e) {
writer.write("{ \"error\": \"File not found\"}");
}
}
private static void delete(File f) throws Exception {
if (f.isDirectory()) {
for (File c : f.listFiles())
@ -378,32 +372,36 @@ public class IndexServlet extends HttpServlet
throw new Exception("Failed to delete file: " + f);
}
private static void downloadToFile(String url, File file) throws Exception {
if (url == null || url.isEmpty()) throw new Exception("argument url");
if (file == null) throw new Exception("argument path");
URL uri = new URL(url);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) uri.openConnection();
InputStream stream = connection.getInputStream();
if (stream == null)
{
throw new Exception("Stream is null");
private static void download(String filePath, HttpServletResponse response, PrintWriter writer) {
String fileType = null;
try {
fileType = Files.probeContentType(Paths.get(filePath));
} catch (IOException e) {
e.printStackTrace();
}
try (FileOutputStream out = new FileOutputStream(file))
{
int read;
final byte[] bytes = new byte[1024];
while ((read = stream.read(bytes)) != -1)
{
out.write(bytes, 0, read);
File file = new File(filePath);
response.setHeader("Content-Length", String.valueOf(file.length()));
response.setHeader("Content-Type", fileType);
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + file.getName());
BufferedInputStream inputStream = null;
try {
FileInputStream fileInputStream = new FileInputStream(file);
inputStream = new BufferedInputStream(fileInputStream);
int readBytes = 0;
while ((readBytes = inputStream.read()) != -1)
writer.write(readBytes);
}catch (Exception e){
e.printStackTrace();
}finally {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
out.flush();
}
connection.disconnect();
}
@Override

View File

@ -20,11 +20,7 @@ package entities;
import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.*;
import helpers.DocumentManager;
import helpers.ServiceConverter;
@ -54,18 +50,23 @@ public class FileModel
document = new Document();
document.title = fileName;
document.url = DocumentManager.GetFileUri(fileName);
document.url = DocumentManager.GetFileUri(fileName, true);
document.urlUser = DocumentManager.GetFileUri(fileName, false);
document.fileType = FileUtility.GetFileExtension(fileName).replace(".", "");
document.key = ServiceConverter.GenerateRevisionId(DocumentManager.CurUserHostAddress(null) + "/" + fileName + "/" + Long.toString(new File(DocumentManager.StoragePath(fileName, null)).lastModified()));
document.info = new Info();
document.info.favorite = uid != null && !uid.isEmpty() ? uid.equals("uid-2") : null;
editorConfig = new EditorConfig(actionData);
editorConfig.callbackUrl = DocumentManager.GetCallback(fileName);
if (lang != null) editorConfig.lang = lang;
if (uid != null) editorConfig.user.id = uid;
if (uname != null) editorConfig.user.name = uname;
if (uname != null) editorConfig.user.name = uid.equals("uid-0") ? null : uname;
if (editorConfig.user.id.equals("uid-2")) editorConfig.user.group = "group-2";
if (editorConfig.user.id.equals("uid-3")) editorConfig.user.group = "group-3";
editorConfig.customization.goback.url = DocumentManager.GetServerUrl() + "/IndexServlet";
editorConfig.customization.goback.url = DocumentManager.GetServerUrl(false) + "/IndexServlet";
changeType(mode, type);
}
@ -76,7 +77,7 @@ public class FileModel
if (_type != null) type = _type;
Boolean canEdit = DocumentManager.GetEditedExts().contains(FileUtility.GetFileExtension(document.title));
editorConfig.customization.submitForm = canEdit && (mode.equals("edit") || mode.equals("fillForms"));
editorConfig.mode = canEdit && !mode.equals("view") ? "edit" : "view";
document.permissions = new Permissions(mode, type, canEdit);
@ -86,7 +87,7 @@ public class FileModel
public void InitDesktop()
{
editorConfig.InitDesktop(document.url);
editorConfig.InitDesktop(document.urlUser);
}
public void BuildToken()
@ -107,13 +108,13 @@ public class FileModel
if (DocumentManager.GetFileVersion(histDir) > 0) {
Integer curVer = DocumentManager.GetFileVersion(histDir);
Set<Object> hist = new HashSet<Object>();
List<Object> hist = new ArrayList<>();
Map<String, Object> histData = new HashMap<String, Object>();
for (Integer i = 0; i <= curVer; i++) {
for (Integer i = 1; i <= curVer; i++) {
Map<String, Object> obj = new HashMap<String, Object>();
Map<String, Object> dataObj = new HashMap<String, Object>();
String verDir = DocumentManager.VersionDir(histDir, i + 1);
String verDir = DocumentManager.VersionDir(histDir, i);
try {
String key = null;
@ -123,7 +124,7 @@ public class FileModel
obj.put("key", key);
obj.put("version", i);
if (i == 0) {
if (i == 1) {
String createdInfo = readFileToEnd(new File(histDir + File.separator + "createdInfo.json"));
JSONObject json = (JSONObject) parser.parse(createdInfo);
@ -138,8 +139,8 @@ public class FileModel
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetPathUri(verDir + File.separator + "prev" + FileUtility.GetFileExtension(document.title)));
dataObj.put("version", i);
if (i > 0) {
JSONObject changes = (JSONObject) parser.parse(readFileToEnd(new File(DocumentManager.VersionDir(histDir, i) + File.separator + "changes.json")));
if (i > 1) {
JSONObject changes = (JSONObject) parser.parse(readFileToEnd(new File(DocumentManager.VersionDir(histDir, i - 1) + File.separator + "changes.json")));
JSONObject change = (JSONObject) ((JSONArray) changes.get("changes")).get(0);
obj.put("changes", changes.get("changes"));
@ -147,16 +148,21 @@ public class FileModel
obj.put("created", change.get("created"));
obj.put("user", change.get("user"));
Map<String, Object> prev = (Map<String, Object>) histData.get(Integer.toString(i - 1));
Map<String, Object> prev = (Map<String, Object>) histData.get(Integer.toString(i - 2));
Map<String, Object> prevInfo = new HashMap<String, Object>();
prevInfo.put("key", prev.get("key"));
prevInfo.put("url", prev.get("url"));
dataObj.put("previous", prevInfo);
dataObj.put("changesUrl", DocumentManager.GetPathUri(DocumentManager.VersionDir(histDir, i) + File.separator + "diff.zip"));
dataObj.put("changesUrl", DocumentManager.GetPathUri(DocumentManager.VersionDir(histDir, i - 1) + File.separator + "diff.zip"));
}
if (DocumentManager.TokenEnabled())
{
dataObj.put("token", DocumentManager.CreateToken(dataObj));
}
hist.add(obj);
histData.put(Integer.toString(i), dataObj);
histData.put(Integer.toString(i - 1), dataObj);
} catch (Exception ex) { }
}
@ -191,8 +197,10 @@ public class FileModel
{
public String title;
public String url;
public String urlUser;
public String fileType;
public String key;
public Info info;
public Permissions permissions;
}
@ -205,6 +213,7 @@ public class FileModel
public Boolean modifyFilter;
public Boolean modifyContentControl;
public Boolean review;
public List<String> reviewGroups;
public Permissions(String mode, String type, Boolean canEdit)
{
@ -215,7 +224,22 @@ public class FileModel
modifyFilter = !mode.equals("filter");
modifyContentControl = !mode.equals("blockcontent");
review = mode.equals("edit") || mode.equals("review");
reviewGroups = editorConfig.user.group != null ? GetReviewGroups(editorConfig.user.group) : null;
}
private List<String> GetReviewGroups(String group){
Map<String, List<String>> reviewGroups = new HashMap<>();
reviewGroups.put("group-2", Arrays.asList("group-2", ""));
reviewGroups.put("group-3", Arrays.asList("group-2"));
return reviewGroups.get(group);
}
}
public class Info
{
Boolean favorite;
}
public class EditorConfig
@ -251,14 +275,18 @@ public class FileModel
{
public String id = "uid-1";
public String name = "John Smith";
public String group = null;
}
public class Customization
{
public Goback goback;
public Boolean forcesave;
public Boolean submitForm;
public Customization()
{
forcesave = false;
goback = new Goback();
}

View File

@ -20,7 +20,7 @@ package entities;
public enum FileType
{
Text,
Spreadsheet,
Presentation
Word,
Cell,
Slide
}

View File

@ -24,14 +24,12 @@ import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.InetAddress;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import entities.FileType;
@ -134,7 +132,33 @@ public class DocumentManager
public static String StoragePath(String fileName, String userAddress)
{
String directory = FilesRootPath(userAddress);
return directory + fileName;
return directory + FileUtility.GetFileName(fileName);
}
public static String ForcesavePath(String fileName, String userAddress, Boolean create)
{
String hostAddress = CurUserHostAddress(userAddress);
String serverPath = request.getSession().getServletContext().getRealPath("");
String storagePath = ConfigManager.GetProperty("storage-folder");
String directory = serverPath + storagePath + File.separator + hostAddress + File.separator;
File file = new File(directory);
if (!file.exists()) return "";
directory = directory + fileName + "-hist" + File.separator;
file = new File(directory);
if (!create && !file.exists()) return "";
file.mkdirs();
directory = directory + fileName;
file = new File(directory);
if (!create && !file.exists()) {
return "";
}
return directory;
}
public static String HistoryDir(String storagePath)
@ -165,7 +189,7 @@ public class DocumentManager
}
});
return dirs.length;
return dirs.length + 1;
}
public static int GetFileVersion(String fileName, String userAddress)
@ -173,26 +197,26 @@ public class DocumentManager
return GetFileVersion(HistoryDir(StoragePath(fileName, userAddress)));
}
public static String GetCorrectName(String fileName)
public static String GetCorrectName(String fileName, String userAddress)
{
String baseName = FileUtility.GetFileNameWithoutExtension(fileName);
String ext = FileUtility.GetFileExtension(fileName);
String name = baseName + ext;
File file = new File(StoragePath(name, null));
File file = new File(StoragePath(name, userAddress));
for (int i = 1; file.exists(); i++)
{
name = baseName + " (" + i + ")" + ext;
file = new File(StoragePath(name, null));
file = new File(StoragePath(name, userAddress));
}
return name;
}
public static void CreateMeta(String fileName, String uid, String uname) throws Exception
public static void CreateMeta(String fileName, String uid, String uname, String userAddress) throws Exception
{
String histDir = HistoryDir(StoragePath(fileName, null));
String histDir = HistoryDir(StoragePath(fileName, userAddress));
File dir = new File(histDir);
dir.mkdir();
@ -224,9 +248,10 @@ public class DocumentManager
public static String CreateDemo(String fileExt, Boolean sample, String uid, String uname) throws Exception
{
String demoName = (sample ? "sample." : "new.") + fileExt;
String fileName = GetCorrectName(demoName);
String demoPath = "assets" + File.separator + (sample ? "sample" : "new") + File.separator;
String fileName = GetCorrectName(demoName, null);
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(demoName);
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(demoPath + demoName);
File file = new File(StoragePath(fileName, null));
@ -241,16 +266,16 @@ public class DocumentManager
out.flush();
}
CreateMeta(fileName, uid, uname);
CreateMeta(fileName, uid, uname, null);
return fileName;
}
public static String GetFileUri(String fileName)
public static String GetFileUri(String fileName, Boolean forDocumentServer)
{
try
{
String serverPath = GetServerUrl();
String serverPath = GetServerUrl(forDocumentServer);
String storagePath = ConfigManager.GetProperty("storage-folder");
String hostAddress = CurUserHostAddress(null);
@ -264,9 +289,39 @@ public class DocumentManager
}
}
public static ArrayList<Map<String, Object>> GetFilesInfo(){
ArrayList<Map<String, Object>> files = new ArrayList<>();
for(File file : GetStoredFiles(null)){
Map<String, Object> map = new LinkedHashMap<>();
map.put("version", GetFileVersion(file.getName(), null));
map.put("id", ServiceConverter.GenerateRevisionId(CurUserHostAddress(null) + "/" + file.getName() + "/" + Long.toString(new File(StoragePath(file.getName(), null)).lastModified())));
map.put("contentLength", new BigDecimal(String.valueOf((file.length()/1024.0))).setScale(2, RoundingMode.HALF_UP) + " KB");
map.put("pureContentLength", file.length());
map.put("title", file.getName());
map.put("updated", String.valueOf(new Date(file.lastModified())));
files.add(map);
}
return files;
}
public static ArrayList<Map<String, Object>> GetFilesInfo(String fileId){
ArrayList<Map<String, Object>> file = new ArrayList<>();
for (Map<String, Object> map : GetFilesInfo()){
if (map.get("id").equals(fileId)){
file.add(map);
break;
}
}
return file;
}
public static String GetPathUri(String path)
{
String serverPath = GetServerUrl();
String serverPath = GetServerUrl(true);
String storagePath = ConfigManager.GetProperty("storage-folder");
String hostAddress = CurUserHostAddress(null);
@ -276,14 +331,17 @@ public class DocumentManager
}
public static String GetServerUrl()
{
return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
public static String GetServerUrl(Boolean forDocumentServer) {
if (forDocumentServer && !ConfigManager.GetProperty("files.docservice.url.example").equals("")) {
return ConfigManager.GetProperty("files.docservice.url.example");
} else {
return request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath();
}
}
public static String GetCallback(String fileName)
{
String serverPath = GetServerUrl();
String serverPath = GetServerUrl(true);
String hostAddress = CurUserHostAddress(null);
try
{
@ -299,13 +357,13 @@ public class DocumentManager
public static String GetInternalExtension(FileType fileType)
{
if (fileType.equals(FileType.Text))
if (fileType.equals(FileType.Word))
return ".docx";
if (fileType.equals(FileType.Spreadsheet))
if (fileType.equals(FileType.Cell))
return ".xlsx";
if (fileType.equals(FileType.Presentation))
if (fileType.equals(FileType.Slide))
return ".pptx";
return ".docx";

View File

@ -34,15 +34,15 @@ public class FileUtility
String ext = GetFileExtension(fileName).toLowerCase();
if (ExtsDocument.contains(ext))
return FileType.Text;
return FileType.Word;
if (ExtsSpreadsheet.contains(ext))
return FileType.Spreadsheet;
return FileType.Cell;
if (ExtsPresentation.contains(ext))
return FileType.Presentation;
return FileType.Slide;
return FileType.Text;
return FileType.Word;
}
public static List<String> ExtsDocument = Arrays.asList
@ -50,7 +50,7 @@ public class FileUtility
".doc", ".docx", ".docm",
".dot", ".dotx", ".dotm",
".odt", ".fodt", ".ott", ".rtf", ".txt",
".html", ".htm", ".mht",
".html", ".htm", ".mht", ".xml",
".pdf", ".djvu", ".fb2", ".epub", ".xps"
);
@ -72,17 +72,10 @@ public class FileUtility
public static String GetFileName(String url)
{
if (url == null) return null;
//for external file url
String tempstorage = ConfigManager.GetProperty("files.docservice.url.tempstorage");
if (!tempstorage.isEmpty() && url.startsWith(tempstorage))
{
Map<String, String> params = GetUrlParams(url);
return params == null ? null : params.get("filename");
}
if (url == null) return "";
String fileName = url.substring(url.lastIndexOf('/') + 1, url.length());
fileName = fileName.split("\\?")[0];
return fileName;
}

View File

@ -40,7 +40,7 @@ import org.json.simple.parser.ParseException;
public class ServiceConverter
{
private static int ConvertTimeout = 120000;
private static final String DocumentConverterUrl = ConfigManager.GetProperty("files.docservice.url.converter");
private static final String DocumentConverterUrl = ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.converter");
private static final String DocumentJwtHeader = ConfigManager.GetProperty("files.docservice.header");
public static class ConvertBody
@ -125,7 +125,7 @@ public class ServiceConverter
if (DocumentManager.TokenEnabled())
{
connection.setRequestProperty(DocumentJwtHeader == "" ? "Authorization" : DocumentJwtHeader, "Bearer " + headerToken);
connection.setRequestProperty(DocumentJwtHeader.equals("") ? "Authorization" : DocumentJwtHeader, "Bearer " + headerToken);
}
connection.connect();
@ -223,7 +223,7 @@ public class ServiceConverter
return resultPercent >= 100l ? responseUri : "";
}
private static String ConvertStreamToString(InputStream stream) throws IOException
public static String ConvertStreamToString(InputStream stream) throws IOException
{
InputStreamReader inputStreamReader = new InputStreamReader(stream);
StringBuilder stringBuilder = new StringBuilder();
@ -241,7 +241,7 @@ public class ServiceConverter
return result;
}
private static JSONObject ConvertStringToJSON(String jsonString) throws ParseException
public static JSONObject ConvertStringToJSON(String jsonString) throws ParseException
{
JSONParser parser = new JSONParser();
Object obj = parser.parse(jsonString);

View File

@ -0,0 +1,299 @@
/**
*
* (c) Copyright Ascensio System SIA 2020
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package helpers;
import com.google.gson.Gson;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.primeframework.jwt.domain.JWT;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
public class TrackManager {
private static final String DocumentJwtHeader = ConfigManager.GetProperty("files.docservice.header");
public static JSONObject readBody(HttpServletRequest request, PrintWriter writer) throws Exception {
String bodyString = "";
try {
Scanner scanner = new Scanner(request.getInputStream());
scanner.useDelimiter("\\A");
bodyString = scanner.hasNext() ? scanner.next() : "";
scanner.close();
}
catch (Exception ex) {
writer.write("get request.getInputStream error:" + ex.getMessage());
throw ex;
}
if (bodyString.isEmpty()) {
writer.write("empty request.getInputStream");
throw new Exception("empty request.getInputStream");
}
JSONParser parser = new JSONParser();
JSONObject body;
try {
Object obj = parser.parse(bodyString);
body = (JSONObject) obj;
} catch (Exception ex) {
writer.write("JSONParser.parse error:" + ex.getMessage());
throw ex;
}
if (DocumentManager.TokenEnabled()) {
String token = (String) body.get("token");
if (token == null) {
String header = (String) request.getHeader(DocumentJwtHeader == null || DocumentJwtHeader.isEmpty() ? "Authorization" : DocumentJwtHeader);
if (header != null && !header.isEmpty()) {
token = header.startsWith("Bearer ") ? header.substring(7) : header;
}
}
if (token == null || token.isEmpty()) {
writer.write("{\"error\":1,\"message\":\"JWT expected\"}");
throw new Exception("{\"error\":1,\"message\":\"JWT expected\"}");
}
JWT jwt = DocumentManager.ReadToken(token);
if (jwt == null) {
writer.write("{\"error\":1,\"message\":\"JWT validation failed\"}");
throw new Exception("{\"error\":1,\"message\":\"JWT validation failed\"}");
}
if (jwt.getObject("payload") != null) {
try {
@SuppressWarnings("unchecked") LinkedHashMap<String, Object> payload =
(LinkedHashMap<String, Object>)jwt.getObject("payload");
jwt.claims = payload;
} catch (Exception ex) {
writer.write("{\"error\":1,\"message\":\"Wrong payload\"}");
throw ex;
}
}
try {
Gson gson = new Gson();
Object obj = parser.parse(gson.toJson(jwt.claims));
body = (JSONObject) obj;
} catch (Exception ex) {
writer.write("JSONParser.parse error:" + ex.getMessage());
throw ex;
}
}
return body;
}
public static void processSave(JSONObject body, String fileName, String userAddress) throws Exception {
String downloadUri = (String) body.get("url");
String changesUri = (String) body.get("changesurl");
String key = (String) body.get("key");
String newFileName = fileName;
String curExt = FileUtility.GetFileExtension(fileName);
String downloadExt = FileUtility.GetFileExtension(downloadUri);
if (!curExt.equals(downloadExt)) {
try {
String newFileUri = ServiceConverter.GetConvertedUri(downloadUri, downloadExt, curExt, ServiceConverter.GenerateRevisionId(downloadUri), false);
if (newFileUri.isEmpty()) {
newFileName = DocumentManager.GetCorrectName(FileUtility.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
} else {
downloadUri = newFileUri;
}
} catch (Exception e){
newFileName = DocumentManager.GetCorrectName(FileUtility.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
}
String storagePath = DocumentManager.StoragePath(newFileName, userAddress);
File histDir = new File(DocumentManager.HistoryDir(storagePath));
if (!histDir.exists()) histDir.mkdirs();
String versionDir = DocumentManager.VersionDir(histDir.getAbsolutePath(), DocumentManager.GetFileVersion(histDir.getAbsolutePath()));
File ver = new File(versionDir);
File lastVersion = new File(DocumentManager.StoragePath(fileName, userAddress));
File toSave = new File(storagePath);
if (!ver.exists()) ver.mkdirs();
lastVersion.renameTo(new File(versionDir + File.separator + "prev" + curExt));
downloadToFile(downloadUri, toSave);
downloadToFile(changesUri, new File(versionDir + File.separator + "diff.zip"));
String history = (String) body.get("changeshistory");
if (history == null && body.containsKey("history")) {
history = ((JSONObject) body.get("history")).toJSONString();
}
if (history != null && !history.isEmpty()) {
FileWriter fw = new FileWriter(new File(versionDir + File.separator + "changes.json"));
fw.write(history);
fw.close();
}
FileWriter fw = new FileWriter(new File(versionDir + File.separator + "key.txt"));
fw.write(key);
fw.close();
String forcesavePath = DocumentManager.ForcesavePath(newFileName, userAddress, false);
if (!forcesavePath.equals("")) {
File forceSaveFile = new File(forcesavePath);
forceSaveFile.delete();
}
}
public static void processForceSave(JSONObject body, String fileName, String userAddress) throws Exception {
String downloadUri = (String) body.get("url");
String curExt = FileUtility.GetFileExtension(fileName);
String downloadExt = FileUtility.GetFileExtension(downloadUri);
String newFileName = fileName;
if (!curExt.equals(downloadExt)) {
try {
String newFileUri = ServiceConverter.GetConvertedUri(downloadUri, downloadExt, curExt, ServiceConverter.GenerateRevisionId(downloadUri), false);
if (newFileUri.isEmpty()) {
newFileName = DocumentManager.GetCorrectName(FileUtility.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
} else {
downloadUri = newFileUri;
}
} catch (Exception e){
newFileName = DocumentManager.GetCorrectName(FileUtility.GetFileNameWithoutExtension(fileName) + downloadExt, userAddress);
}
}
String forcesavePath = "";
boolean isSubmitForm = body.get("forcesavetype").toString().equals("3");
if (isSubmitForm) {
//new file
if (newFileName.equals(fileName)){
newFileName = DocumentManager.GetCorrectName(fileName, userAddress);
}
forcesavePath = DocumentManager.StoragePath(newFileName, userAddress);
} else {
forcesavePath = DocumentManager.ForcesavePath(newFileName, userAddress, false);
if (forcesavePath == "") {
forcesavePath = DocumentManager.ForcesavePath(newFileName, userAddress, true);
}
}
File toSave = new File(forcesavePath);
downloadToFile(downloadUri, toSave);
if (isSubmitForm) {
JSONArray actions = (JSONArray) body.get("actions");
JSONObject action = (JSONObject) actions.get(0);
String user = (String) action.get("userid");
DocumentManager.CreateMeta(newFileName, user, "Filling Form", userAddress);
}
}
private static void downloadToFile(String url, File file) throws Exception {
if (url == null || url.isEmpty()) throw new Exception("argument url");
if (file == null) throw new Exception("argument path");
URL uri = new URL(url);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) uri.openConnection();
InputStream stream = connection.getInputStream();
if (stream == null)
{
throw new Exception("Stream is null");
}
try (FileOutputStream out = new FileOutputStream(file))
{
int read;
final byte[] bytes = new byte[1024];
while ((read = stream.read(bytes)) != -1)
{
out.write(bytes, 0, read);
}
out.flush();
}
connection.disconnect();
}
public static void commandRequest(String method, String key) throws Exception {
String DocumentCommandUrl = ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.command");
URL url = new URL(DocumentCommandUrl);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("c", method);
params.put("key", key);
String headerToken = "";
if (DocumentManager.TokenEnabled())
{
Map<String, Object> payloadMap = new HashMap<String, Object>();
payloadMap.put("payload", params);
headerToken = DocumentManager.CreateToken(payloadMap);
connection.setRequestProperty(DocumentJwtHeader.equals("") ? "Authorization" : DocumentJwtHeader, "Bearer " + headerToken);
String token = DocumentManager.CreateToken(params);
params.put("token", token);
}
Gson gson = new Gson();
String bodyString = gson.toJson(params);
byte[] bodyByte = bodyString.getBytes(StandardCharsets.UTF_8);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
connection.setDoOutput(true);
connection.connect();
try (OutputStream os = connection.getOutputStream()) {
os.write(bodyByte);
}
InputStream stream = connection.getInputStream();;
if (stream == null)
throw new Exception("Could not get an answer");
String jsonString = ServiceConverter.ConvertStreamToString(stream);
connection.disconnect();
JSONObject response = ServiceConverter.ConvertStringToJSON(jsonString);
if (!response.get("error").toString().equals("0")){
throw new Exception(response.toJSONString());
}
}
}

View File

@ -3,12 +3,15 @@ storage-folder=app_data
files.docservice.viewed-docs=.pdf|.djvu|.xps
files.docservice.edited-docs=.docx|.xlsx|.csv|.pptx|.txt
files.docservice.convert-docs=.docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.epub
files.docservice.convert-docs=.docm|.dotx|.dotm|.dot|.doc|.odt|.fodt|.ott|.xlsm|.xltx|.xltm|.xlt|.xls|.ods|.fods|.ots|.pptm|.ppt|.ppsx|.ppsm|.pps|.potx|.potm|.pot|.odp|.fodp|.otp|.rtf|.mht|.html|.htm|.xml|.epub|.fb2
files.docservice.timeout=120000
files.docservice.url.converter=https://documentserver/ConvertService.ashx
files.docservice.url.tempstorage=https://documentserver/ResourceService.ashx
files.docservice.url.api=https://documentserver/web-apps/apps/api/documents/api.js
files.docservice.url.preloader=https://documentserver/web-apps/apps/api/documents/cache-scripts.html
files.docservice.url.site=https://documentserver/
files.docservice.url.converter=ConvertService.ashx
files.docservice.url.command=coauthoring/CommandService.ashx
files.docservice.url.api=web-apps/apps/api/documents/api.js
files.docservice.url.preloader=web-apps/apps/api/documents/cache-scripts.html
files.docservice.url.example=
files.docservice.secret=
files.docservice.header=Authorization

View File

@ -1,13 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET</param-value>
</init-param>
<init-param>
<param-name>cors.support.credentials</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>cors.exposed.headers</param-name>
<param-value>Access-Control-Allow-Origin,Access-Control-Allow-Methods</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
<session-timeout>30</session-timeout>
</session-config>
<listener>
<listener-class>
controllers.GlobalServletContextListener
</listener-class>
<listener-class>controllers.GlobalServletContextListener</listener-class>
</listener>
</web-app>
</web-app>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,15 @@
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -44,10 +44,13 @@ a, a:hover, a:visited {
.top-panel {
background: url("img/logo.png") no-repeat 30px center #3D4A6B;
background: #3D4A6B;
height: 80px;
width: 100%;
}
.top-panel img {
margin: 12px 0 0 16px;
}
.main-panel {
margin: 80px auto;
width: 600px;
@ -125,13 +128,13 @@ label .checkbox {
text-align: center;
text-decoration: none;
}
.try-editor.document {
.try-editor.word {
background-image: url("img/file_docx.png");
}
.try-editor.spreadsheet {
.try-editor.cell {
background-image: url("img/file_xlsx.png");
}
.try-editor.presentation {
.try-editor.slide {
background-image: url("img/file_pptx.png");
}
@ -312,15 +315,15 @@ label .checkbox {
white-space: nowrap;
}
.stored-edit.text {
.stored-edit.word {
background-image: url("img/icon_docx.png");
}
.stored-edit.spreadsheet {
.stored-edit.cell {
background-image: url("img/icon_xlsx.png");
}
.stored-edit.presentation {
.stored-edit.slide {
background-image: url("img/icon_pptx.png");
}

View File

@ -1,6 +1,8 @@
<%@page import="entities.FileModel"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% FileModel Model = (FileModel) request.getAttribute("file"); %>
<!DOCTYPE html>
<html>
<head>
@ -26,11 +28,9 @@
*
-->
<title>ONLYOFFICE</title>
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<link rel="icon" href="css/img/<%= Model.documentType %>.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="css/editor.css" />
<% FileModel Model = (FileModel) request.getAttribute("file"); %>
<script type="text/javascript" src="${docserviceApiUrl}"></script>
<script type="text/javascript" language="javascript">
@ -86,6 +86,28 @@
docEditor.setActionLink(replaceActionLink(location.href, linkParam));
};
var onMetaChange = function (event) {
var favorite = !!event.data.favorite;
var title = document.title.replace(/^\☆/g, "");
document.title = (favorite ? "☆" : "") + title;
docEditor.setFavorite(favorite);
};
var onRequestInsertImage = function(event) {
docEditor.insertImage({
"c": event.data.c,
${dataInsertImage}
})
};
var onRequestCompareFile = function() {
docEditor.setRevisedFile(${dataCompareFile});
};
var onRequestMailMergeRecipients = function (event) {
docEditor.setMailMergeRecipients(${dataMailMergeRecipients});
};
var config = JSON.parse('<%= FileModel.Serialize(Model) %>');
config.width = "100%";
config.height = "100%";
@ -96,6 +118,10 @@
"onError": onError,
"onOutdatedVersion": onOutdatedVersion,
"onMakeActionLink": onMakeActionLink,
"onMetaChange": onMetaChange,
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
};
<%
@ -111,7 +137,7 @@
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = <%= historyData %>;
docEditor.setHistoryData(histData[ver]);
docEditor.setHistoryData(histData[ver - 1]);
};
config.events['onRequestHistoryClose'] = function () {
document.location.reload();

View File

@ -35,7 +35,11 @@
</head>
<body>
<div class="top-panel"></div>
<div class="top-panel">
<a href="">
<img src ="css/img/logo.svg" alt="ONLYOFFICE" />
</a>
</div>
<div class="main-panel">
<span class="portal-name">ONLYOFFICE Document Editors</span>
@ -52,6 +56,7 @@
<option value="uid-1">John Smith</option>
<option value="uid-2">Mark Pottato</option>
<option value="uid-3">Hamish Mitchell</option>
<option value="uid-0">anonymous</option>
</select>
</td>
<td width="70%" valign="middle">Select user name before opening the document; you can open the same document using different users in different Web browser sessions, so you can check out multi-user editing functions.</td>
@ -114,9 +119,9 @@
</div>
<div class="create-panel">
<ul class="try-editor-list clearFix">
<li><a class="try-editor document" data-type="docx">Create<br />Document</a></li>
<li><a class="try-editor spreadsheet" data-type="xlsx">Create<br />Spreadsheet</a></li>
<li><a class="try-editor presentation" data-type="pptx">Create<br />Presentation</a></li>
<li><a class="try-editor word" data-type="docx">Create<br />Document</a></li>
<li><a class="try-editor cell" data-type="xlsx">Create<br />Spreadsheet</a></li>
<li><a class="try-editor slide" data-type="pptx">Create<br />Presentation</a></li>
</ul>
<label class="create-sample">
<input id="createSample" class="checkbox" type="checkbox" />
@ -152,7 +157,7 @@
<a class="stored-edit <%= docType %>" href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>" target="_blank">
<span title="<%= files[i].getName() %>"><%= files[i].getName() %></span>
</a>
<a href="<%= DocumentManager.GetFileUri(files[i].getName()) %>">
<a href="IndexServlet?type=download&name=<%=URLEncoder.encode(files[i].getName(), "UTF-8")%>">
<img class="icon-download" src="css/img/download-24.png" alt="Download" title="Download" />
</a>
<a class="delete-file" data-filename="<%= files[i].getName() %>">
@ -171,11 +176,11 @@
</a>
</td>
<td class="contentCells contentCells-icon">
<% if (docType.equals("text")) { %>
<% if (docType.equals("word")) { %>
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=review" target="_blank">
<img src="css/img/review-24.png" alt="Open in editor for review" title="Open in editor for review"/>
</a>
<% } else if (docType.equals("spreadsheet")) { %>
<% } else if (docType.equals("cell")) { %>
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=filter" target="_blank">
<img src="css/img/filter-24.png" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" />
</a>
@ -187,14 +192,14 @@
</a>
</td>
<td class="contentCells contentCells-icon">
<% if (docType.equals("text")) { %>
<% if (docType.equals("word")) { %>
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=fillForms" target="_blank">
<img src="css/img/fill-forms-24.png" alt="Open in editor for filling in forms" title="Open in editor for filling in forms"/>
</a>
<% } %>
</td>
<td class="contentCells contentCells-shift contentCells-icon">
<% if (docType.equals("text")) { %>
<% if (docType.equals("word")) { %>
<a href="EditorServlet?fileName=<%= URLEncoder.encode(files[i].getName(), "UTF-8") %>&type=desktop&mode=blockcontent" target="_blank">
<img src="css/img/block-content-24.png" alt="Open in editor without content control modification" title="Open in editor without content control modification"/>
</a>
@ -278,7 +283,7 @@
<div id="cancelEdit" class="button gray">Cancel</div>
</div>
<span id="loadScripts" data-docs="<%= ConfigManager.GetProperty("files.docservice.url.preloader") %>"></span>
<span id="loadScripts" data-docs="<%= ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.preloader") %>"></span>
<div class="bottom-panel">
&copy; Ascensio System SIA <%= Calendar.getInstance().get(Calendar.YEAR) %>. All rights reserved.

View File

@ -31,7 +31,11 @@
<body>
<div id="page">
<div class="top-panel"></div>
<div class="top-panel">
<a href="">
<img src ="logo.svg" alt="ONLYOFFICE" />
</a>
</div>
<div id="mainPanel" class="main-panel">
<span class="portal-name">ONLYOFFICE Document Editors</span>
<br />

View File

@ -65,7 +65,7 @@ function key(k) {
};
var getDocumentType = function (ext) {
if (".doc.docx.docm.dot.dotx.dotm.odt.fodt.ott.rtf.txt.html.htm.mht.pdf.djvu.fb2.epub.xps".indexOf(ext) != -1) return "text";
if (".doc.docx.docm.dot.dotx.dotm.odt.fodt.ott.rtf.txt.html.htm.mht.xml.pdf.djvu.fb2.epub.xps".indexOf(ext) != -1) return "text";
if (".xls.xlsx.xlsm.xlt.xltx.xltm.ods.fods.ots.csv".indexOf(ext) != -1) return "spreadsheet";
if (".pps.ppsx.ppsm.ppt.pptx.pptm.pot.potx.potm.odp.fodp.otp".indexOf(ext) != -1) return "presentation";
return null;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -0,0 +1,15 @@
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -41,10 +41,13 @@ div {
.top-panel {
background: url("logo.png") no-repeat 30px center #3D4A6B;
background: #3D4A6B;
height: 80px;
width: 100%;
}
.top-panel img{
margin: 12px 0 0 16px;
}
.main-panel {
margin: 105px auto 0;
width: 350px;

View File

@ -292,6 +292,7 @@ app.get("/files", function(req, res) {
try {
docManager.init(storageFolder, req, res);
const filesInDirectoryInfo = docManager.getFilesInfo();
res.setHeader("Content-Type", "application/json");
res.write(JSON.stringify(filesInDirectoryInfo));
} catch (ex) {
console.log(ex);
@ -305,6 +306,7 @@ app.get("/files/file/:fileId", function(req, res) {
docManager.init(storageFolder, req, res);
const fileId = req.params.fileId;
const fileInfoById = docManager.getFilesInfo(fileId);
res.setHeader("Content-Type", "application/json");
res.write(JSON.stringify(fileInfoById));
} catch (ex) {
console.log(ex);
@ -338,6 +340,19 @@ app.delete("/file", function (req, res) {
res.end();
});
app.get("/csv", function (req, res) {
var fileName = "csv.csv";
var csvPath = path.join(__dirname, "public", "assets", "sample", fileName);
res.setHeader("Content-Length", fileSystem.statSync(csvPath).size);
res.setHeader("Content-Type", mime.getType(csvPath));
res.setHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + encodeURIComponent(fileName));
var filestream = fileSystem.createReadStream(csvPath);
filestream.pipe(res);
})
app.post("/track", function (req, res) {
docManager.init(storageFolder, req, res);
@ -348,110 +363,155 @@ app.post("/track", function (req, res) {
var processTrack = function (response, body, fileName, userAddress) {
var processSave = function (downloadUri, body, fileName, userAddress, resp) {
var curExt = fileUtility.getFileExtension(fileName);
var downloadExt = fileUtility.getFileExtension(downloadUri);
if (downloadExt != curExt) {
var key = documentService.generateRevisionId(downloadUri);
try {
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (dUri) {
processSave(dUri, body, fileName, userAddress, resp)
});
return;
} catch (ex) {
console.log(ex);
fileName = docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress)
}
}
var callbackProcessSave = function (downloadUri, body, fileName, userAddress, newFileName) {
try {
var storagePath = docManager.storagePath(newFileName, userAddress);
var path = docManager.storagePath(fileName, userAddress);
if (docManager.existsSync(path)) {
var historyPath = docManager.historyPath(fileName, userAddress);
if (historyPath == "") {
historyPath = docManager.historyPath(fileName, userAddress, true);
docManager.createDirectory(historyPath);
}
var count_version = docManager.countVersion(historyPath);
version = count_version + 1;
var versionPath = docManager.versionPath(fileName, userAddress, version);
docManager.createDirectory(versionPath);
var downloadZip = body.changesurl;
if (downloadZip) {
var path_changes = docManager.diffPath(fileName, userAddress, version);
var diffZip = syncRequest("GET", downloadZip);
fileSystem.writeFileSync(path_changes, diffZip.getBody());
}
var changeshistory = body.changeshistory || JSON.stringify(body.history);
if (changeshistory) {
var path_changes_json = docManager.changesPath(fileName, userAddress, version);
fileSystem.writeFileSync(path_changes_json, changeshistory);
}
var path_key = docManager.keyPath(fileName, userAddress, version);
fileSystem.writeFileSync(path_key, body.key);
var path_prev = docManager.prevFilePath(fileName, userAddress, version);
fileSystem.writeFileSync(path_prev, fileSystem.readFileSync(path));
var file = syncRequest("GET", downloadUri);
fileSystem.writeFileSync(path, file.getBody());
var forcesavePath = docManager.forcesavePath(fileName, userAddress, false);
if (forcesavePath != "") {
fileSystem.unlinkSync(forcesavePath);
}
var historyPath = docManager.historyPath(newFileName, userAddress);
if (historyPath == "") {
historyPath = docManager.historyPath(newFileName, userAddress, true);
docManager.createDirectory(historyPath);
}
var count_version = docManager.countVersion(historyPath);
version = count_version + 1;
var versionPath = docManager.versionPath(newFileName, userAddress, version);
docManager.createDirectory(versionPath);
var downloadZip = body.changesurl;
if (downloadZip) {
var path_changes = docManager.diffPath(newFileName, userAddress, version);
var diffZip = syncRequest("GET", downloadZip);
fileSystem.writeFileSync(path_changes, diffZip.getBody());
}
var changeshistory = body.changeshistory || JSON.stringify(body.history);
if (changeshistory) {
var path_changes_json = docManager.changesPath(newFileName, userAddress, version);
fileSystem.writeFileSync(path_changes_json, changeshistory);
}
var path_key = docManager.keyPath(newFileName, userAddress, version);
fileSystem.writeFileSync(path_key, body.key);
var path_prev = path.join(versionPath, "prev" + fileUtility.getFileExtension(fileName));
fileSystem.renameSync(docManager.storagePath(fileName, userAddress), path_prev);
var file = syncRequest("GET", downloadUri);
fileSystem.writeFileSync(storagePath, file.getBody());
var forcesavePath = docManager.forcesavePath(newFileName, userAddress, false);
if (forcesavePath != "") {
fileSystem.unlinkSync(forcesavePath);
}
} catch (ex) {
console.log(ex);
response.write("{\"error\":1}");
response.end();
return;
}
response.write("{\"error\":0}");
response.end();
};
}
var processForceSave = function (downloadUri, body, fileName, userAddress, resp) {
var processSave = function (downloadUri, body, fileName, userAddress, resp) {
var curExt = fileUtility.getFileExtension(fileName);
var downloadExt = fileUtility.getFileExtension(downloadUri);
var newFileName = fileName;
if (downloadExt != curExt) {
var key = documentService.generateRevisionId(downloadUri);
newFileName = docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress);
try {
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (dUri) {
processForceSave(dUri, body, fileName, userAddress, resp)
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (err, data) {
if (err) {
callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
return;
}
try {
var res = documentService.getResponseUri(data);
callbackProcessSave(res.value, body, fileName, userAddress, fileName);
return;
} catch (ex) {
console.log(ex);
callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
return;
}
});
return;
} catch (ex) {
console.log(ex);
fileName = docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress)
}
}
callbackProcessSave(downloadUri, body, fileName, userAddress, newFileName);
};
var callbackProcessForceSave = function (downloadUri, body, fileName, userAddress, newFileName){
try {
var isSubmitForm = body.forcesavetype === 3; //SubmitForm
var path = docManager.storagePath(fileName, userAddress);
var forcesavePath = docManager.forcesavePath(fileName, userAddress, false);
if (forcesavePath == "") {
forcesavePath = docManager.forcesavePath(fileName, userAddress, true);
if (isSubmitForm) {
//new file
if (newFileName == fileName){
newFileName = docManager.getCorrectName(fileName, userAddress);
}
var forcesavePath = docManager.storagePath(newFileName, userAddress);
} else {
forcesavePath = docManager.forcesavePath(newFileName, userAddress, false);
if (forcesavePath == "") {
forcesavePath = docManager.forcesavePath(newFileName, userAddress, true);
}
}
var file = syncRequest("GET", downloadUri);
fileSystem.writeFileSync(forcesavePath, file.getBody());
if (isSubmitForm) {
var uid =body.actions[0].userid
docManager.saveFileData(newFileName, uid, "Filling Form", userAddress);
}
} catch (ex) {
console.log(ex);
response.write("{\"error\":1}");
response.end();
return;
}
response.write("{\"error\":0}");
response.end();
}
var processForceSave = function (downloadUri, body, fileName, userAddress, resp) {
var curExt = fileUtility.getFileExtension(fileName);
var downloadExt = fileUtility.getFileExtension(downloadUri);
var newFileName = fileName;
if (downloadExt != curExt) {
var key = documentService.generateRevisionId(downloadUri);
try {
documentService.getConvertedUriSync(downloadUri, downloadExt, curExt, key, function (err, data) {
if (err) {
newFileName = docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress);
callbackProcessForceSave(downloadUri, body, fileName, userAddress, newFileName);
return;
}
try {
var res = documentService.getResponseUri(data);
callbackProcessForceSave(res.value, body, fileName, userAddress, newFileName);
return;
} catch (ex) {
console.log(ex);
newFileName = docManager.getCorrectName(fileUtility.getFileName(fileName, true) + downloadExt, userAddress);
callbackProcessForceSave(downloadUri, body, fileName, userAddress, newFileName);
return;
}
});
return;
} catch (ex) {
console.log(ex);
}
}
callbackProcessForceSave (downloadUri, body, fileName, userAddress, newFileName);
};
if (body.status == 1) { //Editing
@ -538,11 +598,24 @@ app.get("/editor", function (req, res) {
var historyData = [];
var lang = docManager.getLang();
var userid = req.query.userid ? req.query.userid : "uid-1";
var name = req.query.name ? req.query.name : "John Smith";
var name = (userid == "uid-0" ? null : (req.query.name ? req.query.name : "John Smith"));
var actionData = req.query.action ? req.query.action : "null";
var userGroup = null;
var reviewGroups = null;
if (userid == "uid-2")
{
userGroup = "group-2";
// own and without group
reviewGroups = ["group-2", ""];
} else if (userid == "uid-3") {
userGroup = "group-3";
// other group only
reviewGroups = ["group-2"];
}
if (fileExt != null) {
var fileName = docManager.createDemo((req.query.sample ? "sample." : "new.") + fileExt, userid, name);
var fileName = docManager.createDemo(!!req.query.sample, fileExt, userid, name);
var redirectPath = docManager.getServerUrl() + "/editor?fileName=" + encodeURIComponent(fileName) + docManager.getCustomParams();
res.redirect(redirectPath);
@ -558,6 +631,7 @@ app.get("/editor", function (req, res) {
}
var key = docManager.getKey(fileName);
var url = docManager.getFileUri(fileName);
var urlUser = docManager.getlocalFileUri(fileName, 0, false)
var mode = req.query.mode || "edit"; //mode: view/edit/review/comment/fillForms/embedded
var type = req.query.type || ""; //type: embedded/mobile/desktop
if (type == "") {
@ -565,6 +639,7 @@ app.get("/editor", function (req, res) {
}
var canEdit = configServer.get('editedDocs').indexOf(fileUtility.getFileExtension(fileName)) != -1;
var submitForm = canEdit && (mode == "edit" || mode == "fillForms");
var countVersion = 1;
@ -626,8 +701,10 @@ app.get("/editor", function (req, res) {
name: fileName,
ext: fileUtility.getFileExtension(fileName, true),
uri: url,
uriUser: urlUser,
version: countVersion,
created: new Date().toDateString()
created: new Date().toDateString(),
favorite: req.query.userid ? req.query.userid === "uid-2" : "null"
},
editor: {
type: type,
@ -648,12 +725,27 @@ app.get("/editor", function (req, res) {
lang: lang,
userid: userid,
name: name,
userGroup: userGroup,
reviewGroups: JSON.stringify(reviewGroups),
fileChoiceUrl: fileChoiceUrl,
submitForm: submitForm,
plugins: JSON.stringify(plugins),
actionData: actionData
},
history: history,
historyData: historyData
historyData: historyData,
dataInsertImage: {
fileType: "png",
url: docManager.getServerUrl(true) + "/images/logo.png"
},
dataCompareFile: {
fileType: "docx",
url: docManager.getServerUrl(true) + "/assets/sample/sample.docx"
},
dataMailMergeRecipients: {
fileType: "csv",
url: docManager.getServerUrl(true) + "/csv"
}
};
if (cfgSignatureEnable) {
@ -662,6 +754,9 @@ app.get("/editor", function (req, res) {
console.log(err);
} else {
argss.editor.token = jwt.sign(JSON.parse("{"+html+"}"), cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
argss.dataInsertImage.token = jwt.sign(argss.dataInsertImage, cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
argss.dataCompareFile.token = jwt.sign(argss.dataCompareFile, cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
argss.dataMailMergeRecipients.token = jwt.sign(argss.dataMailMergeRecipients, cfgSignatureSecret, {expiresIn: cfgSignatureSecretExpiresIn});
}
res.render("editor", argss);
});

View File

@ -15,13 +15,12 @@
"siteUrl": "https://documentserver/",
"commandUrl": "coauthoring/CommandService.ashx",
"converterUrl": "ConvertService.ashx",
"tempStorageUrl": "ResourceService.ashx",
"apiUrl": "web-apps/apps/api/documents/api.js",
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html",
"exampleUrl": null,
"viewedDocs": [".pdf", ".djvu", ".xps"],
"editedDocs": [".docx", ".xlsx", ".csv", ".pptx", ".txt"],
"convertedDocs": [".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt", ".fodt", ".ott", ".xlsm", ".xls", ".xltx", ".xltm", ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsx", ".ppsm", ".pps", ".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".epub", ".fb2"],
"convertedDocs": [".docm", ".doc", ".dotx", ".dotm", ".dot", ".odt", ".fodt", ".ott", ".xlsm", ".xls", ".xltx", ".xltm", ".xlt", ".ods", ".fods", ".ots", ".pptm", ".ppt", ".ppsx", ".ppsm", ".pps", ".potx", ".potm", ".pot", ".odp", ".fodp", ".otp", ".rtf", ".mht", ".html", ".htm", ".xml", ".epub", ".fb2"],
"storageFolder": "./files",
"storagePath": "/files",
"maxFileSize": 1073741824,

View File

@ -1,7 +1,7 @@
{
"server": {
"port": 3000,
"siteUrl": "http://127.0.0.1:8001/",
"siteUrl": "http://127.0.0.1:8000/",
"apiUrl": "web-apps/apps/api/documents/api.js",
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html"
}

View File

@ -1,7 +1,7 @@
{
"server": {
"port": 3000,
"siteUrl": "http://127.0.0.1:8001/",
"siteUrl": "http://127.0.0.1:8000/",
"apiUrl": "web-apps/apps/api/documents/api.js",
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html"
}

View File

@ -1,7 +1,7 @@
{
"server": {
"port": 80,
"siteUrl": "http://127.0.0.1:8001/",
"siteUrl": "http://127.0.0.1:8000/",
"apiUrl": "web-apps/apps/api/documents/api.js",
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html"
}

View File

@ -99,19 +99,22 @@ docManager.getCorrectName = function (fileName, userAddress) {
return name;
};
docManager.createDemo = function (demoName, userid, username) {
docManager.createDemo = function (isSample, fileExt, userid, username) {
const demoName = (isSample ? "sample" : "new") + "." + fileExt;
const fileName = docManager.getCorrectName(demoName);
docManager.copyFile(path.join(__dirname, "..","public", "samples", demoName), docManager.storagePath(fileName));
docManager.copyFile(path.join(__dirname, "..","public", "assets", isSample ? "sample" : "new", demoName), docManager.storagePath(fileName));
docManager.saveFileData(fileName, userid, username);
return fileName;
};
docManager.saveFileData = function (fileName, userid, username) {
const userAddress = docManager.curUserHostAddress();
const date_create = fileSystem.statSync(docManager.storagePath(fileName)).mtime;
docManager.saveFileData = function (fileName, userid, username, userAddress) {
if (!userAddress) {
userAddress = docManager.curUserHostAddress();
}
const date_create = fileSystem.statSync(docManager.storagePath(fileName, userAddress)).mtime;
const minutes = (date_create.getMinutes() < 10 ? '0' : '') + date_create.getMinutes().toString();
const month = (date_create.getMonth() < 10 ? '0' : '') + (parseInt(date_create.getMonth().toString()) + 1);
const sec = (date_create.getSeconds() < 10 ? '0' : '') + date_create.getSeconds().toString();
@ -276,13 +279,13 @@ docManager.copyFile = function (exist, target) {
};
docManager.getInternalExtension = function (fileType) {
if (fileType == fileUtility.fileType.text)
if (fileType == fileUtility.fileType.word)
return ".docx";
if (fileType == fileUtility.fileType.spreadsheet)
if (fileType == fileUtility.fileType.cell)
return ".xlsx";
if (fileType == fileUtility.fileType.presentation)
if (fileType == fileUtility.fileType.slide)
return ".pptx";
return ".docx";

View File

@ -39,12 +39,7 @@ documentService.userIp = null;
documentService.getConvertedUriSync = function (documentUri, fromExtension, toExtension, documentRevisionId, callback) {
documentService.getConvertedUri(documentUri, fromExtension, toExtension, documentRevisionId, false, function (err, data) {
if (err) {
callback();
return;
}
var res = documentService.getResponseUri(data);
callback(res.value);
callback(err, data);
});
};

View File

@ -16,24 +16,14 @@
*
*/
var configServer = require('config').get('server');
var siteUrl = configServer.get('siteUrl');
var tempStorageUrl = siteUrl + configServer.get('tempStorageUrl');
var fileUtility = {};
fileUtility.getFileName = function (url, withoutExtension) {
if (!url) return "";
var filename;
if (tempStorageUrl && url.indexOf(tempStorageUrl) == 0) {
var params = getUrlParams(url);
filename = params == null ? null : params["filename"];
} else {
var parts = url.toLowerCase().split("/");
fileName = parts.pop();
}
var parts = url.toLowerCase().split("/");
var fileName = parts.pop();
fileName = fileName.split("?")[0];
if (withoutExtension) {
var ext = fileUtility.getFileExtension(fileName);
@ -56,20 +46,20 @@ fileUtility.getFileExtension = function (url, withoutDot) {
fileUtility.getFileType = function (url) {
var ext = fileUtility.getFileExtension(url);
if (fileUtility.documentExts.indexOf(ext) != -1) return fileUtility.fileType.text;
if (fileUtility.spreadsheetExts.indexOf(ext) != -1) return fileUtility.fileType.spreadsheet;
if (fileUtility.presentationExts.indexOf(ext) != -1) return fileUtility.fileType.presentation;
if (fileUtility.documentExts.indexOf(ext) != -1) return fileUtility.fileType.word;
if (fileUtility.spreadsheetExts.indexOf(ext) != -1) return fileUtility.fileType.cell;
if (fileUtility.presentationExts.indexOf(ext) != -1) return fileUtility.fileType.slide;
return fileUtility.fileType.text;
return fileUtility.fileType.word;
}
fileUtility.fileType = {
text: "text",
spreadsheet: "spreadsheet",
presentation: "presentation"
word: "word",
cell: "cell",
slide: "slide"
}
fileUtility.documentExts = [".doc", ".docx", ".docm", ".dot", ".dotx", ".dotm", ".odt", ".fodt", ".ott", ".rtf", ".txt", ".html", ".htm", ".mht", ".pdf", ".djvu", ".fb2", ".epub", ".xps"];
fileUtility.documentExts = [".doc", ".docx", ".docm", ".dot", ".dotx", ".dotm", ".odt", ".fodt", ".ott", ".rtf", ".txt", ".html", ".htm", ".mht", ".xml", ".pdf", ".djvu", ".fb2", ".epub", ".xps"];
fileUtility.spreadsheetExts = [".xls", ".xlsx", ".xlsm", ".xlt", ".xltx", ".xltm", ".ods", ".fods", ".ots", ".csv"];

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,15 @@
<svg width="248" height="53" viewBox="0 0 248 53" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 46.0096L7.13565 37.771C5.62145 37.0517 5.62145 35.9401 7.13565 35.2863L13.3241 32.4093L24.8453 37.771C26.3595 38.4902 28.7954 38.4902 30.2437 37.771L41.7648 32.4093L47.9533 35.2863C49.4675 36.0055 49.4675 37.1171 47.9533 37.771L30.1779 46.0096C28.7954 46.6635 26.3595 46.6635 24.9111 46.0096Z" fill="#FF6F3D"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 35.8748L7.13565 27.6361C5.62145 26.9169 5.62145 25.8053 7.13565 25.1514L13.1925 22.3398L24.9111 27.7669C26.4253 28.4861 28.8612 28.4861 30.3096 27.7669L42.0282 22.3398L48.085 25.1514C49.5992 25.8707 49.5992 26.9823 48.085 27.6361L30.3096 35.8748C28.7953 36.594 26.3595 36.594 24.9111 35.8748Z" fill="#95C038"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.9111 26.0014L7.13565 17.7628C5.62145 17.0435 5.62145 15.9319 7.13565 15.2781L24.9111 7.03944C26.4253 6.32019 28.8612 6.32019 30.3096 7.03944L48.085 15.2781C49.5992 15.9973 49.5992 17.1089 48.085 17.7628L30.3096 26.0014C28.7953 26.6553 26.3595 26.6553 24.9111 26.0014Z" fill="#5DC0E8"/>
<path d="M60.085 26.4189C60.085 23.0116 61.0651 20.44 63.0906 18.7685C65.0509 17.0327 67.4031 16.197 70.0821 16.197C72.7611 16.197 75.048 17.0327 77.0083 18.7685C78.9685 20.5043 79.9486 23.0116 79.9486 26.4832C79.9486 29.8906 78.9685 32.4621 77.0083 34.1336C75.048 35.8695 72.6958 36.7052 70.0821 36.7052C67.4031 36.7052 65.1162 35.8695 63.0906 34.1336C61.0651 32.3978 60.085 29.8263 60.085 26.4189ZM64.3975 26.4189C64.3975 28.7976 64.8548 30.4692 65.7043 31.5621C66.619 32.655 67.5992 33.3622 68.6446 33.6193C68.906 33.6836 69.102 33.7479 69.3634 33.7479C69.5594 33.7479 69.8208 33.8122 70.0168 33.8122C70.2781 33.8122 70.4742 33.8122 70.7355 33.7479C70.9969 33.7479 71.1929 33.6836 71.4543 33.6193C72.4997 33.3622 73.4798 32.655 74.3293 31.5621C75.1787 30.4692 75.6361 28.7334 75.6361 26.4832C75.6361 24.1688 75.1787 22.4973 74.3293 21.4044C73.4798 20.3115 72.4997 19.6043 71.4543 19.3471C71.1929 19.2828 70.9315 19.2186 70.7355 19.2186C70.4742 19.2186 70.2781 19.1543 70.0168 19.1543C69.7554 19.1543 69.5594 19.1543 69.3634 19.2186C69.1673 19.2186 68.906 19.2828 68.6446 19.3471C67.5992 19.6043 66.619 20.3115 65.7043 21.4044C64.8548 22.3687 64.3975 24.1045 64.3975 26.4189Z" fill="white"/>
<path d="M82.105 16.3898H87.4629L94.5198 28.9905L95.5652 31.755H95.6306L95.5652 28.1548V16.3898H99.6817V36.4481H94.3237L87.2669 23.3331L86.2215 21.0829H86.1561L86.2215 24.6188V36.4481H82.105V16.3898Z" fill="white"/>
<path d="M103.929 16.3898H108.045V33.0407H116.147V36.4481H103.929V16.3898Z" fill="white"/>
<path d="M113.599 16.3898H118.369L122.551 23.3974L123.204 24.8117H123.335L123.988 23.3974L128.235 16.3898H132.613L125.23 28.2833V36.4481H121.113V28.219L113.599 16.3898Z" fill="white"/>
<path d="M132.091 26.4189C132.091 23.0116 133.071 20.44 135.096 18.7685C137.057 17.0327 139.409 16.197 142.088 16.197C144.767 16.197 147.054 17.0327 149.014 18.7685C150.974 20.5043 151.954 23.0116 151.954 26.4832C151.954 29.8906 150.974 32.4621 149.014 34.1336C147.054 35.8695 144.702 36.7052 142.088 36.7052C139.409 36.7052 137.122 35.8695 135.096 34.1336C133.136 32.3978 132.091 29.8263 132.091 26.4189ZM136.403 26.4189C136.403 28.7976 136.861 30.4692 137.71 31.5621C138.625 32.655 139.54 33.3622 140.65 33.6193C140.912 33.6836 141.108 33.7479 141.369 33.7479C141.565 33.7479 141.827 33.8122 142.023 33.8122C142.284 33.8122 142.48 33.8122 142.741 33.7479C143.003 33.7479 143.199 33.6836 143.46 33.6193C144.506 33.3622 145.486 32.655 146.335 31.5621C147.185 30.4692 147.642 28.7334 147.642 26.4832C147.642 24.1688 147.185 22.4973 146.335 21.4044C145.486 20.3115 144.506 19.6043 143.46 19.3471C143.199 19.2828 142.937 19.2186 142.741 19.2186C142.48 19.2186 142.284 19.1543 142.023 19.1543C141.761 19.1543 141.565 19.1543 141.369 19.2186C141.173 19.2186 140.912 19.2828 140.65 19.3471C139.605 19.6043 138.625 20.3115 137.71 21.4044C136.861 22.3687 136.403 24.1045 136.403 26.4189Z" fill="white"/>
<path d="M154.829 16.3898H166.198V19.7329H158.946V24.6188H165.872V28.0262H158.946V36.4481H154.829V16.3898Z" fill="white"/>
<path d="M169.27 16.3898H180.639V19.7329H173.386V24.6188H180.312V28.0262H173.386V36.4481H169.27V16.3898Z" fill="white"/>
<path d="M183.057 36.4481V16.3898H187.173V36.4481H183.057Z" fill="white"/>
<path d="M205.311 16.8397V20.3113C204.592 20.0542 203.873 19.8613 203.089 19.7327C202.305 19.6041 201.39 19.5398 200.476 19.5398C198.319 19.5398 196.686 20.1827 195.51 21.5328C194.334 22.8186 193.746 24.4901 193.746 26.4831C193.746 28.4117 194.268 30.019 195.379 31.3048C196.49 32.5905 198.058 33.2977 200.084 33.2977C200.802 33.2977 201.521 33.2334 202.371 33.1692C203.22 33.0406 204.069 32.8477 204.984 32.462L205.246 35.8693C205.115 35.9336 204.919 35.9979 204.723 36.0622C204.462 36.1265 204.2 36.1907 203.873 36.255C203.351 36.3836 202.697 36.4479 201.913 36.5765C201.129 36.6408 200.345 36.7051 199.496 36.7051C199.365 36.7051 199.234 36.7051 199.169 36.7051C199.038 36.7051 198.908 36.7051 198.842 36.7051C196.49 36.5765 194.334 35.6764 192.373 34.1335C190.413 32.5263 189.433 30.019 189.433 26.6759C189.433 23.3972 190.413 20.8256 192.308 19.0255C194.203 17.2254 196.817 16.3254 200.018 16.3254C200.868 16.3254 201.652 16.3254 202.305 16.3897C203.024 16.454 203.677 16.5825 204.396 16.7111C204.527 16.7754 204.723 16.7754 204.854 16.8397C204.984 16.7754 205.115 16.8397 205.311 16.8397Z" fill="white"/>
<path d="M208.578 16.3899H220.797V19.5401H212.76V24.5546H220.013V27.6405H212.76V33.298H220.797V36.4481H208.578V16.3899Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

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