mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-02 07:06:41 +03:00
delete button, less refreshing
This commit is contained in:
parent
ee6deae576
commit
2231f29fdc
@ -128,6 +128,7 @@
|
|||||||
++ poke-kiln-unsync (wrap poke-unsync):from-kiln
|
++ poke-kiln-unsync (wrap poke-unsync):from-kiln
|
||||||
++ poke-write-paste (wrap poke-paste):from-write
|
++ poke-write-paste (wrap poke-paste):from-write
|
||||||
++ poke-write-tree (wrap poke-tree):from-write
|
++ poke-write-tree (wrap poke-tree):from-write
|
||||||
|
++ poke-write-wipe (wrap poke-wipe):from-write
|
||||||
++ poke-will (wrap poke-will):from-helm
|
++ poke-will (wrap poke-will):from-helm
|
||||||
++ quit-drum-phat (wrap quit-phat):from-drum
|
++ quit-drum-phat (wrap quit-phat):from-drum
|
||||||
++ reap-drum-phat (wrap reap-phat):from-drum
|
++ reap-drum-phat (wrap reap-phat):from-drum
|
||||||
|
@ -32,9 +32,17 @@
|
|||||||
:: pax/(cu deft (su fel:stab))
|
:: pax/(cu deft (su fel:stab))
|
||||||
:: dat/(of json/some mime/(pe / (cu taco so)) ~) :: XX mite
|
:: dat/(of json/some mime/(pe / (cu taco so)) ~) :: XX mite
|
||||||
:: ==
|
:: ==
|
||||||
|
++ poke-wipe
|
||||||
|
|= sup=spur ^+ abet :: XX determine extension, beak
|
||||||
|
=+ ext=%md
|
||||||
|
?~ (file (tope beak-now [ext sup]))
|
||||||
|
~|(not-found/[ext `path`(flop sup)] !!)
|
||||||
|
=- abet:(emit %info write/~ our -)
|
||||||
|
(fray (tope beak-now [ext sup]))
|
||||||
|
::
|
||||||
++ poke-tree
|
++ poke-tree
|
||||||
|= [sup=spur mim=mime] ^+ abet
|
|= [sup=spur mim=mime] ^+ abet :: XX determine extension, beak
|
||||||
(poke--data [`%md (flop sup)] %mime mim) :: XX determine extension
|
(poke--data [`%md (flop sup)] %mime mim)
|
||||||
::
|
::
|
||||||
++ poke-paste
|
++ poke-paste
|
||||||
|= [typ=?(%hoon %md %txt) txt=@t] ^+ abet
|
|= [typ=?(%hoon %md %txt) txt=@t] ^+ abet
|
||||||
|
12
mar/write/paste.hoon
Normal file
12
mar/write/paste.hoon
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
::
|
||||||
|
:::: /hoon/core/save/mar
|
||||||
|
::
|
||||||
|
!:
|
||||||
|
|_ [typ=?(%hoon %md %txt) txt=@t]
|
||||||
|
++ grab
|
||||||
|
|%
|
||||||
|
++ noun ,[?(%hoon %md %txt) @t]
|
||||||
|
++ json
|
||||||
|
(corl need =>(jo (ot typ/(ci (soft ?(%hoon %md %txt)) so) txt/so ~)))
|
||||||
|
--
|
||||||
|
--
|
13
mar/write/tree.hoon
Normal file
13
mar/write/tree.hoon
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
::
|
||||||
|
:::: /hoon/core/save/mar
|
||||||
|
::
|
||||||
|
!:
|
||||||
|
|_ [sup=spur mim=mime]
|
||||||
|
++ grab
|
||||||
|
|%
|
||||||
|
++ noun ,[spur mime]
|
||||||
|
++ json
|
||||||
|
%+ corl need :: XX {pax, mite, octs}
|
||||||
|
=>(jo (ot sup/(su fel:stab) mime/(cu |=(a=@t [/ (taco a)]) so) ~))
|
||||||
|
--
|
||||||
|
--
|
11
mar/write/wipe.hoon
Normal file
11
mar/write/wipe.hoon
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
::
|
||||||
|
:::: /hoon/core/save/mar
|
||||||
|
::
|
||||||
|
!:
|
||||||
|
|_ spur
|
||||||
|
++ grab
|
||||||
|
|%
|
||||||
|
++ noun spur
|
||||||
|
++ json (corl need (su:jo fel:stab))
|
||||||
|
--
|
||||||
|
--
|
@ -21,3 +21,8 @@ module.exports =
|
|||||||
TreePersistence.put spur, mime, (err,res)->
|
TreePersistence.put spur, mime, (err,res)->
|
||||||
if err? then throw err
|
if err? then throw err
|
||||||
if cb? then cb res
|
if cb? then cb res
|
||||||
|
|
||||||
|
deleteFile: (spur, cb) ->
|
||||||
|
TreePersistence.del spur, (err,res)->
|
||||||
|
if err? then throw err
|
||||||
|
if cb? then cb res
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
clas = require 'classnames'
|
clas = require 'classnames'
|
||||||
|
|
||||||
|
load = require './LoadComponent.coffee'
|
||||||
query = require './Async.coffee'
|
query = require './Async.coffee'
|
||||||
reactify = require './Reactify.coffee'
|
reactify = require './Reactify.coffee'
|
||||||
codemirror = require './CodeMirror.coffee'
|
codemirror = require './CodeMirror.coffee'
|
||||||
@ -81,11 +82,20 @@ Add = recl
|
|||||||
else
|
else
|
||||||
input {type:"text",onKeyDown:(e)=>
|
input {type:"text",onKeyDown:(e)=>
|
||||||
if 13 is e.keyCode
|
if 13 is e.keyCode
|
||||||
neu = @getDOMNode().value
|
{value} = @getDOMNode()
|
||||||
newPath = @props.path+"/"+neu
|
escp = value.toLowerCase().replace(/[^a-z0-9._~-]+/g, '-')
|
||||||
|
newPath = @props.path+"/"+escp
|
||||||
|
newSpur = "/"+escp+@props.spur
|
||||||
history.pushState {}, "", window.tree.basepath newPath + "#edit"
|
history.pushState {}, "", window.tree.basepath newPath + "#edit"
|
||||||
TreeActions.saveFile "/"+neu+@props.spur, '', ->
|
# TreeActions.setCurr newPath # XX indirect through Anchor poll
|
||||||
# TreeActions.setCurr newPath
|
urb.onupdate = -> # disable autoreload
|
||||||
|
TreeActions.saveFile newSpur, '# '+value, ->
|
||||||
|
TreeActions.loadPath newPath, {
|
||||||
|
spur:newSpur
|
||||||
|
meta:{}
|
||||||
|
mime:{mite:"text/x-markdown",octs:'# '+value}
|
||||||
|
body:{gn:"div",ga:{},c:[{gn:"h1",ga:{},c:[value]}]}
|
||||||
|
}
|
||||||
@setState edit:false
|
@setState edit:false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,10 +113,14 @@ module.exports = query {
|
|||||||
@hash = document.location.hash
|
@hash = document.location.hash
|
||||||
document.location.hash = "#edit" # XX generic state<->hash binding
|
document.location.hash = "#edit" # XX generic state<->hash binding
|
||||||
@setState edit:true
|
@setState edit:true
|
||||||
|
urb.onupdate = -> # disable autoreload
|
||||||
unsetEdit: ->
|
unsetEdit: ->
|
||||||
document.location.hash = @hash ? ""
|
document.location.hash = @hash ? ""
|
||||||
@setState edit:false
|
|
||||||
document.location.reload() # XX sigh
|
document.location.reload() # XX sigh
|
||||||
|
# @setState edit:false
|
||||||
|
doDelete: ->
|
||||||
|
TreeActions.deleteFile @props.spur, => @unsetEdit()
|
||||||
|
@setState edit:"gone"
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
className = clas (@props.meta.layout?.split ',')
|
className = clas (@props.meta.layout?.split ',')
|
||||||
@ -114,17 +128,20 @@ module.exports = query {
|
|||||||
extra = (name,props={})=>
|
extra = (name,props={})=>
|
||||||
if @props.meta[name]? then rele extras[name], props
|
if @props.meta[name]? then rele extras[name], props
|
||||||
|
|
||||||
unless @state.edit
|
switch @state.edit
|
||||||
body = reactify @props.body
|
when false
|
||||||
editButton = button {onClick: => @setEdit()}, "Edit"
|
body = reactify @props.body
|
||||||
|
editButton = button {onClick: => @setEdit()}, "Edit"
|
||||||
else
|
when "pending", "gone"
|
||||||
body = rele Edit, {}
|
body = div {}, rele load, {}
|
||||||
|
editButton = button {onClick: => @setEdit()}, "Edit"
|
||||||
onClick = =>
|
when true
|
||||||
txt = $(@getDOMNode()).find('.CodeMirror')[0].CodeMirror.getValue() # XX refs
|
body = rele Edit, {}
|
||||||
TreeActions.saveFile @props.spur, txt, => @unsetEdit()
|
onClick = =>
|
||||||
editButton = button {onClick}, "Done"
|
txt = $(@getDOMNode()).find('.CodeMirror')[0].CodeMirror.getValue() # XX refs
|
||||||
|
TreeActions.saveFile @props.spur, txt, => @unsetEdit()
|
||||||
|
@setState edit:"pending"
|
||||||
|
editButton = button {onClick}, "Done"
|
||||||
|
|
||||||
(div {
|
(div {
|
||||||
id:'body',
|
id:'body',
|
||||||
@ -134,6 +151,7 @@ module.exports = query {
|
|||||||
extra 'spam'
|
extra 'spam'
|
||||||
extra 'logo', color: @props.meta.logo
|
extra 'logo', color: @props.meta.logo
|
||||||
if own then editButton
|
if own then editButton
|
||||||
|
if own then button {onClick: => @doDelete()}, "Delete"
|
||||||
body
|
body
|
||||||
extra 'next', {dataPath:@props.sein,curr:@props.name}
|
extra 'next', {dataPath:@props.sein,curr:@props.name}
|
||||||
if own then rele Add,{spur:@props.spur, path:@props.path}
|
if own then rele Add,{spur:@props.spur, path:@props.path}
|
||||||
|
@ -44,6 +44,16 @@ module.exports = {
|
|||||||
return cb(res);
|
return cb(res);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
deleteFile: function(spur, cb) {
|
||||||
|
return TreePersistence.del(spur, function(err, res) {
|
||||||
|
if (err != null) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
if (cb != null) {
|
||||||
|
return cb(res);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -443,10 +453,12 @@ module.exports = function(queries, Child, load) {
|
|||||||
|
|
||||||
|
|
||||||
},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":21,"./LoadComponent.coffee":10}],4:[function(require,module,exports){
|
},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":21,"./LoadComponent.coffee":10}],4:[function(require,module,exports){
|
||||||
var Add, Edit, TreeActions, a, button, clas, codemirror, div, extras, img, input, p, pre, query, reactify, recl, ref, rele;
|
var Add, Edit, TreeActions, a, button, clas, codemirror, div, extras, img, input, load, p, pre, query, reactify, recl, ref, rele;
|
||||||
|
|
||||||
clas = require('classnames');
|
clas = require('classnames');
|
||||||
|
|
||||||
|
load = require('./LoadComponent.coffee');
|
||||||
|
|
||||||
query = require('./Async.coffee');
|
query = require('./Async.coffee');
|
||||||
|
|
||||||
reactify = require('./Reactify.coffee');
|
reactify = require('./Reactify.coffee');
|
||||||
@ -583,12 +595,34 @@ Add = recl({
|
|||||||
type: "text",
|
type: "text",
|
||||||
onKeyDown: (function(_this) {
|
onKeyDown: (function(_this) {
|
||||||
return function(e) {
|
return function(e) {
|
||||||
var neu, newPath;
|
var escp, newPath, newSpur, value;
|
||||||
if (13 === e.keyCode) {
|
if (13 === e.keyCode) {
|
||||||
neu = _this.getDOMNode().value;
|
value = _this.getDOMNode().value;
|
||||||
newPath = _this.props.path + "/" + neu;
|
escp = value.toLowerCase().replace(/[^a-z0-9._~-]+/g, '-');
|
||||||
|
newPath = _this.props.path + "/" + escp;
|
||||||
|
newSpur = "/" + escp + _this.props.spur;
|
||||||
history.pushState({}, "", window.tree.basepath(newPath + "#edit"));
|
history.pushState({}, "", window.tree.basepath(newPath + "#edit"));
|
||||||
TreeActions.saveFile("/" + neu + _this.props.spur, '', function() {});
|
urb.onupdate = function() {};
|
||||||
|
TreeActions.saveFile(newSpur, '# ' + value, function() {});
|
||||||
|
TreeActions.loadPath(newPath, {
|
||||||
|
spur: newSpur,
|
||||||
|
meta: {},
|
||||||
|
mime: {
|
||||||
|
mite: "text/x-markdown",
|
||||||
|
octs: '# ' + value
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
gn: "div",
|
||||||
|
ga: {},
|
||||||
|
c: [
|
||||||
|
{
|
||||||
|
gn: "h1",
|
||||||
|
ga: {},
|
||||||
|
c: [value]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
return _this.setState({
|
return _this.setState({
|
||||||
edit: false
|
edit: false
|
||||||
});
|
});
|
||||||
@ -617,18 +651,26 @@ module.exports = query({
|
|||||||
setEdit: function() {
|
setEdit: function() {
|
||||||
this.hash = document.location.hash;
|
this.hash = document.location.hash;
|
||||||
document.location.hash = "#edit";
|
document.location.hash = "#edit";
|
||||||
return this.setState({
|
this.setState({
|
||||||
edit: true
|
edit: true
|
||||||
});
|
});
|
||||||
|
return urb.onupdate = function() {};
|
||||||
},
|
},
|
||||||
unsetEdit: function() {
|
unsetEdit: function() {
|
||||||
var ref1;
|
var ref1;
|
||||||
document.location.hash = (ref1 = this.hash) != null ? ref1 : "";
|
document.location.hash = (ref1 = this.hash) != null ? ref1 : "";
|
||||||
this.setState({
|
|
||||||
edit: false
|
|
||||||
});
|
|
||||||
return document.location.reload();
|
return document.location.reload();
|
||||||
},
|
},
|
||||||
|
doDelete: function() {
|
||||||
|
TreeActions.deleteFile(this.props.spur, (function(_this) {
|
||||||
|
return function() {
|
||||||
|
return _this.unsetEdit();
|
||||||
|
};
|
||||||
|
})(this));
|
||||||
|
return this.setState({
|
||||||
|
edit: "gone"
|
||||||
|
});
|
||||||
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var body, className, editButton, extra, onClick, own, ref1;
|
var body, className, editButton, extra, onClick, own, ref1;
|
||||||
className = clas((ref1 = this.props.meta.layout) != null ? ref1.split(',') : void 0);
|
className = clas((ref1 = this.props.meta.layout) != null ? ref1.split(',') : void 0);
|
||||||
@ -643,29 +685,45 @@ module.exports = query({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(this);
|
})(this);
|
||||||
if (!this.state.edit) {
|
switch (this.state.edit) {
|
||||||
body = reactify(this.props.body);
|
case false:
|
||||||
editButton = button({
|
body = reactify(this.props.body);
|
||||||
onClick: (function(_this) {
|
editButton = button({
|
||||||
|
onClick: (function(_this) {
|
||||||
|
return function() {
|
||||||
|
return _this.setEdit();
|
||||||
|
};
|
||||||
|
})(this)
|
||||||
|
}, "Edit");
|
||||||
|
break;
|
||||||
|
case "pending":
|
||||||
|
case "gone":
|
||||||
|
body = div({}, rele(load, {}));
|
||||||
|
editButton = button({
|
||||||
|
onClick: (function(_this) {
|
||||||
|
return function() {
|
||||||
|
return _this.setEdit();
|
||||||
|
};
|
||||||
|
})(this)
|
||||||
|
}, "Edit");
|
||||||
|
break;
|
||||||
|
case true:
|
||||||
|
body = rele(Edit, {});
|
||||||
|
onClick = (function(_this) {
|
||||||
return function() {
|
return function() {
|
||||||
return _this.setEdit();
|
var txt;
|
||||||
|
txt = $(_this.getDOMNode()).find('.CodeMirror')[0].CodeMirror.getValue();
|
||||||
|
TreeActions.saveFile(_this.props.spur, txt, function() {
|
||||||
|
return _this.unsetEdit();
|
||||||
|
});
|
||||||
|
return _this.setState({
|
||||||
|
edit: "pending"
|
||||||
|
});
|
||||||
};
|
};
|
||||||
})(this)
|
})(this);
|
||||||
}, "Edit");
|
editButton = button({
|
||||||
} else {
|
onClick: onClick
|
||||||
body = rele(Edit, {});
|
}, "Done");
|
||||||
onClick = (function(_this) {
|
|
||||||
return function() {
|
|
||||||
var txt;
|
|
||||||
txt = $(_this.getDOMNode()).find('.CodeMirror')[0].CodeMirror.getValue();
|
|
||||||
return TreeActions.saveFile(_this.props.spur, txt, function() {
|
|
||||||
return _this.unsetEdit();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
})(this);
|
|
||||||
editButton = button({
|
|
||||||
onClick: onClick
|
|
||||||
}, "Done");
|
|
||||||
}
|
}
|
||||||
return div({
|
return div({
|
||||||
id: 'body',
|
id: 'body',
|
||||||
@ -673,7 +731,13 @@ module.exports = query({
|
|||||||
className: className
|
className: className
|
||||||
}, extra('spam'), extra('logo', {
|
}, extra('spam'), extra('logo', {
|
||||||
color: this.props.meta.logo
|
color: this.props.meta.logo
|
||||||
}), own ? editButton : void 0, body, extra('next', {
|
}), own ? editButton : void 0, own ? button({
|
||||||
|
onClick: (function(_this) {
|
||||||
|
return function() {
|
||||||
|
return _this.doDelete();
|
||||||
|
};
|
||||||
|
})(this)
|
||||||
|
}, "Delete") : void 0, body, extra('next', {
|
||||||
dataPath: this.props.sein,
|
dataPath: this.props.sein,
|
||||||
curr: this.props.name
|
curr: this.props.name
|
||||||
}), own ? rele(Add, {
|
}), own ? rele(Add, {
|
||||||
@ -685,7 +749,7 @@ module.exports = query({
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
},{"../actions/TreeActions.coffee":1,"./Async.coffee":3,"./CodeMirror.coffee":5,"./Reactify.coffee":11,"classnames":16}],5:[function(require,module,exports){
|
},{"../actions/TreeActions.coffee":1,"./Async.coffee":3,"./CodeMirror.coffee":5,"./LoadComponent.coffee":10,"./Reactify.coffee":11,"classnames":16}],5:[function(require,module,exports){
|
||||||
var div, recl, ref, textarea;
|
var div, recl, ref, textarea;
|
||||||
|
|
||||||
recl = React.createClass;
|
recl = React.createClass;
|
||||||
@ -2001,14 +2065,20 @@ dedup = {};
|
|||||||
|
|
||||||
if (urb.send) {
|
if (urb.send) {
|
||||||
urb.appl = 'hood';
|
urb.appl = 'hood';
|
||||||
urb.send.mark = 'write-tree';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
del: function(sup, cb) {
|
||||||
|
return urb.send(sup, {
|
||||||
|
mark: 'write-wipe'
|
||||||
|
}, cb);
|
||||||
|
},
|
||||||
put: function(sup, mime, cb) {
|
put: function(sup, mime, cb) {
|
||||||
return urb.send({
|
return urb.send({
|
||||||
sup: sup,
|
sup: sup,
|
||||||
mime: mime
|
mime: mime
|
||||||
|
}, {
|
||||||
|
mark: 'write-tree'
|
||||||
}, cb);
|
}, cb);
|
||||||
},
|
},
|
||||||
get: function(path, query, cb) {
|
get: function(path, query, cb) {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
dedup = {} # XX wrong layer
|
dedup = {} # XX wrong layer
|
||||||
if urb.send
|
if urb.send
|
||||||
urb.appl = 'hood'
|
urb.appl = 'hood'
|
||||||
urb.send.mark = 'write-tree'
|
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
put: (sup,mime,cb)-> urb.send {sup,mime},cb
|
del: (sup,cb)-> urb.send sup,{mark:'write-wipe'}, cb
|
||||||
|
put: (sup,mime,cb)-> urb.send {sup,mime},{mark:'write-tree'}, cb
|
||||||
|
|
||||||
get: (path,query="no-query",cb) ->
|
get: (path,query="no-query",cb) ->
|
||||||
url = "#{window.tree.basepath(path)}.json?q=#{@encode query}"
|
url = "#{window.tree.basepath(path)}.json?q=#{@encode query}"
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
[;script(type "text/javascript", src "/~/as/own/~/at/home/lib/urb.js");]~
|
[;script(type "text/javascript", src "/~/as/own/~/at/home/lib/urb.js");]~
|
||||||
==
|
==
|
||||||
;body
|
;body
|
||||||
;+ =+ inject=(jobe kids/kids-json body/body.dat ~)
|
;+ =+ mime=(jobe mite/[%s (moon p.mime.dat)] octs/[%s q.q.mime.dat] ~) :: XX factor out
|
||||||
|
=+ inject=(jobe kids/kids-json body/body.dat ?.(aut ~ [mime/mime]~))
|
||||||
;script(type "text/javascript"): window.tree = {(pojo inject)}
|
;script(type "text/javascript"): window.tree = {(pojo inject)}
|
||||||
;div#nav;
|
;div#nav;
|
||||||
;div#cont;
|
;div#cont;
|
||||||
|
Loading…
Reference in New Issue
Block a user