ferron

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

commit cd9284b7ddc01c0f9bcaec321af22f8a59655ac4
parent 5b9008408682895bab1e8e5d4fa914c41eeb1798
Author: Hugo Soucy <hsoucy@kronostechnologies.com>
Date:   Thu,  4 Oct 2018 12:00:51 -0400

Add returns

Diffstat:
Mferron/feed.lua | 4++--
Mferron/page.lua | 23++++++++---------------
Mferron/utilities/file-utils.lua | 4+++-
3 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/ferron/feed.lua b/ferron/feed.lua @@ -14,7 +14,7 @@ function feed.makefeed(entries, destination) local feedtemplate = Ferron.site.path .. Ferron.site.siteconfig.paths.templates .. "/feed/" .. k .. ".mustache" if path.isfile(feedtemplate) then - fileutils.pushfilecontent( + return fileutils.pushfilecontent( destination .. "/" .. v.name .. v.extension, templateutils.processmustache( fileutils.pullfilecontent(feedtemplate), @@ -23,7 +23,7 @@ function feed.makefeed(entries, destination) ) ) else - print("*** Warning! The `" .. feedtemplate .. "` template is missing!") + return print("*** Warning! The `" .. feedtemplate .. "` template is missing!") end end end diff --git a/ferron/page.lua b/ferron/page.lua @@ -50,7 +50,13 @@ function page.makepage() fileutils.mkdir(page_htmlpath) end - -- Build the HTML file + -- Update the JSON file data + fileutils.pushfilecontent( + fileutils.removeextension(page) .. ".json", + json.encode(page_conf, {indent = true, keyorder = Ferron.site.siteconfig.metaskeyorder}) + ) + + -- Build and push the HTML page fileutils.pushfilecontent( page_htmlpath .. "/" .. fileutils.getplainname(page) .. ".html", templateutils.processmustache( @@ -60,20 +66,7 @@ function page.makepage() ) ) - if not path.isfile(page_htmlpath .. "/" .. fileutils.getplainname(page) .. ".html") then - print(" !! " .. fileutils.getrelpath(page_noextension) .. ".html - error!") - end - - -- Update the JSON file data - fileutils.pushfilecontent( - fileutils.removeextension(page) .. ".json", - json.encode( - page_conf, { - indent = true, - keyorder = {"bridgy","cite","citeurl","content","date","datetime","description","id","keywords","permalink","shortlink","template","title"} - } - ) - ) + return end end, { diff --git a/ferron/utilities/file-utils.lua b/ferron/utilities/file-utils.lua @@ -78,6 +78,8 @@ function fileutils.pushfilecontent(pathtofile, data) file:write(data) file:close() + + return assert(path.isfile(pathtofile)) end function fileutils.getrelpath(file) @@ -115,7 +117,7 @@ function fileutils.emptydirectory(dirpath) function(P, mode) if mode == 'directory' then path.rmdir(P) - elseif P ~= dirpath .. ".gitignore" then + elseif P ~= dirpath .. ".gitignore" then path.remove(P) end