ferron

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

commit 921924250ca93b6819e08a6bc7d227cb145e631c
parent 27aa0ad731733a93ed191c401f7ba3a8200c5dd2
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Sat, 25 Nov 2017 08:39:09 -0500

Create symlinks directly in the public_html/ and move all images.

Diffstat:
Mfunctions/dispatch-nontextuals.lua | 27+++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/functions/dispatch-nontextuals.lua b/functions/dispatch-nontextuals.lua @@ -5,27 +5,26 @@ local path = require("path") local tableutils = require("functions.table-utils") local function dispatchnontextuals(file, filesection) - local mimestable = {"image/svg+xml", "image/jpeg", "image/png"} - - -- Create symlinks for images in section's landing page + local mimestable = {"image/svg+xml", "image/jpeg", "image/png", "application/pdf"} + prefetchtable = {} + path.each( path.dirname(file) .. "/*", "f", function(f) if tableutils.hasvalue(mimestable, mimetypes.guess(f)) then local img = f local img_section = filesection - local img_relpath - local img_html = Ferron.site.path .. Ferron.site.config.SITE.PATHS.HTML .. "/" .. img_section .. img:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. img_section):len() + 1) - - -- lfs.link("." .. img:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. img_section):len() + 1), - -- path.dirname(file) .. "/" .. img:match("^.+/(.+)$"), true) - - --print(img_section .. img:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. img_section):len() + 1)) - --print(path.dirname(file) .. "/" .. img:match("^.+/(.+)$")) - --print(img_section) - ---print(img) + local img_name = img:match("^.+/(.+)$") + local img_relpath = img:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. img_section):len() + 1) + local htmlfolder = Ferron.site.path .. Ferron.site.config.SITE.PATHS.HTML + + -- Copy all non-textual contents (jpg, pdf, png, svg, etc.) to `public_html/` + path.copy(img, htmlfolder .. "/" .. img_section .. img_relpath) + + -- Then symlinks from those non-textuals for list index pages + lfs.link("." .. img_relpath, htmlfolder .. "/" .. img_section .. "/" .. img_name, true) - path.copy(img, img_html) + print() end end, {recurse = true}