bugfix: static site generator

This commit is contained in:
Leon van Kammen 2026-10-15 18:50:08 +02:00
parent dde10e9de2
commit 7dfb0bd2a7
9 changed files with 44 additions and 16 deletions

View file

@ -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.
</div>
<div class="p" id="radical">
## Radical opensource
```
@ -116,11 +117,12 @@ Archive: result/bin/xrforge.com
## Adding content
First you need a directory with glTF or JanusXR experiences.<br>
Just run this in the terminal:
First you need a directory with glTF or (JanusXR) JML experiences.<br>
Luckily, running the server (`./xrforge.com server`) once will produce example-folder `myverse`.<br>
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.
</div>
<div class="addcontent">

View file

@ -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()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 125 KiB

View file

@ -1 +0,0 @@
../tronverse.png

View file

@ -1 +0,0 @@
../janusxr

View file

@ -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

View file

@ -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

View file

@ -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)