From eb556356062974f4e40f7c0347fd54098a0ce209 Mon Sep 17 00:00:00 2001 From: s-ol Date: Sat, 27 Oct 2018 17:11:19 +1100 Subject: rename to mmmfs, add canvas on client --- lib/init.client.moon | 17 +++++++++++------ lib/init.server.moon | 16 ++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) (limited to 'lib') 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 "" -- cgit v1.2.3