refactored tree json into separate hooks

This commit is contained in:
Anton Dyudin 2015-07-30 15:25:58 -07:00
parent 6c65a950e0
commit fba6d51505
6 changed files with 90 additions and 59 deletions

View File

@ -1139,12 +1139,15 @@ module.exports = invariant;
},{}],14:[function(require,module,exports){
module.exports = {
get: function(path, query, cb) {
get: function(path, type, cb) {
var url;
url = (window.tree.basepath(path)) + ".json";
if (query) {
url += "?" + query;
if (type == null) {
type = "body";
}
if (path[0] !== "/") {
path = "/" + path;
}
url = (window.tree.basepath(type + path)) + ".json";
return $.get(url, {}, function(data) {
if (cb) {
return cb(null, data);

View File

@ -1,5 +1,5 @@
module.exports =
get: (path,query,cb) ->
url = "#{window.tree.basepath(path)}.json"
if query then url += "?#{query}"
get: (path,type="body",cb) ->
if path[0] isnt "/" then path = "/" + path
url = "#{window.tree.basepath(type+path)}.json"
$.get url, {}, (data) -> if cb then cb null,data

22
tree/body/json.hook Normal file
View File

@ -0,0 +1,22 @@
::
:::: /hook/json/body/tree
::
/? 314
/= gas /$ fuel
/= dat /: /=== /% /react-json/
::
::::
::
// /%%%/util
::
[util=. +>]
::
!:
::::
::
^- json
=+ ~(. util gas)
%- jobe :~
kids/[%a (turn get-kids |=(a=span s/a))]
body/dat
==

View File

@ -1,52 +0,0 @@
::
/? 314
/= gas /$ fuel
/= ral /: /=== /% /react-json/
/= pal /: /===
/^ (map ,@ta json)
/% 2
/_ /react-json/
::
/= sal /: /===
/^ (map ,@ta json)
/% 2
/_ /react-snips-json/
::
::::
::
// /%%/util
::
[util=. +>]
::
!:
::::
::
^- json
=+ ~(. util gas)
:: .json?kids
?: (~(has by qix.gas) %kids)
%+ joba %kids
=. pal (~(del by pal) %md) :: XX haxor
=- [%a (turn (~(tap by pal)) -)]
|= [a=span b=json]
%- jobe :~
name/s/a
body/b
==
:: .json?snip
?: (~(has by qix.gas) %snip)
%+ joba %snip
=. sal (~(del by sal) %md) :: XX haxor
=- [%a (turn (~(tap by sal)) -)]
|= [a=span b=json]
=+ fon=(json-front b)
%- jobe :~
meta/fon
name/s/a
body/b
==
:: .json
%- jobe :~
kids/[%a (turn get-kids |=(a=span s/a))]
body/ral
==

28
tree/kids/json.hook Normal file
View File

@ -0,0 +1,28 @@
::
:::: /hook/json/kids/tree
::
/? 314
/= gas /$ fuel
/= dat /: /===
/^ (map ,@ta json)
/% 2
/_ /react-json/
::
::::
::
// /%%%/util
::
[util=. +>]
::
!:
::::
::
^- json
=+ ~(. util gas)
%+ joba %kids
=- [%a (turn (~(tap by dat)) -)]
|= [a=span b=json]
%- jobe :~
name/s/a
body/b
==

30
tree/snip/json.hook Normal file
View File

@ -0,0 +1,30 @@
::
:::: /hook/json/snip/tree
::
/? 314
/= gas /$ fuel
/= dat /: /===
/^ (map ,@ta json)
/% 2
/_ /react-snips-json/
::
::::
::
// /%%%/util
::
[util=. +>]
::
!:
::::
::
^- json
=+ ~(. util gas)
%+ joba %snip
=- [%a (turn (~(tap by dat)) -)]
|= [a=span b=json]
=+ fon=(json-front b)
%- jobe :~
meta/fon
name/s/a
body/b
==