diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-11-09 13:14:56 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-11-09 13:14:56 +0000 |
| commit | fa977b6a5d6f6063479a97917810ef393c312e76 (patch) | |
| tree | b21984147c34293fe91e76eef13bfd969b3a7368 /render.moon | |
| parent | add $order mechanism (diff) | |
| parent | add deploy script (diff) | |
| download | mmm-fa977b6a5d6f6063479a97917810ef393c312e76.tar.gz mmm-fa977b6a5d6f6063479a97917810ef393c312e76.zip | |
Merge branch 'new-tup'
Diffstat (limited to 'render.moon')
| -rw-r--r-- | render.moon | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/render.moon b/render.moon index 66272ec..5284e66 100644 --- a/render.moon +++ b/render.moon @@ -1,22 +1,28 @@ -package.moonpath = './?.server.moon;./?/init.server.moon;' .. package.moonpath -require 'mmm.init' +require 'mmm' import render from require 'mmm.mmmfs' -import load_fileder from require 'mmm.mmmfs.fs' -- usage: --- moon render.moon <output> <fileder_path> -{ output_name, path } = arg +-- moon render.moon <path_to_root> +{ root } = arg -assert output_name, "please specify the output filename as an argument" -assert path, "please specify the path name to build as an argument" +assert root, "please specify the relative root path as an argument" -root = load_fileder 'root' .. path -root\mount path +require 'lfs' +cwd = lfs.currentdir! +path = '' + +while root\find '^%.%./' + root = root\match '^%.%./(.*)' + cwd, trimmed = cwd\match '(.*)(/[^/]+)$' + path = trimmed .. path + +root = dofile '$bundle.lua' +root\mount path, true content, rehydrate = render root, path assert content, "no content" -with io.open output_name, 'w' +with io.open 'index.html', 'w' \write "<!DOCTYPE html> <html> <head> @@ -39,8 +45,7 @@ with io.open output_name, 'w' <script src=\"//cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js\"></script> <script src=\"/fengari-web.js\"></script> <script type=\"application/lua\" src=\"/mmm.bundle.lua\"></script> - <script type=\"application/lua\" src=\"/root.bundle.lua\"></script> - <script defer type=\"application/lua\" src=\"/mmm/init.lua\"></script> + <script type=\"application/lua\">require 'mmm'</script> #{rehydrate} </body> |
