git.s-ol.nu mmm / 9ab2f0f
add $interactive facet with Browser s-ol 3 years ago
3 changed file(s) with 23 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
1111 import Key, dir_base, load_tree from require 'mmm.mmmfs.fileder'
1212 import convert from require 'mmm.mmmfs.conversion'
1313 import get_store from require 'mmm.mmmfs.stores'
14 import render from require 'mmm.mmmfs.layout'
15 import Browser from require 'mmm.mmmfs.browser'
1416 import decodeURI from require 'http.util'
1517
1618 lfs = require 'lfs'
4446 switch method
4547 when 'GET', 'HEAD'
4648 val = switch facet.name
49 when '?interactive'
50 export BROWSER
51
52 root = load_tree @store
53 BROWSER = Browser root, path
54 render BROWSER\todom!, fileder, noview: true, scripts: "
55 <script type=\"application/lua\">
56 on_load = on_load or {}
57 table.insert(on_load, function()
58 local path = #{string.format '%q', path}
59 local browser = require 'mmm.mmmfs.browser'
60 local root = dofile '/$bundle.lua'
61 root:mount('', true)
62
63 BROWSER = browser.Browser(root, path, true)
64 end)
65 </script>"
66
4767 when '?index', '?tree'
4868 -- serve fileder index
4969 -- '?index': one level deep
00 require = relative ..., 1
11 import Key from require '.fileder'
22 import converts, get_conversions, apply_conversions from require '.conversion'
3 import ReactiveVar, get_or_create, text, elements from require 'mmm.component'
3 import ReactiveVar, get_or_create, text, elements, tohtml from require 'mmm.component'
44 import pre, div, nav, span, button, a, code, select, option from elements
55 import languages from require 'mmm.highlighting'
66
239239 navigate: (new) =>
240240 @path\set new
241241
242 todom: => tohtml @
243
242244 {
243245 :Browser
244246 }
152152 ]]
153153
154154 buf ..= opts.scripts
155 -- <script type=\"application/lua\">
156 -- on_load = on_load or {}
157 -- table.insert(on_load, function()
158 -- local path = #{string.format '%q', path}
159 -- local browser = require 'mmm.mmmfs.browser'
160 -- local root = dofile '/$bundle.lua'
161 -- root:mount('', true)
162
163 -- BROWSER = browser.Browser(root, path, true)
164 -- end)
165 -- </script>
166155 buf ..= "
167156 </body>
168157 </html>