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(BASE_FRW.."silk.api")
if REQUEST.query.r then
REQUEST.query.r = REQUEST.query.r:gsub("%:", "/")
if REQUEST.r then
REQUEST.r = REQUEST.r:gsub("%:", "/")
end
-- registry object store global variables

View File

@ -48,7 +48,7 @@
<?lua
echo("<ul>")
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
echo("</ul>")
end?>

View File

@ -26,7 +26,7 @@ end
function SystemController:packages(...)
auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
local packages = require("packages")
packages.init(rq.args.paths)
if rq ~= nil then
@ -52,10 +52,10 @@ function SystemController:settings(...)
local user = SESSION.user
if user then
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")
if f then
f:write(REQUEST.query.json)
f:write(REQUEST.json)
f:close()
result(true)
else
@ -72,10 +72,10 @@ end
function SystemController:application(...)
auth_or_die("User unauthorized. Please login")
local rq = nil
if REQUEST.query.json ~= nil then
rq = (JSON.decodeString(REQUEST.query.json))
if REQUEST.json ~= nil then
rq = (JSON.decodeString(REQUEST.json))
else
rq = REQUEST.query
rq = REQUEST
end
if rq.path ~= nil then
@ -97,7 +97,7 @@ end
function SystemController:apigateway(...)
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
echo = std.ws.swrite
use_ws = true
@ -180,8 +180,8 @@ function SystemController:apigateway(...)
print("Web socket is not available.")
end
else
if REQUEST.query.json then
data = JSON.decodeString(REQUEST.query.json)
if REQUEST.json then
data = JSON.decodeString(REQUEST.json)
--std.json()
exec_with_user_priv(data)
else

View File

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

View File

@ -26,7 +26,7 @@ end
function VDBController:save(...)
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
local model = require("dbmodel").get(SESSION.user, rq.table, rq.data)
local ret
@ -54,7 +54,7 @@ end
function VDBController:get(...)
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
local model = require("dbmodel").get(SESSION.user, rq.table, nil)
local ret
@ -76,7 +76,7 @@ end
function VDBController:select(...)
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
local model = require("dbmodel").get(SESSION.user, rq.table, nil)
local ret
@ -99,7 +99,7 @@ end
function VDBController:delete(...)
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
local model = require("dbmodel").get(SESSION.user, rq.table, nil)
local ret

View File

@ -32,7 +32,7 @@ end
function VFSController:fileinfo(...)
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)
if r then
result(m)
@ -46,7 +46,7 @@ function VFSController:exists(...)
auth_or_die("User unauthorized. Please login")
local vfs = require("vfs")
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then
result(vfs.exists(rq.path))
@ -60,7 +60,7 @@ function VFSController:delete(...)
auth_or_die("User unauthorized. Please login")
local vfs = require("vfs")
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then
local r, e = vfs.delete(rq.path)
@ -120,7 +120,7 @@ end
function VFSController:mkdir(...)
auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then
local r, m = require("vfs").mkdir(rq.path)
@ -138,7 +138,7 @@ end
function VFSController:move(...)
auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then
local r, m = require("vfs").move(rq.src, rq.dest)
@ -156,7 +156,7 @@ end
function VFSController:publish(...)
auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then
local p = nil
@ -198,7 +198,7 @@ end
function VFSController:scandir(...)
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 r = require("vfs").readDir(vfspath)
if r == nil then
@ -213,8 +213,8 @@ end
function VFSController:upload(...)
auth_or_die("User unauthorized. Please login")
local vfs = require("vfs")
if REQUEST.query then
local r, m = require("vfs").upload(REQUEST.query.path)
if REQUEST then
local r, m = require("vfs").upload(REQUEST.path)
if r then
result(r)
else
@ -228,7 +228,7 @@ end
function VFSController:write(...)
auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json))
local rq = (JSON.decodeString(REQUEST.json))
if rq ~= nil then
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")
if(r) then
local uid = ulib.uid(SESSION.user)
local file = m.."/"..REQUEST.query["upload.file"]
ulib.move(REQUEST.query["upload.tmp"], file)
local file = m.."/"..REQUEST["upload.file"]
ulib.move(REQUEST["upload.tmp"], file)
ulib.chown(file, uid.id, uid.gid)
return true, nil
else

View File

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