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