Compare commits

...

481 Commits

Author SHA1 Message Date
2459863430 Merge pull request #468 from ONLYOFFICE/release/1.7.0
Release/1.7.0
2023-10-30 12:17:35 +03:00
52c11fa3a1 using documentserver v7.5 2023-10-27 18:39:40 +03:00
86d2fc1399 Merge pull request #478 from ONLYOFFICE/chore/php-readme
php: update readme
# Conflicts:
#	web/documentserver-example/php/README.md
2023-10-27 18:36:09 +03:00
d2f77d857d Merge pull request #477 from ONLYOFFICE/chore/python-readme
python: update readme
# Conflicts:
#	web/documentserver-example/python/readme.md
2023-10-27 18:34:31 +03:00
4ec7e46736 Merge pull request #473 from ONLYOFFICE/chore/ruby-readme
ruby: update readme
# Conflicts:
#	web/documentserver-example/ruby/README.md
2023-10-25 13:11:37 +03:00
8c433b2867 nodejs: date format fix (Fix Bug 64155)
# Conflicts:
#	web/documentserver-example/nodejs/helpers/docManager.js
2023-10-23 13:33:58 +03:00
c3922de50c fix: actions 2023-10-19 18:35:43 +05:00
29f7beff3c changelog reorder 2023-10-19 12:42:06 +03:00
0a8df9cb5d 1.7.0 2023-10-19 12:40:03 +03:00
08b752411b Merge pull request #465 from ONLYOFFICE/hotfix/history-user-id
nodejs: userId in history fixed
2023-10-12 13:46:23 +03:00
c6a2007c6a nodejs: userId in history fixed 2023-10-12 13:21:58 +03:00
847e4ce6d9 nodejs: fix datetime format in history (56e46466b2) (Fix Bug 64155) 2023-10-09 13:30:49 +03:00
152083ed4e nodejs: update icons 2023-09-29 14:20:34 +03:00
d594870c87 Merge pull request #385 from ONLYOFFICE/dependabot/npm_and_yarn/web/documentserver-example/nodejs/fast-xml-parser-4.2.4
build(deps): bump fast-xml-parser from 3.19.0 to 4.2.4 in /web/documentserver-example/nodejs
2023-09-25 12:47:23 +03:00
ce0bbca5b2 nodejs: update fast-xml-parser 2023-09-25 12:46:58 +03:00
e6831fa52f nodejs: XMLParser usage fixed 2023-09-22 11:31:29 +03:00
ffa686e0a2 update fast-xml-parser package version to 4.3.0 2023-09-22 11:09:45 +03:00
730cc09520 build(deps): bump fast-xml-parser in /web/documentserver-example/nodejs
Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 3.19.0 to 4.2.4.
- [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases)
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/NaturalIntelligence/fast-xml-parser/commits)

---
updated-dependencies:
- dependency-name: fast-xml-parser
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-22 09:32:30 +03:00
35613ddccb nodejs: change get files route 2023-09-02 11:04:18 +03:00
2fa83dcc94 Merge branch 'feature/select-word' into develop 2023-09-01 12:24:33 +03:00
c1af2ba5b4 nodejs: onRequestSelectDocument / setRequestedDocument 2023-09-01 12:24:25 +03:00
fa84f451c2 Merge pull request #432 from ONLYOFFICE/feature/ruby-matrix-formats
ruby: add support for formats
2023-09-01 11:58:34 +03:00
87e9da1212 Merge pull request #444 from ONLYOFFICE/refactor/php-linting
php: many changes to satisfy linter
2023-09-01 09:40:05 +03:00
22dbacaa63 ruby: replace the previous implementation of formats 2023-08-31 11:44:52 +04:00
d192d1e0e8 ruby: add tests for the format module 2023-08-31 11:44:52 +04:00
5b115f7dbc ruby: add format module 2023-08-31 11:44:52 +04:00
41a22934a0 ruby: add document-formats submodule 2023-08-31 11:44:51 +04:00
94f4e83d79 php: update lint action 2023-08-31 11:40:28 +04:00
8ed0c4771d php: many changes to satisfy linter
- Delete unused imports.
- Rename methods and variables from snake case to camel case.
- Shorten code lines.
2023-08-31 11:40:25 +04:00
0445184cbc php: add rules to lint variable names 2023-08-31 11:37:14 +04:00
e4750e7a61 php: set targets for the lint recipe 2023-08-31 11:37:14 +04:00
a78450453d Merge pull request #450 from ONLYOFFICE/feature/csharp-restore
Feature/csharp restore
2023-08-30 22:50:03 +03:00
ca139938e9 csharp: restore to changelog 2023-08-30 22:47:52 +03:00
8ae9dc6fff Merge remote-tracking branch 'remotes/origin/develop' into feature/csharp-restore 2023-08-30 22:47:14 +03:00
9c0121e69f Merge pull request #449 from ONLYOFFICE/feature/csharp-mvc-restore
Feature/csharp mvc restore
2023-08-30 22:46:25 +03:00
e11861b30f csharp-mvc: restore to changelog 2023-08-30 22:46:08 +03:00
21842b772d Merge remote-tracking branch 'remotes/origin/feature/select-cell' into develop 2023-08-30 22:19:14 +03:00
17a1485d52 nodejs: onRequestSelectSpreadsheet/setRequestedSpreadsheet 2023-08-30 22:18:51 +03:00
07c752ed81 nodejs: refactoring 2023-08-30 22:12:59 +03:00
8c704687a7 php: not used function (fd4dfea7d7) 2023-08-30 12:18:34 +03:00
b691eb5717 Merge pull request #436 from ONLYOFFICE/feature/python-matrix-formats
python: add support for formats
2023-08-30 11:24:44 +03:00
dc35b240d1 Merge pull request #448 from ONLYOFFICE/hotfix/restore-paths
fixed restore file paths
2023-08-29 16:45:29 +03:00
527e5053e6 nodejs: fixed restore file paths (Fix Bug 63842) 2023-08-29 16:44:41 +03:00
1839a5c26b nodejs: fix linter 2023-08-29 15:12:52 +03:00
ccb81a60e1 python: replace the previous implementation of formats 2023-08-25 10:06:09 +04:00
b73a70e6d0 python: add tests for the format module 2023-08-25 10:06:09 +04:00
89e64fe71e python: add format module 2023-08-25 10:06:06 +04:00
2ffc44f339 python: add document-formats submodule 2023-08-25 10:06:05 +04:00
4e515a66ef python: add tests for the memoize module 2023-08-25 10:05:59 +04:00
a758f9a6d8 python: add memoize module 2023-08-25 10:05:52 +04:00
0131724cab Merge pull request #445 from ONLYOFFICE/feature/python-msgspec
python: add msgspec
2023-08-24 18:26:33 +03:00
a178dbc612 python: 3rd party licenses 2023-08-24 18:25:48 +03:00
4064f73c89 nodejs: Fix Bug 63800 template image (9048082cb7) 2023-08-24 16:03:33 +03:00
561af8444c Merge remote-tracking branch 'remotes/origin/feature/auto-convert' into develop 2023-08-23 15:16:48 +03:00
091bf10374 nodejs: convert after uploading only tagged formats 2023-08-23 15:16:23 +03:00
63461b3eb6 csharp-mvc: fixed urls for version data 2023-08-23 13:45:58 +03:00
bd20af2096 csharp-mvc: added version restore 2023-08-23 13:03:23 +03:00
2611fae25c csharp-mvc: use ajax for display version history 2023-08-23 12:16:23 +03:00
c740e21e83 csharp: fixed urls for version data 2023-08-23 11:44:41 +03:00
8193d5b9f2 csharp: jwt to version data 2023-08-22 16:41:21 +03:00
1f109c2b88 csharp: added version restore 2023-08-22 16:20:52 +03:00
a676da0a61 python: add msgspec 2023-08-22 12:43:16 +04:00
5f0fcfebd2 csharp: use ajax for display version history 2023-08-21 21:31:06 +03:00
292640aa95 Merge pull request #441 from ONLYOFFICE/feature/php-matrix-formats
php: add support for formats
2023-08-18 14:28:24 +03:00
9aedba8be3 php: 3rd party licenses 2023-08-18 14:26:03 +03:00
c98e8d03d2 Merge pull request #431 from ONLYOFFICE/feature/ruby-internal-network
ruby: add support for internal network
2023-08-17 17:02:21 +03:00
5951870870 Merge pull request #434 from ONLYOFFICE/feature/python-internal-network
python: add support for internal network
2023-08-16 15:06:04 +03:00
9bc6964274 Merge pull request #443 from ONLYOFFICE/feature/php-internal-network
php: add support for internal network
2023-08-16 15:04:41 +03:00
2051f3028e Merge remote-tracking branch 'remotes/origin/release/v7.5.0' into develop 2023-08-16 13:40:15 +03:00
869f8e7ba7 Merge remote-tracking branch 'remotes/origin/feature/referenceData-open' into develop 2023-08-16 13:36:58 +03:00
815b5fb428 nodejs: onRequestOpen for referenceData source file 2023-08-16 13:20:19 +03:00
13a1a6ba2c Merge pull request #440 from ONLYOFFICE/feature/java-spring-templates
java-spring: move document-templates to the assets directory
2023-08-15 11:44:41 +03:00
a3b93fee99 java-spring: update paths to the new location of templates 2023-08-15 12:42:49 +04:00
36cca57dd8 java-spring: move document-templates to the assets directory 2023-08-15 12:42:48 +04:00
53f315c5ee php: add public and private document-server urls to the compose 2023-08-15 10:45:58 +04:00
7c0d8cd59d php: add support for the internal network for the track endpoint 2023-08-15 10:45:58 +04:00
3405af796c php: add tests for the proxy module 2023-08-15 10:45:58 +04:00
b4905eb94e php: add proxy module 2023-08-15 10:45:58 +04:00
5a3330beb2 php: add support for specifying public and private document-server urls 2023-08-15 10:45:58 +04:00
5d16a50f0f php: remove the final keyword for a few classes 2023-08-15 10:45:58 +04:00
d8b6b0bbb5 Merge pull request #433 from ONLYOFFICE/feature/ruby-templates
ruby: move document-templates to the assets directory
2023-08-14 16:43:31 +03:00
7b6c9b5683 ruby: update paths to the new location of templates 2023-08-14 17:36:24 +04:00
d4bed077e0 ruby: move document-templates to the assets directory 2023-08-14 17:36:24 +04:00
8aba537cea Merge pull request #442 from ONLYOFFICE/feature/php-docker
php: add support for containerization
2023-08-14 15:23:51 +03:00
9cc6612bb2 Merge branch 'feature/submit-form' into develop 2023-08-14 11:25:50 +03:00
4bae7d8bf5 nodejs: submitForm to chamgelog 2023-08-14 11:25:14 +03:00
59c9061306 nodejs: fix max length (a06aa8c8b3) 2023-08-14 11:16:23 +03:00
2fb011185a Revert "nodejs: hide submit button"
This reverts commit 94cb70c0db.

# Conflicts:
#	web/documentserver-example/nodejs/app.js
#	web/documentserver-example/nodejs/helpers/users.js
2023-08-14 11:07:23 +03:00
49a58e687d nodejs: 1.6.0 (50a4ddbd11) 2023-08-14 10:43:43 +03:00
42e1b0635a Merge pull request #427 from ONLYOFFICE/feature/java-restore-endpoint
java: add restore endpoint
2023-08-14 09:59:33 +03:00
e9d8b60c13 java: add restore endpoint 2023-08-11 20:39:59 +04:00
33119ca2ad php: replace the previous implementation of formats 2023-08-11 20:35:30 +04:00
913c1350c2 php: add tests for the format module 2023-08-11 20:35:25 +04:00
fa34f5a44e php: add format module 2023-08-11 20:35:19 +04:00
5784171806 php: add serializer 2023-08-11 20:27:56 +04:00
8829f969d3 php: add docker files 2023-08-11 20:25:42 +04:00
ab48645ba8 php: add the recipe to work with docker 2023-08-11 20:25:42 +04:00
5d0f1b62d0 Merge pull request #430 from ONLYOFFICE/feature/java-spring-restore-endpoint
java-spring: add restore endpoint
2023-08-11 17:23:24 +03:00
78747c1cae Merge pull request #438 from ONLYOFFICE/feature/java-templates
java: move document-templates to the assets directory
2023-08-08 15:07:10 +03:00
2955dc004f java: update paths to the new location of templates 2023-08-08 14:47:51 +04:00
85981abd00 java: move document-templates to the assets directory 2023-08-08 14:47:51 +04:00
7542c6ca6e Merge pull request #435 from ONLYOFFICE/feature/python-templates
python: move document-templates to the assets directory
2023-08-08 12:32:04 +03:00
ab0553d988 Merge remote-tracking branch 'remotes/origin/develop' into release/v7.5.0 2023-08-08 12:14:21 +03:00
57e498ebba Merge remote-tracking branch 'remotes/origin/feature/referenceData-key' into develop 2023-08-08 12:06:57 +03:00
ce1052139e nodejs: fix forcesave (Fix Bug 63570) (bf04979c31) 2023-08-08 11:52:29 +03:00
350ea4e678 Merge pull request #426 from ONLYOFFICE/feature/php-project-structure
php: normalize project structure
2023-08-04 22:43:29 +03:00
979391e413 Merge remote-tracking branch 'remotes/origin/feature/referenceData-key' into release/v7.5.0 2023-08-04 13:41:56 +03:00
2b454e23d5 php: simplify the test receipt 2023-08-03 17:14:48 +04:00
9ed5f19d6b php: update urls to the new favicon location 2023-08-03 17:14:48 +04:00
851b2e48c7 php: move favicon files to the images directory 2023-08-03 17:14:48 +04:00
be40222d1a php: rename project namespace 2023-08-03 17:14:48 +04:00
d701f1565b php: update autoload map 2023-08-03 17:14:48 +04:00
2f39fb3bc6 php: update urls to new other files location 2023-08-03 17:14:48 +04:00
626f051aab php: move other files to the source directory 2023-08-03 17:14:48 +04:00
acd4bf87e7 php: update urls to the new global files location 2023-08-03 17:14:48 +04:00
9a9e122eec php: move global files to the source directory 2023-08-03 17:14:48 +04:00
340eaa31f4 php: update urls to the new scripts location 2023-08-03 17:14:48 +04:00
6433f502ad php: move scripts to the assets directory 2023-08-03 17:14:48 +04:00
cbfbf77f0f php: update urls to the new styles location 2023-08-03 17:14:48 +04:00
173641a7af php: move styles to the assets directory 2023-08-03 17:14:48 +04:00
ce37d1de20 php: update urls to the new images location 2023-08-03 17:14:48 +04:00
ce80e89028 php: move images to the assets directory 2023-08-03 17:14:48 +04:00
63365e176e java-spring: add restore endpoint 2023-08-03 12:34:14 +04:00
32a60c09aa python: add public and private document-server urls to the compose 2023-08-02 10:49:34 +04:00
5a03024cd3 python: add support for the internal network for the track endpoint 2023-08-02 10:49:34 +04:00
cb6416c481 python: sort imports 2023-08-02 10:49:34 +04:00
55e4247687 python: add tests for proxy manager 2023-08-02 10:49:34 +04:00
a0620905b2 python: add proxy manager to resolve the document-server url 2023-08-02 10:49:34 +04:00
3fcef4096a python: remove the strict CORS hint 2023-08-02 10:49:34 +04:00
4e5349c1c4 python: add tests for specifying public and private document-server urls 2023-08-02 10:49:34 +04:00
538eec1ff3 python: add support for specifying public and private document-server urls 2023-08-02 10:49:34 +04:00
10e67c787c ruby: add public and private document-server urls to the compose 2023-08-02 10:17:14 +04:00
565a27d981 ruby: add support for the internal network for the track endpoint 2023-08-02 10:17:14 +04:00
7304c1e67a ruby: add tests for proxy manager 2023-08-02 10:17:14 +04:00
f9ba90d3ac ruby: add proxy manager to resolve the document-server url 2023-08-02 10:17:14 +04:00
d2f40c5395 ruby: add tests for specifying public and private document-server urls 2023-08-02 10:17:14 +04:00
ca0b7adcee ruby: add support for specifying public and private document-server urls 2023-08-02 10:17:14 +04:00
df7cfda2fb Merge pull request #429 from ONLYOFFICE/fix/java-spring-save-previous
java-spring: add a step to save the previous version of the file during processing save
2023-07-31 15:37:55 +03:00
9ebef04f3d Merge pull request #415 from ONLYOFFICE/feature/ruby-docker
ruby: add support for containerization
2023-07-31 15:36:46 +03:00
a6ed970bca Merge pull request #413 from ONLYOFFICE/feature/python-docker
python: add support for containerization
2023-07-31 15:36:06 +03:00
7f659bc95e Merge pull request #428 from ONLYOFFICE/fix/php-lint-action
php: update php lint action to latest changes
2023-07-31 09:46:00 +03:00
3c4a1c1c31 Merge pull request #425 from ONLYOFFICE/feature/php-server-configuration
php: simplify server configuration
2023-07-29 15:42:55 +03:00
2bae0567ad nodejs: fix for ie (496a150620) 2023-07-28 17:26:53 +03:00
419fbf90f9 python: update paths to the new location of templates 2023-07-27 17:10:50 +04:00
2d637b88df python: move document-templates to the assets directory 2023-07-27 17:10:50 +04:00
13e2d5b33c python: add recipes to work with docker 2023-07-27 16:12:43 +04:00
f208fe1939 python: add docker files 2023-07-27 16:12:43 +04:00
b3cc35cb5e python: add support for the ADDRESS env variable 2023-07-27 16:12:43 +04:00
8b316b0786 python: move the lint recipe to the bottom of file 2023-07-27 16:12:43 +04:00
c57fcbfd90 python: delete recipes sorting in the help recipe 2023-07-27 16:12:43 +04:00
1939b85c8c ruby: disable strict hosts policy 2023-07-27 11:26:40 +04:00
ee0ac33820 ruby: add recipes to work with docker 2023-07-27 11:26:40 +04:00
c93579d98f ruby: add docker files 2023-07-27 11:26:40 +04:00
61a9e122cd ruby: move the lint recipe to the bottom of file 2023-07-27 11:26:40 +04:00
e88a9f5bed ruby: delete recipes sorting in the help recipe 2023-07-27 11:26:40 +04:00
f1ce0fb415 ruby: rename server recipes 2023-07-27 11:26:40 +04:00
3b142d92fc php: update urls to new endpoints 2023-07-26 17:42:48 +04:00
1898da660e php: simplify server configuration 2023-07-26 17:42:48 +04:00
0629cf0797 php: add HTTPStatus enum 2023-07-26 17:42:48 +04:00
7737670a6d php: delete IIS config 2023-07-26 17:42:48 +04:00
5bdcac42e3 php: add recipes to start the server 2023-07-26 17:42:48 +04:00
4b8ffa26cc php: add fpm config 2023-07-26 17:41:53 +04:00
a4b6fcb512 java-spring: add a step to save the previous version of the file during processing save 2023-07-26 17:34:07 +04:00
523b10c979 php: update php lint action to latest changes 2023-07-26 17:03:50 +04:00
1d4bc95c29 Merge pull request #424 from ONLYOFFICE/feature/php-configuration-manager
php: add support for configuration via environment variables
2023-07-26 15:31:05 +03:00
e94a4863aa php: replace json config with configuration manager 2023-07-26 12:07:58 +04:00
edda981ab7 php: append configuration directory to test recipe 2023-07-26 12:07:55 +04:00
65ebf9a5b1 php: add configuration manager tests 2023-07-26 12:07:55 +04:00
a081cd1f06 php: add configuration manager 2023-07-26 12:07:55 +04:00
04c5ee8cd7 php: add URL tests 2023-07-26 12:07:55 +04:00
3ebf3fabee php: add URL class 2023-07-26 12:07:52 +04:00
403efc1325 php: add tests for the path absolute function 2023-07-26 11:27:50 +04:00
7deedcaa5e php: enrich Path with new methods 2023-07-26 11:27:50 +04:00
161e26dd8a Merge pull request #423 from ONLYOFFICE/feature/php-missed-tests
php: add missed path tests and rewrite path methods a bit
2023-07-26 10:21:30 +03:00
09804349fa php: update path instances due to new methods 2023-07-24 14:22:28 +04:00
83a83f4f5d php: fix make test receipt 2023-07-24 14:22:28 +04:00
79ee987003 php: add path tests 2023-07-24 14:22:28 +04:00
434484cac3 php: separate path normalization from join 2023-07-24 14:22:25 +04:00
a0bafb0e4b php: simplify path string generation 2023-07-24 12:41:43 +04:00
184aded727 php: remove path separator from constructor options 2023-07-24 12:41:40 +04:00
7db708e559 Merge pull request #422 from ONLYOFFICE/feature/php-normalize-dependencies
php: pin and normalize existing dependencies, add new ones
2023-07-21 14:42:41 +03:00
3b3116f56e php: license link 2023-07-21 14:42:18 +03:00
15c70f43d7 Merge pull request #421 from ONLYOFFICE/feature/php-restore-endpoint
php: add restore endpoint
2023-07-21 09:49:00 +03:00
39af4be045 php: restore to changelog 2023-07-21 09:48:35 +03:00
c9dc4862ed php: add ignore file 2023-07-20 16:15:46 +04:00
122d41e307 php: add lint and test recieps 2023-07-20 16:15:44 +04:00
2880db7383 php: add install recipes 2023-07-20 16:14:24 +04:00
c0f23a4fc2 php: add makefile 2023-07-20 16:14:24 +04:00
1a49d8dd03 php: normalize codesniffer config file 2023-07-20 16:14:24 +04:00
180f287c07 php: delete composer scripts 2023-07-20 16:14:24 +04:00
37c33965c8 php: move autoload to the production section 2023-07-20 16:14:24 +04:00
0861732dbe php: replace local jwt with jwt as a dependency 2023-07-20 16:14:24 +04:00
d3220c7a91 php: add phpunit 2023-07-20 16:14:24 +04:00
450cafdae3 php: move mbstring extension to production dependencies 2023-07-20 16:14:24 +04:00
62abe3e569 php: pin dependency versions 2023-07-20 16:14:24 +04:00
8b2fbff3b7 php: update lock file 2023-07-20 16:14:24 +04:00
acf243ee3e php: add restore endpoint 2023-07-19 15:29:27 +04:00
66c38ded4a php: add the common module with Path class 2023-07-19 15:29:27 +04:00
58a73190d4 Merge pull request #420 from ONLYOFFICE/fix/php-assets-path
php: fix a new path to the assets directory
2023-07-19 09:41:21 +03:00
ae7a208831 php: fix a new path to the assets directory 2023-07-18 13:52:13 +04:00
2d83f3f39c Merge pull request #419 from ONLYOFFICE/feature/ruby-restore-endpoint
ruby: add restore endpoint
2023-07-18 12:20:46 +03:00
2aed1e3a83 ruby: restore to changelog 2023-07-18 12:19:57 +03:00
001a99b502 Merge pull request #418 from ONLYOFFICE/fix/ruby-sorbet-commands
ruby: hide sorbet commands for unsupported platforms
2023-07-18 12:18:26 +03:00
a7a9f997d5 ruby: add restore endpoint 2023-07-18 10:35:31 +04:00
4c3dc96e30 Merge pull request #417 from ONLYOFFICE/fix/ruby-config-manager-typo
ruby: fix typo in config manager name
2023-07-18 09:19:46 +03:00
7fe1ae27b4 Merge pull request #416 from ONLYOFFICE/feature/ruby-configuration-manager-tests
ruby: add missed configuration manager tests
2023-07-18 09:19:09 +03:00
dce840c627 ruby: hide sorbet commands for unsupported platforms 2023-07-17 18:50:17 +04:00
4f832ac2f7 ruby: fix typo in config manager name 2023-07-17 18:42:59 +04:00
e7623e29d7 ruby: add test recipe 2023-07-17 18:26:09 +04:00
16dd8a55e5 ruby: add missed configuration manager tests 2023-07-17 18:26:09 +04:00
dca68bf0d1 ruby: add missed imports 2023-07-17 18:26:09 +04:00
f028f1ba2f ruby: add test-unit as a dependency to satisfy rake 2023-07-17 18:26:09 +04:00
5c8867dd20 ruby: move the configuration to its directory 2023-07-17 18:26:09 +04:00
27eea60fc3 Merge pull request #414 from ONLYOFFICE/feature/python-restore-endpoint
python: add restore endpoint
2023-07-17 15:12:00 +03:00
c285b49d3b python: restore to changelog 2023-07-17 15:11:28 +03:00
70c86f3054 python: add onRequestRestore callback 2023-07-14 14:55:57 +04:00
00e5466a0c python: add restore endpoint 2023-07-14 14:55:57 +04:00
12a366a28a python: sort imports 2023-07-14 14:55:12 +04:00
b4918cf493 python: delete unused imports 2023-07-14 14:55:12 +04:00
b2b21980d1 python: add error response 2023-07-14 14:55:12 +04:00
09a97c0f66 python: add tests for the http functions 2023-07-14 14:55:12 +04:00
5db65ef062 python: add functions to declare the http method for the endpoint 2023-07-14 14:55:12 +04:00
5164380336 python: add a function to find a user by his ID 2023-07-14 14:55:12 +04:00
26c5cd0a83 python: remove unused import 2023-07-14 14:55:12 +04:00
bff8c83283 Merge pull request #410 from ONLYOFFICE/feature/python-server-configuration
python: simplify server configuration
2023-07-14 10:43:29 +03:00
827bd3981f python: add missed django_settings_module 2023-07-13 17:10:10 +04:00
e8599c7c56 python: add recipes to start the server 2023-07-13 17:10:06 +04:00
0a3b951eb6 Merge pull request #412 from ONLYOFFICE/feature/ruby-respect-gitignore
ruby: respect gitignore
2023-07-13 15:25:59 +03:00
988da27e3f python: simplify server configuration 2023-07-13 16:23:09 +04:00
a697219dcf ruby: add receipt stages to generate bin files 2023-07-13 16:04:54 +04:00
7649e7f51e ruby: delete files that should be ignored 2023-07-13 16:02:24 +04:00
108b5ea317 ruby: move example-specific ignored files to the root of the example 2023-07-13 16:02:24 +04:00
4ea0760803 Merge pull request #411 from ONLYOFFICE/feature/ruby-server-configuration
ruby: simplify server configuration
2023-07-13 14:51:07 +03:00
c558098deb ruby: delete sqlite3 2023-07-13 14:48:57 +03:00
4a61093343 Merge pull request #409 from ONLYOFFICE/feature/python-configuration-manager
python: add support for configuration via environment variables
2023-07-13 14:46:34 +03:00
2af1f56aa7 ruby: delete sqlite3 as it's not used 2023-07-13 14:02:30 +04:00
6780feafa6 ruby: add recipes to start the server 2023-07-13 14:02:26 +04:00
23b4ffc104 ruby: simplify server configuration 2023-07-12 13:44:20 +04:00
7304166d8f nodejs: key in referenceData 2023-07-12 12:00:37 +03:00
46a9fffb0e 7.4 formats 2023-07-12 11:46:15 +03:00
0ccc98e83f python: standardize the format of URLs 2023-07-10 16:29:59 +04:00
7f59c15112 python: replace the global config with the configuration manager 2023-07-10 16:29:59 +04:00
455f2ee823 python: add tests for the configuration manager 2023-07-10 16:29:51 +04:00
3076a9bc0e python: add configuration manager 2023-07-10 16:05:30 +04:00
c605607b5e python: add test recipe 2023-07-10 14:52:21 +04:00
e05afc931a python: add tests for the string boolean function 2023-07-10 14:49:25 +04:00
53aeb19e2f python: add the common module with string boolean function 2023-07-10 14:46:33 +04:00
14a557be69 Merge pull request #396 from ONLYOFFICE/feature/ruby-configuration-environment
ruby: support for configuration via environment variables
2023-07-10 10:28:24 +03:00
666b6f8a03 Merge pull request #408 from ONLYOFFICE/fix/ruby-sorbet-platforms
ruby: fix sorbet installation on unsupported platforms
2023-07-07 15:33:10 +03:00
ebddc8114a ruby: fix sorbet installation on unsupported platforms 2023-07-05 12:26:00 +04:00
fa76819b2d Merge pull request #403 from ONLYOFFICE/feature/python-normalize-dependencies
python: pin and add new dependencies
2023-07-05 10:02:00 +03:00
69aa25880a python: 3rd party licenses 2023-07-05 10:00:21 +03:00
7cd79280ff python: add help, dev, lint, prod recipes to Makefile 2023-07-04 16:57:03 +04:00
4535bfe661 python: add development dependencies 2023-07-04 16:56:57 +04:00
01cabdf1e5 python: pin python version 2023-07-04 14:12:11 +04:00
8b15a0e417 python: pin dependency versions 2023-07-04 14:12:11 +04:00
451b3b7a38 ruby: standardize the format of the URIs in the configuration 2023-07-04 13:52:40 +04:00
952b495c4d ruby: support for configuration via environment variables 2023-07-04 13:52:37 +04:00
1cd3642de8 Merge pull request #407 from ONLYOFFICE/feature/reference-source
Feature/reference source
2023-07-04 12:49:58 +03:00
a4f49cb86b nodejs: change reference source to changelog 2023-07-04 12:45:15 +03:00
9ca722329f nodejs: 1.6.0 (50a4ddbd11) 2023-07-04 10:51:24 +03:00
496a150620 nodejs: onRequestReferenceSource method 2023-06-30 11:29:38 +03:00
983a92d9e0 nodejs: function for getting of file extension 2023-06-30 11:27:48 +03:00
ad94016a85 Merge remote-tracking branch 'remotes/origin/master' into develop
# Conflicts:
#	CHANGELOG.md
#	web/documentserver-example/php/functions.php
#	web/documentserver-example/php/views/DocEditorView.php
2023-06-29 11:13:23 +05:00
fcb807471f Merge pull request #406 from ONLYOFFICE/release/1.6.0
Release/1.6.0
2023-06-29 11:07:55 +05:00
50a4ddbd11 1.6.0 2023-06-29 11:00:42 +05:00
01d1dc4274 Merge pull request #405 from ONLYOFFICE/hotfix/csharp-reload-filelist-upload
Hotfix/csharp reload filelist upload
2023-06-28 11:20:58 +05:00
1447b304eb Merge pull request #404 from ONLYOFFICE/hotfix/delete-old-file-after-convert
Hotfix/delete old file after convert
2023-06-28 11:20:24 +05:00
8e79c6448f csharp: reload after click on edit or view in upload window 2023-06-27 12:08:59 +03:00
badf3c7d49 csharp-mvc: reload after click on edit or view in upload window 2023-06-27 12:08:35 +03:00
342b31f7d7 java-spring: delete original file after convert 2023-06-27 11:32:28 +03:00
0ae8f5d396 java: delete original file after convert 2023-06-27 11:09:43 +03:00
7a238c2b73 Merge branch 'release/v7.4.0' into hotfix/delete-old-file-after-convert 2023-06-27 10:55:39 +03:00
0b4c67e552 Merge branch 'hotfix/headers-charset-on-upload-convert' into release/v7.4.0 2023-06-27 12:10:42 +05:00
f5391051b1 ruby: delete original file after convert 2023-06-27 09:59:00 +03:00
01c8a940d4 csharp: fix error with convert response (6aa80c4a8c) 2023-06-26 17:33:42 +05:00
579992e40b Merge pull request #402 from ONLYOFFICE/hotfix/csharp
fixed: generating key
2023-06-26 15:42:14 +05:00
3a2218a466 Merge pull request #401 from ONLYOFFICE/hotfix/ruby-filelist-reload-fix
ruby: reload after click on edit or view in upload window
2023-06-26 15:40:55 +05:00
0ea28f525f Merge pull request #400 from ONLYOFFICE/hotfix/disable-cors-on-download
php: disable CORS on download
2023-06-26 15:40:27 +05:00
33363f6144 fixed: generating key 2023-06-26 13:01:03 +03:00
da8bdca022 ruby: reload after click on edit or view in upload window 2023-06-26 12:52:17 +03:00
c4eccc5ee8 Merge pull request #398 from ONLYOFFICE/hotfix/php-sample-key-fix
php: undefined "sample" key fix
2023-06-26 14:24:02 +05:00
ab13745cf6 Merge pull request #399 from ONLYOFFICE/hotfix/referenceData
Hotfix/reference data
2023-06-26 14:23:09 +05:00
97f07e4275 ruby: fixed directUrl property 2023-06-26 12:20:07 +03:00
7c3e250797 php: undefined "sample" key fix 2023-06-26 11:40:57 +03:00
32ab794f11 python: fixed directUrl property 2023-06-26 11:23:03 +03:00
800ef84f84 csharp: fixed directUrl property 2023-06-26 11:18:52 +03:00
a7e4036667 php: fixed directUrl property 2023-06-26 11:11:52 +03:00
4f589a7394 java: fixed directUrl property 2023-06-26 11:05:01 +03:00
a3abb58d72 java-spring: fixed directUrl property 2023-06-26 10:21:21 +03:00
17536df8e5 csharp-mvc: fixed directUrl property 2023-06-26 10:08:44 +03:00
2e8a483a0c csharp-mvc: fix error with convert response (d9a79e20d7) 2023-06-26 11:47:38 +05:00
a0aa7b4fd0 php: disable CORS on download 2023-06-23 13:38:06 +03:00
8b720beffa Merge pull request #397 from ONLYOFFICE/hotfix/java-spring
java-spring: fixed bug with update external links reference data
2023-06-23 11:36:50 +05:00
a1c286cbaa java-spring: fixed bug with update external links reference data 2023-06-23 09:05:26 +03:00
fc377b967d Merge pull request #395 from ONLYOFFICE/hotfix/disable-cors-for-download
python: disable CORS in download
2023-06-22 17:43:07 +05:00
b2de5eff4c Merge pull request #394 from ONLYOFFICE/hotfix/python-reload-file-list
python: reload file list after start of editing
2023-06-22 17:42:31 +05:00
02439f3699 Merge pull request #393 from ONLYOFFICE/hotfix/php-fixes-release-740
Hotfix/php fixes for release 7.4.0
2023-06-22 17:41:28 +05:00
2429f21a84 python: disable CORS in download 2023-06-22 12:13:36 +03:00
aa0a4b5400 php: encoded space used 2023-06-22 11:48:51 +03:00
a28300848b python: reload file list after start of editing 2023-06-22 11:22:56 +03:00
fec0e87218 php: fix warnings in editor 2023-06-22 10:46:36 +03:00
efbace1e8b php: correct name of file when downloading 2023-06-22 10:30:37 +03:00
35e479355a php: convert warning fix 2023-06-22 10:22:17 +03:00
32c91b9016 Merge pull request #392 from ONLYOFFICE/hotfix/users-permissions-fix
java: null instead of empty lists
2023-06-21 16:01:01 +05:00
183d165c00 java: null instead of empty lists 2023-06-21 12:40:35 +03:00
a996f2c3c3 Merge pull request #390 from ONLYOFFICE/hotfix/content-disposition-for-download-encode
python: filename encoding for content-disposition header
2023-06-21 13:19:06 +05:00
782243eb86 Merge pull request #391 from ONLYOFFICE/hotfix/java-spring
Hotfix/java spring
2023-06-21 13:18:15 +05:00
f058d68126 fix bug with switching from view to edit 2023-06-21 11:11:33 +03:00
a8f07fce4d fix bug with upload file size more 1MB 2023-06-21 11:11:28 +03:00
025bd1068d fix bug with file conversion 2023-06-21 11:11:17 +03:00
75b22614cf refresh licenses 2023-06-21 12:29:59 +05:00
6cb15697ab Merge pull request #388 from ONLYOFFICE/feature/ruby-normalize-dependencies
ruby: pin and add new dependencies
2023-06-21 12:12:22 +05:00
1da93ce071 python: filename encoding for content-disposition header 2023-06-21 09:37:26 +03:00
837e34de37 Merge pull request #389 from ONLYOFFICE/hotfix/convert-status-code-type
ruby: fix conversion service status type
2023-06-20 13:52:27 +05:00
20c4ec1b78 ruby: fix conversion service status type 2023-06-20 11:30:40 +03:00
39bab74422 Merge pull request #383 from ONLYOFFICE/feature/formats
Feature/formats
2023-06-19 11:47:19 +05:00
665ab6a77d formats to changelog 2023-06-19 11:47:03 +05:00
5663227c55 update formats repo 2023-06-19 11:45:26 +05:00
42ac89e5e5 Merge pull request #370 from ONLYOFFICE/hotfix/headers-charset-on-upload-convert
java: upload and convert fix
2023-06-19 11:33:09 +05:00
c95499536d ruby: add lint recipe to Makefile 2023-06-14 10:38:35 +04:00
5659756c07 ruby: add install recipe to Makefile 2023-06-14 10:38:35 +04:00
038b3b3049 ruby: add help recipe to Makefile 2023-06-14 10:38:35 +04:00
6b555c4d0d ruby: add sorbet as a type-checker dependency 2023-06-14 10:38:27 +04:00
44d49bed62 ruby: add rubocop as a lint dependency 2023-06-14 10:23:02 +04:00
517b130db6 ruby: pin ruby version 2023-06-09 12:13:40 +04:00
0ff435b9bd ruby: pin dependency versions and add support for the arm64 platform 2023-06-09 12:13:14 +04:00
56bc372140 Merge remote-tracking branch 'remotes/origin/release/v7.4.0' into develop
# Conflicts:
#	web/documentserver-example/nodejs/helpers/docManager.js
2023-06-07 18:57:00 +05:00
0068b6d87d Merge pull request #381 from ONLYOFFICE/feature/getServerHost
Fix get server host function
2023-06-07 18:44:17 +05:00
4679804774 Merge pull request #386 from ONLYOFFICE/hotfix/fix-php-readme
php: composer installation added to readme
2023-06-07 16:30:48 +05:00
d03f74087c php: composer installation added to readme 2023-06-07 16:29:57 +05:00
e3a088ccaf nodejs: fix undefined header 2023-06-07 13:29:45 +05:00
5865fedbe7 java: upload and convert fix 2023-06-05 10:19:58 +03:00
68390aa26c php: lossy-edit to getEditExtensions() 2023-06-02 12:31:41 +03:00
744e5203cb nodejs: lossy-edit to getEditExtensions() 2023-06-02 12:29:44 +03:00
7df7af3f47 nodejs, php: update submodule document-formats 2023-06-02 12:21:00 +03:00
bf40cd1249 Merge branch 'develop' into feature/formats 2023-06-02 11:01:19 +03:00
f3cb5adb22 nodejs: fix (668df46ec3) 2023-06-02 11:00:30 +03:00
c8d44199c2 php: fix lint 2023-06-01 16:21:36 +03:00
12bcc0009b nodejs: disable eslint for import onlyoffice-docs-formats.json 2023-06-01 16:14:12 +03:00
be1ea81f82 Merge branch 'develop' into feature/formats 2023-06-01 15:53:41 +03:00
668df46ec3 nodejs: fix(dd3255779f) 2023-06-01 15:53:07 +03:00
43905695e0 nodejs: fix lint 2023-06-01 14:50:06 +03:00
4a49becea1 php: revert composer.lock 2023-05-31 15:34:42 +03:00
c91d3a24b9 update submodule document-formats 2023-05-31 14:39:48 +03:00
d6a4984b84 Merge pull request #382 from ONLYOFFICE/feature/restore-version
Feature/restore version
2023-05-22 15:45:19 +05:00
f1dae06746 changelog: restore file 2023-05-22 15:44:45 +05:00
3cf3bcf2c8 Merge remote-tracking branch 'remotes/origin/develop' into feature/restore-version 2023-05-22 15:44:11 +05:00
aa6e19ebaa Merge pull request #372 from ONLYOFFICE/dependabot/bundler/web/documentserver-example/ruby/nokogiri-1.14.3
build(deps): bump nokogiri from 1.13.9 to 1.14.3 in /web/documentserver-example/ruby
2023-05-22 14:01:04 +05:00
24a26fd530 Correct spelling mistake 2023-05-19 12:57:10 +00:00
a5f91bc14f Fix get server host function 2023-05-19 09:07:38 +00:00
d7034c72c9 Merge pull request #379 from ONLYOFFICE/feature/remove-row-without-reload
nodejs: remove row without reload
2023-05-18 18:12:46 +05:00
c0437b152f remove row to changelog 2023-05-18 18:10:44 +05:00
b72b2c6619 Merge branch 'develop' into feature/remove-row-without-reload
# Conflicts:
#	web/documentserver-example/nodejs/public/javascripts/jscript.js
2023-05-18 13:34:34 +03:00
c516631360 nodejs: fix remove for IE 2023-05-18 13:31:50 +03:00
5cc8d7c094 Merge pull request #380 from ONLYOFFICE/feature/get-history-by-request
nodejs: get history data by request
2023-05-18 11:23:10 +05:00
5f4764060c changelog: history request 2023-05-18 11:22:17 +05:00
44832008a8 nodejs: reload the page if deleted line is the last one 2023-05-17 13:24:28 +03:00
d86e737493 nodejs: fix properties for IE, historyObject used in requestRestore 2023-05-17 12:59:55 +03:00
07a1e3101b Merge branch 'feature/get-history-by-request' into feature/restore-version 2023-05-17 12:55:51 +03:00
1ebfe49916 nodejs: fix properties for IE 2023-05-17 12:54:15 +03:00
b1d6f8d652 Merge branch 'feature/get-history-by-request' into feature/restore-version 2023-05-17 12:46:15 +03:00
8f0edf90e6 nodejs: request in onRequestHistory only 2023-05-17 12:43:33 +03:00
7c77389550 build(deps): bump nokogiri in /web/documentserver-example/ruby
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.9 to 1.14.3.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.9...v1.14.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-17 12:42:09 +05:00
637731a4d7 Merge pull request #373 from ONLYOFFICE/refactor/collect-params-for-url
Refactor/collect params for url
2023-05-17 12:34:35 +05:00
6fc98a025b Merge branch 'feature/get-history-by-request' into feature/restore-version
# Conflicts:
#	web/documentserver-example/nodejs/app.js
2023-05-12 13:03:31 +03:00
f123cbcce3 nodejs: handler for restore file version 2023-05-12 13:00:48 +03:00
11f166525e nodejs: onRequestRestore method on front 2023-05-12 12:56:24 +03:00
68db498dfd nodejs: get history data by request 2023-05-12 11:12:32 +03:00
f914afcc53 nodejs: remove row without reload 2023-05-11 15:14:07 +03:00
8dcf75f3fb nodejs: get history data by request 2023-05-11 14:06:48 +03:00
3d9e091882 Merge pull request #378 from ONLYOFFICE/hotfix/disable-rule-for-old-nodejs
nodejs: hasOwnProperty() used instead of hasOwn() for NodeJS v.14
2023-05-10 17:36:27 +05:00
a9ca4b3272 Merge remote-tracking branch 'remotes/origin/release/v7.4.0' into develop 2023-05-10 17:32:40 +05:00
a722b04226 Merge pull request #375 from ONLYOFFICE/feature/edited-chinese
edited language name zh
2023-05-10 17:29:49 +05:00
9a1110a56e ruby: edited language name zh 2023-05-10 17:28:40 +05:00
707122013f python: edited language name zh 2023-05-10 17:28:39 +05:00
f9ed5edf89 php: edited language name zh 2023-05-10 17:28:39 +05:00
dbf6766897 java-spring: edited language name zh 2023-05-10 17:28:39 +05:00
a60c594505 java: edited language name zh 2023-05-10 17:28:38 +05:00
2d0e6c0d3f csharp-mvc: edited language name zh 2023-05-10 17:28:38 +05:00
63e7461995 csharp: edited language name zh 2023-05-10 17:28:38 +05:00
d2491ae6b7 edited language name zh 2023-05-10 17:28:38 +05:00
35798a7916 nodejs: hasOwnProperty() used instead of hasOwn() for NodeJS v.14 2023-05-10 11:30:26 +03:00
f7000b51a7 Merge branch 'release/v7.4.0' into develop
# Conflicts:
#	web/documentserver-example/nodejs/app.js
#	web/documentserver-example/nodejs/helpers/users.js
2023-05-10 10:55:24 +05:00
7e36939392 Merge pull request #376 from ONLYOFFICE/feature/region-protect
setUsers for region protection
2023-05-03 17:52:40 +05:00
afec51b296 nodejs: setUsers for region protection 2023-05-03 13:08:11 +05:00
66faaab294 Merge branch 'develop' into refactor/collect-params-for-url
# Conflicts:
#	web/documentserver-example/nodejs/views/index.ejs
#	web/documentserver-example/nodejs/views/wopiIndex.ejs
2023-04-28 11:20:25 +03:00
7be2a5a507 nodejs: remove serverUrl 2023-04-27 16:45:22 +03:00
8cf26de5e2 Merge remote-tracking branch 'remotes/origin/release/v7.4.0' into develop 2023-04-27 15:15:15 +03:00
016611ba52 Merge pull request #374 from ONLYOFFICE/hotfix/nodejs-wopi-jquery-fix
nodejs: jquery fix in WOPI-template
2023-04-27 15:14:42 +03:00
73d1011e8a nodejs: jquery fix in WOPI-template 2023-04-27 15:14:00 +03:00
f2a11a5894 nodejs: WOPI-page fix 2023-04-27 14:54:36 +03:00
c6043d4428 nodejs: fix tabulation 2023-04-27 11:36:04 +03:00
c37ba28ad3 php: added work with onlyoffice-docs-formats.json 2023-04-27 11:33:57 +03:00
53f810fc54 php: added module document-formats 2023-04-27 10:48:48 +03:00
a55875ae1e php: added module document-templates 2023-04-27 10:46:33 +03:00
707a634823 php: removed module document-templates 2023-04-27 10:42:31 +03:00
b511fa872a nodejs: added module document-formats 2023-04-27 10:36:56 +03:00
4a2e7d9a9e nodejs: added module document-templates 2023-04-27 10:32:49 +03:00
e4d5de2c0e removed module document-templates 2023-04-27 10:24:32 +03:00
50dca2e2c0 php: added work with onlyoffice-docs-formats.json 2023-04-26 14:58:00 +03:00
893303c27f nodejs: added work with onlyoffice-docs-formats.json 2023-04-26 11:48:38 +03:00
b543392c62 nodejs: server url to link in logo 2023-04-26 09:22:39 +03:00
adf52c756e nodejs: fix url-params + IE fix 2023-04-21 12:55:02 +03:00
693cc5a951 Merge pull request #369 from ONLYOFFICE/refactor/format-by-linter-nodejs
Refactor/format by linter nodejs
2023-04-21 09:40:20 +05:00
ff9ba7fbf1 Merge pull request #371 from ONLYOFFICE/hotfix/editor-warning-fix
php: editor warnings fix
2023-04-20 17:06:59 +05:00
c2b87959a2 nodejs: collectParams() instead of reload() + input text added 2023-04-19 11:14:45 +03:00
18ee7776ef nodejs: radio elements + "name" attribute instead of "data-param" 2023-04-19 10:06:29 +03:00
c99efda67a nodejs: open window in new tab 2023-04-19 09:25:49 +03:00
d65f970255 nodejs: collectParams() method added 2023-04-18 14:45:31 +03:00
f5442a8a89 nodejs: url params for collectable elements 2023-04-18 14:44:04 +03:00
e347ea36ce nodejs: "params" in links deleted, added class for actions 2023-04-18 11:50:54 +03:00
f0651dabf0 php: editor warnings fix 2023-04-10 12:31:04 +03:00
ccf85c1c0f nodejs: "no-plusplus" - rule excluded for loops 2023-04-05 15:16:33 +03:00
6ea35bf55c Merge branch 'refactor/format-by-linter-nodejs' of https://github.com/ONLYOFFICE/document-server-integration into refactor/format-by-linter-nodejs 2023-04-05 15:05:05 +03:00
f6afde346a nodejs: await in loops excluded from check 2023-04-05 15:04:50 +03:00
ce4074bcce nodejs: change order 2023-04-05 11:46:06 +05:00
5697b58aa2 nodejs: radix parameters for parseInt() 2023-04-04 12:57:32 +03:00
d5e6301211 nodejs: no restricted syntax 2023-04-04 12:50:45 +03:00
9048082cb7 nodejs: no shadow vars 2023-04-04 11:05:29 +03:00
56e46466b2 nodejs: useless rules deleted, autofixed spaces before parenthesis, arrow functions syntax, and comma after arguments added 2023-04-03 17:05:26 +03:00
fa9731ab57 nodejs: no unnamed functions 2023-04-03 16:44:48 +03:00
c2ba46ce85 nodejs: no await in loops 2023-04-03 15:25:43 +03:00
4c5780f1d6 nodejs: default param last 2023-04-03 15:20:26 +03:00
0419611a62 nodejs: no prototype builtins 2023-04-03 15:17:57 +03:00
bcc1011ddd nodejs: no constant condition 2023-04-03 15:04:57 +03:00
91a4fe1e52 nodejs: no throw literal 2023-04-03 12:51:30 +03:00
21fed8a81e nodejs: off unused airbnb-base rules 2023-03-31 14:29:59 +03:00
f2fc63c24f nodejs: default cases required 2023-03-31 14:03:14 +03:00
521608fa15 nodejs: no unused else blocks 2023-03-31 13:55:35 +03:00
e16ad4e53d nodejs: define vars is required 2023-03-31 13:48:11 +03:00
7205e383c8 nodejs: no new RegExp() 2023-03-31 13:40:47 +03:00
9bf317b3e0 nodejs: camelCase used 2023-03-31 13:38:38 +03:00
ac668a41c5 nodejs: declaration of methods before use 2023-03-31 13:32:20 +03:00
606f4255dc nodejs: no useless return statements + ';' in the end 2023-03-31 13:03:15 +03:00
22a64dd932 nodejs: no mixed tabs 2023-03-31 12:34:05 +03:00
dd3255779f nodejs: required the use of === and !== 2023-03-31 12:30:04 +03:00
89c7e63ab8 nodejs: object curly spacing 2023-03-31 11:04:35 +03:00
447c604fe9 nodejs: no multiple empty lines 2023-03-31 10:54:40 +03:00
dff9602852 nodejs: require correct order 2023-03-31 10:00:32 +03:00
f4d7915dd6 nodejs: 'use strict' is unnecessary inside of modules 2023-03-31 09:35:57 +03:00
01204d544e nodejs: const declarations for variables that are never reassigned after declared 2023-03-30 17:03:40 +03:00
a06aa8c8b3 nodejs: max-length of lines - 120 2023-03-30 16:31:39 +03:00
7977427038 nodejs: no unused variables 2023-03-30 13:47:33 +03:00
0b8d0ed10a nodejs: disallowed spacing around embedded expressions of template strings 2023-03-30 12:33:52 +03:00
efec141039 nodejs: disallowed padding within blocks 2023-03-30 12:29:39 +03:00
6736555ff3 nodejs: constructor names to begin with a capital letter 2023-03-30 12:20:50 +03:00
d94fe30a3e nodejs: fix no nested ternary expressions 2023-03-30 12:12:04 +03:00
3079320534 nodejs: no multi spaces 2023-03-30 10:57:00 +03:00
4f3af51e54 nodejs: newline after each call in a method chain 2023-03-30 10:52:48 +03:00
d19c81c944 nodejs: EOL last 2023-03-30 10:48:34 +03:00
bc3cbbbb82 nodejs: spacing around infix operators 2023-03-30 10:47:14 +03:00
8ee3ddc925 nodejs: space before the opening parenthesis in control statements 2023-03-30 10:44:00 +03:00
173c05dbf3 nodejs: consistent indentation (2 spaces) 2023-03-30 10:41:27 +03:00
b13c548c4d nodejs: 1 space before comment text 2023-03-30 10:30:18 +03:00
ef8237adfd nodejs: disallowed else blocks after return statements in if statements 2023-03-30 10:24:06 +03:00
c80379da31 nodejs: braces for multi-line blocks with if and else 2023-03-30 10:22:04 +03:00
a54c43c0c2 nodejs: braces with all multi-line blocks 2023-03-30 10:19:25 +03:00
5e524aa148 nodejs: disallow bitwise operators 2023-03-30 10:12:41 +03:00
e84ee9e01b nodejs: no unneeded ternary operators 2023-03-30 09:32:01 +03:00
27ceb1e6c6 nodejs: no nested ternary expressions 2023-03-29 17:23:50 +03:00
508b0d913c nodejs: disallow the unary operators ++ and -- 2023-03-29 16:35:32 +03:00
5999b070dc nodejs: dot notation whenever possible 2023-03-29 15:43:55 +03:00
3ed13f3975 nodejs: braces around arrow function bodies 2023-03-29 13:33:51 +03:00
1789f7c9fd nodejs: parentheses around arrow function arguments 2023-03-29 13:31:33 +03:00
a05ea11dd7 nodejs: spacing before and after the arrow in arrow functions 2023-03-29 13:29:34 +03:00
c6dd46a004 nodejs: linebreaks inside function parentheses if any of the parameters/arguments have a line break between them 2023-03-29 13:27:07 +03:00
bf04979c31 nodejs: reassigning function parameters disallowed 2023-03-29 13:20:33 +03:00
e9274b7303 nodejs: spacing before blocks 2023-03-29 12:52:36 +03:00
03022c5b45 nodejs: spacing before function definition opening parenthesis 2023-03-29 12:50:35 +03:00
ce4ccdd5b0 nodejs: rest parameters instead of arguments 2023-03-29 12:32:28 +03:00
07eba65458 nodejs: used named function expressions instead of function declarations 2023-03-29 10:56:17 +03:00
072b082240 nodejs: require using arrow functions for callbacks 2023-03-29 09:49:21 +03:00
c664bc4ee9 nodejs: template literals instead of string concatenation 2023-03-28 17:38:41 +03:00
f113d7eeb1 nodejs: require destructuring from arrays and objects 2023-03-28 16:52:27 +03:00
9409bf0785 nodejs: quote only properties that are invalid identifiers 2023-03-28 15:41:02 +03:00
d51e724130 nodejs: method and property shorthand syntax for object literals 2023-03-28 15:35:27 +03:00
9489b4dcde nodejs: variables with block scope used 2023-03-28 14:46:09 +03:00
d9c139a42b nodejs: const declarations for variables that are never reassigned after declared 2023-03-28 14:08:15 +03:00
534f1d8284 nodejs: single quotes used 2023-03-28 14:02:31 +03:00
f177af8791 nodejs: added max-length (120) to ruleset 2023-03-28 13:57:52 +03:00
326 changed files with 14328 additions and 5977 deletions

