commit 9ebea28752f9c1b2fbba0078c68a74502494c1d8
parent be4034481f4fb7e895509f337c1eb12e1c42f955
Author: Hugo Soucy <hugo@soucy.cc>
Date: Tue, 30 Jan 2018 15:19:51 -0500
Refactoring the dispatchnontextuals function
Diffstat:
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/functions/dispatch-nontextuals.lua b/functions/dispatch-nontextuals.lua
@@ -4,24 +4,29 @@ local mimetypes = require('mimetypes')
local path = require("path")
local tableutils = require("functions.table-utils")
-local function dispatchnontextuals(file, filesection)
+local function dispatchnontextuals(file)
local mimestable = Ferron.site.config.SITE.MIMETYPES
path.each(
path.dirname(file) .. "/*", "f",
function(f)
if tableutils.hasvalue(mimestable, mimetypes.guess(f)) then
+ local file_dirname = path.dirname(file)
local img = f
- local img_section = filesection
local img_name = img:match("^.+/(.+)$")
- local img_relpath = img:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. img_section):len() + 1)
+ local img_relpath = img:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT):len() + 1)
+ local img_section_relpath = file_dirname:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT):len() + 1)
+ local img_dir_relpath = img_section_relpath:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT):len() + 1)
local htmlfolder = Ferron.site.path .. Ferron.site.config.SITE.PATHS.HTML
+ -- Then symlinks from those non-textuals for list index pages
+ --lfs.link("." .. img_relpath, htmlfolder .. "/" .. img_section .. "/" .. img_name, true)
+
-- Copy all non-textual contents (jpg, pdf, png, svg, etc.) to `public_html/`
- path.copy(img, htmlfolder .. "/" .. img_section .. img_relpath)
+ path.copy(img, htmlfolder .. img_relpath)
- -- Then symlinks from those non-textuals for list index pages
- lfs.link("." .. img_relpath, htmlfolder .. "/" .. img_section .. "/" .. img_name, true)
+ -- print("." .. img_dir_relpath .. "/" .. img_name)
+ print(img_section_relpath)
end
end,
{recurse = true}
diff --git a/functions/make-lists-of-pages.lua b/functions/make-lists-of-pages.lua
@@ -88,7 +88,7 @@ local function makelistsofpages()
fileutils.mkdir(listindex_htmlpath)
end
- dispatchnontextuals(listindex, listindex_section)
+ dispatchnontextuals(listindex)
-- Build the HTML file
fileutils.pushfilecontent(