diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2018-10-19 14:12:16 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2018-10-19 14:12:16 +0000 |
| commit | 87c165036718abc9b94ca69ea7144c356dd45e3b (patch) | |
| tree | a5c7b7b9519045b007e9758c4facecb343c9b710 | |
| parent | small cleaning (diff) | |
| download | mmm-87c165036718abc9b94ca69ea7144c356dd45e3b.tar.gz mmm-87c165036718abc9b94ca69ea7144c356dd45e3b.zip | |
build fixes
| -rw-r--r-- | Tupfile | 7 | ||||
| -rw-r--r-- | app/index.moon | 4 | ||||
| -rw-r--r-- | app/init.moon | 94 | ||||
| m--------- | dist | 0 | ||||
| -rw-r--r-- | lib/init.client.moon | 2 | ||||
| -rw-r--r-- | render.moon | 17 | ||||
| -rw-r--r-- | tup.moon | 7 |
7 files changed, 113 insertions, 18 deletions
@@ -1,8 +1,6 @@ .gitignore !download = |> ^ DOWNLOAD %O^ curl -L https://github.com/fengari-lua/fengari-web/releases/download/@(FENGARI_VERSION)/`basename %o` > %o |> -# !render = |> ^ HTML %b^ moon render.moon > %o %B |> -!render = |> ^ HTML %b^ moon render.moon > %o %B |> dist/%B.html !moonc = |> ^ MOON %b^ moonc -o %o %f |> dist/%f.lua !sassc = |> ^ SCSS %b^ sassc -mauto %f %o |> | %o.map @@ -26,6 +24,5 @@ PAGES += app/tags # render stylesheet : scss/main.scss |> !sassc |> dist/main.css -# # render static content -: foreach $(PAGES) |> !render |> -# run moon find.moon +# render static content +run moon tup.moon diff --git a/app/index.moon b/app/index.moon index 44df8bc..6c68dbe 100644 --- a/app/index.moon +++ b/app/index.moon @@ -19,7 +19,7 @@ on_client -> { :location } = window if location.search and #location.search > 1 name = location.search\sub 2 - location.href = "#{redirs[name] or name}.html" + location.href = redirs[name] or name append h1 'mmm' append p { @@ -36,7 +36,7 @@ append p { } append p 'current demos:' append ul for name, desc in opairs demos - li (a name, href: "/#{name}.html"), ': ', desc + li (a name, href: name), ': ', desc append p { "made with #{moon} by " diff --git a/app/init.moon b/app/init.moon new file mode 100644 index 0000000..6895782 --- /dev/null +++ b/app/init.moon @@ -0,0 +1,94 @@ +require = relative ... +import opairs from require 'lib.ordered' + +merge = (tables) -> + first = table.remove tables, 1 + for tbl in *tables + for k,v in pairs tbl + first[k] = v + first + +experiments = + twisted: { + desc: 'canvas animation' + render: -> require '.twisted' + }, + todo: { + desc: 'Todo demo of a simple reactive UI framework' + render: -> require '.todo' + }, + realities: { + desc: 'draft of a paper on virtual and other realities' + render: -> require '.realities' + }, + center_of_mass: { + desc: 'aligning characters by their centers of mass' + render: -> require '.center_of_mass' + }, + test_component: { + desc: 'Test suite for the UI framework' + render: -> require '.test_component' + }, + tags: { + desc: 'Playground for Functional Tags' + render: -> require '.tags' + }, + +destify = (name, route) -> + name, with route + .route = name + .dest = "#{name}/index.html" + +routes = { destify k,v for k,v in pairs experiments } + +patch_redirs = -> + redirs = + 'center-of-mass': 'center_of_mass', + 'test-component': 'test_component', + 'play-tags': 'tags', + + { :location } = window + if location.search and #location.search > 1 + name = location.search\sub 2 + location.href = redirs[name] or name + +routes.index = { + route: '' + dest: 'index.html' + render: => + import h1, p, a, br, ul, tt, li from require 'lib.html' + import opairs from require 'lib.ordered' + + moon = '\xe2\x98\xbd' + + -- redirects for old-style URIs + on_client patch_redirs + + -- menu + append h1 'mmm' + append p { + tt 'mmm' + ' is not the ' + tt 'www' + ', because it runs on ' + a { 'MoonScript', href: 'https://moonscript.org' } + '.' + br! + 'You can find the source code of everything ' + a { 'here', href: 'https://github.com/s-ol/mmm' } + '.' + } + append p 'current demos:' + append ul for name, { :desc, :route } in opairs experiments + li (a name, href: route), ': ', desc + + append p { + "made with #{moon} by " + a { 's-ol', href: 'https://twitter.com/S0lll0s' } + } +} + +{ + :routes, + render: (name) -> require ".#{name}" +} diff --git a/dist b/dist -Subproject eebe79c04907788f8df1f86f0a477d691385e7c +Subproject 8325b7fb13f2bf6a9e153d8a934d3bc31b281d2 diff --git a/lib/init.client.moon b/lib/init.client.moon index 53f3569..731fd87 100644 --- a/lib/init.client.moon +++ b/lib/init.client.moon @@ -9,7 +9,7 @@ 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' +package.path = '/?.shared.moon.lua;/?.client.moon.lua;/?.moon.lua;/?/init.moon.lua;/?.lua;/?/init.lua' -- relative imports relative = (...) -> diff --git a/render.moon b/render.moon index 00f4946..8dca141 100644 --- a/render.moon +++ b/render.moon @@ -1,25 +1,22 @@ package.moonpath = './?.shared.moon;./?.server.moon;' .. package.moonpath import flush from require 'lib.init' -error "please specify the module to build as an argumnet" unless arg[1] +import routes from require 'app' -require "app.#{arg[1]}" - -load_file = (name) -> - file = io.open name - with file\read '*a' - file\close! +route_name = assert arg[1], "please specify the route name to build as an argument" +route = assert routes[route_name], "route not found: '#{route_name}'" +route\render! print "<!DOCTYPE html> <html> <head> <meta charset=\"UTF-8\"> <title>MMM: lunar low-gravity scripting playground</title> - <link rel=\"stylesheet\" type=\"text/css\" href=\"main.css\" /> + <link rel=\"stylesheet\" type=\"text/css\" href=\"/main.css\" /> </head> <body> - <script src=\"fengari-web.js\"></script> - <script type=\"application/lua\" src=\"lib/init.client.moon.lua\"></script> + <script src=\"/fengari-web.js\"></script> + <script type=\"application/lua\" src=\"/lib/init.client.moon.lua\"></script> #{flush!} </body> </html>" diff --git a/tup.moon b/tup.moon new file mode 100644 index 0000000..289dba0 --- /dev/null +++ b/tup.moon @@ -0,0 +1,7 @@ +package.moonpath = './?.shared.moon;./?.server.moon;' .. package.moonpath +require 'lib.init' +import routes from require 'app' +import opairs from require 'lib.ordered' + +for name, { :dest } in opairs routes + print ": |> ^ HTML #{name}^ moon render.moon #{name} > %o |> dist/#{dest}" |
