Merge remote-tracking branch 'remotes/origin/develop' into feature/delete-all-files

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Sergey Linnik
2024-03-15 16:48:58 +03:00
59 changed files with 478 additions and 284 deletions

View File

@ -1,13 +1,9 @@
# Change Log
- php: delete all files
- java: delete all files
- java-spring: delete all files
- python: delete all files
- ruby: delete all files
- csharp: delete all files
- csharp-mvc: delete all files
- nodejs: delete all files
- delete all files
- nodejs: wopi formsubmit icon
- php: handling conversion -9 error
- nodejs: tabs menu
- change insert image
- nodejs: handling conversion -9 error
- different goback for users

View File

@ -1,11 +1,11 @@
## Integration examples
Test examples are simple document management systems that can be built into your application for testing.
These test examples are simple document management systems that can be built into your application for testing.
Do NOT use these integration examples on your own server without proper code modifications!
In case you enabled any of the test examples, disable it before going for production.
These examples show the way to integrate [ONLYOFFICE Docs][2] into your own website or application using one of the programming languages.
The package contains examples written in .Net (C# MVC), .Net (C#), Java, Node.js, PHP and Ruby.
The package contains examples written in .Net (C# MVC), .Net (C#), Java, Java Spring, Node.js, PHP, Python and Ruby.
You should change `http://documentserver` to your server address in these files:
* [.Net (C# MVC)](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/csharp-mvc) - `web/documentserver-example/csharp-mvc/web.appsettings.config`
@ -13,9 +13,9 @@ You should change `http://documentserver` to your server address in these files:
* [Java](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/java) - `web/documentserver-example/java/src/main/resources/settings.properties`
* [Java Spring](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/java-spring) - `web/documentserver-example/java-spring/src/main/resources/application.properties`
* [Node.js](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/nodejs) - `web/documentserver-example/nodejs/config/default.json`
* [PHP](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/php) - `web/documentserver-example/php/config.json`
* [Python](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/python) - `web/documentserver-example/python/config.py`
* [Ruby](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/ruby) - `web/documentserver-example/ruby/config/application.rb`
* [PHP](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/php) - `web/documentserver-example/php/src/configuration/ConfigurationManager.php`
* [Python](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/python) - `web/documentserver-example/python/src/configuration/configuration.py`
* [Ruby](https://github.com/ONLYOFFICE/document-server-integration/tree/master/web/documentserver-example/ruby) - `web/documentserver-example/ruby/app/configuration/configuration.rb`
More information on how to use these examples can be found here: [http://api.onlyoffice.com/editors/demopreview](http://api.onlyoffice.com/editors/demopreview "http://api.onlyoffice.com/editors/demopreview")

View File

@ -23,6 +23,7 @@ using System.IO;
using static OnlineEditorsExampleMVC.Models.FileUtility;
using System.Linq;
using System.Text;
using Newtonsoft.Json.Converters;
namespace OnlineEditorsExampleMVC.Models
{
@ -48,9 +49,21 @@ namespace OnlineEditorsExampleMVC.Models
}
}
public class EmptyTolerantStringEnumConverter : StringEnumConverter
{
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.String && string.IsNullOrWhiteSpace(reader.Value.ToString()))
return Activator.CreateInstance(objectType);
return base.ReadJson(reader, objectType, existingValue, serializer);
}
}
public class Format
{
public string Name { get; }
[JsonConverter(typeof(EmptyTolerantStringEnumConverter))]
public FileType Type { get; }
public List<string> Actions { get; }
public List<string> Convert { get; }

View File

@ -19,6 +19,7 @@
package com.onlyoffice.integration.documentserver.util.service;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.onlyoffice.integration.documentserver.models.Format;
@ -41,6 +42,7 @@ public class DefaultFormatService implements FormatService {
final ObjectMapper objectMapper
) {
try {
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
File targetFile = resourceFile.getFile();
this.formats = objectMapper.readValue(targetFile, new TypeReference<List<Format>>() { });
} catch (Exception e) {

View File

@ -29,6 +29,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
public final class FormatManager {
@ -93,6 +94,7 @@ public final class FormatManager {
private List<Format> all() {
try {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
Path path = this.file();
return objectMapper.readValue(Files.readAllBytes(path), new TypeReference<List<Format>>() { });
} catch (Exception e) {

View File

@ -270,6 +270,18 @@ app.post('/create', (req, res) => {
try {
req.DocManager = new DocManager(req, res);
let host = siteUrl;
if (host.indexOf('/') === 0) {
host = req.DocManager.getServerHost();
}
if (urlModule.parse(fileUrl).host !== urlModule.parse(host).host) {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.write(JSON.stringify({ error: 'File domain is incorrect' }));
res.end();
return;
}
req.DocManager.storagePath(''); // mkdir if not exist
const fileName = req.DocManager.getCorrectName(title);
@ -645,7 +657,7 @@ app.post('/track', async (req, res) => { // define a handler for tracking file c
const zip = await urllib.request(downloadZip, { method: 'GET' });
const statusZip = zip.status;
const dataZip = zip.data;
if (status === 200) {
if (statusZip === 200) {
fileSystem.writeFileSync(pathChanges, dataZip); // write the document version differences to the archive
} else {
emitWarning(`Document editing service returned status: ${statusZip}`);
@ -928,6 +940,7 @@ app.get('/editor', (req, res) => { // define a handler for editing document
const { name } = user;
if (fileExt) {
fileExt = fileUtility.getFileExtension(fileUtility.getFileName(fileExt), true);
// create demo document of a given extension
const fName = req.DocManager.createDemo(!!req.query.sample, fileExt, userid, name, false);
@ -983,12 +996,19 @@ app.get('/editor', (req, res) => { // define a handler for editing document
const { userInfoGroups } = user;
const usersInfo = [];
const usersForProtect = [];
if (user.id !== 'uid-0') {
users.getAllUsers().forEach((userInfo) => {
const u = userInfo;
u.image = userInfo.avatar ? `${req.DocManager.getServerUrl()}/images/${userInfo.id}.png` : null;
usersInfo.push(u);
}, usersInfo);
users.getUsersForProtect(user.id).forEach((userInfo) => {
const u = userInfo;
u.image = userInfo.avatar ? `${req.DocManager.getServerUrl()}/images/${userInfo.id}.png` : null;
usersForProtect.push(u);
}, usersForProtect);
}
fileExt = fileUtility.getFileExtension(fileName);
@ -1092,7 +1112,7 @@ app.get('/editor', (req, res) => { // define a handler for editing document
directUrl: !userDirectUrl ? null : `${req.DocManager.getServerUrl()}/csv`,
},
usersForMentions: user.id !== 'uid-0' ? users.getUsersForMentions(user.id) : null,
usersForProtect: user.id !== 'uid-0' ? users.getUsersForProtect(user.id) : null,
usersForProtect,
usersInfo,
};

View File

@ -51,7 +51,7 @@ DocManager.prototype.createDirectory = function createDirectory(directory) {
// get the language from the request
DocManager.prototype.getLang = function getLang() {
if (/^[a-z]{2}(-[A-z]{4})?(-[A-Z]{2})?$/.test(this.req.query.lang)) {
if (/^[a-z]{2}(-[a-zA-z]{4})?(-[A-Z]{2})?$/.test(this.req.query.lang)) {
return this.req.query.lang;
} // the default language value is English
return 'en';

View File

@ -180,10 +180,7 @@ users.getUsersForProtect = function getUsersForProtect(id) {
const result = [];
this.forEach((user) => {
if (user.id !== id && user.name != null) {
result.push({
id: user.id,
name: user.name,
});
result.push(user);
}
});
return result;

View File

@ -27,57 +27,67 @@ const siteUrl = configServer.get('siteUrl'); // the path to the editors installa
let cache = null;
const requestDiscovery = async function requestDiscovery(url) {
const requestDiscovery = async function requestDiscovery() {
// eslint-disable-next-line no-unused-vars
return new Promise((resolve, reject) => {
const uri = siteUrl + configServer.get('wopi.discovery');
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 || '',
// 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: '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);
});
resolve(actions);
},
);
});
};
// get the wopi discovery information
const getDiscoveryInfo = async function getDiscoveryInfo(url) {
const getDiscoveryInfo = async function getDiscoveryInfo() {
let actions = [];
if (cache) return cache;
try {
actions = await requestDiscovery(url);
actions = await requestDiscovery();
} catch (e) {
return actions;
}
@ -91,16 +101,6 @@ const getDiscoveryInfo = async function getDiscoveryInfo(url) {
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
const getActions = async function getActions(ext) {
const actions = await getDiscoveryInfo(); // get the wopi discovery information
@ -149,7 +149,6 @@ const getActionUrl = function getActionUrl(host, userAddress, action, filename)
return `${action.urlsrc.replace(/<.*&>/g, '')}WOPISrc=${encodeURIComponent(WOPISrc)}`;
};
exports.initWopi = initWopi;
exports.getDiscoveryInfo = getDiscoveryInfo;
exports.getAction = getAction;
exports.getActions = getActions;

View File

@ -45,8 +45,6 @@ exports.registerRoutes = function registerRoutes(app) {
app.get('/wopi', async (req, res) => {
req.DocManager = new DocManager(req, res);
await utils.initWopi(req.DocManager);
// get the wopi discovery information
const actions = await utils.getDiscoveryInfo();
const wopiEnable = actions.length !== 0;
@ -111,8 +109,6 @@ exports.registerRoutes = function registerRoutes(app) {
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

View File

@ -0,0 +1,8 @@
<?xml version="1.0"?>
<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
<g class="layer">
<title>Layer 1</title>
<path d="m9.05,22.33l0,-5.9l5.9,0l0,5.9l5.9,0l0,-10.33l2.95,0l-11.8,-10.33l-11.8,10.33l2.95,0l0,10.33l5.9,0z" fill="#FF6F3D" id="svg_1"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 322 B

View File

@ -0,0 +1,4 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6 16V13H7V11H5C4.44772 11 4 11.4477 4 12V17C4 17.5523 4.44772 18 5 18H19C19.5523 18 20 17.5523 20 17V12C20 11.4477 19.5523 11 19 11H17V13H18V16H6Z" fill="#444444"/>
<path d="M11 15H9V13L16 6H17V7H18V8L11 15Z" fill="#444444"/>
</svg>

After

Width:  |  Height:  |  Size: 379 B

View File

@ -144,7 +144,7 @@
}
.scroll-table-body {
top: 31px;
top: 88px;
}
footer {
@ -411,7 +411,7 @@
}
.scroll-table-body {
top: 31px;
top: 88px;
}
footer table tr {

View File

@ -331,24 +331,47 @@ label .checkbox {
width: 192px;
}
.create-panel,
.links-panel {
.create-panel {
float: left;
padding: 16px 0;
}
.links-panel {
display: flex;
column-gap: 30px;
margin-bottom: 35px;
align-items: center;
}
.links-panel-current {
position: relative;
}
.links-panel-current::after {
content: "";
background-color: #ff6f3d;
position: absolute;
left: -10%;
bottom: -8px;
width: 120%;
height: 2.5px;
}
.links-panel a {
font-size: 14px;
text-decoration: none;
}
.links-panel-home {
width: 22px;
}
.upload-panel,
.create-panel {
width: 100%;
border-bottom: 1px solid #D0D5DA;
}
.links-panel-border {
margin-top: 24px;
width: 100%;
border-top: 1px solid #D0D5DA;
}
#mainProgress {
color: #333333;
display: none;
@ -837,7 +860,7 @@ footer table tr td:first-child {
overflow-x: auto;
position: absolute;
right: 0;
top: 71px;
top: 130px;
scrollbar-color: #D0D5DA transparent;
scrollbar-width: thin;
}

View File

@ -431,9 +431,11 @@
if (window.addEventListener) {
window.addEventListener("load", connectEditor);
window.addEventListener("resize", fixSize);
window.addEventListener("orientationchange", fixSize);
} else if (window.attachEvent) {
window.attachEvent("onload", connectEditor);
window.attachEvent("onresize", fixSize);
window.attachEvent("orientationchange", fixSize);
}
</script>

View File

@ -106,10 +106,6 @@
</tr>
</tbody>
</table>
<div class="links-panel links-panel-border clearFix">
<a href="wopi" class="">Go to WOPI page</a>
</div>
</div>
</div>
</td>
@ -137,6 +133,12 @@
<%if (storedFiles.length > 0)
{%>
<div class="stored-list">
<div class="links-panel">
<a href="./" class="links-panel-current">
<img src="images/home.svg" alt="Home" class="links-panel-home"/>
</a>
<a href="wopi">Wopi</a>
</div>
<div class="storedHeader">
<div class="storedHeaderText">
<span class="header-list">Your documents</span>

View File

@ -98,10 +98,6 @@
</tr>
</tbody>
</table>
<div class="links-panel links-panel-border clearFix">
<a href="./" class="">Go to Index page</a>
</div>
</div>
</td>
<td class="section">
@ -109,6 +105,12 @@
<div id="portal-info" style="display: <%= storedFiles.length > 0 ? "none" : "table-cell" %>">
<% if (!wopiEnable)
{ %>
<div class="links-panel">
<a href="./">
<img src="images/home.svg" alt="Home" class="links-panel-home"/>
</a>
<a href="wopi" class="links-panel-current">Wopi</a>
</div>
<span class="portal-name">ONLYOFFICE Document Editors Welcome!</span>
<span class="portal-descr">
Before you get started with a demo sample of ONLYOFFICE Docs, please enable the WOPI protocol.
@ -129,6 +131,12 @@
<% if (storedFiles.length > 0)
{ %>
<div class="stored-list">
<div class="links-panel">
<a href="./">
<img src="images/home.svg" alt="Home" class="links-panel-home"/>
</a>
<a href="wopi" class="links-panel-current">Wopi</a>
</div>
<div class="storedHeader">
<div class="storedHeaderText">
<span class="header-list">Your documents</span>

View File

@ -61,6 +61,12 @@ compose-prod: # Up containers in a production environment.
@docker-compose build
@docker-compose up --detach
.PHONY: restart
restart: # Restart containers replacing volume files.
@docker-compose rm --stop --force proxy example
@docker volume rm php_example
@docker compose up --detach --build
.PHONY: lint
lint: # Lint the source code for the style.
@./vendor/bin/phpcs src index.php

View File

@ -504,6 +504,17 @@
justify-content: space-between;
align-items: center;
}
.buttonsMobile.indent {
margin-bottom: 0;
flex-wrap: nowrap;
}
.button.file-type:hover,
.button.file-type {
height: 28px;
width: 100px;
margin-bottom: 10px !important;
font-size: 9px;
}
.button.gray{
margin: 0;
}

View File

@ -229,6 +229,33 @@ label .checkbox {
color: #FF6F3D;
}
.button.file-type {
font-size: 11px;
color: #FFFFFF;
padding: 8px 8px;
margin-right: 10px;
}
.button.file-type.disable {
cursor: default;
}
.button.file-type.pale {
opacity: 30%;
}
.button.file-type.document {
background: #446995;
}
.button.file-type.spreadsheet {
background: #40865C;
}
.button.file-type.presentation {
background: #AA5252;
}
.upload-panel {
float: left;
padding: 24px 0;
@ -766,6 +793,16 @@ html {
margin-left: 25px;
}
.buttonsMobile.indent{
padding-left: 35px;
margin-top: 10px;
margin-bottom: 10px;
}
.invisible {
display: none;
}
.tooltip {
background: #FFFFFF;
border-radius: 5px;

View File

@ -97,7 +97,7 @@ if (typeof jQuery != "undefined") {
});
var timer = null;
var checkConvert = function (fileUri, filePass) {
var checkConvert = function (fileUri, filePass, fileExt) {
filePass = filePass ? filePass : null;
if (timer != null) {
clearTimeout(timer);
@ -132,7 +132,7 @@ if (typeof jQuery != "undefined") {
contentType: "text/xml",
type: "post",
dataType: "json",
data: JSON.stringify({filename : fileName, fileUri : fileUri || "", filePass: filePass}),
data: JSON.stringify({filename: fileName, fileUri: fileUri || "", filePass: filePass, fileExt: fileExt}),
url: requestAddress,
complete: function (data) {
var responseText = data.responseText;
@ -153,6 +153,12 @@ if (typeof jQuery != "undefined") {
}
return;
} else {
if (response.error.includes("Error conversion output format")){
jq("#select-file-type").removeClass("invisible");
jq("#step2").removeClass("current");
jq("#hiddenFileName").attr("placeholder",filePass);
return;
}
jq(".current").removeClass("current");
jq(".step:not(.done)").addClass("error");
jq("#mainProgress .error-message").show().find("span").text(response.error);
@ -164,7 +170,7 @@ if (typeof jQuery != "undefined") {
jq("#hiddenFileName").val(response.filename);
if (response.step < 100) {
checkConvert(response.fileUri, filePass);
checkConvert(response.fileUri, filePass, fileExt);
} else {
jq("#step2").addClass("done").removeClass("current");
loadScripts();
@ -199,7 +205,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 + 1).trim().toLowerCase() : '';
if (EditedExtList.indexOf(posExt) != -1 || FillFormsExtList.indexOf(posExt) != -1) {
@ -228,6 +234,15 @@ if (typeof jQuery != "undefined") {
});
};
jq(document).on("click", ".file-type:not(.disable)", function () {
const currentElement = jq(this);
var fileExt = currentElement.attr("data");
var filePass = jq("#hiddenFileName").attr("placeholder");
jq('.file-type').addClass(["disable", "pale"]);
currentElement.removeClass("pale");
checkConvert(null, filePass, fileExt);
});
jq(document).on("click", "#enterPass", function () {
var filePass = jq("#filePass").val();
if (filePass) {

View File

@ -1,9 +1,9 @@
version: "3.8"
services:
document-server:
container_name: document-server
image: onlyoffice/documentserver:7.5
documentserver:
container_name: documentserver
image: onlyoffice/documentserver:8.0
expose:
- "80"
environment:
@ -32,7 +32,7 @@ services:
context: .
target: proxy
depends_on:
- document-server
- documentserver
- example
ports:
- "80:80"

View File

@ -76,7 +76,7 @@ function routers()
}
if (str_starts_with($path, '/convert')) {
$response = convert();
$response['status'] = 'success';
$response['status'] = isset($response['error']) ? 'error' : 'success';
echo json_encode($response);
return;
}

View File

@ -11,3 +11,5 @@ pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
clear_env = no
php_admin_value[upload_max_filesize] = 100M
php_admin_value[post_max_size] = 100M

View File

@ -24,6 +24,14 @@ http {
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass example:80;
proxy_redirect off;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_x_forwarded_host;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Real-IP $remote_addr;
}
}
@ -34,7 +42,7 @@ http {
location / {
client_max_body_size 100m;
proxy_http_version 1.1;
proxy_pass http://document-server;
proxy_pass http://documentserver;
proxy_redirect off;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;

View File

@ -228,6 +228,7 @@ function convert()
$lang = $_COOKIE["ulang"] ?? "";
$extension = mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
$internalExtension = "ooxml";
$conversionExtension = $post['fileExt'] ?? $internalExtension;
// check if the file with such an extension can be converted
if (in_array($extension, $formatManager->convertibleExtensions()) &&
@ -245,7 +246,7 @@ function convert()
$convertedData = getConvertedData(
$fileUri,
$extension,
$internalExtension,
$conversionExtension,
$key,
true,
$newFileUri,
@ -540,7 +541,7 @@ function reference()
}
}
$link = $post["link"];
$link = $post["link"] ?? null;
if (!isset($filename) && isset($link)) {
if (strpos($link, serverPath()) === false) {
return ["url" => $link, "directUrl"=> $link];

View File

@ -40,7 +40,7 @@ class ConfigurationManager
public function documentServerPublicURL(): URL
{
$url = getenv('DOCUMENT_SERVER_PUBLIC_URL') ?: 'http://document-server';
$url = getenv('DOCUMENT_SERVER_PUBLIC_URL') ?: 'http://documentserver';
return new URL($url);
}

View File

@ -42,7 +42,7 @@ final class ConfigurationManagerDocumentServerAPIURLTests extends TestCase
$configManager = new ConfigurationManager();
$url = $configManager->documentServerAPIURL();
$this->assertEquals(
'http://document-server/web-apps/apps/api/documents/api.js',
'http://documentserver/web-apps/apps/api/documents/api.js',
$url->string()
);
}
@ -53,7 +53,7 @@ final class ConfigurationManagerDocumentServerAPIURLTests extends TestCase
$configManager = new ConfigurationManager();
$url = $configManager->documentServerAPIURL();
$this->assertEquals(
'http://document-server/api',
'http://documentserver/api',
$url->string()
);
}

View File

@ -42,7 +42,7 @@ final class ConfigurationManagerDocumentServerCommandURLTests extends TestCase
$configManager = new ConfigurationManager();
$url = $configManager->documentServerCommandURL();
$this->assertEquals(
'http://document-server/coauthoring/CommandService.ashx',
'http://documentserver/coauthoring/CommandService.ashx',
$url->string()
);
}
@ -53,7 +53,7 @@ final class ConfigurationManagerDocumentServerCommandURLTests extends TestCase
$configManager = new ConfigurationManager();
$url = $configManager->documentServerCommandURL();
$this->assertEquals(
'http://document-server/command',
'http://documentserver/command',
$url->string()
);
}

View File

@ -42,7 +42,7 @@ final class ConfigurationManagerDocumentServerConverterURLTests extends TestCase
$configManager = new ConfigurationManager();
$url = $configManager->documentServerConverterURL();
$this->assertEquals(
'http://document-server/ConvertService.ashx',
'http://documentserver/ConvertService.ashx',
$url->string()
);
}
@ -53,7 +53,7 @@ final class ConfigurationManagerDocumentServerConverterURLTests extends TestCase
$configManager = new ConfigurationManager();
$url = $configManager->documentServerConverterURL();
$this->assertEquals(
'http://document-server/converter',
'http://documentserver/converter',
$url->string()
);
}

View File

@ -42,7 +42,7 @@ final class ConfigurationManagerDocumentServerPreloaderURLTests extends TestCase
$configManager = new ConfigurationManager();
$url = $configManager->documentServerPreloaderURL();
$this->assertEquals(
'http://document-server/web-apps/apps/api/documents/cache-scripts.html',
'http://documentserver/web-apps/apps/api/documents/cache-scripts.html',
$url->string()
);
}
@ -53,7 +53,7 @@ final class ConfigurationManagerDocumentServerPreloaderURLTests extends TestCase
$configManager = new ConfigurationManager();
$url = $configManager->documentServerPreloaderURL();
$this->assertEquals(
'http://document-server/preloader',
'http://documentserver/preloader',
$url->string()
);
}

View File

@ -41,7 +41,7 @@ final class ConfigurationManagerDocumentServerPrivateURLTests extends TestCase
{
$configManager = new ConfigurationManager();
$url = $configManager->documentServerPrivateURL();
$this->assertEquals('http://document-server', $url->string());
$this->assertEquals('http://documentserver', $url->string());
}
public function testAssignsAValueFromTheEnvironment()

View File

@ -41,7 +41,7 @@ final class ConfigurationManagerDocumentServerPublicURLTests extends TestCase
{
$configManager = new ConfigurationManager();
$url = $configManager->documentServerPublicURL();
$this->assertEquals('http://document-server', $url->string());
$this->assertEquals('http://documentserver', $url->string());
}
public function testAssignsAValueFromTheEnvironment()

View File

@ -158,7 +158,7 @@ function getTemplateImageUrl($filename)
{
$formatManager = new FormatManager();
$ext = mb_strtolower(pathinfo($filename, PATHINFO_EXTENSION));
$path = serverPath(true) . "/assets/images/";
$path = serverPath(false) . "/assets/images/";
foreach ($formatManager->all() as $format) {
if ($format->name === $ext) {
@ -553,6 +553,9 @@ function processConvServResponceError($errorCode)
// add the error message to the error message template depending on the error code
switch ($errorCode) {
case -9:
$errorMessage = $errorMessageTemplate . "Error conversion output format";
break;
case -8:
$errorMessage = $errorMessageTemplate . "Error document VKey";
break;

View File

@ -33,6 +33,7 @@ final class Users
public ?array $userInfoGroups;
public ?bool $avatar;
public ?string $image;
public ?array $goback;
/**

View File

@ -48,7 +48,7 @@ final class DocEditorView extends View
$jwtManager = new JwtManager();
$userList = new ExampleUsers();
$fileId = $request["fileID"] ?? "";
$user = $userList->getUser($request["user"]);
$user = $userList->getUser($request["user"] ?? null);
$isEnableDirectUrl = isset($request["directUrl"]) ? filter_var($request["directUrl"], FILTER_VALIDATE_BOOLEAN)
: false;
if (!empty($externalUrl)) {
@ -165,7 +165,7 @@ final class DocEditorView extends View
"id" => $user->id != "uid-0" ? $user->id : null,
"name" => $user->name,
"group" => $user->group,
"image" => $user->avatar ? serverPath(true) . "/assets/images/" . $user->id . ".png" : null
"image" => $user->avatar ? serverPath(false) . "/assets/images/" . $user->id . ".png" : null
],
"embedded" => [ // the parameters for the embedded document type
// the absolute URL that will allow the document to be saved onto the user personal computer
@ -230,7 +230,7 @@ final class DocEditorView extends View
if ($user->id != 'uid-0') {
foreach ($userList->getAllUsers() as $userInfo) {
$u = $userInfo;
$u->image = $userInfo->avatar ? serverPath(true) . "/assets/images/" . $userInfo->id . ".png" : null;
$u->image = $userInfo->avatar ? serverPath(false) . "/assets/images/" . $userInfo->id . ".png" : null;
array_push($usersInfo, $u);
}
}

View File

@ -140,6 +140,15 @@
<span id="step1" class="step">1. Loading the file.</span>
<span class="step-descr">The loading speed depends on file size
and additional elements it contains.</span>
<div id="select-file-type" class="invisible">
<br />
<span class="step">Please select the current document type</span>
<div class="buttonsMobile indent">
<div class="button file-type document" data="docx">Document</div>
<div class="button file-type spreadsheet" data="xlsx">Spreadsheet</div>
<div class="button file-type presentation" data="pptx">Presentation</div>
</div>
</div>
<br />
<span id="step2" class="step">2. Conversion.</span>
<span class="step-descr">The file is converted to OOXML so that you can edit it.</span>

View File

@ -1,9 +1,9 @@
version: "3.8"
services:
document-server:
container_name: document-server
image: onlyoffice/documentserver:7.5
documentserver:
container_name: documentserver
image: onlyoffice/documentserver:8.0
expose:
- "80"
environment:
@ -29,7 +29,7 @@ services:
context: .
target: proxy
depends_on:
- document-server
- documentserver
- example
ports:
- "80:80"

View File

@ -15,6 +15,14 @@ http {
location / {
proxy_http_version 1.1;
proxy_pass http://example;
proxy_redirect off;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_x_forwarded_host;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Real-IP $remote_addr;
}
}
@ -25,7 +33,7 @@ http {
location / {
client_max_body_size 100m;
proxy_http_version 1.1;
proxy_pass http://document-server;
proxy_pass http://documentserver;
proxy_redirect off;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;

View File

@ -36,7 +36,7 @@ class ConfigurationManager:
def document_server_public_url(self) -> ParseResult:
url = (
environ.get('DOCUMENT_SERVER_PUBLIC_URL') or
'http://document-server'
'http://documentserver'
)
return urlparse(url)

View File

@ -46,7 +46,7 @@ class ConfigurationManagerDocumentServerPublicURLTests(TestCase):
def test_assigns_a_default_value(self):
config_manager = ConfigurationManager()
url = config_manager.document_server_public_url()
self.assertEqual(url.geturl(), 'http://document-server')
self.assertEqual(url.geturl(), 'http://documentserver')
@patch.dict(environ, {
'DOCUMENT_SERVER_PUBLIC_URL': 'http://localhost'
@ -61,7 +61,7 @@ class ConfigurationManagerDocumentServerPrivateURLTests(TestCase):
def test_assigns_a_default_value(self):
config_manager = ConfigurationManager()
url = config_manager.document_server_private_url()
self.assertEqual(url.geturl(), 'http://document-server')
self.assertEqual(url.geturl(), 'http://documentserver')
@patch.dict(environ, {
'DOCUMENT_SERVER_PRIVATE_URL': 'http://localhost'

View File

@ -74,7 +74,7 @@ def getInternalExtension(fileType):
# get image url for templates
def getTemplateImageUrl(fileType, request):
path = getServerUrl(True, request) + '/static/images/'
path = getServerUrl(False, request) + '/static/images/'
mapping = {
'word': path + 'file_docx.svg',
'cell': path + 'file_xlsx.svg',

View File

@ -239,7 +239,7 @@ def edit(request):
if user.id != 'uid-0':
for userInfo in users.getAllUsers():
u = userInfo
u.image = docManager.getServerUrl(True, request) + f'/static/images/{u.id}.jpg' if user.avatar else None
u.image = docManager.getServerUrl(False, request) + f'/static/images/{u.id}.jpg' if user.avatar else None
usersInfo.append({"id": u.id, "name": u.name, "email": u.email, "image": u.image, "group": u.group,
"reviewGroups": u.reviewGroups, "commentGroups": u.commentGroups, "favorite": u.favorite,
"deniedPermissions": u.deniedPermissions, "descriptions": u.descriptions,
@ -310,7 +310,7 @@ def edit(request):
'id': user.id if user.id != 'uid-0' else None,
'name': user.name,
'group': user.group,
'image': docManager.getServerUrl(True, request) + f'/static/images/{user.id}.jpg' if user.avatar
'image': docManager.getServerUrl(False, request) + f'/static/images/{user.id}.jpg' if user.avatar
else None
},
'embedded': { # the parameters for the embedded document type

View File

@ -8,73 +8,73 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.8)
actionpack (= 7.0.8)
activesupport (= 7.0.8)
actioncable (7.0.8.1)
actionpack (= 7.0.8.1)
activesupport (= 7.0.8.1)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.8)
actionpack (= 7.0.8)
activejob (= 7.0.8)
activerecord (= 7.0.8)
activestorage (= 7.0.8)
activesupport (= 7.0.8)
actionmailbox (7.0.8.1)
actionpack (= 7.0.8.1)
activejob (= 7.0.8.1)
activerecord (= 7.0.8.1)
activestorage (= 7.0.8.1)
activesupport (= 7.0.8.1)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.8)
actionpack (= 7.0.8)
actionview (= 7.0.8)
activejob (= 7.0.8)
activesupport (= 7.0.8)
actionmailer (7.0.8.1)
actionpack (= 7.0.8.1)
actionview (= 7.0.8.1)
activejob (= 7.0.8.1)
activesupport (= 7.0.8.1)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.8)
actionview (= 7.0.8)
activesupport (= 7.0.8)
actionpack (7.0.8.1)
actionview (= 7.0.8.1)
activesupport (= 7.0.8.1)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.8)
actionpack (= 7.0.8)
activerecord (= 7.0.8)
activestorage (= 7.0.8)
activesupport (= 7.0.8)
actiontext (7.0.8.1)
actionpack (= 7.0.8.1)
activerecord (= 7.0.8.1)
activestorage (= 7.0.8.1)
activesupport (= 7.0.8.1)
globalid (>= 0.6.0)
nokogiri (>= 1.14.3)
actionview (7.0.8)
activesupport (= 7.0.8)
nokogiri (>= 1.8.5)
actionview (7.0.8.1)
activesupport (= 7.0.8.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.8)
activesupport (= 7.0.8)
activejob (7.0.8.1)
activesupport (= 7.0.8.1)
globalid (>= 0.3.6)
activemodel (7.0.8)
activesupport (= 7.0.8)
activerecord (7.0.8)
activemodel (= 7.0.8)
activesupport (= 7.0.8)
activestorage (7.0.8)
actionpack (= 7.0.8)
activejob (= 7.0.8)
activerecord (= 7.0.8)
activesupport (= 7.0.8)
activemodel (7.0.8.1)
activesupport (= 7.0.8.1)
activerecord (7.0.8.1)
activemodel (= 7.0.8.1)
activesupport (= 7.0.8.1)
activestorage (7.0.8.1)
actionpack (= 7.0.8.1)
activejob (= 7.0.8.1)
activerecord (= 7.0.8.1)
activesupport (= 7.0.8.1)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.8)
activesupport (7.0.8.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.1.1)
base64 (0.2.0)
bindex (0.8.1)
builder (3.2.4)
byebug (11.1.3)
@ -85,14 +85,14 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
crass (1.0.6)
dalli (3.2.6)
date (3.3.3)
dalli (3.2.8)
date (3.3.4)
erubi (1.12.0)
execjs (2.9.1)
ffi (1.16.2)
ffi (1.16.2-x64-mingw-ucrt)
ffi (1.16.3)
ffi (1.16.3-x64-mingw-ucrt)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.1)
@ -104,12 +104,13 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.6.3)
jwt (2.7.1)
json (2.7.1)
jwt (2.8.0)
base64
language_server-protocol (3.17.0.3)
loofah (2.21.3)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.14.3)
nokogiri (>= 1.12.0)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.8.1)
@ -120,89 +121,94 @@ GEM
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.5)
minitest (5.20.0)
net-imap (0.3.7)
minitest (5.22.2)
net-imap (0.4.10)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
net-protocol (0.2.2)
timeout
net-smtp (0.4.0)
net-smtp (0.4.0.1)
net-protocol
netrc (0.11.0)
nio4r (2.5.9)
nokogiri (1.15.4-arm64-darwin)
nio4r (2.7.0)
nokogiri (1.16.2-arm64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x64-mingw-ucrt)
nokogiri (1.16.2-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
nokogiri (1.16.2-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.3)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
power_assert (2.0.3)
prettier_print (1.2.1)
psych (5.1.0)
prism (0.24.0)
psych (5.1.2)
stringio
racc (1.7.1)
rack (2.2.8)
racc (1.7.3)
rack (2.2.8.1)
rack-cors (2.0.1)
rack (>= 2.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8)
actioncable (= 7.0.8)
actionmailbox (= 7.0.8)
actionmailer (= 7.0.8)
actionpack (= 7.0.8)
actiontext (= 7.0.8)
actionview (= 7.0.8)
activejob (= 7.0.8)
activemodel (= 7.0.8)
activerecord (= 7.0.8)
activestorage (= 7.0.8)
activesupport (= 7.0.8)
rails (7.0.8.1)
actioncable (= 7.0.8.1)
actionmailbox (= 7.0.8.1)
actionmailer (= 7.0.8.1)
actionpack (= 7.0.8.1)
actiontext (= 7.0.8.1)
actionview (= 7.0.8.1)
activejob (= 7.0.8.1)
activemodel (= 7.0.8.1)
activerecord (= 7.0.8.1)
activestorage (= 7.0.8.1)
activesupport (= 7.0.8.1)
bundler (>= 1.15.0)
railties (= 7.0.8)
railties (= 7.0.8.1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.14.3)
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14.3)
railties (7.0.8)
actionpack (= 7.0.8)
activesupport (= 7.0.8)
nokogiri (~> 1.14)
railties (7.0.8.1)
actionpack (= 7.0.8.1)
activesupport (= 7.0.8.1)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
rbi (0.1.1)
rake (13.1.0)
rbi (0.1.9)
prism (>= 0.18.0, < 0.25)
sorbet-runtime (>= 0.5.9204)
yarp (>= 0.11.0)
rdoc (6.5.0)
rdoc (6.6.2)
psych (>= 4.0.0)
regexp_parser (2.8.1)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.56.3)
base64 (~> 0.1.1)
rubocop (1.60.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-rails (2.23.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (1.13.0)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
@ -216,14 +222,14 @@ GEM
tilt
sdoc (2.6.1)
rdoc (>= 5.0)
sorbet (0.5.11048)
sorbet-static (= 0.5.11048)
sorbet-runtime (0.5.11048)
sorbet-static (0.5.11048-universal-darwin)
sorbet-static (0.5.11048-x86_64-linux)
sorbet-static-and-runtime (0.5.11048)
sorbet (= 0.5.11048)
sorbet-runtime (= 0.5.11048)
sorbet (0.5.11274)
sorbet-static (= 0.5.11274)
sorbet-runtime (0.5.11274)
sorbet-static (0.5.11274-universal-darwin)
sorbet-static (0.5.11274-x86_64-linux)
sorbet-static-and-runtime (0.5.11274)
sorbet (= 0.5.11274)
sorbet-runtime (= 0.5.11274)
spoom (1.2.4)
erubi (>= 1.10.0)
sorbet-static-and-runtime (>= 0.5.10187)
@ -236,34 +242,34 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
stringio (3.0.8)
stringio (3.1.0)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
systemu (2.6.5)
tapioca (0.11.9)
tapioca (0.11.17)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (~> 0.1.0, >= 0.1.0)
sorbet-static-and-runtime (>= 0.5.10187)
rbi (>= 0.1.4, < 0.2)
sorbet-static-and-runtime (>= 0.5.10820)
spoom (~> 1.2.0, >= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
test-unit (3.6.1)
test-unit (3.6.2)
power_assert
thor (1.2.2)
thor (1.3.1)
tilt (2.3.0)
timeout (0.4.0)
timeout (0.4.1)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2023.3)
tzinfo-data (1.2024.1)
tzinfo (>= 1.0.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.4.2)
unicode-display_width (2.5.0)
uuid (2.3.9)
macaddr (~> 1.0)
web-console (4.2.1)
@ -279,8 +285,7 @@ GEM
yard-sorbet (0.8.1)
sorbet-runtime (>= 0.5)
yard (>= 0.9)
yarp (0.12.0)
zeitwerk (2.6.12)
zeitwerk (2.6.13)
PLATFORMS
arm64-darwin-22
@ -298,6 +303,7 @@ DEPENDENCIES
rack-cors (~> 2.0)
rails (~> 7.0.8)
rubocop (~> 1.52)
rubocop-rails (~> 2.20)
sass-rails (~> 6.0)
sdoc (~> 2.6)
sorbet (~> 0.5.10871)

View File

@ -44,7 +44,7 @@ class ConfigurationManager
sig { returns(URI::Generic) }
def document_server_public_uri
url = ENV['DOCUMENT_SERVER_PUBLIC_URL'] || 'http://document-server'
url = ENV['DOCUMENT_SERVER_PUBLIC_URL'] || 'http://documentserver'
URI(url)
end

View File

@ -65,7 +65,7 @@ class ConfigurationManagerDocumentServerPublicURITests < Test::Unit::TestCase
def test_assigns_a_default_value
config_manager = ConfigurationManager.new
uri = config_manager.document_server_public_uri
assert_equal(uri.to_s, 'http://document-server')
assert_equal(uri.to_s, 'http://documentserver')
end
def test_assigns_a_value_from_the_environment
@ -83,7 +83,7 @@ class ConfigurationManagerDocumentServerPrivateURITests < Test::Unit::TestCase
def test_assigns_a_default_value
config_manager = ConfigurationManager.new
uri = config_manager.document_server_private_uri
assert_equal(uri.to_s, 'http://document-server')
assert_equal(uri.to_s, 'http://documentserver')
end
def test_assigns_a_value_from_the_environment
@ -103,7 +103,7 @@ class ConfigurationManagerDocumentServerAPIURITests < Test::Unit::TestCase
uri = config_manager.document_server_api_uri
assert_equal(
uri.to_s,
'http://document-server/web-apps/apps/api/documents/api.js'
'http://documentserver/web-apps/apps/api/documents/api.js'
)
end
@ -113,7 +113,7 @@ class ConfigurationManagerDocumentServerAPIURITests < Test::Unit::TestCase
uri = config_manager.document_server_api_uri
assert_equal(
uri.to_s,
'http://document-server/api'
'http://documentserver/api'
)
end
end
@ -127,7 +127,7 @@ class ConfigurationManagerDocumentServerPreloaderURITests < Test::Unit::TestCase
uri = config_manager.document_server_preloader_uri
assert_equal(
uri.to_s,
'http://document-server/web-apps/apps/api/documents/cache-scripts.html'
'http://documentserver/web-apps/apps/api/documents/cache-scripts.html'
)
end
@ -137,7 +137,7 @@ class ConfigurationManagerDocumentServerPreloaderURITests < Test::Unit::TestCase
uri = config_manager.document_server_preloader_uri
assert_equal(
uri.to_s,
'http://document-server/preloader'
'http://documentserver/preloader'
)
end
end
@ -151,7 +151,7 @@ class ConfigurationManagerDocumentServerCommandURITests < Test::Unit::TestCase
uri = config_manager.document_server_command_uri
assert_equal(
uri.to_s,
'http://document-server/coauthoring/CommandService.ashx'
'http://documentserver/coauthoring/CommandService.ashx'
)
end
@ -161,7 +161,7 @@ class ConfigurationManagerDocumentServerCommandURITests < Test::Unit::TestCase
uri = config_manager.document_server_command_uri
assert_equal(
uri.to_s,
'http://document-server/command'
'http://documentserver/command'
)
end
end
@ -175,7 +175,7 @@ class ConfigurationManagerDocumentServerConverterURITests < Test::Unit::TestCase
uri = config_manager.document_server_converter_uri
assert_equal(
uri.to_s,
'http://document-server/ConvertService.ashx'
'http://documentserver/ConvertService.ashx'
)
end
@ -185,7 +185,7 @@ class ConfigurationManagerDocumentServerConverterURITests < Test::Unit::TestCase
uri = config_manager.document_server_converter_uri
assert_equal(
uri.to_s,
'http://document-server/converter'
'http://documentserver/converter'
)
end
end

View File

@ -169,7 +169,7 @@ class HomeController < ApplicationController
action_data: file_data['action_data'],
direct_url: file_data['direct_url']
)
history = file.get_history
history = file.history
render(json: history)
rescue StandardError
render(json: '{ "error": "File not found"}')
@ -349,7 +349,10 @@ class HomeController < ApplicationController
# Save Copy as...
def saveas
body = JSON.parse(request.body.read)
file_url = body['url']
file_url = body['url'].sub(
HomeController.config_manager.document_server_public_uri.to_s,
HomeController.config_manager.document_server_private_uri.to_s
)
title = body['title']
file_name = DocumentHelper.get_correct_name(title, nil)
extension = File.extname(file_name).downcase
@ -384,7 +387,7 @@ class HomeController < ApplicationController
render(plain: "{\"file\" : \"#{file_name}\"}")
nil
rescue StandardError => e
render(plain: "{\"error\":1, \"message\": \"#{e.message}\"}")
render(plain: JSON.generate({ error: 1, message: e.message }))
nil
end

View File

@ -269,7 +269,7 @@ class DocumentHelper
# get image url for templates
def self.get_template_image_url(file_type)
path = "#{get_server_url(true)}/assets/"
path = "#{get_server_url(false)}/assets/"
case file_type
when 'word' # for word type
"#{path}file_docx.svg"

View File

@ -183,7 +183,7 @@ class FileModel
id: @user.id.eql?('uid-0') ? nil : @user.id,
name: @user.name,
group: @user.group,
image: @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil
image: @user.avatar ? "#{DocumentHelper.get_server_url(false)}/assets/#{@user.id}.png" : nil
},
embedded: { # the parameters for the embedded document type
# the absolute URL that will allow the document to be saved onto the user personal computer
@ -262,8 +262,7 @@ class FileModel
data_obj['url'] =
if i == cur_ver
DocumentHelper.get_download_url(
file_name,
true
file_name
)
else
DocumentHelper.get_historypath_uri(
@ -304,22 +303,20 @@ class FileModel
prev = hist_data[(i - 2).to_s] # get the history data from the previous file version
# write key and url information about previous file version with optional direct url
data(
obj['previous'] = if enable_direct_url? == true
{ # write key and url information about previous file version with optional directUrl
fileType: prev['fileType'],
key: prev['key'],
url: prev['url'],
directUrl: prev['directUrl']
}
else
{
fileType: prev['fileType'],
key: prev['key'],
url: prev['url']
}
end
)
data_obj['previous'] = if enable_direct_url? == true
{ # write key and url information about previous file version with optional directUrl
fileType: prev['fileType'],
key: prev['key'],
url: prev['url'],
directUrl: prev['directUrl']
}
else
{
fileType: prev['fileType'],
key: prev['key'],
url: prev['url']
}
end
diff_path = [hist_dir, (i - 1).to_s, 'diff.zip'].join(File::SEPARATOR)
if File.exist?(diff_path)
@ -457,7 +454,7 @@ class FileModel
templates: user_info.templates,
avatar: user_info.avatar
}
u['image'] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil
u['image'] = user_info.avatar ? "#{DocumentHelper.get_server_url(false)}/assets/#{user_info.id}.png" : nil
users_info.push(u)
end
users_info

View File

@ -165,7 +165,13 @@ class ServiceConverter
percent_element = file_result['percent'] # get the percentage value
result_percent = Integer(percent_element, 10) unless percent_element.nil?
result_percent = unless percent_element.nil?
if percent_element.is_a?(String)
Integer(percent_element, 10)
else
Integer(percent_element)
end
end
result_percent = 99 if result_percent >= 100

View File

@ -1,9 +1,9 @@
version: "3.8"
services:
document-server:
container_name: document-server
image: onlyoffice/documentserver:7.5
documentserver:
container_name: documentserver
image: onlyoffice/documentserver:8.0
expose:
- "80"
environment:
@ -30,7 +30,7 @@ services:
context: .
target: proxy
depends_on:
- document-server
- documentserver
- example
ports:
- "80:80"

View File

@ -6,6 +6,7 @@ events {
http {
include /etc/nginx/mime.types;
client_max_body_size 100M;
server {
listen 80;
@ -14,6 +15,14 @@ http {
location / {
proxy_http_version 1.1;
proxy_pass http://example;
proxy_redirect off;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_x_forwarded_host;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Real-IP $remote_addr;
}
}
@ -24,7 +33,7 @@ http {
location / {
client_max_body_size 100m;
proxy_http_version 1.1;
proxy_pass http://document-server;
proxy_pass http://documentserver;
proxy_redirect off;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;