Imported from ../lua-3.0.tar.gz.
[lua.git] / test / examples / www / staff.lua
blob7fa5b810c89a8b34a6bd183c26dcc84892891e80
1 $debug
3 readfrom("template.html")
4 TEMPLATE=read(".*")
5 readfrom()
7 PAT="|(%a%a*)|"
9 GLOBAL={
10 DATE=date("%d/%m/%Y %T"),
13 function get(i)
14 if LOCAL[i] then return LOCAL[i]
15 elseif GLOBAL[i] then return GLOBAL[i]
16 else return "<BLINK>?"..i.."?</BLINK>" end
17 end
19 function global(t)
20 local i,v=next(t,nil)
21 while i do
22 GLOBAL[i]=v
23 i,v=next(t,i)
24 end
25 end
27 function staff(t)
28 LOCAL=t
29 if t.AREAS then t.AREAS=gsub(t.AREAS,"[;,] *","\n<LI>") end
30 local p,n=TEMPLATE
31 if t.WWW=="" then p=gsub(p,'<A HREF="|WWW|">|NAME|</A>',"|NAME|") end
32 repeat p,n=gsub(p,PAT,get) until n==0
33 write(t.LOGIN,"\n")
34 writeto(t.LOGIN..".html")
35 write(p)
36 writeto()
37 end