Generator for my site.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.3 KiB

4 years ago
local sitelib = {}
sitelib.srcpath = "src"
sitelib.outpath = "out"
sitelib.gopherpath = "gopher"
4 years ago
sitelib.includepath = "include"
sitelib.staticpath = "static"
sitelib.hostname = "shadowkat.net"
sitelib.gopherport = 70
4 years ago
sitelib.header, sitelib.footer = "", ""
sitelib.gheader, sitelib.gfooter = "", ""
4 years ago
local f = io.open("include/header.html")
if f then
sitelib.header = f:read("*a")
f:close()
end
local f = io.open("include/footer.html")
if f then
sitelib.footer = f:read("*a")
f:close()
end
local f = io.open("include/gheader")
if f then
sitelib.gheader = f:read("*a")
f:close()
end
local f = io.open("include/gfooter")
if f then
sitelib.gfooter = f:read("*a")
f:close()
end
4 years ago
function sitelib.parsepage(s)
local page={}
page.md = ""
for l in s:gmatch("(.-)\n") do
if l:sub(1,3) == "-- " then
k,v=l:match("%-%- (.-) (.+)")
page[k] = v
else
page.md=page.md..l.."\n"
end
end
local fn="/tmp/md"..tostring(math.random(1,2^24))
f=io.open(fn,"wb")
f:write(page.md)
f:close()
page.html = io.popen("markdown "..fn):read("*a")
os.execute("rm "..fn)
4 years ago
-- SKS specific stuff starts here
page.html=page.html:gsub("++leftcol",'<div class="left-column">')
page.html=page.html:gsub("++colbreak",'</div><div class="left-column">')
page.html=page.html:gsub("++colend",'</div>')
-- and ends here
return page
end
return sitelib