blob: 855a7a07f04bd0b8195628a8d18eb3ca3496ff87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package.moonpath = './?.server.moon;' .. package.moonpath
import flush from require 'lib.init'
import render from require 'lib.mmmfs'
-- usage:
-- moon render.moon <output> <fileder_path> [<prefix module> <prefix path>]
{ output_name, path, prefix_mod, prefix_path } = arg
-- output_name = assert arg[1], "please specify the output filename as an argument"
-- path = assert arg[2], "please specify the path name to build as an argument"
assert output_name, "please specify the output filename as an argument"
assert path, "please specify the path name to build as an argument"
root = if prefix_mod and prefix_path
-- prefix module and path are given, skip deeper into the tree
assert path\match '^' .. prefix_path
with require prefix_mod
\mount prefix_path, true
else
-- load full tree
with require 'root'
\mount!
content, rehydrate = render root, path
assert content, "no content"
with io.open output_name, 'w'
\write "<!DOCTYPE html>
<html>
<head>
<meta charset=\"UTF-8\">
<title>MMM: lunar low-gravity scripting playground</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"/main.css\" />
<!--
<link rel=\"preload\" as=\"fetch\" href=\"/lib/dom.lua\" />
<link rel=\"preload\" as=\"fetch\" href=\"/lib/mmmfs/init.lua\" />
<link rel=\"preload\" as=\"fetch\" href=\"/lib/mmmfs/fileder.lua\" />
<link rel=\"preload\" as=\"fetch\" href=\"/lib/mmmfs/browser.lua\" />
-->
</head>
<body>
#{content}
<script src=\"/fengari-web.js\"></script>
<script src=\"/highlight.pack.js\"></script>
<script type=\"application/lua\" src=\"/lib/init.lua\"></script>
<script src=\"//cdnjs.cloudflare.com/ajax/libs/marked/0.5.1/marked.min.js\"></script>
<script src=\"//cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js\"></script>
#{rehydrate}
</body>
</html>"
\close!
|