View File

@ -21,11 +21,9 @@ jobs:
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/csharp-mvc
mkdir -p ./deploy/'DotNet (Csharp MVN) Example'
mkdir -p ./deploy/'DotNet (Csharp MVC) Example'
rsync -av --exclude='deploy' ./ ./deploy/'DotNet (Csharp MVC) Example'
cd ./deploy/'DotNet (Csharp MVC) Example'/assets
rm -rf ./.git/
rm .git
rm -rf ./deploy/'DotNet (Csharp MVC) Example'/assets/.git
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:

View File

@ -18,14 +18,11 @@ jobs:
- name: Build Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/csharp
mkdir -p ./deploy/'DotNet (Csharp) Example'
rsync -av --exclude='deploy' ./ ./deploy/'DotNet (Csharp) Example'
cd ./deploy/'DotNet (Csharp) Example'/assets
rm -rf ./.git/
rm .git
rm -rf ./deploy/'DotNet (Csharp) Example'/assets/.git
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:

View File

@ -18,14 +18,12 @@ jobs:
- name: Build Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/java
mkdir -p ./deploy/'Java Example'
rsync -av --exclude='deploy' ./ ./deploy/'Java Example'
cd ./deploy/'Java Example'/src/main/resources/assets
rm -rf ./.git/
rm .git
rm -rf ./deploy/'Java Example'/src/main/resources/assets/document-formats/.git
rm -rf ./deploy/'Java Example'/src/main/resources/assets/document-templates/.git
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:

View File

@ -18,14 +18,12 @@ jobs:
- name: Build Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/nodejs
mkdir -p ./deploy/'Node.js Example'
rsync -av --exclude='deploy' ./ ./deploy/'Node.js Example'
cd ./deploy/'Node.js Example'/public/assets
rm -rf ./.git/
rm .git
rm -rf ./deploy/'Node.js Example'/public/assets/document-formats/.git
rm -rf ./deploy/'Node.js Example'/public/assets/document-templates/.git
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:

View File

@ -18,14 +18,12 @@ jobs:
- name: Build Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/php
mkdir -p ./deploy/'PHP Example'
rsync -av --exclude='deploy' ./ ./deploy/'PHP Example'
cd ./deploy/'PHP Example'/assets
rm -rf ./.git/
rm .git
rm -rf ./deploy/'PHP Example'/assets/document-formats/.git
rm -rf ./deploy/'PHP Example'/assets/document-templates/.git
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:

View File

@ -18,14 +18,12 @@ jobs:
- name: Build Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/python
mkdir -p ./deploy/'Python Example'
rsync -av --exclude='deploy' ./ ./deploy/'Python Example'
cd ./deploy/'Python Example'/assets
rm -rf ./.git/
rm .git
rm -rf ./deploy/'Python Example'/assets/document-formats/.git
rm -rf ./deploy/'Python Example'/assets/document-templates/.git
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:

View File

@ -18,14 +18,12 @@ jobs:
- name: Build Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/ruby
mkdir -p ./deploy/'Ruby Example'
rsync -av --exclude='deploy' ./ ./deploy/'Ruby Example'
cd ./deploy/'Ruby Example'/public/assets
rm -rf ./.git/
rm .git
rm -rf ./deploy/'Ruby Example'/public/assets/document-formats/.git
rm -rf ./deploy/'Ruby Example'/public/assets/document-templates/.git
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:

View File

@ -23,9 +23,8 @@ jobs:
cd ./web/documentserver-example/java-spring
mkdir -p ./deploy/'Java Spring Example'
rsync -av --exclude='deploy' ./ ./deploy/'Java Spring Example'
cd ./deploy/'Java Spring Example'/src/main/resources/assets
rm -rf ./.git/
rm .git
rm -rf ./deploy/'Java Spring Example'/src/main/resources/assets/document-formats/.git
rm -rf ./deploy/'Java Spring Example'/src/main/resources/assets/document-templates/.git
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:

View File

@ -25,7 +25,5 @@ jobs:
php-version: '8.2'
tools: cs2pr, phpcs
- name: Run phpcs
run: |
phpcs --version
phpcs -q --extensions=php,module,inc,install,test,profile,theme,info --ignore=node_modules,bower_components,vendor,css,js,lib --standard=./ruleset.xml ./
- name: Lint
run: phpcs src index.php

View File

@ -32,9 +32,9 @@ jobs:
- name: Lint Flake8
run: |
flake8 ./**/*.py --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 ./**/*.py --count --max-complexity=10 --max-line-length=79 --statistics
flake8 --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 --count --max-complexity=10 --max-line-length=79 --statistics
- name: Lint Pylint
run: |
pylint ./**/*.py
find . -type f -name "*.py" | xargs pylint

View File

@ -16,16 +16,22 @@ jobs:
run:
working-directory: ./web/documentserver-example/ruby
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.0'
bundler-cache: true
- name: Install dependencies
run: |
bundle install
- name: Rubocop
run: |
gem install rubocop
rubocop
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2.2'
- name: Update Submodules
run: |
git submodule update --init --recursive
- name: Install Dependencies
run: |
bundle update
- name: Rubocop
run: |
bundle exec rubocop

View File

@ -13,8 +13,10 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Zip
run: sudo apt-get install zip
- name: Clone Submodules
run: |
cd ${{ github.workspace }}
git submodule update --init --recursive
- name: Get Info
run: |
echo "version=$(grep -Eo '[0-9]+(\.[0-9]+)+' CHANGELOG.md | head -n 1)" >> $GITHUB_OUTPUT
@ -25,91 +27,66 @@ jobs:
- name: Build Csharp MVC Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/csharp-mvc
mkdir -p ./'DotNet (Csharp MVC) Example'
rsync -av --exclude='DotNet (Csharp MVC) Example' ./ ./'DotNet (Csharp MVC) Example'
cd ./'DotNet (Csharp MVC) Example'/assets
rm -rf ./.git/
rm .git
rm -rf .git
- name: Build Csharp Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/csharp
mkdir -p ./'DotNet (Csharp) Example'
rsync -av --exclude='DotNet (Csharp) Example' ./ ./'DotNet (Csharp) Example'
cd ./'DotNet (Csharp) Example'/assets
rm -rf ./.git/
rm .git
rm -rf ./'DotNet (Csharp) Example'/assets/.git
- name: Build Java Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/java
mkdir -p ./'Java Example'
rsync -av --exclude='Java Example' ./ ./'Java Example'
cd ./'Java Example'/src/main/resources/assets
rm -rf ./.git/
rm .git
rm -rf ./'Java Example'/src/main/resources/assets/document-formats/.git
rm -rf ./'Java Example'/src/main/resources/assets/document-templates/.git
- name: Build Nodejs Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/nodejs
mkdir -p ./'Node.js Example'
rsync -av --exclude='Node.js Example' ./ ./'Node.js Example'
cd ./'Node.js Example'/public/assets
rm -rf ./.git/
rm .git
rm -rf ./'Node.js Example'/public/assets/document-formats/.git
rm -rf ./'Node.js Example'/public/assets/document-templates/.git
- name: Build PHP Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/php
mkdir -p ./'PHP Example'
rsync -av --exclude='PHP Example' ./ ./'PHP Example'
cd ./'PHP Example'/assets
rm -rf ./.git/
rm .git
rm -rf ./'PHP Example'/assets/document-formats/.git
rm -rf ./'PHP Example'/assets/document-templates/.git
- name: Build Python Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/python
mkdir -p ./'Python Example'
rsync -av --exclude='Python Example' ./ ./'Python Example'
cd ./'Python Example'/assets
rm -rf ./.git/
rm .git
rm -rf ./'Python Example'/assets/document-formats/.git
rm -rf ./'Python Example'/assets/document-templates/.git
- name: Build Ruby Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/ruby
mkdir -p ./'Ruby Example'
rsync -av --exclude='Ruby Example' ./ ./'Ruby Example'
cd ./'Ruby Example'/public/assets
rm -rf ./.git/
rm .git
rm -rf ./'Ruby Example'/public/assets/document-formats/.git
rm -rf ./'Ruby Example'/public/assets/document-templates/.git
- name: Build Spring Artifact
run: |
cd ${{ github.workspace }}
cwd=$(pwd)
git submodule update --init --recursive
cd ./web/documentserver-example/java-spring
mkdir -p ./'Java Spring Example'
rsync -av --exclude='Java Spring Example' ./ ./'Java Spring Example'
cd ./'Java Spring Example'/src/main/resources/assets
rm -rf ./.git/
rm .git
rm -rf ./'Java Spring Example'/src/main/resources/assets/document-formats/.git
rm -rf ./'Java Spring Example'/src/main/resources/assets/document-templates/.git
- name: Pack Artifacts
run: |
cd ${{ github.workspace }}/web/documentserver-example/csharp-mvc

5
.gitignore vendored
View File

