motyl

Opinionated blog-aware static site generator written in Ruby
Log | Files | Refs | README | LICENSE

commit 7f7be8c11346da5eb4fc0d19ccc730c98ef0be55
parent 5e0286acd3786ad0adbe72b8b7489291295149df
Author: Frederic Cambus <fred@statdns.com>
Date:   Fri, 25 Nov 2016 18:30:51 +0100

Display status messages in the writeFile function

Diffstat:
Msrc/motyl.lua | 18+++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/motyl.lua b/src/motyl.lua @@ -7,7 +7,7 @@ # http://www.cambus.net/motyl/ # # # # Created: 2016-02-16 # -# Last Updated: 2016-10-13 # +# Last Updated: 2016-11-25 # # # # Motyl is released under the BSD 2-Clause license. # # See LICENSE file for details. # @@ -20,6 +20,11 @@ local lyaml = require "lyaml" local lunamark = require "lunamark" local lustache = require "lustache" +-- Display status message +local function status(message) + print("[" .. os.date("%X") .. "] " .. message) +end + -- Read data from file local function readFile(path) local file = assert(io.open(path, "rb")) @@ -33,6 +38,7 @@ end -- Write data to file local function writeFile(path, data) local file = assert(io.open(path, "wb")) + status("Rendering " .. path) file:write(data) file:close() @@ -60,11 +66,6 @@ local function sortDates(a,b) return a.date > b.date end --- Display status message -local function status(message) - print("[" .. os.date("%X") .. "] " .. message) -end - -- Loading configuration local data = {} data.version = "Motyl 1.00" @@ -95,8 +96,6 @@ local function render(directory) data.page.content = loadMD(directory .. "/" .. file) data.page.url = path .. "/" - status("Rendering " .. data.page.url) - if directory == "posts" then local year, month, day, hour, min = data.page.date:match("(%d+)%-(%d+)%-(%d+) (%d+)%:(%d+)") data.page.datetime = os.date("%c", os.time{year=year, month=month, day=day, hour=hour, min=min}) @@ -138,7 +137,6 @@ data.page.description = data.site.description data.page.keywords = data.site.keywords writeFile("deploy/index.html", renderTemplate(templates.archives, data, templates)) -status("Rendering index.html") -- Feed for loop=1, 20 do @@ -146,7 +144,6 @@ for loop=1, 20 do end writeFile("deploy/atom.xml", renderTemplate(templates.atom, data, templates)) -status("Rendering atom.xml") data.page = {} -- Categories @@ -163,5 +160,4 @@ for category in pairs(data.site.categories) do lfs.mkdir("deploy/categories/" .. categoryURL) writeFile("deploy/categories/" .. categoryURL .. "index.html", renderTemplate(templates.archives, data, templates)) - status("Rendering " .. categoryURL) end