icosa.gallery can hotlink now + xrfragment sidecarfile fixes

This commit is contained in:
Leon van Kammen 2026-11-11 16:34:09 +01:00
parent cb7e6fe770
commit 067f64382b
6 changed files with 68 additions and 30 deletions

View file

@ -30,7 +30,10 @@ local apiSync = {
end end
end, true) end, true)
if synced > 0 then if synced > 0 then
app.cache.url = {} -- delete page cache -- we don't call reset() because that triggers our listener
app.cache.url = {}
app.cache.items = {}
app.cache.dirs = {}
app.plugin.diskscan.scan(app.opts.plugin_diskscan_dir) app.plugin.diskscan.scan(app.opts.plugin_diskscan_dir)
end end
return synced return synced

View file

@ -1,6 +1,6 @@
local util = { } local util = { }
util.fileExist = function(filename) util.fileExist = function(filename,mode)
local file, err = io.open(filename, mode or "r") local file, err = io.open(filename, mode or "r")
local exist = false local exist = false
if file then if file then

View file

@ -191,7 +191,12 @@ return {
-- check for directory thumbnail sidecarfile -- check for directory thumbnail sidecarfile
local thumbExt = {"png","jpg","webp"} local thumbExt = {"png","jpg","webp"}
foreach( thumbExt, function(k,ext) foreach( thumbExt, function(k,ext)
local files = { fullpath .. '.' .. ext, fullpath .. '/' .. name .. '.' .. ext } local files = {
fullpath .. '.' .. ext,
fullpath:gsub("%.[a-zA-Z][a-zA-Z][a-zA-Z]$","") .. '.' .. ext,
fullpath .. '/' .. name .. '.' .. ext,
fullpath .. '/' .. name:gsub("%..*","") .. '.' .. ext
}
foreach( files, function(kk,thumbnailFile) foreach( files, function(kk,thumbnailFile)
if util.fileExist( thumbnailFile ) then if util.fileExist( thumbnailFile ) then
experience.thumbnail = "/" .. util.stripPath(thumbnailFile) experience.thumbnail = "/" .. util.stripPath(thumbnailFile)

View file

@ -45,6 +45,7 @@ local sync_URL = app.opts_plugin_manyfold_sync_URL or ''
-- this registers the plugin UI -- this registers the plugin UI
local plugin = { local plugin = {
name = "ManyFold", name = "ManyFold",
hide = true, -- not finished
infowide = true, infowide = true,
info = [[ info = [[
<img src="img/manyfold.png" style="width:50%; max-width:233px; display:inline-block; float:left; margin-right:20px;"/> <img src="img/manyfold.png" style="width:50%; max-width:233px; display:inline-block; float:left; margin-right:20px;"/>

View file

@ -106,8 +106,8 @@ local plugin = {
key='app.opts.plugin_openbrush_sync_strategy', key='app.opts.plugin_openbrush_sync_strategy',
title='How to sync', title='How to sync',
info='download assets locally (prevent linkrot)', info='download assets locally (prevent linkrot)',
default = "mirror", default = "link",
values={mirror="mirror locally"} values={mirror="mirror locally",link="link to URLs"}
}, },
{ {
key='app.opts.plugin_openbrush_sync_when', key='app.opts.plugin_openbrush_sync_when',
@ -120,7 +120,7 @@ local plugin = {
key='app.opts.plugin_openbrush_sync_folder', key='app.opts.plugin_openbrush_sync_folder',
title='Sync to folder', title='Sync to folder',
info='openbrush (icosa.gallery) assets will be saved here', info='openbrush (icosa.gallery) assets will be saved here',
default = "./myverse/tech-demos/tronverse", default = "./myverse",
type = "dir", type = "dir",
values = {} -- populated by plugin/diskscan.lua values = {} -- populated by plugin/diskscan.lua
}, },
@ -280,7 +280,11 @@ local plugin = {
.. [[This virtual world is generated in realtime via <a href='https://icosa.gallery' target='_blank'>icosa.gallery</a>. .. [[This virtual world is generated in realtime via <a href='https://icosa.gallery' target='_blank'>icosa.gallery</a>.
You can add/create parcels in icosa.gallery, by publishing via <a href='https://openbrush.app'>OpenBrush</a>, <a href='https://openblocks.app'>OpenBlocks</a>, or <a href='https://blender.org' target='_blank'>Blender</a>.<br> You can add/create parcels in icosa.gallery, by publishing via <a href='https://openbrush.app'>OpenBrush</a>, <a href='https://openblocks.app'>OpenBlocks</a>, or <a href='https://blender.org' target='_blank'>Blender</a>.<br>
> NOTE: Make sure to add hashtag **]] .. tag .. [[** to the title (and re-run xrforge for fast re-sync). ]] > NOTE: Make sure to add hashtag **]] .. tag .. [[** to the title (and re-run xrforge for fast re-sync).
Press the 'Enter XR'-button above for the autogenerated world, or view the individual assets below:
]]
) )
end end
end, end,
@ -291,7 +295,8 @@ You can add/create parcels in icosa.gallery, by publishing via <a href='https://
local synced = 0 local synced = 0
foreach( t.assets, function(k,asset) foreach( t.assets, function(k,asset)
if type(asset) == 'table' then if type(asset) == 'table' then
local dirname = '_' .. asset.assetId .. '-' .. util.hyphenate( asset.displayName) local displayName = util.hyphenate( asset.displayName:gsub(" #.*","") )
local dirname = '_' .. asset.assetId
local dirnameFull = me.getFolder(tag) .. '/' .. dirname local dirnameFull = me.getFolder(tag) .. '/' .. dirname
local jsonfile = dirnameFull .. '/asset.json' local jsonfile = dirnameFull .. '/asset.json'
local README = me.getFolder(tag) .. '/README.md' local README = me.getFolder(tag) .. '/README.md'
@ -326,29 +331,52 @@ You can add/create parcels in icosa.gallery, by publishing via <a href='https://
sync = false -- already finished sync = false -- already finished
end end
end end
if sync then
print('✅ ' .. asset.displayName .. ' (syncing) #openbrush') if app.opts.plugin_openbrush_sync_strategy == "mirror" then
util.writefile( jsonfile, EncodeJson(asset) ) if sync then
local rootfile = dirnameFull .. '/' .. f.root.url:gsub(".*/","") print('✅ ' .. displayName .. ' (syncing) #openbrush #mirror')
local thumbnailfile = '' util.writefile( jsonfile, EncodeJson(asset) )
if asset.thumbnail and asset.thumbnail.url then local rootfile = dirnameFull .. '/' .. f.root.url:gsub(".*/","")
thumbnailfile = dirnameFull .. '.' .. asset.thumbnail.url:gsub(".*%.",'') local thumbnailfile = ''
print('🤞 fetch ' .. asset.thumbnail.url) if asset.thumbnail and asset.thumbnail.url then
os.execute('wget "' ..asset.thumbnail.url .. '" -O "' .. thumbnailfile .. '"') thumbnailfile = dirnameFull .. '.' .. asset.thumbnail.url:gsub(".*%.",'')
print('🤞 fetch ' .. asset.thumbnail.url)
os.execute('wget "' ..asset.thumbnail.url .. '" -O "' .. thumbnailfile .. '"')
end
print('🤞 fetch ' .. f.root.url)
os.execute('wget "' .. f.root.url .. '" -O "' .. rootfile .. '"')
if #f.resources > 0 then
foreach( f.resources, function(k,resource)
local file = dirnameFull .. '/' .. resource.url:gsub(".*/","")
print('🤞 fetch ' .. resource.url)
os.execute('wget "' .. resource.url .. '" -O "' .. file .. '"')
end)
end
synced = synced + 1
else
print('ℹ️ ' .. displayName .. ' (up to date) #openbrush')
end end
print('🤞 fetch ' .. f.root.url)
os.execute('wget "' .. f.root.url .. '" -O "' .. rootfile .. '"')
if #f.resources > 0 then
foreach( f.resources, function(k,resource)
local file = dirnameFull .. '/' .. resource.url:gsub(".*/","")
print('🤞 fetch ' .. resource.url)
os.execute('wget "' .. resource.url .. '" -O "' .. file .. '"')
end)
end
synced = synced + 1
else
print('ℹ️ ' .. asset.displayName .. ' (up to date) #openbrush')
end end
if app.opts.plugin_openbrush_sync_strategy == "link" then
print('✅ ' .. displayName .. ' (syncing) #openbrush #link')
local desktopfile = dirnameFull .. '/' .. util.hyphenate( displayName) .. '.desktop'
if not util.fileExist(desktopfile) then
print(desktopfile)
local desktopdata = '[Desktop Entry]\n'
.. 'Type=Link\n'
.. 'Name=' .. (displayName or '') .. '\n'
.. 'URL=' .. (f.root.url or '') .. '\n'
.. 'Icon=' .. (asset.thumbnail.url or '') .. '\n'
util.writefile( desktopfile, desktopdata)
print('✅ writing ' .. desktopfile .. ' #openbrush')
synced = synced + 1
else
print('ℹ️ ' .. asset.displayName .. ' (up to date) #openbrush')
end
end
else else
print('[openbrush.lua] error: no suitable format found for ' .. asset.displayName .. ' ' .. asset.assetId) print('[openbrush.lua] error: no suitable format found for ' .. asset.displayName .. ' ' .. asset.assetId)
end end

View file

@ -32,7 +32,8 @@ app.on('scan_experience_file', function(exp)
end) end)
-- set thumbnail if any -- set thumbnail if any
if exp.sidecarfile.png then if exp.sidecarfile.png then
exp.thumbnail = exp.sidecarfile.png exp.parent.thumbnail = exp.sidecarfile.png
print("✅ └─ plugin/xrfragments: " .. exp.thumbnail .. " thumbnail detected")
end end
local jsonfile = exp.path:gsub("."..ext.."$",".json") local jsonfile = exp.path:gsub("."..ext.."$",".json")
-- scan for hrefs in json sidecarfile -- scan for hrefs in json sidecarfile