diff options
author | ubq323 <ubq323@ubq323.website> | 2023-05-22 00:24:21 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-05-22 00:30:30 +0100 |
commit | 9eb6d483f356a77caf37e819f9666abe3f9a6159 (patch) | |
tree | 8bc27abce25a2617e1a54c38dae7f8786a2e005f /questions | |
parent | 35409af1e0230323a6bc96de229ef2aa02a2a086 (diff) |
questions page
Diffstat (limited to 'questions')
-rw-r--r-- | questions/questions.lua | 69 | ||||
-rw-r--r-- | questions/questions.txt | 1 |
2 files changed, 70 insertions, 0 deletions
diff --git a/questions/questions.lua b/questions/questions.lua new file mode 100644 index 0000000..a0a44ea --- /dev/null +++ b/questions/questions.lua @@ -0,0 +1,69 @@ +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 = "<p>" + local aline = F:read("l") + while aline and not aline:match("^%-%-%-") do + if aline:match("%S") then + a = a .. tostring(escape(aline)) .. "\n" + else + a = a .. '<p>' + 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('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 +})) + + + diff --git a/questions/questions.txt b/questions/questions.txt new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/questions/questions.txt @@ -0,0 +1 @@ + |