1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00

adapt to new api mechanism

This commit is contained in:
lxsang 2018-10-05 19:03:29 +02:00
parent cceb8b2c49
commit a6c14bd9bf
8 changed files with 31 additions and 31 deletions

View File

@ -18,8 +18,8 @@ POST_LIMIT = 2
-- require needed library -- require needed library
require(BASE_FRW.."silk.api") require(BASE_FRW.."silk.api")
if REQUEST.query.r then if REQUEST.r then
REQUEST.query.r = REQUEST.query.r:gsub("%:", "/") REQUEST.r = REQUEST.r:gsub("%:", "/")
end end
-- registry object store global variables -- registry object store global variables

View File

@ -48,7 +48,7 @@
<?lua <?lua
echo("<ul>") echo("<ul>")
for k,v in pairs(similar_posts) do for k,v in pairs(similar_posts) do
echo("<li><a href='./r:id:"..v.st.sid.."'>"..v.post.title.."</a> (<b>Score</b>: "..string.format("%2.2f",v.st.score)..")</li>") echo("<li><a href='./"..v.st.sid.."'>"..v.post.title.."</a> (<b>Score</b>: "..string.format("%2.2f",v.st.score)..")</li>")
end end
echo("</ul>") echo("</ul>")
end?> end?>

View File

@ -26,7 +26,7 @@ end
function SystemController:packages(...) function SystemController:packages(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
local packages = require("packages") local packages = require("packages")
packages.init(rq.args.paths) packages.init(rq.args.paths)
if rq ~= nil then if rq ~= nil then
@ -52,10 +52,10 @@ function SystemController:settings(...)
local user = SESSION.user local user = SESSION.user
if user then if user then
local ospath = require("vfs").ospath("home:///", user) local ospath = require("vfs").ospath("home:///", user)
if REQUEST.query and REQUEST.query.json then if REQUEST and REQUEST.json then
local f = io.open(ospath .. "/" .. ".settings.json", "w") local f = io.open(ospath .. "/" .. ".settings.json", "w")
if f then if f then
f:write(REQUEST.query.json) f:write(REQUEST.json)
f:close() f:close()
result(true) result(true)
else else
@ -72,10 +72,10 @@ end
function SystemController:application(...) function SystemController:application(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = nil local rq = nil
if REQUEST.query.json ~= nil then if REQUEST.json ~= nil then
rq = (JSON.decodeString(REQUEST.query.json)) rq = (JSON.decodeString(REQUEST.json))
else else
rq = REQUEST.query rq = REQUEST
end end
if rq.path ~= nil then if rq.path ~= nil then
@ -97,7 +97,7 @@ end
function SystemController:apigateway(...) function SystemController:apigateway(...)
local use_ws = false local use_ws = false
if REQUEST.query and REQUEST.query.ws == "1" then if REQUEST and REQUEST.ws == "1" then
-- override the global echo command -- override the global echo command
echo = std.ws.swrite echo = std.ws.swrite
use_ws = true use_ws = true
@ -180,8 +180,8 @@ function SystemController:apigateway(...)
print("Web socket is not available.") print("Web socket is not available.")
end end
else else
if REQUEST.query.json then if REQUEST.json then
data = JSON.decodeString(REQUEST.query.json) data = JSON.decodeString(REQUEST.json)
--std.json() --std.json()
exec_with_user_priv(data) exec_with_user_priv(data)
else else

View File

@ -39,8 +39,8 @@ end
return: return:
{} ]] {} ]]
function UserController:login(...) function UserController:login(...)
if REQUEST.query.json ~= nil then if REQUEST.json ~= nil then
local request = JSON.decodeString(REQUEST.query.json) local request = JSON.decodeString(REQUEST.json)
local r = ulib.auth(request.username,request.password) local r = ulib.auth(request.username,request.password)
if r == true then if r == true then
local cookie = {sessionid=std.sha1(request.username..request.password)} -- iotos_user = request.username local cookie = {sessionid=std.sha1(request.username..request.password)} -- iotos_user = request.username

View File

