diff --git a/blog.lua b/blog.lua
index b246258..31d4487 100755
--- a/blog.lua
+++ b/blog.lua
@@ -34,7 +34,7 @@ for i = #ftab, 1, -1 do
f:write("
")
end
if ftab[i-1] then
- f:write("")
+ f:write("")
end
f:write("")
end
diff --git a/genall.sh b/genall.sh
index 2155f08..0d1781e 100755
--- a/genall.sh
+++ b/genall.sh
@@ -3,3 +3,6 @@
./blog.lua
./tags.lua
./home.lua
+./genrss.lua
+./gengopher.lua
+./gopher-home.lua
diff --git a/genrss.lua b/genrss.lua
new file mode 100755
index 0000000..8a7bd3a
--- /dev/null
+++ b/genrss.lua
@@ -0,0 +1,64 @@
+#!/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()