summaryrefslogtreecommitdiffstats
path: root/_scripts/generate_atom.lua
diff options
context:
space:
mode:
Diffstat (limited to '_scripts/generate_atom.lua')
-rw-r--r--_scripts/generate_atom.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/_scripts/generate_atom.lua b/_scripts/generate_atom.lua
new file mode 100644
index 0000000..d434772
--- /dev/null
+++ b/_scripts/generate_atom.lua
@@ -0,0 +1,23 @@
+#!/usr/bin/lua
+
+local yaml = require('yaml')
+local lustache = require('lustache')
+
+local function filecontent(filename)
+ local file=assert(io.open(filename, "r"))
+ local content = file:read ("*a")
+ file:close()
+ return content
+end
+
+template = filecontent(arg[1])
+entries = yaml.load(filecontent(arg[2]))
+
+for k,v in ipairs(entries) do
+ -- timestamps in Atom must conform to RFC 3339
+ entries[k].updated = v.date.."T00:00:00Z"
+end
+local data = {updated=os.date('!%Y-%m-%dT%H:%M:%SZ'), entries=entries}
+
+io.write(lustache:render(template, data))
+