git.s-ol.nu mmm / 6ce6480
clean up JS deps for static builds s-ol 2 years ago
4 changed file(s) with 23 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
5959
6060 root = Fileder @store
6161 BROWSER = Browser root, path, facet.name
62 render BROWSER\todom!, fileder, noview: true, scripts: "
62
63 deps = [[
64 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js"></script>
65 <script type="text/javascript" src="//unpkg.com/marked@0.7.0/marked.min.js"></script>
66 <script type="text/javascript" src="/static/fengari-web/:text/javascript"></script>
67 <script type="text/lua" src="/static/mmm/:text/lua"></script>
68 <script type="text/lua">require 'mmm'</script>
69 ]]
70
71 render BROWSER\todom!, fileder, noview: true, scripts: deps .. "
6372 <script type=\"text/lua\">
6473 on_load = on_load or {}
6574 table.insert(on_load, function()
00 import code from require 'mmm.dom'
1 local highlight
21
32 trim = (str) -> str\match '^ *(..-) *$'
43
5 if MODE == 'SERVER'
6 highlight = (lang, str) ->
4 highlight = if MODE == 'SERVER'
5 (lang, str) ->
76 assert str, 'no string to highlight'
87 code (trim str), class: "hljs lang-#{lang}"
98 else
10 highlight = (lang, str) ->
9 (lang, str) ->
1110 assert str, 'no string to highlight'
11
12 if not window.hljs\getLanguage lang
13 lang = 'markdown'
14
1215 result = window.hljs\highlight lang, (trim str), true
1316 with code class: "hljs lang-#{lang}"
1417 .innerHTML = result.value
1212 last
1313
1414 code_cast = (lang) ->
15
16 casts = {
1517 {
16 inp: "text/#{lang}.*",
18 inp: 'text/.*',
1719 out: 'mmm/dom',
1820 cost: 0
19 transform: (val) => languages[lang] val
21 transform: (val) =>
22 lang = @from\match 'text/(.*)'
23 languages[lang] val
2024 }
21
22 casts = {
23 code_cast 'javascript'
24 code_cast 'moonscript'
25 code_cast 'lua'
26 code_cast 'markdown'
27 code_cast 'html'
28 code_cast 'css'
2925 {
3026 inp: 'URL.*'
3127 out: 'mmm/dom'
143143 "
144144 buf ..= [[
145145 <script type="text/javascript" src="/static/highlight-pack/:text/javascript"></script>
146 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/marked/0.5.1/marked.min.js"></script>
147 <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/svg.js/2.6.6/svg.min.js"></script>
148146 <script type="text/javascript" src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
149 <script type="text/javascript" src="/static/fengari-web/:text/javascript"></script>
150 <script type="text/lua" src="/static/mmm/:text/lua"></script>
151 <script type="text/lua">require 'mmm'</script>
152147 ]]
153148
154149 buf ..= opts.scripts