Sat, 01 Nov 2014 23:34:21 +0000
Lua 5.2 compatibility hack
module('lgen', package.seeall) -- export src dst hierarchy -- Lua 5.1 setfenv/getfenv compatibility for Lua 5.2 local CE = require('compat_env') _G.setfenv = CE.setfenv _G.getfenv = CE.getfenv require('scan') require('handlers') -- globally add missing stuff require('luaext') -- -- Main -- if #arg < 3 then error("Usage: lgen src tmpl dst") end src = arg[1] tmpl = arg[2] dst = arg[3] print('Scan...') hierarchy = scan.scan(src) local env={ paths={ src=src, dst=dst, tmpl=tmpl, }, pages={ }, } -- Pitäisi env konstruoida. polun perusteella. scan.map(hierarchy, function(f) handlers.choose(f, env) end) print('Phase 1...') scan.map(hierarchy, function(f) handlers.phase1(f, env) end) print('Phase 2...') scan.map(hierarchy, function(f) handlers.phase2(f, env) end, function(d) --log.log("Make path "..path.join(dst, d).."\n") lfs.mkdir(path.join(dst, d)) end) --print('Phase 3...') --scan.map(hierarchy, function(f) handlers.phase3(f, env) end)