lgen.lua

Sun, 07 May 2017 20:02:53 +0100

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 07 May 2017 20:02:53 +0100
changeset 6
219d7a7304f8
parent 5
7667b101cb1e
child 7
038275cd92ed
permissions
-rw-r--r--

5.3 updates

     
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)

mercurial