diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-10-27 06:11:19 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-10-27 06:11:19 +0000 |
| commit | eb556356062974f4e40f7c0347fd54098a0ce209 (patch) | |
| tree | 8cd56e0dcbd301ecc25824ac5285170eb647f254 | |
| parent | styling (diff) | |
| download | mmm-eb556356062974f4e40f7c0347fd54098a0ce209.tar.gz mmm-eb556356062974f4e40f7c0347fd54098a0ce209.zip | |
rename to mmmfs, add canvas on client
| -rw-r--r-- | Tupfile | 2 | ||||
| -rw-r--r-- | app/init.moon | 30 | ||||
| -rw-r--r-- | app/mmmfs/init.moon (renamed from app/tablefs/init.moon) | 2 | ||||
| -rw-r--r-- | app/mmmfs/tree.moon (renamed from app/tablefs/tablefs.moon) | 13 | ||||
| -rw-r--r-- | app/mmmfs/twisted.moon | 37 | ||||
| -rw-r--r-- | app/tablefs/twisted.moon | 38 | ||||
| -rw-r--r-- | lib/init.client.moon | 17 | ||||
| -rw-r--r-- | lib/init.server.moon | 16 |
8 files changed, 89 insertions, 66 deletions
@@ -8,7 +8,7 @@ preload app app/tags lib CLIENT += app/*.moon CLIENT += app/tags/*.moon -CLIENT += app/tablefs/*.moon +CLIENT += app/mmmfs/*.moon CLIENT += lib/*.client.moon CLIENT += lib/*.shared.moon diff --git a/app/init.moon b/app/init.moon index daa2d47..e1f7a75 100644 --- a/app/init.moon +++ b/app/init.moon @@ -7,42 +7,48 @@ patch_redirs = -> 'play-tags': 'tags', { :location } = window - if location.search and #location.search > 1 + if (not location.search\find '=') and #location.search > 1 name = location.search\sub 2 location.href = redirs[name] or name +client_goto = -> + { :location } = window + if module = location.search\match 'client=([%w_]+)' + document.body.innerHTML = '' + require 'app.' .. module + experiments = { { - name: 'twisted', + name: 'twisted' desc: 'pseudo 3d animation' }, { - name: 'koch', - desc: "lil' fractal thing", + name: 'koch' + desc: "lil' fractal thing" }, { - name: 'realities', + name: 'realities' desc: 'a paper on virtual and other realities' }, { - name: 'center_of_mass', + name: 'center_of_mass' desc: 'aligning characters by their centers of mass' }, { - name: 'todo', + name: 'todo' desc: 'Todo MVC with the mmm UI framework' }, { - name: 'test_component', + name: 'test_component' desc: 'test suite for the mmm reactive UI framework' }, { - name: 'tags', + name: 'tags' desc: 'organizing files with Functional Tags' }, { - name: 'tablefs', - desc: 'a (file)system to live in' + name: 'mmmfs' + desc: 'an operating, file- and living system' }, } @@ -83,6 +89,8 @@ table.insert routes, { "made with #{moon} by " a { 's-ol', href: 'https://twitter.com/S0lll0s' } } + + on_client client_goto } destify = (route) -> with route diff --git a/app/tablefs/init.moon b/app/mmmfs/init.moon index db3a328..0808aee 100644 --- a/app/tablefs/init.moon +++ b/app/mmmfs/init.moon @@ -144,6 +144,6 @@ class Fileder nil, "node doesn't have value for #{name}:#{type}" require = relative ... -root = require '.tablefs' +root = require '.tree' append root\gett 'mmm/dom' diff --git a/app/tablefs/tablefs.moon b/app/mmmfs/tree.moon index 4983b6e..ee25490 100644 --- a/app/tablefs/tablefs.moon +++ b/app/mmmfs/tree.moon @@ -1,3 +1,5 @@ +require = relative ..., 1 + Fileder { 'moon -> mmm/dom': () => html = require 'lib.html' @@ -32,7 +34,7 @@ Fileder { table.insert args, style: { 'list-style': 'none', 'font-size': '0.8em' } ol table.unpack args - append h1 'Tablefs', style: { 'margin-bottom': 0 } + append h1 'mmmfs', style: { 'margin-bottom': 0 } append p "(it's a terrible name, isn't it)", style: { 'margin-top': 0, 'margin-bottom': '1em' } append p do @@ -42,7 +44,7 @@ Fileder { types/keys associated, but these have unspecified schemas and don't nest. In addition it can have many children, which are fileders themselves and can nest, but they are not labelled." - "in Tablefs, directories are files and files are directories, or something like that. + "in mmmfs, directories are files and files are directories, or something like that. Listen, I don't really know yet either. The idea is that every node knows how to render it's contents; so for example your 'Pictures' fileder", fileder, " contains a script within itself that renders all the picture files you put into it at the children level", child, "." @@ -153,7 +155,7 @@ table.insert converts, { rendered just using ", (code "append root\\get 'mmm/dom'"), " as well." append h2 "interp overloading" - append p "The example with the image is curious as well. In tablefs, you might want to save a link to an image, + append p "The example with the image is curious as well. In mmmfs, you might want to save a link to an image, without ever saving the actual image on your hard drive (or wherever the data may ever be stored - it is quite transient currently). The image Fileder below has it's main (unnamed) value tagged as ", (code 'URL -> image/png'), " - a png image, encoded as an URL. When accessed as ", (code 'image/png'), " @@ -205,4 +207,9 @@ If you are reading this in the source, then c'mon, just scroll past and give me and some bold **text** and `code tags` with me.", } + + if MODE == 'CLIENT' then Fileder { + 'title: text/plain': "canvas animation that doesn't quite fit", + 'preview: moon -> mmm/component': => require '.twisted' + } } diff --git a/app/mmmfs/twisted.moon b/app/mmmfs/twisted.moon new file mode 100644 index 0000000..c2f805b --- /dev/null +++ b/app/mmmfs/twisted.moon @@ -0,0 +1,37 @@ +Math = window.Math + +import CanvasApp from require 'lib.canvasapp' +import hsl from require 'lib.color' + +class TwistedDemo extends CanvasApp + width: 500 + height: 400 + length: math.pi * 4 + new: => + super true + @background = {Math.random!, Math.random!/3+.2, Math.random!/4} + hue = Math.random! + @shades = setmetatable {}, __index: (key) => + with val = { hue, .7, key * .3 + .1} do rawset @, key, val + + draw: => + @ctx.fillStyle = hsl @background + @ctx\fillRect 0, 0, @width, @height + @ctx\translate @width/2, @height/2 + 70 + + draw = (i) -> + @ctx\save! + @ctx\translate 0, -120*i + s = 1 - 0.1 * math.sin @time + i*2 + s *= 0.8 - i * .4 * math.cos @time + @ctx\scale s, s/2 + @ctx\rotate @time/4 + i * .6 * math.cos @time + @ctx.fillStyle = hsl table.unpack @shades[i] + @ctx\fillRect -80, -80, 160, 160 + @ctx\restore! + + for i=0,1,1/(20 + 19 * math.sin(@time / 2)) + draw i + draw 1 + +TwistedDemo! diff --git a/app/tablefs/twisted.moon b/app/tablefs/twisted.moon deleted file mode 100644 index 0ab30b1..0000000 --- a/app/tablefs/twisted.moon +++ /dev/null @@ -1,38 +0,0 @@ -on_client -> - Math = window.Math - - import CanvasApp from require 'lib.canvasapp' - import hsl from require 'lib.color' - - class TwistedDemo extends CanvasApp - width: 500 - height: 400 - length: math.pi * 4 - new: => - super true - @background = {Math.random!, Math.random!/3+.2, Math.random!/4} - hue = Math.random! - @shades = setmetatable {}, __index: (key) => - with val = { hue, .7, key * .3 + .1} do rawset @, key, val - - draw: => - @ctx.fillStyle = hsl @background - @ctx\fillRect 0, 0, @width, @height - @ctx\translate @width/2, @height/2 + 70 - - draw = (i) -> - @ctx\save! - @ctx\translate 0, -120*i - s = 1 - 0.1 * math.sin @time + i*2 - s *= 0.8 - i * .4 * math.cos @time - @ctx\scale s, s/2 - @ctx\rotate @time/4 + i * .6 * math.cos @time - @ctx.fillStyle = hsl table.unpack @shades[i] - @ctx\fillRect -80, -80, 160, 160 - @ctx\restore! - - for i=0,1,1/(20 + 19 * math.sin(@time / 2)) - draw i - draw 1 - - document.body\appendChild TwistedDemo!.node diff --git a/lib/init.client.moon b/lib/init.client.moon index 731fd87..c1aea07 100644 --- a/lib/init.client.moon +++ b/lib/init.client.moon @@ -8,16 +8,21 @@ MODE = 'CLIENT' print = console\log warn = console\warn --- package.path = './?.shared.lua;./?.client.lua;' .. package.path package.path = '/?.shared.moon.lua;/?.client.moon.lua;/?.moon.lua;/?/init.moon.lua;/?.lua;/?/init.lua' -- relative imports -relative = (...) -> - path = ... +relative = do + _require = require - (name) -> - name = path .. name if '.' == name\sub 1, 1 - require name + (base, sub) -> + sub = 0 unless 'number' == type sub + + for i=1, sub + base = base\match '^(.*)%.%w+$' + + (name, x) -> + name = base .. name if '.' == name\sub 1, 1 + _require name append = document.body\appendChild on_client = (f, ...) -> f ... diff --git a/lib/init.server.moon b/lib/init.server.moon index 912bbb4..5e0cb30 100644 --- a/lib/init.server.moon +++ b/lib/init.server.moon @@ -7,13 +7,18 @@ warn = (...) -> io.stderr\write '\n' -- relative imports -relative = (...) -> +relative = do _require = require - path = ... - (name) -> - name = path .. name if '.' == name\sub 1, 1 - require name + (base, sub) -> + sub = 0 unless 'number' == type sub + + for i=1, sub + base = base\match '^(.*)%.%w+$' + + (name, x) -> + name = base .. name if '.' == name\sub 1, 1 + _require name -- shorthand to append elements to body buffer = '' @@ -27,7 +32,6 @@ on_client = (fn, ...) -> args = {...} -- warn code append "<script type=\"application/lua\"> - MODE = 'HYBRID' local fn = #{compile fn} fn(#{table.concat [string.format '%q', v for v in *args ], ', '}) </script>" |
