Imported from ../lua-4.0.tar.gz.
[lua.git] / test / examples / www / staff.lua
blobf36df4ad622a3c9f5b111e811f387b6773d249af
1 readfrom("template.html")
2 TEMPLATE=read("*a")
3 readfrom()
5 PAT="|(%a%a*)|"
7 GLOBAL={
8 DATE=date("%d/%m/%Y %T"),
11 function get(i)
12 if LOCAL[i] then return LOCAL[i]
13 elseif GLOBAL[i] then return GLOBAL[i]
14 else return "<BLINK>?"..i.."?</BLINK>" end
15 end
17 function global(t)
18 for i,v in t do
19 GLOBAL[i]=v
20 end
21 end
23 function staff(t)
24 LOCAL=t
25 if t.AREAS then t.AREAS=gsub(t.AREAS,"[;,] *","\n<LI>") end
26 local p,n=TEMPLATE
27 if t.WWW=="" then p=gsub(p,'<A HREF="|WWW|">|NAME|</A>',"|NAME|") end
28 repeat p,n=gsub(p,PAT,get) until n==0
29 write(t.LOGIN,"\n")
30 writeto(t.LOGIN..".html")
31 write(p)
32 writeto()
33 end