get modified date from ls instead of stat

This commit is contained in:
sejo 2022-03-28 17:26:49 -06:00
parent e64ed6a753
commit a879d19ce8
1 changed files with 9 additions and 13 deletions

View File

@ -365,12 +365,12 @@ function secondPass() -- write incoming links and footer
end
end
function initPageMetadata( name ) -- return a table with metadata
function initPageMetadata( name, date ) -- return a table with metadata
local meta = {
incoming = {},
slug = slugify(name), name = name,
ptitle = "", pdescription = "",
updatedate = "",
updatedate = date,
navcontent = "",
gemincoming = "", webincoming = "",
gemtranslation = "", webtranslation = ""
@ -379,11 +379,6 @@ function initPageMetadata( name ) -- return a table with metadata
web = { path = string.format("%s/%s.html", webdir, meta.slug) },
gem = { path = string.format("%s/%s.gmi", gemdir, meta.slug) }
}
-- get update date for file
local stat = io.popen(string.format("stat -c %%y src/%s.gmo", meta.slug),"r")
local dat = stat:read("l")
stat:close()
meta.updatedate = string.sub(dat, 1, 10) -- YYYY-MM-DD
return meta
end
@ -395,18 +390,19 @@ function genIndex()
local index = assert( io.open(indexpath,"a" ) )
-- get gmo files in chronological order
local gmofiles = io.popen("ls -t src/*gmo")
local gmofiles = io.popen("ls -to --time-style=+%F src/*gmo")
local count = 0
for filename in gmofiles:lines() do
local basename = string.sub(filename, 5, -5) -- remove src/ and .gmo
local date,basename = string.match(filename,"^.+%s(.-)%ssrc/(.-).gmo$")
local name = spacify(basename)
-- create an entry for each file
local entry = string.format("=> ./%s.gmi {%s}\n", basename, name)
index:write(entry)
if name ~= "pages" then
local entry = string.format("=> ./%s.gmi {%s}\n", basename, name)
index:write(entry)
end
-- also initialize each name in the pages table
-- initialize page metadata
pages[ name ] = initPageMetadata( name )
pages[ name ] = initPageMetadata( name, date )
count = count + 1
end
gmofiles:close()