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.
59 lines
1.3 KiB
59 lines
1.3 KiB
local sitelib = {}
|
|
|
|
sitelib.srcpath = "src"
|
|
sitelib.outpath = "out"
|
|
sitelib.gopherpath = "gopher"
|
|
sitelib.includepath = "include"
|
|
sitelib.staticpath = "static"
|
|
sitelib.hostname = "shadowkat.net"
|
|
sitelib.gopherport = 70
|
|
|
|
sitelib.header, sitelib.footer = "", ""
|
|
sitelib.gheader, sitelib.gfooter = "", ""
|
|
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
|
|
|
|
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)
|
|
-- 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
|
|
|