summaryrefslogtreecommitdiffstatshomepage
path: root/plugins
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-02-14 19:48:44 +0100
committer Miodrag Milanovic <mmicko@gmail.com>2016-02-14 19:48:44 +0100
commit686ba42466ca46f9e49f13d45ae9a225aa2dbe51 (patch)
tree209ff8b5e73b3ffe44c05cc73cd764c8768b9e0a /plugins
parent5a31d8513b9bc63637aa50bffb59d4ce1c246029 (diff)
Added plugin info json files and made system automatically load available plugins and start them if flagged so (nw)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/boot.lua38
-rw-r--r--plugins/coro-channel/plugin.json8
-rw-r--r--plugins/coro-fs/plugin.json8
-rw-r--r--plugins/coro-http/plugin.json8
-rw-r--r--plugins/coro-net/plugin.json8
-rw-r--r--plugins/coro-tls/plugin.json8
-rw-r--r--plugins/coro-wrapper/plugin.json8
-rw-r--r--plugins/dummy/init.lua20
-rw-r--r--plugins/dummy/plugin.json9
-rw-r--r--plugins/http-codec/plugin.json8
-rw-r--r--plugins/json/plugin.json8
-rw-r--r--plugins/mime/plugin.json8
-rw-r--r--plugins/path/plugin.json8
-rw-r--r--plugins/pretty-print/plugin.json8
-rw-r--r--plugins/querystring/plugin.json8
-rw-r--r--plugins/weblit/plugin.json8
-rw-r--r--plugins/webserver/init.lua34
-rw-r--r--plugins/webserver/plugin.json9
-rw-r--r--plugins/websocket-codec/plugin.json8
19 files changed, 202 insertions, 20 deletions
diff --git a/plugins/boot.lua b/plugins/boot.lua
index e6cdde58004..4f8c6a0ee96 100644
--- a/plugins/boot.lua
+++ b/plugins/boot.lua
@@ -1,26 +1,24 @@
+require('lfs')
local uv = require('luv')
local cwd = uv.cwd()
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({
- host = "0.0.0.0",
- port = 8080
- })
-
- .use(require('weblit/logger'))
- .use(require('weblit/auto-headers'))
- .use(require('weblit/etag-cache'))
-
- .route({
- method = "GET",
- path = "/",
- }, function (req, res, go)
- res.code = 200
- res.headers["Content-Type"] = "text/html"
- res.body = "<h1>Hello!</h1>\n"
- end)
-
- .start()
+for file in lfs.dir("plugins") do
+ if (file~="." and file~=".." and lfs.attributes("plugins/" .. file,"mode")=="directory") then
+ local filename = "plugins/" .. file .. "/plugin.json"
+ local meta = json.parse(readAll(filename))
+ if (meta["plugin"]["type"]=="plugin") and (meta["plugin"]["start"]=="true") then
+ server = require(meta["plugin"]["name"])
+ server.startplugin();
+ end
+ end
+end
diff --git a/plugins/coro-channel/plugin.json b/plugins/coro-channel/plugin.json
new file mode 100644
index 00000000000..5a3f5af8813
--- /dev/null
+++ b/plugins/coro-channel/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "coro-channel",
+ "version": "1.2.0",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/coro-fs/plugin.json b/plugins/coro-fs/plugin.json
new file mode 100644
index 00000000000..c35d9e27315
--- /dev/null
+++ b/plugins/coro-fs/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "coro-fs",
+ "version": "1.3.0",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/coro-http/plugin.json b/plugins/coro-http/plugin.json
new file mode 100644
index 00000000000..0c8047c9ebe
--- /dev/null
+++ b/plugins/coro-http/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "coro-http",
+ "version": "1.2.1-1",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/coro-net/plugin.json b/plugins/coro-net/plugin.json
new file mode 100644
index 00000000000..cf839aad881
--- /dev/null
+++ b/plugins/coro-net/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "coro-net",
+ "version": "1.1.1-1",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/coro-tls/plugin.json b/plugins/coro-tls/plugin.json
new file mode 100644
index 00000000000..257224e2ea3
--- /dev/null
+++ b/plugins/coro-tls/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "coro-tls",
+ "version": "1.2.1",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/coro-wrapper/plugin.json b/plugins/coro-wrapper/plugin.json
new file mode 100644
index 00000000000..6075edba1fa
--- /dev/null
+++ b/plugins/coro-wrapper/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "coro-wrapper",
+ "version": "1.0.0-1",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/dummy/init.lua b/plugins/dummy/init.lua
new file mode 100644
index 00000000000..8c4fbe6a0f5
--- /dev/null
+++ b/plugins/dummy/init.lua
@@ -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
diff --git a/plugins/dummy/plugin.json b/plugins/dummy/plugin.json
new file mode 100644
index 00000000000..4d877fa4dfa
--- /dev/null
+++ b/plugins/dummy/plugin.json
@@ -0,0 +1,9 @@
+{
+ "plugin": {
+ "name": "dummy",
+ "version": "0.0.1",
+ "author": "Miodrag Milanovic",
+ "type": "plugin",
+ "start": "false",
+ }
+} \ No newline at end of file
diff --git a/plugins/http-codec/plugin.json b/plugins/http-codec/plugin.json
new file mode 100644
index 00000000000..ce511afa785
--- /dev/null
+++ b/plugins/http-codec/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "http-codec",
+ "version": "1.0.0-1",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/json/plugin.json b/plugins/json/plugin.json
new file mode 100644
index 00000000000..c5a0c77355d
--- /dev/null
+++ b/plugins/json/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "json",
+ "version": "2.5.0",
+ "author": "David Kolf",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/mime/plugin.json b/plugins/mime/plugin.json
new file mode 100644
index 00000000000..ee55fd559b3
--- /dev/null
+++ b/plugins/mime/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "mime",
+ "version": "0.1.2-1",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/path/plugin.json b/plugins/path/plugin.json
new file mode 100644
index 00000000000..c88de67d77c
--- /dev/null
+++ b/plugins/path/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "path",
+ "version": "1.0.0",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/pretty-print/plugin.json b/plugins/pretty-print/plugin.json
new file mode 100644
index 00000000000..556608c8dd6
--- /dev/null
+++ b/plugins/pretty-print/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "pretty-print",
+ "version": "1.0.3",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/querystring/plugin.json b/plugins/querystring/plugin.json
new file mode 100644
index 00000000000..ddd3cc4291e
--- /dev/null
+++ b/plugins/querystring/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "querystring",
+ "version": "1.0.2",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/weblit/plugin.json b/plugins/weblit/plugin.json
new file mode 100644
index 00000000000..69dd45ccc0e
--- /dev/null
+++ b/plugins/weblit/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "weblit",
+ "version": "1.0.0",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file
diff --git a/plugins/webserver/init.lua b/plugins/webserver/init.lua
new file mode 100644
index 00000000000..3d68b01e6d5
--- /dev/null
+++ b/plugins/webserver/init.lua
@@ -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
diff --git a/plugins/webserver/plugin.json b/plugins/webserver/plugin.json
new file mode 100644
index 00000000000..e420a5d5485
--- /dev/null
+++ b/plugins/webserver/plugin.json
@@ -0,0 +1,9 @@
+{
+ "plugin": {
+ "name": "webserver",
+ "version": "1.0.0",
+ "author": "Miodrag Milanovic",
+ "type": "plugin",
+ "start": "false",
+ }
+} \ No newline at end of file
diff --git a/plugins/websocket-codec/plugin.json b/plugins/websocket-codec/plugin.json
new file mode 100644
index 00000000000..00a49dbcba3
--- /dev/null
+++ b/plugins/websocket-codec/plugin.json
@@ -0,0 +1,8 @@
+{
+ "plugin": {
+ "name": "websocket-codec",
+ "version": "1.0.7",
+ "author": "Tim Caswell",
+ "type": "library",
+ }
+} \ No newline at end of file