mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-02 07:06:41 +03:00
save: md only
This commit is contained in:
parent
f6b1a6779a
commit
473e0e08cf
@ -127,6 +127,7 @@
|
||||
++ poke-kiln-unmount (wrap poke-unmount):from-kiln
|
||||
++ poke-kiln-unsync (wrap poke-unsync):from-kiln
|
||||
++ poke-write-paste (wrap poke-paste):from-write
|
||||
++ poke-write-tree (wrap poke-tree):from-write
|
||||
++ poke-will (wrap poke-will):from-helm
|
||||
++ quit-drum-phat (wrap quit-phat):from-drum
|
||||
++ reap-drum-phat (wrap reap-phat):from-drum
|
||||
|
@ -32,6 +32,9 @@
|
||||
:: pax/(cu deft (su fel:stab))
|
||||
:: dat/(of json/some mime/(pe / (cu taco so)) ~) :: XX mite
|
||||
:: ==
|
||||
++ poke-tree
|
||||
|= [sup=spur mim=mime] ^+ abet
|
||||
(poke--data [`%md (flop sup)] %mime mim) :: XX determine extension
|
||||
::
|
||||
++ poke-paste
|
||||
|= [typ=?(%hoon %md %txt) txt=@t] ^+ abet
|
||||
|
@ -8,9 +8,16 @@ module.exports =
|
||||
sendQuery: (path,query) ->
|
||||
return unless query?
|
||||
if path.slice(-1) is "/" then path = path.slice(0,-1)
|
||||
TreePersistence.get path,query,(err,res) => @loadPath path,res
|
||||
TreePersistence.get path,query,(err,res) =>
|
||||
if err? then throw err
|
||||
@loadPath path,res
|
||||
|
||||
setCurr: (path) ->
|
||||
TreeDispatcher.handleViewAction
|
||||
type:"set-curr"
|
||||
path:path
|
||||
|
||||
saveFile: (spur, mime, cb) ->
|
||||
TreePersistence.put spur, mime, (err,res)->
|
||||
if err? then throw err
|
||||
cb res
|
||||
|
@ -4,6 +4,8 @@ query = require './Async.coffee'
|
||||
reactify = require './Reactify.coffee'
|
||||
codemirror = require './CodeMirror.coffee'
|
||||
|
||||
TreeActions = require '../actions/TreeActions.coffee'
|
||||
|
||||
recl = React.createClass
|
||||
rele = React.createElement
|
||||
{div,pre,p,img,a,button} = React.DOM
|
||||
@ -64,7 +66,7 @@ Edit = query {mime:'m'}, recl
|
||||
displayName: "Edit"
|
||||
render: ->
|
||||
{mite,octs} = @props.mime
|
||||
codemirror {value:octs, readOnly:false, mode:mite}
|
||||
rele codemirror, {value:octs, readOnly:false, mode:mite}
|
||||
|
||||
module.exports = query {
|
||||
body:'r'
|
||||
@ -72,19 +74,27 @@ module.exports = query {
|
||||
path:'t'
|
||||
meta:'j'
|
||||
sein:'t'
|
||||
spur:'t'
|
||||
}, recl
|
||||
displayName: "Body"
|
||||
getInitialState: -> edit:false
|
||||
render: ->
|
||||
className = clas (@props.meta.layout?.split ',')
|
||||
own = urb.ship is urb.user
|
||||
own = urb.user and urb.user is urb.ship
|
||||
extra = (name,props={})=>
|
||||
if @props.meta[name]? then rele extras[name], props
|
||||
|
||||
body =
|
||||
if @state.edit
|
||||
rele Edit, {onFinish:=> @setState edit:false}
|
||||
else reactify @props.body
|
||||
unless @state.edit
|
||||
body = reactify @props.body
|
||||
editButton = button {onClick: => @setState edit:true}, "Edit"
|
||||
|
||||
else
|
||||
body = rele Edit, {}
|
||||
|
||||
onClick = =>
|
||||
txt = $(@getDOMNode()).find('.CodeMirror')[0].CodeMirror.getValue() # XX refs
|
||||
TreeActions.saveFile @props.spur, txt, => @setState edit:false
|
||||
editButton = button {onClick}, "Done"
|
||||
|
||||
(div {
|
||||
id:'body',
|
||||
@ -93,8 +103,7 @@ module.exports = query {
|
||||
},
|
||||
extra 'spam'
|
||||
extra 'logo', color: @props.meta.logo
|
||||
if own
|
||||
button {onClick: => @setState edit:true}, "Edit"
|
||||
if own then editButton
|
||||
body
|
||||
extra 'next', {dataPath:@props.sein,curr:@props.name}
|
||||
if own then button {}, "Add"
|
||||
|
@ -2,7 +2,7 @@ recl = React.createClass
|
||||
{div,textarea} = React.DOM
|
||||
|
||||
module.exports = recl
|
||||
render: -> div {}, textarea ref:'ed', value:@props.value
|
||||
render: -> div {}, textarea ref:'ed', defaultValue:@props.value
|
||||
componentDidMount: ->
|
||||
CodeMirror.fromTextArea @refs.ed.getDOMNode(),
|
||||
_.extend {readOnly:true,lineNumbers:true}, @props
|
||||
|
@ -22,6 +22,9 @@ module.exports = {
|
||||
}
|
||||
return TreePersistence.get(path, query, (function(_this) {
|
||||
return function(err, res) {
|
||||
if (err != null) {
|
||||
throw err;
|
||||
}
|
||||
return _this.loadPath(path, res);
|
||||
};
|
||||
})(this));
|
||||
@ -31,6 +34,14 @@ module.exports = {
|
||||
type: "set-curr",
|
||||
path: path
|
||||
});
|
||||
},
|
||||
saveFile: function(spur, mime, cb) {
|
||||
return TreePersistence.put(spur, mime, function(err, res) {
|
||||
if (err != null) {
|
||||
throw err;
|
||||
}
|
||||
return cb(res);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -428,7 +439,7 @@ module.exports = function(queries, Child, load) {
|
||||
|
||||
|
||||
},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":21,"./LoadComponent.coffee":10}],4:[function(require,module,exports){
|
||||
var Edit, a, button, clas, codemirror, div, extras, img, p, pre, query, reactify, recl, ref, rele;
|
||||
var Edit, TreeActions, a, button, clas, codemirror, div, extras, img, p, pre, query, reactify, recl, ref, rele;
|
||||
|
||||
clas = require('classnames');
|
||||
|
||||
@ -438,6 +449,8 @@ reactify = require('./Reactify.coffee');
|
||||
|
||||
codemirror = require('./CodeMirror.coffee');
|
||||
|
||||
TreeActions = require('../actions/TreeActions.coffee');
|
||||
|
||||
recl = React.createClass;
|
||||
|
||||
rele = React.createElement;
|
||||
@ -530,7 +543,7 @@ Edit = query({
|
||||
render: function() {
|
||||
var mite, octs, ref1;
|
||||
ref1 = this.props.mime, mite = ref1.mite, octs = ref1.octs;
|
||||
return codemirror({
|
||||
return rele(codemirror, {
|
||||
value: octs,
|
||||
readOnly: false,
|
||||
mode: mite
|
||||
@ -543,7 +556,8 @@ module.exports = query({
|
||||
name: 't',
|
||||
path: 't',
|
||||
meta: 'j',
|
||||
sein: 't'
|
||||
sein: 't',
|
||||
spur: 't'
|
||||
}, recl({
|
||||
displayName: "Body",
|
||||
getInitialState: function() {
|
||||
@ -552,9 +566,9 @@ module.exports = query({
|
||||
};
|
||||
},
|
||||
render: function() {
|
||||
var body, className, extra, own, ref1;
|
||||
var body, className, editButton, extra, onClick, own, ref1;
|
||||
className = clas((ref1 = this.props.meta.layout) != null ? ref1.split(',') : void 0);
|
||||
own = urb.ship === urb.user;
|
||||
own = urb.user && urb.user === urb.ship;
|
||||
extra = (function(_this) {
|
||||
return function(name, props) {
|
||||
if (props == null) {
|
||||
@ -565,30 +579,41 @@ module.exports = query({
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
body = this.state.edit ? rele(Edit, {
|
||||
onFinish: (function(_this) {
|
||||
if (!this.state.edit) {
|
||||
body = reactify(this.props.body);
|
||||
editButton = button({
|
||||
onClick: (function(_this) {
|
||||
return function() {
|
||||
return _this.setState({
|
||||
edit: true
|
||||
});
|
||||
};
|
||||
})(this)
|
||||
}, "Edit");
|
||||
} else {
|
||||
body = rele(Edit, {});
|
||||
onClick = (function(_this) {
|
||||
return function() {
|
||||
return _this.setState({
|
||||
edit: false
|
||||
var txt;
|
||||
txt = $(_this.getDOMNode()).find('.CodeMirror')[0].CodeMirror.getValue();
|
||||
return TreeActions.saveFile(_this.props.spur, txt, function() {
|
||||
return _this.setState({
|
||||
edit: false
|
||||
});
|
||||
});
|
||||
};
|
||||
})(this)
|
||||
}) : reactify(this.props.body);
|
||||
})(this);
|
||||
editButton = button({
|
||||
onClick: onClick
|
||||
}, "Done");
|
||||
}
|
||||
return div({
|
||||
id: 'body',
|
||||
key: "body" + this.props.path,
|
||||
className: className
|
||||
}, extra('spam'), extra('logo', {
|
||||
color: this.props.meta.logo
|
||||
}), own ? button({
|
||||
onClick: (function(_this) {
|
||||
return function() {
|
||||
return _this.setState({
|
||||
edit: true
|
||||
});
|
||||
};
|
||||
})(this)
|
||||
}, "Edit") : void 0, body, extra('next', {
|
||||
}), own ? editButton : void 0, body, extra('next', {
|
||||
dataPath: this.props.sein,
|
||||
curr: this.props.name
|
||||
}), own ? button({}, "Add") : void 0, extra('footer'));
|
||||
@ -597,7 +622,7 @@ module.exports = query({
|
||||
|
||||
|
||||
|
||||
},{"./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,"./Reactify.coffee":11,"classnames":16}],5:[function(require,module,exports){
|
||||
var div, recl, ref, textarea;
|
||||
|
||||
recl = React.createClass;
|
||||
@ -608,7 +633,7 @@ module.exports = recl({
|
||||
render: function() {
|
||||
return div({}, textarea({
|
||||
ref: 'ed',
|
||||
value: this.props.value
|
||||
defaultValue: this.props.value
|
||||
}));
|
||||
},
|
||||
componentDidMount: function() {
|
||||
@ -1911,7 +1936,18 @@ var dedup;
|
||||
|
||||
dedup = {};
|
||||
|
||||
if (urb.send) {
|
||||
urb.appl = 'hood';
|
||||
urb.send.mark = 'write-tree';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
put: function(sup, mime, cb) {
|
||||
return urb.send({
|
||||
sup: sup,
|
||||
mime: mime
|
||||
}, cb);
|
||||
},
|
||||
get: function(path, query, cb) {
|
||||
var url;
|
||||
if (query == null) {
|
||||
@ -1986,7 +2022,8 @@ QUERIES = {
|
||||
snip: 'r',
|
||||
sect: 'j',
|
||||
meta: 'j',
|
||||
mime: 'm'
|
||||
mime: 'm',
|
||||
spur: 't'
|
||||
};
|
||||
|
||||
TreeStore = _.extend(EventEmitter.prototype, {
|
||||
|
@ -1,5 +1,11 @@
|
||||
dedup = {} # XX wrong layer
|
||||
if urb.send
|
||||
urb.appl = 'hood'
|
||||
urb.send.mark = 'write-tree'
|
||||
|
||||
module.exports =
|
||||
put: (sup,mime,cb)-> urb.send {sup,mime},cb
|
||||
|
||||
get: (path,query="no-query",cb) ->
|
||||
url = "#{window.tree.basepath(path)}.json?q=#{@encode query}"
|
||||
return if dedup[url]
|
||||
|
@ -7,7 +7,7 @@ _tree = {}
|
||||
_data = {}
|
||||
_curr = ""
|
||||
|
||||
QUERIES = {body:'r', head:'r', snip:'r', sect:'j', meta:'j', mime:'m'}
|
||||
QUERIES = {body:'r', head:'r', snip:'r', sect:'j', meta:'j', mime:'m', spur:'t'}
|
||||
|
||||
TreeStore = _.extend EventEmitter.prototype, {
|
||||
addChangeListener: (cb) -> @on 'change', cb
|
||||
|
@ -15,6 +15,7 @@
|
||||
::
|
||||
=+ dez=(trip &2:%)
|
||||
=+ kids-json=a/(turn (~(tap by kid)) |=([a=span *] (joba %name s/a)))
|
||||
=+ aut=(~(has ju aut.ced.gas) %$ (scot %p p.bem.gas))
|
||||
;html
|
||||
;head
|
||||
;title: Tree
|
||||
@ -33,6 +34,8 @@
|
||||
::;script(type "text/javascript", src "http://localhost:8000/docs/pub/tree/src/js/main.js");
|
||||
;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/".
|
||||
"codemirror/4.3.0/mode/markdown/markdown.min.js");
|
||||
;* ?. aut ~
|
||||
[;script(type "text/javascript", src "/~/as/own/~/at/home/lib/urb.js");]~
|
||||
==
|
||||
;body
|
||||
;+ =+ inject=(jobe kids/kids-json body/body.dat ~)
|
||||
|
@ -21,6 +21,7 @@
|
||||
$% [%kids p=(list query)]
|
||||
[%name %t]
|
||||
[%path %t]
|
||||
[%spur %t]
|
||||
[%sect %j]
|
||||
[%snip %r]
|
||||
[%head %r]
|
||||
@ -54,6 +55,7 @@
|
||||
?- -.a
|
||||
%name (from-type +.a ?^(s.bem i.s.bem q.bem))
|
||||
%path (from-type +.a (crip (spud (flop s.bem))))
|
||||
%spur (from-type +.a (crip (spud s.bem)))
|
||||
%head (from-type +.a head.dat)
|
||||
%snip (from-type +.a snip.dat)
|
||||
%sect (from-type +.a sect.dat)
|
||||
|
Loading…
Reference in New Issue
Block a user