mirror of
https://github.com/holub/mame
synced 2025-07-01 00:09:18 +03:00
Added plugin info json files and made system automatically load available plugins and start them if flagged so (nw)
This commit is contained in:
parent
5a31d8513b
commit
686ba42466
@ -1,26 +1,24 @@
|
|||||||
|
require('lfs')
|
||||||
local uv = require('luv')
|
local uv = require('luv')
|
||||||
local cwd = uv.cwd()
|
local cwd = uv.cwd()
|
||||||
package.path = cwd .. "/plugins/?.lua;" .. cwd .. "/plugins/?/init.lua"
|
package.path = cwd .. "/plugins/?.lua;" .. cwd .. "/plugins/?/init.lua"
|
||||||
|
|
||||||
require('weblit/app')
|
local json = require('json')
|
||||||
|
function readAll(file)
|
||||||
|
local f = io.open(file, "rb")
|
||||||
|
local content = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
return content
|
||||||
|
end
|
||||||
|
|
||||||
.bind({
|
for file in lfs.dir("plugins") do
|
||||||
host = "0.0.0.0",
|
if (file~="." and file~=".." and lfs.attributes("plugins/" .. file,"mode")=="directory") then
|
||||||
port = 8080
|
local filename = "plugins/" .. file .. "/plugin.json"
|
||||||
})
|
local meta = json.parse(readAll(filename))
|
||||||
|
if (meta["plugin"]["type"]=="plugin") and (meta["plugin"]["start"]=="true") then
|
||||||
.use(require('weblit/logger'))
|
server = require(meta["plugin"]["name"])
|
||||||
.use(require('weblit/auto-headers'))
|
server.startplugin();
|
||||||
.use(require('weblit/etag-cache'))
|
end
|
||||||
|
end
|
||||||
.route({
|
end
|
||||||
method = "GET",
|
|
||||||
path = "/",
|
|
||||||
}, function (req, res, go)
|
|
||||||
res.code = 200
|
|
||||||
res.headers["Content-Type"] = "text/html"
|
|
||||||
res.body = "<h1>Hello!</h1>\n"
|
|
||||||
end)
|
|
||||||
|
|
||||||
.start()
|
|
||||||
|
|
||||||
|
8
plugins/coro-channel/plugin.json
Normal file
8
plugins/coro-channel/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "coro-channel",
|
||||||
|
"version": "1.2.0",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/coro-fs/plugin.json
Normal file
8
plugins/coro-fs/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "coro-fs",
|
||||||
|
"version": "1.3.0",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/coro-http/plugin.json
Normal file
8
plugins/coro-http/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "coro-http",
|
||||||
|
"version": "1.2.1-1",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/coro-net/plugin.json
Normal file
8
plugins/coro-net/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "coro-net",
|
||||||
|
"version": "1.1.1-1",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/coro-tls/plugin.json
Normal file
8
plugins/coro-tls/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "coro-tls",
|
||||||
|
"version": "1.2.1",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/coro-wrapper/plugin.json
Normal file
8
plugins/coro-wrapper/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "coro-wrapper",
|
||||||
|
"version": "1.0.0-1",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
20
plugins/dummy/init.lua
Normal file
20
plugins/dummy/init.lua
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
local exports = {}
|
||||||
|
exports.name = "dummy"
|
||||||
|
exports.version = "0.0.1"
|
||||||
|
exports.description = "A dummy example"
|
||||||
|
exports.license = "MIT"
|
||||||
|
exports.author = { name = "Miodrag Milanovic" }
|
||||||
|
|
||||||
|
local dummy = exports
|
||||||
|
|
||||||
|
function dummy.startplugin()
|
||||||
|
emu.register_start(function()
|
||||||
|
print("Starting " .. emu.gamename())
|
||||||
|
end)
|
||||||
|
|
||||||
|
emu.register_stop(function()
|
||||||
|
print("Exiting " .. emu.gamename())
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
return exports
|
9
plugins/dummy/plugin.json
Normal file
9
plugins/dummy/plugin.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "dummy",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"author": "Miodrag Milanovic",
|
||||||
|
"type": "plugin",
|
||||||
|
"start": "false",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/http-codec/plugin.json
Normal file
8
plugins/http-codec/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "http-codec",
|
||||||
|
"version": "1.0.0-1",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/json/plugin.json
Normal file
8
plugins/json/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "json",
|
||||||
|
"version": "2.5.0",
|
||||||
|
"author": "David Kolf",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/mime/plugin.json
Normal file
8
plugins/mime/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "mime",
|
||||||
|
"version": "0.1.2-1",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/path/plugin.json
Normal file
8
plugins/path/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "path",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/pretty-print/plugin.json
Normal file
8
plugins/pretty-print/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "pretty-print",
|
||||||
|
"version": "1.0.3",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/querystring/plugin.json
Normal file
8
plugins/querystring/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "querystring",
|
||||||
|
"version": "1.0.2",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/weblit/plugin.json
Normal file
8
plugins/weblit/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "weblit",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
34
plugins/webserver/init.lua
Normal file
34
plugins/webserver/init.lua
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
local exports = {}
|
||||||
|
exports.name = "webserver"
|
||||||
|
exports.version = "1.0.0"
|
||||||
|
exports.description = "A simple web server"
|
||||||
|
exports.license = "MIT"
|
||||||
|
exports.author = { name = "Miodrag Milanovic" }
|
||||||
|
|
||||||
|
local ws = exports
|
||||||
|
|
||||||
|
local app = require('weblit/app')
|
||||||
|
|
||||||
|
function ws.startplugin()
|
||||||
|
app.bind({
|
||||||
|
host = "0.0.0.0",
|
||||||
|
port = 8080
|
||||||
|
})
|
||||||
|
|
||||||
|
app.use(require('weblit/logger'))
|
||||||
|
app.use(require('weblit/auto-headers'))
|
||||||
|
app.use(require('weblit/etag-cache'))
|
||||||
|
|
||||||
|
app.route({
|
||||||
|
method = "GET",
|
||||||
|
path = "/",
|
||||||
|
}, function (req, res, go)
|
||||||
|
res.code = 200
|
||||||
|
res.headers["Content-Type"] = "text/html"
|
||||||
|
res.body = "<h1>Hello!</h1>\n"
|
||||||
|
end)
|
||||||
|
|
||||||
|
app.start()
|
||||||
|
end
|
||||||
|
|
||||||
|
return exports
|
9
plugins/webserver/plugin.json
Normal file
9
plugins/webserver/plugin.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "webserver",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": "Miodrag Milanovic",
|
||||||
|
"type": "plugin",
|
||||||
|
"start": "false",
|
||||||
|
}
|
||||||
|
}
|
8
plugins/websocket-codec/plugin.json
Normal file
8
plugins/websocket-codec/plugin.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"plugin": {
|
||||||
|
"name": "websocket-codec",
|
||||||
|
"version": "1.0.7",
|
||||||
|
"author": "Tim Caswell",
|
||||||
|
"type": "library",
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user