diff options
Diffstat (limited to 'h.lua')
-rw-r--r-- | h.lua | 43 |
1 files changed, 36 insertions, 7 deletions
@@ -27,14 +27,15 @@ local function fmt_attrs(attrs) end local function fmt_tag(tag) - local a = tag.attrs and fmt_attrs(tag.attrs) or "" - local bf - if type(tag.body) == "string" or (type(tag.body) == "table" and tag.body.tag) then - bf = "%s" + local attrs = tag.attrs and fmt_attrs(tag.attrs) or "" + local selfclosing = (tag.body == "") + local sameline = type(tag.body) == "string" or (type(tag.body) == "table" and tag.body.tag) + local maybenl = sameline and "" or "\n" + if selfclosing then + return ("<%s%s/>"):format(tag.tname,attrs) else - bf = "\n%s" + return ("<%s%s>%s%s</%s>"):format(tag.tname,attrs,maybenl,html(tag.body),tag.tname) end - return ("<%s%s>"..bf.."</%s>"):format(tag.tname,a,html(tag.body),tag.tname) end function tag(tname, a1, a2) @@ -87,7 +88,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 li dl dt dd div section header figure figcaption" +local tnames = qw"h1 h2 p b ul li dl dt dd div section header figure figcaption img title" for _,n in ipairs(tnames) do _G[n] = tagfn(n) end @@ -100,3 +101,31 @@ function readf(fname) return c end function safereadf(fname) return safe(readf(fname)) end + +function mkhead(t) + -- includes css and stuff, and title element + return { + safereadf "head.html", + title(t), + } +end + +-- the box at the top with the cool picture of me in, etc +-- presumably the same on all pages +site_top = header { + img({id="me",src="/me.png"},""), + h1 "ubq323's website", + p [[rebecca, "ubq323" (she/her, 20) - eminently engromulent]], +} + + +function blogpost(meta, content) + -- creates a whole page + + return { + mkhead(meta.title), + site_top, + section(content), + -- maybe footer? + } +end |