diff --git a/.gitignore b/.gitignore
index 3377cf3..42e3f2e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ experienceB
result
src/v
janusweb*
+myverse
diff --git a/run.sh b/run.sh
index ec69ec6..c44e742 100755
--- a/run.sh
+++ b/run.sh
@@ -1,4 +1,4 @@
#!/bin/sh
source ./.env
rebuild
-result/bin/xrforge.com server
+result/bin/xrforge.com "$@"
diff --git a/src/.init.lua b/src/.init.lua
index eb7c431..26de663 100644
--- a/src/.init.lua
+++ b/src/.init.lua
@@ -88,7 +88,7 @@ app --
app.on('init', function()
if assert(unix.fork()) == 0 then
- app.plugin.diskscan.scan()
+ app.plugin.diskscan.scan(app.opts.plugin_diskscan_dir)
print_r(app.cache)
--os.execute("ls ; sleep 5")
print("ok")
diff --git a/src/.lua/config.lua b/src/.lua/config.lua
index 12a8140..a643a7f 100644
--- a/src/.lua/config.lua
+++ b/src/.lua/config.lua
@@ -6,7 +6,7 @@ return function(app)
name = "XRForge",
baseurl="/",
title="Your XR Forge",
- subtitle="Portable XR experiences for Phone, VRheadset & desktop.",
+ subtitle="Local-first XR experiences for Phone, VRheadset & desktop.",
admin_title = "XRForge Admin",
admin_subtitle = "Manage your XR experiences here",
}
diff --git a/src/cmd/help.lua b/src/cmd/help.lua
index be36d37..1f3076a 100644
--- a/src/cmd/help.lua
+++ b/src/cmd/help.lua
@@ -3,11 +3,13 @@ return function(app,argv)
io.write( app.bin .. " " .. k .. "\t\t # " .. v.info .. "\n")
end)
io.write("\nexample: " .. app.bin .. " title='My XRForge experiences'\n\n")
- io.write("Flags: (overrides xrforge.lua configfile)\n\n")
+ io.write("example content: unzip result/bin/xrforge.com myverse/*\n\n")
+ io.write("Flags:\n\n")
foreach( app.opts, function(k,v)
if not k:match("/") and not k:match("^help") and not k:match("updated") then
io.write( " " .. k .. "='" .. v .. "'\n")
end
end)
+ io.write("\n> NOTE: flags override flags in xrforge.lua configfile]\n")
os.exit()
end
diff --git a/src/myverse/janusxr/helloworld/janusxr.xml b/src/myverse/janusxr/helloworld/janusxr.xml
new file mode 100644
index 0000000..ee70229
--- /dev/null
+++ b/src/myverse/janusxr/helloworld/janusxr.xml
@@ -0,0 +1,6 @@
+
world 1 title
+
+
+
+
+
diff --git a/src/myverse/janusxr/janusxr.png b/src/myverse/janusxr/janusxr.png
new file mode 100644
index 0000000..b5d61fa
Binary files /dev/null and b/src/myverse/janusxr/janusxr.png differ
diff --git a/src/myverse/janusxr/tronverse b/src/myverse/janusxr/tronverse
new file mode 120000
index 0000000..ca678ec
--- /dev/null
+++ b/src/myverse/janusxr/tronverse
@@ -0,0 +1 @@
+../tronverse
\ No newline at end of file
diff --git a/src/myverse/tronverse/janusxr b/src/myverse/tronverse/janusxr
new file mode 120000
index 0000000..aa06852
--- /dev/null
+++ b/src/myverse/tronverse/janusxr
@@ -0,0 +1 @@
+../janusxr
\ No newline at end of file
diff --git a/src/myverse/tronverse/tron/tron.glb b/src/myverse/tronverse/tron/tron.glb
new file mode 100644
index 0000000..d60f133
Binary files /dev/null and b/src/myverse/tronverse/tron/tron.glb differ
diff --git a/src/myverse/tronverse/tron/tron.mp3 b/src/myverse/tronverse/tron/tron.mp3
new file mode 100644
index 0000000..4f86a03
Binary files /dev/null and b/src/myverse/tronverse/tron/tron.mp3 differ
diff --git a/src/myverse/tronverse/tron/tron.png b/src/myverse/tronverse/tron/tron.png
new file mode 100644
index 0000000..7ee07cc
Binary files /dev/null and b/src/myverse/tronverse/tron/tron.png differ
diff --git a/src/myverse/tronverse/tronverse.png b/src/myverse/tronverse/tronverse.png
new file mode 100644
index 0000000..249e441
Binary files /dev/null and b/src/myverse/tronverse/tronverse.png differ
diff --git a/src/plugin/diskscan.lua b/src/plugin/diskscan.lua
index 6999769..164548a 100644
--- a/src/plugin/diskscan.lua
+++ b/src/plugin/diskscan.lua
@@ -9,45 +9,51 @@ return {
key='app.opts.plugin_diskscan_dir',
title='Directory',
info="Directory to scan for experiences (use '.' for current) ",
- default=".",
+ default="./myverse",
values=''
}
},
shouldHideFile = function(name)
- return name == ".."
+ return name == ".." -- parent
or name == "util" -- repository
- or name == ".git" -- files
- or name == "src" --
- or name == "result" --
+ or name:match("^%.") -- hidden
+ or name == "src" -- repository
+ or name == "result" -- repository
end,
- scan = function()
+ scan = function(scandir,parent,seen)
+ seen = seen or {}
local me = app.plugin.diskscan
- local folder = app.opts.plugin_diskscan_dir
-- scan dirs
- local dref, derr= dir.foreach( folder, function(path,stat,state,name,kind,ino,off,attr,fullpath)
- if (kind == unix.DT_DIR or kind == unix.DT_LNK) and not me.shouldHideFile(name) then
- local experience = {
- path = fullpath,
- name = name,
- title = name,
- tag = {},
- file = {stat=stat,state=state,kind=kind,ino=ino,off=off,attr=attr,fullpath=fullpath,name=name,path=path}
- }
- app.pub("scan_experience", nil, experience)
- print("ℹ️ ".. fullpath)
+ local dref, derr = dir.foreach( scandir, function(path,stat,state,name,kind,ino,off,attr,fullpath)
- -- scan files
- local fref, ferr = dir.foreach(fullpath, function(path,stat,state,name,kind,ino,off,attr, fullpath)
- if kind ~= unix.DT_DIR and not me.shouldHideFile(name) then
- experience.file = {stat=stat,state=state,kind=kind,ino=ino,off=off,attr=attr,fullpath=fullpath,name=name,path=path}
- app.pub("scan_experience_file", nil, experience)
- local size = attr:size()
- trace("ℹ️ ".. fullpath)
- end
- end)
- if not ferr then fref:close() end
+ local experience = {
+ path = fullpath,
+ name = name,
+ title = name,
+ tag = {},
+ file = {stat=stat,state=state,kind=kind,ino=ino,off=off,attr=attr,fullpath=fullpath,name=name,path=path}
+ }
+
+ -- found directory
+ if not seen[ino] and (kind == unix.DT_DIR or kind == unix.DT_LNK)
+ and not me.shouldHideFile(name) then
+ seen[ino] = true -- prevent recursion with symlinks
+ print("✅ ".. fullpath)
+ app.pub("scan_experience", nil, experience)
+ table.insert( app.cache.items, experience)
+ me.scan(fullpath, dir,seen)
end
+
+ ---- found file
+ if not seen[ino] and (kind ~= unix.DT_DIR and kind ~= unix.DT_LNK)
+ and not me.shouldHideFile(name) then
+ seen[ino] = true -- prevent recursion with symlinks
+ print("ℹ️ ".. fullpath)
+ app.pub("scan_experience_file", nil, experience)
+ local size = attr:size()
+ end
+
end)
if not derr then dref:close() end
diff --git a/src/plugin/janusxr.lua b/src/plugin/janusxr.lua
index 4bad0bf..5400501 100644
--- a/src/plugin/janusxr.lua
+++ b/src/plugin/janusxr.lua
@@ -4,27 +4,27 @@ local pattern_fireboxroom = "[Ff][Ii][Rr][Ee][Bb][Oo][Xx][Rr][Oo][Oo][Mm][ ]?.*>
local pattern_title = "<[Tt][Ii][Tt][Ll][Ee]>(.*)<"
app.on('scan_experience', function(exp)
+ print("dir: "..exp.file.fullpath)
--print_r(exp)
end)
app.on('scan_experience_file', function(exp)
local size = exp.file.attr:size()
- if exp.file.name:match(".glb") and not util.contains(exp.tag,"xrfragment") then
- print("✅ └─ plugin/janusxr: generating janusxr.xml")
- table.insert(exp.tag, "janusxr")
- app.pub("scan_experience_janusxr", nil, {exp=exp, item=item}) -- be nice to other plugins
- table.insert( app.cache.items, exp)
- elseif size < 1000 then -- skip large binary files
+ if size < 1000 then -- skip large binary files
local data = util.readfile( exp.file.fullpath)
- if data:match(pattern_fireboxroom) then
- table.insert(exp.tag, "janusxr")
- local title = data:match(pattern_title)
- if title then
- exp.title = title:gsub("<.*","")
+ if data then
+ if data:match(pattern_fireboxroom) then
+ table.insert(exp.tag, "janusxr")
+ local title = data:match(pattern_title)
+ if title then
+ exp.title = title:gsub("<.*","")
+ end
+ app.pub("scan_experience_janusxr", nil, {exp=exp, item=item}) -- be nice to other plugins
+ table.insert( app.cache.items, exp)
+ print("✅ └─ plugin/janusxr: " .. exp.file.name)
end
- app.pub("scan_experience_janusxr", nil, {exp=exp, item=item}) -- be nice to other plugins
- table.insert( app.cache.items, exp)
- print("✅ └─ plugin/janusxr: " .. exp.file.name)
+ else
+ -- symlink to directory
end
end
end)
diff --git a/src/test/env/demofiles.sh b/src/test/env/demofiles.sh
new file mode 100755
index 0000000..f5f81f5
--- /dev/null
+++ b/src/test/env/demofiles.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+cleanup(){
+ rm -rf world{1,2,3,4} 2>/dev/null || true
+}
+
+create(){
+ mkdir world1 ;
+ mkdir world2 ;
+ ln -s /tmp world3 ;
+ ln -fs nonexisting world4 ;
+}
+
+"$@"
diff --git a/src/test/main.lua b/src/test/main.lua
index 89a2c9a..721debc 100644
--- a/src/test/main.lua
+++ b/src/test/main.lua
@@ -2,22 +2,7 @@ local lust = require 'test/lust'
local describe, it, expect = lust.describe, lust.it, lust.expect
-- usage: https://github.com/bjornbytes/lust
-describe('my project', function()
- lust.before(function()
- -- This gets run before every test.
- end)
-
- describe('ℹ️ app vars', function() -- Can be nested
- it('bindir', function()
- print(app.bindir)
- expect(app.bindir).to.fail('xrforge.com') -- Pass
- end)
-
- it('feature2', function()
- expect(nil).to.exist() -- Fail
- end)
- end)
-end)
+require('test/plugin_diskscan')(lust)
if lust.errors == 0 then
print("✅ all tests passed")
diff --git a/src/test/plugin_diskscan.lua b/src/test/plugin_diskscan.lua
new file mode 100755
index 0000000..5a0b6f1
--- /dev/null
+++ b/src/test/plugin_diskscan.lua
@@ -0,0 +1,24 @@
+return function(lust)
+
+
+ local describe, it, expect = lust.describe, lust.it, lust.expect
+
+ describe('src/plugin/diskscan.lua', function()
+
+ lust.before(function() os.execute('test/env/demofiles.sh create') end)
+ lust.after(function() os.execute('test/env/demofiles.sh cleanup') end)
+
+ describe('ℹ️ app vars', function() -- Can be nested
+ it('bindir', function()
+ print(app.bindir)
+ expect(app.bindir).to.fail('xrforge.com') -- Pass
+ end)
+
+ it('feature2', function()
+ expect(nil).to.exist() -- Fail
+ end)
+ end)
+
+ end)
+
+end
diff --git a/util/xrforge.sh b/util/xrforge.sh
index 9d217a7..0d3d17b 100755
--- a/util/xrforge.sh
+++ b/util/xrforge.sh
@@ -35,12 +35,12 @@ build(){
download redbean
download janusweb
cd src
- zip -r ../result/bin/xrforge.com * .lua .init.lua .args
+ zip -yr ../result/bin/xrforge.com * .lua .init.lua .args
}
rebuild(){
cd src
- zip -r ../result/bin/xrforge.com .lua page plugin cmd css .init.lua .args
+ zip -yr ../result/bin/xrforge.com .lua page plugin cmd css .init.lua .args test myverse
}
"$@"