diff --git a/sitelib.lua b/sitelib.lua new file mode 100644 index 0000000..3ff25b5 --- /dev/null +++ b/sitelib.lua @@ -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",'
') + page.html=page.html:gsub("++colbreak",'
') + page.html=page.html:gsub("++colend",'
') + -- and ends here + return page +end + +return sitelib