2026-07-22 18:36:02 +02:00
|
|
|
local util = require('util')
|
|
|
|
|
|
|
|
|
|
return function(app)
|
|
|
|
|
|
|
|
|
|
local config = { -- default
|
|
|
|
|
name = "XRForge",
|
|
|
|
|
baseurl="/",
|
|
|
|
|
title="My XRForge experiences",
|
|
|
|
|
subtitle="Portable XR experiences for Phone, VRheadset & desktop.",
|
|
|
|
|
admin_title = "XRForge Admin",
|
|
|
|
|
admin_subtitle = "Manage your XR experiences here",
|
|
|
|
|
disk_dir = ".",
|
2026-07-23 10:01:34 +02:00
|
|
|
hide_keywords = "wip beta -v[0-9] customerX",
|
2026-07-22 18:36:02 +02:00
|
|
|
manyfold_instance_1 = "https://xrforge.isvery.ninja",
|
|
|
|
|
manyfold_instance_2 = "",
|
|
|
|
|
manyfold_instance_3 = "",
|
|
|
|
|
sync_interval = 30,
|
|
|
|
|
sync_strategy = "recent"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local configfile = "xrforge.lua"
|
|
|
|
|
local savedconfig = util.readfile( app.bindir .. configfile, 'r', true) -- check local config
|
|
|
|
|
or LoadAsset(configfile) -- then internal saved config
|
|
|
|
|
|
|
|
|
|
if savedconfig then
|
|
|
|
|
local eval = function(str) return load(str)() end
|
|
|
|
|
local status, result = pcall(eval, savedconfig ) -- Pass "string" as the first argument
|
|
|
|
|
if not status then
|
|
|
|
|
print("error: xrforge.lua contains errors:")
|
|
|
|
|
else
|
|
|
|
|
config = result -- overrule default config
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
app.on('set', function(k,v)
|
|
|
|
|
if k == 'app.opts' then
|
|
|
|
|
app.opts = v
|
|
|
|
|
app.opts.updated = os.time()
|
|
|
|
|
local newconfig = "app.on('init', function()\n\tprint('config loaded')\nend)\n\nreturn " .. util.dump(app.opts)
|
|
|
|
|
newconfig = newconfig:gsub("^}$"," init = function() print('xrforge.lua config loaded') end\n}")
|
|
|
|
|
util.writefile( app.bindir .. configfile, newconfig )
|
|
|
|
|
print("stored xrforge.lua")
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
-- store local config if not exist
|
|
|
|
|
if not util.readfile( app.bindir .. configfile, 'r', true) then
|
|
|
|
|
app.set('app.opts', config )
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return config
|
|
|
|
|
end
|