ferron

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

commit 96a635792392800810cc7e4eca288201dfc3bba8
parent 37d600285572dd5c494d2d327099fa3bd497918d
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Tue, 21 Nov 2017 09:56:08 -0500

Add some outputs

Diffstat:
Mfunctions/make-atom-feed.lua | 4+++-
Mfunctions/make-lists-of-pages.lua | 12+++++++++---
Mfunctions/make-pages.lua | 9++++++---
Mfunctions/move-to-publichtml.lua | 2++
Mfunctions/template-utils.lua | 2+-
5 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/functions/make-atom-feed.lua b/functions/make-atom-feed.lua @@ -26,7 +26,9 @@ local function makeatomfeed() feed ) ) - + + print("¤ /feed.atom.xml - done") + print("==========") end return makeatomfeed diff --git a/functions/make-lists-of-pages.lua b/functions/make-lists-of-pages.lua @@ -6,7 +6,7 @@ local fileutils = require("functions.file-utils") local tableutils = require("functions.table-utils") local templateutils = require("functions.template-utils") -local function makelistsofpages() +local function makelistsofpages() for file, attr in fileutils.getdirtree(Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT) do if attr.mode ~= "directory" and file:match("^.+/(.+)$") == "index.md" @@ -16,6 +16,9 @@ local function makelistsofpages() local listindex_section = path.dirname(listindex):match("^.+/(.+)$") local listindex_table = {} local listindex_metadatas = json.decode(fileutils.pullfilecontent(listindex:match("(.+)%..*") .. ".json")) + local listindex_relpath = listindex:match("(.+)%..*"):sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT):len() + 1) + + print("§ Make an index page for `" .. listindex_section .. "` section:") -- Convert the markdown file to HTML listindex_metadatas.content = markdown(fileutils.pullfilecontent(listindex)) @@ -38,7 +41,7 @@ local function makelistsofpages() path.dirname(listindex) .. "/*", "f", function(f) if path.extension(f) == ".jpg" or path.extension(f) == ".png" then - lfs.link("." .. f:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. listindex_section):len() + 1), path.dirname(listindex) .. "/" .. f:match("^.+/(.+)$"), true) + lfs.link("." .. f:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. listindex_section):len() + 1), path.dirname(listindex) .. "/" .. f:match("^.+/(.+)$"), true) end end, {recurse = true} @@ -54,12 +57,15 @@ local function makelistsofpages() ) ) + print(" " .. listindex_relpath .. ".html - done") + print("==========") + -- Update the JSON file data listindex_metadatas["entries"] = nil listindex_metadatas["SITE"] = nil fileutils.pushfilecontent(listindex:match("(.+)%..*") .. ".json", json.encode(listindex_metadatas, {indent = true})) end - end + end end return makelistsofpages diff --git a/functions/make-pages.lua b/functions/make-pages.lua @@ -7,7 +7,9 @@ local templateutils = require("functions.template-utils") local function makepages() -- Loop in the content directory - for file, attr in fileutils.getdirtree(Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT) do + print("- Looking for markdown in " .. Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT) + + for file, attr in fileutils.getdirtree(Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT) do if attr.mode ~= "directory" and file:match("^.+(%..+)$") == ".md" and file:match("^.+/(.+)$") ~= "index.md" @@ -48,14 +50,15 @@ local function makepages() ) ) + print("¬ " .. md_relpath .. ".html - done") + -- Update the JSON file data md_metadatas["SITE"] = nil fileutils.pushfilecontent(md_noextension .. ".json", json.encode(md_metadatas, {indent = true})) - end end - return (type(callback) == "function" and callback() or nil) + print("==========") end return makepages diff --git a/functions/move-to-publichtml.lua b/functions/move-to-publichtml.lua @@ -39,6 +39,8 @@ local function movetopublichtml() -- Copy the entire `SITE.PATHS.STATIC` folder in `SITE.PATHS.HTML` path.copy(Ferron.site.path .. Ferron.site.config.SITE.PATHS.STATIC .. "/*", Ferron.site.path .. Ferron.site.config.SITE.PATHS.HTML, {recurse = true}) + + print("Your site is ready at " .. Ferron.site.path .. Ferron.site.config.SITE.PATHS.HTML) end return movetopublichtml diff --git a/functions/template-utils.lua b/functions/template-utils.lua @@ -12,7 +12,7 @@ function templateutils.setmustache(tpl, partialspath, data) if v.type == ">" then partials[v.value] = fileutils.pullfilecontent(partialspath .. "/" .. v.value .. ".mustache") end - end + end return lustache:render(tpl, data, partials) end