among other things, wrote a tag index and improved gopher page generation

This commit is contained in:
Izaya 2020-01-26 22:48:17 +11:00
parent 47ef6350fd
commit d658119ea3
5 changed files with 24 additions and 2 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/src
/static
/out
/gopher

View File

@ -5,4 +5,5 @@
./home.lua
./genrss.lua
./gengopher.lua
./gopherblog.lua
./gopher-home.lua

View File

@ -3,7 +3,7 @@ local sitelib = require "sitelib"
local fs = require "lfs"
print("Copying static content...")
os.execute("cp -rv static/* out/")
os.execute("rsync -avzh --delete static/* out/")
print("Building list of markdown files")
local mdfiles = {}

View File

@ -29,7 +29,7 @@ for k,infile in ipairs(mdfiles) do
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\n%s",page.title,fpath,sitelib.hostname,sitelib.gopherport,fline,index)
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

View File

@ -52,3 +52,23 @@ for tag,v in pairs(tags) do
f:write(sitelib.footer)
f:close()
end
print("Writing overall tag index...")
local ti = {}
for tag, v in pairs(tags) do
ti[#ti+1] = tag
end
table.sort(ti)
local f = io.open(sitelib.outpath.."/tag/index.html","wb")
f:write("<html><head><title>Tag Index</title>\n")
f:write(sitelib.header)
f:write("<h1>Tag index</h1>\n")
for k,v in pairs(ti) do
if #tags[v] > 1 then
f:write("<h3><a href=\""..v..".html\">"..v.."</a> ("..#tags[v].." entries)</h3>\n")
else
f:write("<h3><a href=\""..v..".html\">"..v.."</a> ("..#tags[v].." entry)</h3>\n")
end
end
f:write(sitelib.footer)
f:close()