aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-10-27 06:11:19 +0000
committers-ol <s-ol@users.noreply.github.com>2018-10-27 06:11:19 +0000
commiteb556356062974f4e40f7c0347fd54098a0ce209 (patch)
tree8cd56e0dcbd301ecc25824ac5285170eb647f254 /lib
parentstyling (diff)
downloadmmm-eb556356062974f4e40f7c0347fd54098a0ce209.tar.gz
mmm-eb556356062974f4e40f7c0347fd54098a0ce209.zip
rename to mmmfs, add canvas on client
Diffstat (limited to 'lib')
-rw-r--r--lib/init.client.moon17
-rw-r--r--lib/init.server.moon16
2 files changed, 21 insertions, 12 deletions
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>"