mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2025-05-31 16:04:22 +02:00
fix: Libreoffice v0.1.6-a
This commit is contained in:
parent
4a62c4d1cf
commit
5594516697
@ -9,6 +9,9 @@ It support a wide range of documents.
|
||||

|
||||
|
||||
## Change log
|
||||
- v 0.1.6-a:
|
||||
* fix document exporting does not work
|
||||
* fix missing toolbar icons
|
||||
- v 0.1.5-a:
|
||||
* allow user to configure document server URI
|
||||
- v 0.1.4-a:
|
||||
|
@ -13,9 +13,20 @@ local result = function(data)
|
||||
end
|
||||
|
||||
local error = function(msg)
|
||||
LOG_ERROR("Error: "..msg)
|
||||
return {error = msg, result = false}
|
||||
end
|
||||
|
||||
local decode_path = function(str)
|
||||
local encoded = str:gsub("%.(.*)$", ""):gsub('_', '/'):gsub('-', '+')
|
||||
if #encoded % 4 == 2 then
|
||||
encoded = encoded.."=="
|
||||
elseif #encoded %4 == 3 then
|
||||
encoded = encoded.."="
|
||||
end
|
||||
return tostring(enc.b64decode(encoded))
|
||||
end
|
||||
|
||||
local fetch = function(url)
|
||||
local https = require('ssl.https')
|
||||
local body, code, headers = https.request(url)
|
||||
@ -63,15 +74,19 @@ end
|
||||
|
||||
handle.file = function(data)
|
||||
local rq = REQUEST.r
|
||||
LOG_INFO("Request Data:"..JSON.encode(data))
|
||||
if not rq then
|
||||
return error("Unknown request")
|
||||
end
|
||||
|
||||
local ret, stat = vfs.fileinfo(data.file)
|
||||
if not ret then
|
||||
return error("Unable to query file info")
|
||||
end
|
||||
local path = vfs.ospath(data.file)
|
||||
LOG_INFO("Check for request GET/POST/or data")
|
||||
if rq:match("/wopi/files/[^/]*/contents$") then
|
||||
LOG_INFO("/wopi/files/[^/]*/contents$")
|
||||
if REQUEST.method == "GET" then
|
||||
std.sendFile(path)
|
||||
return nil
|
||||
@ -84,14 +99,44 @@ handle.file = function(data)
|
||||
return error("Unknown request method")
|
||||
end
|
||||
elseif rq:match("/wopi/files/[^/]*$") then
|
||||
return {
|
||||
BaseFileName = stat.name,
|
||||
Size = math.floor(stat.size),
|
||||
UserCanWrite = vfs.checkperm(data.file,"write"),
|
||||
mime = stat.mime,
|
||||
PostMessageOrigin = "*",
|
||||
UserCanNotWriteRelative = false
|
||||
}
|
||||
LOG_INFO("Matching /wopi/files/[^/]*$")
|
||||
if REQUEST.method == "GET" then
|
||||
return {
|
||||
BaseFileName = stat.name,
|
||||
Size = math.floor(stat.size),
|
||||
UserCanWrite = vfs.checkperm(data.file,"write"),
|
||||
mime = stat.mime,
|
||||
PostMessageOrigin = "*",
|
||||
UserCanNotWriteRelative = false
|
||||
}
|
||||
elseif REQUEST.method == "POST" then
|
||||
LOG_INFO("Checking for header X_WOPI_SUGGESTEDTARGET")
|
||||
local out_file = HEADER['X_WOPI_SUGGESTEDTARGET']
|
||||
if not out_file then
|
||||
return error("Unknown request")
|
||||
end
|
||||
LOG_INFO("Encoded path:"..out_file)
|
||||
local dpath = decode_path(out_file)
|
||||
LOG_INFO("Decoded path:"..dpath)
|
||||
out_file = vfs.ospath(dpath)
|
||||
LOG_INFO("Save file to:"..out_file)
|
||||
local barr = REQUEST["application/octet-stream"]
|
||||
barr:fileout(out_file)
|
||||
local ret, stat = vfs.fileinfo(out_file)
|
||||
if not ret then
|
||||
return error("Unable to save file")
|
||||
end
|
||||
return {
|
||||
BaseFileName = stat.name,
|
||||
Size = math.floor(stat.size),
|
||||
UserCanWrite = vfs.checkperm(data.file,"write"),
|
||||
mime = stat.mime,
|
||||
PostMessageOrigin = "*",
|
||||
UserCanNotWriteRelative = false
|
||||
}
|
||||
else
|
||||
return error("Unknown request method")
|
||||
end
|
||||
else
|
||||
return error("Unknown request")
|
||||
end
|
||||
|
@ -52,7 +52,9 @@
|
||||
"api",
|
||||
"main.css",
|
||||
"templates",
|
||||
"icon.png"
|
||||
"icons/icon.png",
|
||||
"icons/new.png",
|
||||
"icons/open.png"
|
||||
],
|
||||
"dest":"build/debug"
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ It support a wide range of documents.
|
||||

