diff --git a/README.md b/README.md index 8dc97de..364bb5f 100644 --- a/README.md +++ b/README.md @@ -84,16 +84,17 @@ You can override the default content (embedded in the executable). Extract and run example 3D content in your browser: ```bash -$ unzip xrforge.com myverse/* # extract example 3D verse files $ ./xrforge.com server # run as server +ℹ️ unzipping example content to folder 'myverse' opening your browser at https://localhost:8080 ``` -> just look around in `myverse` and get a hunch of how directories + sidecarfiles are used to manage content. +> Play around in the browser, and launch a file-explorer with directory `myverse`, and see how directories, sidecarfiles and symlinks are used to manage interconnected virtual worlds.
+ ## Radical opensource ``` @@ -116,11 +117,12 @@ Archive: result/bin/xrforge.com ## Adding content -First you need a directory with glTF or JanusXR experiences.
-Just run this in the terminal: +First you need a directory with glTF or (JanusXR) JML experiences.
+Luckily, running the server (`./xrforge.com server`) once will produce example-folder `myverse`.
+Then run this in the terminal: ```bash -$ unzip xrforge.com myverse +$ unzip xrforge.com myverse/* # optional: unzip example-content manually $ tree myverse myverse ├── janusxr @@ -138,7 +140,7 @@ myverse └── tronverse.png ``` -> optionally you can run `./xrforge.com admin` and change the `myverse` directory if needed. +> optionally you can run `./xrforge.com admin` and change default directoryname (`myverse`) if needed.
diff --git a/src/.lua/util.lua b/src/.lua/util.lua index 7e71469..30335cd 100644 --- a/src/.lua/util.lua +++ b/src/.lua/util.lua @@ -13,7 +13,7 @@ end util.readfile = function(filename, mode, silent) local file, err = io.open(filename, mode or "r") if not file then - if not silent then print("Error opening file:", err) end + if not silent then print("Error opening file:", filename, err) end return end local content = file:read("*a") @@ -24,7 +24,7 @@ end util.writefile = function(filename, content, mode) local file, err = io.open(filename, mode or "w") -- Default write mode if not file then - return print("Error opening file:", err) + return print("Error opening file:", filename, err) end file:write(content) file:close() diff --git a/src/img/mastodon.jpg b/src/img/mastodon.jpg index 9a83167..71937a3 100644 Binary files a/src/img/mastodon.jpg and b/src/img/mastodon.jpg differ diff --git a/src/myverse/tech-demos.jpg b/src/myverse/tech-demos.jpg index 78649bf..4b13b69 100644 Binary files a/src/myverse/tech-demos.jpg and b/src/myverse/tech-demos.jpg differ diff --git a/src/myverse/tech-demos/janusxr_tutorial/tronverse.png b/src/myverse/tech-demos/janusxr_tutorial/tronverse.png deleted file mode 120000 index c031b92..0000000 --- a/src/myverse/tech-demos/janusxr_tutorial/tronverse.png +++ /dev/null @@ -1 +0,0 @@ -../tronverse.png \ No newline at end of file diff --git a/src/myverse/tech-demos/tronverse/janusxr b/src/myverse/tech-demos/tronverse/janusxr deleted file mode 120000 index aa06852..0000000 --- a/src/myverse/tech-demos/tronverse/janusxr +++ /dev/null @@ -1 +0,0 @@ -../janusxr \ No newline at end of file diff --git a/src/page/dir.html b/src/page/dir.html index 6219169..f8d9a9f 100644 --- a/src/page/dir.html +++ b/src/page/dir.html @@ -59,10 +59,19 @@ end} {if items then function getURL(url, item) - if app.arg[1] == 'generate' or url:match("://") then - url = '?view=3D#janus.url=' .. EscapeFragment( url ) + item = item or {} + local playable = item.view3D + or (item.janusxr and item.janusxr.room) + or (item.redirect) + if app.arg[1] == 'generate' then + if playable or url:match("://") then + url = 'janusweb/#janus.url=' .. EscapeFragment( url ) + end url = util.baseURLify(url) else + if url:match("://") then + url = '?view=3D#janus.url=' .. EscapeFragment( url ) + end url = util.stripPath( url ) end return url diff --git a/src/plugin/diskscan.lua b/src/plugin/diskscan.lua index b4a6727..cae73a9 100644 --- a/src/plugin/diskscan.lua +++ b/src/plugin/diskscan.lua @@ -12,8 +12,13 @@ app.on('init', function() end else if not util.fileExist(app.opts.plugin_diskscan_dir) then - print("ℹ️ serving " .. app.opts.plugin_diskscan_dir .. " from internal (executable)") - app.opts.plugin_diskscan_dir = '/zip/' .. util.stripPath(app.opts.plugin_diskscan_dir) + if app.opts.plugin_diskscan_dirname == 'myverse' and util.cmdExist("unzip") then + print("ℹ️ unzipping example content to folder 'myverse'") + os.execute("unzip " .. argv[-1] .. ' "myverse/*"') + else + print("ℹ️ serving " .. app.opts.plugin_diskscan_dir .. " from internal (executable)") + app.opts.plugin_diskscan_dir = '/zip/' .. util.stripPath(app.opts.plugin_diskscan_dir) + end app.set('app.opts', app.opts) end end diff --git a/src/plugin/staticwebgen.lua b/src/plugin/staticwebgen.lua index 40eb576..e2b6c70 100644 --- a/src/plugin/staticwebgen.lua +++ b/src/plugin/staticwebgen.lua @@ -71,10 +71,13 @@ local plugin = { print("[!] folder 'www' was already detected..please delete it") os.exit() end - local selfbinary = '../' .. argv[-1] + local selfbinary = argv[-1] os.execute("mkdir www www/about") + print("cp -Lr " .. app.opts.plugin_diskscan_dir .. " " .. outdir .. "/.") os.execute("cp -Lr " .. app.opts.plugin_diskscan_dir .. " " .. outdir .. "/.") + print("cd " .. outdir .. " && unzip " .. selfbinary .. " 'img/*' 'css/*' 'janusweb/*' 'shader/*'") os.execute("cd " .. outdir .. " && unzip " .. selfbinary .. " 'img/*' 'css/*' 'janusweb/*' 'shader/*'") + foreach( app.cache.items, function(k,v) if v.dir then table.insert(urls, v.url .. ".rss" ) @@ -90,7 +93,18 @@ local plugin = { app.on('response', function(opts) local body = opts.res._body -- capture the output local url = opts.req.url:gsub("//","/") - util.writefile( outdir .. url .. '/index.html', body ) + local dir = url:gsub("/$","") + local isfile = url:match("%.[a-zA-Z0-9]+$") + if isfile then + dir = url:gsub("/[^/]+$", "") + end + print("mkdir -p " .. outdir .. dir ) + os.execute("mkdir -p " .. outdir .. dir) + if isfile then + util.writefile( outdir .. url, body ) + else + util.writefile( outdir .. url .. '/index.html', body ) + end end) foreach( urls, function(k,url)