ferron

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

commit b050379098957b5fbcb52227412ab694b40e2fea
parent 10312d5c893de6cc91997c73d1931a292421f15b
Author: Hugo Soucy <hsoucy@kronostechnologies.com>
Date:   Fri, 12 Oct 2018 14:33:54 -0400

Rename site-config in config ... move ferron config in ferron dir

Diffstat:
Mcornelius | 2+-
Rconfig.lua -> ferron/config.lua | 0
Mferron/content.lua | 10+++++-----
Mferron/feed.lua | 6+++---
Mferron/link.lua | 6+++---
Mferron/list.lua | 12++++++------
Mferron/page.lua | 14+++++++-------
Mferron/site.lua | 10+++++-----
Mferron/static.lua | 8++++----
Mferron/tag.lua | 6+++---
Mferron/utilities/file-utils.lua | 6+++---
Rsites/ferron-ssg.tld/site-config.lua -> sites/ferron-ssg.tld/config.lua | 0
12 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/cornelius b/cornelius @@ -3,7 +3,7 @@ -- Cornelius Ferron is the CLI of Ferron SSG and it's a WIP. -- <https://en.wikipedia.org/wiki/Cornelius_the_First> -local config = require "config" +local config = require "ferron.config" if arg[1] == "install" and tonumber(_VERSION:match("%d+%.%d+")) >= config.dependencies.lua then -- First, check if luarocks is present in the env. diff --git a/config.lua b/ferron/config.lua diff --git a/ferron/content.lua b/ferron/content.lua @@ -14,7 +14,7 @@ local content = {} function content.getarchetypes(dir) local archetypes = {} - local archetypesdir = (dir ~= nil and dir or Ferron.site.path .. Ferron.site.siteconfig.paths.archetypes) + local archetypesdir = (dir ~= nil and dir or Ferron.site.path .. Ferron.site.config.paths.archetypes) if path.isdir(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.siteconfig.paths.content .. "/" .. archetypetype .. "/" .. os.date("%Y") .."/"..os.date("%m") .. "/" - local archetypepath = Ferron.site.path .. Ferron.site.siteconfig.paths.archetypes .. "/" + 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 .. "/" archetype.title = title archetype.filename = slugify(archetype.title) @@ -81,7 +81,7 @@ function content.makecontent(contenttype, contenttitle) contentpath .. archetype.filename .. ".md", templateutils.processmustache( fileutils.pullfilecontent(archetypepath .. archetypetype .. ".md" ), - Ferron.site.path .. Ferron.site.siteconfig.paths.templates .. "/partials", + Ferron.site.path .. Ferron.site.config.paths.templates .. "/partials", archetype ) ) @@ -91,7 +91,7 @@ function content.makecontent(contenttype, contenttitle) contentpath .. archetype.filename .. ".json", templateutils.processmustache( fileutils.pullfilecontent(archetypepath .. archetypetype .. ".json"), - Ferron.site.path .. Ferron.site.siteconfig.paths.templates .. "/partials", + Ferron.site.path .. Ferron.site.config.paths.templates .. "/partials", archetype ) ) diff --git a/ferron/feed.lua b/ferron/feed.lua @@ -6,11 +6,11 @@ local templateutils = require "ferron.utilities.template-utils" local feed = {} function feed.makefeed(entries, destination) - local feedtypes = Ferron.site.siteconfig.feedtypes - local feedpartials = path.isdir(Ferron.site.path .. Ferron.site.siteconfig.paths.templates .. "/partials") + local feedtypes = Ferron.site.config.feedtypes + local feedpartials = path.isdir(Ferron.site.path .. Ferron.site.config.paths.templates .. "/partials") for k, v in pairs(feedtypes) do - local feedtemplate = Ferron.site.path .. Ferron.site.siteconfig.paths.templates .. "/feed/" .. k .. ".mustache" + local feedtemplate = Ferron.site.path .. Ferron.site.config.paths.templates .. "/feed/" .. k .. ".mustache" if path.isfile(feedtemplate) then fileutils.pushfilecontent( diff --git a/ferron/link.lua b/ferron/link.lua @@ -9,7 +9,7 @@ local link = {} function link.makeshorts() local links = {} local links_keyorder = {} - local links_db = Ferron.site.path .. Ferron.site.siteconfig.paths.data .. "/shortlinks.json" + local links_db = Ferron.site.path .. Ferron.site.config.paths.data .. "/shortlinks.json" -- If `links_db` dosen't exists create it if path.isfile(links_db) == false then @@ -44,8 +44,8 @@ function link.makeshorts() end function link.makerewritemap() - local links_db = Ferron.site.path .. Ferron.site.siteconfig.paths.data .. "/shortlinks.json" - local links_map = Ferron.site.path .. Ferron.site.siteconfig.paths.html .. "/shortlinksmap.txt" + 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" if path.isfile(links_db) then links = json.decode(fileutils.pullfilecontent(links_db)) diff --git a/ferron/list.lua b/ferron/list.lua @@ -32,7 +32,7 @@ local function sortentries(entries_tb, list_mt) end local function setentries(directory, list_mt) - local contentpath = Ferron.site.path .. Ferron.site.siteconfig.paths.content + local contentpath = Ferron.site.path .. Ferron.site.config.paths.content local entries_tb = {} path.each( @@ -58,8 +58,8 @@ local function setentries(directory, list_mt) end function list.makelist() - local contentpath = Ferron.site.path .. Ferron.site.siteconfig.paths.content - local templatespath = Ferron.site.path .. Ferron.site.siteconfig.paths.templates + local contentpath = Ferron.site.path .. Ferron.site.config.paths.content + local templatespath = Ferron.site.path .. Ferron.site.config.paths.templates path.each( contentpath .. "/index.md", @@ -74,9 +74,9 @@ function list.makelist() -- Convert the markdown file to HTML list_conf_mt.content = markdown(fileutils.pullfilecontent(list)) -- Set a dynamic permalink - list_conf_mt.permalink = Ferron.site.siteconfig.baseurl .. path.dirname(fileutils.getrelpath(fileutils.removeextension(list))) + list_conf_mt.permalink = Ferron.site.config.baseurl .. path.dirname(fileutils.getrelpath(fileutils.removeextension(list))) -- Import site configuration in the metatable - list_conf_mt["site"] = Ferron.site.siteconfig + list_conf_mt["site"] = Ferron.site.config -- Set a table for the list of entries list_conf_mt["entries"] = {} @@ -100,7 +100,7 @@ function list.makelist() -- Update the JSON file data fileutils.pushfilecontent( fileutils.removeextension(list) .. ".json", - json.encode(list_conf, {indent = true, keyorder = Ferron.site.siteconfig.metaskeyorder}) + json.encode(list_conf, {indent = true, keyorder = Ferron.site.config.metaskeyorder}) ) -- Build and push the HTML page diff --git a/ferron/page.lua b/ferron/page.lua @@ -8,9 +8,9 @@ local templateutils = require "ferron.utilities.template-utils" local page = {} function page.makepage() - local contentpath = Ferron.site.path .. Ferron.site.siteconfig.paths.content - local templatespath = Ferron.site.path .. Ferron.site.siteconfig.paths.templates - local shortlinks_db = path.isfile(Ferron.site.path .. Ferron.site.siteconfig.paths.data .. "/shortlinks.json") + local contentpath = Ferron.site.path .. Ferron.site.config.paths.content + local templatespath = Ferron.site.path .. Ferron.site.config.paths.templates + local shortlinks_db = path.isfile(Ferron.site.path .. Ferron.site.config.paths.data .. "/shortlinks.json") local shortlinks_tb = (shortlinks_db ~= false and json.decode(fileutils.pullfilecontent(shortlinks_db)) or nil) -- Loop in the content directory @@ -27,16 +27,16 @@ function page.makepage() local page_key = page_conf.date .. "|" .. page_conf.datetime .. "|" .. fileutils.getrelpath(fileutils.removeextension(page)) local page_template = templatespath .. "/" .. (page_conf.template ~= nil and page_conf.template or "default") .. ".mustache" - page_conf.id = "tag:" .. Ferron.site.siteconfig.domainname .. "," .. page_conf.date .. ":" .. string.sub(page_conf.date, 0, 4) .. "/" .. string.sub(page_conf.date, 6, 7) .. "/" .. fileutils.getplainname(page) + page_conf.id = "tag:" .. Ferron.site.config.domainname .. "," .. page_conf.date .. ":" .. string.sub(page_conf.date, 0, 4) .. "/" .. string.sub(page_conf.date, 6, 7) .. "/" .. fileutils.getplainname(page) -- Convert the markdown file to HTML -- And put it in a metatable page_conf_mt.content = markdown(fileutils.pullfilecontent(page)) page_conf_mt.updated = os.date("%Y-%m-%dT%H:%M:%S", path.mtime(page)) - page_conf_mt.permalink = Ferron.site.siteconfig.baseurl .. (fileutils.getplainname(page) ~= "index" and fileutils.getrelpath(fileutils.removeextension(page)) .. ".html" or "") + page_conf_mt.permalink = Ferron.site.config.baseurl .. (fileutils.getplainname(page) ~= "index" and fileutils.getrelpath(fileutils.removeextension(page)) .. ".html" or "") page_conf_mt.rellink = (fileutils.getplainname(page) ~= "index" and fileutils.getrelpath(fileutils.removeextension(page)) .. ".html" or "") - page_conf_mt["site"] = Ferron.site.siteconfig + page_conf_mt["site"] = Ferron.site.config -- If exists set the shortlink if shortlinks_tb ~= nil and shortlinks_db ~= nil then @@ -53,7 +53,7 @@ function page.makepage() -- Update the JSON file data fileutils.pushfilecontent( fileutils.removeextension(page) .. ".json", - json.encode(page_conf, {indent = true, keyorder = Ferron.site.siteconfig.metaskeyorder}) + json.encode(page_conf, {indent = true, keyorder = Ferron.site.config.metaskeyorder}) ) -- Build and push the HTML page diff --git a/ferron/site.lua b/ferron/site.lua @@ -1,5 +1,5 @@ local path = require "path" -local config = require "config" +local config = require "ferron.config" local tableutils = require "ferron.utilities.table-utils" local fileutils = require "ferron.utilities.file-utils" @@ -23,11 +23,11 @@ end function site.getsiteinfos(sitename) package.path = package.path .. ";sites/".. sitename .."/?.lua" - local site_config = require "site-config" + local site_config = require "config" -- Create a table with the basic infos of the site local site_infos = { path = site.location .. sitename, - siteconfig = tableutils.extend({}, config, site_config), + config = tableutils.extend({}, config, site_config), pagestable = {}, } @@ -56,7 +56,7 @@ function site.setsite(name) end Ferron.site = site.getsiteinfos((name ~= nil and name or sites_list[tonumber(whichsite)])) - Ferron.site.siteconfig.baseurl = (Ferron.devmode == true and Ferron.site.siteconfig.urldev or Ferron.site.siteconfig.url) + Ferron.site.config.baseurl = (Ferron.devmode == true and Ferron.site.config.urldev or Ferron.site.config.url) return Ferron.site end @@ -88,7 +88,7 @@ end function site.reset() -- Reset the `public_html/` folder of the selected site - return fileutils.emptydirectory(Ferron.site.path .. Ferron.site.siteconfig.paths.html .. "/") + return fileutils.emptydirectory(Ferron.site.path .. Ferron.site.config.paths.html .. "/") end return site diff --git a/ferron/static.lua b/ferron/static.lua @@ -20,7 +20,7 @@ function static.dispatch(file) if fileutils.isNonTextual(f) then local listindex_dirname = path.dirname(file) local img = f - local htmlfolder = Ferron.site.path .. Ferron.site.siteconfig.paths.html + local htmlfolder = Ferron.site.path .. Ferron.site.config.paths.html if not posix.readlink(img) then -- Copy content's images in the `public_html/` directory @@ -42,12 +42,12 @@ end function static.move() -- Copy the entire `siteconfig.paths.static` folder in `siteconfig.paths.html` path.copy( - Ferron.site.path .. Ferron.site.siteconfig.paths.static .. "/*", - Ferron.site.path .. Ferron.site.siteconfig.paths.html, + Ferron.site.path .. Ferron.site.config.paths.static .. "/*", + Ferron.site.path .. Ferron.site.config.paths.html, {recurse = true} ) - print("¤¤ Your site is ready at `" .. Ferron.site.path .. Ferron.site.siteconfig.paths.html .. "` ¤¤") + print("¤¤ Your site is ready at `" .. Ferron.site.path .. Ferron.site.config.paths.html .. "` ¤¤") end return static diff --git a/ferron/tag.lua b/ferron/tag.lua @@ -35,7 +35,7 @@ end function tag.maketagpage() local tagstable = maketagstable() - local htmlpath = Ferron.site.path .. Ferron.site.siteconfig.paths.html + local htmlpath = Ferron.site.path .. Ferron.site.config.paths.html for tag, urls in pairs(tagstable) do local tag_tb = { @@ -51,8 +51,8 @@ function tag.maketagpage() fileutils.pushfilecontent( htmlpath .. "/tag/" .. tag .. ".html", templateutils.processmustache( - fileutils.pullfilecontent(Ferron.site.path .. Ferron.site.siteconfig.paths.templates .. "/tag.mustache"), - Ferron.site.path .. Ferron.site.siteconfig.paths.templates .. "/partials", + fileutils.pullfilecontent(Ferron.site.path .. Ferron.site.config.paths.templates .. "/tag.mustache"), + Ferron.site.path .. Ferron.site.config.paths.templates .. "/partials", tag_tb ) ) diff --git a/ferron/utilities/file-utils.lua b/ferron/utilities/file-utils.lua @@ -7,7 +7,7 @@ local tableutils = require "ferron.utilities.table-utils" local fileutils = {} function fileutils.isNonTextual(file) - local mimestable = Ferron.site.siteconfig.mimetypes + local mimestable = Ferron.site.config.mimetypes return (tableutils.hasvalue(mimestable, mimetypes.guess(file)) and true or false) end @@ -83,11 +83,11 @@ function fileutils.pushfilecontent(pathtofile, data) end function fileutils.getrelpath(file) - return file:sub((Ferron.site.path .. Ferron.site.siteconfig.paths.content):len() + 1) + return file:sub((Ferron.site.path .. Ferron.site.config.paths.content):len() + 1) end function fileutils.sethtmlpath(folder) - return Ferron.site.path .. Ferron.site.siteconfig.paths.html .. folder + return Ferron.site.path .. Ferron.site.config.paths.html .. folder end function fileutils.removeextension(file) diff --git a/sites/ferron-ssg.tld/site-config.lua b/sites/ferron-ssg.tld/config.lua