satelito

Static [web] site (or page) generator (ssg) made with Lua script.
git clone git://soucy.cc/satelito.git
Log | Files | Refs | README

commit 77e07da1c8b195ec98baede665c44194acd0f68a
parent 53514ef5e5e34301e7f046af8ac2839c17cd86d0
Author: Hugo Soucy <hugo@soucy.cc>
Date:   Fri,  8 Oct 2021 20:11:58 -0400

Add some feedback to the user

Diffstat:
Msatelito/init.lua | 54++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 10 deletions(-)

diff --git a/satelito/init.lua b/satelito/init.lua @@ -35,30 +35,40 @@ args = parser:parse() if args['init'] then os.execute('mkdir ~/satelito-sample') os.execute('git clone git://soucy.cc/satelito-sample.git ~/satelito-sample') - print('--------------------------------------------------------------------------------------------') + print('------------------------------------------------------------------------------------------------------') os.execute('rm -Rf ~/satelito-sample/.git') os.execute('ls -la ~/satelito-sample') - print('--------------------------------------------------------------------------------------------') + print('------------------------------------------------------------------------------------------------------') print('You should rename `~/satelito-sample` and edit `~/satelito-sample/config.lua` according to your needs.') - print('--------------------------------------------------------------------------------------------') + print('------------------------------------------------------------------------------------------------------') return end -- Example: '$ find site/content/ -name "*.md" | satelito pipe' if args['pipe'] then - local config + local configpath = false + local config = false + local contentdir = false + local sitemap = {} local templates local timestart = os.time() - local sitemap = {} + + print('=> Satelito is on ...') for filepath in (io.lines()) do if file.is_markdown(filepath) or file.is_html(filepath) then -- Get the site configuration's path - local configpath = site.get_config(filepath) + if not configpath then + print('=> Searching for the nearest config.lua ...') + configpath = site.get_config(filepath) + end -- Change the current directory to the config's directory - lfs.chdir(file.get_dirname(configpath)) + if lfs.currentdir()..'/' ~= file.get_dirname(configpath) then + print('=> Moving where the configuration file is located ...') + lfs.chdir(file.get_dirname(configpath)) + end -- If the site configuration file exists if file.exists(configpath) then @@ -66,24 +76,39 @@ if args['pipe'] then package.path = package.path .. ';'.. lfs.currentdir() ..'/?.lua' -- Set config.lua in a table - config = require 'config' + if not config then + print('=> Fetching the configuration file content ...') + config = require 'config' + end -- Absolute path to the 'content/' directory - local contentdir = lfs.currentdir() .. '/' .. config.paths.content + if not contentdir then + contentdir = lfs.currentdir() .. '/' .. config.paths.content + end -- Get the meta of the file local meta = model.set(filepath, config, contentdir) -- Add the meta of the file into the sitemap table + if lume.count(sitemap) == 0 then + print('=> Fetching the markdown and HTML content ...') + end + sitemap[meta.relpath] = lume.extend({}, meta) end end end + print('=> '..lume.count(sitemap)..' content found') + -- Array of templates + print('=> Fetching the templates ...') templates = lume.array(dirtree.get(lfs.currentdir() .. '/' .. config.paths.templates)) - return site.make(sitemap, templates, args['export'], timestart) + print('=> Making the web site ...') + site.make(sitemap, templates, args['export'], timestart) + + return end -- Example: '$ satelito make --export' @@ -93,16 +118,21 @@ if args['make'] then local timestart = os.time() local sitemap = {} + print('=> Satelito is on ...') + if file.exists('config.lua') then -- Add the currentdir to the package.path package.path = package.path .. ';'.. lfs.currentdir() ..'/?.lua' -- Set config.lua in a table + print('=> Fetching the configuration file content ...') config = require 'config' -- Absolute path to the 'content/' directory local contentdir = lfs.currentdir() .. '/' .. config.paths.content + print('=> Fetching the markdown and HTML content ...') + for filepath in dirtree.get(contentdir) do if file.is_markdown(filepath) or file.is_html(filepath) then local meta = model.set(filepath, config, contentdir) @@ -111,9 +141,13 @@ if args['make'] then end end + print('=> '..lume.count(sitemap)..' content found') + -- Array of templates + print('=> Fetching the templates ...') templates = lume.array(dirtree.get(lfs.currentdir() .. '/' .. config.paths.templates)) + print('=> Making the web site ...') return site.make(sitemap, templates, args['export'], timestart) else print('There is no "config.lua" here.')