ferron

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

commit 69ca7dd4c661e32f130d2ad60418c2e0156d1be1
parent 0d1e88071242b5e378eabb4ed6f5b6546c46f3ee
Author: Hugo Soucy <hsoucy@kronostechnologies.com>
Date:   Fri, 30 Nov 2018 13:33:01 -0500

Add a method to get the folder of a file.

Diffstat:
Mferron/list.lua | 7++++++-
Mferron/utilities/file-utils.lua | 4++++
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ferron/list.lua b/ferron/list.lua @@ -105,8 +105,13 @@ end function list.init() local contentpath = assert(fileutils.isDirectory(Ferron.site.path .. Ferron.site.config.paths.content)) - tableutils.each(list.render, tableutils.filter(fileutils.isIndex, tableutils.settable(fileutils.getdirtree(contentpath)))) + local function test(pth) + print(fileutils.getdirname(pth)) + end + -- tableutils.each(list.render, tableutils.filter(fileutils.isIndex, tableutils.settable(fileutils.getdirtree(contentpath)))) + tableutils.each(test, tableutils.filter(fileutils.isIndex, tableutils.settable(fileutils.getdirtree(contentpath)))) + os.exit('1') return end diff --git a/ferron/utilities/file-utils.lua b/ferron/utilities/file-utils.lua @@ -130,6 +130,10 @@ function fileutils.getplainname(file) return fileutils.removeextension(file):match("^.+/(.+)$") end +function fileutils.getdirname(file) + return file:match("(.*/)") +end + function fileutils.shorturlencode(num) local alphabet = "23456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ-_" local base = alphabet:len()