diff --git a/src/page/dir.lua b/src/page/dir.lua index 052e417..9c5d30e 100644 --- a/src/page/dir.lua +++ b/src/page/dir.lua @@ -74,7 +74,9 @@ return { res.template = 'page/index.html' end app.pub("dir", nil, {res=res,data=data, urlpath=urlpath, isdir=isdir}) - app.cache.url[ urlpath ] = util.templateFile( res.template, data) + if not redirect then + app.cache.url[ urlpath ] = util.templateFile( res.template, data) + end end if redirect then print("REDIRECT! " .. redirect ) diff --git a/src/page/janusxr.html b/src/page/janusxr.html index 271d2ae..5cc6deb 100644 --- a/src/page/janusxr.html +++ b/src/page/janusxr.html @@ -45,6 +45,7 @@ local center = -((#items*width)/1.3) + (i*width) local url = v.url if v.dir then url = url .. "/" end + if v.redirect then url = v.redirect end -- dont wrap standalone glb's in janusxr addPortal('dir',center, v, url,i, -4, 'img', '0 0 0', '0.2 0.2 0.2') end end} diff --git a/src/plugin/xrfragments.lua b/src/plugin/xrfragments.lua index f3860d9..bebc82c 100644 --- a/src/plugin/xrfragments.lua +++ b/src/plugin/xrfragments.lua @@ -3,13 +3,16 @@ local json = require('json') app.on('init', function() end) +app.on('dir', function(opts) +end) + app.on('scan_experience_file', function(exp) local me = app.plugin.xrfragments foreach( util.split( app.opts.plugin_xrfragments_filetypes, ' '), function(k,ext) if exp.path:lower():match("."..ext.."$") then + exp.view3D = true local hasHref = false if ext == 'glb' then - exp.view3D = true -- detect XR Fragment exp https://xrfragment.org/#%F0%9F%93%9C%20level0%3A%20File local tree = me.extract_glb_json( util.stripPath(exp.path) ) hasHref = me.detectHrefInStruct(tree) @@ -32,10 +35,13 @@ app.on('scan_experience_file', function(exp) if util.fileExist( jsonfile ) then exp.sidecarfile.JSONXRF = me.detectHrefInStruct( json.decode( util.readfile(jsonfile) ) ) end - exp.tag.xrfragments = hasHref or hasPNG or hasWebVTT or hasOGG or hasJSONref - if exp.tag.xrfragments then + exp.tag.xrfragments = { qualify = hasHref or hasPNG or hasWebVTT or hasOGG or hasJSONref, href = hasHref } + if exp.tag.xrfragments.qualify then print("✅ └─ plugin/xrfragments: detected xrfragments experience") end + if exp.tag.xrfragments.href then + exp.parent.redirect = exp.url -- mark parent to redirect to this standalone url instead + end foreach(exp.sidecarfile, function(ext,v) print("✅ └─ plugin/xrfragments: detected .".. ext:lower() .. " sidecarfile") end)