@ -22,8 +22,3 @@
/web/documentserver-example/csharp/packages
/web/documentserver-example/csharp-mvc/packages
/web/documentserver-example/java-spring/documents/
/web/documentserver-example/ruby/.bundle
/web/documentserver-example/ruby/db/*.sqlite3
/web/documentserver-example/ruby/db/*.sqlite3-journal
/web/documentserver-example/ruby/log/*
/web/documentserver-example/ruby/tmp

56
.gitmodules vendored
View File

@ -1,19 +1,3 @@
[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
@ -22,11 +6,43 @@
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
[submodule "web/documentserver-example/nodejs/public/assets/document-templates"]
path = web/documentserver-example/nodejs/public/assets/document-templates
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/java-spring/src/main/resources/assets"]
path = web/documentserver-example/java-spring/src/main/resources/assets
[submodule "web/documentserver-example/nodejs/public/assets/document-formats"]
path = web/documentserver-example/nodejs/public/assets/document-formats
url = https://github.com/ONLYOFFICE/document-formats
branch = master
[submodule "web/documentserver-example/php/assets/document-templates"]
path = web/documentserver-example/php/assets/document-templates
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/php/assets/document-formats"]
path = web/documentserver-example/php/assets/document-formats
url = https://github.com/ONLYOFFICE/document-formats
branch = master
[submodule "web/documentserver-example/python/assets/document-templates"]
path = web/documentserver-example/python/assets/document-templates
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/java/src/main/resources/assets/document-templates"]
path = web/documentserver-example/java/src/main/resources/assets/document-templates
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/ruby/assets/document-templates"]
path = web/documentserver-example/ruby/assets/document-templates
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/java-spring/src/main/resources/assets/document-templates"]
path = web/documentserver-example/java-spring/src/main/resources/assets/document-templates
url = https://github.com/ONLYOFFICE/document-templates
branch = main/en
[submodule "web/documentserver-example/python/assets/document-formats"]
path = web/documentserver-example/python/assets/document-formats
url = https://github.com/ONLYOFFICE/document-formats
branch = master
[submodule "web/documentserver-example/ruby/assets/document-formats"]
path = web/documentserver-example/ruby/assets/document-formats
url = https://github.com/ONLYOFFICE/document-formats
branch = master

View File

@ -3,10 +3,6 @@ Document Server integration example uses code from the following 3rd party proje
web/documentserver-example/csharp
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -19,14 +15,26 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
License File: jQuery.UI.license
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
License: MIT
License File: JWT.license
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
License: MIT
License File: Newtonsoft.Json.license
web/documentserver-example/csharp-mvc
@ -34,10 +42,6 @@ Entity Framework - Entity Framework is an object-relational mapper that enables
License: MICROSOFT SOFTWARE SUPPLEMENTAL TERMS, MICROSOFT SOFTWARE LICENSE TERMS
License File: EntityFramework.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -50,19 +54,27 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
License File: jQuery.UI.license
JWT - JWT (JSON Web Token) Implementation for .NET (Public Domain) (https://github.com/jwt-dotnet/jwt/)
License: MIT
License File: JWT.license
Microsoft.Web.Infrastructure - This package contains the Microsoft.Web.Infrastructure assembly that lets you dynamically register HTTP modules at run time. (https://www.microsoft.com/web/webpi/eula/aspnetmvc3update-eula.htm)
License: MS-EULA License
License File: Microsoft.Web.Infrastructure.license
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://licenses.nuget.org/MIT)
Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET (https://github.com/JamesNK/Newtonsoft.Json)
License: MIT
License File: Newtonsoft.Json.license
@ -73,10 +85,6 @@ License File: WebGrease.license
web/documentserver-example/java
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -89,9 +97,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
@ -104,9 +116,17 @@ License File: prime-jwt.license
web/documentserver-example/java-spring
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
License: Apache 2.0
License File: gson.license
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
License: MPL 2.0 or EPL 1.0
License File: h2database.license
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
License: Apache 2.0
License File: jackson-databind.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
@ -120,14 +140,30 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
License File: jQuery.UI.license
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
License: Apache 2.0
License File: JSON.simple.license
Project Lombok - Project Lombok is a java library that automatically plugs into your editor and build tools. (https://mvnrepository.com/artifact/org.projectlombok/lombok).
License: MIT
License File lombok.license
ModelMapper - ModelMapper is an intelligent object mapping library that automatically maps objects to each other. (https://github.com/modelmapper/modelmapper)
License: Apache 2.0
License File modelmapper.license
Prime JWT - is intended to be fast and easy to use. Prime JWT has a single external dependency on Jackson. (https://github.com/ws-apps/prime-jwt/blob/master/LICENSE)
License: Apache 2.0
License File: prime-jwt.license
@ -148,22 +184,6 @@ Spring Data JPA - Persist data in SQL stores with Java Persistence API using Spr
License: Apache 2.0
License File: spring-data-jpa.license
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
License: MPL 2.0 or EPL 1.0
License File: h2database.license
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
License: Apache 2.0
License File: JSON.simple.license
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
License: Apache 2.0
License File: gson.license
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
License: Apache 2.0
License File: jackson-databind.license
web/documentserver-example/nodejs
@ -199,10 +219,6 @@ he - a robust HTML entity encoder/decoder written in JavaScript. (htt
License: MIT
License File: he.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -215,9 +231,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
@ -248,11 +268,8 @@ License: MIT
License File: urllib.license
web/documentserver-example/php
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
web/documentserver-example/php
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
@ -266,9 +283,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
@ -282,16 +303,32 @@ PHP_CodeSniffer - PHP_CodeSniffer is a set of two PHP scripts; the main phpcs sc
License: BSD-3-Clause
License File: PHP_CodeSniffer.license
PHPUnit - The PHP Unit Testing framework. (https://github.com/sebastianbergmann/phpunit/blob/main/LICENSE)
License: BSD 3-Clause
License File: phpunit.license
property-access - Provides functions to read and write from/to an object or array using a simple string notation. (https://github.com/symfony/property-access/blob/6.3/LICENSE)
License: MIT
License File: property-access.license
serializer - Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON. (https://github.com/symfony/serializer/blob/6.3/LICENSE)
License: MIT
License File: serializer.license
web/documentserver-example/python
django-stubs - PEP-484 stubs for Django. (https://github.com/typeddjango/django-stubs/blob/master/LICENSE.md)
License: MIT
License File: django-stubs.license
Django - Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out. (https://github.com/django/django/blob/main/LICENSE)
License: BSD-3-Clause
License File: Django.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
flake8 - flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code. (https://github.com/PyCQA/flake8/blob/main/LICENSE)
License: MIT
License File: jQuery.license
License File: flake8.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
@ -305,57 +342,26 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
License File: jQuery.UI.license
PyJWT - A Python implementation of RFC 7519. (https://github.com/jpadilla/pyjwt/blob/master/LICENSE)
License: MIT
License File: PyJWT.license
python-magic - python-magic is a Python interface to the libmagic file type identification library. (https://github.com/ahupp/python-magic/blob/master/LICENSE)
License: MIT
License File: python-magic.license
requests - Requests allows you to send HTTP/1.1 requests extremely easily. Theres no need to manually add query strings to your URLs, or to form-encode your PUT & POST data — but nowadays, just use the json method! (https://github.com/psf/requests/blob/main/LICENSE)
License: Apache 2.0
License File: requests.license
web/documentserver-example/python
Django - Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out. (https://github.com/django/django/blob/main/LICENSE)
License: BSD-3-Clause
License File: Django.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
jQuery.FileUpload - File Upload widget with multiple file selection, drag&drop support, progress bar, validation and preview images, audio and video for jQuery. Supports cross-domain, chunked and resumable file uploads. Works with any server-side platform (Google App Engine, PHP, Python, Ruby on Rails, Java, etc.) that supports standard HTML form file uploads. (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt)
License: MIT
License File: jQuery.FileUpload.license
jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https://github.com/blueimp/jQuery-File-Upload/blob/master/LICENSE.txt)
License: MIT
License File: jQuery.iframe-transport.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
License File: jQuery.UI.license
msgspec - A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML. (https://github.com/jcrist/msgspec/blob/0.18.1/LICENSE)
License: BSD 3-Clause
License File: msgspec.license
mypy - Optional static typing for Python. (https://github.com/python/mypy/blob/master/LICENSE)
License: MIT
License File: mypy.license
PyJWT - A Python implementation of RFC 7519. (https://github.com/jpadilla/pyjwt/blob/master/LICENSE)
License: MIT
License File: PyJWT.license
@ -368,6 +374,10 @@ requests - Requests allows you to send HTTP/1.1 requests extremely easily.
License: Apache 2.0
License File: requests.license
typeshed - Collection of library stubs for Python, with static types. (https://github.com/python/typeshed/blob/main/LICENSE)
License: Apache 2.0
License File: typeshed.license
web/documentserver-example/ruby
@ -379,14 +389,14 @@ coffee-rails - CoffeeScript adapter for the Rails asset pipeline. (https://gith
License: MIT
License File: coffee-rails.license
dalli - High performance memcached client for Ruby. (https://github.com/petergoldstein/dalli/blob/v3.2.0/LICENSE)
License: MIT
License File: dalli.license
jbuilder - Create JSON structures via a Builder-style DSL (https://github.com/rails/jbuilder/blob/master/MIT-LICENSE)
License: MIT
License File: jbuilder.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -399,9 +409,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
@ -411,10 +425,18 @@ jquery-rails - This gem provides jQuery and the jQuery-ujs driver for your Rail
License: MIT
License File: jquery-rails.license
mimemagic - А library to detect the mime type of a file by extension or by content. (https://github.com/mimemagicrb/mimemagic/blob/master/LICENSE)
License: MIT
License File: mimemagic.license
rails - Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern. (https://github.com/rails/rails/blob/v6.0.3.2/MIT-LICENSE)
License: MIT
License File: rails.license
rubocop - A Ruby static code analyzer and formatter, based on the community Ruby style guide. (https://github.com/rubocop/rubocop/blob/v1.52.0/LICENSE.txt)
License: MIT
License File: rubocop.license
sass-rails - This gem provides official integration for Ruby on Rails projects with the Sass stylesheet language. (https://github.com/rails/sass-rails/blob/master/MIT-LICENSE)
License: MIT
License File: sass-rails.license
@ -423,9 +445,13 @@ sdoc - rdoc generator html with javascript search index. (https://githu
License: MIT
License File: sdoc.license
sqlite3 - This module allows Ruby programs to interface with the SQLite3 database engine (www.sqlite.org). (https://github.com/sparklemotion/sqlite3-ruby/blob/master/LICENSE)
License: BSD-3-Clause
License File: sqlite3.license
sorbet - A fast, powerful type checker designed for Ruby. (https://github.com/sorbet/sorbet/blob/0.5.10871.20230607144259-d9000e2ba/LICENSE)
License: Apache License 2.0
License File: sorbet.license
tapioca - The swiss army knife of RBI generation. (https://github.com/Shopify/tapioca/blob/v0.11.6/LICENSE.txt)
License: MIT
License File: tapioca.license
turbolinks - Rails engine for Turbolinks 5 support (https://github.com/turbolinks/turbolinks-rails/blob/master/LICENSE)
License: MIT

View File

@ -1,5 +1,27 @@
# Change Log
## 1.7.0
- nodejs: onRequestSelectDocument method
- nodejs: onRequestSelectSpreadsheet method
- nodejs: onRequestOpen
- nodejs: submitForm
- nodejs: key in referenceData
- nodejs: change reference source
- nodejs: using a repo with a list of formats
- nodejs: delete file without reloading the page
- nodejs: getting history by a separate request
- nodejs: restore from history
- php: using a repo with a list of formats
- php: restore from history
- python: restore from history
- ruby: restore from history
- csharp-mvc: getting history by a separate request
- csharp-mvc: restore from history
- csharp: getting history by a separate request
- csharp: restore from history
## 1.6.0
- nodejs: setUsers for region protection
- si skin languages
- fix "no" skin languages
- anonymous can't change viewer to edit

View File

@ -4,10 +4,6 @@ Entity Framework - Entity Framework is an object-relational mapper that enables
License: MICROSOFT SOFTWARE SUPPLEMENTAL TERMS, MICROSOFT SOFTWARE LICENSE TERMS
License File: EntityFramework.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -20,9 +16,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT

View File

@ -220,6 +220,7 @@ namespace OnlineEditorsExampleMVC.Helpers
var fileName = GetCorrectName(demoName); // get a file name with an index if the file with such a name already exists
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, StoragePath(fileName)); // copy file to the storage directory
File.SetLastWriteTime(StoragePath(fileName), DateTime.Now);
return fileName;
}

View File

@ -17,7 +17,6 @@
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Web;
@ -236,123 +235,6 @@ namespace OnlineEditorsExampleMVC.Models
return jss.Serialize(config);
}
// get the document history
public void GetHistory(out string history, out string historyData)
{
var storagePath = WebConfigurationManager.AppSettings["storage-path"];
var jss = new JavaScriptSerializer();
var histDir = DocManagerHelper.HistoryDir(DocManagerHelper.StoragePath(FileName, null));
history = null;
historyData = null;
if (DocManagerHelper.GetFileVersion(histDir) > 0) // if the file was modified (the file version is greater than 0)
{
var currentVersion = DocManagerHelper.GetFileVersion(histDir);
var hist = new List<Dictionary<string, object>>();
var histData = new Dictionary<string, object>();
for (var i = 1; i <= currentVersion; i++) // run through all the file versions
{
var obj = new Dictionary<string, object>();
var dataObj = new Dictionary<string, object>();
var verDir = DocManagerHelper.VersionDir(histDir, i); // get the path to the given file version
var key = i == currentVersion ? Key : File.ReadAllText(Path.Combine(verDir, "key.txt")); // get document key
obj.Add("key", key);
obj.Add("version", i);
if (i == 1) // check if the version number is equal to 1
{
var infoPath = Path.Combine(histDir, "createdInfo.json"); // get meta data of this file
if (File.Exists(infoPath))
{
var info = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(infoPath));
obj.Add("created", info["created"]); // write meta information to the object (user information and creation date)
obj.Add("user", new Dictionary<string, object>() {
{ "id", info["id"] },
{ "name", info["name"] },
});
}
}
var ext = Path.GetExtension(FileName).ToLower();
dataObj.Add("fileType", ext.Replace(".", ""));
dataObj.Add("key", key);
// write file url to the data object
string prevFileUrl;
string directPrevFileUrl;
if (Path.IsPathRooted(storagePath) && !string.IsNullOrEmpty(storagePath))
{
prevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext)
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
directPrevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext, false)
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
}
else {
prevFileUrl = i == currentVersion ? FileUri
: DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext);
directPrevFileUrl = i == currentVersion ? DocManagerHelper.GetHistoryDownloadUrl(FileName, i.ToString(), "prev" + ext, false)
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
}
dataObj.Add("url", prevFileUrl);
if (IsEnabledDirectUrl)
{
dataObj.Add("directUrl", directPrevFileUrl);
}
dataObj.Add("version", i);
if (i > 1) // check if the version number is greater than 1 (the file was modified)
{
// get the path to the changes.json file
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(DocManagerHelper.VersionDir(histDir, i - 1), "changes.json")));
var changesArray = (ArrayList)changes["changes"];
var change = changesArray.Count > 0
? (Dictionary<string, object>)changesArray[0]
: new Dictionary<string, object>();
// write information about changes to the object
obj.Add("changes", change.Count > 0 ? changes["changes"] : null);
obj.Add("serverVersion", changes["serverVersion"]);
obj.Add("created", change.Count > 0 ? change["created"] : null);
obj.Add("user", change.Count > 0 ? change["user"] : null);
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()]; // get the history data from the previous file version
dataObj.Add("previous", IsEnabledDirectUrl ? new Dictionary<string, object>() { // write information about previous file version to the data object with direct url
{ "fileType", prev["fileType"] },
{ "key", prev["key"] }, // write key and url information about previous file version
{ "url", prev["url"] },
{ "directUrl", prev["directUrl"] },
} : new Dictionary<string, object>() { // write information about previous file version to the data object without direct url
{ "fileType", prev["fileType"] },
{ "key", prev["key"] }, // write key and url information about previous file version
{ "url", prev["url"] },
});
// write the path to the diff.zip archive with differences in this file version
var changesUrl = DocManagerHelper.GetHistoryDownloadUrl(FileName, (i - 1).ToString(), "diff.zip");
dataObj.Add("changesUrl", changesUrl);
}
if(JwtManager.Enabled)
{
var token = JwtManager.Encode(dataObj);
dataObj.Add("token", token);
}
hist.Add(obj); // add object dictionary to the hist list
histData.Add((i - 1).ToString(), dataObj); // write data object information to the history data
}
// write history information about the current file version to the history object
history = jss.Serialize(new Dictionary<string, object>()
{
{ "currentVersion", currentVersion },
{ "history", hist }
});
historyData = jss.Serialize(histData);
}
}
// get a document which will be compared with the current document
public void GetCompareFileData(out string compareConfig)
{

View File

@ -236,6 +236,7 @@ if (typeof jQuery != "undefined") {
window.open(url, "_blank");
jq('#hiddenFileName').val("");
jq.unblockUI();
document.location.reload();
});
jq(document).on("click", "#beginView:not(.disable)", function () {
@ -244,6 +245,7 @@ if (typeof jQuery != "undefined") {
window.open(url, "_blank");
jq('#hiddenFileName').val("");
jq.unblockUI();
document.location.reload();
});
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {

View File

@ -190,6 +190,47 @@
}
};
var onRequestHistory = function () {
let xhr = new XMLHttpRequest();
xhr.open("GET", "webeditor.ashx?type=gethistory&filename=<%= Model.FileName %>");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
xhr.onload = function () {
console.log(xhr.responseText);
docEditor.refreshHistory(JSON.parse(xhr.responseText));
}
};
var onRequestHistoryData = function (event) {
var ver = event.data;
let xhr = new XMLHttpRequest();
xhr.open("GET", "webeditor.ashx?type=getversiondata&filename=<%= Model.FileName %>&version=" + ver + "&directUrl=" + !!config.document.directUrl);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
xhr.onload = function () {
console.log(xhr.responseText);
docEditor.setHistoryData(JSON.parse(xhr.responseText)); // send the link to the document for viewing the version history
}
};
var onRequestRestore = function (event) {
var fileName = "<%= Model.FileName %>";
var version = event.data.version;
var data = {
fileName: fileName,
version: version
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "webeditor.ashx?type=restore&directUrl=" + !!config.document.directUrl);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
docEditor.refreshHistory(JSON.parse(xhr.responseText));
}
}
config = <%= Model.GetDocConfig(Request, Url) %>;
config.width = "100%";
@ -207,30 +248,19 @@
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
};
<% string hist, histData; %>
<% Model.GetHistory(out hist, out histData); %>
<% string usersForMentions; %>
<% Model.GetUsersMentions(Request, out usersForMentions); %>
if (config.editorConfig.user.id) {
<% if (!string.IsNullOrEmpty(hist) && !string.IsNullOrEmpty(histData))
{ %>
// the user is trying to show the document version history
config.events['onRequestHistory'] = function () {
docEditor.refreshHistory(<%= hist %>); // show the document version history
};
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = function (event) {
var ver = event.data;
var histData = <%= histData %>;
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
};
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose'] = function () {
document.location.reload();
};
<% } %>
// the user is trying to show the document version history
config.events['onRequestHistory'] = onRequestHistory;
// the user is trying to click the specific document version in the document version history
config.events['onRequestHistoryData'] = onRequestHistoryData;
// the user is trying to go back to the document from viewing the document version history
config.events['onRequestHistoryClose'] = function () {
document.location.reload();
};
config.events['onRequestRestore'] = onRequestRestore;
// add mentions for not anonymous users
<% if (!string.IsNullOrEmpty(usersForMentions))

View File

@ -17,6 +17,7 @@
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
@ -50,6 +51,15 @@ namespace OnlineEditorsExampleMVC
case "downloadhistory":
DownloadHistory(context);
break;
case "gethistory":
GetHistory(context);
break;
case "getversiondata":
GetVersionData(context);
break;
case "restore":
Restore(context);
break;
case "convert":
Convert(context);
break;
@ -249,14 +259,14 @@ namespace OnlineEditorsExampleMVC
// get the url and file type of the converted file
Dictionary<string, string> newFileData;
var result = ServiceConverter.GetConvertedData(downloadUri.ToString(), extension, internalExtension, key, true, out newFileData, filePass, lang);
var newFileUri = newFileData["fileUrl"];
var newFileType = "." + newFileData["fileType"];
if (result != 100)
{
context.Response.Write("{ \"step\" : \"" + result + "\", \"filename\" : \"" + fileName + "\"}");
return;
}
var newFileUri = newFileData["fileUrl"];
var newFileType = "." + newFileData["fileType"];
// get a file name of an internal file extension with an index if the file with such a name already exists
var correctName = DocManagerHelper.GetCorrectName(Path.GetFileNameWithoutExtension(fileName) + newFileType);
@ -513,6 +523,173 @@ namespace OnlineEditorsExampleMVC
get { return false; }
}
private static void GetHistory(HttpContext context)
{
var jss = new JavaScriptSerializer();
var fileName = context.Request["filename"];
var history = GetHistory(fileName);
context.Response.Write(jss.Serialize(history));
}
private static void GetVersionData(HttpContext context)
{
var storagePath = WebConfigurationManager.AppSettings["storage-path"];
var jss = new JavaScriptSerializer();
var fileName = context.Request["filename"];
int version;
if (!int.TryParse(context.Request["version"], out version))
{
context.Response.Write("{ \"error\": \"Version number invalid!\"}");
return;
}
var versionData = new Dictionary<string, object>();
var histDir = DocManagerHelper.HistoryDir(DocManagerHelper.StoragePath(fileName, null));
var lastVersion = DocManagerHelper.GetFileVersion(histDir);
var verDir = DocManagerHelper.VersionDir(histDir, version);
var key = version == lastVersion
? ServiceConverter.GenerateRevisionId(DocManagerHelper.CurUserHostAddress()
+ "/" + fileName + "/"
+ File.GetLastWriteTime(DocManagerHelper.StoragePath(fileName, null)).GetHashCode())
: File.ReadAllText(Path.Combine(verDir, "key.txt"));
var ext = Path.GetExtension(fileName).ToLower();
versionData.Add("fileType", ext.Replace(".", ""));
versionData.Add("key", key);
// write file url to the data object
string prevFileUrl;
string directPrevFileUrl;
if (Path.IsPathRooted(storagePath) && !string.IsNullOrEmpty(storagePath))
{
prevFileUrl = version == lastVersion ? DocManagerHelper.GetDownloadUrl(fileName)
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
directPrevFileUrl = version == lastVersion ? DocManagerHelper.GetDownloadUrl(fileName, false)
: DocManagerHelper.GetDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
}
else
{
prevFileUrl = version == lastVersion ? DocManagerHelper.GetFileUri(fileName, true)
: DocManagerHelper.GetHistoryDownloadUrl(fileName, version.ToString(), "prev" + ext);
directPrevFileUrl = version == lastVersion ? DocManagerHelper.GetFileUri(fileName, false)
: DocManagerHelper.GetHistoryDownloadUrl(fileName, version.ToString(), "prev" + ext, false);
}
versionData.Add("url", prevFileUrl);
var isEnableDirectUrl = string.Equals(DocManagerHelper.GetDirectUrl(), "true");
if (isEnableDirectUrl)
{
versionData.Add("directUrl", directPrevFileUrl); // write direct url to the data object
}
versionData.Add("version", version);
if (version > 1)
{
var prevVerDir = DocManagerHelper.VersionDir(histDir, version - 1);
var prevUrl = Path.IsPathRooted(storagePath) && !string.IsNullOrEmpty(storagePath)
? DocManagerHelper.GetDownloadUrl(Directory.GetFiles(prevVerDir, "prev.*")[0].Replace(storagePath + "\\", ""))
: DocManagerHelper.GetHistoryDownloadUrl(fileName, (version - 1).ToString(), "prev" + ext);
var prevKey = File.ReadAllText(Path.Combine(prevVerDir, "key.txt"));
Dictionary<string, object> dataPrev = new Dictionary<string, object>() { // write information about previous file version to the data object
{ "fileType", ext.Replace(".", "") },
{ "key", prevKey }, // write key and url information about previous file version
{ "url", prevUrl }
};
string directPrevUrl;
if (isEnableDirectUrl)
{
directPrevUrl = Path.IsPathRooted(storagePath) && !string.IsNullOrEmpty(storagePath)
? DocManagerHelper.GetDownloadUrl(Directory.GetFiles(prevVerDir, "prev.*")[0].Replace(storagePath + "\\", ""), false)
: DocManagerHelper.GetHistoryDownloadUrl(fileName, version.ToString(), "prev" + ext, false);
dataPrev.Add("directUrl", directPrevUrl);
}
versionData.Add("previous", dataPrev);
if (File.Exists(Path.Combine(prevVerDir, "diff.zip")))
{
var changesUrl = DocManagerHelper.GetHistoryDownloadUrl(fileName, (version - 1).ToString(), "diff.zip");
versionData.Add("changesUrl", changesUrl);
}
}
if (JwtManager.Enabled)
{
var token = JwtManager.Encode(versionData);
versionData.Add("token", token);
}
context.Response.Write(jss.Serialize(versionData));
}
private static void Restore(HttpContext context)
{
string fileData;
try
{
using (var receiveStream = context.Request.InputStream)
using (var readStream = new StreamReader(receiveStream))
{
fileData = readStream.ReadToEnd();
if (string.IsNullOrEmpty(fileData)) return;
}
}
catch (Exception e)
{
throw new HttpException((int)HttpStatusCode.BadRequest, e.Message);
}
var jss = new JavaScriptSerializer();
var body = jss.Deserialize<Dictionary<string, object>>(fileData);
var fileName = (string)body["fileName"];
var version = (int)body["version"];
var key = ServiceConverter.GenerateRevisionId(DocManagerHelper.CurUserHostAddress()
+ "/" + fileName + "/"
+ File.GetLastWriteTime(DocManagerHelper.StoragePath(fileName, null)).GetHashCode());
var histDir = DocManagerHelper.HistoryDir(DocManagerHelper.StoragePath(fileName, null));
var currentVersionDir = DocManagerHelper.VersionDir(histDir, DocManagerHelper.GetFileVersion(histDir));
var verDir = DocManagerHelper.VersionDir(histDir, version);
if (!Directory.Exists(currentVersionDir)) Directory.CreateDirectory(currentVersionDir);
var ext = Path.GetExtension(fileName).ToLower();
File.Copy(DocManagerHelper.StoragePath(fileName, null), Path.Combine(currentVersionDir, "prev" + ext));
File.WriteAllText(Path.Combine(currentVersionDir, "key.txt"), key);
var changesPath = Path.Combine(DocManagerHelper.VersionDir(histDir, version - 1), "changes.json");
if (File.Exists(changesPath))
{
File.Copy(changesPath, Path.Combine(currentVersionDir, "changes.json"));
}
File.Copy(Path.Combine(verDir, "prev" + ext), DocManagerHelper.StoragePath(fileName, null), true);
var fileInfo = new FileInfo(DocManagerHelper.StoragePath(fileName, null));
fileInfo.LastWriteTimeUtc = DateTime.UtcNow;
var history = GetHistory(fileName);
context.Response.Write(jss.Serialize(history));
}
// download a history file
private static void DownloadHistory(HttpContext context)
{
@ -659,10 +836,12 @@ namespace OnlineEditorsExampleMVC
return;
}
var directUrl = (bool)body["directUrl"];
var data = new Dictionary<string, object>() {
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower() },
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower().Trim('.') },
{ "url", DocManagerHelper.GetDownloadUrl(fileName)},
{ "directUrl", DocManagerHelper.GetDownloadUrl(fileName) },
{ "directUrl", directUrl ? DocManagerHelper.GetDownloadUrl(fileName, false) : null },
{ "referenceData", new Dictionary<string, string>()
{
{ "fileKey", jss.Serialize(new Dictionary<string, object>{
@ -670,7 +849,7 @@ namespace OnlineEditorsExampleMVC
{"userAddress", HttpUtility.UrlEncode(DocManagerHelper.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress))}
})
},
{"instanceId", DocManagerHelper.GetServerUrl(false) }
{ "instanceId", DocManagerHelper.GetServerUrl(false) }
}
},
{ "path", fileName }
@ -685,6 +864,70 @@ namespace OnlineEditorsExampleMVC
context.Response.Write(jss.Serialize(data));
}
// get the document history
private static Dictionary<string, object> GetHistory(string fileName)
{
var jss = new JavaScriptSerializer();
var histDir = DocManagerHelper.HistoryDir(DocManagerHelper.StoragePath(fileName, null));
var history = new Dictionary<string, object>();
var currentVersion = DocManagerHelper.GetFileVersion(histDir);
var currentKey = ServiceConverter.GenerateRevisionId(DocManagerHelper.CurUserHostAddress()
+ "/" + fileName + "/"
+ File.GetLastWriteTime(DocManagerHelper.StoragePath(fileName, null)).GetHashCode());
var versionList = new List<Dictionary<string, object>>();
for (var versionNum = 1; versionNum <= currentVersion; versionNum++)
{
var versionObj = new Dictionary<string, object>();
var verDir = DocManagerHelper.VersionDir(histDir, versionNum); // get the path to the given file version
var key = versionNum == currentVersion ? currentKey : File.ReadAllText(Path.Combine(verDir, "key.txt")); // get document key
versionObj.Add("key", key);
versionObj.Add("version", versionNum);
var changesPath = Path.Combine(DocManagerHelper.VersionDir(histDir, versionNum - 1), "changes.json");
if (versionNum == 1 || !File.Exists(changesPath)) // check if the version number is equal to 1
{
var infoPath = Path.Combine(histDir, "createdInfo.json"); // get meta data of this file
if (File.Exists(infoPath))
{
var info = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(infoPath));
versionObj.Add("created", info["created"]); // write meta information to the object (user information and creation date)
versionObj.Add("user", new Dictionary<string, object>()
{
{ "id", info["id"] },
{ "name", info["name"] },
});
}
}
else if (versionNum > 1) // check if the version number is greater than 1 (the file was modified)
{
// get the path to the changes.json file
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(changesPath));
var changesArray = (ArrayList)changes["changes"];
var change = changesArray.Count > 0
? (Dictionary<string, object>)changesArray[0]
: new Dictionary<string, object>();
// write information about changes to the object
versionObj.Add("changes", change.Count > 0 ? changes["changes"] : null);
versionObj.Add("serverVersion", changes["serverVersion"]);
versionObj.Add("created", change.Count > 0 ? change["created"] : null);
versionObj.Add("user", change.Count > 0 ? change["user"] : null);
}
versionList.Add(versionObj);
}
history.Add("currentVersion", currentVersion);
history.Add("history", versionList);
return history;
}
}
}

View File

@ -4,10 +4,6 @@ Entity Framework - Entity Framework is an object-relational mapper that enables
License: MICROSOFT SOFTWARE SUPPLEMENTAL TERMS, MICROSOFT SOFTWARE LICENSE TERMS
License File: EntityFramework.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -20,9 +16,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<appSettings>
<clear />
<add key="version" value="1.5.1"/>
<add key="version" value="1.7.0"/>
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>
@ -18,7 +18,7 @@
<add key="files.docservice.verify-peer-off" value="true"/>
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
<add key="files.docservice.url.site" value="http://documentserver/"/>

View File

@ -1,9 +1,5 @@
ONLYOFFICE Applications example uses code from the following 3rd party projects:
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT

View File

@ -489,13 +489,13 @@ namespace OnlineEditorsExample
// get the url and file type of the converted file
Dictionary<string, string> newFileData;
var result = ServiceConverter.GetConvertedData(fileUrl.ToString() , extension, internalExtension, key, true, out newFileData, filePass, lang);
var newFileUri = newFileData["fileUrl"];
var newFileType = "." + newFileData["fileType"];
if (result != 100)
{
return "{ \"step\" : \"" + result + "\", \"filename\" : \"" + _fileName + "\"}";
}
var newFileUri = newFileData["fileUrl"];
var newFileType = "." + newFileData["fileType"];
// get a file name of an internal file extension with an index if the file with such a name already exists
var fileName = GetCorrectName(Path.GetFileNameWithoutExtension(_fileName) + newFileType);
@ -633,5 +633,12 @@ namespace OnlineEditorsExample
string isEnabledDirectUrl = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query).Get("directUrl");
return "&directUrl=" + (isEnabledDirectUrl != null ? isEnabledDirectUrl : "false");
}
// get direct url flag
public static bool IsEnabledDirectUrl()
{
string isEnabledDirectUrl = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query).Get("directUrl");
return isEnabledDirectUrl != null ? Convert.ToBoolean(isEnabledDirectUrl) : false;
}
}
}

View File

@ -221,20 +221,49 @@
};
if (config.editorConfig.user.id) {
<% if (!string.IsNullOrEmpty(History) && !string.IsNullOrEmpty(HistoryData))
{ %>
config.events['onRequestHistory'] = function () { // the user is trying to show the document version history
docEditor.refreshHistory(<%= History %>); // show the document version history
config.events['onRequestHistory'] = function (event) { // the user is trying to show the document version history
let xhr = new XMLHttpRequest();
xhr.open("GET", "webeditor.ashx?type=gethistory&filename=<%= FileName %>");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
xhr.onload = function () {
console.log(xhr.responseText);
docEditor.refreshHistory(JSON.parse(xhr.responseText));
}
};
config.events['onRequestHistoryData'] = function (event) { // the user is trying to click the specific document version in the document version history
var ver = event.data;
let xhr = new XMLHttpRequest();
xhr.open("GET", "webeditor.ashx?type=getversiondata&filename=<%= FileName %>&version=" + ver + "&directUrl=" + !!config.document.directUrl);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
xhr.onload = function () {
console.log(xhr.responseText);
docEditor.setHistoryData(JSON.parse(xhr.responseText)); // send the link to the document for viewing the version history
}
};
config.events['onRequestHistoryClose'] = function () { // the user is trying to go back to the document from viewing the document version history
document.location.reload();
};
config.events['onRequestRestore'] = function (event) {
var fileName = "<%= FileName %>";
var version = event.data.version;
var data = {
fileName: fileName,
version: version
};
config.events['onRequestHistoryData'] = function (event) { // the user is trying to click the specific document version in the document version history
var ver = event.data;
var histData = <%= HistoryData %>;
docEditor.setHistoryData(histData[ver - 1]); // send the link to the document for viewing the version history
};
config.events['onRequestHistoryClose'] = function () { // the user is trying to go back to the document from viewing the document version history
document.location.reload();
};
<% } %>
let xhr = new XMLHttpRequest();
xhr.open("POST", "webeditor.ashx?type=restore&directUrl=" + !!config.document.directUrl);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(data));
xhr.onload = function () {
docEditor.refreshHistory(JSON.parse(xhr.responseText));
}
};
// add mentions for not anonymous users
<% if (!string.IsNullOrEmpty(UsersForMentions))

View File

@ -17,7 +17,6 @@
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Web;
@ -61,8 +60,6 @@ namespace OnlineEditorsExample
}
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; }
@ -195,7 +192,7 @@ namespace OnlineEditorsExample
{
{ "title", FileName },
{ "url", getDownloadUrl(FileName) },
{ "directUrl", IsEnabledDirectUrl() ? directUrl : "" },
{ "directUrl", _Default.IsEnabledDirectUrl() ? directUrl : "" },
{ "fileType", ext.Trim('.') },
{ "key", Key },
{
@ -320,134 +317,10 @@ namespace OnlineEditorsExample
// get users for mentions
List<Dictionary<string, object>> usersData = Users.getUsersForMentions(user.id);
UsersForMentions = !user.id.Equals("uid-0") ? jss.Serialize(usersData) : null;
Dictionary<string, object> hist;
Dictionary<string, object> histData;
// get the document history
GetHistory(out hist, out histData);
if (hist != null && histData != null)
{
History = jss.Serialize(hist);
HistoryData = jss.Serialize(histData);
}
}
catch { }
}
// get the document history
private void GetHistory(out Dictionary<string, object> history, out Dictionary<string, object> historyData)
{
var storagePath = WebConfigurationManager.AppSettings["storage-path"];
var jss = new JavaScriptSerializer();
var histDir = _Default.HistoryDir(_Default.StoragePath(FileName, null));
history = null;
historyData = null;
if (_Default.GetFileVersion(histDir) > 0) // if the file was modified (the file version is greater than 0)
{
var currentVersion = _Default.GetFileVersion(histDir);
var hist = new List<Dictionary<string, object>>();
var histData = new Dictionary<string, object>();
for (var i = 1; i <= currentVersion; i++) // run through all the file versions
{
var obj = new Dictionary<string, object>();
var dataObj = new Dictionary<string, object>();
var verDir = _Default.VersionDir(histDir, i); // get the path to the given file version
var key = i == currentVersion ? Key : File.ReadAllText(Path.Combine(verDir, "key.txt")); // get document key
obj.Add("key", key);
obj.Add("version", i);
if (i == 1) // check if the version number is equal to 1
{
var infoPath = Path.Combine(histDir, "createdInfo.json"); // get meta data of this file
if (File.Exists(infoPath)) {
var info = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(infoPath));
obj.Add("created", info["created"]); // write meta information to the object (user information and creation date)
obj.Add("user", new Dictionary<string, object>() {
{ "id", info["id"] },
{ "name", info["name"] },
});
}
}
var ext = Path.GetExtension(FileName).ToLower();
dataObj.Add("fileType", ext.Replace(".", ""));
dataObj.Add("key", key);
// write file url to the data object
var directPrevFileUrl = i == currentVersion ? _Default.FileUri(FileName, false) : MakePublicHistoryUrl(FileName, i.ToString(), "prev" + ext, false);
var prevFileUrl = i == currentVersion ? FileUri : MakePublicHistoryUrl(FileName, i.ToString(), "prev" + ext);
if (Path.IsPathRooted(storagePath))
{
prevFileUrl = i == currentVersion ? getDownloadUrl(FileName) : getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
directPrevFileUrl = i == currentVersion ? getDownloadUrl(FileName, false) : getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
}
dataObj.Add("url", prevFileUrl); // write file url to the data object
if (IsEnabledDirectUrl())
{
dataObj.Add("directUrl", directPrevFileUrl); // write direct url to the data object
}
dataObj.Add("version", i);
if (i > 1) // check if the version number is greater than 1 (the file was modified)
{
// get the path to the changes.json file
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(Path.Combine(_Default.VersionDir(histDir, i - 1), "changes.json")));
var changesArray = (ArrayList)changes["changes"];
var change = changesArray.Count > 0
? (Dictionary<string, object>)changesArray[0]
: new Dictionary<string, object>();
// write information about changes to the object
obj.Add("changes", change.Count > 0 ? changes["changes"] : null);
obj.Add("serverVersion", changes["serverVersion"]);
obj.Add("created", change.Count > 0 ? change["created"] : null);
obj.Add("user", change.Count > 0 ? change["user"] : null);
var prev = (Dictionary<string, object>)histData[(i - 2).ToString()]; // get the history data from the previous file version
Dictionary<string, object> dataPrev = new Dictionary<string, object>() { // write information about previous file version to the data object
{ "fileType", prev["fileType"] },
{ "key", prev["key"] }, // write key and url information about previous file version
{ "url", prev["url"] }
};
if (IsEnabledDirectUrl())
{
dataPrev.Add("directUrl", prev["directUrl"]);
}
dataObj.Add("previous", dataPrev);
// write the path to the diff.zip archive with differences in this file version
var changesUrl = MakePublicHistoryUrl(FileName, (i - 1).ToString(), "diff.zip");
dataObj.Add("changesUrl", changesUrl);
}
if (JwtManager.Enabled)
{
var token = JwtManager.Encode(dataObj);
dataObj.Add("token", token);
}
hist.Add(obj); // add object dictionary to the hist list
histData.Add((i - 1).ToString(), dataObj); // write data object information to the history data
}
// write history information about the current file version to the history object
history = new Dictionary<string, object>()
{
{ "currentVersion", currentVersion },
{ "history", hist }
};
historyData = histData;
}
}
// get a logo config
private Dictionary<string, object> GetLogoConfig()
{
@ -469,7 +342,7 @@ namespace OnlineEditorsExample
{ "url", InsertImageUrl.ToString()}
};
if (IsEnabledDirectUrl())
if (_Default.IsEnabledDirectUrl())
{
logoConfig.Add("directUrl", DirectImageUrl.ToString());
}
@ -506,7 +379,7 @@ namespace OnlineEditorsExample
{ "url", compareFileUrl.ToString() }
};
if (IsEnabledDirectUrl())
if (_Default.IsEnabledDirectUrl())
{
dataCompareFile.Add("directUrl", DirectFileUrl.ToString());
}
@ -545,7 +418,7 @@ namespace OnlineEditorsExample
{ "url", mailmergeUrl.ToString() }
};
if (IsEnabledDirectUrl())
if (_Default.IsEnabledDirectUrl())
{
mailMergeConfig.Add("directUrl", DirectMailMergeUrl.ToString());
}
@ -589,21 +462,6 @@ namespace OnlineEditorsExample
return _Default.GetServerUrl(true) + fullPath.Substring(root.Length).Replace(Path.DirectorySeparatorChar, '/');
}
// create the public history url
private string MakePublicHistoryUrl(string filename, string version, string file, Boolean isServer = true)
{
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
var fileUrl = new UriBuilder(_Default.GetServerUrl(isServer));
fileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "webeditor.ashx";
fileUrl.Query = "type=downloadhistory&fileName=" + HttpUtility.UrlEncode(filename)
+ "&ver=" + version + "&file=" + file
+ userAddress;
return fileUrl.ToString();
}
// create demo document
private static void Try(string type, string sample, HttpRequest request)
{
@ -632,6 +490,7 @@ namespace OnlineEditorsExample
var filePath = _Default.StoragePath(FileName, null);
File.Copy(HttpRuntime.AppDomainAppPath + demoPath + demoName, filePath); // copy this file to the storage directory
File.SetLastWriteTime(filePath, DateTime.Now);
// create a json file with file meta data
var id = request.Cookies.GetOrDefault("uid", null);
@ -651,12 +510,5 @@ namespace OnlineEditorsExample
{ "name", uname }
}));
}
// get direct url flag
private static bool IsEnabledDirectUrl()
{
string isEnabledDirectUrl = HttpUtility.ParseQueryString(HttpContext.Current.Request.Url.Query).Get("directUrl");
return isEnabledDirectUrl != null ? Convert.ToBoolean(isEnabledDirectUrl) : false;
}
}
}

View File

@ -26,7 +26,9 @@ using System.Diagnostics;
using System.Web.Configuration;
using System.Linq;
using System.Net;
using System.Collections;
using System.Net.Sockets;
using ASC.Api.DocumentConverter;
namespace OnlineEditorsExample
{
@ -48,6 +50,15 @@ namespace OnlineEditorsExample
case "downloadhistory":
DownloadHistory(context);
break;
case "gethistory":
GetHistory(context);
break;
case "getversiondata":
GetVersionData(context);
break;
case "restore":
Restore(context);
break;
case "convert":
Convert(context);
break;
@ -333,6 +344,164 @@ namespace OnlineEditorsExample
get { return false; }
}
private static void GetHistory(HttpContext context)
{
var jss = new JavaScriptSerializer();
var fileName = context.Request["filename"];
var history = GetHistory(fileName);
context.Response.Write(jss.Serialize(history));
}
private static void GetVersionData(HttpContext context)
{
var storagePath = WebConfigurationManager.AppSettings["storage-path"];
var jss = new JavaScriptSerializer();
var fileName = context.Request["filename"];
int version;
if (!int.TryParse(context.Request["version"], out version))
{
context.Response.Write("{ \"error\": \"Version number invalid!\"}");
return;
}
var versionData = new Dictionary<string, object>();
var histDir = _Default.HistoryDir(_Default.StoragePath(fileName, null));
var lastVersion = _Default.GetFileVersion(histDir);
var verDir = _Default.VersionDir(histDir, version);
var lastVersionUri = _Default.FileUri(fileName, true);
var key = version == lastVersion
? ServiceConverter.GenerateRevisionId(_Default.CurUserHostAddress(null)
+ "/" + Path.GetFileName(lastVersionUri)
+ "/" + File.GetLastWriteTime(_Default.StoragePath(fileName, null)).GetHashCode())
: File.ReadAllText(Path.Combine(verDir, "key.txt"));
var ext = Path.GetExtension(fileName).ToLower();
versionData.Add("fileType", ext.Replace(".", ""));
versionData.Add("key", key);
var directPrevFileUrl = version == lastVersion ? _Default.FileUri(fileName, false) : MakePublicHistoryUrl(fileName, version.ToString(), "prev" + ext, false);
var prevFileUrl = version == lastVersion ? lastVersionUri : MakePublicHistoryUrl(fileName, version.ToString(), "prev" + ext);
if (Path.IsPathRooted(storagePath))
{
prevFileUrl = version == lastVersion ? DocEditor.getDownloadUrl(fileName) : DocEditor.getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""));
directPrevFileUrl = version == lastVersion ? DocEditor.getDownloadUrl(fileName, false) : DocEditor.getDownloadUrl(Directory.GetFiles(verDir, "prev.*")[0].Replace(storagePath + "\\", ""), false);
}
versionData.Add("url", prevFileUrl);
if (_Default.IsEnabledDirectUrl())
{
versionData.Add("directUrl", directPrevFileUrl); // write direct url to the data object
}
versionData.Add("version", version);
if (version > 1)
{
var prevVerDir = _Default.VersionDir(histDir, version - 1);
var prevUrl = MakePublicHistoryUrl(fileName, (version - 1).ToString(), "prev" + ext);
if (Path.IsPathRooted(storagePath))
prevUrl = DocEditor.getDownloadUrl(Directory.GetFiles(prevVerDir, "prev.*")[0].Replace(storagePath + "\\", ""));
var prevKey = File.ReadAllText(Path.Combine(prevVerDir, "key.txt"));
Dictionary<string, object> dataPrev = new Dictionary<string, object>() { // write information about previous file version to the data object
{ "fileType", ext.Replace(".", "") },
{ "key", prevKey }, // write key and url information about previous file version
{ "url", prevUrl }
};
string directPrevUrl;
if (_Default.IsEnabledDirectUrl())
{
directPrevUrl = Path.IsPathRooted(storagePath)
? DocEditor.getDownloadUrl(Directory.GetFiles(prevVerDir, "prev.*")[0].Replace(storagePath + "\\", ""), false)
: MakePublicHistoryUrl(fileName, (version - 1).ToString(), "prev" + ext, false);
dataPrev.Add("directUrl", directPrevUrl); // write direct url to the data object
}
versionData.Add("previous", dataPrev);
if (File.Exists(Path.Combine(prevVerDir, "diff.zip")))
{
var changesUrl = MakePublicHistoryUrl(fileName, (version - 1).ToString(), "diff.zip");
versionData.Add("changesUrl", changesUrl);
}
}
if (JwtManager.Enabled)
{
var token = JwtManager.Encode(versionData);
versionData.Add("token", token);
}
context.Response.Write(jss.Serialize(versionData));
}
private void Restore(HttpContext context)
{
string fileData;
try
{
using (var receiveStream = context.Request.InputStream)
using (var readStream = new StreamReader(receiveStream))
{
fileData = readStream.ReadToEnd();
if (string.IsNullOrEmpty(fileData)) return;
}
}
catch (Exception e)
{
throw new HttpException((int)HttpStatusCode.BadRequest, e.Message);
}
var jss = new JavaScriptSerializer();
var body = jss.Deserialize<Dictionary<string, object>>(fileData);
var fileName = (string)body["fileName"];
var version = (int)body["version"];
var lastVersionUri = _Default.FileUri(fileName, true);
var key = ServiceConverter.GenerateRevisionId(_Default.CurUserHostAddress(null)
+ "/" + Path.GetFileName(lastVersionUri)
+ "/" + File.GetLastWriteTime(_Default.StoragePath(fileName, null)).GetHashCode());
var histDir = _Default.HistoryDir(_Default.StoragePath(fileName, null));
var currentVersionDir = _Default.VersionDir(histDir, _Default.GetFileVersion(histDir));
var verDir = _Default.VersionDir(histDir, version);
if (!Directory.Exists(currentVersionDir)) Directory.CreateDirectory(currentVersionDir);
var ext = Path.GetExtension(fileName).ToLower();
File.Copy(_Default.StoragePath(fileName, null), Path.Combine(currentVersionDir, "prev" + ext));
File.WriteAllText(Path.Combine(currentVersionDir, "key.txt"), key);
var changesPath = Path.Combine(_Default.VersionDir(histDir, version - 1), "changes.json");
if (File.Exists(changesPath))
{
File.Copy(changesPath, Path.Combine(currentVersionDir, "changes.json"));
}
File.Copy(Path.Combine(verDir, "prev" + ext), _Default.StoragePath(fileName, null), true);
var fileInfo = new FileInfo(_Default.StoragePath(fileName, null));
fileInfo.LastWriteTimeUtc = DateTime.UtcNow;
var history = GetHistory(fileName);
context.Response.Write(jss.Serialize(history));
}
private static void DownloadHistory(HttpContext context)
{
try
@ -477,10 +646,12 @@ namespace OnlineEditorsExample
return;
}
var directUrl = (bool) body["directUrl"];
var data = new Dictionary<string, object>() {
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower() },
{ "fileType", (Path.GetExtension(fileName) ?? "").ToLower().Trim('.') },
{ "url", DocEditor.getDownloadUrl(fileName)},
{ "directUrl", DocEditor.getDownloadUrl(fileName) },
{ "directUrl", directUrl ? DocEditor.getDownloadUrl(fileName, false) : null},
{ "referenceData", new Dictionary<string, string>()
{
{ "fileKey", jss.Serialize(new Dictionary<string, object>{
@ -502,5 +673,84 @@ namespace OnlineEditorsExample
context.Response.Write(jss.Serialize(data));
}
// get the document history
private static Dictionary<string, object> GetHistory(string fileName)
{
var jss = new JavaScriptSerializer();
var histDir = _Default.HistoryDir(_Default.StoragePath(fileName, null));
var history = new Dictionary<string, object>();
var currentVersion = _Default.GetFileVersion(histDir);
var currentFileUri = _Default.FileUri(fileName, true);
var currentKey = ServiceConverter.GenerateRevisionId(_Default.CurUserHostAddress(null)
+ "/" + Path.GetFileName(currentFileUri)
+ "/" + File.GetLastWriteTime(_Default.StoragePath(fileName, null)).GetHashCode());
var versionList = new List<Dictionary<string, object>>();
for (var versionNum = 1; versionNum <= currentVersion; versionNum++)
{
var versionObj = new Dictionary<string, object>();
var verDir = _Default.VersionDir(histDir, versionNum); // get the path to the given file version
var key = versionNum == currentVersion ? currentKey : File.ReadAllText(Path.Combine(verDir, "key.txt")); // get document key
versionObj.Add("key", key);
versionObj.Add("version", versionNum);
var changesPath = Path.Combine(_Default.VersionDir(histDir, versionNum - 1), "changes.json");
if (versionNum == 1 || !File.Exists(changesPath)) // check if the version number is equal to 1
{
var infoPath = Path.Combine(histDir, "createdInfo.json"); // get meta data of this file
if (File.Exists(infoPath))
{
var info = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(infoPath));
versionObj.Add("created", info["created"]); // write meta information to the object (user information and creation date)
versionObj.Add("user", new Dictionary<string, object>()
{
{ "id", info["id"] },
{ "name", info["name"] },
});
}
}
else if (versionNum > 1) // check if the version number is greater than 1 (the file was modified)
{
// get the path to the changes.json file
var changes = jss.Deserialize<Dictionary<string, object>>(File.ReadAllText(changesPath));
var changesArray = (ArrayList)changes["changes"];
var change = changesArray.Count > 0
? (Dictionary<string, object>)changesArray[0]
: new Dictionary<string, object>();
// write information about changes to the object
versionObj.Add("changes", change.Count > 0 ? changes["changes"] : null);
versionObj.Add("serverVersion", changes["serverVersion"]);
versionObj.Add("created", change.Count > 0 ? change["created"] : null);
versionObj.Add("user", change.Count > 0 ? change["user"] : null);
}
versionList.Add(versionObj);
}
history.Add("currentVersion", currentVersion);
history.Add("history", versionList);
return history;
}
// create the public history url
private static string MakePublicHistoryUrl(string filename, string version, string file, Boolean isServer = true)
{
var userAddress = isServer ? "&userAddress=" + HttpUtility.UrlEncode(_Default.CurUserHostAddress(HttpContext.Current.Request.UserHostAddress)) : "";
var fileUrl = new UriBuilder(_Default.GetServerUrl(isServer));
fileUrl.Path = HttpRuntime.AppDomainAppVirtualPath
+ (HttpRuntime.AppDomainAppVirtualPath.EndsWith("/") ? "" : "/")
+ "webeditor.ashx";
fileUrl.Query = "type=downloadhistory&fileName=" + HttpUtility.UrlEncode(filename)
+ "&ver=" + version + "&file=" + file
+ userAddress;
return fileUrl.ToString();
}
}
}

View File

@ -1,9 +1,5 @@
ONLYOFFICE Applications example uses code from the following 3rd party projects:
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT

View File

@ -236,6 +236,7 @@ if (typeof jQuery != "undefined") {
window.open(url, "_blank");
jq('#hiddenFileName').val("");
jq.unblockUI();
document.location.reload();
});
jq(document).on("click", "#beginView:not(.disable)", function () {
@ -244,6 +245,7 @@ if (typeof jQuery != "undefined") {
window.open(url, "_blank");
jq('#hiddenFileName').val("");
jq.unblockUI();
document.location.reload();
});
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
<clear />
<add key="version" value="1.5.1"/>
<add key="version" value="1.7.0"/>
<add key="filesize-max" value="52428800"/>
<add key="storage-path" value=""/>
@ -17,7 +17,7 @@
<add key="files.docservice.token.useforrequest" value="true" />
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
<add key="files.docservice.languages" value="en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA: Test Language"/>
<add key="files.docservice.url.site" value="http://documentserver/"/>

View File

@ -1,8 +1,17 @@
ONLYOFFICE Applications example uses code from the following 3rd party projects:
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
License: Apache 2.0
License File: gson.license
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
License: MPL 2.0 or EPL 1.0
License File: h2database.license
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
License: Apache 2.0
License File: jackson-databind.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
@ -16,14 +25,30 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
License File: jQuery.UI.license
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
License: Apache 2.0
License File: JSON.simple.license
Project Lombok - Project Lombok is a java library that automatically plugs into your editor and build tools. (https://mvnrepository.com/artifact/org.projectlombok/lombok).
License: MIT
License File lombok.license
ModelMapper - ModelMapper is an intelligent object mapping library that automatically maps objects to each other. (https://github.com/modelmapper/modelmapper)
License: Apache 2.0
License File modelmapper.license
Prime JWT - is intended to be fast and easy to use. Prime JWT has a single external dependency on Jackson. (https://github.com/ws-apps/prime-jwt/blob/master/LICENSE)
License: Apache 2.0
License File: prime-jwt.license
@ -43,27 +68,3 @@ License File: spring-boot.license
Spring Data JPA - Persist data in SQL stores with Java Persistence API using Spring Data and Hibernate. (https://github.com/spring-projects/spring-data-jpa/blob/main/LICENSE.txt)
License: Apache 2.0
License File: spring-data-jpa.license
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
License: MPL 2.0 or EPL 1.0
License File: h2database.license
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
License: Apache 2.0
License File: JSON.simple.license
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
License: Apache 2.0
License File: gson.license
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
License: Apache 2.0
License File: jackson-databind.license
ModelMapper - ModelMapper is an intelligent object mapping library that automatically maps objects to each other. (https://github.com/modelmapper/modelmapper)
License: Apache 2.0
License File modelmapper.license
Project Lombok - Project Lombok is a java library that automatically plugs into your editor and build tools. (https://mvnrepository.com/artifact/org.projectlombok/lombok).
License: MIT
License File lombok.license

View File

@ -1,8 +1,17 @@
ONLYOFFICE Applications example uses code from the following 3rd party projects:
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
License: Apache 2.0
License File: gson.license
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
License: MPL 2.0 or EPL 1.0
License File: h2database.license
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
License: Apache 2.0
License File: jackson-databind.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
@ -16,14 +25,30 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
License File: jQuery.UI.license
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
License: Apache 2.0
License File: JSON.simple.license
Project Lombok - Project Lombok is a java library that automatically plugs into your editor and build tools. (https://mvnrepository.com/artifact/org.projectlombok/lombok).
License: MIT
License File lombok.license
ModelMapper - ModelMapper is an intelligent object mapping library that automatically maps objects to each other. (https://github.com/modelmapper/modelmapper)
License: Apache 2.0
License File modelmapper.license
Prime JWT - is intended to be fast and easy to use. Prime JWT has a single external dependency on Jackson. (https://github.com/ws-apps/prime-jwt/blob/master/LICENSE)
License: Apache 2.0
License File: prime-jwt.license
@ -43,19 +68,3 @@ License File: spring-boot.license
Spring Data JPA - Persist data in SQL stores with Java Persistence API using Spring Data and Hibernate. (https://github.com/spring-projects/spring-data-jpa/blob/main/LICENSE.txt)
License: Apache 2.0
License File: spring-data-jpa.license
H2 Database Engine - This software contains unmodified binary redistributions for H2 database engine. H2 is a relational DBMS that can be embedded in java applications. (https://h2database.com/html/license.html)
License: MPL 2.0 or EPL 1.0
License File: h2database.license
JSON.simple - JSON.simple is a simple Java toolkit for JSON. You can use JSON.simple to encode or decode JSON text. (https://github.com/fangyidong/json-simple/blob/master/LICENSE.txt)
License: Apache 2.0
License File: JSON.simple.license
Gson - Gson is a Java library that can be used to convert Java Objects into their JSON representation. (https://github.com/google/gson/blob/master/LICENSE)
License: Apache 2.0
License File: gson.license
Jackson Databind - General-purpose data-binding functionality and tree-model for Jackson Data Processor. (https://github.com/FasterXML/jackson-databind/blob/master/LICENSE)
License: Apache 2.0
License File: jackson-databind.license

View File

@ -35,7 +35,10 @@ import com.onlyoffice.integration.documentserver.util.file.FileUtility;
import com.onlyoffice.integration.documentserver.util.service.ServiceConverter;
import com.onlyoffice.integration.documentserver.managers.document.DocumentManager;
import com.onlyoffice.integration.documentserver.managers.callback.CallbackManager;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
@ -48,6 +51,7 @@ import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@ -55,15 +59,22 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
@ -234,6 +245,9 @@ public class FileController {
throw new RuntimeException("Input stream is null");
}
// remove source file
storageMutator.deleteFile(fileName);
// create the converted file with input stream
storageMutator.createFile(Path.of(storagePathBuilder.getFileLocation(correctedName)), stream);
fileName = correctedName;
@ -350,13 +364,13 @@ public class FileController {
@GetMapping("/assets")
public ResponseEntity<Resource> assets(@RequestParam("name")
final String name) { // get sample files from the assests
String fileName = Path.of("assets", "sample", fileUtility.getFileName(name)).toString();
String fileName = Path.of("assets", "document-templates", "sample", fileUtility.getFileName(name)).toString();
return downloadFile(fileName);
}
@GetMapping("/csv")
public ResponseEntity<Resource> csv() { // download a csv file
String fileName = Path.of("assets", "sample", "csv.csv").toString();
String fileName = Path.of("assets", "document-templates", "sample", "csv.csv").toString();
return downloadFile(fileName);
}
@ -459,18 +473,18 @@ public class FileController {
@ResponseBody
public String reference(@RequestBody final JSONObject body) {
try {
JSONParser parser = new JSONParser();
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
String userAddress = "";
String fileName = "";
if (body.containsKey("referenceData")) {
JSONObject referenceDataObj = (JSONObject) body.get("referenceData");
LinkedHashMap referenceDataObj = (LinkedHashMap) body.get("referenceData");
String instanceId = (String) referenceDataObj.get("instanceId");
if (instanceId.equals(storagePathBuilder.getServerUrl(false))) {
JSONObject fileKey = (JSONObject) referenceDataObj.get("fileKey");
JSONObject fileKey = (JSONObject) parser.parse((String) referenceDataObj.get("fileKey"));
userAddress = (String) fileKey.get("userAddress");
if (userAddress.equals(InetAddress.getLocalHost().getHostAddress())) {
fileName = (String) fileKey.get("fileName");
@ -496,18 +510,20 @@ public class FileController {
return "{ \"error\": \"File not found\"}";
}
boolean directUrl = (boolean) body.get("directUrl");
HashMap<String, Object> fileKey = new HashMap<>();
fileKey.put("fileName", fileName);
fileKey.put("userAddress", InetAddress.getLocalHost().getHostAddress());
HashMap<String, Object> referenceData = new HashMap<>();
referenceData.put("instanceId", storagePathBuilder.getServerUrl(true));
referenceData.put("fileKey", fileKey);
referenceData.put("fileKey", gson.toJson(fileKey));
HashMap<String, Object> data = new HashMap<>();
data.put("fileType", fileUtility.getFileExtension(fileName));
data.put("fileType", fileUtility.getFileExtension(fileName).replace(".", ""));
data.put("url", documentManager.getDownloadUrl(fileName, true));
data.put("directUrl", documentManager.getDownloadUrl(fileName, true));
data.put("directUrl", directUrl ? documentManager.getDownloadUrl(fileName, false) : null);
data.put("referenceData", referenceData);
data.put("path", fileName);
@ -521,4 +537,88 @@ public class FileController {
return "{ \"error\" : 1, \"message\" : \"" + e.getMessage() + "\"}";
}
}
@PutMapping("/restore")
@ResponseBody
public String restore(@RequestBody final JSONObject body) {
try {
String sourceBasename = (String) body.get("fileName");
Integer version = (Integer) body.get("version");
String userID = (String) body.get("userId");
String sourceStringFile = storagePathBuilder.getFileLocation(sourceBasename);
File sourceFile = new File(sourceStringFile);
Path sourcePathFile = sourceFile.toPath();
String historyDirectory = storagePathBuilder.getHistoryDir(sourcePathFile.toString());
Integer bumpedVersion = storagePathBuilder.getFileVersion(historyDirectory, false);
String bumpedVersionStringDirectory = documentManager.versionDir(historyDirectory, bumpedVersion, true);
File bumpedVersionDirectory = new File(bumpedVersionStringDirectory);
if (!bumpedVersionDirectory.exists()) {
bumpedVersionDirectory.mkdir();
}
Path bumpedKeyPathFile = Paths.get(bumpedVersionStringDirectory, "key.txt");
String bumpedKeyStringFile = bumpedKeyPathFile.toString();
File bumpedKeyFile = new File(bumpedKeyStringFile);
String bumpedKey = serviceConverter.generateRevisionId(
storagePathBuilder.getStorageLocation()
+ "/"
+ sourceBasename
+ "/"
+ Long.toString(sourceFile.lastModified())
);
FileWriter bumpedKeyFileWriter = new FileWriter(bumpedKeyFile);
bumpedKeyFileWriter.write(bumpedKey);
bumpedKeyFileWriter.close();
Integer userInnerID = Integer.parseInt(userID.replace("uid-", ""));
User user = userService.findUserById(userInnerID).get();
Path bumpedChangesPathFile = Paths.get(bumpedVersionStringDirectory, "changes.json");
String bumpedChangesStringFile = bumpedChangesPathFile.toString();
File bumpedChangesFile = new File(bumpedChangesStringFile);
JSONObject bumpedChangesUser = new JSONObject();
// Don't add the `uid-` prefix.
// https://github.com/ONLYOFFICE/document-server-integration/issues/437#issuecomment-1663526562
bumpedChangesUser.put("id", user.getId());
bumpedChangesUser.put("name", user.getName());
JSONObject bumpedChangesChangesItem = new JSONObject();
bumpedChangesChangesItem.put("created", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
bumpedChangesChangesItem.put("user", bumpedChangesUser);
JSONArray bumpedChangesChanges = new JSONArray();
bumpedChangesChanges.add(bumpedChangesChangesItem);
JSONObject bumpedChanges = new JSONObject();
bumpedChanges.put("serverVersion", null);
bumpedChanges.put("changes", bumpedChangesChanges);
String bumpedChangesContent = bumpedChanges.toJSONString();
FileWriter bumpedChangesFileWriter = new FileWriter(bumpedChangesFile);
bumpedChangesFileWriter.write(bumpedChangesContent);
bumpedChangesFileWriter.close();
String sourceExtension = fileUtility.getFileExtension(sourceBasename);
String previousBasename = "prev" + sourceExtension;
Path bumpedFile = Paths.get(bumpedVersionStringDirectory, previousBasename);
Files.move(sourcePathFile, bumpedFile);
String recoveryVersionStringDirectory = documentManager.versionDir(historyDirectory, version, true);
Path recoveryPathFile = Paths.get(recoveryVersionStringDirectory, previousBasename);
String recoveryStringFile = recoveryPathFile.toString();
FileInputStream recoveryStream = new FileInputStream(recoveryStringFile);
storageMutator.createFile(sourcePathFile, recoveryStream);
recoveryStream.close();
JSONObject responseBody = new JSONObject();
responseBody.put("error", null);
responseBody.put("success", true);
return responseBody.toJSONString();
} catch (Exception error) {
error.printStackTrace();
JSONObject responseBody = new JSONObject();
responseBody.put("error", error.getMessage());
responseBody.put("success", false);
return responseBody.toJSONString();
}
}
}

View File

@ -163,6 +163,8 @@ public class DefaultCallbackManager implements CallbackManager {
storageMutator.createDirectory(ver); // create the file version directory
lastVersion.toFile().renameTo(new File(versionDir + File.separator + "prev" + curExt));
saveFile(byteArrayFile, toSave); // save document file
byte[] byteArrayChanges = getDownloadFile(changesUri); // download file changes

View File

@ -217,8 +217,14 @@ public class DefaultDocumentManager implements DocumentManager {
public String createDemo(final String fileExt, final Boolean sample, final String uid, final String uname) {
String demoName = (sample ? "sample." : "new.")
+ fileExt; // create sample or new template file with the necessary extension
String demoPath = "assets" + File.separator + (sample ? "sample" : "new")
+ File.separator + demoName; // get the path to the sample document
String demoPath =
"assets"
+ File.separator
+ "document-templates"
+ File.separator
+ (sample ? "sample" : "new")
+ File.separator
+ demoName;
// get a file name with an index if the file with such a name already exists
String fileName = getCorrectName(demoName);

View File

@ -106,17 +106,17 @@ public class DefaultServiceConverter implements ServiceConverter {
connection.connect();
try (OutputStream os = connection.getOutputStream()) {
os.write(bodyByte); // write bytes to the output stream
os.flush(); // force write data to the output stream that can be cached in the current thread
}
int statusCode = connection.getResponseCode();
if (statusCode != HttpStatus.OK.value()) { // checking status code
connection.disconnect();
throw new RuntimeException("Convertation service returned status: " + statusCode);
}
try (OutputStream os = connection.getOutputStream()) {
os.write(bodyByte); // write bytes to the output stream
os.flush(); // force write data to the output stream that can be cached in the current thread
}
response = connection.getInputStream(); // get the input stream
jsonString = convertStreamToString(response); // convert the response stream into a string
} finally {

View File

@ -1,4 +1,4 @@
server.version=1.5.1
server.version=1.7.0
server.address=
server.port=4000
@ -28,7 +28,7 @@ files.docservice.token-use-for-request=true
files.docservice.verify-peer-off=true
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
spring.datasource.url=jdbc:h2:mem:usersdb
spring.datasource.driverClassName=org.h2.Driver
@ -38,6 +38,8 @@ spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
hibernate.ddl-auto
spring.h2.console.enabled=true
spring.h2.console.path=/h2
spring.servlet.multipart.max-file-size=5MB
spring.servlet.multipart.max-request-size=5MB
url.index=/
url.converter=/converter

View File

@ -52,7 +52,7 @@
// the user is trying to switch the document from the viewing into the editing mode
var onRequestEditRights = function () {
location.href = location.href.replace(RegExp("\&?action=view\&?", "i"), "");
location.href = location.href.replace(RegExp("\&?action=view", "i"), "");
};
// an error or some other specific event occurs
@ -172,6 +172,28 @@
}
};
function onRequestRestore(event) {
const query = new URLSearchParams(window.location.search)
const config = [[${model}]]
const payload = {
fileName: query.get('fileName'),
version: event.data.version,
userId: config.editorConfig.user.id
}
const request = new XMLHttpRequest()
request.open('PUT', 'restore')
request.setRequestHeader('Content-Type', 'application/json')
request.send(JSON.stringify(payload))
request.onload = function () {
if (request.status != 200) {
response = JSON.parse(request.response)
innerAlert(response.error)
return
}
document.location.reload()
}
}
config.width = "100%";
config.height = "100%";
config.events = {
@ -184,6 +206,7 @@
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
"onRequestRestore": onRequestRestore
};
var histArray = [[${fileHistory}]];

View File

@ -1,9 +1,5 @@
ONLYOFFICE Applications example uses code from the following 3rd party projects:
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT

View File

@ -1,9 +1,5 @@
ONLYOFFICE Applications example uses code from the following 3rd party projects:
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT

View File

@ -48,6 +48,7 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
@ -57,7 +58,9 @@ import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
@ -78,6 +81,11 @@ public class IndexServlet extends HttpServlet {
return;
}
// charset for response headers if upload or convert
if (action.matches("upload|convert")) {
response.setCharacterEncoding("UTF-8");
}
DocumentManager.init(request, response);
// create a variable to display information about the application and error messages
@ -121,6 +129,9 @@ public class IndexServlet extends HttpServlet {
case "reference":
reference(request, response, writer);
break;
case "restore":
restore(request, response, writer);
break;
default:
break;
}
@ -310,9 +321,9 @@ public class IndexServlet extends HttpServlet {
connection.disconnect();
// remove source file ?
// File sourceFile = new File(DocumentManager.StoragePath(fileName, null));
// sourceFile.delete();
// remove source file
File sourceFile = new File(DocumentManager.storagePath(fileName, null));
sourceFile.delete();
fileName = correctName;
@ -446,7 +457,7 @@ public class IndexServlet extends HttpServlet {
private static void csv(final HttpServletRequest request,
final HttpServletResponse response,
final PrintWriter writer) {
String fileName = "assets/sample/csv.csv";
String fileName = "assets/document-templates/sample/csv.csv";
URL fileUrl = Thread.currentThread().getContextClassLoader().getResource(fileName);
Path filePath = null;
try {
@ -461,7 +472,7 @@ public class IndexServlet extends HttpServlet {
private static void assets(final HttpServletRequest request,
final HttpServletResponse response,
final PrintWriter writer) {
String fileName = "assets/sample/" + FileUtility.getFileName(request.getParameter("name"));
String fileName = "assets/document-templates/sample/" + FileUtility.getFileName(request.getParameter("name"));
URL fileUrl = Thread.currentThread().getContextClassLoader().getResource(fileName);
Path filePath = null;
try {
@ -695,6 +706,8 @@ public class IndexServlet extends HttpServlet {
return;
}
boolean directUrl = (boolean) body.get("directUrl");
HashMap<String, Object> fileKey = new HashMap<>();
fileKey.put("fileName", fileName);
fileKey.put("userAddress", DocumentManager.curUserHostAddress(null));
@ -704,9 +717,9 @@ public class IndexServlet extends HttpServlet {
referenceData.put("fileKey", gson.toJson(fileKey));
HashMap<String, Object> data = new HashMap<>();
data.put("fileType", FileUtility.getFileExtension(fileName));
data.put("fileType", FileUtility.getFileExtension(fileName).replace(".", ""));
data.put("url", DocumentManager.getDownloadUrl(fileName, true));
data.put("directUrl", DocumentManager.getDownloadUrl(fileName, true));
data.put("directUrl", directUrl ? DocumentManager.getDownloadUrl(fileName, false) : null);
data.put("referenceData", referenceData);
data.put("path", fileName);
@ -721,6 +734,97 @@ public class IndexServlet extends HttpServlet {
}
}
private static void restore(final HttpServletRequest request,
final HttpServletResponse response,
final PrintWriter writer) {
try {
Scanner scanner = new Scanner(request.getInputStream());
scanner.useDelimiter("\\A");
String bodyString = scanner.hasNext() ? scanner.next() : "";
scanner.close();
JSONParser parser = new JSONParser();
JSONObject body = (JSONObject) parser.parse(bodyString);
String sourceBasename = (String) body.get("fileName");
Integer version = ((Long) body.get("version")).intValue();
String userID = (String) body.get("userId");
String sourceStringFile = DocumentManager.storagePath(sourceBasename, null);
File sourceFile = new File(sourceStringFile);
Path sourcePathFile = sourceFile.toPath();
String historyDirectory = DocumentManager.historyDir(sourceStringFile);
Integer bumpedVersion = DocumentManager.getFileVersion(historyDirectory);
String bumpedVersionStringDirectory = DocumentManager.versionDir(historyDirectory, bumpedVersion);
File bumpedVersionDirectory = new File(bumpedVersionStringDirectory);
if (!bumpedVersionDirectory.exists()) {
bumpedVersionDirectory.mkdir();
}
Path bumpedKeyPathFile = Paths.get(bumpedVersionStringDirectory, "key.txt");
String bumpedKeyStringFile = bumpedKeyPathFile.toString();
File bumpedKeyFile = new File(bumpedKeyStringFile);
String bumpedKey = ServiceConverter.generateRevisionId(
DocumentManager.curUserHostAddress(null)
+ "/"
+ sourceBasename
+ "/"
+ Long.toString(sourceFile.lastModified())
);
FileWriter bumpedKeyFileWriter = new FileWriter(bumpedKeyFile);
bumpedKeyFileWriter.write(bumpedKey);
bumpedKeyFileWriter.close();
User user = Users.getUser(userID);
Path bumpedChangesPathFile = Paths.get(bumpedVersionStringDirectory, "changes.json");
String bumpedChangesStringFile = bumpedChangesPathFile.toString();
File bumpedChangesFile = new File(bumpedChangesStringFile);
JSONObject bumpedChangesUser = new JSONObject();
bumpedChangesUser.put("id", user.getId());
bumpedChangesUser.put("name", user.getName());
JSONObject bumpedChangesChangesItem = new JSONObject();
bumpedChangesChangesItem.put("created", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
bumpedChangesChangesItem.put("user", bumpedChangesUser);
JSONArray bumpedChangesChanges = new JSONArray();
bumpedChangesChanges.add(bumpedChangesChangesItem);
JSONObject bumpedChanges = new JSONObject();
bumpedChanges.put("serverVersion", null);
bumpedChanges.put("changes", bumpedChangesChanges);
String bumpedChangesContent = bumpedChanges.toJSONString();
FileWriter bumpedChangesFileWriter = new FileWriter(bumpedChangesFile);
bumpedChangesFileWriter.write(bumpedChangesContent);
bumpedChangesFileWriter.close();
String sourceExtension = FileUtility.getFileExtension(sourceBasename);
String previousBasename = "prev" + sourceExtension;
Path bumpedFile = Paths.get(bumpedVersionStringDirectory, previousBasename);
Files.move(sourcePathFile, bumpedFile);
String recoveryVersionStringDirectory = DocumentManager.versionDir(historyDirectory, version);
Path recoveryPathFile = Paths.get(recoveryVersionStringDirectory, previousBasename);
String recoveryStringFile = recoveryPathFile.toString();
FileInputStream recoveryStream = new FileInputStream(recoveryStringFile);
DocumentManager.createFile(sourcePathFile, recoveryStream);
recoveryStream.close();
JSONObject responseBody = new JSONObject();
responseBody.put("error", null);
responseBody.put("success", true);
String responseContent = responseBody.toJSONString();
writer.write(responseContent);
} catch (Exception error) {
error.printStackTrace();
JSONObject responseBody = new JSONObject();
responseBody.put("error", error.getMessage());
responseBody.put("success", false);
String responseContent = responseBody.toJSONString();
writer.write(responseContent);
}
}
// process get request
@Override
protected void doGet(final HttpServletRequest request,
@ -735,6 +839,12 @@ public class IndexServlet extends HttpServlet {
processRequest(request, response);
}
@Override
protected void doPut(final HttpServletRequest request,
final HttpServletResponse response) throws ServletException, IOException {
processRequest(request, response);
}
// get servlet information
@Override
public String getServletInfo() {

View File

@ -306,7 +306,12 @@ public final class DocumentManager {
String demoName = (sample ? "sample." : "new.") + fileExt;
// get the path to the sample document
String demoPath = "assets" + File.separator + (sample ? "sample" : "new") + File.separator;
String demoPath = "assets"
+ File.separator
+ "document-templates"
+ File.separator
+ (sample ? "sample" : "new")
+ File.separator;
// get a file name with an index if the file with such a name already exists
String fileName = getCorrectName(demoName, null);

View File

@ -213,14 +213,15 @@ public final class ServiceConverter {
connection.connect();
try (OutputStream os = connection.getOutputStream()) {
os.write(bodyByte);
}
int statusCode = connection.getResponseCode();
if (statusCode != HttpServletResponse.SC_OK) { // checking status code
connection.disconnect();
throw new Exception("Conversion service returned status: " + statusCode);
}
try (OutputStream os = connection.getOutputStream()) {
os.write(bodyByte);
}
InputStream stream = connection.getInputStream();

View File

@ -86,11 +86,11 @@ public final class Users {
true, new ArrayList<String>(), descriptionUserSecond, false));
add(new User("uid-3", "Hamish Mitchell", "mitchell@example.com",
"group-3", Arrays.asList("group-2"), new CommentGroups(Arrays.asList("group-3", "group-2"),
Arrays.asList("group-2"), new ArrayList<String>()), Arrays.asList("group-2"),
Arrays.asList("group-2"), null), Arrays.asList("group-2"),
false, Arrays.asList("copy", "download", "print"),
descriptionUserThird, false));
add(new User("uid-0", null, null,
"", null, new CommentGroups(), new ArrayList<String>(),
"", null, null, null,
null, Arrays.asList("protect"), descriptionUserZero, false));
}};

View File

@ -1,4 +1,4 @@
version=1.5.1
version=1.7.0
filesize-max=5242880
storage-folder=app_data
@ -16,7 +16,7 @@ files.docservice.url.api=web-apps/apps/api/documents/api.js
files.docservice.url.preloader=web-apps/apps/api/documents/cache-scripts.html
files.docservice.url.example=
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese|zh-TW:Chinese (Taiwan)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
files.docservice.languages=en:English|hy:Armenian|az:Azerbaijani|eu:Basque|be:Belarusian|bg:Bulgarian|ca:Catalan|zh:Chinese (Simplified)|zh-TW:Chinese (Traditional)|cs:Czech|da:Danish|nl:Dutch|fi:Finnish|fr:French|gl:Galego|de:German|el:Greek|hu:Hungarian|id:Indonesian|it:Italian|ja:Japanese|ko:Korean|lo:Lao|lv:Latvian|ms:Malay (Malaysia)|no:Norwegian|pl:Polish|pt:Portuguese (Brazil)|pt-PT:Portuguese (Portugal)|ro:Romanian|ru:Russian|si:Sinhala (Sri Lanka)|sk:Slovak|sl:Slovenian|es:Spanish|sv:Swedish|tr:Turkish|uk:Ukrainian|vi:Vietnamese|aa-AA:Test Language
files.docservice.secret=
files.docservice.header=Authorization

View File

@ -173,6 +173,26 @@
}
};
function onRequestRestore(event) {
const query = new URLSearchParams(window.location.search)
const payload = {
fileName: query.get('fileName'),
version: event.data.version,
userId: config.editorConfig.user.id
}
const request = new XMLHttpRequest()
request.open('PUT', 'IndexServlet?type=restore')
request.send(JSON.stringify(payload))
request.onload = function () {
if (request.status != 200) {
response = JSON.parse(request.response)
innerAlert(response.error)
return
}
document.location.reload()
}
}
config = JSON.parse('<%= FileModel.serialize(Model) %>');
config.width = "100%";
config.height = "100%";
@ -186,6 +206,7 @@
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
"onRequestRestore": onRequestRestore
};
<%

View File

@ -11,5 +11,11 @@ module.exports = {
ecmaVersion: 'latest',
},
rules: {
'max-len': ['error', { code: 120 }],
'no-console': 'off',
'no-continue': 'off',
'no-extend-native': ['error', { exceptions: ['String'] }],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'no-prototype-builtins': 'off',
},
};

View File

@ -32,10 +32,6 @@ he - a robust HTML entity encoder/decoder written in JavaScript. (htt
License: MIT
License File: he.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -48,9 +44,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
{
"version": "1.5.1",
"version": "1.7.0",
"log": {
"appenders": [
{
@ -22,10 +22,6 @@
"apiUrl": "web-apps/apps/api/documents/api.js",
"preloaderUrl": "web-apps/apps/api/documents/cache-scripts.html",
"exampleUrl": null,
"viewedDocs": [".djvu", ".oxps", ".pdf", ".xps"],
"editedDocs": [".csv", ".docm", ".docx", ".docxf", ".dotm", ".dotx", ".epub", ".fb2", ".html", ".odp", ".ods", ".odt", ".otp", ".ots", ".ott", ".potm", ".potx", ".ppsm", ".ppsx", ".pptm", ".pptx", ".rtf", ".txt", ".xlsm", ".xlsx", ".xltm", ".xltx"],
"fillDocs": [".docx", ".oform"],
"convertedDocs": [".doc", ".dot", ".dps", ".dpt", ".epub", ".et", ".ett", ".fb2", ".fodp", ".fods", ".fodt", ".htm", ".html", ".mht", ".mhtml", ".odp", ".ods", ".odt", ".otp", ".ots", ".ott", ".pot", ".pps", ".ppt", ".rtf", ".stw", ".sxc", ".sxi", ".sxw", ".wps", ".wpt", ".xls", ".xlsb", ".xlt", ".xml"],
"storageFolder": "./files",
"storagePath": "/files",
"maxFileSize": 1073741824,
@ -54,8 +50,8 @@
"be": "Belarusian",
"bg": "Bulgarian",
"ca": "Catalan",
"zh": "Chinese",
"zh-TW": "Chinese (Taiwan)",
"zh": "Chinese (Simplified)",
"zh-TW": "Chinese (Traditional)",
"cs": "Czech",
"da": "Danish",
"nl": "Dutch",

View File

@ -1,4 +1,4 @@
/**
/**
*
* (c) Copyright Ascensio System SIA 2023
*
@ -16,42 +16,43 @@
*
*/
var cache = {};
let cache = {};
// write the key value and its creation time to the cache
exports.put = function (key, value) {
cache[key] = { value:value, time: new Date().getTime()};
}
exports.put = function put(key, value) {
cache[key] = { value, time: new Date().getTime() };
};
// check if the given key is in the cache
exports.containsKey = function (key) {
if (typeof cache[key] == "undefined"){
return false;
}
exports.containsKey = function containsKey(key) {
if (typeof cache[key] === 'undefined') {
return false;
}
var secondsCache = 30;
const secondsCache = 30;
var t1 = new Date(cache[key].time + (1000 * secondsCache)); // get the creation time of the given key and add 30 seconds to it
var t2 = new Date(); // get the current time
if (t1 < t2 ){ // if the current time is greater
delete cache[key]; // delete the given key from the cache
return false;
}
// get the creation time of the given key and add 30 seconds to it
const t1 = new Date(cache[key].time + (1000 * secondsCache));
const t2 = new Date(); // get the current time
if (t1 < t2) { // if the current time is greater
delete cache[key]; // delete the given key from the cache
return false;
}
return true;
}
return true;
};
// get the given key from the cache
exports.get = function (key) {
return cache[key];
}
exports.get = function get(key) {
return cache[key];
};
// delete the given key from the cache
exports.delete = function (key) {
delete cache[key];
}
exports.delete = function deleteKey(key) {
delete cache[key];
};
// clear the cache
exports.clear = function () {
cache = {};
}
exports.clear = function clear() {
cache = {};
};

