1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2025-07-27 03:09:53 +02:00

mimgrating from another repo

This commit is contained in:
Xuan Sang LE
2018-09-19 15:08:49 +02:00
parent 91320521e8
commit 38bd13b46b
600 changed files with 362490 additions and 1 deletions

View File

@ -0,0 +1,24 @@
auth_or_die("User unauthorized. Please login")
local rq = nil
if REQUEST.query.json ~= nil then
rq = (JSON.decodeString(REQUEST.query.json))
else
rq = REQUEST.query
end
if rq.path ~= nil then
local pkg = require("fs.vfs").ospath(rq.path)
if pkg == nil then
pkg = OSROOT..'/packages/'..rq.path
--die("unkown request path:"..rq.path)
end
pkg = pkg.."/api.lua"
if unix.exists(pkg) then
dofile(pkg).exec(rq.method,rq.arguments)
else
fail("Uknown application handler: "..pkg)
end
else
fail("Uknown request")
end

View File

@ -0,0 +1,3 @@
auth_or_die("User unauthorized. Please login")
local user = require("system.uman").userinfo(SESSION.iotos_user)
result(user)

View File

@ -0,0 +1,17 @@
auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json))
if rq ~= nil then
local r,m = require("web").get(rq.url)
if r then
if r.binary then
result({body="data:"..r.contentType..";base64,"..r.data})
else
result({body=r.data})
end
else
fail(m)
end
else
fail("Uknown request")
end

View File

@ -0,0 +1,39 @@
if REQUEST.query.json ~= nil then
local request = JSON.decodeString(REQUEST.query.json)
local r = unix.auth(request.username,request.password)
if r == true then
local cookie = {sessionid=std.sha1(request.username..request.password)} -- iotos_user = request.username
local db = sysdb();
if db == nil then return fail("Cannot setup session") end
local cond = {exp= {["="] = { sessionid = cookie.sessionid }}}
local data = db:find(cond)
--print(data)
if data == nil or data[1] == nil then
--print("insert new data")
data = {sessionid = cookie.sessionid, username=request.username, stamp=os.time(os.date("!*t"))}
else
data = data[1]
--print("Update old data")
data.stamp = os.time(os.date("!*t"))
end
if data.id == nil then
db:insert(data)
else
db:update(data)
end
db:close()
std.cjson(cookie)
SESSION.iotos_user = request.username
local user = {
result = require("system.uman").userinfo(request.username),
error = false
}
std.t(JSON.encode(user))
else
fail("Invalid login")
end
else
fail("Invalid request")
end

View File

@ -0,0 +1,17 @@
if SESSION.sessionid ~= nil and SESSION.sessionid ~= '0' then
local cookie = {sessionid='0'}
local db = sysdb()
if db ~= nil then
--local data = db:find("sessionid ='"..SESSION.sessionid.."'")
--if data and data[0] ~= nil then
-- db:delete(data[0].id)
--end
local cond = {["="] = { sessionid = SESSION.sessionid }}
db:delete(cond)
db:close()
end
std.cjson(cookie)
else
std.json()
end
std.t(JSON.encode({error=false,result=true}))

View File

@ -0,0 +1,21 @@
[
{
"className": "NotePad",
"name": "Source editor",
"description": "Advance text editor",
"category": "development",
"author": "xsang.le@gmail.com",
"version": "0.1",
"download": "http://192.168.1.49:9191/repo/AceEditor.zip"
},
{
"className": "DummyApp",
"name": "Antos features",
"description": "Antos features show case",
"category": "utilities",
"author": "xsang.le@gmail.com",
"version": "1.0",
"download": "https://os.localhost:9195/repo/DummyApp.zip"
}
]

View File

