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, true)
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)
end
return synced

View file

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

View file

@ -191,7 +191,12 @@ return {
-- check for directory thumbnail sidecarfile
local thumbExt = {"png","jpg","webp"}
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)
if util.fileExist( thumbnailFile ) then
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
local plugin = {
name = "ManyFold",
hide = true, -- not finished
infowide = true,
info = [[
<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',
title='How to sync',
info='download assets locally (prevent linkrot)',
default = "mirror",
values={mirror="mirror locally"}
default = "link",
values={mirror="mirror locally",link="link to URLs"}
},
{
key='app.opts.plugin_openbrush_sync_when',
@ -120,7 +120,7 @@ local plugin = {
key='app.opts.plugin_openbrush_sync_folder',
title='Sync to folder',
info='openbrush (icosa.gallery) assets will be saved here',
default = "./myverse/tech-demos/tronverse",
default = "./myverse",
type = "dir",
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>.
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,
@ -291,7 +295,8 @@ You can add/create parcels in icosa.gallery, by publishing via <a href='https://
local synced = 0
foreach( t.assets, function(k,asset)
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 jsonfile = dirnameFull .. '/asset.json'
local README = me.getFolder(tag) .. '/README.md'
@ -326,8 +331,10 @@ You can add/create parcels in icosa.gallery, by publishing via <a href='https://
sync = false -- already finished
end
end
if app.opts.plugin_openbrush_sync_strategy == "mirror" then
if sync then
print('✅ ' .. asset.displayName .. ' (syncing) #openbrush')
print('✅ ' .. displayName .. ' (syncing) #openbrush #mirror')
util.writefile( jsonfile, EncodeJson(asset) )
local rootfile = dirnameFull .. '/' .. f.root.url:gsub(".*/","")
local thumbnailfile = ''
@ -346,9 +353,30 @@ You can add/create parcels in icosa.gallery, by publishing via <a href='https://
end)
end
synced = synced + 1
else
print('ℹ️ ' .. 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
print('[openbrush.lua] error: no suitable format found for ' .. asset.displayName .. ' ' .. asset.assetId)
end

View file

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