|
||||
|
||||
## Change log
|
||||
- v 0.1.6-a:
|
||||
* fix document exporting does not work
|
||||
* fix missing toolbar icons
|
||||
- v 0.1.5-a:
|
||||
* allow user to configure document server URI
|
||||
- v 0.1.4-a:
|
||||
|
@ -13,9 +13,20 @@ local result = function(data)
|
||||
end
|
||||
|
||||
local error = function(msg)
|
||||
LOG_ERROR("Error: "..msg)
|
||||
return {error = msg, result = false}
|
||||
end
|
||||
|
||||
local decode_path = function(str)
|
||||
local encoded = str:gsub("%.(.*)$", ""):gsub('_', '/'):gsub('-', '+')
|
||||
if #encoded % 4 == 2 then
|
||||
encoded = encoded.."=="
|
||||
elseif #encoded %4 == 3 then
|
||||
encoded = encoded.."="
|
||||
end
|
||||
return tostring(enc.b64decode(encoded))
|
||||
end
|
||||
|
||||
local fetch = function(url)
|
||||
local https = require('ssl.https')
|
||||
local body, code, headers = https.request(url)
|
||||
@ -63,15 +74,19 @@ end
|
||||
|
||||
handle.file = function(data)
|
||||
local rq = REQUEST.r
|
||||
LOG_INFO("Request Data:"..JSON.encode(data))
|
||||
if not rq then
|
||||
return error("Unknown request")
|
||||
end
|
||||
|
||||
local ret, stat = vfs.fileinfo(data.file)
|
||||
if not ret then
|
||||
return error("Unable to query file info")
|
||||
end
|
||||
local path = vfs.ospath(data.file)
|
||||
LOG_INFO("Check for request GET/POST/or data")
|
||||
if rq:match("/wopi/files/[^/]*/contents$") then
|
||||
LOG_INFO("/wopi/files/[^/]*/contents$")
|
||||
if REQUEST.method == "GET" then
|
||||
std.sendFile(path)
|
||||
return nil
|
||||
@ -84,14 +99,44 @@ handle.file = function(data)
|
||||
return error("Unknown request method")
|
||||
end
|
||||
elseif rq:match("/wopi/files/[^/]*$") then
|
||||
return {
|
||||
BaseFileName = stat.name,
|
||||
Size = math.floor(stat.size),
|
||||
UserCanWrite = vfs.checkperm(data.file,"write"),
|
||||
mime = stat.mime,
|
||||
PostMessageOrigin = "*",
|
||||
UserCanNotWriteRelative = false
|
||||
}
|
||||
LOG_INFO("Matching /wopi/files/[^/]*$")
|
||||
if REQUEST.method == "GET" then
|
||||
return {
|
||||
BaseFileName = stat.name,
|
||||
Size = math.floor(stat.size),
|
||||
UserCanWrite = vfs.checkperm(data.file,"write"),
|
||||
mime = stat.mime,
|
||||
PostMessageOrigin = "*",
|
||||
UserCanNotWriteRelative = false
|
||||
}
|
||||
elseif REQUEST.method == "POST" then
|
||||
LOG_INFO("Checking for header X_WOPI_SUGGESTEDTARGET")
|
||||
local out_file = HEADER['X_WOPI_SUGGESTEDTARGET']
|
||||
if not out_file then
|
||||
return error("Unknown request")
|
||||
end
|
||||
LOG_INFO("Encoded path:"..out_file)
|
||||
local dpath = decode_path(out_file)
|
||||
LOG_INFO("Decoded path:"..dpath)
|
||||
out_file = vfs.ospath(dpath)
|
||||
LOG_INFO("Save file to:"..out_file)
|
||||
local barr = REQUEST["application/octet-stream"]
|
||||
barr:fileout(out_file)
|
||||
local ret, stat = vfs.fileinfo(out_file)
|
||||
if not ret then
|
||||
return error("Unable to save file")
|
||||
end
|
||||
return {
|
||||
BaseFileName = stat.name,
|
||||
Size = math.floor(stat.size),
|
||||
UserCanWrite = vfs.checkperm(data.file,"write"),
|
||||
mime = stat.mime,
|
||||
PostMessageOrigin = "*",
|
||||
UserCanNotWriteRelative = false
|
||||
}
|
||||
else
|
||||
return error("Unknown request method")
|
||||
end
|
||||
else
|
||||
return error("Unknown request")
|
||||
end
|
||||
|
File diff suppressed because one or more lines are too long
BIN
LibreOffice/build/debug/new.png
Normal file
BIN
LibreOffice/build/debug/new.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
LibreOffice/build/debug/open.png
Normal file
BIN
LibreOffice/build/debug/open.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -7,7 +7,7 @@
|
||||
"author": "Dany LE",
|
||||
"email": "contact@iohub.dev"
|
||||
},
|
||||
"version":"0.1.5-a",
|
||||
"version":"0.1.6-b",
|
||||
"category":"Office",
|
||||
"icon":"icon.png",
|
||||
"mimes":[
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
BIN
LibreOffice/icons/new.png
Normal file
BIN
LibreOffice/icons/new.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
LibreOffice/icons/open.png
Normal file
BIN
LibreOffice/icons/open.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -2,8 +2,8 @@ namespace OS {
|
||||
|
||||
export namespace application {
|
||||
const BUTTON_ICONS = {
|
||||
opendoc: "data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAD8UlEQVR42q1Va2gcVRQ+587s7mRItNskfaY1trRi2sZHNYoQHzGmQkAMlNZK1R+l0R+K/REhRAmzIEElaqX2R/tDhZamov4QbV0a6V9Nm9DiI8QEEtpI8zDbPPfh7sw93juzOzv7Ugge2L3nztz7fed859w7CHmGiKocYHVGwswcvLwFWnNzc3tLS8sjaTIvcX4kBZvD4fBAf3//aeEmShGUd3Z2nu7q6noBHZPABOjA2/9ijs4+wiwrydehUKivp6fnqPCjOQSHPhrTmKI2XP/uA33/k9s6Ot58rSkNnvPzZlKQkTDDMM4XJXjp08m3aiqV9xUex3sqZqCtqZ6QMSeDdKQeEoISGQiCvo9PfnY0tjBVQNC9d7vf0Fkcq2AK9jXeR8wrEQB6Ii8gkJWV/skz4ZlLI8posKbOQmQfnnl9y/f2gsMnbnbvuctnaCwOm9QZaH3ifmAlpCklj7RvLw/Bn8lqSPAy+PVGKnT2ja0hN4MdmxTDDzGs1Wbh+aYHXVm8kebNM5m4En3TfxXGY1WUBB3HblmGyCBLsLUaDZViuLN8DvY/s9cL+p8SZQi+DF+BkaW1ZKKON/+iLIGUaEMQDMZjsHtNBA7ue6hAnlISCfldv++HK/DL7SBwpsP0PGQlOnh8onttBRpgruDD6xbgcGtDTgb5EkmXc27XVozus7MXr8L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sVVD14FZ8mbc5JU8IRF6/CnpsfSXlr5iVsvw9VQa0Ox5eWRP0b/ZF9uqSII+7Nch+QwthJVSTUc31aUXqvN5npeE2Uexp/q5VQFfQkhCN9hquxZtb1f3PQzq+UQflCVK6bWcdCAboSQtHJMf/zHVV98pBt0Rnfmbx7TYWFZoC4A5m0oVh+mr2gP5viIpbUH7GIeAKcAilUPogQ6H9vqJuB8taGp9z88LJ/0H4BR3aNW1eB/4cAAAAASUVORK5CYII="
|
||||
opendoc: "pkg://LibreOffice/open.png".asFileHandle().getlink(),
|
||||
newdoc: "pkg://LibreOffice/new.png".asFileHandle().getlink()
|
||||
}
|
||||
const DEFAULT_LOO_URL = "https://loo.iohub.dev/hosting/discovery";
|
||||
/**
|
||||
@ -163,6 +163,7 @@ namespace OS {
|
||||
return;
|
||||
let orgevt = e.originalEvent;
|
||||
let data = JSON.parse(orgevt.data);
|
||||
console.log("receive data", data);
|
||||
switch(data.MessageId)
|
||||
{
|
||||
case 'Action_Load_Resp':
|
||||
@ -220,7 +221,7 @@ namespace OS {
|
||||
}
|
||||
break;
|
||||
case "UI_SaveAs":
|
||||
this.check_dirty().then((_)=>this.save_as());
|
||||
this.check_dirty().then((_)=>this.save_as(data.Values.format));
|
||||
break;
|
||||
default:
|
||||
console.log(data);
|
||||
@ -228,28 +229,45 @@ namespace OS {
|
||||
//console.log(this.eid, e);
|
||||
|
||||
}
|
||||
private save_as()
|
||||
private save_as(format:string = undefined)
|
||||
{
|
||||
this.openDialog("FileDialog", {
|
||||
if(!format) {
|
||||
format = this.curr_file.ext;
|
||||
}
|
||||
const out_file = `${this.curr_file.parent().path}/${this.curr_file.basename.replace(/\..*$/, '.'+format)}`;
|
||||
console.log("export file data as ", out_file);
|
||||
this.openDialog("FileDialog",
|
||||
{
|
||||
title: __("Save file as"),
|
||||
type: "dir",
|
||||
file: this.curr_file.asFileHandle()
|
||||
file: out_file.asFileHandle()
|
||||
})
|
||||
.then(async (d) => {
|
||||
.then(async (d) =>
|
||||
{
|
||||
const file = `${d.file.path}/${d.name}`.asFileHandle();
|
||||
try
|
||||
{
|
||||
|
||||
const r = await this.exec({
|
||||
action: 'duplicate',
|
||||
args:{src: this.curr_file.path, dest: file.path}
|
||||
});
|
||||
if(r.error)
|
||||
if(this.curr_file.ext == file.ext)
|
||||
{
|
||||
throw r.error;
|
||||
const r = await this.exec(
|
||||
{
|
||||
action: 'duplicate',
|
||||
args:{src: this.curr_file.path, dest: file.path}
|
||||
});
|
||||
if(r.error)
|
||||
{
|
||||
throw r.error;
|
||||
}
|
||||
this.curr_file = file;
|
||||
this.open();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.post_message("Action_SaveAs", {
|
||||
Filename: `${this.enb64u(file.path)}.${format}`,
|
||||
Notify: true
|
||||
});
|
||||
}
|
||||
this.curr_file = file;
|
||||
this.open();
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
@ -453,13 +471,17 @@ namespace OS {
|
||||
args: {file: this.curr_file.path}
|
||||
}
|
||||
}
|
||||
|
||||
// encode data to URL safe base64 encoding
|
||||
let encoded =
|
||||
btoa(JSON.stringify(cmd))
|
||||
let encoded = this.enb64u(JSON.stringify(cmd));
|
||||
return `${this._api.REST}/system/apigateway/${encoded}/wopi/files/${this.curr_file.path.hash()}&${this.access_token}`;
|
||||
}
|
||||
private enb64u(input: string)
|
||||
{
|
||||
return btoa(input)
|
||||
.trimBy("=")
|
||||
.replace(/\+/g, '-')
|
||||
.replace(/\//g, '_');
|
||||
return `${this._api.REST}/system/apigateway/${encoded}/wopi/files/${this.curr_file.basename}&${this.access_token}`;
|
||||
}
|
||||
private check_dirty():Promise<any>
|
||||
{
|
||||
|
@ -7,7 +7,7 @@
|
||||
"author": "Dany LE",
|
||||
"email": "contact@iohub.dev"
|
||||
},
|
||||
"version":"0.1.5-a",
|
||||
"version":"0.1.6-b",
|
||||
"category":"Office",
|
||||
"icon":"icon.png",
|
||||
"mimes":[
|
||||
|
@ -6,7 +6,7 @@
|
||||
"name": "batch",
|
||||
"data": {
|
||||
"target": "release",
|
||||
"modules": ["Blogger"]
|
||||
"modules": ["LibreOffice"]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -1,15 +0,0 @@
|
||||
# AntunnelTestClient
|
||||
This is an example project, generated by AntOS Development Kit
|
||||
|
||||
## Howto
|
||||
Use the Antedit command palette to access to the SDK functionalities:
|
||||
|
||||
1. Create new project
|
||||
2. Init the project from the current folder located in side bar
|
||||
3. Build and run the project
|
||||
4. Release the project in zip package
|
||||
|
||||
## Set up build target
|
||||
|
||||
Open the `build.json` file from the current project tree and add/remove
|
||||
build target entries and jobs. Save the file
|
Binary file not shown.
@ -9,6 +9,9 @@ It support a wide range of documents.
|
||||

|
||||
|
||||
## Change log
|
||||
- v 0.1.6-a:
|
||||
* fix document exporting does not work
|
||||
* fix missing toolbar icons
|
||||
- v 0.1.5-a:
|
||||
* allow user to configure document server URI
|
||||
- v 0.1.4-a:
|
||||
|
Binary file not shown.
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user