View File

@ -1,4 +1,3 @@
"use strict";
/**
*
* (c) Copyright Ascensio System SIA 2023
@ -17,488 +16,596 @@
*
*/
const path = require("path");
const fileSystem = require("fs");
const fileUtility = require("./fileUtility");
const documentService = require("./documentService");
const path = require('path');
const fileSystem = require('fs');
const configServer = require('config').get('server');
const storageConfigFolder = configServer.get("storageFolder");
const fileUtility = require('./fileUtility');
const documentService = require('./documentService');
function docManager(req, res) {
this.req = req;
this.res = res;
}
const storageConfigFolder = configServer.get('storageFolder');
const DocManager = function DocManager(req, res) {
this.req = req;
this.res = res;
};
// check if the path exists or not
docManager.prototype.existsSync = function(path) {
let res = true;
try {
fileSystem.accessSync(path, fileSystem.F_OK); // synchronously test the user's permissions for the directory specified by path; the directory is visible to the calling process
} catch (e) { // the response is set to false, if an error occurs
res = false;
}
return res;
DocManager.prototype.existsSync = function existsSync(directory) {
let res = true;
try {
// synchronously test the user's permissions for the directory specified by path;
// the directory is visible to the calling process
fileSystem.accessSync(directory, fileSystem.F_OK);
} catch (e) { // the response is set to false, if an error occurs
res = false;
}
return res;
};
// create a new directory if it doesn't exist
docManager.prototype.createDirectory = function(path) {
if (!this.existsSync(path)) {
fileSystem.mkdirSync(path);
}
DocManager.prototype.createDirectory = function createDirectory(directory) {
if (!this.existsSync(directory)) {
fileSystem.mkdirSync(directory);
}
};
// get the language from the request
docManager.prototype.getLang = function () {
if (new RegExp("^[a-z]{2}(-[A-Z]{2})?$", "i").test(this.req.query.lang)) {
return this.req.query.lang;
} else { // the default language value is English
return "en"
}
DocManager.prototype.getLang = function getLang() {
if (/^[a-z]{2}(-[A-Z]{2})?$/i.test(this.req.query.lang)) {
return this.req.query.lang;
} // the default language value is English
return 'en';
};
// get customization parameters
docManager.prototype.getCustomParams = function () {
let params = "";
DocManager.prototype.getCustomParams = function getCustomParams() {
let params = '';
const userid = this.req.query.userid; // user id
params += (userid ? "&userid=" + userid : "");
const { userid } = this.req.query; // user id
params += (userid ? `&userid=${userid}` : '');
const lang = this.req.query.lang; // language
params += (lang ? "&lang=" + this.getLang() : "");
const { lang } = this.req.query; // language
params += (lang ? `&lang=${this.getLang()}` : '');
const directUrl = this.req.query.directUrl; // directUrl
params += (directUrl ? "&directUrl=" + (directUrl == "true") : "");
const { directUrl } = this.req.query; // directUrl
params += (directUrl ? `&directUrl=${directUrl === 'true'}` : '');
const fileName = this.req.query.fileName; // file name
params += (fileName ? "&fileName=" + fileName : "");
const { fileName } = this.req.query; // file name
params += (fileName ? `&fileName=${fileName}` : '');
const mode = this.req.query.mode; // mode: view/edit/review/comment/fillForms/embedded
params += (mode ? "&mode=" + mode : "");
const { mode } = this.req.query; // mode: view/edit/review/comment/fillForms/embedded
params += (mode ? `&mode=${mode}` : '');
const type = this.req.query.type; // type: embedded/mobile/desktop
params += (type ? "&type=" + type : "");
const { type } = this.req.query; // type: embedded/mobile/desktop
params += (type ? `&type=${type}` : '');
return params;
return params;
};
// get the correct file name if such a name already exists
docManager.prototype.getCorrectName = function (fileName, userAddress) {
const baseName = fileUtility.getFileName(fileName, true); // get file name from the url without extension
const ext = fileUtility.getFileExtension(fileName); // get file extension from the url
let name = baseName + ext; // get full file name
let index = 1;
DocManager.prototype.getCorrectName = function getCorrectName(fileName, userAddress) {
const baseName = fileUtility.getFileName(fileName, true); // get file name from the url without extension
const ext = fileUtility.getFileExtension(fileName); // get file extension from the url
let name = baseName + ext; // get full file name
let index = 1;
while (this.existsSync(this.storagePath(name, userAddress))) { // if the file with such a name already exists in this directory
name = baseName + " (" + index + ")" + ext; // add an index after its base name
index++;
}
// if the file with such a name already exists in this directory
while (this.existsSync(this.storagePath(name, userAddress))) {
name = `${baseName} (${index})${ext}`; // add an index after its base name
index += 1;
}
return name;
return name;
};
// processes a request editnew
docManager.prototype.RequestEditnew = function (req, fileName, user) {
if (req.params['id'] != fileName){ // processes a repeated request editnew
this.fileRemove(req.params['id']);
fileName = this.getCorrectName(req.params['id']);
}
this.fileSizeZero(fileName);
this.saveFileData(fileName, user.id, user.name);
DocManager.prototype.requestEditnew = function requestEditnew(req, fileName, user) {
let correctName = fileName;
if (req.params.id !== fileName) { // processes a repeated request editnew
this.fileRemove(req.params.id);
correctName = this.getCorrectName(req.params.id);
}
this.fileSizeZero(correctName);
this.saveFileData(correctName, user.id, user.name);
return fileName;
}
return correctName;
};
// delete a file with its history
docManager.prototype.fileRemove = function (fileName) {
const filePath = this.storagePath(fileName); // get the path to this file
fileSystem.unlinkSync(filePath); // and delete it
DocManager.prototype.fileRemove = function fileRemove(fileName) {
const filePath = this.storagePath(fileName); // get the path to this file
fileSystem.unlinkSync(filePath); // and delete it
const userAddress = this.curUserHostAddress();
const historyPath = this.historyPath(fileName, userAddress, true);
this.cleanFolderRecursive(historyPath, true); // clean all the files from the history folder
}
const userAddress = this.curUserHostAddress();
const historyPath = this.historyPath(fileName, userAddress, true);
this.cleanFolderRecursive(historyPath, true); // clean all the files from the history folder
};
// create a zero-size file
docManager.prototype.fileSizeZero = function (fileName) {
var path = this.storagePath(fileName);
var fh = fileSystem.openSync(path, 'w');
fileSystem.closeSync(fh);
}
DocManager.prototype.fileSizeZero = function fileSizeZero(fileName) {
const storagePath = this.storagePath(fileName);
const fh = fileSystem.openSync(storagePath, 'w');
fileSystem.closeSync(fh);
};
// create demo document
docManager.prototype.createDemo = function (isSample, fileExt, userid, username, wopi) {
// eslint-disable-next-line no-unused-vars
DocManager.prototype.createDemo = function createDemo(isSample, fileExt, userid, username, wopi) {
const demoName = `${isSample ? 'sample' : 'new'}.${fileExt}`;
const fileName = this.getCorrectName(demoName); // get the correct file name if such a name already exists
const demoName = (isSample ? "sample" : "new") + "." + fileExt;
const fileName = this.getCorrectName(demoName); // get the correct file name if such a name already exists
// copy sample document of a necessary extension to the storage path
this.copyFile(path.join(__dirname, '..', 'public', 'assets', 'document-templates', isSample
? 'sample' : 'new', demoName), this.storagePath(fileName));
this.copyFile(path.join(__dirname, "..","public", "assets", isSample ? "sample" : "new", demoName), this.storagePath(fileName)); // copy sample document of a necessary extension to the storage path
this.saveFileData(fileName, userid, username); // save file data to the file
this.saveFileData(fileName, userid, username); // save file data to the file
return fileName;
return fileName;
};
// save file data to the file
docManager.prototype.saveFileData = function (fileName, userid, username, userAddress) {
if (!userAddress) {
userAddress = this.curUserHostAddress(); // get current user host address
}
// get full creation date of the document
const date_create = fileSystem.statSync(this.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();
const date_format = date_create.getFullYear() + "-" + month + "-" + date_create.getDate() + " " + date_create.getHours() + ":" + minutes + ":" + sec;
DocManager.prototype.saveFileData = function saveFileData(fileName, userid, username, userAddress) {
let address = userAddress;
if (!address) {
address = this.curUserHostAddress(); // get current user host address
}
// get full creation date of the document
const dateCreate = fileSystem.statSync(this.storagePath(fileName, address)).mtime;
const minutes = (dateCreate.getMinutes() < 10 ? '0' : '') + dateCreate.getMinutes().toString();
const month = (dateCreate.getMonth() < 9 ? '0' : '') + (parseInt(dateCreate.getMonth().toString(), 10) + 1);
const sec = (dateCreate.getSeconds() < 10 ? '0' : '') + dateCreate.getSeconds().toString();
const dateFormat = `${dateCreate.getFullYear()}-${month}-${dateCreate.getDate()} `
+ `${dateCreate.getHours()}:${minutes}:${sec}`;
const file_info = this.historyPath(fileName, userAddress, true); // get file history information
this.createDirectory(file_info); // create a new history directory if it doesn't exist
const fileInfo = this.historyPath(fileName, address, true); // get file history information
this.createDirectory(fileInfo); // create a new history directory if it doesn't exist
fileSystem.writeFileSync(path.join(file_info, fileName + ".txt"), date_format + "," + userid + "," + username); // write all the file information to a new txt file
// write all the file information to a new txt file
fileSystem.writeFileSync(path.join(fileInfo, `${fileName}.txt`), `${dateFormat},${userid},${username}`);
};
// get file data
docManager.prototype.getFileData = function (fileName, userAddress) {
const history = path.join(this.historyPath(fileName, userAddress, true), fileName + ".txt"); // get the path to the file with file information
if (!this.existsSync(history)) { // if such a file doesn't exist
return ["2017-01-01", "uid-1", "John Smith"]; // return default information
}
DocManager.prototype.getFileData = function getFileData(fileName, userAddress) {
// get the path to the file with file information
const history = path.join(this.historyPath(fileName, userAddress, true), `${fileName}.txt`);
if (!this.existsSync(history)) { // if such a file doesn't exist
return ['2017-01-01', 'uid-1', 'John Smith']; // return default information
}
return ((fileSystem.readFileSync(history)).toString()).split(",");
return ((fileSystem.readFileSync(history)).toString())
.split(',');
};
// get server url
docManager.prototype.getServerUrl = function (forDocumentServer) {
return (forDocumentServer && !!configServer.get("exampleUrl")) ? configServer.get("exampleUrl") : this.getServerPath();
DocManager.prototype.getServerUrl = function getServerUrl(forDocumentServer) {
return (forDocumentServer && !!configServer.get('exampleUrl'))
? configServer.get('exampleUrl') : this.getServerPath();
};
// get server address from the request
docManager.prototype.getServerPath = function () {
return this.getServerHost() + (this.req.headers["x-forwarded-path"] || this.req.baseUrl);
DocManager.prototype.getServerPath = function getServerPath() {
return this.getServerHost() + (this.req.headers['x-forwarded-path'] || this.req.baseUrl);
};
// get host address from the request
docManager.prototype.getServerHost = function () {
return this.getProtocol() + "://" + (this.req.headers["x-forwarded-host"] || this.req.headers["host"]);
DocManager.prototype.getServerHost = function getServerHost() {
return `${this.getProtocol()}://${this.req.headers['x-forwarded-host'] || this.req.headers.host}`
+ `${this.req.headers['x-forwarded-prefix'] || ''}`;
};
// get protocol from the request
docManager.prototype.getProtocol = function () {
return this.req.headers["x-forwarded-proto"] || this.req.protocol;
DocManager.prototype.getProtocol = function getProtocol() {
return this.req.headers['x-forwarded-proto'] || this.req.protocol;
};
// get callback url
docManager.prototype.getCallback = function (fileName) {
const server = this.getServerUrl(true);
const hostAddress = this.curUserHostAddress();
const handler = "/track?filename=" + encodeURIComponent(fileName) + "&useraddress=" + encodeURIComponent(hostAddress); // get callback handler
DocManager.prototype.getCallback = function getCallback(fileName) {
const server = this.getServerUrl(true);
const hostAddress = this.curUserHostAddress();
// get callback handler
const handler = `/track?filename=${encodeURIComponent(fileName)}&useraddress=${encodeURIComponent(hostAddress)}`;
return server + handler;
return server + handler;
};
// get url to the created file
docManager.prototype.getCreateUrl = function (docType, userid, type, lang) {
const server = this.getServerUrl();
var ext = this.getInternalExtension(docType).replace(".", "");
const handler = "/editor?fileExt=" + ext + "&userid=" + userid + "&type=" + type + "&lang=" + lang;
DocManager.prototype.getCreateUrl = function getCreateUrl(docType, userid, type, lang) {
const server = this.getServerUrl();
const ext = this.getInternalExtension(docType).replace('.', '');
const handler = `/editor?fileExt=${ext}&userid=${userid}&type=${type}&lang=${lang}`;
return server + handler;
}
// get url to download a file
docManager.prototype.getDownloadUrl = function (fileName, forDocumentServer) {
const server = this.getServerUrl(forDocumentServer);
var handler = "/download?fileName=" + encodeURIComponent(fileName);
if (forDocumentServer) {
const hostAddress = this.curUserHostAddress();
handler += "&useraddress=" + encodeURIComponent(hostAddress);
}
return server + handler;
return server + handler;
};
docManager.prototype.storageRootPath = function (userAddress) {
return path.join(storageConfigFolder, this.curUserHostAddress(userAddress)); // get the path to the directory for the host address
}
// get url to download a file
DocManager.prototype.getDownloadUrl = function getDownloadUrl(fileName, forDocumentServer) {
const server = this.getServerUrl(forDocumentServer);
let handler = `/download?fileName=${encodeURIComponent(fileName)}`;
if (forDocumentServer) {
const hostAddress = this.curUserHostAddress();
handler += `&useraddress=${encodeURIComponent(hostAddress)}`;
}
return server + handler;
};
DocManager.prototype.storageRootPath = function storageRootPath(userAddress) {
// get the path to the directory for the host address
return path.join(storageConfigFolder, this.curUserHostAddress(userAddress));
};
// get the storage path of the given file
docManager.prototype.storagePath = function (fileName, userAddress) {
fileName = fileUtility.getFileName(fileName); // get the file name with extension
const directory = this.storageRootPath(userAddress);
this.createDirectory(directory); // create a new directory if it doesn't exist
return path.join(directory, fileName); // put the given file to this directory
DocManager.prototype.storagePath = function storagePath(fileName, userAddress) {
const fileNameExt = fileUtility.getFileName(fileName); // get the file name with extension
const directory = this.storageRootPath(userAddress);
this.createDirectory(directory); // create a new directory if it doesn't exist
return path.join(directory, fileNameExt); // put the given file to this directory
};
// get the path to the forcesaved file version
docManager.prototype.forcesavePath = function (fileName, userAddress, create) {
let directory = this.storageRootPath(userAddress);
if (!this.existsSync(directory)) { // the directory with host address doesn't exist
return "";
}
directory = path.join(directory, fileName + "-history"); // get the path to the history of the given file
if (!create && !this.existsSync(directory)) { // the history directory doesn't exist and we are not supposed to create it
return "";
}
this.createDirectory(directory); // create history directory if it doesn't exist
directory = path.join(directory, fileName); // and get the path to the given file
if (!create && !this.existsSync(directory)) {
return "";
}
return directory;
DocManager.prototype.forcesavePath = function forcesavePath(fileName, userAddress, create) {
let directory = this.storageRootPath(userAddress);
if (!this.existsSync(directory)) { // the directory with host address doesn't exist
return '';
}
directory = path.join(directory, `${fileName}-history`); // get the path to the history of the given file
// the history directory doesn't exist and we are not supposed to create it
if (!create && !this.existsSync(directory)) {
return '';
}
this.createDirectory(directory); // create history directory if it doesn't exist
directory = path.join(directory, fileName); // and get the path to the given file
if (!create && !this.existsSync(directory)) {
return '';
}
return directory;
};
// create the path to the file history
docManager.prototype.historyPath = function (fileName, userAddress, create) {
let directory = this.storageRootPath(userAddress);
if (!this.existsSync(directory)) {
return "";
}
directory = path.join(directory, fileName + "-history");
if (!create && !this.existsSync(path.join(directory, "1"))) {
return "";
}
return directory;
DocManager.prototype.historyPath = function historyPath(fileName, userAddress, create) {
let directory = this.storageRootPath(userAddress);
if (!this.existsSync(directory)) {
return '';
}
directory = path.join(directory, `${fileName}-history`);
if (!create && !this.existsSync(path.join(directory, '1'))) {
return '';
}
return directory;
};
// get the path to the specified file version
docManager.prototype.versionPath = function (fileName, userAddress, version) {
const historyPath = this.historyPath(fileName, userAddress, true); // get the path to the history of a given file or create it if it doesn't exist
return path.join(historyPath, "" + version);
DocManager.prototype.versionPath = function versionPath(fileName, userAddress, version) {
// get the path to the history of a given file or create it if it doesn't exist
const historyPath = this.historyPath(fileName, userAddress, true);
return path.join(historyPath, `${version}`);
};
// get the path to the previous file version
docManager.prototype.prevFilePath = function (fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), "prev" + fileUtility.getFileExtension(fileName));
DocManager.prototype.prevFilePath = function prevFilePath(fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), `prev${fileUtility.getFileExtension(fileName)}`);
};
// get the path to the file with document versions differences
docManager.prototype.diffPath = function (fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), "diff.zip");
DocManager.prototype.diffPath = function diffPath(fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), 'diff.zip');
};
// get the path to the file with document changes
docManager.prototype.changesPath = function (fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), "changes.txt");
DocManager.prototype.changesPath = function changesPath(fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), 'changes.txt');
};
// get the path to the file with key value in it
docManager.prototype.keyPath = function (fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), "key.txt");
DocManager.prototype.keyPath = function keyPath(fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), 'key.txt');
};
// get the path to the file with the user information
docManager.prototype.changesUser = function (fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), "user.txt");
DocManager.prototype.changesUser = function changesUser(fileName, userAddress, version) {
return path.join(this.versionPath(fileName, userAddress, version), 'user.txt');
};
// get all the stored files
docManager.prototype.getStoredFiles = function () {
const userAddress = this.curUserHostAddress();
const directory = this.storageRootPath(userAddress);
this.createDirectory(directory);
const result = [];
const storedFiles = fileSystem.readdirSync(directory); // read the user host directory contents
for (let i = 0; i < storedFiles.length; i++) { // run through all the elements from the folder
const stats = fileSystem.lstatSync(path.join(directory, storedFiles[i])); // save element parameters
DocManager.prototype.getStoredFiles = function getStoredFiles() {
const userAddress = this.curUserHostAddress();
const directory = this.storageRootPath(userAddress);
this.createDirectory(directory);
const result = [];
const storedFiles = fileSystem.readdirSync(directory); // read the user host directory contents
for (let i = 0; i < storedFiles.length; i++) { // run through all the elements from the folder
const stats = fileSystem.lstatSync(path.join(directory, storedFiles[i])); // save element parameters
if (!stats.isDirectory()) { // if the element isn't a directory
let historyPath = this.historyPath(storedFiles[i], userAddress); // get the path to the file history
let version = 0;
if (historyPath != "") { // if the history path exists
version = this.countVersion(historyPath); // get the last file version
}
if (!stats.isDirectory()) { // if the element isn't a directory
const historyPath = this.historyPath(storedFiles[i], userAddress); // get the path to the file history
let version = 0;
if (historyPath !== '') { // if the history path exists
version = this.countVersion(historyPath); // get the last file version
}
const time = stats.mtime.getTime(); // get the time of element modification
const item = { // create an object with element data
time: time,
name: storedFiles[i],
documentType: fileUtility.getFileType(storedFiles[i]),
canEdit: configServer.get("editedDocs").indexOf(fileUtility.getFileExtension(storedFiles[i])) != -1,
version: version+1
};
const time = stats.mtime.getTime(); // get the time of element modification
const item = { // create an object with element data
time,
name: storedFiles[i],
documentType: fileUtility.getFileType(storedFiles[i]),
canEdit: fileUtility.getEditExtensions().indexOf(fileUtility.getFileExtension(storedFiles[i], true)) !== -1,
version: version + 1,
};
if (!result.length) { // if the result array is empty
result.push(item); // push the item object to it
} else {
let j = 0;
for (; j < result.length; j++) {
if (time > result[j].time) { // otherwise, run through all the objects from the result array
break;
}
}
result.splice(j, 0, item); // and add new object in ascending order of time
}
if (!result.length) { // if the result array is empty
result.push(item); // push the item object to it
} else {
let j = 0;
for (; j < result.length; j++) {
if (time > result[j].time) { // otherwise, run through all the objects from the result array
break;
}
}
result.splice(j, 0, item); // and add new object in ascending order of time
}
}
return result;
}
return result;
};
// get current user host address
docManager.prototype.curUserHostAddress = function (userAddress) {
if (!userAddress) // if user address isn't passed to the function
userAddress = this.req.headers["x-forwarded-for"] || this.req.connection.remoteAddress; // take it from the header or use the remote address
DocManager.prototype.curUserHostAddress = function curUserHostAddress(userAddress) {
let address = userAddress;
if (!address) { // if user address isn't passed to the function
// take it from the header or use the remote address
address = this.req.headers['x-forwarded-for'] || this.req.connection.remoteAddress;
}
return userAddress.replace(new RegExp("[^0-9a-zA-Z.=]", "g"), "_");
return address.replace(/[^0-9a-zA-Z.=]/g, '_');
};
// copy file
docManager.prototype.copyFile = function (exist, target) {
fileSystem.writeFileSync(target, fileSystem.readFileSync(exist));
DocManager.prototype.copyFile = function copyFile(exist, target) {
fileSystem.writeFileSync(target, fileSystem.readFileSync(exist));
};
// get an internal extension
docManager.prototype.getInternalExtension = function (fileType) {
if (fileType == fileUtility.fileType.word) // .docx for word type
return ".docx";
DocManager.prototype.getInternalExtension = function getInternalExtension(fileType) {
if (fileType === fileUtility.fileType.word) { // .docx for word type
return '.docx';
}
if (fileType == fileUtility.fileType.cell) // .xlsx for cell type
return ".xlsx";
if (fileType === fileUtility.fileType.cell) { // .xlsx for cell type
return '.xlsx';
}
if (fileType == fileUtility.fileType.slide) // .pptx for slide type
return ".pptx";
if (fileType === fileUtility.fileType.slide) { // .pptx for slide type
return '.pptx';
}
return ".docx"; // the default value is .docx
return '.docx'; // the default value is .docx
};
// get the template image url
docManager.prototype.getTemplateImageUrl = function (fileType) {
let path = this.getServerUrl(true);
if (fileType == fileUtility.fileType.word) // for word type
return path + "/images/file_docx.svg";
DocManager.prototype.getTemplateImageUrl = function getTemplateImageUrl(fileType) {
const serverUrl = this.getServerUrl(true);
if (fileType === fileUtility.fileType.word) { // for word type
return `${serverUrl}/images/file_docx.svg`;
}
if (fileType == fileUtility.fileType.cell) // for cell type
return path + "/images/file_xlsx.svg";
if (fileType === fileUtility.fileType.cell) { // for cell type
return `${serverUrl}/images/file_xlsx.svg`;
}
if (fileType == fileUtility.fileType.slide) // for slide type
return path + "/images/file_pptx.svg";
if (fileType === fileUtility.fileType.slide) { // for slide type
return `${serverUrl}/images/file_pptx.svg`;
}
return path + "/images/file_docx.svg"; // the default value
}
return `${serverUrl}/images/file_docx.svg`; // the default value
};
// get document key
docManager.prototype.getKey = function (fileName, userAddress) {
userAddress = userAddress || this.curUserHostAddress();
let key = userAddress + fileName; // get document key by adding local file url to the current user host address
DocManager.prototype.getKey = function getKey(fileName, userAddress) {
const address = userAddress || this.curUserHostAddress();
let key = address + fileName; // get document key by adding local file url to the current user host address
let historyPath = this.historyPath(fileName, userAddress); // get the path to the file history
if (historyPath != ""){ // if the path to the file history exists
key += this.countVersion(historyPath); // add file version number to the document key
}
const historyPath = this.historyPath(fileName, address); // get the path to the file history
if (historyPath !== '') { // if the path to the file history exists
key += this.countVersion(historyPath); // add file version number to the document key
}
let storagePath = this.storagePath(fileName, userAddress); // get the storage path to the given file
const stat = fileSystem.statSync(storagePath); // get file information
key += stat.mtime.getTime(); // and add creation time to the document key
const storagePath = this.storagePath(fileName, address); // get the storage path to the given file
const stat = fileSystem.statSync(storagePath); // get file information
key += stat.mtime.getTime(); // and add creation time to the document key
return documentService.generateRevisionId(key); // generate the document key value
return documentService.generateRevisionId(key); // generate the document key value
};
// get current date
docManager.prototype.getDate = function (date) {
const minutes = (date.getMinutes() < 10 ? '0' : '') + date.getMinutes().toString();
return date.getMonth() + "/" + date.getDate() + "/" + date.getFullYear() + " " + date.getHours() + ":" + minutes;
DocManager.prototype.getDate = function getDate(date) {
const minutes = (date.getMinutes() < 10 ? '0' : '') + date.getMinutes().toString();
return `${date.getMonth()}/${date.getDate()}/${date.getFullYear()} ${date.getHours()}:${minutes}`;
};
// get changes made in the file
docManager.prototype.getChanges = function (fileName) {
if (this.existsSync(fileName)) { // if the directory with such a file exists
return JSON.parse(fileSystem.readFileSync(fileName)); // read this file and parse it
}
return null;
DocManager.prototype.getChanges = function getChanges(fileName) {
if (this.existsSync(fileName)) { // if the directory with such a file exists
return JSON.parse(fileSystem.readFileSync(fileName)); // read this file and parse it
}
return null;
};
// get the last file version
docManager.prototype.countVersion = function(directory) {
let i = 0;
while (this.existsSync(path.join(directory, '' + (i + 1)))) { // run through all the file versions
i++; // and count them
}
return i;
DocManager.prototype.countVersion = function countVersion(directory) {
let i = 0;
while (this.existsSync(path.join(directory, `${i + 1}`))) { // run through all the file versions
i += 1; // and count them
}
return i;
};
// get file history information
docManager.prototype.getHistory = function (fileName, content, keyVersion, version) {
let oldVersion = false;
let contentJson = null;
if (content) { // if content is defined
if (content.changes && content.changes.length) { // and there are some modifications in the content
contentJson = content.changes[0]; // write these modifications to the json content
} else if (content.length){
contentJson = content[0]; // otherwise, write original content to the json content
oldVersion = true; // and note that this is an old version
} else {
content = false;
}
DocManager.prototype.getHistoryObject = function getHistoryObject(fileName, userAddr = null, userDirectUrl = null) {
const userAddress = userAddr || this.curUserHostAddress();
const historyPath = this.historyPath(fileName, userAddress);
const key = this.getKey(fileName);
const directUrl = this.getDownloadUrl(fileName);
const fileExt = fileUtility.getFileExtension(fileName);
const url = this.getDownloadUrl(fileName, true);
const history = [];
const historyData = [];
let countVersion = 1;
let changes = null;
let keyVersion = key;
if (historyPath !== '') {
countVersion = this.countVersion(historyPath) + 1; // get the number of file versions
for (let i = 1; i <= countVersion; i++) { // get keys to all the file versions
if (i < countVersion) {
const keyPath = this.keyPath(fileName, userAddress, i);
if (!fileSystem.existsSync(keyPath)) continue;
keyVersion = `${fileSystem.readFileSync(keyPath)}`;
} else {
keyVersion = key;
}
// write all the file history information
history.push(this.getHistory(fileName, changes, keyVersion, i));
const userUrl = i === countVersion ? directUrl : (`${this.getServerUrl(false)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}`);
const historyD = {
fileType: fileExt.slice(1),
version: i,
key: keyVersion,
url: i === countVersion ? url : (`${this.getServerUrl(true)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=prev${fileExt}&ver=${i}&useraddress=${userAddress}`),
directUrl: !userDirectUrl ? null : userUrl,
};
// check if the path to the file with document versions differences exists
if (i > 1 && this.existsSync(this.diffPath(fileName, userAddress, i - 1))) {
historyD.previous = { // write information about previous file version
fileType: historyData[i - 2].fileType,
key: historyData[i - 2].key,
url: historyData[i - 2].url,
directUrl: !userDirectUrl ? null : historyData[i - 2].directUrl,
};
const changesUrl = `${this.getServerUrl(true)}/history?fileName=`
+ `${encodeURIComponent(fileName)}&file=diff.zip&ver=${i - 1}&useraddress=${userAddress}`;
historyD.changesUrl = changesUrl; // get the path to the diff.zip file and write it to the history object
}
historyData.push(historyD);
if (i < countVersion) {
// get the path to the file with document changes
const changesFile = this.changesPath(fileName, userAddress, i);
changes = this.getChanges(changesFile); // get changes made in the file
}
}
} else { // if history path is empty
// write the history information about the last file version
history.push(this.getHistory(fileName, changes, keyVersion, countVersion));
historyData.push({
fileType: fileExt.slice(1),
version: countVersion,
key,
url,
directUrl: !userDirectUrl ? null : directUrl,
});
}
const userAddress = this.curUserHostAddress();
const username = content ? (oldVersion ? contentJson.username : contentJson.user.name) : (this.getFileData(fileName, userAddress))[2];
const userid = content ? (oldVersion ? contentJson.userid : contentJson.user.id) : (this.getFileData(fileName, userAddress))[1];
const created = content ? (oldVersion ? contentJson.date : contentJson.created) : (this.getFileData(fileName, userAddress))[0];
const res = (content && !oldVersion) ? content : {changes: content};
res.key = keyVersion; // write the information about the user, creation time, key and version to the result object
res.version = version;
res.created = created;
res.user = {
id: userid,
name: username != "null" ? username : null
};
return { history, historyData, countVersion };
};
// get file history information
DocManager.prototype.getHistory = function getHistory(fileName, content, keyVersion, version) {
let oldVersion = false;
let contentJson = null;
let fileContent = content;
let userNameFromJson = null;
let userIdFromJson = null;
let createdFromJson = null;
if (fileContent) { // if content is defined
if (fileContent.changes && fileContent.changes.length) { // and there are some modifications in the content
[contentJson] = fileContent.changes; // write these modifications to the json content
} else if (fileContent.length) {
[contentJson] = fileContent; // otherwise, write original content to the json content
oldVersion = true; // and note that this is an old version
} else {
fileContent = false;
}
}
return res;
const userAddress = this.curUserHostAddress();
if (content && contentJson) {
userNameFromJson = oldVersion ? contentJson.username : contentJson.user.name;
userIdFromJson = oldVersion ? contentJson.userid : contentJson.user.id;
createdFromJson = oldVersion ? contentJson.date : contentJson.created;
}
const username = userNameFromJson || (this.getFileData(fileName, userAddress))[2];
const userid = userIdFromJson || (this.getFileData(fileName, userAddress))[1];
const created = createdFromJson || (this.getFileData(fileName, userAddress))[0];
const res = (fileContent && !oldVersion) ? fileContent : { changes: fileContent };
res.key = keyVersion; // write the information about the user, creation time, key and version to the result object
res.version = version;
res.created = created;
res.user = {
id: userid,
name: username !== 'null' ? username : null,
};
return res;
};
// clean folder
docManager.prototype.cleanFolderRecursive = function (folder, me) {
if (fileSystem.existsSync(folder)) { // if the given folder exists
const files = fileSystem.readdirSync(folder);
files.forEach((file) => { // for each file from the folder
const curPath = path.join(folder, file); // get its current path
if (fileSystem.lstatSync(curPath).isDirectory()) {
this.cleanFolderRecursive(curPath, true); // for each folder included in this one repeat the same procedure
} else {
fileSystem.unlinkSync(curPath); // remove the file
}
});
if (me) {
fileSystem.rmdirSync(folder);
}
DocManager.prototype.cleanFolderRecursive = function cleanFolderRecursive(folder, me) {
if (fileSystem.existsSync(folder)) { // if the given folder exists
const files = fileSystem.readdirSync(folder);
files.forEach((file) => { // for each file from the folder
const curPath = path.join(folder, file); // get its current path
if (fileSystem.lstatSync(curPath).isDirectory()) {
this.cleanFolderRecursive(curPath, true); // for each folder included in this one repeat the same procedure
} else {
fileSystem.unlinkSync(curPath); // remove the file
}
});
if (me) {
fileSystem.rmdirSync(folder);
}
}
};
// get files information
docManager.prototype.getFilesInfo = function (fileId) {
const userAddress = this.curUserHostAddress();
const directory = this.storageRootPath(userAddress);
const filesInDirectory = this.getStoredFiles(); // get all the stored files from the folder
let responseArray = [];
let responseObject;
for (let currentFile = 0; currentFile < filesInDirectory.length; currentFile++) { // run through all the files from the directory
const file = filesInDirectory[currentFile];
const stats = fileSystem.lstatSync(path.join(directory, file.name)); // get file information
const fileObject = { // write file parameters to the file object
version: file.version,
id: this.getKey(file.name),
contentLength: `${(stats.size/1024).toFixed(2)} KB`,
pureContentLength: stats.size,
title: file.name,
updated: stats.mtime
};
if (fileId !== undefined) { // if file id is defined
if (this.getKey(file.name) == fileId) { // and it is equal to the document key value
responseObject = fileObject; // response object will be equal to the file object
break;
}
}
else responseArray.push(fileObject); // otherwise, push file object to the response array
DocManager.prototype.getFilesInfo = function getFilesInfo(fileId) {
const userAddress = this.curUserHostAddress();
const directory = this.storageRootPath(userAddress);
const filesInDirectory = this.getStoredFiles(); // get all the stored files from the folder
const responseArray = [];
let responseObject;
// run through all the files from the directory
for (let currentFile = 0; currentFile < filesInDirectory.length; currentFile++) {
const file = filesInDirectory[currentFile];
const stats = fileSystem.lstatSync(path.join(directory, file.name)); // get file information
const fileObject = { // write file parameters to the file object
version: file.version,
id: this.getKey(file.name),
contentLength: `${(stats.size / 1024).toFixed(2)} KB`,
pureContentLength: stats.size,
title: file.name,
updated: stats.mtime,
};
if (fileId !== undefined) {
if (responseObject !== undefined) return responseObject;
else return "File not found";
}
else return responseArray;
if (fileId !== undefined) { // if file id is defined
if (this.getKey(file.name) === fileId) { // and it is equal to the document key value
responseObject = fileObject; // response object will be equal to the file object
break;
}
} else responseArray.push(fileObject); // otherwise, push file object to the response array
}
if (fileId !== undefined) {
if (responseObject !== undefined) return responseObject;
return 'File not found';
} return responseArray;
};
docManager.prototype.getInstanceId = function () {
return this.getServerUrl();
DocManager.prototype.getInstanceId = function getInstanceId() {
return this.getServerUrl();
};
// save all the functions to the docManager module to export it later in other files
module.exports = docManager;
// save all the functions to the DocManager module to export it later in other files
module.exports = DocManager;

View File

@ -1,4 +1,4 @@
/**
/**
*
* (c) Copyright Ascensio System SIA 2023
*
@ -17,229 +17,261 @@
*/
// get all the necessary values and modules
var urlModule = require("url");
var urllib = require("urllib");
var jwt = require("jsonwebtoken");
var fileUtility = require("./fileUtility");
var guidManager = require("./guidManager");
var configServer = require('config').get('server');
var siteUrl = configServer.get('siteUrl'); // the path to the editors installation
var cfgSignatureEnable = configServer.get('token.enable');
var cfgSignatureUseForRequest = configServer.get('token.useforrequest');
var cfgSignatureAuthorizationHeader = configServer.get('token.authorizationHeader');
var cfgSignatureAuthorizationHeaderPrefix = configServer.get('token.authorizationHeaderPrefix');
var cfgSignatureSecretExpiresIn = configServer.get('token.expiresIn');
var cfgSignatureSecret = configServer.get('token.secret');
var cfgSignatureSecretAlgorithmRequest = configServer.get('token.algorithmRequest');
const urlModule = require('url');
const urllib = require('urllib');
const jwt = require('jsonwebtoken');
const configServer = require('config').get('server');
const fileUtility = require('./fileUtility');
const guidManager = require('./guidManager');
var documentService = {};
const siteUrl = configServer.get('siteUrl'); // the path to the editors installation
const cfgSignatureEnable = configServer.get('token.enable');
const cfgSignatureUseForRequest = configServer.get('token.useforrequest');
const cfgSignatureAuthorizationHeader = configServer.get('token.authorizationHeader');
const cfgSignatureAuthorizationHeaderPrefix = configServer.get('token.authorizationHeaderPrefix');
const cfgSignatureSecretExpiresIn = configServer.get('token.expiresIn');
const cfgSignatureSecret = configServer.get('token.secret');
const cfgSignatureSecretAlgorithmRequest = configServer.get('token.algorithmRequest');
const documentService = {};
documentService.userIp = null;
// get the url of the converted file (synchronous)
documentService.getConvertedUriSync = function (documentUri, fromExtension, toExtension, documentRevisionId, callback) {
documentService.getConvertedUri(documentUri, fromExtension, toExtension, documentRevisionId, false, function (err, data) {
callback(err, data);
});
documentService.getConvertedUriSync = function getConvertedUriSync(
documentUri,
fromExtension,
toExtension,
documentRevisionId,
callback,
) {
documentService.getConvertedUri(documentUri, fromExtension, toExtension, documentRevisionId, false, (err, data) => {
callback(err, data);
});
};
// get the url of the converted file
documentService.getConvertedUri = function (documentUri, fromExtension, toExtension, documentRevisionId, async, callback, filePass = null, lang = null) {
fromExtension = fromExtension || fileUtility.getFileExtension(documentUri); // get the current document extension
documentService.getConvertedUri = function getConvertedUri(
documentUri,
fromExtension,
toExtension,
documentRevisionId,
async,
callback,
filePass = null,
lang = null,
) {
const fromExt = fromExtension || fileUtility.getFileExtension(documentUri); // get the current document extension
var title = fileUtility.getFileName(documentUri) || guidManager.newGuid(); // get the current document name or uuid
const title = fileUtility.getFileName(documentUri) || guidManager.newGuid(); // get the current document name or uuid
documentRevisionId = documentService.generateRevisionId(documentRevisionId || documentUri); // generate the document key value
// generate the document key value
const revisionId = documentService.generateRevisionId(documentRevisionId || documentUri);
var params = { // write all the conversion parameters to the params dictionary
async: async,
url: documentUri,
outputtype: toExtension.replace(".", ""),
filetype: fromExtension.replace(".", ""),
title: title,
key: documentRevisionId,
password: filePass,
region: lang,
};
const params = { // write all the conversion parameters to the params dictionary
async,
url: documentUri,
outputtype: toExtension.replace('.', ''),
filetype: fromExt.replace('.', ''),
title,
key: revisionId,
password: filePass,
region: lang,
};
var uri = siteUrl + configServer.get('converterUrl'); // get the absolute converter url
var headers = {
'Content-Type': 'application/json',
"Accept": "application/json"
};
const uri = siteUrl + configServer.get('converterUrl'); // get the absolute converter url
const headers = {
'Content-Type': 'application/json',
Accept: 'application/json',
};
if (cfgSignatureEnable && cfgSignatureUseForRequest) { // if the signature is enabled and it can be used for request
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params); // write signature authorization header
params.token = documentService.getToken(params); // get token and save it to the parameters
}
if (cfgSignatureEnable && cfgSignatureUseForRequest) { // if the signature is enabled and it can be used for request
// write signature authorization header
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
params.token = documentService.getToken(params); // get token and save it to the parameters
}
//parse url to allow request by relative url after https://github.com/node-modules/urllib/pull/321/commits/514de1924bf17a38a6c2db2a22a6bc3494c0a959
urllib.request(urlModule.parse(uri),
{
method: "POST",
headers: headers,
data: params
},
callback);
// parse url to allow request by relative url after
// https://github.com/node-modules/urllib/pull/321/commits/514de1924bf17a38a6c2db2a22a6bc3494c0a959
urllib.request(
urlModule.parse(uri),
{
method: 'POST',
headers,
data: params,
},
callback,
);
};
// generate the document key value
documentService.generateRevisionId = function (expectedKey) {
let maxKeyLength = 128; // the max key length is 128
if (expectedKey.length > maxKeyLength) { // if the expected key length is greater than the max key length
expectedKey = expectedKey.hashCode().toString(); // the expected key is hashed and a fixed length value is stored in the string format
}
documentService.generateRevisionId = function generateRevisionId(expectedKey) {
const maxKeyLength = 128; // the max key length is 128
let expKey = expectedKey;
if (expKey.length > maxKeyLength) { // if the expected key length is greater than the max key length
// the expected key is hashed and a fixed length value is stored in the string format
expKey = expKey.hashCode().toString();
}
var key = expectedKey.replace(new RegExp("[^0-9-.a-zA-Z_=]", "g"), "_");
const key = expKey.replace(/[^0-9-.a-zA-Z_=]/g, '_');
return key.substring(0, Math.min(key.length, maxKeyLength)); // the resulting key is of the max key length or less
return key.substring(0, Math.min(key.length, maxKeyLength)); // the resulting key is of the max key length or less
};
// create an error message for the error code
documentService.processConvertServiceResponceError = function (errorCode) {
var errorMessage = "";
var errorMessageTemplate = "Error occurred in the ConvertService: ";
documentService.processConvertServiceResponceError = function processConvertServiceResponceError(errorCode) {
let errorMessage = '';
const errorMessageTemplate = 'Error occurred in the ConvertService: ';
// add the error message to the error message template depending on the error code
switch (errorCode) {
case -20:
errorMessage = errorMessageTemplate + "Error encrypt signature";
break;
case -8:
errorMessage = errorMessageTemplate + "Error document signature";
break;
case -7:
errorMessage = errorMessageTemplate + "Error document request";
break;
case -6:
errorMessage = errorMessageTemplate + "Error database";
break;
case -5:
errorMessage = errorMessageTemplate + "Incorrect password";
break;
case -4:
errorMessage = errorMessageTemplate + "Error download error";
break;
case -3:
errorMessage = errorMessageTemplate + "Error convertation error";
break;
case -2:
errorMessage = errorMessageTemplate + "Error convertation timeout";
break;
case -1:
errorMessage = errorMessageTemplate + "Error convertation unknown";
break;
case 0: // if the error code is equal to 0, the error message is empty
break;
default:
errorMessage = "ErrorCode = " + errorCode; // default value for the error message
break;
}
// add the error message to the error message template depending on the error code
switch (errorCode) {
case -20:
errorMessage = `${errorMessageTemplate}Error encrypt signature`;
break;
case -8:
errorMessage = `${errorMessageTemplate}Error document signature`;
break;
case -7:
errorMessage = `${errorMessageTemplate}Error document request`;
break;
case -6:
errorMessage = `${errorMessageTemplate}Error database`;
break;
case -5:
errorMessage = `${errorMessageTemplate}Incorrect password`;
break;
case -4:
errorMessage = `${errorMessageTemplate}Error download error`;
break;
case -3:
errorMessage = `${errorMessageTemplate}Error convertation error`;
break;
case -2:
errorMessage = `${errorMessageTemplate}Error convertation timeout`;
break;
case -1:
errorMessage = `${errorMessageTemplate}Error convertation unknown`;
break;
case 0: // if the error code is equal to 0, the error message is empty
break;
default:
errorMessage = `ErrorCode = ${errorCode}`; // default value for the error message
break;
}
throw { message: errorMessage };
throw new Error(errorMessage);
};
// get the response url
documentService.getResponseUri = function (json) {
var fileResult = JSON.parse(json);
documentService.getResponseUri = function getResponseUri(json) {
const fileResult = JSON.parse(json);
if (fileResult.error) // if an error occurs
documentService.processConvertServiceResponceError(parseInt(fileResult.error)); // get an error message
if (fileResult.error) { // if an error occurs
documentService.processConvertServiceResponceError(parseInt(fileResult.error, 10)); // get an error message
}
var isEndConvert = fileResult.endConvert // check if the conversion is completed
const isEndConvert = fileResult.endConvert; // check if the conversion is completed
var percent = parseInt(fileResult.percent); // get the conversion percentage
var uri = null;
var fileType = null;
let percent = parseInt(fileResult.percent, 10); // get the conversion percentage
let uri = null;
let fileType = null;
if (isEndConvert) { // if the conversion is completed
if (!fileResult.fileUrl) // and the file url doesn't exist
throw { message: "FileUrl is null" }; // the file url is null
uri = fileResult.fileUrl; // otherwise, get the file url
fileType = fileResult.fileType; // get the file type
percent = 100;
} else { // if the conversion isn't completed
percent = percent >= 100 ? 99 : percent; // get the percentage value
if (isEndConvert) { // if the conversion is completed
if (!fileResult.fileUrl) { // and the file url doesn't exist
throw new Error('FileUrl is null'); // the file url is null
}
return {
percent : percent,
uri : uri,
fileType : fileType
};
uri = fileResult.fileUrl; // otherwise, get the file url
({ fileType } = fileResult); // get the file type
percent = 100;
} else { // if the conversion isn't completed
percent = percent >= 100 ? 99 : percent; // get the percentage value
}
return {
percent,
uri,
fileType,
};
};
// create a command request
documentService.commandRequest = function (method, documentRevisionId, meta = null, callback) {
documentService.commandRequest = function commandRequest(method, documentRevisionId, callback, meta = null) {
const revisionId = documentService.generateRevisionId(documentRevisionId); // generate the document key value
const params = { // create a parameter object with command method and the document key value in it
c: method,
key: revisionId,
};
documentRevisionId = documentService.generateRevisionId(documentRevisionId); // generate the document key value
params = { // create a parameter object with command method and the document key value in it
c: method,
key: documentRevisionId
};
if (meta) {
params.meta = meta;
}
if (meta) {
params.meta = meta;
}
const uri = siteUrl + configServer.get('commandUrl'); // get the absolute command url
const headers = { // create a headers object
'Content-Type': 'application/json',
};
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
params.token = documentService.getToken(params);
}
var uri = siteUrl + configServer.get('commandUrl'); // get the absolute command url
var headers = { // create a headers object
'Content-Type': 'application/json'
};
if (cfgSignatureEnable && cfgSignatureUseForRequest) {
headers[cfgSignatureAuthorizationHeader] = cfgSignatureAuthorizationHeaderPrefix + this.fillJwtByUrl(uri, params);
params.token = documentService.getToken(params);
}
//parse url to allow request by relative url after https://github.com/node-modules/urllib/pull/321/commits/514de1924bf17a38a6c2db2a22a6bc3494c0a959
urllib.request(urlModule.parse(uri),
{
method: "POST",
headers: headers,
data: params
},
callback);
// parse url to allow request by relative url after
// https://github.com/node-modules/urllib/pull/321/commits/514de1924bf17a38a6c2db2a22a6bc3494c0a959
urllib.request(
urlModule.parse(uri),
{
method: 'POST',
headers,
data: params,
},
callback,
);
};
// check jwt token headers
documentService.checkJwtHeader = function (req) {
var decoded = null;
var authorization = req.get(cfgSignatureAuthorizationHeader); // get signature authorization header from the request
if (authorization && authorization.startsWith(cfgSignatureAuthorizationHeaderPrefix)) { // if authorization header exists and it starts with the authorization header prefix
var token = authorization.substring(cfgSignatureAuthorizationHeaderPrefix.length); // the resulting token starts after the authorization header prefix
documentService.checkJwtHeader = function checkJwtHeader(req) {
let decoded = null;
const authorization = req.get(cfgSignatureAuthorizationHeader); // get signature authorization header from the request
// if authorization header exists and it starts with the authorization header prefix
if (authorization && authorization.startsWith(cfgSignatureAuthorizationHeaderPrefix)) {
// the resulting token starts after the authorization header prefix
const token = authorization.substring(cfgSignatureAuthorizationHeaderPrefix.length);
try {
decoded = jwt.verify(token, cfgSignatureSecret); // verify signature on jwt token using signature secret
decoded = jwt.verify(token, cfgSignatureSecret); // verify signature on jwt token using signature secret
} catch (err) {
console.log('checkJwtHeader error: name = ' + err.name + ' message = ' + err.message + ' token = ' + token) // print debug information to the console
// print debug information to the console
console.log(`checkJwtHeader error: name = ${err.name} message = ${err.message} token = ${token}`);
}
}
return decoded;
}
};
// get jwt token using url information
documentService.fillJwtByUrl = function (uri, opt_dataObject) {
var parseObject = urlModule.parse(uri, true); // get parse object from the url
var payload = {query: parseObject.query, payload: opt_dataObject}; // create payload object
documentService.fillJwtByUrl = function fillJwtByUrl(uri, optDataObject) {
const parseObject = urlModule.parse(uri, true); // get parse object from the url
const payload = { query: parseObject.query, payload: optDataObject }; // create payload object
var options = {algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn};
return jwt.sign(payload, cfgSignatureSecret, options); // sign token with given data using signature secret and options parameters
}
const options = { algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn };
// sign token with given data using signature secret and options parameters
return jwt.sign(payload, cfgSignatureSecret, options);
};
// get token
documentService.getToken = function (data) {
var options = {algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn};
return jwt.sign(data, cfgSignatureSecret, options); // sign token with given data using signature secret and options parameters
documentService.getToken = function getToken(data) {
const options = { algorithm: cfgSignatureSecretAlgorithmRequest, expiresIn: cfgSignatureSecretExpiresIn };
// sign token with given data using signature secret and options parameters
return jwt.sign(data, cfgSignatureSecret, options);
};
// read and verify token
documentService.readToken = function (token) {
try {
return jwt.verify(token, cfgSignatureSecret); // verify signature on jwt token using signature secret
} catch (err) {
console.log('checkJwtHeader error: name = ' + err.name + ' message = ' + err.message + ' token = ' + token)
}
return null;
documentService.readToken = function readToken(token) {
try {
return jwt.verify(token, cfgSignatureSecret); // verify signature on jwt token using signature secret
} catch (err) {
console.log(`checkJwtHeader error: name = ${err.name} message = ${err.message} token = ${token}`);
}
return null;
};
// save all the functions to the documentService module to export it later in other files

View File

@ -1,4 +1,4 @@
/**
/**
*
* (c) Copyright Ascensio System SIA 2023
*
@ -16,79 +16,101 @@
*
*/
var fileUtility = {};
const supportedFormats = require('../public/assets/document-formats/onlyoffice-docs-formats.json'); // eslint-disable-line
const fileUtility = {};
// get file name from the given url
fileUtility.getFileName = function (url, withoutExtension) {
if (!url) return "";
fileUtility.getFileName = function getFileName(url, withoutExtension) {
if (!url) return '';
var parts = url.split("\\");
parts = parts.pop();
parts = parts.split("/");
var fileName = parts.pop(); // get the file name from the last part of the url
fileName = fileName.split("?")[0];
let parts = url.split('\\');
parts = parts.pop();
parts = parts.split('/');
let fileName = parts.pop(); // get the file name from the last part of the url
[fileName] = fileName.split('?');
// get file name without extension
if (withoutExtension) {
return fileName.substring(0, fileName.lastIndexOf("."));
}
// get file name without extension
if (withoutExtension) {
return fileName.substring(0, fileName.lastIndexOf('.'));
}
return fileName;
return fileName;
};
// get file extension from the given url
fileUtility.getFileExtension = function (url, withoutDot) {
if (!url) return null;
fileUtility.getFileExtension = function getFileExtension(url, withoutDot) {
if (!url) return null;
var fileName = fileUtility.getFileName(url); // get file name from the given url
const fileName = fileUtility.getFileName(url); // get file name from the given url
var parts = fileName.toLowerCase().split(".");
const parts = fileName.toLowerCase().split('.');
return withoutDot ? parts.pop() : "." + parts.pop(); // get the extension from the file name with or without dot
return withoutDot ? parts.pop() : `.${parts.pop()}`; // get the extension from the file name with or without dot
};
// get file type from the given url
fileUtility.getFileType = function (url) {
var ext = fileUtility.getFileExtension(url); // get the file extension from the given url
fileUtility.getFileType = function getFileType(url) {
const ext = fileUtility.getFileExtension(url, true); // get the file extension from the given url
if (fileUtility.documentExts.indexOf(ext) != -1) return fileUtility.fileType.word; // word type for document extensions
if (fileUtility.spreadsheetExts.indexOf(ext) != -1) return fileUtility.fileType.cell; // cell type for spreadsheet extensions
if (fileUtility.presentationExts.indexOf(ext) != -1) return fileUtility.fileType.slide; // slide type for presentation extensions
for (let i = 0; i < supportedFormats.length; i++) {
if (supportedFormats[i].name === ext) return supportedFormats[i].type;
}
return fileUtility.fileType.word; // the default file type is word
}
return fileUtility.fileType.word; // the default file type is word
};
fileUtility.fileType = {
word: "word",
cell: "cell",
slide: "slide"
}
word: 'word',
cell: 'cell',
slide: 'slide',
};
// the document extension list
fileUtility.documentExts = [".doc", ".docx", ".oform", ".docm", ".dot", ".dotx", ".dotm", ".odt", ".fodt", ".ott", ".rtf", ".txt", ".html", ".htm", ".mht", ".xml", ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps"];
fileUtility.getSuppotredExtensions = function getSuppotredExtensions() {
return supportedFormats.reduce((extensions, format) => [...extensions, format.name], []);
};
// the spreadsheet extension list
fileUtility.spreadsheetExts = [".xls", ".xlsx", ".xlsm", ".xlsb", ".xlt", ".xltx", ".xltm", ".ods", ".fods", ".ots", ".csv"];
fileUtility.getViewExtensions = function getViewExtensions() {
return supportedFormats.filter(
(format) => format.actions.includes('view'),
).reduce((extensions, format) => [...extensions, format.name], []);
};
// the presentation extension list
fileUtility.presentationExts = [".pps", ".ppsx", ".ppsm", ".ppt", ".pptx", ".pptm", ".pot", ".potx", ".potm", ".odp", ".fodp", ".otp"];
fileUtility.getEditExtensions = function getEditExtensions() {
return supportedFormats.filter(
(format) => format.actions.includes('edit') || format.actions.includes('lossy-edit'),
).reduce((extensions, format) => [...extensions, format.name], []);
};
fileUtility.getFillExtensions = function getFillExtensions() {
return supportedFormats.filter(
(format) => format.actions.includes('fill'),
).reduce((extensions, format) => [...extensions, format.name], []);
};
fileUtility.getConvertExtensions = function getConvertExtensions() {
return supportedFormats.filter(
(format) => format.actions.includes('auto-convert'),
).reduce((extensions, format) => [...extensions, format.name], []);
};
// get url parameters
function getUrlParams(url) {
try {
var query = url.split("?").pop(); // take all the parameters which are placed after ? sign in the file url
var params = query.split("&"); // parameters are separated by & sign
var map = {}; // write parameters and their values to the map dictionary
for (var i = 0; i < params.length; i++) {
var parts = param.split("=");
map[parts[0]] = parts[1];
}
return map;
// eslint-disable-next-line no-unused-vars
const getUrlParams = function getUrlParams(url) {
try {
const query = url.split('?').pop(); // take all the parameters which are placed after ? sign in the file url
const params = query.split('&'); // parameters are separated by & sign
const map = {}; // write parameters and their values to the map dictionary
for (let i = 0; i < params.length; i++) {
// eslint-disable-next-line no-undef
const parts = param.split('=');
[, map[parts[0]]] = parts;
}
catch (ex) {
return null;
}
}
return map;
} catch (ex) {
return null;
}
};
// save all the functions to the fileUtility module to export it later in other files
module.exports = fileUtility;

View File

@ -1,4 +1,4 @@
/**
/**
*
* (c) Copyright Ascensio System SIA 2023
*
@ -17,11 +17,12 @@
*/
// generate 16 octet
var s4 = function () {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
const s4 = function s4() {
return Math.trunc((1 + Math.random()) * 0x10000).toString(16)
.substring(1);
};
// create uuid v4
exports.newGuid = function () {
return (s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4());
};
exports.newGuid = function newGuid() {
return (`${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`);
};

View File

@ -16,80 +16,20 @@
*
*/
var descr_user_1 = [
"File author by default",
"Doesnt belong to any group",
"Can review all the changes",
"Can perform all actions with comments",
"The file favorite state is undefined",
"Can create files from templates using data from the editor",
"Can see the information about all users",
//"Can submit forms"
];
var descr_user_2 = [
"Belongs to Group2",
"Can review only his own changes or changes made by users with no group",
"Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only",
"This file is marked as favorite",
"Can create new files from the editor",
"Can see the information about users from Group2 and users who dont belong to any group",
//"Cant submit forms"
];
var descr_user_3 = [
"Belongs to Group3",
"Can review changes made by Group2 users",
"Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users",
"This file isnt marked as favorite",
"Cant copy data from the file to clipboard",
"Cant download the file",
"Cant print the file",
"Can create new files from the editor",
"Can see the information about Group2 users",
//"Cant submit forms"
];
var descr_user_0 = [
"The name is requested when the editor is opened",
"Doesnt belong to any group",
"Can review all the changes",
"Can perform all actions with comments",
"The file favorite state is undefined",
"Can't mention others in comments",
"Can't create new files from the editor",
"Cant see anyones information",
"Can't rename files from the editor",
"Can't view chat",
"Can't protect file",
"View file without collaboration",
//"Cant submit forms"
];
var users = [
new User("uid-1", "John Smith", "smith@example.com",
null, null, {}, null,
null, [], descr_user_1, true),
new User("uid-2", "Mark Pottato", "pottato@example.com",
"group-2", ["group-2", ""], {
view: "",
edit: ["group-2", ""],
remove: ["group-2"]
}, ["group-2", ""],
true, [], descr_user_2, false), // own and without group
new User("uid-3", "Hamish Mitchell", "mitchell@example.com",
"group-3", ["group-2"], {
view: ["group-3", "group-2"],
edit: ["group-2"],
remove: []
}, ["group-2"],
false, ["copy", "download", "print"], descr_user_3, false), // other group only
new User("uid-0", null, null,
null, null, {}, [],
null, ["protect"], descr_user_0, false),
];
function User(id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates) {
class User {
constructor(
id,
name,
email,
group,
reviewGroups,
commentGroups,
userInfoGroups,
favorite,
deniedPermissions,
descriptions,
templates,
) {
this.id = id;
this.name = name;
this.email = email;
@ -101,36 +41,117 @@ function User(id, name, email, group, reviewGroups, commentGroups, userInfoGroup
this.deniedPermissions = deniedPermissions;
this.descriptions = descriptions;
this.templates = templates;
};
}
}
const descrUser1 = [
'File author by default',
'Doesnt belong to any group',
'Can review all the changes',
'Can perform all actions with comments',
'The file favorite state is undefined',
'Can create files from templates using data from the editor',
'Can see the information about all users',
'Can submit forms',
];
const descrUser2 = [
'Belongs to Group2',
'Can review only his own changes or changes made by users with no group',
'Can view comments, edit his own comments and comments left by users with no group. Can remove his own comments only',
'This file is marked as favorite',
'Can create new files from the editor',
'Can see the information about users from Group2 and users who dont belong to any group',
'Cant submit forms',
];
const descrUser3 = [
'Belongs to Group3',
'Can review changes made by Group2 users',
'Can view comments left by Group2 and Group3 users. Can edit comments left by the Group2 users',
'This file isnt marked as favorite',
'Cant copy data from the file to clipboard',
'Cant download the file',
'Cant print the file',
'Can create new files from the editor',
'Can see the information about Group2 users',
'Cant submit forms',
];
const descrUser0 = [
'The name is requested when the editor is opened',
'Doesnt belong to any group',
'Can review all the changes',
'Can perform all actions with comments',
'The file favorite state is undefined',
'Can\'t mention others in comments',
'Can\'t create new files from the editor',
'Cant see anyones information',
'Can\'t rename files from the editor',
'Can\'t view chat',
'Can\'t protect file',
'View file without collaboration',
'Cant submit forms',
];
const users = [
new User('uid-1', 'John Smith', 'smith@example.com', null, null, {}, null, null, [], descrUser1, true),
new User('uid-2', 'Mark Pottato', 'pottato@example.com', 'group-2', ['group-2', ''], {
view: '',
edit: ['group-2', ''],
remove: ['group-2'],
}, ['group-2', ''], true, [], descrUser2, false), // own and without group
new User('uid-3', 'Hamish Mitchell', 'mitchell@example.com', 'group-3', ['group-2'], {
view: ['group-3', 'group-2'],
edit: ['group-2'],
remove: [],
}, ['group-2'], false, ['copy', 'download', 'print'], descrUser3, false), // other group only
new User('uid-0', null, null, null, null, {}, [], null, ['protect'], descrUser0, false),
];
// get a list of all the users
users.getAllUsers = function () {
return users;
users.getAllUsers = function getAllUsers() {
return users;
};
// get a user by id specified
users.getUser = function (id) {
var result = null;
this.forEach(user => {
if (user.id == id) {
result = user;
}
});
return result ? result : this[0];
users.getUser = function getUser(id) {
let result = null;
this.forEach((user) => {
if (user.id === id) {
result = user;
}
});
return result || this[0];
};
// get a list of users with their name and email
users.getUsersForMentions = function (id) {
var result = [];
this.forEach(user => {
if (user.id != id && user.name != null && user.email != null) {
result.push({
email: user.email,
name: user.name
});
}
});
return result;
// get a list of users with their name and email for mentions
users.getUsersForMentions = function getUsersForMentions(id) {
const result = [];
this.forEach((user) => {
if (user.id !== id && user.name && user.email) {
result.push({
email: user.email,
name: user.name,
});
}
});
return result;
};
// get a list of users with their name, id and email for protect
users.getUsersForProtect = function getUsersForProtect(id) {
const result = [];
this.forEach((user) => {
if (user.id !== id && user.name != null) {
result.push({
email: user.email,
id: user.id,
name: user.name,
});
}
});
return result;
};
module.exports = users;

View File

@ -16,14 +16,343 @@
*
*/
const fileSystem = require('fs');
const mime = require('mime');
const path = require('path');
const reqConsts = require('./request');
const fileUtility = require("../fileUtility");
const lockManager = require("./lockManager");
const fileSystem = require("fs");
const mime = require("mime");
const path = require("path");
const users = require("../users");
const docManager = require("../docManager");
const fileUtility = require('../fileUtility');
const lockManager = require('./lockManager');
const users = require('../users');
const DocManager = require('../docManager');
// return lock mismatch
const returnLockMismatch = function returnLockMismatch(res, lock, reason) {
res.setHeader(reqConsts.requestHeaders.Lock, lock || ''); // set the X-WOPI-Lock header
if (reason) { // if there is a reason for lock mismatch
res.setHeader(reqConsts.requestHeaders.LockFailureReason, reason); // set it as the X-WOPI-LockFailureReason header
}
res.sendStatus(409); // conflict
};
// lock file editing
const lock = function lock(wopi, req, res, userHost) {
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
const userAddress = req.DocManager.curUserHostAddress(userHost); // get current user host address
const filePath = req.DocManager.storagePath(wopi.id, userAddress); // get the storage path of the given file
if (!lockManager.hasLock(filePath)) {
// file isn't locked => lock
lockManager.lock(filePath, requestLock);
res.sendStatus(200);
} else if (lockManager.getLock(filePath) === requestLock) {
// lock matches current lock => extend duration
lockManager.lock(filePath, requestLock);
res.sendStatus(200);
} else {
// file locked by someone else => return lock mismatch
const locked = lockManager.getLock(filePath);
returnLockMismatch(res, lock, `File already locked by ${locked}`);
}
};
const saveFileFromBody = function saveFileFromBody(req, filename, userAddress, isNewVersion, callback) {
if (req.body) {
const storagePath = req.DocManager.storagePath(filename, userAddress);
let historyPath = req.DocManager.historyPath(filename, userAddress); // get the path to the file history
if (historyPath === '') { // if it is empty
historyPath = req.DocManager.historyPath(filename, userAddress, true); // create it
req.DocManager.createDirectory(historyPath); // and create a new directory for the history
}
let version = 0;
if (isNewVersion) {
const countVersion = req.DocManager.countVersion(historyPath); // get the last file version
version = countVersion + 1; // get a number of a new file version
// get the path to the specified file version
const versionPath = req.DocManager.versionPath(filename, userAddress, version);
req.DocManager.createDirectory(versionPath); // and create a new directory for the specified version
// get the path to the previous file version
const pathPrev = path.join(versionPath, `prev${fileUtility.getFileExtension(filename)}`);
fileSystem.renameSync(storagePath, pathPrev); // synchronously rename the given file as the previous file version
}
const filestream = fileSystem.createWriteStream(storagePath);
req.pipe(filestream);
req.on('end', () => {
filestream.close();
callback(null, version);
});
} else {
callback('empty body');
}
};
// return name that wopi-client can use as the value of X-WOPI-RelativeTarget in a future PutRelativeFile operation
const returnValidRelativeTarget = function returnValidRelativeTarget(res, filename) {
res.setHeader(reqConsts.requestHeaders.ValidRelativeTarget, filename); // set the X-WOPI-ValidRelativeTarget header
res.sendStatus(409); // file with that name already exists
};
// retrieve a lock on a file
const getLock = function getLock(wopi, req, res, userHost) {
const userAddress = req.DocManager.curUserHostAddress(userHost);
const filePath = req.DocManager.storagePath(wopi.id, userAddress);
// get the lock of the specified file and set it as the X-WOPI-Lock header
res.setHeader(reqConsts.requestHeaders.lock, lockManager.getLock(filePath));
res.sendStatus(200);
};
// refresh the lock on a file by resetting its automatic expiration timer to 30 minutes
const refreshLock = function refreshLock(wopi, req, res, userHost) {
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
const userAddress = req.DocManager.curUserHostAddress(userHost);
const filePath = req.DocManager.storagePath(wopi.id, userAddress);
if (!lockManager.hasLock(filePath)) {
// file isn't locked => mismatch
returnLockMismatch(res, '', 'File isn\'t locked');
} else if (lockManager.getLock(filePath) === requestLock) {
// lock matches current lock => extend duration
lockManager.lock(filePath, requestLock);
res.sendStatus(200);
} else {
// lock mismatch
returnLockMismatch(res, lockManager.getLock(filePath), 'Lock mismatch');
}
};
// allow for file editing
const unlock = function unlock(wopi, req, res, userHost) {
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
const userAddress = req.DocManager.curUserHostAddress(userHost);
const filePath = req.DocManager.storagePath(wopi.id, userAddress);
if (!lockManager.hasLock(filePath)) {
// file isn't locked => mismatch
returnLockMismatch(res, '', 'File isn\'t locked');
} else if (lockManager.getLock(filePath) === requestLock) {
// lock matches current lock => unlock
lockManager.unlock(filePath);
res.sendStatus(200);
} else {
// lock mismatch
returnLockMismatch(res, lockManager.getLock(filePath), 'Lock mismatch');
}
};
// allow for file editing, and then immediately take a new lock on the file
const unlockAndRelock = function unlockAndRelock(wopi, req, res, userHost) {
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
const oldLock = req.headers[reqConsts.requestHeaders.oldLock.toLowerCase()]; // get the X-WOPI-OldLock header
const userAddress = req.DocManager.curUserHostAddress(userHost);
const filePath = req.DocManager.storagePath(wopi.id, userAddress);
if (!lockManager.hasLock(filePath)) {
// file isn't locked => mismatch
returnLockMismatch(res, '', 'File isn\'t locked');
} else if (lockManager.getLock(filePath) === oldLock) {
// lock matches current lock => lock with new key
lockManager.lock(filePath, requestLock);
res.sendStatus(200);
} else {
// lock mismatch
returnLockMismatch(res, lockManager.getLock(filePath), 'Lock mismatch');
}
};
// request a message to retrieve a file
const getFile = function getFile(wopi, req, res, userHost) {
const userAddress = req.DocManager.curUserHostAddress(userHost);
const storagePath = req.DocManager.storagePath(wopi.id, userAddress);
res.setHeader('Content-Length', fileSystem.statSync(storagePath).size);
res.setHeader('Content-Type', mime.getType(storagePath));
res.setHeader('Content-Disposition', `attachment; filename*=UTF-8''${encodeURIComponent(wopi.id)}`);
const filestream = fileSystem.createReadStream(storagePath); // open a file as a readable stream
filestream.pipe(res); // retrieve data from file stream and output it to the response object
};
// request a message to update a file
const putFile = function putFile(wopi, req, res, userHost) {
const requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
const userAddress = req.DocManager.curUserHostAddress(userHost);
const storagePath = req.DocManager.storagePath(wopi.id, userAddress);
if (!lockManager.hasLock(storagePath)) {
// ToDo: if body length is 0 bytes => handle document creation
// file isn't locked => mismatch
returnLockMismatch(res, '', 'File isn\'t locked');
} else if (lockManager.getLock(storagePath) === requestLock) {
// lock matches current lock => put file
saveFileFromBody(req, wopi.id, userAddress, true, (err, version) => {
if (!err) {
res.setHeader(reqConsts.requestHeaders.ItemVersion, version); // set the X-WOPI-ItemVersion header
}
res.sendStatus(err ? 404 : 200);
});
} else {
// lock mismatch
returnLockMismatch(res, lockManager.getLock(storagePath), 'Lock mismatch');
}
};
const putRelativeFile = function putRelativeFile(wopi, req, res, userHost) {
const userAddress = req.DocManager.curUserHostAddress(userHost);
const storagePath = req.DocManager.storagePath(wopi.id, userAddress);
let filename = req.headers[reqConsts.requestHeaders.RelativeTarget.toLowerCase()]; // we cannot modify this filename
if (filename) {
if (req.DocManager.existsSync(storagePath)) { // check if already exists
const overwrite = req.headers[reqConsts.requestHeaders.OverwriteRelativeTarget.toLowerCase()]; // overwrite header
if (overwrite && overwrite === 'true') { // check if we can overwrite
if (lockManager.hasLock(storagePath)) { // check if file locked
// file is locked, cannot overwrite
returnValidRelativeTarget(res, req.DocManager.getCorrectName(wopi.id, userAddress));
return;
}
} else {
// file exists and overwrite header is false
returnValidRelativeTarget(res, req.DocManager.getCorrectName(wopi.id, userAddress));
return;
}
}
} else {
filename = req.headers[reqConsts.requestHeaders.SuggestedTarget.toLowerCase()]; // we can modify this filename
if (filename.startsWith('.')) { // check if extension
filename = fileUtility.getFileName(wopi.id, true) + filename; // get original filename with new extension
}
filename = req.DocManager.getCorrectName(filename, userAddress); // get correct filename if already exists
}
const isConverted = req.headers[reqConsts.requestHeaders.FileConversion.toLowerCase()];
console.log(`putRelativeFile after conversation: ${isConverted}`);
// if we got here, then we can save a file
saveFileFromBody(req, filename, userAddress, false, (err) => {
if (err) {
res.sendStatus(404);
return;
}
const serverUrl = req.DocManager.getServerUrl(true);
const fileActionUrl = `${serverUrl}/wopi-action/${filename}?action=`;
const fileInfo = {
Name: filename,
Url: `${serverUrl}/wopi/files/${filename}`,
HostViewUrl: `${fileActionUrl}view`,
HostEditNewUrl: `${fileActionUrl}editnew`,
HostEditUrl: `${fileActionUrl}edit`,
};
res.status(200).send(fileInfo);
});
};
// return information about the file properties, access rights and editor settings
const checkFileInfo = function checkFileInfo(wopi, req, res, userHost) {
const userAddress = req.DocManager.curUserHostAddress(userHost);
const version = req.DocManager.getKey(wopi.id, userAddress);
const storagePath = req.DocManager.storagePath(wopi.id, userAddress);
// add wopi query
const query = new URLSearchParams(wopi.accessToken);
const user = users.getUser(query.get('userid'));
// create the file information object
const fileInfo = {
BaseFileName: wopi.id,
OwnerId: req.DocManager.getFileData(wopi.id, userAddress)[1],
Size: fileSystem.statSync(storagePath).size,
UserId: user.id,
UserFriendlyName: user.name,
Version: version,
UserCanWrite: true,
SupportsGetLock: true,
SupportsLocks: true,
SupportsUpdate: true,
};
res.status(200).send(fileInfo);
};
// parse wopi request
const parseWopiRequest = function parseWopiRequest(req) {
const wopiData = {
requestType: reqConsts.requestType.None,
accessToken: req.query.access_token,
id: req.params.id,
};
// get the request path
const reqPath = req.path.substring('/wopi/'.length);
if (reqPath.startsWith('files')) { // if it starts with "files"
if (reqPath.endsWith('/contents')) { // ends with "/contents"
if (req.method === 'GET') { // and the request method is GET
wopiData.requestType = reqConsts.requestType.GetFile; // then the request type is GetFile
} else if (req.method === 'POST') { // if the request method is POST
wopiData.requestType = reqConsts.requestType.PutFile; // then the request type is PutFile
}
} else if (req.method === 'GET') { // otherwise, if the request method is GET
wopiData.requestType = reqConsts.requestType.CheckFileInfo; // the request type is CheckFileInfo
} else if (req.method === 'POST') { // if the request method is POST
// get the X-WOPI-Override header which determines the request type
const wopiOverride = req.headers[reqConsts.requestHeaders.RequestType.toLowerCase()];
switch (wopiOverride) {
case 'LOCK': // if it is equal to LOCK
// check if the request sends the X-WOPI-OldLock header
if (req.headers[reqConsts.requestHeaders.OldLock.toLowerCase()]) {
// if yes, then the request type is UnlockAndRelock
wopiData.requestType = reqConsts.requestType.UnlockAndRelock;
} else {
wopiData.requestType = reqConsts.requestType.Lock; // otherwise, it is Lock
}
break;
case 'GET_LOCK': // if it is equal to GET_LOCK
wopiData.requestType = reqConsts.requestType.GetLock; // the request type is GetLock
break;
case 'REFRESH_LOCK': // if it is equal to REFRESH_LOCK
wopiData.requestType = reqConsts.requestType.RefreshLock; // the request type is RefreshLock
break;
case 'UNLOCK': // if it is equal to UNLOCK
wopiData.requestType = reqConsts.requestType.Unlock; // the request type is Unlock
break;
case 'PUT_RELATIVE': // if it is equal to PUT_RELATIVE
// the request type is PutRelativeFile (creates a new file on the host based on the current file)
wopiData.requestType = reqConsts.requestType.PutRelativeFile;
break;
case 'RENAME_FILE': // if it is equal to RENAME_FILE
wopiData.requestType = reqConsts.requestType.RenameFile; // the request type is RenameFile (renames a file)
break;
case 'PUT_USER_INFO': // if it is equal to PUT_USER_INFO
// the request type is PutUserInfo (stores some basic user information on the host)
wopiData.requestType = reqConsts.requestType.PutUserInfo;
break;
default:
}
}
}
return wopiData;
};
const actionMapping = {};
actionMapping[reqConsts.requestType.GetFile] = getFile;
@ -36,352 +365,33 @@ actionMapping[reqConsts.requestType.GetLock] = getLock;
actionMapping[reqConsts.requestType.RefreshLock] = refreshLock;
actionMapping[reqConsts.requestType.Unlock] = unlock;
// parse wopi request
function parseWopiRequest(req) {
let wopiData = {
requestType: reqConsts.requestType.None,
accessToken: req.query["access_token"],
id: req.params['id']
}
// get the request path
let reqPath = req.path.substring("/wopi/".length)
if (reqPath.startsWith("files")) { // if it starts with "files"
if (reqPath.endsWith("/contents")) { // ends with "/contents"
if (req.method == "GET") { // and the request method is GET
wopiData.requestType = reqConsts.requestType.GetFile; // then the request type is GetFile
} else if (req.method == "POST") { // if the request method is POST
wopiData.requestType = reqConsts.requestType.PutFile; // then the request type is PutFile
}
} else {
if (req.method == "GET") { // otherwise, if the request method is GET
wopiData.requestType = reqConsts.requestType.CheckFileInfo; // the request type is CheckFileInfo
} else if (req.method == "POST") { // if the request method is POST
let wopiOverride = req.headers[reqConsts.requestHeaders.RequestType.toLowerCase()]; // get the X-WOPI-Override header which determines the request type
switch (wopiOverride) {
case "LOCK": // if it is equal to LOCK
if (req.headers[reqConsts.requestHeaders.OldLock.toLowerCase()]) { // check if the request sends the X-WOPI-OldLock header
wopiData.requestType = reqConsts.requestType.UnlockAndRelock; // if yes, then the request type is UnlockAndRelock
} else {
wopiData.requestType = reqConsts.requestType.Lock; // otherwise, it is Lock
}
break;
case "GET_LOCK": // if it is equal to GET_LOCK
wopiData.requestType = reqConsts.requestType.GetLock; // the request type is GetLock
break;
case "REFRESH_LOCK": // if it is equal to REFRESH_LOCK
wopiData.requestType = reqConsts.requestType.RefreshLock; // the request type is RefreshLock
break;
case "UNLOCK": // if it is equal to UNLOCK
wopiData.requestType = reqConsts.requestType.Unlock; // the request type is Unlock
break;
case "PUT_RELATIVE": // if it is equal to PUT_RELATIVE
wopiData.requestType = reqConsts.requestType.PutRelativeFile; // the request type is PutRelativeFile (creates a new file on the host based on the current file)
break;
case "RENAME_FILE": // if it is equal to RENAME_FILE
wopiData.requestType = reqConsts.requestType.RenameFile; // the request type is RenameFile (renames a file)
break;
case "PUT_USER_INFO": // if it is equal to PUT_USER_INFO
wopiData.requestType = reqConsts.requestType.PutUserInfo; // the request type is PutUserInfo (stores some basic user information on the host)
break;
}
}
}
} else if (reqPath.startsWith("folders")) {
}
return wopiData;
}
// lock file editing
function lock(wopi, req, res, userHost) {
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
let userAddress = req.docManager.curUserHostAddress(userHost); // get current user host address
let filePath = req.docManager.storagePath(wopi.id, userAddress); // get the storage path of the given file
if (!lockManager.hasLock(filePath)) {
// file isn't locked => lock
lockManager.lock(filePath, requestLock);
res.sendStatus(200);
} else if (lockManager.getLock(filePath) == requestLock) {
// lock matches current lock => extend duration
lockManager.lock(filePath, requestLock);
res.sendStatus(200);
} else {
// file locked by someone else => return lock mismatch
let lock = lockManager.getLock(filePath);
returnLockMismatch(res, lock, "File already locked by " + lock)
}
}
// retrieve a lock on a file
function getLock(wopi, req, res, userHost) {
let userAddress = req.docManager.curUserHostAddress(userHost);
let filePath = req.docManager.storagePath(wopi.id, userAddress);
// get the lock of the specified file and set it as the X-WOPI-Lock header
res.setHeader(reqConsts.requestHeaders.lock, lockManager.getLock(filePath));
res.sendStatus(200);
}
// refresh the lock on a file by resetting its automatic expiration timer to 30 minutes
function refreshLock(wopi, req, res, userHost) {
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
let userAddress = req.docManager.curUserHostAddress(userHost);
let filePath = req.docManager.storagePath(wopi.id, userAddress);
if (!lockManager.hasLock(filePath)) {
// file isn't locked => mismatch
returnLockMismatch(res, "", "File isn't locked");
} else if (lockManager.getLock(filePath) == requestLock) {
// lock matches current lock => extend duration
lockManager.lock(filePath, requestLock);
res.sendStatus(200);
} else {
// lock mismatch
returnLockMismatch(res, lockManager.getLock(filePath), "Lock mismatch");
}
}
// allow for file editing
function unlock(wopi, req, res, userHost) {
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
let userAddress = req.docManager.curUserHostAddress(userHost);
let filePath = req.docManager.storagePath(wopi.id, userAddress);
if (!lockManager.hasLock(filePath)) {
// file isn't locked => mismatch
returnLockMismatch(res, "", "File isn't locked");
} else if (lockManager.getLock(filePath) == requestLock) {
// lock matches current lock => unlock
lockManager.unlock(filePath);
res.sendStatus(200);
} else {
// lock mismatch
returnLockMismatch(res, lockManager.getLock(filePath), "Lock mismatch");
}
}
// allow for file editing, and then immediately take a new lock on the file
function unlockAndRelock(wopi, req, res, userHost) {
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
let oldLock = req.headers[reqConsts.requestHeaders.oldLock.toLowerCase()]; // get the X-WOPI-OldLock header
let userAddress = req.docManager.curUserHostAddress(userHost);
let filePath = req.docManager.storagePath(wopi.id, userAddress);
if (!lockManager.hasLock(filePath)) {
// file isn't locked => mismatch
returnLockMismatch(res, "", "File isn't locked");
} else if (lockManager.getLock(filePath) == oldLock) {
// lock matches current lock => lock with new key
lockManager.lock(filePath, requestLock);
res.sendStatus(200);
} else {
// lock mismatch
returnLockMismatch(res, lockManager.getLock(filePath), "Lock mismatch");
}
}
// request a message to retrieve a file
function getFile(wopi, req, res, userHost) {
let userAddress = req.docManager.curUserHostAddress(userHost);
let path = req.docManager.storagePath(wopi.id, userAddress);
res.setHeader("Content-Length", fileSystem.statSync(path).size);
res.setHeader("Content-Type", mime.getType(path));
res.setHeader("Content-Disposition", "attachment; filename*=UTF-8\'\'" + encodeURIComponent(wopi.id));
let filestream = fileSystem.createReadStream(path); // open a file as a readable stream
filestream.pipe(res); // retrieve data from file stream and output it to the response object
}
// request a message to update a file
function putFile(wopi, req, res, userHost) {
let requestLock = req.headers[reqConsts.requestHeaders.Lock.toLowerCase()];
let userAddress = req.docManager.curUserHostAddress(userHost);
let storagePath = req.docManager.storagePath(wopi.id, userAddress);
if (!lockManager.hasLock(storagePath)) {
// ToDo: if body length is 0 bytes => handle document creation
// file isn't locked => mismatch
returnLockMismatch(res, "", "File isn't locked");
} else if (lockManager.getLock(storagePath) == requestLock) {
// lock matches current lock => put file
saveFileFromBody(req, wopi.id, userAddress, true, (err, version) => {
if (!err) {
res.setHeader(reqConsts.requestHeaders.ItemVersion, version); // set the X-WOPI-ItemVersion header
}
res.sendStatus(err ? 404 : 200);
});
} else {
// lock mismatch
returnLockMismatch(res, lockManager.getLock(storagePath), "Lock mismatch");
}
}
function putRelativeFile(wopi, req, res, userHost) {
let userAddress = req.docManager.curUserHostAddress(userHost);
let storagePath = req.docManager.storagePath(wopi.id, userAddress);
let filename = req.headers[reqConsts.requestHeaders.RelativeTarget.toLowerCase()]; // we cannot modify this filename
if (filename) {
if (req.docManager.existsSync(storagePath)) { // check if already exists
let overwrite = req.headers[reqConsts.requestHeaders.OverwriteRelativeTarget.toLowerCase()]; // overwrite header
if (overwrite && overwrite === "true") { // check if we can overwrite
if (lockManager.hasLock(storagePath)) { // check if file locked
returnValidRelativeTarget(res, req.docManager.getCorrectName(wopi.id, userAddress)); // file is locked, cannot overwrite
return;
}
} else {
returnValidRelativeTarget(res, req.docManager.getCorrectName(wopi.id, userAddress)); // file exists and overwrite header is false
return;
}
}
} else {
filename = req.headers[reqConsts.requestHeaders.SuggestedTarget.toLowerCase()]; // we can modify this filename
if (filename.startsWith(".")) { // check if extension
filename = fileUtility.getFileName(wopi.id, true) + filename; // get original filename with new extension
}
filename = req.docManager.getCorrectName(filename, userAddress); // get correct filename if already exists
}
let isConverted = req.headers[reqConsts.requestHeaders.FileConversion.toLowerCase()];
console.log("putRelativeFile after conversation: " + isConverted);
// if we got here, then we can save a file
saveFileFromBody(req, filename, userAddress, false, (err) => {
if (err) {
res.sendStatus(404);
return;
}
let serverUrl = req.docManager.getServerUrl(true);
let fileActionUrl = serverUrl + "/wopi-action/" + filename + "?action=";
let fileInfo = {
"Name": filename,
"Url": serverUrl + "/wopi/files/" + filename,
"HostViewUrl": fileActionUrl + "view",
"HostEditNewUrl": fileActionUrl + "editnew",
"HostEditUrl": fileActionUrl + "edit",
};
res.status(200).send(fileInfo);
});
}
// return information about the file properties, access rights and editor settings
function checkFileInfo(wopi, req, res, userHost) {
let userAddress = req.docManager.curUserHostAddress(userHost);
let version = req.docManager.getKey(wopi.id, userAddress);
let path = req.docManager.storagePath(wopi.id, userAddress);
// add wopi query
var query = new URLSearchParams(wopi.accessToken);
let user = users.getUser(query.get("userid"));
// create the file information object
let fileInfo = {
"BaseFileName": wopi.id,
"OwnerId": req.docManager.getFileData(wopi.id, userAddress)[1],
"Size": fileSystem.statSync(path).size,
"UserId": user.id,
"UserFriendlyName": user.name,
"Version": version,
"UserCanWrite": true,
"SupportsGetLock": true,
"SupportsLocks": true,
"SupportsUpdate": true,
};
res.status(200).send(fileInfo);
}
function saveFileFromBody(req, filename, userAddress, isNewVersion, callback) {
if (req.body) {
var storagePath = req.docManager.storagePath(filename, userAddress);
var historyPath = req.docManager.historyPath(filename, userAddress); // get the path to the file history
if (historyPath == "") { // if it is empty
historyPath = req.docManager.historyPath(filename, userAddress, true); // create it
req.docManager.createDirectory(historyPath); // and create a new directory for the history
}
var version = 0;
if (isNewVersion) {
var count_version = req.docManager.countVersion(historyPath); // get the last file version
version = count_version + 1; // get a number of a new file version
var versionPath = req.docManager.versionPath(filename, userAddress, version); // get the path to the specified file version
req.docManager.createDirectory(versionPath); // and create a new directory for the specified version
var path_prev = path.join(versionPath, "prev" + fileUtility.getFileExtension(filename)); // get the path to the previous file version
fileSystem.renameSync(storagePath, path_prev); // synchronously rename the given file as the previous file version
}
let filestream = fileSystem.createWriteStream(storagePath);
req.pipe(filestream);
req.on('end', () => {
filestream.close();
callback(null, version);
})
} else {
callback("empty body");
}
}
// return name that wopi-client can use as the value of X-WOPI-RelativeTarget in a future PutRelativeFile operation
function returnValidRelativeTarget(res, filename) {
res.setHeader(reqConsts.requestHeaders.ValidRelativeTarget, filename); // set the X-WOPI-ValidRelativeTarget header
res.sendStatus(409); // file with that name already exists
}
// return lock mismatch
function returnLockMismatch(res, lock, reason) {
res.setHeader(reqConsts.requestHeaders.Lock, lock || ""); // set the X-WOPI-Lock header
if (reason) { // if there is a reason for lock mismatch
res.setHeader(reqConsts.requestHeaders.LockFailureReason, reason); // set it as the X-WOPI-LockFailureReason header
}
res.sendStatus(409); // conflict
}
exports.fileRequestHandler = (req, res) => {
let userAddress = null;
req.docManager = new docManager(req, res);
if (req.params['id'].includes("@")) { // if there is the "@" sign in the id parameter
let split = req.params['id'].split("@"); // split this parameter by "@"
req.params['id'] = split[0]; // rewrite id with the first part of the split parameter
userAddress = split[1]; // save the second part as the user address
}
let userAddress = null;
req.DocManager = new DocManager(req, res);
if (req.params.id.includes('@')) { // if there is the "@" sign in the id parameter
const split = req.params.id.split('@'); // split this parameter by "@"
[req.params.id] = split; // rewrite id with the first part of the split parameter
[, userAddress] = split; // save the second part as the user address
}
let wopiData = parseWopiRequest(req); // get the wopi data
const wopiData = parseWopiRequest(req); // get the wopi data
// an error of the unknown request type
if (wopiData.requestType == reqConsts.requestType.None) {
res.status(500).send({ 'title': 'fileHandler', 'method': req.method, 'id': req.params['id'], 'error': "unknown" });
return;
}
// an error of the unknown request type
if (wopiData.requestType === reqConsts.requestType.None) {
res.status(500).send({
title: 'fileHandler', method: req.method, id: req.params.id, error: 'unknown',
});
return;
}
// an error of the unsupported request type
let action = actionMapping[wopiData.requestType];
if (!action) {
res.status(501).send({ 'title': 'fileHandler', 'method': req.method, 'id': req.params['id'], 'error': "unsupported" });
return;
}
// an error of the unsupported request type
const action = actionMapping[wopiData.requestType];
if (!action) {
res.status(501).send({
title: 'fileHandler', method: req.method, id: req.params.id, error: 'unsupported',
});
return;
}
action(wopiData, req, res, userAddress);
}
action(wopiData, req, res, userAddress);
};

View File

@ -16,54 +16,54 @@
*
*/
var lockDict = {};
const lockDict = {};
// get the lock object of the specified file
function getLockObject(filePath) {
return lockDict[filePath];
}
const getLockObject = function getLockObject(filePath) {
return lockDict[filePath];
};
// clear the lock timeout
function clearLockTimeout(lockObject) {
if (lockObject && lockObject.timeout) {
clearTimeout(lockObject.timeout);
}
}
const clearLockTimeout = function clearLockTimeout(lockObject) {
if (lockObject && lockObject.timeout) {
clearTimeout(lockObject.timeout);
}
};
// get the lock value of the specified file
function getLockValue(filePath) {
let lock = getLockObject(filePath); // get the lock object of the specified file
if (lock) return lock.value; // if it exists, get the lock value from it
return "";
}
const getLockValue = function getLockValue(filePath) {
const lock = getLockObject(filePath); // get the lock object of the specified file
if (lock) return lock.value; // if it exists, get the lock value from it
return '';
};
// check if the specified file path has lock or not
function hasLock(filePath) {
return !!getLockObject(filePath);
}
// lock file editing
function lock(filePath, lockValue) {
let oldLock = getLockObject(filePath); // get the old lock of the specified file
clearLockTimeout(oldLock); // clear its timeout
// create a new lock object
lockDict[filePath] = {
value: lockValue,
timeout: setTimeout(unlock, 1000 * 60 * 30, filePath) // set lock for 30 minutes
}
}
const hasLock = function hasLock(filePath) {
return !!getLockObject(filePath);
};
// allow for file editing
function unlock(filePath) {
let lock = getLockObject(filePath); // get the lock of the specified file
clearLockTimeout(lock); // clear its timeout
delete lockDict[filePath]; // delete the lock
}
const unlock = function unlock(filePath) {
const lock = getLockObject(filePath); // get the lock of the specified file
clearLockTimeout(lock); // clear its timeout
delete lockDict[filePath]; // delete the lock
};
// lock file editing
const lock = function lock(filePath, lockValue) {
const oldLock = getLockObject(filePath); // get the old lock of the specified file
clearLockTimeout(oldLock); // clear its timeout
// create a new lock object
lockDict[filePath] = {
value: lockValue,
timeout: setTimeout(unlock, 1000 * 60 * 30, filePath), // set lock for 30 minutes
};
};
module.exports = {
hasLock: hasLock,
getLock: getLockValue,
lock: lock,
unlock: unlock
}
hasLock,
getLock: getLockValue,
lock,
unlock,
};

View File

@ -18,55 +18,55 @@
// request types
const requestType = Object.freeze({
"None": 0,
None: 0,
"CheckFileInfo": 1,
"PutRelativeFile": 2,
CheckFileInfo: 1,
PutRelativeFile: 2,
"Lock": 3,
"GetLock": 4,
"Unlock": 5,
"RefreshLock": 6,
"UnlockAndRelock": 7,
Lock: 3,
GetLock: 4,
Unlock: 5,
RefreshLock: 6,
UnlockAndRelock: 7,
"ExecuteCobaltRequest": 8,
ExecuteCobaltRequest: 8,
"DeleteFile": 9,
"ReadSecureStore": 10,
"GetRestrictedLink": 11,
"RevokeRestrictedLink": 12,
DeleteFile: 9,
ReadSecureStore: 10,
GetRestrictedLink: 11,
RevokeRestrictedLink: 12,
"CheckFolderInfo": 13,
CheckFolderInfo: 13,
"GetFile": 14,
"PutFile": 16,
GetFile: 14,
PutFile: 16,
"EnumerateChildren": 16,
EnumerateChildren: 16,
"RenameFile": 17,
"PutUserInfo": 18,
RenameFile: 17,
PutUserInfo: 18,
});
// request headers
const requestHeaders = Object.freeze({
"RequestType": "X-WOPI-Override",
"ItemVersion": "X-WOPI-ItemVersion",
RequestType: 'X-WOPI-Override',
ItemVersion: 'X-WOPI-ItemVersion',
"Lock": "X-WOPI-Lock",
"OldLock": "X-WOPI-OldLock",
"LockFailureReason": "X-WOPI-LockFailureReason",
"LockedByOtherInterface": "X-WOPI-LockedByOtherInterface",
Lock: 'X-WOPI-Lock',
OldLock: 'X-WOPI-OldLock',
LockFailureReason: 'X-WOPI-LockFailureReason',
LockedByOtherInterface: 'X-WOPI-LockedByOtherInterface',
"FileConversion": "X-WOPI-FileConversion",
FileConversion: 'X-WOPI-FileConversion',
"SuggestedTarget": "X-WOPI-SuggestedTarget",
"RelativeTarget": "X-WOPI-RelativeTarget",
"OverwriteRelativeTarget": "X-WOPI-OverwriteRelativeTarget",
SuggestedTarget: 'X-WOPI-SuggestedTarget',
RelativeTarget: 'X-WOPI-RelativeTarget',
OverwriteRelativeTarget: 'X-WOPI-OverwriteRelativeTarget',
"ValidRelativeTarget": "X-WOPI-ValidRelativeTarget",
ValidRelativeTarget: 'X-WOPI-ValidRelativeTarget',
});
module.exports = {
requestType: requestType,
requestHeaders: requestHeaders,
}
requestType,
requestHeaders,
};

View File

@ -16,8 +16,4 @@
*
*/
exports.isValidToken = (req, res, next) => {
if (true) {
return next();
}
}
exports.isValidToken = (req, res, next) => next();

View File

@ -16,129 +16,141 @@
*
*/
const config = require("config");
const configServer = config.get("server");
var urlModule = require("url");
var urllib = require("urllib");
const xmlParser = require("fast-xml-parser");
const he = require("he");
const siteUrl = configServer.get("siteUrl"); // the path to the editors installation
const config = require('config');
const urlModule = require('url');
const urllib = require('urllib');
const xmlParser = require('fast-xml-parser');
const he = require('he');
var cache = null;
const configServer = config.get('server');
const siteUrl = configServer.get('siteUrl'); // the path to the editors installation
async function initWopi(docManager) {
let absSiteUrl = siteUrl;
if (absSiteUrl.indexOf("/") === 0) {
absSiteUrl = docManager.getServerHost() + siteUrl;
}
let cache = null;
// get the wopi discovery information
await getDiscoveryInfo(absSiteUrl);
}
const requestDiscovery = async function requestDiscovery(url) {
// eslint-disable-next-line no-unused-vars
return new Promise((resolve, reject) => {
const actions = [];
urllib.request(urlModule.parse(url + configServer.get('wopi.discovery')), { method: 'GET' }, (err, data) => {
if (data) {
// create the discovery XML file with the parameters from the response
const xmlParseOptions = {
attributeNamePrefix: '',
ignoreAttributes: false,
parseAttributeValue: true,
attrValueProcessor: (val) => he.decode(val, { isAttributeValue: true }),
};
const parser = new xmlParser.XMLParser(xmlParseOptions);
// create the discovery XML file with the parameters from the response
const discovery = parser.parse(data.toString());
if (discovery['wopi-discovery']) {
discovery['wopi-discovery']['net-zone'].app.forEach((app) => {
let appAction = app.action;
if (!Array.isArray(appAction)) {
appAction = [appAction];
}
appAction.forEach((action) => {
actions.push({ // write all the parameters to the actions element
app: app.name,
favIconUrl: app.favIconUrl,
checkLicense: app.checkLicense === 'true',
name: action.name,
ext: action.ext || '',
progid: action.progid || '',
isDefault: !!action.default,
urlsrc: action.urlsrc,
requires: action.requires || '',
});
});
});
}
}
resolve(actions);
});
});
};
// get the wopi discovery information
async function getDiscoveryInfo(siteUrl) {
let actions = [];
const getDiscoveryInfo = async function getDiscoveryInfo(url) {
let actions = [];
if (cache) return cache;
try {
actions = await requestDiscovery(siteUrl);
} catch (e) {
return actions;
}
cache = actions;
setTimeout(() => cache = null, 1000 * 60 * 60); // 1 hour
if (cache) return cache;
try {
actions = await requestDiscovery(url);
} catch (e) {
return actions;
}
}
async function requestDiscovery(siteUrl) {
return new Promise((resolve, reject) => {
var actions = [];
urllib.request(urlModule.parse(siteUrl + configServer.get("wopi.discovery")), {method: "GET"}, (err, data) => {
if (data) {
let discovery = xmlParser.parse(data.toString(), { // create the discovery XML file with the parameters from the response
attributeNamePrefix: "",
ignoreAttributes: false,
parseAttributeValue: true,
attrValueProcessor: (val, attrName) => he.decode(val, {isAttributeValue: true})
});
if (discovery["wopi-discovery"]) {
for (let app of discovery["wopi-discovery"]["net-zone"].app) {
if (!Array.isArray(app.action)) {
app.action = [app.action];
}
for (let action of app.action) {
actions.push({ // write all the parameters to the actions element
app: app.name,
favIconUrl: app.favIconUrl,
checkLicense: app.checkLicense == 'true',
name: action.name,
ext: action.ext || "",
progid: action.progid || "",
isDefault: action.default ? true : false,
urlsrc: action.urlsrc,
requires: action.requires || ""
});
}
}
}
}
resolve(actions);
});
})
}
cache = actions;
setTimeout(() => {
cache = null;
return cache;
}, 1000 * 60 * 60); // 1 hour
return actions;
};
const initWopi = async function initWopi(DocManager) {
let absSiteUrl = siteUrl;
if (absSiteUrl.indexOf('/') === 0) {
absSiteUrl = DocManager.getServerHost() + siteUrl;
}
// get the wopi discovery information
await getDiscoveryInfo(absSiteUrl);
};
// get actions of the specified extension
async function getActions(ext) {
let actions = await getDiscoveryInfo(); // get the wopi discovery information
let filtered = [];
const getActions = async function getActions(ext) {
const actions = await getDiscoveryInfo(); // get the wopi discovery information
const filtered = [];
for (let action of actions) { // and filter it by the specified extention
if (action.ext == ext) {
filtered.push(action);
}
actions.forEach((action) => { // and filter it by the specified extention
if (action.ext === ext) {
filtered.push(action);
}
});
return filtered;
}
return filtered;
};
// get an action for the specified extension and name
async function getAction(ext, name) {
let actions = await getDiscoveryInfo();
const getAction = async function getAction(ext, name) {
const actions = await getDiscoveryInfo();
let act = null;
for (let action of actions) {
if (action.ext == ext && action.name == name) {
return action;
}
actions.forEach((action) => {
if (action.ext === ext && action.name === name) {
act = action;
}
});
return null;
}
return act;
};
// get the default action for the specified extension
async function getDefaultAction(ext) {
let actions = await getDiscoveryInfo();
const getDefaultAction = async function getDefaultAction(ext) {
const actions = await getDiscoveryInfo();
let act = null;
for (let action of actions) {
if (action.ext == ext && action.isDefault) {
return action;
}
actions.forEach((action) => {
if (action.ext === ext && action.isDefault) {
act = action;
}
});
return null;
}
return act;
};
// get the action url
function getActionUrl(host, userAddress, action, filename) {
return action.urlsrc.replace(/<.*&>/g, "") + "WOPISrc=" + host + "/wopi/files/" + filename + "@" + userAddress;
}
const getActionUrl = function getActionUrl(host, userAddress, action, filename) {
return `${action.urlsrc.replace(/<.*&>/g, '')}WOPISrc=${host}/wopi/files/${filename}@${userAddress}`;
};
exports.initWopi = initWopi;
exports.getDiscoveryInfo = getDiscoveryInfo;
exports.getAction = getAction;
exports.getActions = getActions;
exports.getActionUrl = getActionUrl;
exports.getDefaultAction = getDefaultAction;
exports.getDefaultAction = getDefaultAction;

View File

@ -16,157 +16,160 @@
*
*/
const tokenValidator = require("./tokenValidator");
const filesController = require("./filesController");
const utils = require("./utils");
const docManager = require("../docManager");
const fileUtility = require("../fileUtility");
const config = require('config');
const tokenValidator = require('./tokenValidator');
const filesController = require('./filesController');
const utils = require('./utils');
const DocManager = require('../docManager');
const fileUtility = require('../fileUtility');
const users = require('../users');
const configServer = config.get('server');
const siteUrl = configServer.get("siteUrl"); // the path to the editors installation
const users = require("../users");
const siteUrl = configServer.get('siteUrl'); // the path to the editors installation
getCustomWopiParams = function (query) {
let tokenParams = "";
let actionParams = "";
const getCustomWopiParams = function getCustomWopiParams(query) {
let tokenParams = '';
let actionParams = '';
const userid = query.userid; // user id
tokenParams += (userid ? "&userid=" + userid : "");
const { userid } = query; // user id
tokenParams += (userid ? `&userid=${userid}` : '');
const lang = query.lang; // language
actionParams += (lang ? "&ui=" + lang : "");
const { lang } = query; // language
actionParams += (lang ? `&ui=${lang}` : '');
return { "tokenParams": tokenParams, "actionParams": actionParams };
return { tokenParams, actionParams };
};
exports.registerRoutes = function(app) {
exports.registerRoutes = function registerRoutes(app) {
// define a handler for the default wopi page
app.get('/wopi', async (req, res) => {
req.DocManager = new DocManager(req, res);
// define a handler for the default wopi page
app.get("/wopi", async function(req, res) {
await utils.initWopi(req.DocManager);
req.docManager = new docManager(req, res);
// get the wopi discovery information
const actions = await utils.getDiscoveryInfo();
const wopiEnable = actions.length !== 0;
const docsExtEdit = []; // Supported extensions for WOPI
await utils.initWopi(req.docManager);
// get the wopi discovery information
let actions = await utils.getDiscoveryInfo();
let wopiEnable = actions.length != 0 ? true : false;
let docsExtEdit = []; // Supported extensions for WOPI
actions.forEach(el => {
if (el.name == "edit") docsExtEdit.push("."+el.ext);
});
let editedExts = configServer.get('editedDocs').filter(i => docsExtEdit.includes(i)); // Checking supported extensions
let fillExts = configServer.get("fillDocs").filter(i => docsExtEdit.includes(i));
try {
// get all the stored files
let files = req.docManager.getStoredFiles();
// run through all the files and write the corresponding information to each file
for (var file of files) {
let ext = fileUtility.getFileExtension(file.name, true); // get an extension of each file
file.actions = await utils.getActions(ext); // get actions of the specified extension
file.defaultAction = await utils.getDefaultAction(ext); // get the default action of the specified extension
}
// render wopiIndex template with the parameters specified
res.render("wopiIndex", {
wopiEnable : wopiEnable,
storedFiles: wopiEnable ? files : [],
params: req.docManager.getCustomParams(),
users: users,
serverUrl: req.docManager.getServerUrl(),
preloaderUrl: siteUrl + configServer.get('preloaderUrl'),
convertExts: configServer.get('convertedDocs'),
editedExts: editedExts,
fillExts: fillExts,
languages: configServer.get('languages'),
});
} catch (ex) {
console.log(ex); // display error message in the console
res.status(500); // write status parameter to the response
res.render("error", { message: "Server error" }); // render error template with the message parameter specified
return;
}
});
// define a handler for creating a new wopi editing session
app.get("/wopi-new", function(req, res) {
var fileExt = req.query.fileExt; // get the file extension from the request
req.docManager = new docManager(req, res);
if (fileExt != null) { // if the file extension exists
var fileName = req.docManager.getCorrectName("new." + fileExt)
var redirectPath = req.docManager.getServerUrl(true) + "/wopi-action/" + encodeURIComponent(fileName) + "?action=editnew" + req.docManager.getCustomParams(); // get the redirect path
res.redirect(redirectPath);
return;
}
});
// define a handler for getting wopi action information by its id
app.get("/wopi-action/:id", async function(req, res) {
try {
req.docManager = new docManager(req, res);
await utils.initWopi(req.docManager);
var fileName = req.docManager.getCorrectName(req.params['id'])
var fileExt = fileUtility.getFileExtension(fileName, true); // get the file extension from the request
var user = users.getUser(req.query.userid); // get a user by the id
// get an action for the specified extension and name
let action = await utils.getAction(fileExt, req.query["action"]);
if (action != null && req.query["action"] == "editnew") {
fileName = req.docManager.RequestEditnew(req, fileName, user);
}
// render wopiAction template with the parameters specified
res.render("wopiAction", {
actionUrl: utils.getActionUrl(req.docManager.getServerUrl(true), req.docManager.curUserHostAddress(), action, req.params['id']),
token: "test",
tokenTtl: Date.now() + 1000 * 60 * 60 * 10,
params: getCustomWopiParams(req.query),
});
} catch (ex) {
console.log(ex);
res.status(500);
res.render("error", { message: "Server error" });
return;
}
actions.forEach((el) => {
if (el.name === 'edit') docsExtEdit.push(`.${el.ext}`);
});
// define a handler for getting file information by its id
app.route('/wopi/files/:id')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
// Checking supported extensions
const editedExts = fileUtility.getEditExtensions().filter((i) => docsExtEdit.includes(i));
const fillExts = fileUtility.getFillExtensions().filter((i) => docsExtEdit.includes(i));
// define a handler for reading/writing the file contents
app.route('/wopi/files/:id/contents')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
try {
// get all the stored files
const files = req.DocManager.getStoredFiles();
// define a handler for getting folder information by its id
app.route('/wopi/folders/:id')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
// run through all the files and write the corresponding information to each file
// eslint-disable-next-line no-restricted-syntax
for (const file of files) {
const ext = fileUtility.getFileExtension(file.name, true); // get an extension of each file
// eslint-disable-next-line no-await-in-loop
file.actions = await utils.getActions(ext); // get actions of the specified extension
// eslint-disable-next-line no-await-in-loop
file.defaultAction = await utils.getDefaultAction(ext);// get the default action of the specified extension
}
// define a handler for reading/writing the folder contents
app.route('/wopi/folders/:id/contents')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
// render wopiIndex template with the parameters specified
res.render('wopiIndex', {
wopiEnable,
storedFiles: wopiEnable ? files : [],
params: req.DocManager.getCustomParams(),
users,
preloaderUrl: siteUrl + configServer.get('preloaderUrl'),
convertExts: fileUtility.getConvertExtensions(),
editedExts,
fillExts,
languages: configServer.get('languages'),
});
} catch (ex) {
console.log(ex); // display error message in the console
res.status(500); // write status parameter to the response
// render error template with the message parameter specified
res.render('error', { message: 'Server error' });
}
});
// define a handler for creating a new wopi editing session
app.get('/wopi-new', (req, res) => {
const { fileExt } = req.query; // get the file extension from the request
// define a handler for upload files
app.route('/wopi/upload')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
req.DocManager = new DocManager(req, res);
if (fileExt) { // if the file extension exists
const fileName = req.DocManager.getCorrectName(`new.${fileExt}`);
const redirectPath = `${req.DocManager.getServerUrl(true)}/wopi-action/`
+ `${encodeURIComponent(fileName)}?action=editnew${req.DocManager.getCustomParams()}`; // get the redirect path
res.redirect(redirectPath);
}
});
// define a handler for getting wopi action information by its id
app.get('/wopi-action/:id', async (req, res) => {
try {
req.DocManager = new DocManager(req, res);
await utils.initWopi(req.DocManager);
let fileName = req.DocManager.getCorrectName(req.params.id);
const fileExt = fileUtility.getFileExtension(fileName, true); // get the file extension from the request
const user = users.getUser(req.query.userid); // get a user by the id
// get an action for the specified extension and name
const action = await utils.getAction(fileExt, req.query.action);
if (action && req.query.action === 'editnew') {
fileName = req.DocManager.requestEditnew(req, fileName, user);
}
// render wopiAction template with the parameters specified
res.render('wopiAction', {
actionUrl: utils.getActionUrl(
req.DocManager.getServerUrl(true),
req.DocManager.curUserHostAddress(),
action,
req.params.id,
),
token: 'test',
tokenTtl: Date.now() + 1000 * 60 * 60 * 10,
params: getCustomWopiParams(req.query),
});
} catch (ex) {
console.log(ex);
res.status(500);
res.render('error', { message: 'Server error' });
}
});
// define a handler for getting file information by its id
app.route('/wopi/files/:id')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
// define a handler for reading/writing the file contents
app.route('/wopi/files/:id/contents')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
// define a handler for getting folder information by its id
app.route('/wopi/folders/:id')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
// define a handler for reading/writing the folder contents
app.route('/wopi/folders/:id/contents')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
// define a handler for upload files
app.route('/wopi/upload')
.all(tokenValidator.isValidToken)
.get(filesController.fileRequestHandler)
.post(filesController.fileRequestHandler);
};

View File

@ -20,13 +20,17 @@ express - Fast, unopinionated, minimalist web framework for node. (https:/
License: MIT
License File: express.license
fast-xml-parser - Validate XML, Parse XML to JS/JSON and vice versa, or parse XML to Nimn rapidly without C/C++ based libraries and no callback. (https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/LICENSE)
License: MIT
License File: fast-xml-parser.license
formidable - A Node.js module for parsing form data, especially file uploads. (https://github.com/node-formidable/formidable/blob/master/LICENSE)
License: MIT
License File: formidable.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
he - a robust HTML entity encoder/decoder written in JavaScript. (https://github.com/mathiasbynens/he/blob/master/LICENSE-MIT.txt)
License: MIT
License File: jQuery.license
License File: he.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
@ -40,9 +44,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT

View File

@ -1,12 +1,12 @@
{
"name": "OnlineEditorsExampleNodeJS",
"version": "4.1.0",
"version": "1.6.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "OnlineEditorsExampleNodeJS",
"version": "4.1.0",
"version": "1.6.0",
"license": "Apache",
"dependencies": {
"body-parser": "^1.19.0",
@ -14,7 +14,7 @@
"debug": "^4.2.0",
"ejs": "^3.1.5",
"express": "^4.17.1",
"fast-xml-parser": "^3.19.0",
"fast-xml-parser": "^4.3.1",
"formidable": "^1.2.2",
"he": "^1.2.0",
"jsonwebtoken": "^9.0.0",
@ -1509,15 +1509,24 @@
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc="
},
"node_modules/fast-xml-parser": {
"version": "3.19.0",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.19.0.tgz",
"integrity": "sha512-4pXwmBplsCPv8FOY1WRakF970TjNGnGnfbOnLqjlYvMiF1SR3yOHyxMR/YCXpPTOspNF5gwudqktIP4VsWkvBg==",
"bin": {
"xml2js": "cli.js"
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.1.tgz",
"integrity": "sha512-viVv3xb8D+SiS1W4cv4tva3bni08kAkx0gQnWrykMM8nXPc1FxqZPU00dCEVjkiCg4HoXd2jC4x29Nzg/l2DAA==",
"funding": [
{
"type": "paypal",
"url": "https://paypal.me/naturalintelligence"
},
{
"type": "github",
"url": "https://github.com/sponsors/NaturalIntelligence"
}
],
"dependencies": {
"strnum": "^1.0.5"
},
"funding": {
"type": "paypal",
"url": "https://paypal.me/naturalintelligence"
"bin": {
"fxparser": "src/cli/cli.js"
}
},
"node_modules/fastq": {
@ -3515,6 +3524,11 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/strnum": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz",
"integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA=="
},
"node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
@ -4993,9 +5007,12 @@
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc="
},
"fast-xml-parser": {
"version": "3.19.0",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.19.0.tgz",
"integrity": "sha512-4pXwmBplsCPv8FOY1WRakF970TjNGnGnfbOnLqjlYvMiF1SR3yOHyxMR/YCXpPTOspNF5gwudqktIP4VsWkvBg=="
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.1.tgz",
"integrity": "sha512-viVv3xb8D+SiS1W4cv4tva3bni08kAkx0gQnWrykMM8nXPc1FxqZPU00dCEVjkiCg4HoXd2jC4x29Nzg/l2DAA==",
"requires": {
"strnum": "^1.0.5"
}
},
"fastq": {
"version": "1.13.0",
@ -6511,6 +6528,11 @@
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true
},
"strnum": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz",
"integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA=="
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "OnlineEditorsExampleNodeJS",
"version": "4.1.0",
"version": "1.6.0",
"private": false,
"scripts": {
"start": "node ./bin/www",
@ -22,7 +22,7 @@
"debug": "^4.2.0",
"ejs": "^3.1.5",
"express": "^4.17.1",
"fast-xml-parser": "^3.19.0",
"fast-xml-parser": "^4.3.1",
"formidable": "^1.2.2",
"he": "^1.2.0",
"jsonwebtoken": "^9.0.0",

View File

@ -1,8 +1 @@
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 3C0 1.34315 1.34315 0 3 0H21.674C22.4697 0 23.2327 0.316071 23.7953 0.87868L29.1213 6.20465C29.6839 6.76726 30 7.53032 30 8.32597V37C30 38.6569 28.6569 40 27 40H3C1.34315 40 0 38.6569 0 37V3Z" fill="#3779A6"/>
<path d="M22.9167 0L30.0001 7.08333H25.9167C24.2599 7.08333 22.9167 5.74019 22.9167 4.08333V0Z" fill="#1D5880"/>
<path d="M6.17627 14.7059H23.8233V15.8823H6.17627V14.7059Z" fill="white"/>
<path d="M6.17627 18.5294H23.8233V19.7059H6.17627V18.5294Z" fill="white"/>
<path d="M6.17627 22.3529H23.8233V23.5294H6.17627V22.3529Z" fill="white"/>
<path d="M6.17627 26.1765H23.8233V27.3529H6.17627V26.1765Z" fill="white"/>
</svg>
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 3c0-1.65685 1.34315-3 3-3h20l7 7v30c0 1.6569-1.3431 3-3 3H3c-1.65685 0-3-1.3431-3-3V3z" fill="#1E7AAA"/><path d="M23 0l7 7h-4c-1.6569 0-3-1.34315-3-3V0z" fill="#000" fill-opacity=".25"/><path d="M6 15h18v1H6v-1zM6 19h18v1H6v-1zM6 23h18v1H6v-1zM6 27h18v1H6v-1z" fill="#fff"/></svg>

Before

Width:  |  Height:  |  Size: 738 B

After

Width:  |  Height:  |  Size: 387 B

View File

@ -1,6 +1 @@
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 3C0 1.34315 1.34315 0 3 0H22.9167L30 7.08333V37C30 38.6569 28.6569 40 27 40H3C1.34315 40 0 38.6569 0 37V3Z" fill="#27ABA3"/>
<path d="M22.9165 0L29.9998 7.08333H25.9165C24.2597 7.08333 22.9165 5.74019 22.9165 4.08333V0Z" fill="#008078"/>
<rect x="6.5" y="15.5" width="17" height="5" stroke="white"/>
<rect x="6.5" y="23.5" width="17" height="5" stroke="white"/>
</svg>
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 3c0-1.65685 1.34315-3 3-3h20l7 7v30c0 1.6569-1.3431 3-3 3H3c-1.65685 0-3-1.3431-3-3V3z" fill="#27ABA3"/><path d="M23 0l7 7h-4c-1.6569 0-3-1.34315-3-3V0z" fill="#008078"/><path fill-rule="evenodd" clip-rule="evenodd" d="M24 14H6v7h18v-7zm-.8182 5.9978H6.81818V15H23.1818v4.9978zM24 23H6v7h18v-7zm-.8182 5.9978H6.81818V24H23.1818v4.9978z" fill="#fff"/></svg>

Before

Width:  |  Height:  |  Size: 477 B

After

Width:  |  Height:  |  Size: 463 B

View File

@ -1,8 +1 @@
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 3C0 1.34315 1.34315 0 3 0H22.9167L30 7.08333V37C30 38.6569 28.6569 40 27 40H3C1.34315 40 0 38.6569 0 37V3Z" fill="#F36700"/>
<path d="M22.9167 0L30.0001 7.08333H25.9168C24.2599 7.08333 22.9167 5.74019 22.9167 4.08333V0Z" fill="#AB531F"/>
<path d="M6.17627 16.1275H23.8233V17.3039H6.17627V16.1275Z" fill="white"/>
<path d="M6.17627 28.7745L6.17627 16.1275L7.35274 16.1275L7.35274 28.7745H6.17627Z" fill="white"/>
<path d="M23.8233 16.1275V28.7745H22.6469V16.1275L23.8233 16.1275Z" fill="white"/>
<path d="M6.17627 27.598H23.8233V28.7745H6.17627L6.17627 27.598Z" fill="white"/>
</svg>
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 3c0-1.65685 1.34315-3 3-3h20l7 7v30c0 1.6569-1.3431 3-3 3H3c-1.65685 0-3-1.3431-3-3V3z" fill="#F36700"/><path d="M23 0l7 7h-4c-1.6569 0-3-1.34315-3-3V0z" fill="#000" fill-opacity=".25"/><path stroke="#fff" stroke-opacity=".95" d="M6.5 15.5h17v12h-17z"/></svg>

Before

Width:  |  Height:  |  Size: 691 B

After

Width:  |  Height:  |  Size: 366 B

View File

@ -1,6 +1 @@
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M30 7.44186L22 0H3C1.22739 0 0 0.822551 0 2.32558V37.2093C0 38.7123 1.22739 40 3 40H27C28.7726 40 30 38.7123 30 37.2093V7.44186Z" fill="#D0D5DA"/>
<path d="M24.1042 7.27273H29.9631L22 0V5.32334C22 6.4105 22.949 7.27273 24.1042 7.27273Z" fill="#646464"/>
<path d="M16.9562 22.3485H12.9746V17.803H10.9839L14.9654 14.1667L18.947 17.803H16.9562V22.3485Z" fill="#646464"/>
<path d="M20.9378 23.7121C20.9378 24.1666 20.4401 24.6212 19.9424 24.6212H9.98848C9.49078 24.6212 8.99309 24.1666 8.99309 23.7121V22.3485C8.99309 21.8939 9.49078 21.4394 9.98848 21.4394H10.9839V20.0757H9.49078C8.49539 20.0757 7.5 20.9848 7.5 21.8939V24.1666C7.5 25.0757 8.61982 25.9848 9.49078 25.9848H20.4401C21.3111 25.9848 22.4309 25.0757 22.4309 24.1666V21.8939C22.4309 20.9848 21.4355 20.0757 20.4401 20.0757H18.947V21.4394H19.9424C20.4401 21.4394 20.9378 21.8939 20.9378 22.3485V23.7121Z" fill="#646464"/>
</svg>
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 3c0-1.65685 1.34315-3 3-3h20l7 7v30c0 1.6569-1.3431 3-3 3H3c-1.65685 0-3-1.3431-3-3V3z" fill="#D0D5DA"/><path d="M23 0l7 7h-4c-1.6569 0-3-1.34315-3-3V0z" fill="#646464"/><path fill-rule="evenodd" clip-rule="evenodd" d="M7.5 23c-.27614 0-.5.2239-.5.5v4c0 .2761.22386.5.5.5h15c.2761 0 .5-.2239.5-.5v-4c0-.2761-.2239-.5-.5-.5h-2c-.2761 0-.5-.2239-.5-.5s.2239-.5.5-.5h2c.8284 0 1.5.6716 1.5 1.5v4c0 .8284-.6716 1.5-1.5 1.5h-15c-.82843 0-1.5-.6716-1.5-1.5v-4c0-.8284.67157-1.5 1.5-1.5h2c.27614 0 .5.2239.5.5s-.22386.5-.5.5h-2z" fill="#646464"/><path fill-rule="evenodd" clip-rule="evenodd" d="M20 20.0001L15 14l-5 6.0001h3v4c0 .5523.4477 1 1 1h2c.5523 0 1-.4477 1-1v-4h3z" fill="#646464"/></svg>

Before

Width:  |  Height:  |  Size: 992 B

After

Width:  |  Height:  |  Size: 797 B

View File

@ -1,12 +1 @@
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 3C0 1.34315 1.34315 0 3 0H22.9167L30 7.08333V37C30 38.6569 28.6569 40 27 40H3C1.34315 40 0 38.6569 0 37V3Z" fill="#78A73B"/>
<path d="M22.9167 0L30.0001 7.08333H25.9168C24.2599 7.08333 22.9167 5.74019 22.9167 4.08333V0Z" fill="#5A7D2B"/>
<path d="M6.17644 15.2941H23.8235V16.4706H6.17644V15.2941Z" fill="white"/>
<path d="M6.17644 19.1177H23.8235V20.2941H6.17644V19.1177Z" fill="white"/>
<path d="M6.17644 22.9412H23.8235V24.1177H6.17644V22.9412Z" fill="white"/>
<path d="M6.17644 26.7647H23.8235V27.9412H6.17644V26.7647Z" fill="white"/>
<path d="M5.88232 27.9412L5.88232 15.2941L7.0588 15.2941L7.0588 27.9412H5.88232Z" fill="white"/>
<path d="M11.4706 27.9412L11.4706 15.2941L12.647 15.2941V27.9412H11.4706Z" fill="white"/>
<path d="M17.0588 27.9412L17.0588 15.2941L18.2353 15.2941V27.9412H17.0588Z" fill="white"/>
<path d="M22.647 27.9412V15.2941H23.8235V27.9412H22.647Z" fill="white"/>
</svg>
<svg width="30" height="40" viewBox="0 0 30 40" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 3c0-1.65685 1.34315-3 3-3h20l7 7v30c0 1.6569-1.3431 3-3 3H3c-1.65685 0-3-1.3431-3-3V3z" fill="#6AAA1E"/><path d="M23 0l7 7h-4c-1.6569 0-3-1.34315-3-3V0z" fill="#000" fill-opacity=".25"/><path fill-rule="evenodd" clip-rule="evenodd" d="M6 15h18v13H7.00001v-1H12v-3H7v4H6V15zm7 12h4v-3h-4v3zm5 0h5v-3h-5v3zm5-7v3h-5v-3h5zm-6 0v3h-4v-3h4zm-5 0v3H7v-3h5zm11-1v-3h-5v3h5zm-10-3h4v3h-4v-3zm-1 3v-3H7v3h5z" fill="#fff" fill-opacity=".95"/></svg>

Before

Width:  |  Height:  |  Size: 1004 B

After

Width:  |  Height:  |  Size: 545 B

View File

@ -34,30 +34,17 @@ if (typeof jQuery != "undefined") {
else
language = jq("#language").val();
jq("#language").change(function() {
window.location = "?lang=" + jq(this).val() + "&userid=" + userid + "&directUrl=" + directUrl;
});
if ("" != userid && undefined != userid)
jq("#user").val(userid);
else
userid = jq("#user").val();
jq("#user").change(function() {
window.location = "?lang=" + language + "&userid=" + jq(this).val() + "&directUrl=" + directUrl;
});
if (directUrl)
jq("#directUrl").prop("checked", directUrl);
else
directUrl = jq("#directUrl").prop("checked");
jq("#directUrl").change(function() {
window.location = "?lang=" + language + "&userid=" + userid + "&directUrl=" + jq(this).prop("checked");
});
jq(function () {
jq('#fileupload').fileupload({
@ -111,7 +98,7 @@ if (typeof jQuery != "undefined") {
}
});
});
var timer = null;
var checkConvert = function (filePass) {
filePass = filePass ? filePass : null;
@ -126,7 +113,7 @@ if (typeof jQuery != "undefined") {
jq("#filePass").val("");
var fileName = jq("#hiddenFileName").val();
var posExt = fileName.lastIndexOf('.');
var posExt = fileName.lastIndexOf('.') + 1;
posExt = 0 <= posExt ? fileName.substring(posExt).trim().toLowerCase() : '';
if (ConverExtList.indexOf(posExt) == -1) {
@ -207,7 +194,7 @@ if (typeof jQuery != "undefined") {
jq("#beginView, #beginEmbedded").removeClass("disable");
var fileName = jq("#hiddenFileName").val();
var posExt = fileName.lastIndexOf('.');
var posExt = fileName.lastIndexOf('.') + 1;
posExt = 0 <= posExt ? fileName.substring(posExt).trim().toLowerCase() : '';
var checkEdited = EditedExtList.split(",").filter(function(ext) { return ext == posExt;});
@ -230,6 +217,20 @@ if (typeof jQuery != "undefined") {
}
});
jq(document).on("click", ".action-link", function (e) {
e.preventDefault();
let url = this.href + collectParams(true);
let target = null;
if (e.target.hasAttribute("target")) {
target = e.target.getAttribute("target");
} else if (e.target.parentNode.hasAttribute("target")) {
target = e.target.parentNode.getAttribute("target");
}
target !== null ? window.open(url, target) : window.location = url;
});
jq(document).on("click", "#skipPass", function () {
jq("#blockPassword").hide();
loadScripts();
@ -238,32 +239,32 @@ if (typeof jQuery != "undefined") {
jq(document).on("click", "#beginEdit:not(.disable)", function () {
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
if (UrlEditor == "wopi-action"){
var url = UrlEditor + "/" + fileId + "?action=edit";
var url = UrlEditor + "/" + fileId + "?action=edit" + collectParams(true);
}else{
var url = UrlEditor + "?fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
var url = UrlEditor + "?fileName=" + fileId + collectParams(true);
}
window.open(url, "_blank");
jq('#hiddenFileName').val("");
jq.unblockUI();
document.location.reload(true);
window.location = collectParams();
});
jq(document).on("click", "#beginView:not(.disable)", function () {
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
if (UrlEditor == "wopi-action"){
var url = UrlEditor + "/" + fileId + "?action=view";
var url = UrlEditor + "/" + fileId + "?action=view" + collectParams(true);
}else{
var url = UrlEditor + "?mode=view&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
var url = UrlEditor + "?mode=view&fileName=" + fileId + collectParams(true);
}
window.open(url, "_blank");
jq('#hiddenFileName').val("");
jq.unblockUI();
document.location.reload(true);
window.location = collectParams();
});
jq(document).on("click", "#beginEmbedded:not(.disable)", function () {
var fileId = encodeURIComponent(jq('#hiddenFileName').val());
var url = UrlEditor + "?type=embedded&fileName=" + fileId + "&lang=" + language + "&userid=" + userid + "&directUrl=" + directUrl;
var url = UrlEditor + "?type=embedded&fileName=" + fileId + collectParams(true);
jq("#mainProgress").addClass("embedded");
jq("#beginEmbedded").addClass("disable");
@ -272,13 +273,13 @@ if (typeof jQuery != "undefined") {
});
jq(document).on("click", ".reload-page", function () {
setTimeout(function () { document.location.reload(true); }, 1000);
setTimeout(function () { window.location = collectParams(); }, 1000);
return true;
});
jq(document).on("mouseup", ".reload-page", function (event) {
if (event.which == 2) {
setTimeout(function () { document.location.reload(true); }, 1000);
setTimeout(function () { window.location = collectParams(); }, 1000);
}
return true;
});
@ -288,12 +289,13 @@ if (typeof jQuery != "undefined") {
jq("#embeddedView").remove();
jq.unblockUI();
if (mustReload) {
document.location.reload(true);
window.location = collectParams();
}
});
jq(document).on("click", ".delete-file", function () {
var fileName = jq(this).attr("data");
const currentElement = jq(this);
var fileName = currentElement.attr("data");
var requestAddress = "file?filename=" + fileName;
@ -303,7 +305,16 @@ if (typeof jQuery != "undefined") {
type: "delete",
url: requestAddress,
complete: function (data) {
document.location.reload(true);
if (JSON.parse(data.responseText).success) {
const parentRow = currentElement.parents('tr')[0];
if (parentRow) {
jq(parentRow).remove();
}
const remainingRows = jq('tr.tableRow');
if (remainingRows.length === 0) {
window.location = collectParams();
}
}
}
});
});
@ -394,4 +405,32 @@ function getUrlVars() {
vars[hash[0]] = hash[1];
}
return vars;
};
};
function collectParams(startParams) {
let paramsObjects = Array.prototype.slice.call(document.getElementsByClassName('collectable'));
let params = [];
let startChar = startParams ? "&" : "?";
paramsObjects.forEach( function (element) {
if (element.name) {
switch (element.type) {
case "select-one":
case "text":
if (element.value) {
params.push(element.name + "=" + element.value);
}
break;
case "checkbox":
params.push(element.name + "=" + element.checked);
break;
case "radio":
if (element.checked) {
params.push(element.name + "=" + element.value);
}
break;
default:
}
}
});
return startChar + params.join("&");
}

View File

@ -39,6 +39,7 @@
var docEditor;
var config;
let historyObject;
var innerAlert = function (message, inEditor) {
if (console && console.log)
@ -72,26 +73,72 @@
};
var onRequestHistory = function (event) { // the user is trying to show the document version history
var historyObj = <%- JSON.stringify(history) %> || null;
docEditor.refreshHistory( // show the document version history
const fileName = "<%- file.name %>" || null;
const directUrl = "<%- file.directUrl %>" || null;
const data = {
fileName: fileName,
directUrl: directUrl
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "historyObj");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(data));
xhr.onload = function () {
historyObject = JSON.parse(xhr.responseText);
docEditor.refreshHistory( // show the document version history
{
currentVersion: "<%- file.version %>",
history: historyObj
currentVersion: historyObject.countVersion,
history: historyObject.history
});
}
};
var onRequestHistoryData = function (data) { // the user is trying to click the specific document version in the document version history
var version = data.data;
var historyData = <%- JSON.stringify(historyData) %> || null;
docEditor.setHistoryData(historyData[version-1]); // send the link to the document for viewing the version history
var onRequestHistoryData = function (event) { // the user is trying to click the specific document version in the document version history
const version = event.data;
docEditor.setHistoryData(historyObject.historyData[version-1]); // send the link to the document for viewing the version history
};
var onRequestHistoryClose = function (event){ // the user is trying to go back to the document from viewing the document version history
document.location.reload();
};
var onRequestRestore = function (event) { // the user is trying to restore file version
const version = event.data.version;
const fileName = "<%- file.name %>" || null;
const directUrl = "<%- file.directUrl %>" || null;
const restoreData = {
version: version,
fileName: fileName,
};
let xhr = new XMLHttpRequest();
xhr.open("PUT", "restore");
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify(restoreData));
xhr.onload = function () {
const response = JSON.parse(xhr.responseText);
if (response.success && !response.error) {
const dataForHistory = {
fileName: fileName,
directUrl: directUrl
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "historyObj");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(dataForHistory));
xhr.onload = function () {
historyObject = JSON.parse(xhr.responseText);
docEditor.refreshHistory( // show the document version history
{
currentVersion: historyObject.countVersion,
history: historyObject.history
});
}
} else {
innerAlert(response.error);
}
}
}
var onError = function (event) { // an error or some other specific event occurs
if (event)
innerAlert(event.data);
@ -125,23 +172,39 @@
};
var onRequestInsertImage = function(event) { // the user is trying to insert an image by clicking the Image from Storage button
docEditor.insertImage({ // insert an image into the file
"c": event.data.c,
<%- JSON.stringify(dataInsertImage).substring(1, JSON.stringify(dataInsertImage).length - 1)%>
})
var data = <%- JSON.stringify(dataInsertImage) %>;
data.c = event.data.c;
docEditor.insertImage(data); // insert an image into the file
};
var onRequestCompareFile = function() { // the user is trying to select document for comparing by clicking the Document from Storage button
docEditor.setRevisedFile(<%- JSON.stringify(dataCompareFile) %>); // select a document for comparing
var onRequestSelectDocument = function() { // the user is trying to select document by clicking the Document from Storage button
var data = <%- JSON.stringify(dataDocument) %>;
data.c = event.data.c;
docEditor.setRequestedDocument(data); // select a document
};
var onRequestMailMergeRecipients = function (event) { // the user is trying to select recipients data by clicking the Mail merge button
docEditor.setMailMergeRecipients(<%- JSON.stringify(dataMailMergeRecipients) %>); // insert recipient data for mail merge into the file
var onRequestSelectSpreadsheet = function (event) { // the user is trying to select recipients data by clicking the Mail merge button
var data = <%- JSON.stringify(dataSpreadsheet) %>;
data.c = event.data.c;
docEditor.setRequestedSpreadsheet(data); // insert recipient data for mail merge into the file
};
var onRequestUsers = function () {
docEditor.setUsers({ // set a list of users to mention in the comments
"users": <%- JSON.stringify(usersForMentions) %>
var onRequestUsers = function (event) {
if (event && event.data){
var c = event.data.c;
}
switch (c) {
case "protect":
var users = <%- JSON.stringify(usersForProtect) %>;
break;
default:
users = <%- JSON.stringify(usersForMentions) %>;
}
docEditor.setUsers({
"c": c,
"users": users,
});
};
@ -151,22 +214,93 @@
innerAlert("onRequestSendNotify: " + data);
};
var onRequestOpen = function(event) { // user open external data source
innerAlert("onRequestOpen");
var windowName = event.data.windowName;
requestReference(event.data, function (data) {
if (data.error) {
var winEditor = window.open("", windowName);
winEditor.close();
innerAlert(data.error, true);
return;
}
var link = data.link;
window.open(link, windowName);
});
};
var onRequestReferenceData = function(event) { // user refresh external data source
innerAlert("onRequestReferenceData");
innerAlert(event.data);
requestReference(event.data, function (data) {
docEditor.setReferenceData(data);
});
};
var requestReference = function(data, callback) {
innerAlert(data);
event.data.directUrl = !!config.document.directUrl;
let xhr = new XMLHttpRequest();
xhr.open("POST", "reference");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(event.data));
xhr.send(JSON.stringify(data));
xhr.onload = function () {
innerAlert(xhr.responseText);
docEditor.setReferenceData(JSON.parse(xhr.responseText));
callback(JSON.parse(xhr.responseText));
}
};
var onRequestReferenceSource = function (event) {
innerAlert("onRequestReferenceSource");
let xhr = new XMLHttpRequest();
xhr.open("GET", "files/");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send();
xhr.onload = function () {
if (xhr.status === 200) {
innerAlert(JSON.parse(xhr.responseText));
let fileList = JSON.parse(xhr.responseText);
let firstXlsxName;
let file;
for (var i = 0; i < fileList.length; i++) {
file = fileList[i];
if (file["title"]) {
if (getFileExt(file["title"]) === "xlsx")
{
firstXlsxName = file["title"];
break;
}
}
}
if (firstXlsxName) {
let data = {
directUrl : "<%- file.directUrl %>" || false,
path : firstXlsxName
};
let xhr = new XMLHttpRequest();
xhr.open("POST", "reference");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(data));
xhr.onload = function () {
if (xhr.status === 200) {
docEditor.setReferenceSource(JSON.parse(xhr.responseText));
} else {
innerAlert("/reference - bad status");
}
}
} else {
innerAlert("No *.xlsx files");
}
} else {
innerAlert("/files - bad status");
}
}
};
var onRequestSaveAs = function (event) { // the user is trying to save file by clicking Save Copy as... button
var title = event.data.title;
var url = event.data.url;
@ -213,8 +347,9 @@
"onMakeActionLink": onMakeActionLink,
"onMetaChange": onMetaChange,
"onRequestInsertImage": onRequestInsertImage,
"onRequestCompareFile": onRequestCompareFile,
"onRequestMailMergeRecipients": onRequestMailMergeRecipients,
"onRequestSelectDocument": onRequestSelectDocument,
"onRequestSelectSpreadsheet": onRequestSelectSpreadsheet,
"onRequestOpen": onRequestOpen,
};
if (<%- JSON.stringify(editor.userid) %> != null) {
@ -222,10 +357,12 @@
config.events.onRequestHistory = onRequestHistory;
config.events.onRequestHistoryData = onRequestHistoryData;
config.events.onRequestHistoryClose = onRequestHistoryClose;
config.events.onRequestRestore = onRequestRestore;
config.events.onRequestRename = onRequestRename;
config.events.onRequestUsers = onRequestUsers;
config.events.onRequestSendNotify = onRequestSendNotify;
config.events.onRequestReferenceData = onRequestReferenceData;
config.events.onRequestReferenceSource = onRequestReferenceSource;
}
if (config.editorConfig.createUrl) {
@ -265,6 +402,13 @@
}
};
const getFileExt = function (fileName) {
if (fileName.indexOf(".")) {
return fileName.split('.').reverse()[0];
}
return false;
};
if (window.addEventListener) {
window.addEventListener("load", connectEditor);
window.addEventListener("resize", fixSize);

View File

@ -32,7 +32,7 @@
<body>
<header>
<div class="center">
<a href="">
<a href="./">
<img src ="images/logo.svg" alt="ONLYOFFICE" />
</a>
</div>
@ -48,16 +48,16 @@
<div class="create-panel clearFix">
<ul class="try-editor-list clearFix">
<li>
<a class="try-editor word reload-page" target="_blank" href="editor?fileExt=docx<%= params %>" title="Create new document">Document</a>
<a class="try-editor word reload-page action-link" target="_blank" href="editor?fileExt=docx" title="Create new document">Document</a>
</li>
<li>
<a class="try-editor cell reload-page" target="_blank" href="editor?fileExt=xlsx<%= params %>" title="Create new spreadsheet">Spreadsheet</a>
<a class="try-editor cell reload-page action-link" target="_blank" href="editor?fileExt=xlsx" title="Create new spreadsheet">Spreadsheet</a>
</li>
<li>
<a class="try-editor slide reload-page" target="_blank" href="editor?fileExt=pptx<%= params %>" title="Create new presentation">Presentation</a>
<a class="try-editor slide reload-page action-link" target="_blank" href="editor?fileExt=pptx" title="Create new presentation">Presentation</a>
</li>
<li>
<a class="try-editor form reload-page" target="_blank" href="editor?fileExt=docxf<%= params %>" title="Create new form template">Form template</a>
<a class="try-editor form reload-page action-link" target="_blank" href="editor?fileExt=docxf" title="Create new form template">Form template</a>
</li>
</ul>
<label class="side-option">
@ -67,7 +67,7 @@
<div class="upload-panel clearFix">
<a class="file-upload">Upload file
<input type="file" id="fileupload" name="uploadedFile" data-url="upload?<%= params %>" />
<input type="file" id="fileupload" name="uploadedFile" data-url="upload" />
</a>
</div>
@ -77,7 +77,7 @@
<td valign="middle">
<span class="select-user">Username</span>
<img id="info" class="info" src="images/info.svg" />
<select class="select-user" id="user">
<select class="select-user collectable" name="userid" id="user">
<% users.forEach(user => { %>
<option value="<%= user.id %>"><%= user.name == null ? "Anonymous" : user.name %></option>
<% }) %>
@ -88,7 +88,7 @@
<td valign="middle">
<span class="select-user">Language</span>
<img class="info info-tooltip" data-id="language" data-tooltip="Choose the language for ONLYOFFICE editors interface" src="images/info.svg" />
<select class="select-user" id="language">
<select class="select-user collectable" name="lang" id="language">
<% Object.keys(languages).forEach(key => { %>
<option value="<%= key %>"><%= languages[key] %></option>
<% }) %>
@ -98,7 +98,7 @@
<tr>
<td valign="middle">
<label class="side-option">
<input id="directUrl" type="checkbox" class="checkbox" />Try opening on client
<input id="directUrl" type="checkbox" class="checkbox collectable" name="directUrl" />Try opening on client
<img id="directUrlInfo" class="info info-tooltip" data-id="directUrlInfo" data-tooltip="Some files can be opened in the user's browser without connecting to the document server." src="images/info.svg" />
</label>
</td>
@ -107,7 +107,7 @@
</table>
<div class="links-panel links-panel-border clearFix">
<a href="<%= serverUrl %>/wopi" class="">Go to WOPI page</a>
<a href="wopi" class="">Go to WOPI page</a>
</div>
</div>
</div>
@ -154,33 +154,33 @@
<% for (var i = 0; i < storedFiles.length; i++) { %>
<tr class="tableRow" title="<%= storedFiles[i].name %> [<%= storedFiles[i].version %>]">
<td class="contentCells">
<a class="stored-edit <%= storedFiles[i].documentType %>" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="stored-edit <%= storedFiles[i].documentType %> action-link" href="editor?fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<span><%= storedFiles[i].name %></span>
</a>
</td>
<% if (storedFiles[i].canEdit) { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/desktop.svg" alt="Open in editor for full size screens" title="Open in editor for full size screens" /></a>
</td>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=comment&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=comment&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/comment.svg" alt="Open in editor for comment" title="Open in editor for comment" /></a>
</td>
<% if (storedFiles[i].documentType == "word") { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=review&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/review.svg" alt="Open in editor for review" title="Open in editor for review" /></a>
</td>
<% } else if (storedFiles[i].documentType == "cell") { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=filter&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=filter&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/filter.svg" alt="Open in editor without access to change the filter" title="Open in editor without access to change the filter" /></a>
</td>
<% } %>
<% if (storedFiles[i].documentType == "word") { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=blockcontent&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=blockcontent&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/block-content.svg" alt="Open in editor without content control modification" title="Open in editor without content control modification" /></a>
</td>
<% } else { %>
@ -189,44 +189,44 @@
<% if (storedFiles[i].documentType !== "word" && storedFiles[i].documentType !== "cell") {%>
<td class="contentCells contentCells-icon "></td>
<% } %>
<% if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.')).trim().toLowerCase()) !== -1) { %>
<% if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.') + 1).trim().toLowerCase()) !== -1) { %>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/fill-forms.svg" alt="Open in editor for filling in forms" title="Open in editor for filling in forms" /></a>
</td>
<% } else {%>
<td class="contentCells contentCells-icon"></td>
<%}%>
<td class="contentCells contentCells-shift contentCells-icon firstContentCellShift">
<a href="editor?type=mobile&mode=edit&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=mobile&mode=edit&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/mobile.svg" alt="Open in editor for mobile devices" title="Open in editor for mobile devices" /></a>
</td>
<% } else if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.')).trim().toLowerCase()) !== -1) { %>
<% } else if (fillExts.indexOf(storedFiles[i].name.substring(storedFiles[i].name.lastIndexOf('.') + 1).trim().toLowerCase()) !== -1) { %>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon "></td>
<td class="contentCells contentCells-icon">
<a href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/fill-forms.svg" 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 firstContentCellShift">
<a href="editor?type=mobile&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=mobile&mode=fillForms&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/mobile-fill-forms.svg" alt="Open in editor for filling in forms for mobile devices" title="Open in editor for filling in forms for mobile devices" /></a>
</td>
<% } else { %>
<td class="contentCells contentCells-shift contentCells-icon contentCellsEmpty" colspan="6"></td>
<% } %>
<td class="contentCells contentCells-icon firstContentCellViewers">
<a href="editor?type=desktop&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=desktop&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/desktop.svg" alt="Open in viewer for full size screens" title="Open in viewer for full size screens" /></a>
</td>
<td class="contentCells contentCells-icon">
<a href="editor?type=mobile&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=mobile&mode=view&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/mobile.svg" alt="Open in viewer for mobile devices" title="Open in viewer for mobile devices" /></a>
</td>
<td class="contentCells contentCells-icon contentCells-shift">
<a href="editor?type=embedded&mode=embedded&fileName=<%= encodeURIComponent(storedFiles[i].name) + params %>" target="_blank">
<a class="action-link" href="editor?type=embedded&mode=embedded&fileName=<%= encodeURIComponent(storedFiles[i].name) %>" target="_blank">
<img src="images/embeded.svg" alt="Open in embedded mode" title="Open in embedded mode" /></a>
</td>
<td class="contentCells contentCells-icon contentCells-shift downloadContentCellShift">

View File

@ -35,7 +35,7 @@
<body>
<header>
<div class="center">
<a href="">
<a href="wopi">
<img src="images/logo.svg" alt="ONLYOFFICE" />
</a>
</div>
@ -51,16 +51,16 @@
<div class="create-panel clearFix">
<ul class="try-editor-list clearFix">
<li>
<a class="try-editor word reload-page" target="_blank" href="<%= serverUrl %>/wopi-new?fileExt=docx<%= params %>" title="Create new document">Document</a>
<a class="try-editor word reload-page action-link" target="_blank" href="wopi-new?fileExt=docx" title="Create new document">Document</a>
</li>
<li>
<a class="try-editor cell reload-page" target="_blank" href="<%= serverUrl %>/wopi-new?fileExt=xlsx<%= params %>" title="Create new spreadsheet">Spreadsheet</a>
<a class="try-editor cell reload-page action-link" target="_blank" href="wopi-new?fileExt=xlsx" title="Create new spreadsheet">Spreadsheet</a>
</li>
<li>
<a class="try-editor slide reload-page" target="_blank" href="<%= serverUrl %>/wopi-new?fileExt=pptx<%= params %>" title="Create new presentation">Presentation</a>
<a class="try-editor slide reload-page action-link" target="_blank" href="wopi-new?fileExt=pptx" title="Create new presentation">Presentation</a>
</li>
<li>
<a class="try-editor form reload-page" target="_blank" href="<%= serverUrl %>/wopi-new?fileExt=docxf<%= params %>" title="Create new form template">Form template</a>
<a class="try-editor form reload-page action-link" target="_blank" href="wopi-new?fileExt=docxf" title="Create new form template">Form template</a>
</li>
</ul>
</div>
@ -68,7 +68,7 @@
<div class="upload-panel clearFix">
<a class="file-upload">Upload file
<input type="file" id="fileupload" name="uploadedFile" data-url="upload?<%= params %>" />
<input type="file" id="fileupload" name="uploadedFile" data-url="upload" />
</a>
</div>
@ -78,7 +78,7 @@
<td valign="middle">
<span class="select-user">Username</span>
<img id="info" class="info" data-id="user" src="images/info.svg" />
<select class="select-user" id="user">
<select class="select-user collectable" name="userid" id="user">
<% users.forEach(user => { %>
<option value="<%= user.id %>"><%= user.name == null ? "Anonymous" : user.name %></option>
<% }) %>
@ -89,7 +89,7 @@
<td valign="middle">
<span class="select-user">Language</span>
<img class="info info-tooltip" data-id="language" data-tooltip="Choose the language for ONLYOFFICE editors interface" src="images/info.svg" />
<select class="select-user" id="language">
<select class="select-user collectable" name="lang" id="language">
<% Object.keys(languages).forEach(key => { %>
<option value="<%= key %>"><%= languages[key] %></option>
<% }) %>
@ -100,7 +100,7 @@
</table>
<div class="links-panel links-panel-border clearFix">
<a href="<%= serverUrl %>/" class="">Go to Index page</a>
<a href="./" class="">Go to Index page</a>
</div>
</div>
</td>
@ -148,7 +148,7 @@
<tr class="tableRow" title="<%= storedFiles[i].name %> [<%= storedFiles[i].version %>]">
<td class="contentCells">
<% if (storedFiles[i].defaultAction) { %>
<a class="stored-edit <%= storedFiles[i].documentType %>" href="<%= serverUrl %>/wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].defaultAction.name %><%= params %>" target="_blank">
<a class="stored-edit <%= storedFiles[i].documentType %> action-link" href="wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].defaultAction.name %>" target="_blank">
<%} else { %>
<a class="stored-edit <%= storedFiles[i].documentType %>" href="#">
<% } %>
@ -158,7 +158,7 @@
<% if (storedFiles[i].actions && storedFiles[i].actions.length > 0) { %>
<td class="contentCells contentCells-wopi contentCells-shift">
<% for (var j = 0; j < storedFiles[i].actions.length; j++) { %>
<a href="<%= serverUrl %>/wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].actions[j].name %><%= params %>" target="_blank">
<a class="action-link" href="wopi-action/<%= encodeURIComponent(storedFiles[i].name) %>?action=<%= storedFiles[i].actions[j].name %>" target="_blank">
<img
src="images/wopi-<%= storedFiles[i].actions[j].name %>.svg"
alt="<%= storedFiles[i].actions[j].name %>" title="<%= storedFiles[i].actions[j].name %>" />
@ -167,7 +167,7 @@
</td>
<% } %>
<td class="contentCells contentCells-icon contentCells-shift downloadContentCells">
<a href="<%= serverUrl %>/wopi/files/<%= encodeURIComponent(storedFiles[i].name) %>/contents">
<a href="wopi/files/<%= encodeURIComponent(storedFiles[i].name) %>/contents">
<img class="icon-download" src="images/download.svg" alt="Download" title="Download" /></a>
</td>
<td class="contentCells contentCells-icon contentCells-shift">
@ -252,7 +252,8 @@
</div>
</footer>
<script type="text/javascript" src="javascripts/jquery-1.8.2.js"></script>
<script type="text/javascript" src="javascripts/jquery-3.6.4.min.js"></script>
<script type="text/javascript" src="javascripts/jquery-migrate-3.4.1.min.js"></script>
<script type="text/javascript" src="javascripts/jquery-ui.js"></script>
<script type="text/javascript" src="javascripts/jquery.blockUI.js"></script>
<script type="text/javascript" src="javascripts/jquery.iframe-transport.js"></script>

View File

@ -0,0 +1,2 @@
logs
vendor

View File

@ -0,0 +1 @@
8.1.21

View File

@ -1,9 +1,5 @@
ONLYOFFICE Applications example uses code from the following 3rd party projects:
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.BlockUI - The jQuery BlockUI Plugin lets you simulate synchronous behavior when using AJAX, without locking the browser. (https://github.com/malsup/blockui/)
License: MIT, GPL
License File: jQuery.BlockUI.license
@ -16,9 +12,13 @@ jQuery.iframe-transport - jQuery Iframe Transport Plugin for File Upload (https:
License: MIT
License File: jQuery.iframe-transport.license
jQuery - jQuery is a new kind of JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. NOTE: This package is maintained on behalf of the library owners by the NuGet Community Packages project at https://nugetpackages.codeplex.com/ (https://jquery.org/license/)
License: MIT
License File: jQuery.license
jQuery.Migrate - Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used. (https://github.com/jquery/jquery-migrate/blob/main/LICENSE.txt)
License: OpenJS
License File: jQuery.Migrate.license
License: OpenJS
License File: jQuery.Migrate.license
jQuery.UI - jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built according to jQuery's event-driven architecture (find something, manipulate it) and is themeable, making it easy for developers of any skill level to integrate and extend into their own code. (https://jquery.org/license/)
License: MIT
@ -31,3 +31,15 @@ License File: jwt.license
PHP_CodeSniffer - PHP_CodeSniffer is a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent. (https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt)
License: BSD-3-Clause
License File: PHP_CodeSniffer.license
PHPUnit - The PHP Unit Testing framework. (https://github.com/sebastianbergmann/phpunit/blob/main/LICENSE)
License: BSD 3-Clause
License File: phpunit.license
property-access - Provides functions to read and write from/to an object or array using a simple string notation. (https://github.com/symfony/property-access/blob/6.3/LICENSE)
License: MIT
License File: property-access.license
serializer - Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON. (https://github.com/symfony/serializer/blob/6.3/LICENSE)
License: MIT
License File: serializer.license

View File

@ -0,0 +1,14 @@
FROM php:8.2.8-fpm-alpine3.18 AS example
WORKDIR /srv
COPY . .
RUN \
chown -R www-data:www-data /srv && \
apk update && \
apk add --no-cache \
composer \
make && \
make prod
CMD ["make", "server-prod"]
FROM nginx:1.23.4-alpine3.17 AS proxy
COPY proxy/nginx.conf /etc/nginx/nginx.conf

View File

@ -0,0 +1,77 @@
.DEFAULT_GOAL := help
ADDRESS := $(ADDRESS)
PORT := $(PORT)
.PHONY: help
help: # Show help message for each of the Makefile recipes.
@grep -E "^[a-z-]+: #" $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ": # "}; {printf "%s: %s\n", $$1, $$2}'
.PHONY: dev
dev: # Install development dependencies.
@composer install
.PHONY: prod
prod: # Install production dependencies.
@composer install --no-dev
ifeq ($(ADDRESS),)
server-dev: \
export ADDRESS := localhost
else
server-dev: \
export ADDRESS := $(ADDRESS)
endif
ifeq ($(PORT),)
server-dev: \
export PORT := 9000
else
server-dev: \
export PORT := $(PORT)
endif
.PHONY: server-dev
server-dev: # Start the development server on localhost at $PORT (default: 9000).
@php --server $(ADDRESS):$(PORT)
ifeq ($(ADDRESS),)
server-prod: \
export ADDRESS := 0.0.0.0
else
server-prod: \
export ADDRESS := $(ADDRESS)
endif
ifeq ($(PORT),)
server-prod: \
export PORT := 9000
else
server-prod: \
export PORT := $(PORT)
endif
.PHONY: server-prod
server-prod: # Start the production server on 0.0.0.0 at $PORT (default: 9000).
@php-fpm --fpm-config php-fpm.conf
.PHONY: compose-prod
compose-prod: # Up containers in a production environment.
@docker-compose build
@docker-compose up --detach
.PHONY: lint
lint: # Lint the source code for the style.
@./vendor/bin/phpcs src index.php
.PHONY: test
test: # Run tests recursively.
@./vendor/bin/phpunit \
--test-suffix "Tests.php" \
--display-incomplete \
--display-deprecations \
--display-errors \
--display-notices \
--display-warnings \
src

View File

@ -1,202 +1,85 @@
## Overview
This example will help you integrate ONLYOFFICE Docs into your web application written in PHP.
This example will help you integrate ONLYOFFICE Docs into your web application written on PHP.
**Please note**: It is intended for testing purposes and demonstrating functionality of the editors. Do NOT use this integration example on your own server without proper code modifications! In case you enabled the test example, disable it before going for production.
> [!WARNING]
> It is intended for testing purposes and demonstrating functionality of the editors. **DO NOT** use this integration example on your own server without proper code modifications. In case you enabled the test example, disable it before going for production.
## For Windows
## Installation
### Step 1. Install ONLYOFFICE Docs
The PHP example offers various installation options, but we highly recommend using Docker for this purpose.
Download and install ONLYOFFICE Docs (packaged as Document Server).
### Using Docker
See the detailed guide to learn how to [install Document Server for Windows](https://helpcenter.onlyoffice.com/installation/docs-developer-install-windows.aspx?from=api_php_example).
To run the example using [Docker](https://docker.com), you will need [Docker Desktop 4.17.0](https://docs.docker.com/desktop) or [Docker Engine 20.10.23](https://docs.docker.com/engine) with [Docker Compose 2.15.1](https://docs.docker.com/compose). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools.
### Step 2. Download the PHP code for the editors integration
Once you have everything installed, download the release archive and unarchive it.
Download the [PHP example](https://api.onlyoffice.com/editors/demopreview) from our site.
To connect the editors to your website, specify the path to the editors installation and the path to the storage folder in the *config.json* file:
```
"storagePath" = "";
"docServSiteUrl" = "https://documentserver/";
```sh
$ curl --output PHP.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/latest/download/PHP.Example.zip
$ unzip PHP.Example.zip
```
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **storagePath** is the path where files will be created and stored. You can set an absolute path. For example, *D:\\\\folder*. Please note that on Windows OS the double backslash must be used as a separator.
Then open the example directory and [up containers](./Makefile#L60).
If you want to experiment with the editor configuration, modify the [parameters](https://api.onlyoffice.com/editors/advanced) in the *doceditor.php* file.
```sh
$ cd "PHP Example"
$ make compose-prod
```
### Step 3. Install the prerequisites
By default, the server starts at `localhost:80`.
You can use any web server capable of running PHP code to run the example. We will demonstrate how to run the PHP example using the **Internet Information Services (IIS)** web server. To set up and configure PHP on IIS, **PHP Manager for IIS** will be used.
To configure the example, you can edit the environment variables in [`docker-compose.yml`](./docker-compose.yml). See [below](#configuration) for more information about environment variables.
* **IIS**: version 7 or later (refer to [Microsoft official website](https://www.iis.net/learn/application-frameworks/scenario-build-a-php-website-on-iis/configuring-step-1-install-iis-and-php) to learn how to install IIS);
* **PHP** (download it from the [http://php.net](https://php.net/downloads.php) site);
* **PHP Manager for IIS** (download it from the [Microsoft open source site](https://phpmanager.codeplex.com/releases/view/69115)).
### On Local Machine
### Step 4. IIS configuration
Before diving into the example, you will need to install ONLYOFFICE Document Server (also known as Docs). Check the detailed guide to learn how to install it on [Windows](https://helpcenter.onlyoffice.com/installation/docs-developer-install-windows.aspx), [Linux](https://helpcenter.onlyoffice.com/installation/docs-developer-install-ubuntu.aspx), or [Docker](https://helpcenter.onlyoffice.com/installation/docs-developer-install-docker.aspx).
1. **PHP Manager for IIS** configuration.
To run the example on your local machine, you will need [PHP 8.2.11](https://php.net) with [Composer 2.6.5](https://getcomposer.org). Additionally, you might want to consider installing [GNU Make 4.4.1](https://gnu.org/software/make), although it is optional. These are the minimum versions required for the tools.
After PHP Manager for IIS installation is complete, launch the **IIS Manager:**
Once you have everything installed, download the release archive and unarchive it.
**Start** -> **Control Panel** -> **System and Security** -> **Administrative Tools** -> **Internet Information Services (IIS) Manager**
```sh
$ curl --output PHP.Example.zip --location https://github.com/ONLYOFFICE/document-server-integration/releases/latest/download/PHP.Example.zip
$ unzip PHP.Example.zip
```
and find the **PHP Manager** feature in the **Features View** in IIS.
Then open the example directory, [install dependencies](./Makefile#L16), and [start the server](./Makefile#L40).
![manager](screenshots/manager.png)
```sh
$ cd "PHP Example"
$ make prod
$ make server-prod
```
You need to register the installed PHP version in IIS using PHP Manager.
By default, the server starts at `0.0.0.0:9000`.
Double-click **PHP Manager** to open it, click the **Register new PHP version** task and specify the full path to the main PHP executable file location. For example: *C:\Program Files\PHP\php-cgi.exe*.
To configure the example, you can pass the environment variables before the command that starts the server. See [below](#configuration) for more information about environment variables.
![php-version-1](screenshots/php-version-1.jpg)
After clicking **OK**, the new **PHP version** will be registered with IIS and will become active.
![php-version-2](screenshots/php-version-2.jpg)
2. Configure IIS to handle PHP requests.
For IIS to host PHP applications, you must add handler mapping that tells IIS to pass all the PHP-specific requests to the PHP application framework by using the **FastCGI** protocol.
Double-click the **Handler Mappings** feature:
![handlerclick](screenshots/handlerclick.png)
In the **Action** panel, click **Add Module Mapping**. In the **Add Module Mapping** dialog box, specify the configuration settings as follows:
* **Request path**: *.php,
* **Module**: FastCgiModule,
* **Executable**: "C:\[Path to your PHP installation]\php-cgi.exe",
* **Name**: PHP via FastCGI.
Click **OK**.
![handler-add](screenshots/handler-add.png)
After IIS manager configuration is complete, everything is ready for running the PHP example.
### Step 5. Run your website with the editors
1. Add your website in the IIS Manager.
On the **Connections** panel right-click the **Sites** node in the tree, then click **Add Website**.
![add](screenshots/add.png)
2. In the **Add Website** dialog box, specify the name of the folder with the PHP project in the **Site name** box.
Specify the path to the folder with your project in the **Physical path** box.
Specify the unique value used only for this website in the **Port** box.
![php-add](screenshots/php-add.png)
3. Browse your website with the IIS manager:
Right-click the site -> **Manage Website** -> **Browse**
![browse](screenshots/browse.png)
### Step 6. Check accessibility
## Post Installation
In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files.
Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files.
## For Linux
## Configuration
### Step 1. Install ONLYOFFICE Docs
The example is configured by changing environment variables.
Download and install ONLYOFFICE Docs (packaged as Document Server).
| Name | Description | Example |
| ----------------------------- | ----------------------------------------------------------------------- | ----------------------- |
| `ADDRESS` | The address where the server should be started. | `0.0.0.0` |
| `PORT` | The port on which the server should be running. | `80` |
| `DOCUMENT_SERVER_PRIVATE_URL` | The URL through which the server will communicate with Document Server. | `http://proxy:8080` |
| `DOCUMENT_SERVER_PUBLIC_URL` | The URL through which a user will communicate with Document Server. | `http://localhost:8080` |
| `EXAMPLE_URL` | The URL through which Document Server will communicate with the server. | `http://proxy` |
| `JWT_SECRET` | JWT authorization secret. Leave blank to disable authorization. | `your-256-bit-secret` |
See the detailed guide to learn how to [install Document Server for Linux](https://helpcenter.onlyoffice.com/installation/docs-developer-install-ubuntu.aspx?from=api_php_example).
### Step 2. Install the prerequisites and run the website with the editors
1. Install **Apache** and **PHP**:
```
apt-get install -y apache2 php7.0 libapache2-mod-php7.0
```
2. Install **Composer**:
```
instructions should be here
```
3. Download the archive with the PHP example and unpack the archive:
```
cd /var/www/html
```
```
wget https://api.onlyoffice.com/app_data/editor/PHP%20Example.zip
```
```
unzip PHP\ Example.zip
```
4. Change the current directory for the project directory:
```
cd PHP\ Example/
```
5. Edit the *config.json* configuration file. Specify the name of your local server with the ONLYOFFICE Document Server installed.
```
nano config.json
```
Edit the following lines:
```
"storagePath" = "";
"docServSiteUrl" = "https://documentserver/";
```
where the **documentserver** is the name of the server with the ONLYOFFICE Document Server installed and the **STORAGE_PATH** is the path where files will be created and stored. You can set an absolute path.
6. Run *composer install*:
```
php composer.phar install
```
7. Set permission for site:
```
chown -R www-data:www-data /var/www/html
```
8. Restart apache:
```
service apache2 restart
```
9. See the result in your browser using the address:
```
http://localhost/PHP%20Example/
```
### Step 3. Check accessibility
In case the example and Document Server are installed on different computers, make sure that your server with the example installed has access to the Document Server with the address which you specify instead of **documentserver** in the configuration files.
Make sure that the Document Server has access to the server with the example installed with the address which you specify instead of **example.com** in the configuration files.
## Important security info
## Security Info
Please keep in mind the following security aspects when you are using test examples:
* There is no protection of the storage from unauthorized access since there is no need for authorization.
* There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts.
* There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server.
* There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain.
- There is no protection of the storage from unauthorized access since there is no need for authorization.
- There are no checks against parameter substitution in links, since the parameters are generated by the code according to the pre-arranged scripts.
- There are no data checks in requests of saving the file after editing, since each test example is intended for requests only from ONLYOFFICE Document Server.
- There are no prohibitions on using test examples from other sites, since they are intended to interact with ONLYOFFICE Document Server from another domain.

View File

@ -151,19 +151,19 @@ label .checkbox {
}
.try-editor.word {
background-image: url("images/file_docx.svg");
background-image: url("/assets/images/file_docx.svg");
}
.try-editor.cell {
background-image: url("images/file_xlsx.svg");
background-image: url("/assets/images/file_xlsx.svg");
}
.try-editor.slide {
background-image: url("images/file_pptx.svg");
background-image: url("/assets/images/file_pptx.svg");
}
.try-editor.form {
background-image: url("images/file_docxf.svg");
background-image: url("/assets/images/file_docxf.svg");
}
.side-option {
@ -235,7 +235,7 @@ label .checkbox {
}
.file-upload {
background: url("images/file_upload.svg") no-repeat 0 transparent;
background: url("/assets/images/file_upload.svg") no-repeat 0 transparent;
cursor: pointer;
display: block;
font-size: 14px;
@ -308,7 +308,7 @@ label .checkbox {
}
.error-message {
background: url("images/error.svg") no-repeat scroll 4px 10px;
background: url("/assets/images/error.svg") no-repeat scroll 4px 10px;
color: #CB0000;
display: none;
line-height: 160%;
@ -329,15 +329,15 @@ label .checkbox {
}
.current {
background-image: url("images/loader16.gif");
background-image: url("/assets/images/loader16.gif");
}
.done {
background-image: url("images/done.svg");
background-image: url("/assets/images/done.svg");
}
.error {
background-image: url("images/notdone.svg");
background-image: url("/assets/images/notdone.svg");
}
.step-descr {
@ -451,17 +451,17 @@ footer table tr td:first-child {
.stored-edit.word,
.uploadFileName.word {
background-image: url("images/icon_docx.svg");
background-image: url("/assets/images/icon_docx.svg");
}
.stored-edit.cell,
.uploadFileName.cell {
background-image: url("images/icon_xlsx.svg");
background-image: url("/assets/images/icon_xlsx.svg");
}
.stored-edit.slide,
.uploadFileName.slide {
background-image: url("images/icon_pptx.svg");
background-image: url("/assets/images/icon_pptx.svg");
}
.stored-edit span {
@ -490,7 +490,7 @@ footer table tr td:first-child {
}
.dialog-close {
background: url("images/close.svg") no-repeat scroll left top;
background: url("/assets/images/close.svg") no-repeat scroll left top;
cursor: pointer;
float: right;
font-size: 1px;
@ -766,4 +766,4 @@ html {
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
}

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

Before

Width:  |  Height:  |  Size: 781 B

After

Width:  |  Height:  |  Size: 781 B

View File

Before

Width:  |  Height:  |  Size: 547 B

After

Width:  |  Height:  |  Size: 547 B

View File

Before

Width:  |  Height:  |  Size: 425 B

After

Width:  |  Height:  |  Size: 425 B

View File

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 331 B

View File

Before

Width:  |  Height:  |  Size: 507 B

After

Width:  |  Height:  |  Size: 507 B

View File

Before

Width:  |  Height:  |  Size: 757 B

After

Width:  |  Height:  |  Size: 757 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

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