aboutsummaryrefslogtreecommitdiffstats
path: root/render.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-11-01 09:01:49 +0000
committers-ol <s-ol@users.noreply.github.com>2018-11-01 09:01:49 +0000
commitfc181b154fb3f5cdefcf72c2a496b5b14f274e79 (patch)
tree5b4cfbebb4760fba68161265f07826b55206c311 /render.moon
parentREHYDRATION (diff)
parentfaster time to first render (diff)
downloadmmm-fc181b154fb3f5cdefcf72c2a496b5b14f274e79.tar.gz
mmm-fc181b154fb3f5cdefcf72c2a496b5b14f274e79.zip
Merge branch 'root-mmmfs'
Diffstat (limited to 'render.moon')
-rw-r--r--render.moon43
1 files changed, 33 insertions, 10 deletions
diff --git a/render.moon b/render.moon
index 7acf9a4..855a7a0 100644
--- a/render.moon
+++ b/render.moon
@@ -1,12 +1,28 @@
package.moonpath = './?.server.moon;' .. package.moonpath
import flush from require 'lib.init'
+import render from require 'lib.mmmfs'
-import indexed from require 'app'
+-- usage:
+-- moon render.moon <output> <fileder_path> [<prefix module> <prefix path>]
-route_name = assert arg[1], "please specify the route name to build as an argument"
-output_name = assert arg[2], "please specify the output filename as an argument"
-route = assert indexed[route_name], "route not found: '#{route_name}'"
-route\render!
+{ 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>
@@ -15,16 +31,23 @@ with io.open output_name, 'w'
<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/component.lua\" />
- <script src=\"/fengari-web.js\"></script>
- <script src=\"/highlight.pack.js\"></script>
- <script src=\"//cdn.jsdelivr.net/npm/marked/marked.min.js\"></script>
+ <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>
- #{flush!}
+ #{rehydrate}
</body>
</html>"
\close!