diff --git a/run.sh b/run.sh
index 7fc7609..ec69ec6 100755
--- a/run.sh
+++ b/run.sh
@@ -1,2 +1,4 @@
#!/bin/sh
+source ./.env
+rebuild
result/bin/xrforge.com server
diff --git a/src/.init.lua b/src/.init.lua
index f53711b..fe476cd 100644
--- a/src/.init.lua
+++ b/src/.init.lua
@@ -23,20 +23,39 @@ app = require("soakbean") {
cmd={
help = {file="cmd/help.lua", info="display all possible flags"},
server = {file="cmd/server.lua", info="starts the webserver"},
- createplugin = {file="cmd/createplugin.lua", info="generates skeleton plugin"}
+ createplugin = {file="cmd/createplugin.lua", info="generates skeleton plugin"},
+ generate = {file="cmd/generate.lua", info="generate www-folder with XR experiences"}
}
}
-- api skeleton (implemented via soakbean's app.on(...))
app.set = function(k,v) end
app.init = function() end
-app.scan = require('scan').scan
-- load config
app.opts = require('config')(app)
--- load plugins
-app.plugin.janusxr = require('plugin/janusxr')
+-- load system plugins
+app.plugin.moderation = require('plugin/moderation')
+app.plugin.diskscan = require('plugin/diskscan')
+app.plugin.manyfold = require('plugin/manyfold')
+app.plugin.janusxr = require('plugin/janusxr')
+
+-- ensure plugin config-defaults
+foreach( app.plugin, function(name,plugin)
+ foreach( plugin.opts, function(k,opt)
+ local key = opt.key:gsub("app.opts.","")
+ if not app.opts[ key ] then
+ app.opts[ key ] = opt.default
+ end
+ end)
+end)
+
+-- set order preference (optional)
+app.plugin[1] = app.plugin.diskscan
+app.plugin[2] = app.plugin.moderation
+app.plugin[3] = app.plugin.janusxr
+app.plugin[4] = app.plugin.manyfold
app.runcmd(app) -- run clicmds
@@ -67,12 +86,13 @@ app --
.use( function(req,next) Route() end) -- fallback default redbean fileserver
app.on('init', function()
- if assert(unix.fork()) == 0 then
+ if assert(unix.fork()) == 0 then
+ app.plugin.diskscan.scan()
+ print_r(app.cache)
--os.execute("ls ; sleep 5")
- app.scan()
print("ok")
--local ok, headers, body = Fetch('http://127.0.0.1:8080/test')
- end
+ end
end)
function OnHttpRequest() app.run() end
diff --git a/src/.lua/config.lua b/src/.lua/config.lua
index 63c9f53..12a8140 100644
--- a/src/.lua/config.lua
+++ b/src/.lua/config.lua
@@ -5,17 +5,10 @@ return function(app)
local config = { -- default
name = "XRForge",
baseurl="/",
- title="My XRForge experiences",
+ title="Your XR Forge",
subtitle="Portable XR experiences for Phone, VRheadset & desktop.",
admin_title = "XRForge Admin",
admin_subtitle = "Manage your XR experiences here",
- disk_dir = ".",
- hide_keywords = "wip beta -v[0-9] customerX",
- manyfold_instance_1 = "https://xrforge.isvery.ninja",
- manyfold_instance_2 = "",
- manyfold_instance_3 = "",
- sync_interval = 30,
- sync_strategy = "recent"
}
local configfile = "xrforge.lua"
diff --git a/src/.lua/opendirectory.lua b/src/.lua/opendirectory.lua
index 4f121c2..30e0914 100644
--- a/src/.lua/opendirectory.lua
+++ b/src/.lua/opendirectory.lua
@@ -31,25 +31,25 @@ local dir = {}
dir.scan = function(path)
local stat = unix.stat(path)
- if stat == nil then
- return ServeError(404,"does not exist")
- else
- if not unix.S_ISDIR( stat:mode() ) then return false end -- let redbean take care of serving static file
- end
- state = assert(unix.opendir(path))
- return stat, state
+ if not stat or not unix.S_ISDIR( stat:mode() ) then
+ return nil,nil, "not a dir"
+ end -- let redbean take care of serving static file
+ state,err = assert(unix.opendir(path))
+ return stat, state, err
end
dir.foreach = function(path,cb)
- local stat, state = dir.scan(path)
- for name, kind, ino, off in state do
- if name == "." then goto continue end
- attr,err = unix.stat(path..'/'..name, unix.AT_SYMLINK_NOFOLLOW)
- if err then print("error: ".. name .. ": " ..err) end
- cb(path,stat,state,name,kind,ino,off,attr, path .. "/" ..name)
- ::continue::
+ local stat, state, err = dir.scan(path)
+ if not err then
+ for name, kind, ino, off in state do
+ if name == "." then goto continue end
+ attr,err = unix.stat(path..'/'..name, unix.AT_SYMLINK_NOFOLLOW)
+ if err then print("error: ".. name .. ": " ..err) end
+ cb(path,stat,state,name,kind,ino,off,attr, path .. "/" ..name)
+ ::continue::
+ end
end
- return state
+ return state,err
end
dir.serve = function(folder) -- raw redbean function (use dir.foreach in soakbean)
@@ -97,7 +97,11 @@ dir.serve = function(folder) -- raw redbean function (use dir.foreach in soakbea
Write('
ctim\r\n')
Write('
\r\n')
- local stat, state = dir.scan(path)
+ local stat, state, err = dir.scan(path)
+ if stat == nil then
+ return ServeError(404,"does not exist")
+ end
+
dir.foreach(path, function(path,stat,state,name,kind,ino,off,attr,fullpath)
Write('
\r\n')
Write('
')
diff --git a/src/.lua/page b/src/.lua/page
new file mode 120000
index 0000000..ee335c2
--- /dev/null
+++ b/src/.lua/page
@@ -0,0 +1 @@
+../page
\ No newline at end of file
diff --git a/src/cmd/createplugin.lua b/src/cmd/createplugin.lua
index f113546..5958989 100644
--- a/src/cmd/createplugin.lua
+++ b/src/cmd/createplugin.lua
@@ -3,7 +3,7 @@ return function(app,argv)
--
-- 1. put the code below in a file ('xrforge.myplugin.lua' e.g.)
--- 2. make sure to require it at the top of xrforge.lua (require('xrforge.myplugin') e.g.)
+-- 2. in xrforge.lua make sure to add (at the top): app.plugin.myplugin = require('xrforge.myplugin')
-- 3. profit!
--
@@ -38,7 +38,10 @@ local plugin = {
default="bar",
values=""
}
- }
+ },
+ myfunc = function()
+ -- call me via app.plugin.myplugin.myfunc()
+ end
}
return plugin
diff --git a/src/cmd/generate.lua b/src/cmd/generate.lua
new file mode 100644
index 0000000..4d694ea
--- /dev/null
+++ b/src/cmd/generate.lua
@@ -0,0 +1,4 @@
+return function(app,argv)
+ app.plugin.diskscan.scan()
+ os.exit()
+end
diff --git a/src/css/xrforge.css b/src/css/xrforge.css
index f49418a..6e8f249 100644
--- a/src/css/xrforge.css
+++ b/src/css/xrforge.css
@@ -184,14 +184,14 @@ ul{
.menu{
text-align: right;
}
+.menu,
+.menu *{
+ white-space: nowrap;
+}
.menu a {
padding-right:30px;
}
-.menu br {
- display:none
-}
-
.grid .tile{ border-radius:5px; }
.grid .tile .text{ padding:3px 0px; }
.grid .tile .img{
diff --git a/src/css/xrforge.max.css b/src/css/xrforge.max.css
index 8f177f5..264c348 100644
--- a/src/css/xrforge.max.css
+++ b/src/css/xrforge.max.css
@@ -33,9 +33,14 @@ body{
form table tr > td:nth-child(3) {
display:none;
}
- .menu br {
- display:initial !important;
+ .menu{
+ position:absolute;
+ right:20px;
}
+ .menu a{
+ padding-right:20px !important;
+ }
+ .menu a.xl{ display:none; }
}
.grid .tile .text{
diff --git a/src/page/admin/index.html b/src/page/admin/index.html
index 3f02bee..cb87fbd 100644
--- a/src/page/admin/index.html
+++ b/src/page/admin/index.html
@@ -10,145 +10,6 @@ ${notification}
]]
+ local value = app.opts[ opt.key:gsub("^app.opts.","") ]
if type(opt.values) == 'table' then
html = html .. util.template('