#!/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="" local itemtemplate = [[%s %s %s %s %s %s ]] print("Generating index") for i = #mdfiles, #mdfiles - 9, -1 do infile = mdfiles[i] local fpath = "/blog/"..infile local infile = sitelib.srcpath.."/blog/"..infile local uuid = "https://"..sitelib.hostname..(fpath:sub(1,-3)).."html" print(infile,fpath,uuid) --[[ local u = io.popen("./uuidfile.sh "..infile) local uuid = u:read("*a"):match("[^\n]+") u:close() ]]-- local f = io.open(infile,"rb") local c = f:read("*a") f:close() local page = sitelib.parsepage(c) local fline = page.md:match("\n\n(.-)\n") print(fline) -- attempt to convert existing date to a dumb RFC 822 date local d = io.popen("date --date='"..page.date.."' '+%a, %d %b %Y %H:%M:00 %z'"):read("*a"):match("(.+)\n") index = string.format(itemtemplate,index,page.title,fline,uuid,uuid,d) end index=[[ ShadowKat Studios https://shadowkat.net ShadowKat Studios Blog Entries ]]..index local f = io.open(sitelib.outpath.."/rss.xml","wb") f:write(index) f:write([[ ]]) f:close()