ferron

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

commit edca1bbd23fb5e8f0b2549d856b376f254375371
parent 77475664d716c7862231d8def650e48612a78597
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Thu, 23 Nov 2017 15:01:03 -0500

Work on image exportations

Diffstat:
Mferron.lua | 4++--
Mfunctions/make-lists-of-pages.lua | 7++++---
Mfunctions/make-non-textuals-exports.lua | 11++++++++---
Msites/ferron-ssg.tld/content/index.json | 15++++++++-------
4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/ferron.lua b/ferron.lua @@ -18,7 +18,7 @@ local createarchetypecontent = require("functions.create-archetype-content") local makepages = require("functions.make-pages") local makelistsofpages = require("functions.make-lists-of-pages") local makeatomfeed = require("functions.make-atom-feed") -local makenontextualsexport = require("functions.make-non-textuals-exports") +local makenontextualsexports = require("functions.make-non-textuals-exports") local movetopublichtml = require("functions.move-to-publichtml") local exec = require("functions.exec") @@ -40,7 +40,7 @@ Ferron.buildfunctions = { makepages, makelistsofpages, makeatomfeed, - makenontextualsexport, + makenontextualsexports, movetopublichtml } diff --git a/functions/make-lists-of-pages.lua b/functions/make-lists-of-pages.lua @@ -36,8 +36,9 @@ local function makelistsofpages() if section == listindex_section then table.insert(listindex_table["entries"], v) - end - end + end + end + if path.isdir(listindex_pathhtml) == false then fileutils.mkdir(listindex_pathhtml) @@ -58,7 +59,7 @@ local function makelistsofpages() else print(" !! " .. listindex_relpath .. ".html - error!") end - + print("==========") -- Update the JSON file data diff --git a/functions/make-non-textuals-exports.lua b/functions/make-non-textuals-exports.lua @@ -5,13 +5,18 @@ local path = require("path") local tableutils = require("functions.table-utils") local function makenontextualsexports() - local mimetypes = {"image/svg+xml", "image/jpeg", "image/png"} + local mimestable = {"image/svg+xml", "image/jpeg", "image/png"} path.each( Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/*", "f", function(f) - if tableutils.hasvalue(mimetypes, mimetypes.guess(f)) then - print(f) + if tableutils.hasvalue(mimestable, mimetypes.guess(f)) then + local img = f + local img_relpath = path.dirname(img):sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/"):len() + 1) + local img_section = img_relpath:match("^(.-)/") + --if path.extension(f) == ".jpg" or path.extension(f) == ".png" then + --print("." .. img:sub((Ferron.site.path .. Ferron.site.config.SITE.PATHS.CONTENT .. "/" .. path.dirname(img)):len() + 1)) + print(img_section) end end, {recurse = true} ) diff --git a/sites/ferron-ssg.tld/content/index.json b/sites/ferron-ssg.tld/content/index.json @@ -1,10 +1,10 @@ { - "id":"tag:samplesite.tld,0000-00-00:0000/00/index", - "content":"\n<h1>Welcome to Ferron SSG</h1>\n\n<p>Sed tamen haec cum ita tutius observentur, quidam vigore artuum inminuto rogati ad nuptias ubi aurum dextris manibus cavatis offertur, inpigre vel usque Spoletium pergunt. haec nobilium sunt instituta.</p>\n\n<p>Illud autem non dubitatur quod cum esset aliquando virtutum omnium domicilium Roma, ingenuos advenas plerique nobilium, ut Homerici bacarum suavitate Lotophagi, humanitatis multiformibus officiis retentabant.</p>\n\n<p>Quibus ita sceleste patratis Paulus cruore perfusus reversusque ad principis castra multos coopertos paene catenis adduxit in squalorem deiectos atque maestitiam, quorum adventu intendebantur eculei uncosque parabat carnifex et tormenta. et ex is proscripti sunt plures actique in exilium alii, non nullos gladii consumpsere poenales. nec enim quisquam facile meminit sub Constantio, ubi susurro tenus haec movebantur, quemquam absolutum.</p>\n\n", + "id":"tag:ferron-ssg.tld,0000-00-00:0000/00/index", + "template":"default", "title":"Welcome to Ferron SSG", - "updated":"2017-11-11T15:18:54", - "date":"0000-00-00", + "permalink":"http://ferron-ssg.tld", + "updated":"2017-11-22T08:59:26", "datetime":"00:00:00", - "permalink":"http://samplesite.tld/index.html", - "template":"default" -} + "date":"0000-00-00", + "content":"\n<h1>Ferron SSG</h1>\n\n<p>Ferron is a static website generator crafted\nwith <a href=\"https://www.lua.org/\">Lua >= 5.3</a>.</p>\n\n<p><em>This documentation is a WIP</em>.</p>\n\n<h2>Installation</h2>\n\n<ol>\n <li>Make sure Lua 5.3 or up is installed on your machine.</li>\n <li>Then `git clone git@github.com:hs0ucy/ferron-ssg.git &amp;&amp; cd\n ferron-ssg`</li>\n <li>After that install all the dependencies above. For me, the best way\n to do that it's via <a href=\"https://luarocks.org/\">LuaRocks</a>.</li>\n</ol>\n\n<h3>Dependencies</h3>\n\n<ul>\n <li><a href=\"https://luarocks.org/modules/dhkolf/dkjson\">dkjson</a></li>\n <li><a href=\"https://luarocks.org/modules/moteus/lua-path\">lua-path</a></li>\n <li><a href=\"https://luarocks.org/modules/hisham/luafilesystem\">LuaFileSysem</a></li>\n <li><a href=\"https://luarocks.org/modules/olivine-labs/lustache\">lustache</a></li>\n <li><a href=\"https://luarocks.org/modules/mpeterv/markdown\">Markdown</a></li>\n</ul>\n\n<h2>Get Started</h2>\n\n<p>First you need to copy the default site and give it the name of the\nwebsite you want to create:</p>\n\n<p>```\ncd sites/ &amp;&amp; cp -R ferron-ssg.tld mynewwebsite.net &amp;&amp; ls\n```</p>\n\n<p>After that with your favorite texteditor or IDE edit the\n<code>site.config.lua</code> to meet the needs of your web site:</p>\n\n<p>```\nemacs site.config.lua\n```</p>\n\n\n<ul>\n <li>To simply build a web site:</li>\n <li><code>lua ferron.lua</code></li>\n <li>To build a site in development mode:</li>\n <li><code>lua ferron.lua --dev</code></li>\n</ul>\n\n<h2>Architecture of <code>ferron-ssg</code> directory</h2>\n\n<ul>\n <li><code>config.lua</code></li>\n <li><code>rhino</code></li>\n <li><code>ferron.lua</code></li>\n <li><strong><code>functions</code></strong></li>\n <li><code>create-archetype-content.lua</code></li>\n <li><code>exec.lua</code></li>\n <li><code>file-utils.lua</code></li>\n <li><code>get-archetypes.lua</code></li>\n <li><code>get-sites.lua</code></li>\n <li><code>make-atom-feed.lua</code></li>\n <li><code>make-lists-of-pages.lua</code></li>\n <li><code>make-pages.lua</code></li>\n <li><code>move-to-publichtml.lua</code></li>\n <li><code>set-site.lua</code></li>\n <li><code>string-utils.lua</code></li>\n <li><code>table-utils.lua</code></li>\n <li><code>template-utils.lua</code></li>\n <li><strong><code>sites</code></strong>\n <ul>\n <li><strong><code>ferron-ssg.tld</code></strong></li>\n <li><strong><code>archetypes</code></strong></li>\n <li><strong><code>content</code></strong></li>\n <li><strong><code>public_html</code></strong></li>\n <li><code>site.config.lua</code></li>\n <li><strong><code>static</code></strong></li>\n <li><strong><code>templates</code></strong></li>\n </ul></li>\n</ul>\n\n<h2>Content</h2>\n\n<p>All the content of your site should be markdown (<code>*.md</code>) file and\nbelongs in the <code>content/</code> repository. That folder must contains at\nleast an <code>index.md</code> file and an <code>index.json</code>.</p>\n\n<h2>Archetypes</h2>\n\n<p>Archetypes are presets files for writing content faster. When you\ncreate a content through an archetype, the basic metadatas of your\nmarkdown file are prefilled and it is put in the right place of the content\ntree.</p>\n\n<h3>Create a content from an archetype</h3>\n\n<ol>\n <li><p>The first argument is the name (whithout the <code>*.md</code> extension) of an existing archetype.</p></li>\n <li><p>The second (and the last) argument is the title you want to give to your content.</p></li>\n <li><p><code>lua ferron.lua nameofthearchetype \"The title you want for your content\"</code></p></li>\n</ol>\n\n<p>So if i'm using the <code>sample.md</code> archetype to create a new content it\nwill look like this :</p>\n\n<ul>\n <li><code>lua ferron.lua sample \"This is my first content made from an archetype\"</code></li>\n</ul>\n\n<p>If it is a success Ferron will output something like this :</p>\n\n<ul>\n <li><code>- The file '/home/hs0ucy/Documents/fakestache-ssg/content/sample/2017/03/this-is-my-first-content-made-from-an-archetype.md' hab been created.</code></li>\n</ul>\n\n<p>Now you can open the file you have created and start to write right\naway whithout the need of filling the metadatas.</p>\n\n<h2>Templates</h2>\n\n<p>Ferron uses\nthe <a href=\"http://mustache.github.io/\">mustache template engine</a>\n(<a href=\"https://github.com/Olivine-Labs/lustache\">for lua</a>) to give more\nflexibility to build your theme.</p>\n\n" +}+ \ No newline at end of file