ferron

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

commit 38920697bc4307e6b8d4fb50173774913e2b07cd
parent 8eb4a3606636b4bdea6caf14d192925d457df3dc
Author: Hugo Soucy <hugo.soucy@toumoro.com>
Date:   Thu, 12 Mar 2020 09:27:04 -0400

Optimize the site module.

Diffstat:
Mferron/site.lua | 41+----------------------------------------
1 file changed, 1 insertion(+), 40 deletions(-)

diff --git a/ferron/site.lua b/ferron/site.lua @@ -59,7 +59,7 @@ local function setsitepath(sitename) end local function makepaths(sitepath, siteconfig) - for k, v in pairs(siteconfig.paths) do + for k, _ in pairs(siteconfig.paths) do site[k] = sitepath .. siteconfig['paths'][k] end @@ -190,45 +190,6 @@ function site.startsite(samplelocation) end end --- Reset the `public_html/` folder of the selected site -function site.sitereset(htmllocation) - local location = htmllocation or site.html - local function removefiles(dir) - local ok, errormsg - - tb.each( - function(file) - if file ~= '.' - and file ~= '..' - and file ~= '.gitignore' - then - local thefile = dir..'/'..file - - if lfs.attributes(thefile, 'mode') == 'directory' then - removefiles(thefile) - else - ok, errormsg = os.remove(thefile) - - if not ok then - print('Error removing file: '..file..':'..errormsg) - end - end - end - end, - tb.from(lfs.dir(dir)) - ) - - -- remove directory - ok, errormsg = os.remove(dir) - - if not ok then - print('Can\'t removing directory: '..dir..':'..errormsg) - end - end - - removefiles(location) -end - -- Init a site before generates it -- function site.init() -- end