1
0
Fork 0
sitegen/sitelib.lua

60 Zeilen
1.3 KiB
Lua

2018-10-05 05:10:48 +10:00
local sitelib = {}
sitelib.srcpath = "src"
sitelib.outpath = "out"
2019-01-15 15:03:09 +11:00
sitelib.gopherpath = "gopher"
2018-10-05 05:10:48 +10:00
sitelib.includepath = "include"
sitelib.staticpath = "static"
2019-01-15 15:03:09 +11:00
sitelib.hostname = "shadowkat.net"
sitelib.gopherport = 70
2018-10-05 05:10:48 +10:00
sitelib.header, sitelib.footer = "", ""
2019-01-15 15:03:09 +11:00
sitelib.gheader, sitelib.gfooter = "", ""
2018-10-05 05:10:48 +10:00
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
2019-01-15 15:03:09 +11:00
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
2018-10-05 05:10:48 +10:00
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)
2018-10-05 05:10:48 +10:00
-- 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