commit 4186b3701c5376cd9829269e8b5184f8b88fc348
parent 12faa944f9b5e858de3df86a0703e5e926d6ca16
Author: Frederic Cambus <fred@statdns.com>
Date: Thu, 20 Apr 2017 13:08:26 +0200
Improved status notifications
Diffstat:
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/motyl.lua b/src/motyl.lua
@@ -7,7 +7,7 @@
# https://www.cambus.net/motyl/ #
# #
# Created: 2016-02-16 #
-# Last Updated: 2017-02-07 #
+# Last Updated: 2017-04-20 #
# #
# Motyl is released under the BSD 2-Clause license. #
# See LICENSE file for details. #
@@ -20,11 +20,6 @@ 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"))
@@ -38,7 +33,6 @@ 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()
@@ -66,6 +60,11 @@ 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"
@@ -96,7 +95,9 @@ local function render(directory)
data.page.content = loadMD(directory .. "/" .. file)
data.page.url = path .. "/"
- if directory == "posts" then
+ 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})
@@ -137,6 +138,7 @@ 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
@@ -144,6 +146,7 @@ for loop=1, 20 do
end
writeFile("deploy/atom.xml", renderTemplate(templates.atom, data, templates))
+status("Rendering atom.xml")
data.page = {}
-- Categories
@@ -160,4 +163,5 @@ 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