commit 21a90e922de019ef6b606448411f70f9ba836a21
parent 6d7d2f1f4b939974e381878f365c9856627103e4
Author: Frederic Cambus <fred@statdns.com>
Date: Mon, 3 Oct 2016 23:25:47 +0200
Configuration and metadata files are now in YAML instead of JSON
Diffstat:
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
@@ -22,16 +22,16 @@ Motyl requires Lua 5.1+ and Make.
Motyl requires the following Lua modules :
-- Lua CJSON
- LuaFileSystem
-- Lustache
-- Markdown
+- lustache
+- lyaml
+- markdown
Installing via LuaRocks :
- luarocks install lua-cjson
luarocks install luafilesystem
luarocks install lustache
+ luarocks install lyaml
luarocks install markdown
Alternatively, those modules can be installed directly using binary packages.
diff --git a/src/motyl.lua b/src/motyl.lua
@@ -15,8 +15,8 @@
###############################################################################
]]--
-local cjson = require "cjson"
local lfs = require "lfs"
+local lyaml = require "lyaml"
local lustache = require "lustache"
local markdown = require "markdown"
@@ -38,9 +38,9 @@ local function writeFile(path, data)
file:close()
end
--- Load JSON from file
-local function loadJSON(path)
- return cjson.decode(readFile(path))
+-- Load YAML from file
+local function loadYAML(path)
+ return lyaml.load(readFile(path))
end
-- Load and process Markdown file
@@ -66,7 +66,7 @@ end
-- Loading configuration
local data = {}
data.version = "Motyl 1.00"
-data.site = loadJSON("motyl.conf")
+data.site = loadYAML("motyl.conf")
-- Loading templates
local templates = {
@@ -89,7 +89,7 @@ local function render(directory)
if extension == "md" then
local path = file:match "(.*).md$"
- data.page = loadJSON(directory .. "/" .. path .. ".json")
+ data.page = loadYAML(directory .. "/" .. path .. ".yaml")
data.page.content = loadMD(directory .. "/" .. file)
data.page.url = path .. "/"