ferron

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

commit 2776fef553fabe98fab83f48646a816238f5d02b
parent 27d4adc1e45c8113294360eb50b6cf2aa4e49b89
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Sun, 19 Aug 2018 20:33:04 -0400

Test symlinks with luaposix

Diffstat:
Mferron/static.lua | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/ferron/static.lua b/ferron/static.lua @@ -6,6 +6,7 @@ local lfs = require "lfs" local mimetypes = require 'mimetypes' local path = require "path" +local posix = require "posix" local fileutils = require "ferron.utilities.file-utils" local tableutils = require "ferron.utilities.table-utils" @@ -13,13 +14,12 @@ local tableutils = require "ferron.utilities.table-utils" local static = {} function static.dispatch(file) - local mimestable = Ferron.site.siteconfig.mimetypes + local mimestable = Ferron.site.siteconfig.mimetypes path.each( path.dirname(file) .. "/*", "f", function(f) if tableutils.hasvalue(mimestable, mimetypes.guess(f)) then - print(f) local listindex_dirname = path.dirname(file) local img = f local img_name = img:match("^.+/(.+)$") @@ -27,10 +27,16 @@ function static.dispatch(file) local htmlfolder = Ferron.site.path .. Ferron.site.siteconfig.paths.html -- Then symlinks from those non-textuals for list index pages - lfs.link("." .. img:sub((listindex_dirname):len() + 1), listindex_dirname .. "/" .. img_name, true) + if not posix.readlink(img) then + lfs.link("." .. img:sub((listindex_dirname):len() + 1), listindex_dirname .. "/" .. img_name, true) + + path.copy(img, htmlfolder .. img_relpath) + end -- Copy all non-textual contents (jpg, pdf, png, svg, etc.) to `public_html/` - path.copy(img, htmlfolder .. img_relpath) + if posix.readlink(img) then + path.rename(img, htmlfolder .. img_relpath) + end end end, {recurse = true}