| |
1 |
| |
2 module("handlers", package.seeall) |
| |
3 |
| |
4 require("handlers.render") |
| |
5 require("handlers.copy") |
| |
6 require("handlers.ignore") |
| |
7 |
| |
8 local available={ |
| |
9 { pattern = "%.page$", handler = handlers.render}, |
| |
10 { pattern = "", handler = handlers.copy}, |
| |
11 } |
| |
12 |
| |
13 |
| |
14 function find(f) |
| |
15 for _, h in ipairs(available) do |
| |
16 if string.match(h.pattern, f) then |
| |
17 return h.handler |
| |
18 end |
| |
19 end |
| |
20 return handlers.ignore |
| |
21 end |
| |
22 |
| |
23 local cached={} |
| |
24 |
| |
25 function choose(f, env) |
| |
26 cached[f] = find(f) |
| |
27 end |
| |
28 |
| |
29 -- load |
| |
30 function phase1(f, env) |
| |
31 return cached[f].phase1(f, env) |
| |
32 end |
| |
33 |
| |
34 -- write |
| |
35 function phase2(f, env) |
| |
36 return cached[f].phase2(f, env) |
| |
37 end |
| |
38 |