@ -0,0 +1,588 @@
"default/About": {
"className": "ApplicationAbout",
"name": "About OS.js",
"description": "About OS.js",
"names": {
"bg_BG": " За OS.js",
"de_DE": "Über OS.js",
"fr_FR": "À propos d'OS.js",
"it_IT": "Informazioni su OS.js",
"ko_KR": "OS.js에 대하여",
"nl_NL": "Over OS.js",
"no_NO": "Om OS.js",
"pl_PL": "o OS.js",
"ru_RU": "Об OS.js",
"sk_SK": "o OS.js",
"tr_TR": "hakkında OS.js",
"vi_VN": "Thông tin về OS.js"
},
"descriptions": {
"bg_BG": "За OS.js",
"de_DE": "Über OS.js",
"fr_FR": "À propos d'OS.js",
"it_IT": "Informazioni su OS.js",
"ko_KR": "OS.js에 대하여",
"nl_NL": "Over OS.js",
"no_NO": "Om OS.js",
"pl_PL": "o OS.js",
"ru_RU": "Об OS.js",
"sk_SK": "o OS.js",
"tr_TR": "hakkında OS.js",
"vi_VN": "Thông tin về OS.js"
},
"singular": true,
"category": "system",
"icon": "apps/help-browser.png",
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/About",
"build": {},
"repo": "default"
},
"default/AceEditor": {
"className": "ApplicationAceEditor",
"name": "Source Editor",
"icon": "apps/accessories-text-editor.png",
"category": "development",
"mime": [
"^text",
"inode\\/x\\-empty",
"application\\/x\\-empty",
"application\\/x\\-python",
"application\\/x\\-php",
"application\\/javascript"
],
"build": {
"copy": [
"metadata.json",
"scheme.html",
"main.css",
"main.js",
"vendor/ace"
]
},
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/AceEditor",
"repo": "default"
},
"default/Archiver": {
"className": "ApplicationArchiver",
"name": "Archiver",
"mime": [
"application/zip"
],
"icon": "apps/system-software-install.png",
"category": "utilities",
"compability": [
"file",
"blob"
],
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/Archiver",
"build": {},
"repo": "default"
},
"default/Calculator": {
"className": "ApplicationCalculator",
"name": "Calculator",
"names": {
"bg_Bg": "Клакулатор",
"fr_FR": "Calculatrice",
"it_IT": "Calcolatrice",
"ko_KR": "계산기",
"nl_NL": "Rekenmachine",
"no_NO": "Kalkulator",
"pl_PL": "Kalkulator",
"ru_RU": "Калькулятор",
"sk_SK": "Kalkulačka",
"tr_TR": "Hesap Makinesi",
"vi_VN": "Máy tính"
},
"icon": "apps/calc.png",
"category": "office",
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/Calculator",
"build": {},
"repo": "default"
},
"default/CoreWM": {
"className": "CoreWM",
"name": "OS.js Window Manager",
"names": {
"bg_BG": "Мениджър на прозорци на OS.js",
"de_DE": "OS.js Fenster-Manager",
"es_ES": "OS.js Window Manager",
"fr_FR": "Gestionnaire de fenêtre OS.js",
"it_IT": "OS.js Gestore Finestre",
"ko_KR": "OS.js 윈도우 관리자",
"nl_NL": "OS.js venster beheer",
"no_NO": "OS.js Vinduhåndterer",
"pl_PL": "Menedżer Okien OS.js",
"ru_RU": "OS.js Оконный менеджер",
"sk_SK": "Správca Okien OS.js",
"tr_TR": "OS.js Pencere Yöneticisi",
"vi_VN": "Quản lí cửa sổ OS.js"
},
"singular": true,
"type": "windowmanager",
"icon": "apps/gnome-window-manager.png",
"splash": false,
"preload": [{
"src": "scheme.html",
"type": "scheme"
}, {
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}],
"panelItems": {
"AppMenu": {
"Name": "AppMenu",
"Description": "Application Menu",
"Icon": "actions/stock_about.png",
"HasOptions": false
},
"Buttons": {
"Name": "Buttons",
"Description": "Button Bar",
"Icon": "actions/stock_about.png"
},
"Clock": {
"Name": "Clock",
"Description": "View the time",
"Icon": "status/appointment-soon.png",
"HasOptions": true
},
"NotificationArea": {
"Name": "NotificationArea",
"Description": "View notifications",
"Icon": "apps/gnome-panel-notification-area.png"
},
"Search": {
"Name": "Search",
"Description": "Perform searches",
"Icon": "actions/find.png",
"HasOptions": true
},
"Weather": {
"Name": "Weather",
"Description": "Weather notification",
"Icon": "status/weather-few-clouds.png"
},
"WindowList": {
"Name": "Window List",
"Description": "Toggle between open windows",
"Icon": "apps/xfwm4.png"
}
},
"path": "default/CoreWM",
"build": {},
"repo": "default"
},
"default/FileManager": {
"className": "ApplicationFileManager",
"name": "File Manager",
"description": "The default file manager",
"names": {
"bg_BG": "Файлов мениджър",
"de_DE": "Dateimanager",
"fr_FR": "Explorateur de fichier",
"it_IT": "Gestore File",
"nl_NL": "bestands beheer",
"no_NO": "Fil-håndtering",
"pl_PL": "Menedżer Plików",
"ko_KR": "파일 탐색기",
"sk_SK": "Správca súborov",
"ru_RU": "Файловый менеджер",
"tr_TR": "Dosya Yöneticisi",
"vi_VN": "Quản lí file"
},
"descriptions": {
"bg_BG": "Стандартния файлов мениджър",
"de_DE": "Standardmäßiger Dateimanager",
"fr_FR": "Gestionnaire de fichier par défaut",
"it_IT": "Il gestore file predefinito",
"nl_NL": "Standaard bestands beheerder",
"no_NO": "Standard Fil-håndtering program",
"pl_PL": "Domyślny Menedżer Plików",
"ko_KR": "기본 파일 관리자",
"sk_SK": "Štandardný správca súborov",
"ru_RU": "Стандартный файловый менеджер",
"tr_TR": "Varsayılan dosya yöneticisi",
"vi_VN": "Trình quản lí file mặc định"
},
"category": "utilities",
"icon": "apps/file-manager.png",
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/FileManager",
"build": {},
"repo": "default"
},
"default/MarkOn": {
"className": "ApplicationMarkOn",
"name": "MarkOn",
"mime": [
"^text",
"inode\\/x\\-empty",
"application\\/x\\-empty"
],
"category": "office",
"icon": "apps/libreoffice34-writer.png",
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/MarkOn",
"build": {},
"repo": "default"
},
"default/PDFjs": {
"className": "ApplicationPDFjs",
"name": "PDF Viewer",
"description": "PDF Viewer",
"mime": [
"application/pdf"
],
"category": "office",
"icon": "mimetypes/gnome-mime-application-pdf.png",
"build": {
"copy": [
"metadata.json",
"scheme.html",
"main.css",
"main.js",
"vendor/pdf.js"
]
},
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/PDFjs",
"repo": "default"
},
"default/Preview": {
"className": "ApplicationPreview",
"name": "Preview",
"description": "Preview image files",
"names": {
"bg_BG": "Преглед на изображения",
"de_DE": "Vorschau",
"fr_FR": "Visionneuse",
"it_IT": "Anteprima Immagini",
"ko_KR": "미리보기",
"nl_NL": "Foto viewer",
"no_NO": "Forhåndsviser",
"pl_PL": "Podgląd",
"ru_RU": "Просмотрщик",
"sk_SK": "Prehliadač obrázkov",
"tr_TR": "Önizle",
"vi_VN": "Trình xem ảnh"
},
"descriptions": {
"bg_BG": "Преглед на изображения",
"de_DE": "Bildervorschau",
"fr_FR": "Visionneuse de photos",
"it_IT": "Anteprima Immagini",
"ko_KR": "이미지 파일을 미리 봅니다",
"nl_NL": "Foto viewer",
"no_NO": "Forhåndsvisning av bilde-filer",
"pl_PL": "Podgląd zdjęć",
"ru_RU": "Просмотрщик изображений",
"sk_SK": "Prehliadač obrázkov",
"tr_TR": "resim dosyalarını önizle",
"vi_VN": "Trình xem ảnh"
},
"mime": [
"^image",
"^video"
],
"category": "multimedia",
"icon": "mimetypes/image.png",
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/Preview",
"build": {},
"repo": "default"
},
"default/ProcessViewer": {
"className": "ApplicationProcessViewer",
"name": "Process Viewer",
"description": "View running processes",
"names": {
"bg_BG": "Процеси",
"de_DE": "Prozess-Manager",
"fr_FR": "Gestionnaire de processus",
"it_IT": "Gestore Attività",
"ko_KR": "프로세스 관리자",
"nl_NL": "Proces manager",
"no_NO": "Prosess oversikt",
"pl_PL": "Procesy",
"ru_RU": "Менеджер процессов",
"sk_SK": "Správca procesov",
"tr_TR": "İşlemleri Görüntüle",
"vi_VN": "Xem tiến trình"
},
"descriptions": {
"bg_BG": "Преглед на процеси",
"de_DE": "Laufende Prozesse verwalten",
"fr_FR": "Visualiser les processus en cours",
"it_IT": "Mostri processi attivi",
"ko_KR": "실행 중인 프로세스를 관리합니다",
"nl_NL": "Bekijk de lopende processen",
"no_NO": "Se oversikt over kjørende prosesser",
"pl_PL": "Zobacz działające procesy",
"ru_RU": "Менеджер запущенных процессов",
"sk_SK": "Spravovanie bežiacich procesov",
"tr_TR": "çalışan işlemleri görüntüle",
"vi_VN": "Xem các tiến trình đang chạy"
},
"singular": true,
"category": "system",
"icon": "apps/gnome-monitor.png",
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/ProcessViewer",
"build": {},
"repo": "default"
},
"default/Settings": {
"className": "ApplicationSettings",
"preloadParallel": true,
"name": "Settings",
"mime": null,
"icon": "categories/applications-system.png",
"category": "system",
"singular": true,
"names": {
"bg_BG": "Настройки",
"de_DE": "Einstellungen",
"es_ES": "Settings",
"fr_FR": "Paramètres",
"it_IT": "Settaggi",
"ko_KR": "환경설정",
"nl_NL": "Instellingen",
"no_NO": "Instillinger",
"pl_PL": "Ustawienia",
"ru_RU": "Настройки",
"sk_SK": "Nastavenia",
"tr_TR": "Ayarlar",
"vi_VN": "Cài đặt"
},
"descriptions": {
"bg_BG": "Настройки",
"de_DE": "Einstellungen",
"es_ES": "Settings",
"fr_FR": "Paramètres",
"it_IT": "Settaggi",
"ko_KR": "환경설정",
"nl_NL": "Instellingen",
"no_NO": "Instillinger",
"pl_PL": "Ustawienia",
"ru_RU": "Настройки",
"sk_SK": "Nastavenia",
"tr_TR": "Program Ayarlarını düzenle",
"vi_VN": "Cài đặt"
},
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/Settings",
"build": {},
"repo": "default"
},
"default/Textpad": {
"className": "ApplicationTextpad",
"name": "Textpad",
"description": "Simple text editor",
"names": {
"bg_BG": "Текстов редактор",
"de_DE": "Texteditor",
"fr_FR": "Éditeur de texte",
"it_IT": "Editor Testi",
"ko_KR": "텍스트패드",
"nl_NL": "Notities",
"no_NO": "Tekstblokk",
"pl_PL": "Notatnik",
"ru_RU": "Редактор текста",
"sk_SK": "Poznámkový blok",
"tr_TR": "Basit Bir Metin Düzenleyicisi",
"vi_VN": "Trình sửa văn bản"
},
"descriptions": {
"bg_BG": "Стандартен текстов редактор",
"de_DE": "Einfacher Texteditor",
"fr_FR": "Éditeur de texte simple",
"it_IT": "Semplice editor di testi",
"ko_KR": "간단한 텍스트 편집기",
"nl_NL": "Eenvoudige Tekstverwerker",
"no_NO": "Simpel tekst redigering",
"pl_PL": "Prosty edytor tekstu",
"ru_RU": "Простой текстовый редактор",
"sk_SK": "Jednoduchý textový editor",
"tr_TR": "Basit Bir Metin Düzenleyicisi",
"vi_VN": "Trình sửa văn bản đơn giản"
},
"mime": [
"^text",
"inode\\/x\\-empty",
"application\\/x\\-empty",
"application\\/x\\-lua",
"application\\/x\\-python",
"application\\/javascript",
"application\\/json"
],
"category": "utilities",
"icon": "apps/accessories-text-editor.png",
"preload": [{
"type": "javascript",
"src": "combined.js"
}, {
"type": "stylesheet",
"src": "combined.css"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/Textpad",
"build": {},
"repo": "default"
},
"default/wTerm": {
"className": "ApplicationwTerm",
"name": "wTerm",
"mime": null,
"icon": "apps/terminal.png",
"category": "system",
"preload": [{
"type": "stylesheet",
"src": "combined.css"
}, {
"type": "javascript",
"src": "combined.js"
}, {
"src": "scheme.html",
"type": "scheme"
}],
"type": "application",
"path": "default/wTerm",
"build": {},
"repo": "default"
},
"default/LuaPlayground": {
"className": "ApplicationLuaPlayground",
"name": "Lua Playground",
"mime": null,
"icon": "categories/preferences-other.png",
"category": "development",
"preload": [
{
"type": "javascript",
"src": "combined.js"
},
{
"type": "stylesheet",
"src": "combined.css"
},
{
"src": "scheme.html",
"type": "scheme"
}
],
"type": "application",
"path": "default/LuaPlayground",
"build": {},
"repo": "default"
}

View File

@ -0,0 +1,140 @@
auth_or_die("User unauthorized. Please login")
local packages={}
local vfs = require("fs.vfs")
local uid = unix.uid(SESSION.iotos_user)
packages._cache = function(y)
local p = vfs.ospath(y)
local f = io.open(p.."/packages.json", "w")
local has_cache = false
local i = 1
local meta = {}
if f then
local files = vfs.readDir(y)
for k,v in pairs(files) do
if v.type == "dir" then
local f1 = io.open(vfs.ospath(v.path.."/package.json"))
if f1 then
local name = std.basename(v.path)
local mt = JSON.decodeString(f1:read("*all"))
mt.path = v.path
meta[i] ='"'..name..'":'..JSON.encode(mt)
i = i+1
f1:close()
has_cache = true;
end
end
end
f:write(table.concat(meta, ","))
f:close()
if has_cache == false then
unix.delete(p.."/packages.json");
end
end
end
-- we will change this later
packages.list = function(paths)
std.json()
std.t("{\"result\" : { ")
local first = true
--std.f(__ROOT__.."/system/packages.json")
for k,v in pairs(paths) do
local osp = vfs.ospath(v.."/packages.json")
if unix.exists(osp) == false then
packages._cache(v)
end
if unix.exists(osp) then
if first == false then
std.t(",")
else
first = false
end
std.f(osp)
end
end
std.t("}, \"error\":false}")
end
-- generate the packages caches
packages.cache = function(args)
-- perform a packages caches
for x,y in pairs(args.paths) do
packages._cache(y)
end
result(true)
end
-- install a function from zip file
packages.install = function(args)
local path = vfs.ospath(args.dest)
local zip = vfs.ospath(args.zip)
if(unix.exists(path) == false) then
-- create directory if not exist
unix.mkdir(path)
-- change permission
unix.chown(path, uid.id, uid.gid)
end
-- extract the zip file to it
if(unix.unzip(zip, path)) then
-- read metadata
local meta = JSON.decodeFile(path.."/metadata.json")
meta.path = args.dest
meta.scope = "user"
local f=io.open(path.."/package.json","w")
if f then
f:write(JSON.encode(meta))
f:close()
end
result(true)
else
fail("Problem extracting zip file")
end
end
-- uninstall the package
packages.uninstall = function(path)
local osf = vfs.ospath(path)
if(osf and unix.exists(osf) ) then
--remove it
unix.delete(osf)
result(true)
else
fail("Cannot find package")
end
end
-- set user packages environment
packages.init = function(paths)
if(paths) then
for k,v in pairs(paths) do
local p = vfs.ospath(v)
if p and (unix.exists(p) == false) then
unix.mkdir(p)
-- change permission
unix.chown(p, uid.id, uid.gid)
end
end
end
end
-- main()
local rq = (JSON.decodeString(REQUEST.query.json))
packages.init(rq.args.paths)
if rq ~= nil then
-- check user command here
if(rq.command == "install") then
packages.install(rq.args)
elseif rq.command == "cache" then
packages.cache(rq.args)
elseif rq.command == "list" then
packages.list(rq.args.paths)
elseif rq.command == "uninstall" then
packages.uninstall(rq.args.path)
else
fail("Uknown packages command")
end
else
fail("Uknown request")
end

View File

@ -0,0 +1,19 @@
auth_or_die("User unauthorized. Please login")
local user = SESSION.iotos_user
if user then
local ospath = require('fs.vfs').ospath("home:///",user)
if REQUEST.query and REQUEST.query.json then
local f = io.open(ospath.."/"..".settings.json", "w")
if f then
f:write(REQUEST.query.json)
f:close()
result(true)
else
fail("Cannot save setting")
end
else
fail("No setting founds")
end
else
fail("User not found")
end

View File

@ -0,0 +1,27 @@
local uman={}
uman.userinfo = function(user)
local info = {}
local uid = unix.uid(user)
if uid then
-- read the setting
-- use the decodeFile function of JSON instead
local file = require('fs.vfs').ospath("home:///").."/.settings.json"
local st = JSON.decodeFile(file)
if(st) then
info = st
end
info.user = {
username = user,
id = uid.id,
name = user,
groups = uid.groups
}
--print(JSON.encode(info))
return info
else
return {}
end
end
return uman

View File

@ -0,0 +1,23 @@
auth_or_die("User unauthorized. Please login")
local rq = (JSON.decodeString(REQUEST.query.json))
if rq then
if rq.command == "list" then
users = {}
local uid = unix.uid(SESSION.iotos_user)
if uid then
users[0] = {
username = SESSION.iotos_user,
id = uid.id,
name = SESSION.iotos_user,
groups = {"admin"}
}
result(users)
else
fail("Problem when retreive users")
end
else
fail("command "..rq.command.." is not supported yet")
end
else
fail("Unknow request")
end