added sitelib
This commit is contained in:
parent
904e044c51
commit
c9e3590976
44
sitelib.lua
Normal file
44
sitelib.lua
Normal file
@ -0,0 +1,44 @@
|
||||
local sitelib = {}
|
||||
|
||||
sitelib.srcpath = "src"
|
||||
sitelib.outpath = "out"
|
||||
sitelib.includepath = "include"
|
||||
sitelib.staticpath = "static"
|
||||
|
||||
sitelib.header, sitelib.footer = "", ""
|
||||
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
|
||||
|
||||
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")
|
||||
-- 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
|
Loading…
Reference in New Issue
Block a user