summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/boot.lua
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/boot.lua
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/boot.lua')
-rw-r--r--plugins/boot.lua38
1 files changed, 18 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