mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-25 19:58:21 +01:00
Update LibreOffice and OnlyOffice to latests backend API
This commit is contained in:
parent
a2a602f5b2
commit
9afa2f5d1c
@ -9,6 +9,9 @@ It support a wide range of documents.
|
|||||||
![https://github.com/lxsang/antosdk-apps/blob/master/LibreOffice/libreoffice.png?raw=true](https://github.com/lxsang/antosdk-apps/blob/master/LibreOffice/libreoffice.png?raw=true)
|
![https://github.com/lxsang/antosdk-apps/blob/master/LibreOffice/libreoffice.png?raw=true](https://github.com/lxsang/antosdk-apps/blob/master/LibreOffice/libreoffice.png?raw=true)
|
||||||
|
|
||||||
## Change log
|
## Change log
|
||||||
|
- v 0.1.4-a:
|
||||||
|
* Update backend script to latest API changes
|
||||||
|
* use luasocket + luasec to fetch LibreOffice service discovery
|
||||||
- v 0.1.3-a:
|
- v 0.1.3-a:
|
||||||
* Minor fix to support AntOS v2.0.x
|
* Minor fix to support AntOS v2.0.x
|
||||||
- v 0.1.2-a:
|
- v 0.1.2-a:
|
||||||
|
@ -6,7 +6,6 @@ if not args then
|
|||||||
args = REQUEST
|
args = REQUEST
|
||||||
end
|
end
|
||||||
local vfs = require("vfs")
|
local vfs = require("vfs")
|
||||||
local DLCMD="wget --no-check-certificate -O"
|
|
||||||
local handle = {}
|
local handle = {}
|
||||||
--local logger = Logger:new{ levels = {INFO = true, ERROR = true, DEBUG = false}}
|
--local logger = Logger:new{ levels = {INFO = true, ERROR = true, DEBUG = false}}
|
||||||
local result = function(data)
|
local result = function(data)
|
||||||
@ -17,12 +16,22 @@ local error = function(msg)
|
|||||||
return {error = msg, result = false}
|
return {error = msg, result = false}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local fetch = function(url)
|
||||||
|
local https = require('ssl.https')
|
||||||
|
local body, code, headers = https.request(url)
|
||||||
|
if code~=200 then
|
||||||
|
LOG_ERROR("Error: ".. (code or '') )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return body
|
||||||
|
end
|
||||||
|
|
||||||
handle.token = function(data)
|
handle.token = function(data)
|
||||||
local file = vfs.ospath(data.file)
|
local file = vfs.ospath(data.file)
|
||||||
local stat = ulib.file_stat(file)
|
local stat = ulib.file_stat(file)
|
||||||
local ret = {
|
local ret = {
|
||||||
sid = "access_token="..SESSION.sessionid,
|
sid = "access_token="..SESSION.sessionid,
|
||||||
key = std.sha1(file..":"..stat.mtime)
|
key = enc.sha1(file..":"..stat.mtime)
|
||||||
}
|
}
|
||||||
return result(ret)
|
return result(ret)
|
||||||
end
|
end
|
||||||
@ -43,14 +52,9 @@ handle.duplicate = function(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
handle.discover = function(data)
|
handle.discover = function(data)
|
||||||
local tmpfile = "/tmp/libreoffice_discover.xml"
|
content = fetch(url)
|
||||||
local cmd = DLCMD.." "..tmpfile..' '..data.uri
|
|
||||||
os.execute(cmd)
|
|
||||||
-- move file to correct position
|
-- move file to correct position
|
||||||
if ulib.exists(tmpfile) then
|
if content then
|
||||||
local f = assert(io.open(tmpfile, "rb"))
|
|
||||||
local content = f:read("*all")
|
|
||||||
f:close()
|
|
||||||
return result(content)
|
return result(content)
|
||||||
else
|
else
|
||||||
return error("Unable to discover data")
|
return error("Unable to discover data")
|
||||||
@ -74,7 +78,7 @@ handle.file = function(data)
|
|||||||
elseif REQUEST.method == "POST" then
|
elseif REQUEST.method == "POST" then
|
||||||
--local clen = tonumber(HEADER['Content-Length'])
|
--local clen = tonumber(HEADER['Content-Length'])
|
||||||
local barr = REQUEST["application/octet-stream"]
|
local barr = REQUEST["application/octet-stream"]
|
||||||
bytes.write(barr, path)
|
barr:fileout(path)
|
||||||
return result(true)
|
return result(true)
|
||||||
else
|
else
|
||||||
return error("Unknown request method")
|
return error("Unknown request method")
|
||||||
|
@ -9,6 +9,9 @@ It support a wide range of documents.
|
|||||||
![https://github.com/lxsang/antosdk-apps/blob/master/LibreOffice/libreoffice.png?raw=true](https://github.com/lxsang/antosdk-apps/blob/master/LibreOffice/libreoffice.png?raw=true)
|
![https://github.com/lxsang/antosdk-apps/blob/master/LibreOffice/libreoffice.png?raw=true](https://github.com/lxsang/antosdk-apps/blob/master/LibreOffice/libreoffice.png?raw=true)
|
||||||
|
|
||||||
## Change log
|
## Change log
|
||||||
|
- v 0.1.4-a:
|
||||||
|
* Update backend script to latest API changes
|
||||||
|
* use luasocket + luasec to fetch LibreOffice service discovery
|
||||||
- v 0.1.3-a:
|
- v 0.1.3-a:
|
||||||
* Minor fix to support AntOS v2.0.x
|
* Minor fix to support AntOS v2.0.x
|
||||||
- v 0.1.2-a:
|
- v 0.1.2-a:
|
||||||
|
@ -6,7 +6,6 @@ if not args then
|
|||||||
args = REQUEST
|
args = REQUEST
|
||||||
end
|
end
|
||||||
local vfs = require("vfs")
|
local vfs = require("vfs")
|
||||||
local DLCMD="wget --no-check-certificate -O"
|
|
||||||
local handle = {}
|
local handle = {}
|
||||||
--local logger = Logger:new{ levels = {INFO = true, ERROR = true, DEBUG = false}}
|
--local logger = Logger:new{ levels = {INFO = true, ERROR = true, DEBUG = false}}
|
||||||
local result = function(data)
|
local result = function(data)
|
||||||
@ -17,12 +16,22 @@ local error = function(msg)
|
|||||||
return {error = msg, result = false}
|
return {error = msg, result = false}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local fetch = function(url)
|
||||||
|
local https = require('ssl.https')
|
||||||
|
local body, code, headers = https.request(url)
|
||||||
|
if code~=200 then
|
||||||
|
LOG_ERROR("Error: ".. (code or '') )
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
return body
|
||||||
|
end
|
||||||
|
|
||||||
handle.token = function(data)
|
handle.token = function(data)
|
||||||
local file = vfs.ospath(data.file)
|
local file = vfs.ospath(data.file)
|
||||||
local stat = ulib.file_stat(file)
|
local stat = ulib.file_stat(file)
|
||||||
local ret = {
|
local ret = {
|
||||||
sid = "access_token="..SESSION.sessionid,
|
sid = "access_token="..SESSION.sessionid,
|
||||||
key = std.sha1(file..":"..stat.mtime)
|
key = enc.sha1(file..":"..stat.mtime)
|
||||||
}
|
}
|
||||||
return result(ret)
|
return result(ret)
|
||||||
end
|
end
|
||||||
@ -43,14 +52,9 @@ handle.duplicate = function(data)
|
|||||||
end
|
end
|
||||||
|
|
||||||
handle.discover = function(data)
|
handle.discover = function(data)
|
||||||
local tmpfile = "/tmp/libreoffice_discover.xml"
|
content = fetch(url)
|
||||||
local cmd = DLCMD.." "..tmpfile..' '..data.uri
|
|
||||||
os.execute(cmd)
|
|
||||||
-- move file to correct position
|
-- move file to correct position
|
||||||
if ulib.exists(tmpfile) then
|
if content then
|
||||||
local f = assert(io.open(tmpfile, "rb"))
|
|
||||||
local content = f:read("*all")
|
|
||||||
f:close()
|
|
||||||
return result(content)
|
return result(content)
|
||||||
else
|
else
|
||||||
return error("Unable to discover data")
|
return error("Unable to discover data")
|
||||||
@ -74,7 +78,7 @@ handle.file = function(data)
|
|||||||
elseif REQUEST.method == "POST" then
|
elseif REQUEST.method == "POST" then
|
||||||
--local clen = tonumber(HEADER['Content-Length'])
|
--local clen = tonumber(HEADER['Content-Length'])
|
||||||
local barr = REQUEST["application/octet-stream"]
|
local barr = REQUEST["application/octet-stream"]
|
||||||
bytes.write(barr, path)
|
barr:fileout(path)
|
||||||
return result(true)
|
return result(true)
|
||||||
else
|
else
|
||||||
return error("Unknown request method")
|
return error("Unknown request method")
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"author": "Dany LE",
|
"author": "Dany LE",
|
||||||
"email": "contact@iohub.dev"
|
"email": "contact@iohub.dev"
|
||||||
},
|
},
|
||||||
"version":"0.1.3-a",
|
"version":"0.1.4-a",
|
||||||
"category":"Office",
|
"category":"Office",
|
||||||
"icon":"icon.png",
|
"icon":"icon.png",
|
||||||
"mimes":[
|
"mimes":[
|
||||||
|
Binary file not shown.
@ -7,7 +7,7 @@
|
|||||||
"author": "Dany LE",
|
"author": "Dany LE",
|
||||||
"email": "contact@iohub.dev"
|
"email": "contact@iohub.dev"
|
||||||
},
|
},
|
||||||
"version":"0.1.3-a",
|
"version":"0.1.4-a",
|
||||||
"category":"Office",
|
"category":"Office",
|
||||||
"icon":"icon.png",
|
"icon":"icon.png",
|
||||||
"mimes":[
|
"mimes":[
|
||||||
|
@ -10,6 +10,7 @@ way to work with multiple documents at the same time.
|
|||||||
![https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true](https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true)
|
![https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true](https://github.com/lxsang/antosdk-apps/blob/master/OnlyOffice/screenshot.png?raw=true)
|
||||||
|
|
||||||
## Change log
|
## Change log
|
||||||
|
- v 0.1.8a: Use new backend API + luasec + luasocket to manipulate remote file
|
||||||
- v 0.1.7a: Allow setting blur overlay on window
|
- v 0.1.7a: Allow setting blur overlay on window
|
||||||
- v 0.1.6a: Update backend api
|
- v 0.1.6a: Update backend api
|
||||||
- v 0.1.5a: Add document versionning support
|
- v 0.1.5a: Add document versionning support
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
local args=...
|
local args=...
|
||||||
local vfs = require("vfs")
|
local vfs = require("vfs")
|
||||||
|
|
||||||
local DLCMD="wget --no-check-certificate -O"
|
|
||||||
if not args then
|
if not args then
|
||||||
args = REQUEST
|
args = REQUEST
|
||||||
end
|
end
|
||||||
@ -20,6 +19,25 @@ local error = function(data)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local download_file = function(src, dest)
|
||||||
|
local https = require('ssl.https')
|
||||||
|
local ltn12 = require("ltn12")
|
||||||
|
local file = io.open(dest, "w")
|
||||||
|
if not file then
|
||||||
|
LOG_ERROR("Unable to open file %s to write", dest)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
local body, code, headers = https.request{
|
||||||
|
url = src,
|
||||||
|
sink = ltn12.sink.file(file)
|
||||||
|
}
|
||||||
|
if code~=200 then
|
||||||
|
LOG_ERROR("Error: ".. (code or '') )
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
local handle = {}
|
local handle = {}
|
||||||
|
|
||||||
handle.token = function(data)
|
handle.token = function(data)
|
||||||
@ -27,17 +45,17 @@ handle.token = function(data)
|
|||||||
local stat = ulib.file_stat(file)
|
local stat = ulib.file_stat(file)
|
||||||
local ret = {
|
local ret = {
|
||||||
sid = "sessionid="..SESSION.sessionid,
|
sid = "sessionid="..SESSION.sessionid,
|
||||||
key = std.sha1(file..":"..stat.mtime)
|
key = enc.sha1(file..":"..stat.mtime)
|
||||||
}
|
}
|
||||||
return result(ret)
|
return result(ret)
|
||||||
end
|
end
|
||||||
|
|
||||||
handle.history = function(data)
|
handle.history = function(data)
|
||||||
local file = vfs.ospath(data.file)
|
local file = vfs.ospath(data.file)
|
||||||
local history_file = vfs.ospath("home://.office/"..std.sha1(file).."/history.json")
|
local history_file = vfs.ospath("home://.office/"..enc.sha1(file).."/history.json")
|
||||||
if(ulib.exists(history_file)) then
|
if(ulib.exists(history_file)) then
|
||||||
local obj = JSON.decodeFile(history_file)
|
local obj = JSON.decodeFile(history_file)
|
||||||
obj.hash = std.sha1(file)
|
obj.hash = enc.sha1(file)
|
||||||
return result(obj)
|
return result(obj)
|
||||||
else
|
else
|
||||||
return error("No history found")
|
return error("No history found")
|
||||||
@ -64,7 +82,7 @@ end
|
|||||||
handle.restore = function(data)
|
handle.restore = function(data)
|
||||||
local version = data.version
|
local version = data.version
|
||||||
local file = vfs.ospath(data.file)
|
local file = vfs.ospath(data.file)
|
||||||
local basepath = vfs.ospath("home://.office/"..std.sha1(file))
|
local basepath = vfs.ospath("home://.office/"..enc.sha1(file))
|
||||||
if ulib.exists(basepath.."/history.json") then
|
if ulib.exists(basepath.."/history.json") then
|
||||||
local history = JSON.decodeFile(basepath.."/history.json")
|
local history = JSON.decodeFile(basepath.."/history.json")
|
||||||
local obj = handle.clean_up_version(basepath, history,version)
|
local obj = handle.clean_up_version(basepath, history,version)
|
||||||
@ -95,22 +113,14 @@ handle.restore = function(data)
|
|||||||
end
|
end
|
||||||
handle.duplicate = function(data)
|
handle.duplicate = function(data)
|
||||||
local file = vfs.ospath(data.as)
|
local file = vfs.ospath(data.as)
|
||||||
local tmpfile = "/tmp/"..std.sha1(file)
|
download_file(data.remote, file)
|
||||||
local cmd = DLCMD.." "..tmpfile..' "'..data.remote..'"'
|
if not ulib.exists(file) then
|
||||||
os.execute(cmd)
|
|
||||||
-- move file to correct position
|
|
||||||
if ulib.exists(tmpfile) then
|
|
||||||
cmd = "mv "..tmpfile.." "..file
|
|
||||||
os.execute(cmd)
|
|
||||||
print("File "..file.." is duplicated with remote")
|
|
||||||
else
|
|
||||||
return error("Unable to duplicate file")
|
return error("Unable to duplicate file")
|
||||||
end
|
end
|
||||||
return result("File duplicated")
|
return result("File duplicated")
|
||||||
end
|
end
|
||||||
|
|
||||||
handle.save = function()
|
handle.save = function()
|
||||||
--print(JSON.encode(REQUEST))
|
|
||||||
if not REQUEST.json then
|
if not REQUEST.json then
|
||||||
return error("Invalid request")
|
return error("Invalid request")
|
||||||
end
|
end
|
||||||
@ -123,31 +133,31 @@ handle.save = function()
|
|||||||
end
|
end
|
||||||
local file = vfs.ospath(REQUEST.file)
|
local file = vfs.ospath(REQUEST.file)
|
||||||
if data.status == 2 then
|
if data.status == 2 then
|
||||||
local tmpfile = "/tmp/"..std.sha1(file)
|
local tmpfile = "/tmp/"..enc.sha1(file)
|
||||||
local cmd = DLCMD.." "..tmpfile..' "'..data.url..'"'
|
download_file(data.url, tmpfile)
|
||||||
os.execute(cmd)
|
|
||||||
-- move file to correct position
|
-- move file to correct position
|
||||||
if ulib.exists(tmpfile) then
|
if ulib.exists(tmpfile) then
|
||||||
|
LOG_INFO("Remote file saved to %s", tmpfile)
|
||||||
-- back up the file version
|
-- back up the file version
|
||||||
local history_dir = "home://.office"
|
local history_dir = "home://.office"
|
||||||
vfs.mkdir(history_dir)
|
vfs.mkdir(history_dir)
|
||||||
history_dir = history_dir.."/"..std.sha1(file)
|
history_dir = history_dir.."/"..enc.sha1(file)
|
||||||
vfs.mkdir(history_dir)
|
vfs.mkdir(history_dir)
|
||||||
history_dir = vfs.ospath(history_dir)
|
history_dir = vfs.ospath(history_dir)
|
||||||
-- backup old version
|
-- backup old version
|
||||||
cmd = 'cp "'..file..'" "'..history_dir.."/"..data.key..'"'
|
ulib.send_file(file,history_dir.."/"..data.key)
|
||||||
os.execute(cmd)
|
LOG_INFO("Backup file saved to %s", history_dir.."/"..data.key)
|
||||||
-- create new version
|
-- create new version
|
||||||
local old_stat = ulib.file_stat(file)
|
local old_stat = ulib.file_stat(file)
|
||||||
cmd = 'mv "'..tmpfile..'" "'..file..'"'
|
if not ulib.move(tmpfile, file) then
|
||||||
os.execute(cmd)
|
ulib.send_file(tmpfile, file)
|
||||||
|
end
|
||||||
-- get the new key
|
-- get the new key
|
||||||
local stat = ulib.file_stat(file)
|
local stat = ulib.file_stat(file)
|
||||||
local new_key = std.sha1(file..":"..stat.mtime)
|
local new_key = enc.sha1(file..":"..stat.mtime)
|
||||||
-- save changes
|
-- save changes
|
||||||
if(data.changesurl) then
|
if(data.changesurl) then
|
||||||
cmd = DLCMD.." "..history_dir.."/"..new_key..'.zip "'..data.changesurl..'"'
|
download_file(data.changesurl, history_dir.."/"..new_key..'.zip')
|
||||||
os.execute(cmd)
|
|
||||||
end
|
end
|
||||||
-- now save version object
|
-- now save version object
|
||||||
local history_file = history_dir.."/history.json"
|
local history_file = history_dir.."/history.json"
|
||||||
@ -177,7 +187,7 @@ handle.save = function()
|
|||||||
else
|
else
|
||||||
return error("Cannot save history")
|
return error("Cannot save history")
|
||||||
end
|
end
|
||||||
print("File "..file.." sync with remote")
|
LOG_INFO("File "..file.." sync with remote")
|
||||||
else
|
else
|
||||||
return error("Unable to download")
|
return error("Unable to download")
|
||||||
end
|
end
|
||||||
|
Binary file not shown.
@ -7,7 +7,7 @@
|
|||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "mrsang@iohub.dev"
|
"email": "mrsang@iohub.dev"
|
||||||
},
|
},
|
||||||
"version":"0.1.7-a",
|
"version":"0.1.8-a",
|
||||||
"category":"Office",
|
"category":"Office",
|
||||||
"icon":"icon.png",
|
"icon":"icon.png",
|
||||||
"mimes":[
|
"mimes":[
|
||||||
|
@ -275,7 +275,7 @@
|
|||||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/LibreOffice/README.md",
|
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/LibreOffice/README.md",
|
||||||
"category": "Office",
|
"category": "Office",
|
||||||
"author": "Dany LE",
|
"author": "Dany LE",
|
||||||
"version": "0.1.3-a",
|
"version": "0.1.4-a",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/LibreOffice/build/release/LibreOffice.zip"
|
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/LibreOffice/build/release/LibreOffice.zip"
|
||||||
},
|
},
|
||||||
@ -335,7 +335,7 @@
|
|||||||
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/OnlyOffice/README.md",
|
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/OnlyOffice/README.md",
|
||||||
"category": "Office",
|
"category": "Office",
|
||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"version": "0.1.7-a",
|
"version": "0.1.8-a",
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/OnlyOffice/build/release/OnlyOffice.zip"
|
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/2.0.x/OnlyOffice/build/release/OnlyOffice.zip"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user