Mon, 14 Sep 2009 00:16:13 +0300
fixes
2 | 1 | |
2 | module('lgen', package.seeall) | |
3 | -- export src dst hierarchy | |
4 | ||
5 | require('scan') | |
6 | require('handlers') | |
3 | 7 | -- globally add missing stuff |
8 | require('luaext') | |
2 | 9 | |
10 | -- | |
11 | -- Main | |
12 | -- | |
13 | ||
3 | 14 | if #arg < 3 then |
15 | error("Usage: lgen src tmpl dst") | |
2 | 16 | end |
17 | ||
18 | src = arg[1] | |
3 | 19 | tmpl = arg[2] |
20 | dst = arg[3] | |
2 | 21 | |
22 | print('Scan...') | |
23 | hierarchy = scan.scan(src) | |
24 | ||
3 | 25 | |
26 | local env={ | |
27 | paths={ | |
28 | src=src, | |
29 | dst=dst, | |
30 | tmpl=tmpl, | |
31 | }, | |
32 | pages={ | |
33 | }, | |
34 | } | |
35 | ||
36 | ||
2 | 37 | -- Pitäisi env konstruoida. polun perusteella. |
38 | scan.map(hierarchy, function(f) handlers.choose(f, env) end) | |
39 | ||
40 | print('Phase 1...') | |
41 | scan.map(hierarchy, function(f) handlers.phase1(f, env) end) | |
42 | print('Phase 2...') | |
3 | 43 | scan.map(hierarchy, function(f) handlers.phase2(f, env) end, |
44 | function(d) | |
45 | --log.log("Make path "..path.join(dst, d).."\n") | |
46 | lfs.mkdir(path.join(dst, d)) | |
47 | end) | |
48 | --print('Phase 3...') | |
49 | --scan.map(hierarchy, function(f) handlers.phase3(f, env) end) |