aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-11-01 12:48:24 +0000
committers-ol <s-ol@users.noreply.github.com>2019-11-01 12:48:24 +0000
commit16232a2509a87a900b69b2d0f826a2e3edec3f96 (patch)
tree801c1234e5e227acb1e1015d6b71bf77ac15b474
parentfsck root dir (diff)
downloadmmm-16232a2509a87a900b69b2d0f826a2e3edec3f96.tar.gz
mmm-16232a2509a87a900b69b2d0f826a2e3edec3f96.zip
add fileder ordering in stores.web, fileder, browser
-rw-r--r--build/server.moon18
-rw-r--r--mmm/mmmfs/browser.moon4
-rw-r--r--mmm/mmmfs/fileder.moon6
-rw-r--r--mmm/mmmfs/stores/web.moon3
4 files changed, 26 insertions, 5 deletions
diff --git a/build/server.moon b/build/server.moon
index 395b903..a2d6c71 100644
--- a/build/server.moon
+++ b/build/server.moon
@@ -138,7 +138,18 @@ class Server
@store\update_facet path, facet.name, facet.type, value
200, 'ok'
else
- 501, "not implemented"
+ cmd, args = value\match '^([^\n]+)\n(.*)'
+ switch cmd
+ when 'swap'
+ child_a, child_b = args\match '^([^\n]+)\n([^\n]+)$'
+ assert child_a and child_b, "invalid arguments"
+
+ @store\swap_fileders path, child_a, child_b
+ 200, 'ok'
+ when nil
+ 400, "invalid request"
+ else
+ 501, "unknown command #{cmd}"
when 'DELETE'
if facet
@store\remove_facet path, facet.name, facet.type
@@ -175,8 +186,9 @@ class Server
res = headers.new!
response_type = if status > 299 then 'text/plain'
- else if facet.type == 'text/html+interactive' then 'text/html'
- else facet.type
+ else if facet and facet.type == 'text/html+interactive' then 'text/html'
+ else if facet then facet.type
+ else 'text/plain'
res\append ':status', tostring status
res\append 'content-type', response_type
diff --git a/mmm/mmmfs/browser.moon b/mmm/mmmfs/browser.moon
index 6020eb7..e06364c 100644
--- a/mmm/mmmfs/browser.moon
+++ b/mmm/mmmfs/browser.moon
@@ -279,11 +279,11 @@ class Browser
span '- ', (link_to child, code name), style: flex: 1
button '↑', disabled: i == 1, onclick: (_, e) ->
- fileder\reorder_child name, i - 1
+ fileder\swap_children i, i - 1
@refresh true
button '↓', disabled: i == num, onclick: (_, e) ->
- fileder\reorder_child name, i + 1
+ fileder\swap_children i, i + 1
@refresh true
button 'rm', onclick: (_, e) ->
diff --git a/mmm/mmmfs/fileder.moon b/mmm/mmmfs/fileder.moon
index b42c6dd..871f46f 100644
--- a/mmm/mmmfs/fileder.moon
+++ b/mmm/mmmfs/fileder.moon
@@ -79,6 +79,7 @@ class Fileder
__newindex: (t, k, child) ->
rawset t, k, child
+ return if child.path
if @path == '/'
child\mount '/'
@@ -318,6 +319,11 @@ class Fileder
assert removed, "no such child fileder"
@store\remove_fileder removed.path
+ swap_children: (ia, ib) =>
+ a, b = @children[ia], @children[ib]
+ @store\swap_fileders @path, (a\gett 'name: alpha'), (b\gett 'name: alpha')
+ @children[ia], @children[ib] = b, a
+
__tostring: => "Fileder:#{@path}"
{
diff --git a/mmm/mmmfs/stores/web.moon b/mmm/mmmfs/stores/web.moon
index b498d79..ddbd74d 100644
--- a/mmm/mmmfs/stores/web.moon
+++ b/mmm/mmmfs/stores/web.moon
@@ -77,6 +77,9 @@ class WebStore extends Store
@log "moving fileder #{path} -> #{next_parent}/"
error "not implemented"
+ swap_fileders: (parent, child_a, child_b) =>
+ req 'PUT', "#{@host .. parent}/", "swap\n#{child_a}\n#{child_b}"
+
-- facets
list_facets: (path) =>
coroutine.wrap ->