ferron

Ferron is a fast and simple static website generator made with Lua.
Log | Files | Refs | Submodules | README | LICENSE

commit bb83337f202a044c303ff6d26a9f5bdc0581f95b
parent caf3f3d51d974cab612fb9237c3a2ca78ff66a71
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Sat, 25 Apr 2020 21:37:43 -0400

Check if a content was modified since the last build

Diffstat:
Mferron/init.lua | 7++++++-
Mferron/page.lua | 14++++++++++----
Alastbuild | 2++
3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/ferron/init.lua b/ferron/init.lua @@ -31,6 +31,7 @@ Ferron = { if arg[1] == 'build' then do local sitename + local lastbuild if arg[2] ~= '--dev' then sitename = arg[2] @@ -38,12 +39,16 @@ if arg[1] == 'build' then sitename = arg[3] end - return tb.build{ + tb.build{ makepages(site.setsite(sitename)), link.makeshorts(), link.makerewritemap(), movestatic() } + + lastbuild = assert(io.open(lfs.currentdir() .. '/lastbuild', 'w+')) + lastbuild:write(os.time()) + lastbuild:close() end end diff --git a/ferron/page.lua b/ferron/page.lua @@ -85,7 +85,6 @@ function page.render(page, sitedata) local shortlinks_db local shortlinks_tb - -- If draft is set to true -- Don't render the page if metaTable.draft then @@ -123,7 +122,7 @@ function page.render(page, sitedata) end -- For index page set and get entries - if fl.isIndex(page) then + if fl.isIndex(page) and metaTable.listchildnodes ~= false then setentries(fl.getdirname(page), metaTable, sitedata) end @@ -146,7 +145,7 @@ function page.render(page, sitedata) ) ) - return --print(metaTable.content, page) + return --print(page) end function page.makepages(sitedata) @@ -154,7 +153,14 @@ function page.makepages(sitedata) local indexpages = tb.filter(fl.isIndex, sitedata.nodes) -- Render single pages - tb.each(function(p) page.render(p, sitedata) end, singlepages) + tb.each( + function(p) + if lfs.attributes(p).modification > lfs.attributes(lfs.currentdir() .. '/lastbuild').modification then + print(p) + page.render(p, sitedata) + end + end, singlepages + ) -- Render index pages tb.each(function(p) page.render(p, sitedata) end, indexpages) diff --git a/lastbuild b/lastbuild @@ -0,0 +1 @@ +1587864994+ \ No newline at end of file