ferron

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

commit 1fd4bb0083ce54a8fc11019ed53e0b211c20eb38
parent 69ca7dd4c661e32f130d2ad60418c2e0156d1be1
Author: Hugo Soucy <hsoucy@kronostechnologies.com>
Date:   Fri,  7 Dec 2018 14:08:30 -0500

Move the function isnotindex in fileutils + remove path utilisations

Diffstat:
Mferron/page.lua | 14++------------
Mferron/utilities/file-utils.lua | 10++++++++++
2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/ferron/page.lua b/ferron/page.lua @@ -1,23 +1,14 @@ -- local json = require "dkjson" local markdown = require "discount" -local path = require "path" local fileutils = require "ferron.utilities.file-utils" local tableutils = require "ferron.utilities.table-utils" local templateutils = require "ferron.utilities.template-utils" local page = {} -function page.isNotIndexPage(pagepath) - if fileutils.isMarkdown(pagepath) and not fileutils.isIndex(pagepath) then - return pagepath - end - - return -end - function page.render(pagesource) local page = pagesource - local page_htmlpath = fileutils.sethtmlpath(fileutils.getrelpath(path.dirname(page))) + local page_htmlpath = fileutils.sethtmlpath(fileutils.getrelpath(fileutils.getdirname(page))) local page_conf = json.decode(fileutils.pullfilecontent(fileutils.removeextension(page) .. ".json")) local page_conf_mt = setmetatable({}, { __index = page_conf }) local page_key = page_conf.date .. "|" .. page_conf.datetime .. "|" .. fileutils.getrelpath(fileutils.removeextension(page)) @@ -49,7 +40,6 @@ function page.render(pagesource) assert(fileutils.isDirectory(Ferron.site.path .. Ferron.site.config.paths.templates)) .. "/partials" ) ) - --print(page) return end @@ -57,7 +47,7 @@ end function page.init() local contentpath = assert(fileutils.isDirectory(Ferron.site.path .. Ferron.site.config.paths.content)) - tableutils.each(page.render, tableutils.filter(page.isNotIndexPage, tableutils.settable(fileutils.getdirtree(contentpath)))) + tableutils.each(page.render, tableutils.filter(fileutils.isNotIndex, tableutils.settable(fileutils.getdirtree(contentpath)))) print("==========") print("ยง " .. tableutils.length(Ferron.site.pagestable) .. " HTML pages have been created.") diff --git a/ferron/utilities/file-utils.lua b/ferron/utilities/file-utils.lua @@ -50,6 +50,16 @@ function fileutils.isIndex(filepath) return false end +function fileutils.isNotIndex(filepath) + if fileutils.isMarkdown(filepath) == false then + return false + elseif fileutils.isMarkdown(filepath) and not fileutils.isIndex(filepath) then + return filepath + end + + return false +end + function fileutils.isNonTextual(file) local mimestable = Ferron.site.config.mimetypes