git.s-ol.nu mmm / ecdd1d8
handle interactive html in layout s-ol a month ago
2 changed file(s) with 8 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
5757 root = @root or Fileder @store
5858 browser = Browser root, fileder.path, facet.name
5959
60 scripts = "
61 <script type=\"text/javascript\" src=\"//cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js\"></script>
62 <script type=\"text/javascript\" src=\"/static/fengari-web/:text/javascript\"></script>
63 <script type=\"text/lua\" src=\"/static/mmm/:text/lua\"></script>
64 <script type=\"text/lua\">
65 require 'mmm'
66 on_load = on_load or {}
67 table.insert(on_load, function()
68 local path = #{string.format '%q', fileder.path}
69 local facet = #{string.format '%q', facet.name}
70 local browser = require 'mmm.mmmfs.browser'
71 local fileder = require 'mmm.mmmfs.fileder'
72 local web = require 'mmm.mmmfs.stores.web'
73
74 local store = web.WebStore({ verbose = true })
75 local root = fileder.Fileder(store, store:get_index(nil, -1))
76
77 local err_and_trace = function (msg) return debug.traceback(msg, 2) end
78 local ok, browser = xpcall(browser.Browser, err_and_trace, root, path, facet, true)
79 if not ok then error(browser) end
80 end)
81 </script>"
82 convert 'mmm/dom+noview', 'text/html', scripts .. browser\todom!, fileder, facet.name
60 convert 'mmm/dom+interactive', 'text/html', browser\todom!, fileder, facet.name
8361
8462 handle_debug: (fileder, facet) =>
8563 debugger = MermaidDebugger!
5454 runServer () {
5555 find build mmm -name '*.moon' | entr -dr moon build/server.moon "$@"
5656 }
57
58 build () {
59 mkdir -p root/static/mmm
60 find mmm -name '*.moon' | moon build/bundle_modules.moon "$1/static/mmm/text\$lua.lua"
61 }
62
5763 echo -e "\e[90m# run hot-reload server: \e[31mrunServer …\e[0m"
64 echo -e "\e[90m# run hot-reload server: \e[31mrunServer $ROOT\e[0m"
5865 '';
5966 LUA_PATH = "?.lua;?/init.lua";
6067 }