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.

sitelib.lua 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. local sitelib = {}
  2. sitelib.srcpath = "src"
  3. sitelib.outpath = "out"
  4. sitelib.gopherpath = "gopher"
  5. sitelib.includepath = "include"
  6. sitelib.staticpath = "static"
  7. sitelib.hostname = "shadowkat.net"
  8. sitelib.gopherport = 70
  9. sitelib.header, sitelib.footer = "", ""
  10. sitelib.gheader, sitelib.gfooter = "", ""
  11. local f = io.open("include/header.html")
  12. if f then
  13. sitelib.header = f:read("*a")
  14. f:close()
  15. end
  16. local f = io.open("include/footer.html")
  17. if f then
  18. sitelib.footer = f:read("*a")
  19. f:close()
  20. end
  21. local f = io.open("include/gheader")
  22. if f then
  23. sitelib.gheader = f:read("*a")
  24. f:close()
  25. end
  26. local f = io.open("include/gfooter")
  27. if f then
  28. sitelib.gfooter = f:read("*a")
  29. f:close()
  30. end
  31. function sitelib.parsepage(s)
  32. local page={}
  33. page.md = ""
  34. for l in s:gmatch("(.-)\n") do
  35. if l:sub(1,3) == "-- " then
  36. k,v=l:match("%-%- (.-) (.+)")
  37. page[k] = v
  38. else
  39. page.md=page.md..l.."\n"
  40. end
  41. end
  42. local fn="/tmp/md"..tostring(math.random(1,2^24))
  43. f=io.open(fn,"wb")
  44. f:write(page.md)
  45. f:close()
  46. page.html = io.popen("markdown "..fn):read("*a")
  47. os.execute("rm "..fn)
  48. -- SKS specific stuff starts here
  49. page.html=page.html:gsub("++leftcol",'<div class="left-column">')
  50. page.html=page.html:gsub("++colbreak",'</div><div class="left-column">')
  51. page.html=page.html:gsub("++colend",'</div>')
  52. -- and ends here
  53. return page
  54. end
  55. return sitelib