TEMPLATE / READY TO REMIX
Observatory
An interactive Lua showcase with forms and a masked demo code.
preview
This template runs Lua on its host. The source below is not executed by this web preview.
app.lua
return function(ctx)
local P=ctx.page
local art={'ffffffffffff1111ffffffffffff','fffffffffff14441fffffffffff','ffffffffff1444441ffffffffff','fffffffffff14441fffffffffff','ffffffffff1111111ffffffffff','ffffffffff1fffff1ffffffffff','fffffffff11fffff11fffffffff','ffffffff11111111111ffffffff'}
local children={P.image{rows=art,text='A lantern in the night'},P.heading{text='THE LANTERN OBSERVATORY'},P.paragraph{text='Small screens. Bright ideas. An interactive field station between worlds.'},P.columns{children={P.section{children={P.heading{text='01 / EXPLORE'},P.paragraph{text='Palette pixel art, headings, lists and links.'}}},P.section{children={P.heading{text='02 / INTERACT'},P.paragraph{text='Forms travel securely to server-side Lua.'}}}}}}
if ctx.method=='POST' and ctx.path=='/experiment' then
local code=tostring(ctx.fields.code or '')
if code~='glow' then
children[#children+1]=P.heading{text='Try the demo code: glow'}
children[#children+1]=P.paragraph{text='That code did not match. No password or form content was saved.'}
else
local name=tostring(ctx.fields.explorer or 'Traveler'):sub(1,60)
local biome=tostring(ctx.fields.biome or 'Forest'):sub(1,40)
children[#children+1]=P.heading{text='Welcome, '..name..'.'}
children[#children+1]=P.paragraph{text='Your destination: '..biome..'. Your beacon is '..(ctx.fields.beacon and 'lit' or 'off')..'. This response was built by server Lua.'}
children[#children+1]=P.paragraph{text='The demo code was checked and discarded. No login session was created.'}
end
children[#children+1]=P.link{text='Try another experiment',href='/'}
elseif ctx.method=='GET' and ctx.path=='/' then
children[#children+1]=P.list{items={'Layouts stack on pocket computers.','Keyboard: Tab selects, Enter activates.','Password fields are masked in the updated browser.'}}
children[#children+1]=P.heading{text='Run your own experiment'}
children[#children+1]=P.paragraph{text='Use the public demo code glow. Never enter a real password here. Masking hides typing; it is not account authentication.'}
children[#children+1]=P.form{action='/experiment',children={P.input{name='explorer',text='Explorer name'},P.select{name='biome',text='Choose a biome',options={'Forest','Desert','Snowy peaks','The End'}},P.checkbox{name='beacon',text='Light the beacon'},P.input{name='code',text='Demo code (glow)',password=true},P.submit{text='Launch experiment'}}}
else return {kind='error',status=404,message='Page not found'} end
children[#children+1]=P.link{text='Read the component reference',href='hub://help/components.json'}
return {kind='page',page=P.document('Lantern Observatory',children)}
end