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.
38 lines
1.0 KiB
38 lines
1.0 KiB
#!/usr/bin/env lua
|
|
local sitelib = require "sitelib"
|
|
local fs = require "lfs"
|
|
|
|
print("Reading blog entries")
|
|
local mdfiles = {}
|
|
for file in fs.dir(sitelib.srcpath.."/blog/") do
|
|
if file:sub(1,1) ~= "." then
|
|
local index = tonumber(file:match("(%d+).md"))
|
|
if index then
|
|
mdfiles[index] = file
|
|
end
|
|
end
|
|
end
|
|
|
|
if not fs.attributes(sitelib.gopherpath) then
|
|
fs.mkdir(sitelib.gopherpath)
|
|
end
|
|
|
|
local index=""
|
|
print("Generating index")
|
|
for k,infile in ipairs(mdfiles) do
|
|
local fpath = "/blog/"..infile
|
|
local infile = sitelib.srcpath.."/blog/"..infile
|
|
print(infile,fpath)
|
|
local f = io.open(infile,"rb")
|
|
local c = f:read("*a")
|
|
f:close()
|
|
local page = sitelib.parsepage(c)
|
|
if page.date then page.title = string.format("%s (%s)",page.title,page.date) end
|
|
local fline = page.md:match("\n\n(.-)\n")
|
|
index = string.format("0%s\t%s\t%s\t%d\ni%s\ni\n%s",page.title,fpath,sitelib.hostname,sitelib.gopherport,fline,index)
|
|
end
|
|
index=sitelib.gheader .. index .. sitelib.gfooter
|
|
|
|
local f = io.open(sitelib.gopherpath.."/blog/.gopherdir","wb")
|
|
f:write(index)
|
|
f:close()
|
|
|