ferron

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

commit e35d2bf24f6dbc4cf4942d6bcbffb67add4aabba
parent 79d33a27143dcaf6e685d8dae8241a595d1c755d
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Wed, 31 Jan 2018 21:36:56 -0500

Move ferronutils functions in fileutils

Diffstat:
Mferron/dispatch-nontextuals.lua | 2+-
Dferron/ferron-utils.lua | 25-------------------------
Mferron/make-lists-of-pages.lua | 8++++----
Mferron/make-pages.lua | 6+++---
4 files changed, 8 insertions(+), 33 deletions(-)

diff --git a/ferron/dispatch-nontextuals.lua b/ferron/dispatch-nontextuals.lua @@ -16,7 +16,7 @@ local function dispatchnontextuals(file) local listindex_dirname = path.dirname(file) local img = f local img_name = img:match("^.+/(.+)$") - local img_relpath = ferronutils.getrelpath(img) + local img_relpath = fileutils.getrelpath(img) local htmlfolder = Ferron.site.path .. Ferron.site.config.SITE.PATHS.HTML -- Then symlinks from those non-textuals for list index pages diff --git a/ferron/ferron-utils.lua b/ferron/ferron-utils.lua @@ -1,25 +0,0 @@ --- -local ferronutils = {} - -function ferronutils.getrelpath(file) - return file:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT):len() + 1) -end - -function ferronutils.sethtmlpath(folder) - return Ferron.site.path .. Ferron.site.config.SITE.PATHS.HTML .. folder -end - -function ferronutils.shorturlencode(num) - local alphabet = "23456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ-_" - local base = alphabet:len() - local str = "" - - while num > 0 do - str = string.sub(alphabet, num % base, num % base) .. str - num = math.floor(num / base) - end - - return str -end - -return ferronutils diff --git a/ferron/make-lists-of-pages.lua b/ferron/make-lists-of-pages.lua @@ -19,15 +19,15 @@ local function makelistsofpages() local listindex_noextension = listindex:match("(.+)%..*") local listindex_plainname = listindex_noextension:match("^.+/(.+)$") local listindex_dir = path.dirname(listindex) - local listindex_relpath = ferronutils.getrelpath(listindex_noextension) - local listindex_htmlpath = ferronutils.sethtmlpath(ferronutils.getrelpath(path.dirname(listindex))) + local listindex_relpath = fileutils.getrelpath(listindex_noextension) + local listindex_htmlpath = fileutils.sethtmlpath(fileutils.getrelpath(path.dirname(listindex))) local listindex_section = path.dirname(listindex):match("^.+/(.+)$") local listindex_metadatas = json.decode(fileutils.pullfilecontent(listindex_noextension .. ".json")) local listindex_metadatas_mt = setmetatable({}, { __index = listindex_metadatas }) local listindex_length = listindex_metadatas_mt.length ~= nil and listindex_metadatas_mt.length or nil local pagecounter = listindex_length ~= nil and 0 or nil - print("§ Make an index page for the `" .. ferronutils.getrelpath(listindex_dir) .. "` section ...") + print("§ Make an index page for the `" .. fileutils.getrelpath(listindex_dir) .. "` section ...") -- Convert the markdown file to HTML listindex_metadatas_mt.content = markdown(fileutils.pullfilecontent(listindex)) @@ -46,7 +46,7 @@ local function makelistsofpages() function(md) if path.basename(md) ~= "index.md" or md == contentpath .. "/index.md" then local md_noextension = md:match("(.+)%..*") - local md_relpath = ferronutils.getrelpath(md_noextension) + local md_relpath = fileutils.getrelpath(md_noextension) local md_section = md_relpath:match("/(%a-)/") local md_metadatas = json.decode(fileutils.pullfilecontent(md_noextension .. ".json")) local md_key = md_metadatas.date .. "|" .. md_metadatas.datetime .. "|" .. (md_section ~= nil and md_section or "root") .. "|" .. md_relpath diff --git a/ferron/make-pages.lua b/ferron/make-pages.lua @@ -24,8 +24,8 @@ local function makepages() local md = md local md_noextension = md:match("(.+)%..*") local md_plainname = md_noextension:match("^.+/(.+)$") - local md_relpath = ferronutils.getrelpath(md_noextension) - local md_htmlpath = ferronutils.sethtmlpath(ferronutils.getrelpath(path.dirname(md))) + local md_relpath = fileutils.getrelpath(md_noextension) + local md_htmlpath = fileutils.sethtmlpath(fileutils.getrelpath(path.dirname(md))) local md_section = md_relpath:match("/(%a-)/") local md_metadatas = json.decode(fileutils.pullfilecontent(md_noextension .. ".json")) local md_metadatas_mt = setmetatable({}, { __index = md_metadatas }) @@ -76,7 +76,7 @@ local function makepages() ) -- for k, v in pairs(pagesrelpath) do - -- shortlinks[v] = ferronutils.shorturlencode(k) + -- shortlinks[v] = fileutils.shorturlencode(k) -- end -- print(inspect(shortlinks))