summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-05-22 00:24:21 +0100
committerubq323 <ubq323@ubq323.website>2023-05-22 00:30:30 +0100
commit9eb6d483f356a77caf37e819f9666abe3f9a6159 (patch)
tree8bc27abce25a2617e1a54c38dae7f8786a2e005f
parent35409af1e0230323a6bc96de229ef2aa02a2a086 (diff)
questions page
-rwxr-xr-xbuild.sh3
-rw-r--r--h.lua17
-rw-r--r--head.html27
-rw-r--r--questions/questions.lua69
-rw-r--r--questions/questions.txt1
5 files changed, 108 insertions, 9 deletions
diff --git a/build.sh b/build.sh
index d046c26..0ef4c0e 100755
--- a/build.sh
+++ b/build.sh
@@ -35,6 +35,9 @@ bpn index
cf bg.png
cf me.png
+md questions
+bpn questions/questions
+
# md blog
# bp blogindex.lua blog/index.html
diff --git a/h.lua b/h.lua
index 7eb4baf..7fcede1 100644
--- a/h.lua
+++ b/h.lua
@@ -89,7 +89,7 @@ function qw(s)
for a in s:gmatch("%w+") do table.insert(t,a) end
return t
end
-local tnames = qw"h1 h2 p b ul ol li dl dt dd div section header figure figcaption img title nav"
+local tnames = qw"h1 h2 h3 p b i ul ol li dl dt dd div section header figure figcaption img title nav"
for _,n in ipairs(tnames) do
_G[n] = tagfn(n)
end
@@ -103,8 +103,11 @@ function readf(fname)
end
function safereadf(fname) return safe(readf(fname)) end
-function mkhead(t)
+function mkhead(t,nositename)
-- includes css and stuff, and title element
+ if not nositename then
+ t = t .. ' - uq323.website'
+ end
return {
safereadf "head.html",
title(t),
@@ -112,11 +115,17 @@ function mkhead(t)
end
function mktopbox(imgsrc,name,rest)
- return header {
+ return header({class="big-header"}, {
img({id='me',src=imgsrc},''),
h1(name),
rest
- }
+ })
+end
+
+function mksmalltopbox(words)
+ return header ({class="small-header"}, {
+ h1(words)
+ })
end
function bcrumb(items)
diff --git a/head.html b/head.html
index aa4f00e..b9f0334 100644
--- a/head.html
+++ b/head.html
@@ -6,13 +6,21 @@
body {font-family: sans-serif;font-size:larger;max-width:60ch;margin:auto}
body {background-image: url("/bg.png");image-rendering:pixelated}
h1 {color:#e79e00; text-shadow: 0 0 1px #000, 0 0 1px #000, 0 0 1px #000, 0 0 1px #000, 0 0 1px #000, 0 0 1px #000;}
-section {margin:20px 0;padding:20px;border-radius:20px;border:1.7px solid black;background-color:white}
+section {margin:20px 0;padding:10px 20px;border-radius:20px;border:1.7px solid black;background-color:white}
+
+h2,h3 {margin:5px auto}
header {border: 2px solid black;max-width:100%;margin:1em;background-color:white}
-header {display:grid;grid-template-columns:1fr 3fr;}
-#me {max-width:100%;grid-row: 1/3;grid-column:1;margin:auto}
-header * {margin:auto}
-header p {padding:1em}
+
+header.big-header {display:grid;grid-template-columns:1fr 3fr;}
+header.big-header #me {max-width:100%;grid-row: 1/3;grid-column:1}
+header.big-header * {margin:auto}
+header.big-header p {padding:1em}
+header.big-header h1:last-child {grid-row: 1/3}
+
+header.small-header * {margin:10px auto; width:max-content}
+
+nav {background-color:#eee;border-radius:20px;border:1.7px solid black}
.breadcrumb {font-size:smaller;}
.breadcrumb ol {list-style:none;padding-left:1em}
@@ -21,4 +29,13 @@ header p {padding:1em}
.postlist li {list-style:none;}
.postlist time {color:#555;font-style:italic}
+
+.question-date {color:gray;font-size:small;margin-bottom:0;margin-top:30px}
+.question-date:first-child {margin-top: 0;}
+.question-date::before {content:"["}
+.question-date::after {content:"]"}
+.question-heading {margin-top:0px;margin-bottom:4px}
+.question-heading + p {margin-top:5px}
+
+textarea {width: calc(100% - 14px);height:200px}
</style>
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 @@
+