@ -26,7 +26,7 @@ end
function VDBController:save(...) function VDBController:save(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if (rq ~= nil and rq.table ~= nil) then if (rq ~= nil and rq.table ~= nil) then
local model = require("dbmodel").get(SESSION.user, rq.table, rq.data) local model = require("dbmodel").get(SESSION.user, rq.table, rq.data)
local ret local ret
@ -54,7 +54,7 @@ end
function VDBController:get(...) function VDBController:get(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if (rq ~= nil and rq.table ~= nil) then if (rq ~= nil and rq.table ~= nil) then
local model = require("dbmodel").get(SESSION.user, rq.table, nil) local model = require("dbmodel").get(SESSION.user, rq.table, nil)
local ret local ret
@ -76,7 +76,7 @@ end
function VDBController:select(...) function VDBController:select(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if (rq ~= nil and rq.table ~= nil) then if (rq ~= nil and rq.table ~= nil) then
local model = require("dbmodel").get(SESSION.user, rq.table, nil) local model = require("dbmodel").get(SESSION.user, rq.table, nil)
local ret local ret
@ -99,7 +99,7 @@ end
function VDBController:delete(...) function VDBController:delete(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if (rq ~= nil and rq.table ~= nil) then if (rq ~= nil and rq.table ~= nil) then
local model = require("dbmodel").get(SESSION.user, rq.table, nil) local model = require("dbmodel").get(SESSION.user, rq.table, nil)
local ret local ret

View File

@ -32,7 +32,7 @@ end
function VFSController:fileinfo(...) function VFSController:fileinfo(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local vfspath = (JSON.decodeString(REQUEST.query.json)).path local vfspath = (JSON.decodeString(REQUEST.json)).path
local r, m = require("vfs").fileinfo(vfspath) local r, m = require("vfs").fileinfo(vfspath)
if r then if r then
result(m) result(m)
@ -46,7 +46,7 @@ function VFSController:exists(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local vfs = require("vfs") local vfs = require("vfs")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then if rq ~= nil then
result(vfs.exists(rq.path)) result(vfs.exists(rq.path))
@ -60,7 +60,7 @@ function VFSController:delete(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local vfs = require("vfs") local vfs = require("vfs")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then if rq ~= nil then
local r, e = vfs.delete(rq.path) local r, e = vfs.delete(rq.path)
@ -120,7 +120,7 @@ end
function VFSController:mkdir(...) function VFSController:mkdir(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then if rq ~= nil then
local r, m = require("vfs").mkdir(rq.path) local r, m = require("vfs").mkdir(rq.path)
@ -138,7 +138,7 @@ end
function VFSController:move(...) function VFSController:move(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then if rq ~= nil then
local r, m = require("vfs").move(rq.src, rq.dest) local r, m = require("vfs").move(rq.src, rq.dest)
@ -156,7 +156,7 @@ end
function VFSController:publish(...) function VFSController:publish(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then if rq ~= nil then
local p = nil local p = nil
@ -198,7 +198,7 @@ end
function VFSController:scandir(...) function VFSController:scandir(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = JSON.decodeString(REQUEST.query.json) local rq = JSON.decodeString(REQUEST.json)
local vfspath = rq.path local vfspath = rq.path
local r = require("vfs").readDir(vfspath) local r = require("vfs").readDir(vfspath)
if r == nil then if r == nil then
@ -213,8 +213,8 @@ end
function VFSController:upload(...) function VFSController:upload(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local vfs = require("vfs") local vfs = require("vfs")
if REQUEST.query then if REQUEST then
local r, m = require("vfs").upload(REQUEST.query.path) local r, m = require("vfs").upload(REQUEST.path)
if r then if r then
result(r) result(r)
else else
@ -228,7 +228,7 @@ end
function VFSController:write(...) function VFSController:write(...)
auth_or_die("User unauthorized. Please login") auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json)) local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then if rq ~= nil then
local r, m = require("vfs").write(rq.path, rq.data) local r, m = require("vfs").write(rq.path, rq.data)

View File

@ -143,8 +143,8 @@ vfs.upload = function(path)
local r,m = vfs.checkperm(path,"write") local r,m = vfs.checkperm(path,"write")
if(r) then if(r) then
local uid = ulib.uid(SESSION.user) local uid = ulib.uid(SESSION.user)
local file = m.."/"..REQUEST.query["upload.file"] local file = m.."/"..REQUEST["upload.file"]
ulib.move(REQUEST.query["upload.tmp"], file) ulib.move(REQUEST["upload.tmp"], file)
ulib.chown(file, uid.id, uid.gid) ulib.chown(file, uid.id, uid.gid)
return true, nil return true, nil
else else

View File

@ -24,7 +24,7 @@ function Router:infer(url)
-- c,d,e is parameters -- c,d,e is parameters
-- if user dont provide the url, try to infer it -- if user dont provide the url, try to infer it
-- from the REQUEST -- from the REQUEST
url = url or REQUEST.query.r or "" url = url or REQUEST.r or ""
url = std.trim(url, "/") url = std.trim(url, "/")
local args = explode(url, "/") local args = explode(url, "/")
local data = { local data = {