ferron

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

commit 62cb4bfe763e2c4da8582275f034cccd6fbfeb23
parent 450ff8be50ecae685279cdd16d5f5125358c8666
Author: Hugo Soucy <hsoucy@kronostechnologies.com>
Date:   Tue, 18 Dec 2018 13:20:15 -0500

Replace concatened paths with the site.paths form

Diffstat:
Mferron/content.lua | 12++++++------
Mferron/feed.lua | 5+++--
Mferron/link.lua | 8++++----
Mferron/list.lua | 5+++--
Mferron/page.lua | 5+++--
Mferron/static.lua | 9++++-----
Mferron/tag.lua | 13++++++-------
7 files changed, 29 insertions(+), 28 deletions(-)

diff --git a/ferron/content.lua b/ferron/content.lua @@ -3,18 +3,18 @@ ]]-- -- Required Packages -local path = require "path" local fileutils = require "ferron.utilities.file-utils" local slugify = require "ferron.utilities.lua-slugify.slugify" local tableutils = require "ferron.utilities.table-utils" local templateutils = require "ferron.utilities.template-utils" +local site = require "ferron.site" -- Module Declaration local content = {} function content.getarchetypes(dir) local archetypes = {} - local archetypesdir = (dir ~= nil and dir or Ferron.site.path .. Ferron.site.config.paths.archetypes) + local archetypesdir = (dir ~= nil and dir or site.paths.archetypes) if fileutils.isDirectory(archetypesdir) then for archetype, attr in fileutils.getdirtree(archetypesdir) do @@ -63,8 +63,8 @@ function content.makecontent(contenttype, contenttitle) if tableutils.hasvalue(content.getarchetypes(), archetypetype) and type(title) == "string" then local archetype = {} - local contentpath = Ferron.site.path .. Ferron.site.config.paths.content .. "/" .. archetypetype .. "/" .. os.date("%Y") .."/"..os.date("%m") .. "/" - local archetypepath = Ferron.site.path .. Ferron.site.config.paths.archetypes .. "/" + local contentpath = site.paths.content .. "/" .. archetypetype .. "/" .. os.date("%Y") .."/"..os.date("%m") .. "/" + local archetypepath = site.paths.archetypes .. "/" archetype.title = title archetype.filename = slugify(archetype.title) @@ -81,7 +81,7 @@ function content.makecontent(contenttype, contenttitle) contentpath .. archetype.filename .. ".md", templateutils.rendermustache( fileutils.pullfilecontent(archetypepath .. archetypetype .. ".md" ), - Ferron.site.path .. Ferron.site.config.paths.templates .. "/partials", + site.paths.templates .. "/partials", archetype ) ) @@ -91,7 +91,7 @@ function content.makecontent(contenttype, contenttitle) contentpath .. archetype.filename .. ".json", templateutils.rendermustache( fileutils.pullfilecontent(archetypepath .. archetypetype .. ".json"), - Ferron.site.path .. Ferron.site.config.paths.templates .. "/partials", + site.paths.templates .. "/partials", archetype ) ) diff --git a/ferron/feed.lua b/ferron/feed.lua @@ -2,14 +2,15 @@ local fileutils = require "ferron.utilities.file-utils" local tableutils = require "ferron.utilities.table-utils" local templateutils = require "ferron.utilities.template-utils" +local site = require "ferron.site" local feed = {} function feed.makefeed(entries, destination) local feedtypes = Ferron.site.config.feedtypes - local feedpartials = fileutils.isDirectory(Ferron.site.path .. Ferron.site.config.paths.templates .. "/partials") + local feedpartials = fileutils.isDirectory(site.paths.templates .. "/partials") for k, v in pairs(feedtypes) do - local feedtemplate = Ferron.site.path .. Ferron.site.config.paths.templates .. "/feed/" .. k .. ".mustache" + local feedtemplate = site.paths.templates .. "/feed/" .. k .. ".mustache" if fileutils.isFile(feedtemplate) then fileutils.pushfilecontent( diff --git a/ferron/link.lua b/ferron/link.lua @@ -1,15 +1,15 @@ -- @TODO Make sure to always keep the alphanumerical order local json = require "dkjson" -local path = require "path" local fileutils = require "ferron.utilities.file-utils" local tableutils = require "ferron.utilities.table-utils" local templateutils = require "ferron.utilities.template-utils" +local site = require "ferron.site" local link = {} function link.makeshorts() local links = {} local links_keyorder = {} - local links_db = Ferron.site.path .. Ferron.site.config.paths.data .. "/shortlinks.json" + local links_db = site.paths.data .. "/shortlinks.json" -- If `links_db` dosen't exists create it if fileutils.isFile(links_db) == false then @@ -44,8 +44,8 @@ function link.makeshorts() end function link.makerewritemap() - local links_db = Ferron.site.path .. Ferron.site.config.paths.data .. "/shortlinks.json" - local links_map = Ferron.site.path .. Ferron.site.config.paths.html .. "/shortlinksmap.txt" + local links_db = site.paths.data .. "/shortlinks.json" + local links_map = site.paths.html .. "/shortlinksmap.txt" if fileutils.isFile(links_db) then links = json.decode(fileutils.pullfilecontent(links_db)) diff --git a/ferron/list.lua b/ferron/list.lua @@ -6,6 +6,7 @@ local tableutils = require "ferron.utilities.table-utils" local templateutils = require "ferron.utilities.template-utils" local feed = require "ferron.feed" local static = require "ferron.static" +local site = require "ferron.site" local list = {} @@ -88,13 +89,13 @@ function list.render(listsource) templateutils.rendertemplate( templateutils.selecttemplate(false, list_conf.template), list_conf_mt, - Ferron.site.path .. Ferron.site.config.paths.templates .. "/partials" + site.paths.templates .. "/partials" ) ) end function list.init() - local contentpath = assert(fileutils.isDirectory(Ferron.site.path .. Ferron.site.config.paths.content)) + local contentpath = assert(fileutils.isDirectory(site.paths.content)) tableutils.each(list.render, tableutils.filter(fileutils.isIndex, tableutils.settable(fileutils.getdirtree(contentpath)))) diff --git a/ferron/page.lua b/ferron/page.lua @@ -4,6 +4,7 @@ local markdown = require "discount" local fileutils = require "ferron.utilities.file-utils" local tableutils = require "ferron.utilities.table-utils" local templateutils = require "ferron.utilities.template-utils" +local site = require "ferron.site" local page = {} function page.render(pagesource) @@ -37,7 +38,7 @@ function page.render(pagesource) templateutils.rendertemplate( templateutils.selecttemplate(false, page_conf.template), page_conf_mt, - assert(fileutils.isDirectory(Ferron.site.path .. Ferron.site.config.paths.templates)) .. "/partials" + assert(fileutils.isDirectory(site.paths.templates)) .. "/partials" ) ) --print(page) @@ -45,7 +46,7 @@ function page.render(pagesource) end function page.init() - local contentpath = assert(fileutils.isDirectory(Ferron.site.path .. Ferron.site.config.paths.content)) + local contentpath = assert(fileutils.isDirectory(site.paths.content)) tableutils.each(page.render, tableutils.filter(fileutils.isNotIndex, tableutils.settable(fileutils.getdirtree(contentpath)))) diff --git a/ferron/static.lua b/ferron/static.lua @@ -10,21 +10,20 @@ local site = require "ferron.site" local static = {} local function dispatch(file) - return os.execute("cp -p " .. file .. " " .. Ferron.site.path .. Ferron.site.config.paths.html) + return os.execute("cp -p " .. file .. " " .. site.paths.html) end local function move() - return os.execute("cp -Rp " .. Ferron.site.path .. Ferron.site.config.paths.static .. "/*" .. " " .. Ferron.site.path .. Ferron.site.config.paths.html) + return os.execute("cp -Rp " .. site.paths.static .. "/*" .. " " .. site.paths.html) end function static.init() - local contentpath = assert(fileutils.isDirectory(Ferron.site.path .. Ferron.site.config.paths.content)) + local contentpath = assert(fileutils.isDirectory(site.paths.content)) tableutils.each(dispatch, tableutils.filter(fileutils.isNonTextual, tableutils.settable(fileutils.getdirtree(contentpath)))) move() - print(inspect(site.site)) - print("¤¤ Your site is ready at `" .. Ferron.site.path .. Ferron.site.config.paths.html .. "` ¤¤") + print("¤¤ Your site is ready at `" .. site.paths.html .. "` ¤¤") return end diff --git a/ferron/tag.lua b/ferron/tag.lua @@ -1,9 +1,9 @@ -- local json = require "dkjson" -local path = require "path" local fileutils = require "ferron.utilities.file-utils" local tableutils = require "ferron.utilities.table-utils" local templateutils = require "ferron.utilities.template-utils" +local site = require "ferron.site" local tag = {} local function maketagstable() @@ -35,7 +35,6 @@ end function tag.maketagpage() local tagstable = maketagstable() - local htmlpath = Ferron.site.path .. Ferron.site.config.paths.html for tag, urls in pairs(tagstable) do local tag_tb = { @@ -43,16 +42,16 @@ function tag.maketagpage() tagurls = urls } - if fileutils.isDirectory(htmlpath .. "/tag") == false then - fileutils.mkdir(htmlpath .. "/tag") + if fileutils.isDirectory(site.paths.html .. "/tag") == false then + fileutils.mkdir(site.paths.html .. "/tag") end -- Build the HTML file fileutils.pushfilecontent( - htmlpath .. "/tag/" .. tag .. ".html", + site.paths.html .. "/tag/" .. tag .. ".html", templateutils.rendermustache( - fileutils.pullfilecontent(Ferron.site.path .. Ferron.site.config.paths.templates .. "/tag.mustache"), - Ferron.site.path .. Ferron.site.config.paths.templates .. "/partials", + fileutils.pullfilecontent(site.paths.templates .. "/tag.mustache"), + site.paths.templates .. "/partials", tag_tb ) )