require 'h' function eprint(x) io.stderr:write( tostring(x)) io.stderr:write('\n') end local fname = arg[0]:gsub('/[^/]-%.lua$','/questions.txt') eprint("\treading questions from "..fname) local F = io.open(fname,'r') questions = {} local lidx = 0 local line = F:read("l") while line do local date, q = line:match("^(.-)\t(.*)$") if not date then break end q = escape(q) local a = "

" local aline = F:read("l") while aline and not aline:match("^%-%-%-") do if aline:match("%S") then a = a .. aline .. "\n" else a = a .. '

' end aline = F:read("l") end table.insert(questions, 1, { p({class='question-date'},date), h3({class='question-heading'},q), safe(a) }) line = F:read("l") end local head = mkhead('questions') local top = mksmalltopbox('question and answer') local bread = bcrumb{ {'< home', '/'}, {'q & a'} } local asect = section { h2('submit a question'), tag('form',{action='/misc/submit-question.cgi',method='post'},{ tag('textarea',{name='q'},{}), tag('label',{['for']='horse'},'please type the word "horse"'), tag('input',{id='horse',name='horse',type='text'},''), tag('button','submit a question'), }) } local qsect if #questions > 0 then qsect = section { questions } else qsect = section { i'there are no questions yet.' } end print(html({ head, top, bread, asect, qsect }))