Wed, 31 Jan 2018 19:51:10 +0000
added markdown: true/false meta-tag
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
1 | |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
2 | local path=string.gsub(arg[0], "(.*)/[^/]*", "%1"); |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
3 | if path~=nil then |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
4 | package.path=package.path .. ';' .. path .. '/?.lua' |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
5 | end |
2 | 6 | |
5 | 7 | -- Lua 5.1 setfenv/getfenv compatibility for Lua 5.2 |
9
751216807683
Further lua5.3 compatibility fixes
Tuomo Valkonen <tuomov@iki.fi>
parents:
7
diff
changeset
|
8 | -- This is required by the "obsolete" ltp module |
5 | 9 | local CE = require('compat_env') |
10 | _G.setfenv = CE.setfenv | |
11 | _G.getfenv = CE.getfenv | |
12 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
13 | local scan=require('scan') |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
14 | local handlers=require('handlers') |
3 | 15 | -- globally add missing stuff |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
16 | local luaext=require('luaext') |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
17 | local lfs=require('lfs') |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
18 | local path=require('path') |
2 | 19 | |
20 | -- | |
21 | -- Main | |
22 | -- | |
23 | ||
3 | 24 | if #arg < 3 then |
25 | error("Usage: lgen src tmpl dst") | |
2 | 26 | end |
27 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
28 | local src = arg[1] |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
29 | local tmpl = arg[2] |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
30 | local dst = arg[3] |
2 | 31 | |
32 | print('Scan...') | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
33 | |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
34 | local hierarchy = scan.scan(src) |
2 | 35 | |
3 | 36 | |
37 | local env={ | |
38 | paths={ | |
39 | src=src, | |
40 | dst=dst, | |
41 | tmpl=tmpl, | |
42 | }, | |
43 | pages={ | |
44 | }, | |
45 | } | |
46 | ||
47 | ||
2 | 48 | -- Pitäisi env konstruoida. polun perusteella. |
49 | scan.map(hierarchy, function(f) handlers.choose(f, env) end) | |
50 | ||
51 | print('Phase 1...') | |
52 | scan.map(hierarchy, function(f) handlers.phase1(f, env) end) | |
53 | print('Phase 2...') | |
3 | 54 | scan.map(hierarchy, function(f) handlers.phase2(f, env) end, |
55 | function(d) | |
56 | --log.log("Make path "..path.join(dst, d).."\n") | |
57 | lfs.mkdir(path.join(dst, d)) | |
58 | end) | |
59 | --print('Phase 3...') | |
60 | --scan.map(hierarchy, function(f) handlers.phase3(f, env) end) |