ferron

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

commit 473c1eef16a7c9b8df3c03d7816e268beaea586d
parent 61a2bd304f10fc900b68dae82d48b2057b8f60e6
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Wed, 22 Nov 2017 07:39:48 -0500

Add a function for deal with the image symlink

Diffstat:
Mfunctions/make-lists-of-pages.lua | 14+++-----------
Afunctions/make-symlinks-for-non-textuals.lua | 21+++++++++++++++++++++
2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/functions/make-lists-of-pages.lua b/functions/make-lists-of-pages.lua @@ -5,6 +5,7 @@ local path = require("path") local fileutils = require("functions.file-utils") local tableutils = require("functions.table-utils") local templateutils = require("functions.template-utils") +local makesymlinksfornontextuals = require("functions.make-symlinks-for-non-textuals") local function makelistsofpages() for file, attr in fileutils.getdirtree(Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT) do @@ -39,17 +40,8 @@ local function makelistsofpages() end end - -- Create symlinks for images in section's landing page - -- @TODO Create a table with all mime/type accpeted instead of a list of extensions - path.each( - path.dirname(listindex) .. "/*", "f", - function(f) - if path.extension(f) == ".jpg" or path.extension(f) == ".png" then - lfs.link("." .. f:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. listindex_section):len() + 1), path.dirname(listindex) .. "/" .. f:match("^.+/(.+)$"), true) - end - end, - {recurse = true} - ) + -- Create symlinks for images in section's landing page + makesymlinksfornontextuals(listindex, listindex_section) if path.isdir(listindex_pathhtml) == false then fileutils.mkdir(listindex_pathhtml) diff --git a/functions/make-symlinks-for-non-textuals.lua b/functions/make-symlinks-for-non-textuals.lua @@ -0,0 +1,21 @@ +-- +local lfs = require("lfs") +local mimetypes = require('mimetypes') +local path = require("path") + +local function movenontextuals(file, filesection) + -- Create symlinks for images in section's landing page + -- @TODO Create a table with all mime/type accpeted instead of a list of extensions + path.each( + path.dirname(file) .. "/*", "f", + function(f) + if path.extension(f) == ".jpg" or path.extension(f) == ".png" then + -- lfs.link("." .. f:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. filesection):len() + 1), path.dirname(file) .. "/" .. f:match("^.+/(.+)$"), true) + print(f) + end + end, + {recurse = true} + ) +end + +return movenontextuals