aboutsummaryrefslogtreecommitdiffstats
path: root/build/render_fileder.moon
diff options
context:
space:
mode:
Diffstat (limited to 'build/render_fileder.moon')
-rw-r--r--build/render_fileder.moon67
1 files changed, 62 insertions, 5 deletions
diff --git a/build/render_fileder.moon b/build/render_fileder.moon
index d76d162..f8958aa 100644
--- a/build/render_fileder.moon
+++ b/build/render_fileder.moon
@@ -1,20 +1,47 @@
require 'mmm'
-import render from require 'mmm.mmmfs'
import get_path from require 'build.util'
+import tohtml from require 'mmm.component'
+import Browser from require 'mmm.mmmfs.browser'
+
+export BROWSER
-- usage:
-- moon render.moon <path_to_root>
{ path_to_root } = arg
+seed = (str) ->
+ len = #str
+ rnd = -> math.ceil math.random! * len
+
+ math.randomseed len
+
+ return if len == 0
+
+ upper, lower = 0, 0
+ for i=1,4
+ upper += str\byte rnd!
+ upper *= 0x100
+
+ lower += str\byte rnd!
+ lower *= 0x100
+
+ math.randomseed upper, lower
+
+pick = (...) ->
+ num = select '#', ...
+ i = math.ceil math.random! * num
+ select i, ...
+
assert path_to_root, "please specify the relative root path"
path = get_path path_to_root
+seed path
+
root = dofile '$bundle.lua'
assert root, "couldn't load $bundle.lua"
root\mount path, true
-content, rehydrate = render root, path
-assert content, "no content"
+BROWSER = Browser root, path
with io.open 'index.html', 'w'
\write "<!DOCTYPE html>
@@ -30,9 +57,29 @@ with io.open 'index.html', 'w'
<link rel=\"preload\" as=\"fetch\" href=\"/mmm/mmmfs/fileder.lua\" />
<link rel=\"preload\" as=\"fetch\" href=\"/mmm/mmmfs/browser.lua\" />
-->
+
+ <link href=\"https://fonts.googleapis.com/css?family=Source+Sans+Pro:200,400\" rel=\"stylesheet\">
</head>
<body>
- #{content}
+ <header>
+ <h1>
+ <i class=\"sun\">☉</i>
+ <b></b>
+ <span class=\"bold\">mmm</span>
+ .s-ol.nu
+ </h1>
+ <span>
+ fun stuff with code and wires
+<!--
+ #{pick 'fun', 'cool', 'weird', 'interesting', 'new'}
+ #{pick 'stuff', 'things', 'projects', 'experiments', 'news'}
+ with
+ #{pick 'mostly code', 'code and wires', 'silicon', 'electronics'}
+-->
+ </span>
+ </header>
+
+ #{assert (tohtml BROWSER), "couldn't render BROWSER"}
<script src=\"/highlight.pack.js\"></script>
<script src=\"//cdnjs.cloudflare.com/ajax/libs/marked/0.5.1/marked.min.js\"></script>
@@ -41,7 +88,17 @@ with io.open 'index.html', 'w'
<script type=\"application/lua\" src=\"/mmm.bundle.lua\"></script>
<script type=\"application/lua\">require 'mmm'</script>
- #{rehydrate}
+ <script type=\"application/lua\">
+ on_load = on_load or {}
+ table.insert(on_load, function()
+ local path = #{string.format '%q', path}
+ local browser = require 'mmm.mmmfs.browser'
+ local root = dofile '/$bundle.lua'
+ root:mount('', true)
+
+ BROWSER = browser.Browser(root, path, true)
+ end)
+ </script>
</body>
</html>"
\close!