mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
Merge branch 'develop' into feature/flake8-pylint
This commit is contained in:
4
.github/workflows/artifact-csharp-mvc.yml
vendored
4
.github/workflows/artifact-csharp-mvc.yml
vendored
@ -3,10 +3,10 @@ name: Artifact Csharp MVC
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/csharp-mvc/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/csharp-mvc/**']
|
||||
|
||||
jobs:
|
||||
|
||||
4
.github/workflows/artifact-csharp.yml
vendored
4
.github/workflows/artifact-csharp.yml
vendored
@ -3,10 +3,10 @@ name: Artifact Csharp
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/csharp/**']
|
||||
pull_request:
|
||||
branches: [master, main, develop]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/csharp/**']
|
||||
|
||||
jobs:
|
||||
|
||||
4
.github/workflows/artifact-java.yml
vendored
4
.github/workflows/artifact-java.yml
vendored
@ -3,10 +3,10 @@ name: Artifact Java
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/java/**']
|
||||
|
||||
jobs:
|
||||
|
||||
4
.github/workflows/artifact-node.yml
vendored
4
.github/workflows/artifact-node.yml
vendored
@ -3,10 +3,10 @@ name: Artifact Nodejs
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/nodejs/**']
|
||||
|
||||
jobs:
|
||||
|
||||
4
.github/workflows/artifact-php.yml
vendored
4
.github/workflows/artifact-php.yml
vendored
@ -3,10 +3,10 @@ name: Artifact PHP
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/php/**']
|
||||
|
||||
jobs:
|
||||
|
||||
4
.github/workflows/artifact-python.yml
vendored
4
.github/workflows/artifact-python.yml
vendored
@ -3,10 +3,10 @@ name: Artifact Python
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/python/**']
|
||||
|
||||
jobs:
|
||||
|
||||
4
.github/workflows/artifact-ruby.yml
vendored
4
.github/workflows/artifact-ruby.yml
vendored
@ -3,10 +3,10 @@ name: Artifact Ruby
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/ruby/**']
|
||||
|
||||
jobs:
|
||||
|
||||
4
.github/workflows/artifact-spring.yml
vendored
4
.github/workflows/artifact-spring.yml
vendored
@ -3,10 +3,10 @@ name: Artifact Java Spring
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
pull_request:
|
||||
branches: [master, main]
|
||||
branches: [master]
|
||||
paths: ['web/documentserver-example/java-spring/**']
|
||||
|
||||
jobs:
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
# Change Log
|
||||
|
||||
- trimming long name of uploading file
|
||||
- nodejs: link in referenceData
|
||||
- onRequestSelectDocument method
|
||||
- onRequestSelectSpreadsheet method
|
||||
- key in referenceData
|
||||
|
||||
@ -177,7 +177,12 @@ namespace OnlineEditorsExampleMVC.Helpers
|
||||
// get a file name with an index if the file with such a name already exists
|
||||
public static string GetCorrectName(string fileName, string userAddress = null)
|
||||
{
|
||||
int maxName;
|
||||
int.TryParse(WebConfigurationManager.AppSettings["filename-max"], out maxName);
|
||||
var baseName = Path.GetFileNameWithoutExtension(fileName);
|
||||
if (baseName.Length > maxName){
|
||||
baseName = baseName.Substring(0, maxName) + "[...]";
|
||||
}
|
||||
var ext = Path.GetExtension(fileName).ToLower();
|
||||
var name = baseName + ext;
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
<add key="filename-max" value="50"/>
|
||||
|
||||
<add key="files.docservice.fillform-docs" value=".docx|.oform"/>
|
||||
<add key="files.docservice.viewed-docs" value=".djvu|.oxps|.pdf|.xps"/>
|
||||
|
||||
@ -538,7 +538,12 @@ namespace OnlineEditorsExample
|
||||
// get the correct file name if such a name already exists
|
||||
public static string GetCorrectName(string fileName, string userAddress = null)
|
||||
{
|
||||
int maxName;
|
||||
int.TryParse(WebConfigurationManager.AppSettings["filename-max"], out maxName);
|
||||
var baseName = Path.GetFileNameWithoutExtension(fileName); // get file name without extension
|
||||
if (baseName.Length > maxName){
|
||||
baseName = baseName.Substring(0, maxName) + "[...]";
|
||||
}
|
||||
var ext = Path.GetExtension(fileName).ToLower(); // get file extension
|
||||
var name = baseName + ext; // get full file name
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
|
||||
<add key="filesize-max" value="52428800"/>
|
||||
<add key="storage-path" value=""/>
|
||||
<add key="filename-max" value="50"/>
|
||||
|
||||
<add key="files.docservice.fillform-docs" value=".docx|.oform"/>
|
||||
<add key="files.docservice.viewed-docs" value=".djvu|.oxps|.pdf|.xps"/>
|
||||
|
||||
@ -38,6 +38,8 @@ import static com.onlyoffice.integration.documentserver.util.Constants.MAX_FILE_
|
||||
public class DefaultFileUtility implements FileUtility {
|
||||
@Value("${filesize-max}")
|
||||
private String filesizeMax;
|
||||
@Value("${filename-max}")
|
||||
private String filenameMax;
|
||||
|
||||
@Autowired
|
||||
private FormatService formatService;
|
||||
@ -136,13 +138,18 @@ public class DefaultFileUtility implements FileUtility {
|
||||
|
||||
// generate the file path from file directory and name
|
||||
public Path generateFilepath(final String directory, final String fullFileName) {
|
||||
String fileName = getFileNameWithoutExtension(fullFileName); // get file name without extension
|
||||
int maxName = Integer.parseInt(filenameMax);
|
||||
String fileName = getFileNameWithoutExtension(fullFileName);
|
||||
if (fileName.length() > maxName) {
|
||||
fileName = fileName.substring(0, maxName) + "[...]";
|
||||
}
|
||||
String fileExtension = getFileExtension(fullFileName); // get file extension
|
||||
Path path = Paths.get(directory + fullFileName); // get the path to the files with the specified name
|
||||
// get the path to the files with the specified name
|
||||
Path path = Paths.get(directory + fileName + "." + fileExtension);
|
||||
|
||||
for (int i = 1; Files.exists(path); i++) { // run through all the files with the specified name
|
||||
// get a name of each file without extension and add an index to it
|
||||
fileName = getFileNameWithoutExtension(fullFileName) + "(" + i + ")";
|
||||
fileName = fileName + "(" + i + ")";
|
||||
|
||||
// create a new path for this file with the correct name and extension
|
||||
path = Paths.get(directory + fileName + "." + fileExtension);
|
||||
|
||||
@ -4,6 +4,7 @@ server.address=
|
||||
server.port=4000
|
||||
|
||||
filesize-max=5242880
|
||||
filename-max=50
|
||||
|
||||
files.storage=
|
||||
files.storage.folder=documents
|
||||
|
||||
@ -246,7 +246,11 @@ public final class DocumentManager {
|
||||
|
||||
// get a file name with an index if the file with such a name already exists
|
||||
public static String getCorrectName(final String fileName, final String userAddress) {
|
||||
int maxName = Integer.parseInt(ConfigManager.getProperty("filename-max"));
|
||||
String baseName = FileUtility.getFileNameWithoutExtension(fileName);
|
||||
if (baseName.length() > maxName) {
|
||||
baseName = baseName.substring(0, maxName) + "[...]";
|
||||
}
|
||||
String ext = FileUtility.getFileExtension(fileName);
|
||||
String name = baseName + "." + ext;
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ version=1.7.0
|
||||
|
||||
filesize-max=5242880
|
||||
storage-folder=app_data
|
||||
filename-max=50
|
||||
|
||||
files.docservice.timeout=120000
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
"storageFolder": "./files",
|
||||
"storagePath": "/files",
|
||||
"maxFileSize": 1073741824,
|
||||
"maxNameLength": 50,
|
||||
"mobileRegEx": "android|avantgo|playbook|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino",
|
||||
"token": {
|
||||
"enable": false,
|
||||
|
||||
@ -84,7 +84,10 @@ DocManager.prototype.getCustomParams = function getCustomParams() {
|
||||
|
||||
// get the correct file name if such a name already exists
|
||||
DocManager.prototype.getCorrectName = function getCorrectName(fileName, userAddress) {
|
||||
const baseName = fileUtility.getFileName(fileName, true); // get file name from the url without extension
|
||||
// get file name from the url without extension
|
||||
const maxName = configServer.get('maxNameLength');
|
||||
const baseName = fileUtility.getFileName(fileName, true).substr(0, maxName)
|
||||
+ (fileName.length > maxName ? '[...]' : '');
|
||||
const ext = fileUtility.getFileExtension(fileName); // get file extension from the url
|
||||
let name = baseName + ext; // get full file name
|
||||
let index = 1;
|
||||
@ -152,7 +155,7 @@ DocManager.prototype.saveFileData = function saveFileData(fileName, userid, user
|
||||
// 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() < 10 ? '0' : '') + (parseInt(dateCreate.getMonth().toString(), 10) + 1);
|
||||
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}`;
|
||||
|
||||
@ -336,11 +336,18 @@
|
||||
}
|
||||
};
|
||||
|
||||
var onDocumentReady = function(){
|
||||
if (config.type === "mobile") {
|
||||
document.getElementsByTagName("iframe")[0].style.height = window.innerHeight + "px";
|
||||
}
|
||||
};
|
||||
|
||||
config = {
|
||||
<%- include("config") %>
|
||||
};
|
||||
config.events = {
|
||||
"onAppReady": onAppReady,
|
||||
"onDocumentReady": onDocumentReady,
|
||||
"onDocumentStateChange": onDocumentStateChange,
|
||||
"onError": onError,
|
||||
"onOutdatedVersion": onOutdatedVersion,
|
||||
@ -386,20 +393,6 @@
|
||||
}
|
||||
|
||||
docEditor = new DocsAPI.DocEditor("iframeEditor", config);
|
||||
fixSize();
|
||||
};
|
||||
|
||||
// get the editor sizes
|
||||
var fixSize = function () {
|
||||
if (config.type !== "mobile") {
|
||||
return;
|
||||
}
|
||||
var wrapEl = document.getElementsByClassName("form");
|
||||
if (wrapEl.length) {
|
||||
wrapEl[0].style.height = screen.availHeight + "px";
|
||||
window.scrollTo(0, -1);
|
||||
wrapEl[0].style.height = window.innerHeight + "px";
|
||||
}
|
||||
};
|
||||
|
||||
const getFileExt = function (fileName) {
|
||||
@ -411,10 +404,8 @@
|
||||
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener("load", connectEditor);
|
||||
window.addEventListener("resize", fixSize);
|
||||
} else if (window.attachEvent) {
|
||||
window.attachEvent("onload", connectEditor);
|
||||
window.attachEvent("onresize", fixSize);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@ -475,11 +475,12 @@ function getFileInfo($fileId)
|
||||
function GetCorrectName($fileName, $userAddress = null)
|
||||
{
|
||||
$pathParts = pathinfo($fileName);
|
||||
|
||||
$maxName = 50;
|
||||
$ext = mb_strtolower($pathParts['extension']);
|
||||
$name = $pathParts['basename'];
|
||||
// get file name from the basename without extension
|
||||
$baseNameWithoutExt = mb_substr($name, 0, mb_strlen($name) - mb_strlen($ext) - 1);
|
||||
$baseNameWithoutExt = mb_substr(mb_substr($name, 0, mb_strlen($name) - mb_strlen($ext) - 1), 0, $maxName)
|
||||
. (strlen($fileName) > $maxName ? "[...]" : "");
|
||||
$name = $baseNameWithoutExt . "." . $ext;
|
||||
|
||||
// if a file with such a name already exists in this directory
|
||||
|
||||
@ -86,7 +86,8 @@ def getTemplateImageUrl(fileType, request):
|
||||
|
||||
# get file name with an index if such a file name already exists
|
||||
def getCorrectName(filename, req):
|
||||
basename = fileUtils.getFileNameWithoutExt(filename)
|
||||
maxName = 50
|
||||
basename = fileUtils.getFileNameWithoutExt(filename)[0:maxName] + ('','[...]')[len(filename) > maxName]
|
||||
ext = fileUtils.getFileExt(filename)
|
||||
name = f'{basename}{ext}'
|
||||
|
||||
|
||||
1
web/documentserver-example/ruby/.bundler-version
Normal file
1
web/documentserver-example/ruby/.bundler-version
Normal file
@ -0,0 +1 @@
|
||||
2.4.10
|
||||
1
web/documentserver-example/ruby/.gitignore
vendored
1
web/documentserver-example/ruby/.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.bundle
|
||||
bin
|
||||
db
|
||||
log
|
||||
|
||||
@ -22,6 +22,8 @@ help: # Show help message for each of the Makefile recipes.
|
||||
awk 'BEGIN {FS = ": # "}; {printf "%s: %s\n", $$1, $$2}'
|
||||
|
||||
.PHONY: dev
|
||||
dev: \
|
||||
export BUNDLE_WITH := development:doc:test
|
||||
dev: # Install development dependencies and initialize the project.
|
||||
@bundle install
|
||||
@bundle exec rake app:update:bin
|
||||
@ -30,8 +32,10 @@ ifeq ($(SORBET_SUPPORTED),1)
|
||||
endif
|
||||
|
||||
.PHONY: prod
|
||||
prod: \
|
||||
export BUNDLE_WITHOUT := development:doc:test
|
||||
prod: # Install production dependencies.
|
||||
@bundle install --without development doc test
|
||||
@bundle install
|
||||
@bundle exec rake app:update:bin
|
||||
|
||||
.PHONY: server-dev
|
||||
|
||||
@ -149,8 +149,10 @@ class DocumentHelper
|
||||
|
||||
# get the correct file name if such a name already exists
|
||||
def get_correct_name(file_name, user_address)
|
||||
maxName = 50
|
||||
ext = File.extname(file_name) # get file extension
|
||||
base_name = File.basename(file_name, ext) # get file name without extension
|
||||
# get file name without extension
|
||||
base_name = File.basename(file_name, ext)[0...maxName] + (file_name.length > maxName ? '[...]' : '')
|
||||
name = base_name + ext.downcase # get full file name
|
||||
index = 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user