2020-12-23 07:07:00 +01:00
|
|
|
--[[
|
|
|
|
Compiles all the pages under src/pages/ with etlua. See the etlua documentation
|
|
|
|
for more info (https://github.com/leafo/etlua)
|
|
|
|
]]
|
|
|
|
local et = require("etlua")
|
|
|
|
local pagenames = {
|
|
|
|
"index",
|
|
|
|
"author_index",
|
|
|
|
"claim",
|
|
|
|
"paste",
|
|
|
|
"edit",
|
|
|
|
"read",
|
|
|
|
"nostory",
|
|
|
|
"cantedit",
|
|
|
|
"noauthor",
|
|
|
|
"login",
|
|
|
|
"author_paste",
|
|
|
|
"author_edit",
|
|
|
|
"search",
|
2021-02-09 03:40:57 +01:00
|
|
|
"error",
|
2020-12-23 07:07:00 +01:00
|
|
|
}
|
|
|
|
local pages = {}
|
2021-01-04 04:05:50 +01:00
|
|
|
for k,v in pairs(pagenames) do
|
|
|
|
local path = string.format("pages/%s.etlua",v)
|
2021-01-04 03:48:29 +01:00
|
|
|
local parser = et.Parser()
|
|
|
|
local f = assert(io.open(path,"r"))
|
|
|
|
local fdata = assert(f:read("*a"))
|
|
|
|
local code = assert(parser:parse(fdata))
|
|
|
|
local func = assert(parser:load(parser:chunks_to_lua(),path))
|
|
|
|
f:close()
|
2021-01-04 04:05:50 +01:00
|
|
|
pages[v] = function(...)
|
|
|
|
local buf = assert(parser:run(func,...))
|
2021-01-04 03:48:29 +01:00
|
|
|
return table.concat(buf)
|
|
|
|
end
|
|
|
|
end
|
2020-12-23 07:07:00 +01:00
|
|
|
|
|
|
|
return pages
|