1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-12-26 17:38:21 +01:00

remove office controller in doc
All checks were successful
gitea-sync/antd-web-apps/pipeline/head This commit looks good

This commit is contained in:
DanyLE 2023-04-26 18:54:29 +02:00
parent a76942f2f3
commit 6da933da67
2 changed files with 0 additions and 158 deletions

View File

@ -1,91 +0,0 @@
BaseController:subclass(
"OfficeController",
{
registry = {},
models = {}
}
)
local docType = function(ext)
if ext == "doc" or ext=="docx" or ext =="odt" then
return "word"
elseif ext == "csv" or ext =="ods" or ext== "xls" or ext == "xlsx" then
return "cell"
elseif ext == "odp" or ext == "ppt" or ext == "pptx" then
return "slide"
else
return "none"
end
end
function OfficeController:index(sid)
-- doing nothing here
require("sqlite")
local ospath = require("shared").ospath(sid)
local ext = ospath:match("^.+%.(.+)$")
local name = ospath:match("^.+/(.+)$")
if(ulib.exists(ospath)) then
local stat = ulib.file_stat(ospath)
if stat.error == nil then
local key = std.sha1(ospath..":"..stat.mtime)
self.template:set("shareid", sid)
self.template:set("ext", ext )
self.template:set("doctype", docType(ext) )
self.template:set("name", name)
self.template:set("key", key)
end
end
self:switchLayout("office")
return true
end
function OfficeController:shared(id)
require("sqlite")
require(BASE_FRW.."shared").get(id)
return false
end
function OfficeController:save(sid)
require("sqlite")
local ospath = require("shared").ospath(sid)
std.json()
local obj = {
error = false,
result = false
}
if not REQUEST.json then
obj.error = "Invalid request"
echo(JSON.encode(obj))
return false
end
local data = JSON.decodeString(REQUEST.json)
if not data then
obj.error = "Invalid request"
echo(JSON.encode(obj))
return false
end
if data.status == 2 then
local tmpfile = "/tmp/"..std.sha1(ospath)
local cmd = "curl -o "..tmpfile..' "'..data.url..'"'
os.execute(cmd)
-- move file to correct position
if ulib.exists(tmpfile) then
cmd = "mv "..tmpfile.." "..ospath
os.execute(cmd)
print("File "..ospath.." sync with remote")
else
obj.error = "Unable to sync file"
echo(JSON.encode(obj))
return false
end
end
obj.result = "OK"
echo(JSON.encode(obj))
return false
end
function OfficeController:actionnotfound(...)
self.template:setView("index")
return self:index(table.unpack({...}))
end

View File

@ -1,67 +0,0 @@
<?lua
local shareid = __main__:get("shareid")
local ext = __main__:get("ext")
local doctype = __main__:get("doctype")
local name = __main__:get("name")
local key = __main__:get("key")
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link
rel="stylesheet"
type="text/css"
href="<?=HTTP_ROOT?>/assets/office.css" />
<!--meta name="viewport" content="width=device-width, initial-scale=1"-->
<script src="https://office.iohub.dev/web-apps/apps/api/documents/api.js"> </script>
<title>
<?lua
echo(name)
?>
</title>
<script type="text/javascript">
<?lua
if shareid and ext and doctype ~= "none" then
?>
window.onload = () => {
const editor = new DocsAPI.DocEditor("container", {
events: {
onAppReady: (e) => () => {},
//onRequestCreateNew: () => @newDocument(),
//onRequestSaveAs: (e) => @saveAs(e)
},
document: {
fileType: '<?=ext?>',
key: '<?=key?>',
title: '<?=name?>',
url: "https://doc.iohub.dev/office/shared/<?=shareid?>"
},
documentType: '<?=doctype?>',
editorConfig: {
//user: {
// id: @systemsetting.user.id.toString(),
// name: @systemsetting.user.username
//},
customization: {
compactHeader: false,
},
callbackUrl:"https://doc.iohub.dev/office/save/<?=shareid?>"
}
});
};
<?lua
end
?>
</script>
</head>
<body>
<div id = "container">
<?lua
if not shareid or not ext or doctype == "none" then
echo("<h1> Invalid document </h1>")
end
?>
</div>
</body>
</html>