From 552d388e179f61344803397c005f008f6ff4e8ef Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Tue, 12 May 2015 16:35:59 -0700 Subject: [PATCH 01/34] working do --- base/app/bit/core.hook | 9 +++++++-- base/pub/do/fab/hymn.hook | 4 ++-- base/pub/do/src/main.js | 33 +++++++++++++++++++++------------ 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/base/app/bit/core.hook b/base/app/bit/core.hook index a3dfb29ce..8e0a995bf 100644 --- a/base/app/bit/core.hook +++ b/base/app/bit/core.hook @@ -7,7 +7,7 @@ /+ talk, sole, http !: :::: sivtyv-barnel - :: be sure to have oauth2-code markk + :: be sure to have oauth2-code mark |% ++ axle cred ++ cred @@ -40,7 +40,7 @@ $: client-id=(unit ,@t) app-secret=(unit ,@t) ++ redirect-uri (crip (weld hostname "/~~/home/pub/bit/fab")) ++ hostname ?+ (clan our.hid) !! - %czar "http://104.236.139.191:{?+(our.hid !! %~zod "8443", %~reg "8444")}" + %czar "http://localhost:{?+(our.hid !! %~zod "8443", %~reg "8444")}" %duke "http://{+:}.urbit.org" == ++ auth-url @@ -238,6 +238,11 @@ $: client-id=(unit ,@t) app-secret=(unit ,@t) :_ +>.$ [ost %give %nice ~]~ %sent + ~& resp/res + ?> ?=(%e -.res) + ~| 'must receive a 200' + ~| res + ?> =(200 p.p.res) =+ resp=(rash q:(need r.p.res) apex:poja) =+ suc=((ot success/so ~):jo resp) :_ +>.$ diff --git a/base/pub/do/fab/hymn.hook b/base/pub/do/fab/hymn.hook index a44c09c8d..dc9490a50 100644 --- a/base/pub/do/fab/hymn.hook +++ b/base/pub/do/fab/hymn.hook @@ -12,7 +12,7 @@ =+ authcode=(~(get by qix.gas) %'code') ;html ;head - ;script@"/~/at/main/lib/urb.js"; + ;script@"/~/at/home/lib/urb.js"; ;script: urb.appl = 'do' ;script@"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"; ;script@"https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js"; @@ -24,6 +24,6 @@ :_ ~ ;script: authcode='{(trip u.authcode)}'; console.log(authcode) ;div#container; - ;script@"/main/pub/do/src/main.js"; + ;script@"/home/pub/do/src/main.js"; == == diff --git a/base/pub/do/src/main.js b/base/pub/do/src/main.js index 262a423e5..4c9cb162b 100644 --- a/base/pub/do/src/main.js +++ b/base/pub/do/src/main.js @@ -10,11 +10,11 @@ td = React.DOM.td input = React.DOM.input Droplet = React.createClass({ - deleteDroplet: function() { + dropletAction:function(id, action){ urb.send({ - appl: "do", - data: {action: 'delete', - id: this.props.id}}) + appl:"do", + data: {action: action, + id: id}}) }, rebootDroplet: function() { @@ -25,12 +25,20 @@ Droplet = React.createClass({ }, render: function() { - $this = this + var $this = this //local var, else it always points at second + var acts = ["reboot","power_cycle","shutdown","power_off","power_on","password_reset", + "enable_ipv6","enable_private_networking","snapshot","upgrade"] + var buttons = []; + var buttons = acts.map(function(act){ + console.log($this.props.id) + return b({onClick:function(){ + $this.dropletAction($this.props.id, act) + }}, act) + }) kay = Object.keys(this.props) kay = kay.filter(function(b){return b!="children"}) // XX individually adress props return div({}, - b({id:this.props.id}, "delete"), - b({id:this.props.id,onClick:this.rebootDroplet}, "reboot"), + buttons, table({}, tr({},kay.map(function(k){return th({},k)})), tr({},kay.map(function(k){return td({},JSON.stringify($this.props[k]))}))), @@ -41,6 +49,7 @@ Droplet = React.createClass({ Page = recl({ handleClick: function(){ if(window.authcode.length !== ''){ + console.log(window.authcode); urb.send({ appl: "do", data: window.authcode, @@ -81,13 +90,13 @@ Page = recl({ }, render: function(){ - href = "https://cloud.digitalocean.com/v1/oauth/authorize?client_id=d8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f&redirect_uri=http%3A%2F%2Flocalhost%3A8443%2Fmain%2Fpub%2Fdo%2Ffab&response_type=code&redirect_uri=http://localhost:8443/main/pub/do/fab&scope=read+write" - return (div({}, [ + href = "https://cloud.digitalocean.com/v1/oauth/authorize?client_id=d8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f&redirect_uri=http%3A%2F%2Flocalhost%3A8443%2Fhome%2Fpub%2Fdo%2Ffab&response_type=code&scope=read+write" + return (div({}, [ div({}, a({href:href},[ - "get authcode", - b({onClick:this.handleClick}, "Send Authcode") - ]) + "get authcode" + ]), + b({onClick:this.handleClick}, "Send Authcode") ), div({}, [ input({id:"appsecret"}, From a9e358a7591b2f9bbbc1183c0d10fe5ebfe6487b Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Wed, 13 May 2015 06:14:36 -0700 Subject: [PATCH 02/34] small updates --- base/app/do/core.hook | 179 ++++++++++++++++++++++++++-------------- base/pub/do/src/main.js | 2 +- 2 files changed, 116 insertions(+), 65 deletions(-) diff --git a/base/app/do/core.hook b/base/app/do/core.hook index 27d8e27d4..6833c135b 100644 --- a/base/app/do/core.hook +++ b/base/app/do/core.hook @@ -2,17 +2,20 @@ :: :::: :: -/? 310 +/? 314 +/- *talk +/+ talk, sole, http + :: :: -:::: sivtyv-barnel +:::: sivtyv-barnels :: !: |% ++ droplet $: id=@ud name=@t memory=@ud vcpus=@ud disk=@ud locked=? - created=@t status=@t backup-ids=(list ,@t) snapshot-ids=(list ,@t) + created=@t status=@t backup-ids=(list ,@t) snapshot-ids=(list ,@ud) features=(list ,@t) region=regi image=img size=syze size-slug=@t networks=ntwrks kernel=kern next-backup-window=json @@ -31,26 +34,30 @@ $: memory=@ud price-monthly=@t price-hourly=@t disk=@ud vcpus=@ud == ++ reqbody $: -name=@t region=@t size=@t image=@t ssh=(list cord) +name=@t region=@t size=@t image=@ud ssh=(list cord) backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t) == ++ axle ,[ke=keys toke=tokens drops=(list droplet)] ++ keys ,[authc=(unit ,@t) client-secret=(unit ,@t)] ++ tokens ,[access=@t refresh=@t] +++ hapt ,[ship path] ++ move ,[bone (mold note gift)] ++ note -$: %e - %them -(unit hiss) -== +$% +[%t %wait @da] +[%g %mess hapt ship cage] +[%e %them (unit hiss)] +== ++ gift $% [%nice ~] [%rush %json json] -== +== ++ sign -$: %e -$% [%thou p=httr] -== == +$% +[%t %wake ~] +[%g %nice ~] +[%e %thou p=httr] +== -- !: |% ::: @@ -76,12 +83,12 @@ $% [%thou p=httr] => jo (ot name/so slug/so sizes/(ar so) ~) ++ create-body - |= $: name=@t region=@t size=@t image=@t ssh-keys=(list cord) + |= $: name=@t region=@t size=@t image=@ud ssh-keys=(list cord) backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t) == %- jobe - :~ name/s/name region/s/region size/s/size image/s/image - 'ssh_keys'^a/(turn ssh-keys |=(cord s/+<)) backups/?~(backups ~ b/u.backups) ipv6/?~(ipv6 ~ b/u.ipv6) + :~ name/s/name region/s/region size/s/size image/(jone image) ::(jone image) + backups/?~(backups ~ b/u.backups) ipv6/?~(ipv6 ~ b/u.ipv6) 'user_data'^?~(user-data ~ s/u.user-data) 'private_networking'^?~(private-networking ~ b/u.private-networking) == ++ state-to-json @@ -99,7 +106,7 @@ $% [%thou p=httr] created/s/created status/s/status backup-ids/a/(turn backup-ids |=(el=cord s/el)) - snapshot-ids/a/(turn snapshot-ids |=(el=cord s/el)) + snapshot-ids/a/(turn snapshot-ids jone) features/a/(turn features |=(el=cord s/el)) =+ ^= reg :~ name/s/name.region slug/s/slug.region @@ -140,12 +147,20 @@ $% [%thou p=httr] !: |_ [hid=hide vat=axle] :: -++ auth-queries +++ prep ,_`. +::: +++ spam + |= jon=json + %+ turn (~(tap by sup.hid)) + |= [sub=bone @ pax=path] + ^- move + [sub %give %rush %json jon] +++ auth-queries :~ 'grant_type'^'authorization_code' 'code'^(need authc.ke.vat) :- 'client_id' 'd8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f' - 'redirect_uri'^'http://localhost:8443/main/pub/do/fab' + 'redirect_uri'^'http://localhost:8443/home/pub/do/fab' == ++ httpreq |= $: ost=bone pour-path=wire @@ -169,7 +184,6 @@ $% [%thou p=httr] :^ ost %pass pour-path :+ %e %them `(unit hiss)`[~ request] -::++ prep ,_`. :: wipe state when app code is changed :: ++ peer |= [ost=bone you=ship pax=path] @@ -191,7 +205,7 @@ $% [%thou p=httr] ^- [(list move) _+>.$] =. client-secret.ke.vat [~ secret] - ~& client-secret.ke.vat + ~& [secret=client-secret.ke.vat code=authc.ke.vat] :_ +>.$ :_ [ost %give %nice ~]~ %^ httpreq ost /auth @@ -201,77 +215,88 @@ $% [%thou p=httr] :: ++ receive-auth |= [ost=bone pour-path=path resp=sign] + ^- [(list move) _+>.$] + ?> ?=(%thou +<.resp) + ~| resp =+ body=(rash q:(need r.p.+.resp) apex:poja) - ~& body + ~| recieve-auth/resp(r.p.+ body) =+ [ac re]=(need ((ot 'access_token'^so 'refresh_token'^so ~):jo body)) =: access.toke.vat ac refresh.toke.vat re == - ~& toke.vat :_ +>.$ - [ost %give %nice ~]~ + :~ (list-droplets ost) + (publish ost our.hid [%lin & 'successfully authenticated']~) + == :: ++ poke-json |= [ost=bone you=ship act=json] ^- [(list move) _+>.$] =+ do=(need ((ot action/so ~):jo act)) ?+ do !! - %list + %list :_ +>.$ - :+ [(list-droplets ost)] - [ost %give %nice ~] - ~ - %create + :- (list-droplets ost) + [ost %give %nice ~]~ + :: + %create :_ +>.$ =+ ^- deets=reqbody %- need %. act => jo %- ot - :~ name/so region/so size/so image/so ssh/(ar so) backups/(mu bo) + :~ name/so region/so size/so image/(su dem) ssh/(ar so) backups/(mu bo) 'ipv6'^(mu bo) 'priv_networking'^(mu bo) 'user_data'^(mu so) == - :+ [(create-droplet ost deets)] - [ost %give %nice ~] - ~ - %reboot - :_ +>.$ - =+ id=(need ((ot id/ni ~):jo act)) - ~& id - ^- (list move) - :+ `move`(reboot-droplet ost id) - [ost %give %nice ~] - ~ + :- (create-droplet ost deets) + [ost %give %nice ~]~ + :: + $? %reboot %'power_cycle' %shutdown %'power_off' %'power_on' + %'password_reset' %'enable_ipv6' %'enable_private_networking' + %snapshot %upgrade + == + =+ id=(need ((ot id/no ~):jo act)) + (droplet-action ost id do) == - -++ reboot-droplet - |= [os=bone id=@ud] +:: +++ droplet-action + |= $: os=bone id=@t + $= action $? + %delete %reboot %'power_cycle' %shutdown %'power_off' + %'power_on' %'password_reset' %'enable_ipv6' %'enable_private_networking' + %snapshot %upgrade :: add retrieve droplet action + == == + :: restore, resize, rebuild, change_kernelm, retrieve droplet action + :_ +>.$ + ^- (list move) + :_ [os %give %nice ~]~ + =+ ^= req %- httpreq :* - os - /reboot - ~[%digitalocean %api] - =+ path=`path`/v2/droplets/'5073686'/actions - ~& path - path - [%post `json`(jobe type/s/'reboot' ~)] + os /reboot + ~[%digitalocean %api] /v2/droplets/[id]/actions + [%post `json`(jobe type/s/action ~)] (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] ~) *quay == + req ++ list-droplets |= os=bone - ~& 'poked' =+ ^= lis :~ os /list ~[%digitalocean %api] /v2/droplets %get (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] ~) == - (httpreq lis) + (httpreq lis) :: ++ receive-list |= [ost=bone pour-path=path resp=sign] + ^- [(list move) _+>.$] + ?> ?=(%thou +<.resp) =+ parsed=(rash q:(need r.p.+.resp) apex:poja) + ~| recieve-list/parsed =+ dar=(need ((ot droplets/(ar some) ~):jo parsed)) =+ ^- dropz=(list droplet) ~| bad-json/-.dar @@ -283,20 +308,20 @@ $% [%thou p=httr] :~ id/ni name/so memory/ni vcpus/ni disk/ni locked/bo 'created_at'^so status/so - 'backup_ids'^(ar so) 'snapshot_ids'^(ar so) features/(ar so) + 'backup_ids'^(ar so) 'snapshot_ids'^(ar ni) features/(ar so) region/parse-region image/parse-img size/parse-size 'size_slug'^so networks/parse-ntwrks kernel/(ot id/ni name/so version/so ~) 'next_backup_window'^some == =. drops.vat dropz - ~& drops/drops.vat + =+ buf=`@da`(add ~s10 lat.hid) :_ +>.$ - [ost %give %nice ~]~ + :_ (spam (state-to-json drops.vat)) + [ost %pass /refresh %t [%wait p=buf]] :: ++ create-droplet |= [os=bone reqbody] - ~& 'reached' =+ ^= create :* os /create ~[%digitalocean %api] /v2/droplets @@ -309,26 +334,52 @@ $% [%thou p=httr] ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] ~ ~ == - (httpreq create) + ~& (httpreq create) + (httpreq create) :: ++ pour |= [ost=bone pour-path=path resp=sign] ^- [(list move) _+>.$] ?+ -.pour-path !! %auth - (receive-auth ost pour-path resp) + (receive-auth `bone`ost `path`pour-path `sign`resp) :: %list (receive-list ost pour-path resp) :: + $? + %delete %reboot %'power_cycle' %shutdown %'power_off' + %'power_on' %'password_reset' %'enable_ipv6' %'enable_private_networking' + %snapshot %upgrade :: add retrieve droplet action %create - ~& created/resp - :_ +>.$ - [ost %give %nice ~]~ + == + ~& resp + :_ +>.$ ~ :: - %reboot - ~& resp + %pub + :_ +>.$ ~ + :: + %refresh :_ +>.$ - [ost %give %nice ~]~ + [(list-droplets ost)]~ == +++ publish + |= [ost=bone you=ship act=(list speech)] + ^- move + =+ ^= spchz + %+ turn act + |= sp=speech + =+ ^= tail + :- ^- audience + :+ :- `partner`[%& our.hid ?+((clan our.hid) !! %czar %court, %duke %porch)] + ^- (pair envelope delivery) + [`envelope`[& ~] %pending] + ~ + ~ + `statement`[lat.hid ~ sp] + ^- thought + :- `@`(sham eny.hid tail) + tail + =+ cag=`cage`[%talk-command !>([%publish `(list thought)`spchz])] + [ost %pass /pub %g %mess [our.hid /talk] you cag] -- diff --git a/base/pub/do/src/main.js b/base/pub/do/src/main.js index 4c9cb162b..fdb1c85ee 100644 --- a/base/pub/do/src/main.js +++ b/base/pub/do/src/main.js @@ -80,7 +80,7 @@ Page = recl({ region:$('#region').val(), size:$('#size').val(), image:$('#image').val(), - ssh:[$('#ssh').val()], + ssh:[] // $('#ssh').val()], backups:null,//$('#backups').val(), ipv6:null,//$('#ipv6').val(), priv_networking:null,//$('#priv-networking').val(), From 60365b5ae8b62656e1a197233145efd1660b2e2c Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Thu, 14 May 2015 13:46:52 -0400 Subject: [PATCH 03/34] added %slaw jet hint --- base/arvo/hoon.hoon | 1 + 1 file changed, 1 insertion(+) diff --git a/base/arvo/hoon.hoon b/base/arvo/hoon.hoon index f5f6dbf37..540e9f736 100644 --- a/base/arvo/hoon.hoon +++ b/base/arvo/hoon.hoon @@ -3695,6 +3695,7 @@ ++ slav |=([mod=@tas txt=@ta] (need (slaw mod txt))) ++ slaw |= [mod=@tas txt=@ta] + ~/ %slaw ^- (unit ,@) =+ con=(slay txt) ?.(&(?=([~ %$ @ @] con) =(p.p.u.con mod)) ~ [~ q.p.u.con]) From 6b956e0dcbdd12a4082d0ea6d24ba5ec15b20340 Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Thu, 14 May 2015 14:12:12 -0400 Subject: [PATCH 04/34] added %scot jet hint --- base/arvo/hoon.hoon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/arvo/hoon.hoon b/base/arvo/hoon.hoon index 540e9f736..a2df734d7 100644 --- a/base/arvo/hoon.hoon +++ b/base/arvo/hoon.hoon @@ -3689,13 +3689,13 @@ royl == -- -++ scot |=(mol=dime ~(rent co %$ mol)) +++ scot ~/ %scot |=(mol=dime ~(rent co %$ mol)) ++ scow |=(mol=dime ~(rend co %$ mol)) ++ slat |=(mod=@tas |=(txt=@ta (slaw mod txt))) ++ slav |=([mod=@tas txt=@ta] (need (slaw mod txt))) ++ slaw - |= [mod=@tas txt=@ta] ~/ %slaw + |= [mod=@tas txt=@ta] ^- (unit ,@) =+ con=(slay txt) ?.(&(?=([~ %$ @ @] con) =(p.p.u.con mod)) ~ [~ q.p.u.con]) From 4ce18a92d233b048a3623c7faf5083500cc757c7 Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Wed, 20 May 2015 13:49:19 -0700 Subject: [PATCH 05/34] beginning of GCE auth --- base/app/do/core.hook | 3 ++- base/mar/oauth2-code/door.hook | 1 + base/pub/do/fab/hymn.hook | 8 +++++--- base/pub/do/src/main.js | 11 +++++++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/base/app/do/core.hook b/base/app/do/core.hook index 6833c135b..173a9f1ec 100644 --- a/base/app/do/core.hook +++ b/base/app/do/core.hook @@ -194,6 +194,7 @@ $% ++ poke-oauth2-code |= [ost=bone you=ship code=cord] ^- [(list move) _+>.$] + ~& code =. authc.ke.vat [~ code] =+ ath=(need authc.ke.vat) @@ -305,7 +306,7 @@ $% %- need %. drp =+ jo %- ot - :~ id/ni name/so + :~ id/ni name/so memory/ni vcpus/ni disk/ni locked/bo 'created_at'^so status/so 'backup_ids'^(ar so) 'snapshot_ids'^(ar ni) features/(ar so) diff --git a/base/mar/oauth2-code/door.hook b/base/mar/oauth2-code/door.hook index 009224d3d..36bf3fc7c 100644 --- a/base/mar/oauth2-code/door.hook +++ b/base/mar/oauth2-code/door.hook @@ -3,6 +3,7 @@ :::: /hook/door/oauth2-code/mar :: /? 310 +!: |_ cod=cord :: ++ grab :: converter arm diff --git a/base/pub/do/fab/hymn.hook b/base/pub/do/fab/hymn.hook index dc9490a50..6a1edce0c 100644 --- a/base/pub/do/fab/hymn.hook +++ b/base/pub/do/fab/hymn.hook @@ -8,8 +8,9 @@ :: !: ^- manx +=+ do=(~(get by qix.gas) %'code') +=+ g=(~(get by qix.gas) %'access_token') -=+ authcode=(~(get by qix.gas) %'code') ;html ;head ;script@"/~/at/home/lib/urb.js"; @@ -20,9 +21,10 @@ ;title: DO Instance Tracker == ;body - ;* ?~ authcode ~ + ;* =+ d=?~(do ~ (trip u.do)) + =+ g=?~(g ~ (trip u.g)) :_ ~ - ;script: authcode='{(trip u.authcode)}'; console.log(authcode) + ;script: authcode='{?~(d g d)}'; console.log(authcode) ;div#container; ;script@"/home/pub/do/src/main.js"; == diff --git a/base/pub/do/src/main.js b/base/pub/do/src/main.js index fdb1c85ee..9c503d423 100644 --- a/base/pub/do/src/main.js +++ b/base/pub/do/src/main.js @@ -91,6 +91,7 @@ Page = recl({ render: function(){ href = "https://cloud.digitalocean.com/v1/oauth/authorize?client_id=d8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f&redirect_uri=http%3A%2F%2Flocalhost%3A8443%2Fhome%2Fpub%2Fdo%2Ffab&response_type=code&scope=read+write" + ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&state=someinfo&redirect_uri=http://localhost:8443/home/pub/do/fab&client_id=720541965785-jr3c6ijo8abonu9qj77qre1itsdra52r.apps.googleusercontent.com" return (div({}, [ div({}, a({href:href},[ @@ -103,6 +104,16 @@ Page = recl({ b({onClick:this.sendSecret}, "Send Secret")) ]), b({onClick:this.getList}, "Get List"), + div({}, + a({href:ghref},[ + "Get Google Authcode" + ]), + b({onClick:this.handleClick}, "Send Google Authcode") + ), + div({}, [ + input({id:"gappsecret"}, + b({onClick:this.sendSecret}, "Send Google Secret")) + ]), div({}, [ b({onClick:this.createDroplet}, "Create Droplet"), input({id:"name",placeholder:"Name of droplet"}), From 7e4cf03c93efde6e01e562b20dc8d88681a755d7 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 20 May 2015 15:13:27 -0700 Subject: [PATCH 06/34] codemirror tree v1 --- base/lib/react/core.hook | 4 +- base/lib/syntax/codemirror.css | 5 - base/mar/hook/door.hook | 2 +- base/pub/tree/src/js/main.coffee | 3 +- base/pub/tree/src/js/main.js | 1604 +----------------------------- base/tree/hymn.hook | 10 +- 6 files changed, 14 insertions(+), 1614 deletions(-) diff --git a/base/lib/react/core.hook b/base/lib/react/core.hook index 143461eef..d4aae3e0b 100644 --- a/base/lib/react/core.hook +++ b/base/lib/react/core.hook @@ -22,7 +22,9 @@ ~(has in react-elems) ++ react-to-tape |= src=manx ^- tape - :: ?: =(%script n.g.src) + ?: (~(has by (mo a.g.src)) [%urb %codemirror]) + ?> ?=([[%pre *] _:/(**) ~] src) + $(src ;codemirror(value "{v.i.a.g.i.c.src}");) ;: weld "React.createElement(" =* tan n.g.src diff --git a/base/lib/syntax/codemirror.css b/base/lib/syntax/codemirror.css index 7d0dd7ff0..942fbf64c 100644 --- a/base/lib/syntax/codemirror.css +++ b/base/lib/syntax/codemirror.css @@ -3,8 +3,3 @@ } .cm-s-default .cm-atom {color: #70f} .cm-s-default .cm-operator {color: #097} - -#err { - background: #fdd; - display: none; -} \ No newline at end of file diff --git a/base/mar/hook/door.hook b/base/mar/hook/door.hook index 27289b054..437d307ac 100644 --- a/base/mar/hook/door.hook +++ b/base/mar/hook/door.hook @@ -9,7 +9,7 @@ |% ++ mime [/text/hoon (taco own)] :: convert to %mime ++ psal :: convert to %html - ;div:(pre:"{(trip own)}") + ;div:pre(urb_codemirror ""):"{(trip own)}" :: =+ gen-id="src-{<`@ui`(mug own)>}" :: ;div :: ;textarea(id "{gen-id}"):"{(trip own)}" diff --git a/base/pub/tree/src/js/main.coffee b/base/pub/tree/src/js/main.coffee index 4510b8ff3..46e70f4f7 100644 --- a/base/pub/tree/src/js/main.coffee +++ b/base/pub/tree/src/js/main.coffee @@ -5,6 +5,7 @@ $ -> React.initializeTouchEvents(true) + codemirror = React.createFactory require './components/CodeMirror.coffee' head = React.createFactory require './components/AnchorComponent.coffee' body = React.createFactory require './components/BodyComponent.coffee' list = React.createFactory require './components/ListComponent.coffee' @@ -21,7 +22,7 @@ $ -> if path[0] isnt "/" then path = "/"+path window.tree._basepath + path window.tree.fragpath = (path) -> path.replace window.tree._basepath,"" - window.tree.init({kids:kids,list:list,lost:lost}) + window.tree.init({kids:kids,list:list,lost:lost, codemirror:codemirror}) window.tree.reactify = (str) -> eval str TreeActions = require './actions/TreeActions.coffee' diff --git a/base/pub/tree/src/js/main.js b/base/pub/tree/src/js/main.js index dc54a3b3c..bd931c056 100644 --- a/base/pub/tree/src/js/main.js +++ b/base/pub/tree/src/js/main.js @@ -1,1603 +1 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { - p = curr.split("/"); - curr = p.pop(); - up = p.join("/"); - ci = 0; - k = 0; - sibs = _.map(_.keys(this.state.sibs).sort(), (function(_this) { - return function(i) { - var c; - c = ""; - if (curr === i) { - c = "active"; - ci = k; - } - k++; - href = window.tree.basepath(up + "/" + i); - return div({ - className: c - }, a({ - key: i + "-a", - href: href, - onClick: _this._click - }, i)); - }; - })(this)); - offset = 0; - if (ci > 0) { - offset = 0; - } - s = { - marginTop: ((ci * -24) - offset) + "px" - }; - parts.push(div({ - key: "sibs", - id: "sibs", - style: s - }, sibs)); - } - obj = { - onMouseOver: this._mouseOver, - onMouseOut: this._mouseOut, - onClick: this._click, - onTouchStart: this._touchStart, - onTouchEnd: this._touchEnd - }; - if (_.keys(window).indexOf("ontouchstart") !== -1) { - delete obj.onMouseOver; - delete obj.onMouseOut; - } - return div(obj, parts); - } -}); - - - -},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","../stores/TreeStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/BodyComponent.coffee":[function(require,module,exports){ -var TreeActions, TreeStore, div, input, load, recl, ref, textarea; - -TreeStore = require('../stores/TreeStore.coffee'); - -TreeActions = require('../actions/TreeActions.coffee'); - -load = require('./LoadComponent.coffee'); - -recl = React.createClass; - -ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; - -module.exports = recl({ - stateFromStore: function() { - return { - body: TreeStore.getBody(), - load: TreeStore.getLoad(), - curr: TreeStore.getCurr(), - cont: TreeStore.getCont() - }; - }, - componentDidMount: function() { - return TreeStore.addChangeListener(this._onChangeStore); - }, - componentDidUpdate: function(_props, _state) { - if (_state.curr !== this.state.curr) { - return setTimeout(((function(_this) { - return function() { - return _this.getPath(_state.curr); - }; - })(this)), 0); - } - }, - getInitialState: function() { - return this.stateFromStore(); - }, - _onChangeStore: function() { - return this.setState(this.stateFromStore()); - }, - getPath: function(path) { - if (this.state.cont[path] == null) { - TreeActions.setLoading(true); - return TreeActions.getPath(path, (function(_this) { - return function() { - return TreeActions.setLoading(false); - }; - })(this)); - } - }, - render: function() { - var parts, ref1; - parts = []; - parts.push(div({ - id: 'body', - key: "body" + this.state.curr - }, (ref1 = this.state.body) != null ? ref1 : div({ - className: "loading" - }, load({}, "")))); - return div({}, parts); - } -}); - - - -},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","../stores/TreeStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee","./LoadComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/LoadComponent.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/KidsComponent.coffee":[function(require,module,exports){ -var TreeActions, TreeStore, a, div, hr, li, recl, ref, ul; - -TreeStore = require('../stores/TreeStore.coffee'); - -TreeActions = require('../actions/TreeActions.coffee'); - -recl = React.createClass; - -ref = [React.DOM.div, React.DOM.a, React.DOM.ul, React.DOM.li, React.DOM.hr], div = ref[0], a = ref[1], ul = ref[2], li = ref[3], hr = ref[4]; - -module.exports = recl({ - stateFromStore: function() { - var path, ref1; - path = (ref1 = this.props.dataPath) != null ? ref1 : TreeStore.getCurr(); - return { - cont: TreeStore.getCont(), - tree: TreeStore.getTree(path.split("/")), - path: path - }; - }, - componentDidMount: function() { - return TreeStore.addChangeListener(this._onChangeStore); - }, - getInitialState: function() { - return this.stateFromStore(); - }, - _onChangeStore: function() { - return this.setState(this.stateFromStore()); - }, - componentDidMount: function() { - var cont, i, k, len, ref1; - cont = true; - ref1 = _.keys(this.state.tree); - for (i = 0, len = ref1.length; i < len; i++) { - k = ref1[i]; - if (!this.state.cont[this.state.path + "/" + k]) { - cont = false; - } - } - if (!this.state.tree || _.keys(this.state.tree).length === 0 || !cont) { - return TreeActions.getPath(this.state.path, "kids"); - } - }, - render: function() { - var _list, doc, ref1; - doc = (ref1 = this.state.tree) != null ? ref1 : []; - _list = _.map(_.keys(doc).sort(), (function(_this) { - return function(v) { - var _path; - _path = _this.state.path + "/" + v; - return [ - div({ - key: "kid-" + v - }, _this.state.cont[_path]), hr({}, "") - ]; - }; - })(this)); - return div({ - key: "kids-" + this.state.path, - className: "kids" - }, _list); - } -}); - - - -},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","../stores/TreeStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/ListComponent.coffee":[function(require,module,exports){ -var TreeActions, TreeStore, a, div, h1, li, load, recl, ref, ul; - -TreeStore = require('../stores/TreeStore.coffee'); - -TreeActions = require('../actions/TreeActions.coffee'); - -load = require('./LoadComponent.coffee'); - -recl = React.createClass; - -ref = [React.DOM.div, React.DOM.a, React.DOM.ul, React.DOM.li, React.DOM.h1], div = ref[0], a = ref[1], ul = ref[2], li = ref[3], h1 = ref[4]; - -module.exports = recl({ - stateFromStore: function() { - var path, ref1; - path = (ref1 = this.props.dataPath) != null ? ref1 : TreeStore.getCurr(); - return { - snip: TreeStore.getSnip(), - tree: TreeStore.getTree(path.split("/")), - path: path - }; - }, - componentDidMount: function() { - return TreeStore.addChangeListener(this._onChangeStore); - }, - getInitialState: function() { - return this.stateFromStore(); - }, - _onChangeStore: function() { - return this.setState(this.stateFromStore()); - }, - getCont: function() { - var cont, i, k, keys, len; - cont = true; - keys = _.keys(this.state.tree); - for (i = 0, len = keys.length; i < len; i++) { - k = keys[i]; - if (!this.state.snip[this.state.path + "/" + k]) { - cont = false; - } - } - if (keys.length === 0) { - cont = false; - } - return cont; - }, - componentDidMount: function() { - var cont; - cont = this.getCont(); - if (!this.state.tree || _.keys(this.state.tree).length === 0 || !cont) { - return TreeActions.getPath(this.state.path, "snip"); - } - }, - render: function() { - var _list, doc, ref1; - doc = (ref1 = this.state.tree) != null ? ref1 : []; - if (!this.getCont()) { - _list = div({ - className: "loading" - }, load({}, "")); - } else { - _list = _.map(_.keys(doc).sort(), (function(_this) { - return function(v) { - var _path, c, href, prev; - _path = _this.state.path + "/" + v; - if (_this.props.dataPreview != null) { - c = "preview"; - if (_this.props.titlesOnly) { - prev = _this.state.snip[_path].head; - } else { - prev = _this.state.snip[_path]; - } - } else { - c = ""; - prev = h1({}, v); - } - href = window.tree.basepath(_path); - return li({}, a({ - href: href, - className: c, - key: "list-a-" + _path - }, prev)); - }; - })(this)); - } - return ul({ - className: "list", - key: "list-" + this.state.path - }, _list); - } -}); - - - -},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","../stores/TreeStore.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee","./LoadComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/LoadComponent.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/LoadComponent.coffee":[function(require,module,exports){ -var div, input, recl, ref, textarea; - -recl = React.createClass; - -ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; - -module.exports = recl({ - getInitialState: function() { - return { - anim: 0 - }; - }, - componentDidMount: function() { - return this.interval = setInterval(this.setAnim, 100); - }, - componentWillUnmount: function() { - return clearInterval(this.interval); - }, - setAnim: function() { - var anim; - anim = this.state.anim + 1; - if (anim > 3) { - anim = 0; - } - return this.setState({ - anim: anim - }); - }, - render: function() { - return div({ - className: "spin state-" + this.state.anim - }, ""); - } -}); - - - -},{}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/dispatcher/Dispatcher.coffee":[function(require,module,exports){ -var Dispatcher; - -Dispatcher = require('flux').Dispatcher; - -module.exports = _.extend(new Dispatcher(), { - handleServerAction: function(action) { - return this.dispatch({ - source: 'server', - action: action - }); - }, - handleViewAction: function(action) { - return this.dispatch({ - source: 'view', - action: action - }); - } -}); - - - -},{"flux":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/node_modules/flux/index.js"}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/main.coffee":[function(require,module,exports){ -var rend; - -rend = React.render; - -$(function() { - var $body, TreeActions, TreePersistence, body, checkMove, checkScroll, frag, head, kids, list, lost, po, setSo, so; - $body = $('body'); - React.initializeTouchEvents(true); - head = React.createFactory(require('./components/AnchorComponent.coffee')); - body = React.createFactory(require('./components/BodyComponent.coffee')); - list = React.createFactory(require('./components/ListComponent.coffee')); - kids = React.createFactory(require('./components/KidsComponent.coffee')); - lost = React.createClass({ - render: function() { - return React.DOM.div({}, "lost"); - } - }); - window.tree._basepath = window.location.pathname; - window.tree._basepath = window.tree._basepath.split("/"); - window.tree._basepath = window.tree._basepath.slice(0, window.tree._basepath.indexOf("tree") + 1); - window.tree._basepath = window.tree._basepath.join("/"); - window.tree.basepath = function(path) { - if (path[0] !== "/") { - path = "/" + path; - } - return window.tree._basepath + path; - }; - window.tree.fragpath = function(path) { - return path.replace(window.tree._basepath, ""); - }; - window.tree.init({ - kids: kids, - list: list, - lost: lost - }); - window.tree.reactify = function(str) { - return eval(str); - }; - TreeActions = require('./actions/TreeActions.coffee'); - TreePersistence = require('./persistence/TreePersistence.coffee'); - frag = window.tree.fragpath(window.location.pathname); - TreeActions.setCurr(frag); - TreeActions.loadPath(frag, window.tree.body, window.tree.kids); - rend(head({}, ""), $('#nav')[0]); - rend(body({}, ""), $('#cont')[0]); - checkScroll = function() { - if ($(window).scrollTop() > 20) { - return $('#nav').addClass('scrolling'); - } else { - return $('#nav').removeClass('scrolling'); - } - }; - setInterval(checkScroll, 500); - po = {}; - po.cm = null; - po.lm = null; - po.cs = $(window).scrollTop(); - po.ls = $(window).scrollTop(); - $(document).mousemove(function(e) { - return po.cm = { - x: e.pageX, - y: e.pageY - }; - }); - checkMove = function() { - var ds, dx, dy; - if (po.lm !== null && po.cm !== null) { - po.cs = $(window).scrollTop(); - ds = Math.abs(po.cs - po.ls); - dx = Math.abs(po.cm.x - po.lm.x); - dy = Math.abs(po.cm.y - po.lm.y); - $('#nav').toggleClass('moving', dx > 20 || dy > 20); - } - po.lm = po.cm; - return po.ls = po.cs; - }; - setInterval(checkMove, 200); - so = {}; - so.ls = $(window).scrollTop(); - so.cs = $(window).scrollTop(); - so.w = null; - so.$n = $('#nav'); - so.$d = $('#nav > div'); - so.nh = $('#nav').outerHeight(true); - setSo = function() { - so.w = $(window).width(); - return so.$n = $('#nav'); - }; - setInterval(setSo, 200); - $(window).on('resize', function(e) { - if (so.w > 1170) { - return so.$n.removeClass('m-up m-down m-fixed'); - } - }); - return $(window).on('scroll', function(e) { - var dy, sto, top; - so.cs = $(window).scrollTop(); - if (so.w > 1170) { - so.$n.removeClass('m-up m-down m-fixed'); - } - if (so.w < 1170) { - dy = so.ls - so.cs; - so.$d.removeClass('focus'); - if (so.cs <= 0) { - so.$n.removeClass('m-up'); - so.$n.addClass('m-down m-fixed'); - return; - } - if (so.$n.hasClass('m-fixed' && so.w < 1024)) { - so.$n.css({ - left: -1 * $(window).scrollLeft() - }); - } - if (dy > 0) { - if (!so.$n.hasClass('m-down')) { - so.$n.removeClass('m-up').addClass('m-down'); - top = so.cs - so.nh; - if (top < 0) { - top = 0; - } - so.$n.offset({ - top: top - }); - } - if (so.$n.hasClass('m-down') && !so.$n.hasClass('m-fixed') && so.$n.offset().top >= so.cs) { - so.$n.addClass('m-fixed'); - so.$n.attr({ - style: '' - }); - } - } - if (dy < 0) { - if (!so.$n.hasClass('m-up')) { - so.$n.removeClass('m-down m-fixed').addClass('m-up'); - so.$n.attr({ - style: '' - }); - top = so.cs; - sto = so.$n.offset().top; - if (top < 0) { - top = 0; - } - if (top > sto && top < sto + so.nh) { - top = sto; - } - so.$n.offset({ - top: top - }); - } - } - } - return so.ls = so.cs; - }); -}); - - - -},{"./actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee","./components/AnchorComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/AnchorComponent.coffee","./components/BodyComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/BodyComponent.coffee","./components/KidsComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/KidsComponent.coffee","./components/ListComponent.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/components/ListComponent.coffee","./persistence/TreePersistence.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/persistence/TreePersistence.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/node_modules/flux/index.js":[function(require,module,exports){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -module.exports.Dispatcher = require('./lib/Dispatcher') - -},{"./lib/Dispatcher":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/node_modules/flux/lib/Dispatcher.js"}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/node_modules/flux/lib/Dispatcher.js":[function(require,module,exports){ -/* - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule Dispatcher - * @typechecks - */ - -"use strict"; - -var invariant = require('./invariant'); - -var _lastID = 1; -var _prefix = 'ID_'; - -/** - * Dispatcher is used to broadcast payloads to registered callbacks. This is - * different from generic pub-sub systems in two ways: - * - * 1) Callbacks are not subscribed to particular events. Every payload is - * dispatched to every registered callback. - * 2) Callbacks can be deferred in whole or part until other callbacks have - * been executed. - * - * For example, consider this hypothetical flight destination form, which - * selects a default city when a country is selected: - * - * var flightDispatcher = new Dispatcher(); - * - * // Keeps track of which country is selected - * var CountryStore = {country: null}; - * - * // Keeps track of which city is selected - * var CityStore = {city: null}; - * - * // Keeps track of the base flight price of the selected city - * var FlightPriceStore = {price: null} - * - * When a user changes the selected city, we dispatch the payload: - * - * flightDispatcher.dispatch({ - * actionType: 'city-update', - * selectedCity: 'paris' - * }); - * - * This payload is digested by `CityStore`: - * - * flightDispatcher.register(function(payload) { - * if (payload.actionType === 'city-update') { - * CityStore.city = payload.selectedCity; - * } - * }); - * - * When the user selects a country, we dispatch the payload: - * - * flightDispatcher.dispatch({ - * actionType: 'country-update', - * selectedCountry: 'australia' - * }); - * - * This payload is digested by both stores: - * - * CountryStore.dispatchToken = flightDispatcher.register(function(payload) { - * if (payload.actionType === 'country-update') { - * CountryStore.country = payload.selectedCountry; - * } - * }); - * - * When the callback to update `CountryStore` is registered, we save a reference - * to the returned token. Using this token with `waitFor()`, we can guarantee - * that `CountryStore` is updated before the callback that updates `CityStore` - * needs to query its data. - * - * CityStore.dispatchToken = flightDispatcher.register(function(payload) { - * if (payload.actionType === 'country-update') { - * // `CountryStore.country` may not be updated. - * flightDispatcher.waitFor([CountryStore.dispatchToken]); - * // `CountryStore.country` is now guaranteed to be updated. - * - * // Select the default city for the new country - * CityStore.city = getDefaultCityForCountry(CountryStore.country); - * } - * }); - * - * The usage of `waitFor()` can be chained, for example: - * - * FlightPriceStore.dispatchToken = - * flightDispatcher.register(function(payload) { - * switch (payload.actionType) { - * case 'country-update': - * flightDispatcher.waitFor([CityStore.dispatchToken]); - * FlightPriceStore.price = - * getFlightPriceStore(CountryStore.country, CityStore.city); - * break; - * - * case 'city-update': - * FlightPriceStore.price = - * FlightPriceStore(CountryStore.country, CityStore.city); - * break; - * } - * }); - * - * The `country-update` payload will be guaranteed to invoke the stores' - * registered callbacks in order: `CountryStore`, `CityStore`, then - * `FlightPriceStore`. - */ - - function Dispatcher() { - this.$Dispatcher_callbacks = {}; - this.$Dispatcher_isPending = {}; - this.$Dispatcher_isHandled = {}; - this.$Dispatcher_isDispatching = false; - this.$Dispatcher_pendingPayload = null; - } - - /** - * Registers a callback to be invoked with every dispatched payload. Returns - * a token that can be used with `waitFor()`. - * - * @param {function} callback - * @return {string} - */ - Dispatcher.prototype.register=function(callback) { - var id = _prefix + _lastID++; - this.$Dispatcher_callbacks[id] = callback; - return id; - }; - - /** - * Removes a callback based on its token. - * - * @param {string} id - */ - Dispatcher.prototype.unregister=function(id) { - invariant( - this.$Dispatcher_callbacks[id], - 'Dispatcher.unregister(...): `%s` does not map to a registered callback.', - id - ); - delete this.$Dispatcher_callbacks[id]; - }; - - /** - * Waits for the callbacks specified to be invoked before continuing execution - * of the current callback. This method should only be used by a callback in - * response to a dispatched payload. - * - * @param {array} ids - */ - Dispatcher.prototype.waitFor=function(ids) { - invariant( - this.$Dispatcher_isDispatching, - 'Dispatcher.waitFor(...): Must be invoked while dispatching.' - ); - for (var ii = 0; ii < ids.length; ii++) { - var id = ids[ii]; - if (this.$Dispatcher_isPending[id]) { - invariant( - this.$Dispatcher_isHandled[id], - 'Dispatcher.waitFor(...): Circular dependency detected while ' + - 'waiting for `%s`.', - id - ); - continue; - } - invariant( - this.$Dispatcher_callbacks[id], - 'Dispatcher.waitFor(...): `%s` does not map to a registered callback.', - id - ); - this.$Dispatcher_invokeCallback(id); - } - }; - - /** - * Dispatches a payload to all registered callbacks. - * - * @param {object} payload - */ - Dispatcher.prototype.dispatch=function(payload) { - invariant( - !this.$Dispatcher_isDispatching, - 'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.' - ); - this.$Dispatcher_startDispatching(payload); - try { - for (var id in this.$Dispatcher_callbacks) { - if (this.$Dispatcher_isPending[id]) { - continue; - } - this.$Dispatcher_invokeCallback(id); - } - } finally { - this.$Dispatcher_stopDispatching(); - } - }; - - /** - * Is this Dispatcher currently dispatching. - * - * @return {boolean} - */ - Dispatcher.prototype.isDispatching=function() { - return this.$Dispatcher_isDispatching; - }; - - /** - * Call the callback stored with the given id. Also do some internal - * bookkeeping. - * - * @param {string} id - * @internal - */ - Dispatcher.prototype.$Dispatcher_invokeCallback=function(id) { - this.$Dispatcher_isPending[id] = true; - this.$Dispatcher_callbacks[id](this.$Dispatcher_pendingPayload); - this.$Dispatcher_isHandled[id] = true; - }; - - /** - * Set up bookkeeping needed when dispatching. - * - * @param {object} payload - * @internal - */ - Dispatcher.prototype.$Dispatcher_startDispatching=function(payload) { - for (var id in this.$Dispatcher_callbacks) { - this.$Dispatcher_isPending[id] = false; - this.$Dispatcher_isHandled[id] = false; - } - this.$Dispatcher_pendingPayload = payload; - this.$Dispatcher_isDispatching = true; - }; - - /** - * Clear bookkeeping used for dispatching. - * - * @internal - */ - Dispatcher.prototype.$Dispatcher_stopDispatching=function() { - this.$Dispatcher_pendingPayload = null; - this.$Dispatcher_isDispatching = false; - }; - - -module.exports = Dispatcher; - -},{"./invariant":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/node_modules/flux/lib/invariant.js"}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/node_modules/flux/lib/invariant.js":[function(require,module,exports){ -/** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule invariant - */ - -"use strict"; - -/** - * Use invariant() to assert state which your program assumes to be true. - * - * Provide sprintf-style format (only %s is supported) and arguments - * to provide information about what broke and what you were - * expecting. - * - * The invariant message will be stripped in production, but the invariant - * will remain to ensure logic does not differ in production. - */ - -var invariant = function(condition, format, a, b, c, d, e, f) { - if (false) { - if (format === undefined) { - throw new Error('invariant requires an error message argument'); - } - } - - if (!condition) { - var error; - if (format === undefined) { - error = new Error( - 'Minified exception occurred; use the non-minified dev environment ' + - 'for the full error message and additional helpful warnings.' - ); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error( - 'Invariant Violation: ' + - format.replace(/%s/g, function() { return args[argIndex++]; }) - ); - } - - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; - } -}; - -module.exports = invariant; - -},{}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/persistence/TreePersistence.coffee":[function(require,module,exports){ -var TreeActions; - -TreeActions = require('../actions/TreeActions.coffee'); - -module.exports = { - get: function(path, query, cb) { - var url; - url = (window.tree.basepath(path)) + ".json"; - if (query) { - url += "?" + query; - } - return $.get(url, {}, function(data) { - if (cb) { - return cb(null, data); - } - }); - } -}; - - - -},{"../actions/TreeActions.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/actions/TreeActions.coffee"}],"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/stores/TreeStore.coffee":[function(require,module,exports){ -var EventEmitter, MessageDispatcher, TreeStore, _cont, _curr, _load, _snip, _tree; - -EventEmitter = require('events').EventEmitter; - -MessageDispatcher = require('../dispatcher/Dispatcher.coffee'); - -_tree = {}; - -_cont = {}; - -_snip = {}; - -_load = false; - -_curr = ""; - -TreeStore = _.extend(EventEmitter.prototype, { - addChangeListener: function(cb) { - return this.on('change', cb); - }, - removeChangeListener: function(cb) { - return this.removeListener("change", cb); - }, - emitChange: function() { - return this.emit('change'); - }, - pathToArr: function(_path) { - return _path.split("/"); - }, - pathToObj: function(_path, _obj, kids) { - var __path, i, j, l, ref, ref1, results; - __path = this.pathToArr(_path); - for (i = j = 0, ref = __path.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { - _obj = _obj[__path[i]] = {}; - } - if ((kids != null ? kids.length : void 0) > 0) { - results = []; - for (i = l = 0, ref1 = kids.length - 1; 0 <= ref1 ? l <= ref1 : l >= ref1; i = 0 <= ref1 ? ++l : --l) { - results.push(_obj[kids[i]] = {}); - } - return results; - } - }, - getTree: function(_path) { - var i, j, ref, tree; - tree = _tree; - if (_path.length > 0) { - for (i = j = 0, ref = _path.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { - if (tree[_path[i]]) { - tree = tree[_path[i]]; - } else { - return null; - } - } - } - return tree; - }, - setCurr: function(path) { - return _curr = path; - }, - getCurr: function() { - return _curr; - }, - getCont: function() { - return _cont; - }, - setLoad: function(load) { - return _load = load; - }, - getLoad: function() { - return _load; - }, - mergePathToTree: function(path, kids) { - var _obj; - _obj = {}; - this.pathToObj(path, _obj, kids); - return _.merge(_tree, _obj); - }, - getSnip: function() { - return _snip; - }, - loadSnip: function(path, snip) { - var k, results, v; - this.mergePathToTree(path, _.pluck(snip, "name")); - results = []; - for (k in snip) { - v = snip[k]; - results.push(_snip[path + "/" + v.name] = { - head: window.tree.reactify(v.body.head), - body: window.tree.reactify(v.body.body) - }); - } - return results; - }, - loadKids: function(path, kids) { - var k, results, v; - this.mergePathToTree(path, _.pluck(kids, "name")); - results = []; - for (k in kids) { - v = kids[k]; - results.push(_cont[path + "/" + v.name] = window.tree.reactify(v.body)); - } - return results; - }, - loadPath: function(path, body, kids) { - this.mergePathToTree(path, kids); - return _cont[path] = window.tree.reactify(body); - }, - getKids: function() { - return _.keys(this.getTree(_curr.split("/"))); - }, - getSiblings: function() { - var curr; - curr = _curr.split("/"); - curr.pop(); - if (curr.length !== 0) { - return this.getTree(curr); - } else { - return {}; - } - }, - getPrev: function() { - var ind, key, par, sibs, win; - sibs = _.keys(this.getSiblings()).sort(); - if (sibs.length < 2) { - return null; - } else { - par = _curr.split("/"); - key = par.pop(); - ind = sibs.indexOf(key); - win = ind - 1 >= 0 ? sibs[ind - 1] : sibs[sibs.length - 1]; - par.push(win); - return par.join("/"); - } - }, - getNext: function() { - var ind, key, par, sibs, win; - sibs = _.keys(this.getSiblings()).sort(); - if (sibs.length < 2) { - return null; - } else { - par = _curr.split("/"); - key = par.pop(); - ind = sibs.indexOf(key); - win = ind + 1 < sibs.length ? sibs[ind + 1] : sibs[0]; - par.push(win); - return par.join("/"); - } - }, - getPare: function() { - var _path; - _path = this.pathToArr(_curr); - if (_path.length > 1) { - _path.pop(); - _path = _path.join("/"); - if (_path === "") { - _path = "/"; - } - return _path; - } else { - return null; - } - }, - getCrumbs: function() { - var _path, crum, crums, k, v; - _path = this.pathToArr(_curr); - crum = ""; - crums = []; - for (k in _path) { - v = _path[k]; - crum += "/" + v; - crums.push({ - name: v, - path: crum - }); - } - return crums; - }, - getBody: function() { - if (_cont[_curr]) { - return _cont[_curr]; - } else { - return null; - } - } -}); - -TreeStore.dispatchToken = MessageDispatcher.register(function(payload) { - var action; - action = payload.action; - switch (action.type) { - case 'path-load': - TreeStore.loadPath(action.path, action.body, action.kids, action.snip); - return TreeStore.emitChange(); - case 'snip-load': - TreeStore.loadSnip(action.path, action.snip); - return TreeStore.emitChange(); - case 'kids-load': - TreeStore.loadKids(action.path, action.kids); - return TreeStore.emitChange(); - case 'set-curr': - TreeStore.setCurr(action.path); - return TreeStore.emitChange(); - case 'set-load': - TreeStore.setLoad(action.load); - return TreeStore.emitChange(); - } -}); - -module.exports = TreeStore; - - - -},{"../dispatcher/Dispatcher.coffee":"/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/dispatcher/Dispatcher.coffee","events":"/usr/local/lib/node_modules/watchify/node_modules/browserify/node_modules/events/events.js"}],"/usr/local/lib/node_modules/watchify/node_modules/browserify/node_modules/events/events.js":[function(require,module,exports){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; - -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - throw TypeError('Uncaught, unspecified "error" event.'); - } - return false; - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - len = arguments.length; - args = new Array(len - 1); - for (i = 1; i < len; i++) - args[i - 1] = arguments[i]; - handler.apply(this, args); - } - } else if (isObject(handler)) { - len = arguments.length; - args = new Array(len - 1); - for (i = 1; i < len; i++) - args[i - 1] = arguments[i]; - - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - var m; - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } - - listeners = this._events[type]; - - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; - -EventEmitter.listenerCount = function(emitter, type) { - var ret; - if (!emitter._events || !emitter._events[type]) - ret = 0; - else if (isFunction(emitter._events[type])) - ret = 1; - else - ret = emitter._events[type].length; - return ret; -}; - -function isFunction(arg) { - return typeof arg === 'function'; -} - -function isNumber(arg) { - return typeof arg === 'number'; -} - -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} - -function isUndefined(arg) { - return arg === void 0; -} - -},{}]},{},["/Users/galen/Documents/src/urbit-test/urb/zod/docs/pub/tree/src/js/main.coffee"]); +console.error("Error: Cannot find module '/Users/pittyp/temp/urb/zod/base/pub/tree/src/js/node_modules/coffeeify/index.js' from '/Users/pittyp/temp/urb/zod/base/pub/tree/src/js'") \ No newline at end of file diff --git a/base/tree/hymn.hook b/base/tree/hymn.hook index b9f14be59..a5458d9df 100644 --- a/base/tree/hymn.hook +++ b/base/tree/hymn.hook @@ -1,7 +1,7 @@ :: /? 314 /= gas /$ fuel -/= ral /: /=home= /% /react-js/ +/= ral /: /=== /% /react-js/ :: :::: :: @@ -17,12 +17,16 @@ ;head ;title: Tree ;meta(name "viewport", content "width=device-width, initial-scale=1"); - ;link(type "text/css", rel "stylesheet", href "/home/pub/tree/src/css/main.css"); + ;link(type "text/css", rel "stylesheet", href "//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.min.css"); + ;link(type "text/css", rel "stylesheet", href "/{(trip &2:%)}/pub/tree/src/css/main.css"); + ;link(type "text/css", rel "stylesheet", href "/{(trip &2:%)}/lib/syntax/codemirror.css"); ::;link(type "text/css", rel "stylesheet", href "http://localhost:8000/docs/pub/tree/src/css/main.css"); ;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"); ;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"); ;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js"); - ;script(type "text/javascript", src "/home/pub/tree/src/js/main.js"); + ;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.js"); + ;script(type "text/javascript", src "/{(trip &2:%)}/lib/syntax/hoon.js"); + ;script(type "text/javascript", src "/{(trip &2:%)}/pub/tree/src/js/main.js"); ::;script(type "text/javascript", src "http://localhost:8000/docs/pub/tree/src/js/main.js"); == ;body From 62e64ca8f128f9641bb50368e4bbbe4b43151473 Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Wed, 20 May 2015 19:41:18 -0400 Subject: [PATCH 07/34] fix :+sync --- base/cat/hood/sync/gate.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/cat/hood/sync/gate.hook b/base/cat/hood/sync/gate.hook index fd20cd1dc..4c00aaf32 100644 --- a/base/cat/hood/sync/gate.hook +++ b/base/cat/hood/sync/gate.hook @@ -9,4 +9,4 @@ [arg=[syd=@tas her=@p sud=@tas ~] ~] == :- %hood-sync -arg +[syd her sud]:arg From b5e96383972f238e06135636c8da7d5d1cfda22c Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 20 May 2015 16:58:27 -0700 Subject: [PATCH 08/34] Fix parsing of *desk/ape. --- base/lib/drum/core.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/lib/drum/core.hook b/base/lib/drum/core.hook index 2057ed9d4..f35c386d3 100644 --- a/base/lib/drum/core.hook +++ b/base/lib/drum/core.hook @@ -168,8 +168,8 @@ == ++ sp-well ;~ pose - (stag %home sym) ;~(plug sym ;~(pfix fas sym)) + (stag %home sym) == ++ sp-wells (most ;~(plug com ace) sp-well) -- From e4555740919f0f6b0754772ba7534352f0bb880c Mon Sep 17 00:00:00 2001 From: Philip C Monk Date: Wed, 20 May 2015 20:32:54 -0400 Subject: [PATCH 09/34] improved unix sync --- base/arvo/clay.hoon | 23 ++++++++++++++++++++--- base/arvo/zuse.hoon | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/base/arvo/clay.hoon b/base/arvo/clay.hoon index 83c19e1ac..523f37556 100644 --- a/base/arvo/clay.hoon +++ b/base/arvo/clay.hoon @@ -2874,40 +2874,57 @@ ^- soba :- *cart =| pax=path + :: =- ~& [%khan (turn - |=((pair path miso) [p -.q]))] - |- ^- (list ,[p=path q=miso]) ?~ ank ?~ kan + :: ~& >> [pax %ank-kan-sig] ~ + :: ~& >> [pax %ank-sig] =+ =+ (~(tap by dir.u.kan)) - |-(?~(+< ~ (weld ^$(pax [p.i pax], kan `q.i) $(+< t)))) + :: ~& [%dirukan pax=pax (~(run by dir.u.kan) (cury test ~))] + |- ^- (list (pair path miso)) + ?~ +< ~ + ?~ q.i $(+< t) + (weld ^$(pax [p.i pax], kan `u.q.i) $(+< t)) ?~ fil.u.kan - ?~ u.fil.u.kan - + :: ~& >> [pax %ins-1] [[(flop pax) %ins u.u.fil.u.kan] -] ?~ kan + :: ~& >> [pax %kan-sig] =+ =+ (~(tap by r.u.ank)) |-(?~(+< ~ (weld ^$(pax [p.i pax], ank `q.i) $(+< t)))) ?~ q.u.ank - [[(flop pax) %del q.u.q.u.ank] -] + :: ~& >> [pax %neither-sig] =+ %+ weld =+ (~(tap by r.u.ank)) |- ^- (list ,[p=path q=miso]) ?~ +< ~ + =+ (~(get by dir.u.kan) p.i) + ?: ?=([~ ~] -) $(+< t) %- weld :_ $(+< t) - ^$(pax [p.i pax], ank `q.i, kan (~(get by dir.u.kan) p.i)) + :: ~& >> [pax %ankhing p.i ?=(~ -)] + ^$(pax [p.i pax], ank `q.i, kan ?~(- ~ `u.u.-)) =+ (~(tap by dir.u.kan)) + :: ~& > [%sdirukan pax=pax (~(run by dir.u.kan) (cury test ~))] |- ^- (list ,[p=path q=miso]) ?~ +< ~ + ?~ q.i $(+< t) ?: (~(has by r.u.ank) p.i) $(+< t) + :: ~& >> [pax %khaning p.i] %- weld :_ $(+< t) - ^$(pax [p.i pax], kan `q.i, ank ~) + ^$(pax [p.i pax], kan `u.q.i, ank ~) ?~ q.u.ank ?~ fil.u.kan - ?~ u.fil.u.kan - + :: ~& %ins-2 [[(flop pax) %ins u.u.fil.u.kan] -] ?~ fil.u.kan - diff --git a/base/arvo/zuse.hoon b/base/arvo/zuse.hoon index b76695f44..3f0781fc3 100644 --- a/base/arvo/zuse.hoon +++ b/base/arvo/zuse.hoon @@ -2295,7 +2295,7 @@ :: ++ khan :: $: fil=(unit (unit cage)) :: XX see khan-to-soba - dir=(map ,@ta khan) :: + dir=(map ,@ta (unit khan)) :: == :: ++ mick (list ,[path (unit mime)]) ++ riff ,[p=desk q=(unit rave)] :: request/desist From b561cdcb950fc38d085001a0b94d3e47aecfd64d Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Wed, 20 May 2015 17:45:24 -0700 Subject: [PATCH 10/34] Display %url lines. --- base/ape/talk/core.hook | 3 +++ 1 file changed, 3 insertions(+) diff --git a/base/ape/talk/core.hook b/base/ape/talk/core.hook index 896e43ab6..b8fb13762 100644 --- a/base/ape/talk/core.hook +++ b/base/ape/talk/core.hook @@ -1644,6 +1644,9 @@ |= oug=? ^- tape ?+ -.sep "" + %url + (earn p.sep) + :: %lin =+ txt=(trip q.sep) ?: p.sep From 5703d91b3309cc50bb4609953ca882c351aa26cf Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Wed, 20 May 2015 18:34:45 -0700 Subject: [PATCH 11/34] ported do to newgall --- base/ape/do/core.hook | 168 +++++++++++++++++++++------------------- base/arvo/gall.hoon | 5 +- base/pub/do/src/main.js | 45 ++++++----- 3 files changed, 119 insertions(+), 99 deletions(-) diff --git a/base/ape/do/core.hook b/base/ape/do/core.hook index 173a9f1ec..dc9bcd290 100644 --- a/base/ape/do/core.hook +++ b/base/ape/do/core.hook @@ -8,7 +8,7 @@ :: :: -:::: sivtyv-barnels +:::: sivtyv-barnel :: !: @@ -23,7 +23,7 @@ $: id=@ud name=@t memory=@ud vcpus=@ud disk=@ud locked=? ++ regi ,[name=@t slug=@t sizes=(list ,@t)] ++ kern ,[id=@ud name=@t version=@t] ++ img -$: id=@ud name=@t distribution=@t slug=@t public=? regions=(list ,@t) +$: id=@ud name=@t distribution=@t slug=(unit ,@t) public=? regions=(list ,@t) created-at=@t type=@t min-disk-size=@ud == ++ ntwrks ,[v4=(list v) v6=(list v)] @@ -37,26 +37,15 @@ $: name=@t region=@t size=@t image=@ud ssh=(list cord) backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t) == -++ axle ,[ke=keys toke=tokens drops=(list droplet)] +++ axle ,[auth=[do=keys gcp=keys] toke=tokens drops=(list droplet)] ++ keys ,[authc=(unit ,@t) client-secret=(unit ,@t)] ++ tokens ,[access=@t refresh=@t] -++ hapt ,[ship path] -++ move ,[bone (mold note gift)] -++ note -$% -[%t %wait @da] -[%g %mess hapt ship cage] -[%e %them (unit hiss)] -== -++ gift -$% [%nice ~] - [%rush %json json] -== -++ sign -$% -[%t %wake ~] -[%g %nice ~] -[%e %thou p=httr] +++ move ,[bone card] +++ card +$% [%diff %json json] + [%wait wire @da] + [%send wire [ship term] %poke %talk-command command] + [%them wire (unit hiss)] == -- !: @@ -64,7 +53,7 @@ $% ++ parse-img => jo %- ot - :~ id/ni name/so distribution/so slug/so public/bo + :~ id/ni name/so distribution/so slug/(mu so) public/bo regions/(ar so) 'created_at'^so type/so 'min_disk_size'^ni == ++ parse-ntwrks @@ -115,7 +104,7 @@ $% region/(jobe reg) =+ ^= im :~ id/(jone id.image) name/s/name.image distribution/s/distribution.image - slug/s/slug.image public/b/public.image + slug/?~(slug.image ~ s/u.slug.image) public/b/public.image regions/a/(turn regions.image |=(el=cord s/el)) created-at/s/created-at.image type/s/type.image min-disk-size/(jone min-disk-size.image) @@ -154,10 +143,11 @@ $% %+ turn (~(tap by sup.hid)) |= [sub=bone @ pax=path] ^- move - [sub %give %rush %json jon] + [sub %diff %json jon] ++ auth-queries + |= code=cord :~ 'grant_type'^'authorization_code' - 'code'^(need authc.ke.vat) + 'code'^code :- 'client_id' 'd8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f' 'redirect_uri'^'http://localhost:8443/home/pub/do/fab' @@ -181,46 +171,62 @@ $% ?@ req-type [%get headers ~] [%post headers ~ (tact (pojo +.req-type))] - :^ ost %pass pour-path - :+ %e %them + :^ ost %them pour-path `(unit hiss)`[~ request] :: ++ peer - |= [ost=bone you=ship pax=path] + |= [[ost=bone you=ship] pax=path] ^- [(list move) _+>.$] :_ +>.$ - [ost %give %rush %json (state-to-json drops.vat)]~ + [ost %diff %json (state-to-json drops.vat)]~ :: -++ poke-oauth2-code - |= [ost=bone you=ship code=cord] +++ poke-do-auth + |= [[ost=bone you=ship] [cde=cord typ=cord]] ^- [(list move) _+>.$] - ~& code - =. authc.ke.vat - [~ code] - =+ ath=(need authc.ke.vat) + ~& [cde typ] + ?: =(%do typ) + =. authc.do.auth.vat + [~ cde] + :_ +>.$ + ~ + =. authc.gcp.auth.vat + [~ cde] :_ +>.$ - [ost %give %nice ~]~ + ~ :: -++ poke-client-secret - |= [ost=bone you=ship secret=cord] +++ poke-do-secret + |= [[ost=bone you=ship] secret=cord typ=cord] + ~& +<+ ^- [(list move) _+>.$] - =. client-secret.ke.vat - [~ secret] - ~& [secret=client-secret.ke.vat code=authc.ke.vat] - :_ +>.$ - :_ [ost %give %nice ~]~ - %^ httpreq ost /auth - :^ ~[%digitalocean %cloud] `path`/v1/oauth/token - [%post ~] - :- ~ `quay`['client_secret'^(need client-secret.ke.vat) auth-queries] + ::=+ [newvat code path]=[vat(auth auth.vat) ...] + ::=. vat newvat + ?+ typ ~|(missing-platform=typ !!) + %do + =. client-secret.do.auth.vat + [~ secret] + :_ +>.$ + :_ ~ + %^ httpreq ost /auth + :^ ~[%digitalocean %cloud] `path`/v1/oauth/token + [%post ~] + :- ~ `quay`['client_secret'^secret (auth-queries (need authc.do.auth.vat))] + %gce + =. client-secret.gcp.auth.vat + [~ secret] + :_ +>.$ + :_ ~ + %^ httpreq ost /auth + :^ ~[%google %cloud] `path`/v1/oauth/token + [%post ~] + :- ~ `quay`['client_secret'^secret (auth-queries (need authc.gcp.auth.vat))] + == :: ++ receive-auth - |= [ost=bone pour-path=path resp=sign] + |= [ost=bone pour-path=path resp=httr] ^- [(list move) _+>.$] - ?> ?=(%thou +<.resp) ~| resp - =+ body=(rash q:(need r.p.+.resp) apex:poja) - ~| recieve-auth/resp(r.p.+ body) + =+ body=(rash q:(need r.resp) apex:poja) + ~| recieve-auth/resp(r body) =+ [ac re]=(need ((ot 'access_token'^so 'refresh_token'^so ~):jo body)) =: access.toke.vat ac refresh.toke.vat re @@ -231,14 +237,14 @@ $% == :: ++ poke-json - |= [ost=bone you=ship act=json] + |= [[ost=bone you=ship] act=json] ^- [(list move) _+>.$] =+ do=(need ((ot action/so ~):jo act)) ?+ do !! %list :_ +>.$ :- (list-droplets ost) - [ost %give %nice ~]~ + ~ :: %create :_ +>.$ @@ -251,7 +257,7 @@ $% 'ipv6'^(mu bo) 'priv_networking'^(mu bo) 'user_data'^(mu so) == :- (create-droplet ost deets) - [ost %give %nice ~]~ + ~ :: $? %reboot %'power_cycle' %shutdown %'power_off' %'power_on' %'password_reset' %'enable_ipv6' %'enable_private_networking' @@ -271,7 +277,7 @@ $% :: restore, resize, rebuild, change_kernelm, retrieve droplet action :_ +>.$ ^- (list move) - :_ [os %give %nice ~]~ + :_ ~ =+ ^= req %- httpreq :* os /reboot @@ -293,10 +299,9 @@ $% (httpreq lis) :: ++ receive-list - |= [ost=bone pour-path=path resp=sign] + |= [ost=bone pour-path=path resp=httr] ^- [(list move) _+>.$] - ?> ?=(%thou +<.resp) - =+ parsed=(rash q:(need r.p.+.resp) apex:poja) + =+ parsed=(rash q:(need r.resp) apex:poja) ~| recieve-list/parsed =+ dar=(need ((ot droplets/(ar some) ~):jo parsed)) =+ ^- dropz=(list droplet) @@ -319,31 +324,39 @@ $% =+ buf=`@da`(add ~s10 lat.hid) :_ +>.$ :_ (spam (state-to-json drops.vat)) - [ost %pass /refresh %t [%wait p=buf]] + [ost %wait /refresh buf] :: ++ create-droplet |= [os=bone reqbody] - =+ ^= create :* - os /create - ~[%digitalocean %api] /v2/droplets - :- %post - %- create-body - :* name region size image ssh backups - ipv6 private-networking user-data + =- ~& - - + =+ ^- body=json + %- create-body :* + name region size image ssh backups + ipv6 private-networking user-data == - %^ mo ['Content-Type' 'application/json' ~] - ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] ~ - ~ - == - ~& (httpreq create) - (httpreq create) + %- httpreq :* + os /create + ~[%digitalocean %api] /v2/droplets + [%post body] + %^ mo ['Content-Type' 'application/json' ~] + ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] + ~ + ~ + == :: -++ pour - |= [ost=bone pour-path=path resp=sign] +++ wake + |= [[ost=bone him=ship pour-path=path] ~] + ?+ -.pour-path !! + %refresh + :_ +>.$ + [(list-droplets ost)]~ + == +++ thou + |= [[ost=bone him=ship pour-path=path] resp=httr] ^- [(list move) _+>.$] ?+ -.pour-path !! %auth - (receive-auth `bone`ost `path`pour-path `sign`resp) + (receive-auth `bone`ost `path`pour-path resp) :: %list (receive-list ost pour-path resp) @@ -360,9 +373,6 @@ $% %pub :_ +>.$ ~ :: - %refresh - :_ +>.$ - [(list-droplets ost)]~ == ++ publish |= [ost=bone you=ship act=(list speech)] @@ -381,6 +391,6 @@ $% ^- thought :- `@`(sham eny.hid tail) tail - =+ cag=`cage`[%talk-command !>([%publish `(list thought)`spchz])] - [ost %pass /pub %g %mess [our.hid /talk] you cag] + =+ mez=[%talk-command [%publish `(list thought)`spchz]] + [ost %send /pub [our.hid %talk] %poke mez] -- diff --git a/base/arvo/gall.hoon b/base/arvo/gall.hoon index 801b89daa..b3d36bb2b 100644 --- a/base/arvo/gall.hoon +++ b/base/arvo/gall.hoon @@ -805,7 +805,9 @@ ^+ +> =+ cug=(ap-find /lame) ?~ cug - ~& [%ap-lame wut why] + ~> %slog. + :- ~ + rose/[" " "[" "]"]^[>%ap-lame< >wut< why] +>.$ =^ cam +>.$ %+ ap-call q.u.cug @@ -984,6 +986,7 @@ %merg `%c %plug `%c %them `%e + %wait `%t %want `%a == -- diff --git a/base/pub/do/src/main.js b/base/pub/do/src/main.js index 9c503d423..d745aabd4 100644 --- a/base/pub/do/src/main.js +++ b/base/pub/do/src/main.js @@ -47,22 +47,29 @@ Droplet = React.createClass({ }) Page = recl({ - handleClick: function(){ - if(window.authcode.length !== ''){ - console.log(window.authcode); - urb.send({ - appl: "do", - data: window.authcode, - mark: "oauth2-code"}) - } else { console.log("nocode") } + handleClick: function(platform){ + return function(){ + console.log(platform); + if(window.authcode.length !== ''){ + urb.send({ + appl: "do", + data: {authcode:window.authcode, + platform:platform}, + mark: "do-auth"}) + } else { console.log("nocode") } + } }, - sendSecret: function(){ - if($('#appsecret').val()) { - urb.send({appl: "do", - data: $('#appsecret').val(), - mark: "client-secret" - }) + sendSecret: function(platform,codeid){ + return function(){ + console.log(platform,codeid) + secret= $(codeid).val() + if(secret !== '') { + urb.send({appl: "do", + data: {secret:secret, + platform:platform}, + mark: "do-secret"}) + } } }, @@ -80,7 +87,7 @@ Page = recl({ region:$('#region').val(), size:$('#size').val(), image:$('#image').val(), - ssh:[] // $('#ssh').val()], + ssh:[], // $('#ssh').val()] backups:null,//$('#backups').val(), ipv6:null,//$('#ipv6').val(), priv_networking:null,//$('#priv-networking').val(), @@ -97,22 +104,22 @@ Page = recl({ a({href:href},[ "get authcode" ]), - b({onClick:this.handleClick}, "Send Authcode") + b({onClick:this.handleClick('do')}, "Send Authcode") ), div({}, [ input({id:"appsecret"}, - b({onClick:this.sendSecret}, "Send Secret")) + b({onClick:this.sendSecret('do','#appsecret')}, "Send Secret")) ]), b({onClick:this.getList}, "Get List"), div({}, a({href:ghref},[ "Get Google Authcode" ]), - b({onClick:this.handleClick}, "Send Google Authcode") + b({onClick:this.handleClick('gce','#gappsecret')}, "Send Google Authcode") ), div({}, [ input({id:"gappsecret"}, - b({onClick:this.sendSecret}, "Send Google Secret")) + b({onClick:this.sendSecret('gce')}, "Send Google Secret")) ]), div({}, [ b({onClick:this.createDroplet}, "Create Droplet"), From 9fad0573dbc0e976f781965698183e37e8796ee4 Mon Sep 17 00:00:00 2001 From: "C. Guy Yarvin" Date: Thu, 21 May 2015 09:05:14 -0700 Subject: [PATCH 12/34] Fix up demo a little bit. --- base/ape/octo/core.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/ape/octo/core.hook b/base/ape/octo/core.hook index 009f8c41d..42365e72d 100644 --- a/base/ape/octo/core.hook +++ b/base/ape/octo/core.hook @@ -118,7 +118,7 @@ ++ dish |=(cad=card (dump 0 cad)) :: forward move ++ flet |=(from ~(. et +< (~(got by q.eye) ost))) :: in old client ++ fret |=(from ~(. et +< *sole-share)) :: in new client -++ like |=(xir=ship |*(* [/octo [xir %octo] +<])) :: to friend +++ like |=(a=ship |*(* [/octo [a %tictactoe] +<])) :: to friend ++ link |= mot=mote %+ dish(but `[| mot]) %peer :: subscribe to friend ((like p.mot) /octo/net/[?:(q.mot %x %o)]) :: ++ pals %+ turn (pale hid (prix /sole)) |= sink :: per console From 5650ae05f88dd7b32cb4936ee9b8989fb44b01d2 Mon Sep 17 00:00:00 2001 From: demo Date: Thu, 21 May 2015 21:34:06 +0000 Subject: [PATCH 13/34] tame empty-broq-peek --- base/arvo/time.hoon | 3 +++ 1 file changed, 3 insertions(+) diff --git a/base/arvo/time.hoon b/base/arvo/time.hoon index 52244c3eb..a9b0453dc 100644 --- a/base/arvo/time.hoon +++ b/base/arvo/time.hoon @@ -29,6 +29,7 @@ ++ raze |= tym=[p=clok q=clok] ^+ tym + ?~ p.tym tym ?~ q.tym tym ?: (gth p:~(get up p.tym) p:~(get up q.tym)) :: killed nonexisting ~& [%snooze-lost del=p:~(get up q.tym) top=p:~(get up p.tym)] @@ -182,6 +183,8 @@ |- ^+ [*(list move) tym] =. tym (raze tym) ?: =([~ ~] tym) [~ tym] :: XX TMI + ?: =(~ p.tym) + ~& %weird-wake [~ tym] =+ nex=~(get up p.tym) ?: (lte now p.nex) [~ tym] =^ mof tym $(p.tym ~(pop up p.tym)) From f60df5f6b58d2048f23a41b046c27142c6d4e26a Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 21 May 2015 15:56:14 -0700 Subject: [PATCH 14/34] /= decrash --- base/ape/dojo/core.hook | 3 ++- base/arvo/hoon.hoon | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/base/ape/dojo/core.hook b/base/ape/dojo/core.hook index e56599d47..7ce98b071 100644 --- a/base/ape/dojo/core.hook +++ b/base/ape/dojo/core.hook @@ -240,10 +240,11 @@ ++ dp-model-cat ;~(plug dp-server-cat dp-config) :: ++dojo-model ++ dp-model-dog ;~(plug dp-server-dog dp-config) :: ++dojo-model ++ dp-model-pig ;~(plug dp-server-pig dp-config) :: ++dojo-model + ++ dp-path `path`/(scot %p our.hid)/home/(scot %da lat.hid) ++ dp-server-cat (stag 0 (stag %cat dp-device)) :: ++dojo-server ++ dp-server-dog (stag 0 (stag %dog dp-device)) :: ++dojo-server ++ dp-server-pig (stag 0 (stag %pig dp-device)) :: ++dojo-server - ++ dp-twig wide:(vang & ~) :: ++twig + ++ dp-twig wide:(vang & dp-path) :: ++twig ++ dp-device (most fas sym) :: ++dojo-device ++ dp-value :: ++dojo-source %+ cook |=(a=dojo-source a) diff --git a/base/arvo/hoon.hoon b/base/arvo/hoon.hoon index 6cdef6d2d..f11c2cb44 100644 --- a/base/arvo/hoon.hoon +++ b/base/arvo/hoon.hoon @@ -8425,30 +8425,34 @@ $(i.ruw t.i.ruw, cah [i.i.ruw cah]) $(i.ruw t.i.ruw, cah ~, yun [p.i.i.ruw (wod cah yun)]) :: - ++ posh + ++ posh !: |= [pre=(unit tyke) pof=(unit ,[p=@ud q=tyke])] - ^- (list twig) - ~| %posh-fail + ^- (unit (list twig)) + =- ?^(- - ~&(%posh-fail -)) =+ wom=(poof wer) - =+ ^= yez - ?~ pre wom - =+ moz=(poon wom u.pre) - ?~(pof moz (weld moz (slag (lent u.pre) wom))) - ?~ pof yez + %+ biff + ?~ pre `u=wom + %+ bind (poon wom u.pre) + |= moz=(list twig) + ?~(pof moz (weld moz (slag (lent u.pre) wom))) + |= yez=(list twig) + ?~ pof `yez =+ zey=(flop yez) =+ [moz=(scag p.u.pof zey) gul=(slag p.u.pof zey)] - (weld (flop gul) (poon (flop moz) q.u.pof)) + =+ zom=(poon (flop moz) q.u.pof) + ?~(zom ~ `(weld (flop gul) u.zom)) :: ++ poof |=(pax=path ^-(tusk (turn pax |=(a=@ta [%dtzy %ta a])))) ++ poon |= [pag=tusk goo=tyke] - ^- tusk - ?~ goo ~ - :- ?^(i.goo u.i.goo ?>(?=(^ pag) i.pag)) + ^- (unit tusk) + ?~ goo `~ + %+ both + ?^(i.goo i.goo ?~(pag ~ `u=i.pag)) $(goo t.goo, pag ?~(pag ~ t.pag)) :: ++ poor - %+ cook posh + %+ sear posh ;~ plug (stag ~ gash) ;~(pose (stag ~ ;~(pfix cen porc)) (easy ~)) @@ -8746,13 +8750,13 @@ :- '%' ;~ pfix cen ;~ pose - (cook |=([a=@ud b=tyke] [%clsg (posh ~ ~ a b)]) porc) + (stag %clsg (sear |=([a=@ud b=tyke] (posh ~ ~ a b)) porc)) (stag %dtzz (stag %tas (cold %$ buc))) (stag %dtzz (stag %f (cold & pam))) (stag %dtzz (stag %f (cold | bar))) (stag %dtzz (stag %t qut)) (cook (jock &) nuck:so) - (cook |=(a=(list) [%clsg (posh ~ ~ (lent a) ~)]) (star cen)) + (stag %clsg (sear |=(a=(list) (posh ~ ~ (lent a) ~)) (star cen))) :: (easy [%clsg (poof wer)]) == == From 860df1d8b40b6ac6935eb4848364b96618107447 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 21 May 2015 16:47:50 -0700 Subject: [PATCH 15/34] missing desk assert --- base/arvo/eyre.hoon | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index e897f2fb0..feb664087 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -1014,6 +1014,8 @@ =+ ext=(fall p.pok %urb) =+ bem=?-(-.hem %beam p.hem, %spur [root-beak p.hem]) =+ wir=?+(mef !! %get ~, %head [%he ~]) + ~| bad-beam/q.bem + ?< =([~ 0] (sky %cw (tope bem(+ ~, r [%da now])))) =- ?.(aut [%& %| -] [%| (pass-note -)]) :: XX properly [wir (ford-get-beam bem ext)] :: From e6d8ec36d050eb182ae31b280ae7209fbe61bcbd Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Thu, 21 May 2015 17:22:56 -0700 Subject: [PATCH 16/34] do->cloud rename --- base/ape/{do => cloud}/core.hook | 10 +++++----- base/mar/cloud-auth/door.hook | 16 ++++++++++++++++ base/mar/cloud-secret/door.hook | 9 +++++++++ base/pub/{do => cloud}/fab/hymn.hook | 8 ++++---- base/pub/{do => cloud}/src/main.css | 0 base/pub/{do => cloud}/src/main.js | 20 ++++++++++---------- 6 files changed, 44 insertions(+), 19 deletions(-) rename base/ape/{do => cloud}/core.hook (98%) create mode 100644 base/mar/cloud-auth/door.hook create mode 100644 base/mar/cloud-secret/door.hook rename base/pub/{do => cloud}/fab/hymn.hook (76%) rename base/pub/{do => cloud}/src/main.css (100%) rename base/pub/{do => cloud}/src/main.js (91%) diff --git a/base/ape/do/core.hook b/base/ape/cloud/core.hook similarity index 98% rename from base/ape/do/core.hook rename to base/ape/cloud/core.hook index dc9bcd290..4912b3188 100644 --- a/base/ape/do/core.hook +++ b/base/ape/cloud/core.hook @@ -150,7 +150,7 @@ $% [%diff %json json] 'code'^code :- 'client_id' 'd8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f' - 'redirect_uri'^'http://localhost:8443/home/pub/do/fab' + 'redirect_uri'^'http://localhost:8443/home/pub/cloud/fab' == ++ httpreq |= $: ost=bone pour-path=wire @@ -180,7 +180,7 @@ $% [%diff %json json] :_ +>.$ [ost %diff %json (state-to-json drops.vat)]~ :: -++ poke-do-auth +++ poke-cloud-auth |= [[ost=bone you=ship] [cde=cord typ=cord]] ^- [(list move) _+>.$] ~& [cde typ] @@ -194,9 +194,8 @@ $% [%diff %json json] :_ +>.$ ~ :: -++ poke-do-secret +++ poke-cloud-secret |= [[ost=bone you=ship] secret=cord typ=cord] - ~& +<+ ^- [(list move) _+>.$] ::=+ [newvat code path]=[vat(auth auth.vat) ...] ::=. vat newvat @@ -253,7 +252,8 @@ $% [%diff %json json] %. act => jo %- ot - :~ name/so region/so size/so image/(su dem) ssh/(ar so) backups/(mu bo) + :~ name/so region/so size/so image/(su dem) :: id key:img object + ssh/(ar so) backups/(mu bo) 'ipv6'^(mu bo) 'priv_networking'^(mu bo) 'user_data'^(mu so) == :- (create-droplet ost deets) diff --git a/base/mar/cloud-auth/door.hook b/base/mar/cloud-auth/door.hook new file mode 100644 index 000000000..695a9b6b1 --- /dev/null +++ b/base/mar/cloud-auth/door.hook @@ -0,0 +1,16 @@ +:: this mark is used to receive incoming oauth2 tokens that we use to poke our %gall server +:: +:::: /hook/door/do-auth/mar + :: +/? 310 +!: +|_ cod=cord +:: +++ grab :: converter arm + |% + ++ noun ,@t :: clam from noun + ++ json (cork (ot authcode/so platform/so ~):jo need) :: (need (so:jo jon)) + -- +-- + + diff --git a/base/mar/cloud-secret/door.hook b/base/mar/cloud-secret/door.hook new file mode 100644 index 000000000..3cdf63110 --- /dev/null +++ b/base/mar/cloud-secret/door.hook @@ -0,0 +1,9 @@ +!: +|_ cod=cord +:: +++ grab :: converter am + |% + ++ noun ,@t :: clam from noun + ++ json (cork (ot secret/so platform/so ~):jo need) :: (need (so:jo jon)) + -- +-- diff --git a/base/pub/do/fab/hymn.hook b/base/pub/cloud/fab/hymn.hook similarity index 76% rename from base/pub/do/fab/hymn.hook rename to base/pub/cloud/fab/hymn.hook index 6a1edce0c..78bffedd9 100644 --- a/base/pub/do/fab/hymn.hook +++ b/base/pub/cloud/fab/hymn.hook @@ -14,11 +14,11 @@ ;html ;head ;script@"/~/at/home/lib/urb.js"; - ;script: urb.appl = 'do' + ;script: urb.appl = 'cloud' ;script@"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"; ;script@"https://cdnjs.cloudflare.com/ajax/libs/react/0.12.2/react.js"; - ::;link/"/main/pub/do/src/main.css"(rel "stylesheet"); - ;title: DO Instance Tracker + ::;link/"/main/pub/cloud/src/main.css"(rel "stylesheet"); + ;title: DO & GCE Manager == ;body ;* =+ d=?~(do ~ (trip u.do)) @@ -26,6 +26,6 @@ :_ ~ ;script: authcode='{?~(d g d)}'; console.log(authcode) ;div#container; - ;script@"/home/pub/do/src/main.js"; + ;script@"/home/pub/cloud/src/main.js"; == == diff --git a/base/pub/do/src/main.css b/base/pub/cloud/src/main.css similarity index 100% rename from base/pub/do/src/main.css rename to base/pub/cloud/src/main.css diff --git a/base/pub/do/src/main.js b/base/pub/cloud/src/main.js similarity index 91% rename from base/pub/do/src/main.js rename to base/pub/cloud/src/main.js index d745aabd4..410126bf3 100644 --- a/base/pub/do/src/main.js +++ b/base/pub/cloud/src/main.js @@ -12,14 +12,14 @@ input = React.DOM.input Droplet = React.createClass({ dropletAction:function(id, action){ urb.send({ - appl:"do", + appl:"cloud", data: {action: action, id: id}}) }, rebootDroplet: function() { urb.send({ - appl: "do", + appl: "cloud", data: {action: 'reboot', id: this.props.id}}) }, @@ -52,10 +52,10 @@ Page = recl({ console.log(platform); if(window.authcode.length !== ''){ urb.send({ - appl: "do", + appl: "cloud", data: {authcode:window.authcode, platform:platform}, - mark: "do-auth"}) + mark: "cloud-auth"}) } else { console.log("nocode") } } }, @@ -65,22 +65,22 @@ Page = recl({ console.log(platform,codeid) secret= $(codeid).val() if(secret !== '') { - urb.send({appl: "do", + urb.send({appl: "cloud", data: {secret:secret, platform:platform}, - mark: "do-secret"}) + mark: "cloud-secret"}) } } }, getList: function(){ - urb.send({appl: "do", + urb.send({appl: "cloud", data: {action:"list"}, mark: "json"}) }, createDroplet: function(){ - urb.send({appl: "do", + urb.send({appl: "cloud", data: { action:'create', name:$('#name').val(), @@ -97,8 +97,8 @@ Page = recl({ }, render: function(){ - href = "https://cloud.digitalocean.com/v1/oauth/authorize?client_id=d8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f&redirect_uri=http%3A%2F%2Flocalhost%3A8443%2Fhome%2Fpub%2Fdo%2Ffab&response_type=code&scope=read+write" - ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&state=someinfo&redirect_uri=http://localhost:8443/home/pub/do/fab&client_id=720541965785-jr3c6ijo8abonu9qj77qre1itsdra52r.apps.googleusercontent.com" + href = "https://cloud.digitalocean.com/v1/oauth/authorize?client_id=d8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f&redirect_uri=http%3A%2F%2Flocalhost%3A8443%2Fhome%2Fpub%2Fcloud%2Ffab&response_type=code&scope=read+write" + ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&state=someinfo&redirect_uri=http://localhost:8443/home/pub/cloud/fab&client_id=720541965785-jr3c6ijo8abonu9qj77qre1itsdra52r.apps.googleusercontent.com" return (div({}, [ div({}, a({href:href},[ From ffed0f0c62889f8330322886db79fb7a4b7a3419 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 21 May 2015 17:39:55 -0700 Subject: [PATCH 17/34] debugging printf --- base/arvo/eyre.hoon | 1 + 1 file changed, 1 insertion(+) diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index feb664087..facb1b7a9 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -1204,6 +1204,7 @@ ++ foreign-auth |= [him=ship pul=purl] ^+ ..ya =. way (~(put by way) him pul hen) + ~& asking-foreign/him (ames-gram:abet him [lon/~ ses]) :: ++ foreign-hat From 8515db0b3a8850359cbd4016314bfc71b1338f70 Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Thu, 21 May 2015 19:53:50 -0700 Subject: [PATCH 18/34] reorganized frontend components --- base/pub/cloud/src/main.js | 151 +++++++++++++++++++++---------------- 1 file changed, 87 insertions(+), 64 deletions(-) diff --git a/base/pub/cloud/src/main.js b/base/pub/cloud/src/main.js index 410126bf3..399503ada 100644 --- a/base/pub/cloud/src/main.js +++ b/base/pub/cloud/src/main.js @@ -9,6 +9,88 @@ tr = React.DOM.tr td = React.DOM.td input = React.DOM.input +DOControls = React.createClass({ + createDroplet: function(){ + urb.send({appl: "cloud", + data: { + action:'create', + name:$('#name').val(), + region:$('#region').val(), + size:$('#size').val(), + image:$('#image').val(), + ssh:[], // $('#ssh').val()] + backups:null,//$('#backups').val(), + ipv6:null,//$('#ipv6').val(), + priv_networking:null,//$('#priv-networking').val(), + user_data:null//$('#user-data').val() + }, + mark: "json"}) + }, + + render: function(){ + href = "https://cloud.digitalocean.com/v1/oauth/authorize?client_id=d8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f&redirect_uri=http%3A%2F%2Flocalhost%3A8443%2Fhome%2Fpub%2Fcloud%2Ffab&response_type=code&scope=read+write" + return ( + div({}, [ + div({}, + a({href:href},"get authcode"), + b({onClick:this.props.handleClick('do')}, "Send Authcode") + ), + div({}, [ + input({id:"appsecret"}, + b({onClick:this.props.sendSecret('do','#appsecret')}, "Send Secret")) + ]), + + div({}, [ + b({onClick:this.createDroplet}, "Create Droplet"), + input({id:"name",placeholder:"Name of droplet"}), + input({id:"region",placeholder:"Region"}), + input({id:"size",placeholder:"Size (str ending in mb"}), + input({id:"image",placeholder:"Image"}), + input({id:"ssh",placeholder:"ssh keys (optional)"}), + input({id:"backups",placeholder:"backups (optional)"}), + input({id:"ipv6",placeholder:"ipv6 (boolean, optional)"}), + input({id:"user-data",placeholder:" user-data string (optional)"}), + input({id:"priv-networking",placeholder:"Private Networking (boolean, optional)"}) + ]) + ]) + ) + } +}) + +GCEControls = React.createClass({ + createDroplet: function(){ + urb.send({ + + }) + } + render: function(){ + ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&state=someinfo&redirect_uri=http://localhost:8443/home/pub/cloud/fab&client_id=720541965785-jr3c6ijo8abonu9qj77qre1itsdra52r.apps.googleusercontent.com" + return( + div({}, [ + div({}, [ + a({href:ghref},"Get Google Authcode"), + b({onClick:this.props.handleClick('gce','#gappsecret')}, "Send Google Authcode") + ]), + div({}, [ + input({id:"gappsecret"}, + b({onClick:this.props.sendSecret('gce')}, "Send Google Secret")) + ]), + div({}, [ + b({onClick:this.createDroplet}, "Create Droplet"), + input({id:"project",placeholder:"project"}), + input({id:"zone",placeholder:"zone"}), + input({id:"name",placeholder:"Name of droplet"}), + input({id:"size",placeholder:"Size (str ending in mb"}), + input({id:"image",placeholder:"Image"}), + input({id:"ssh",placeholder:"ssh keys (optional)"}), + input({id:"backups",placeholder:"backups (optional)"}), + input({id:"ipv6",placeholder:"ipv6 (boolean, optional)"}), + input({id:"user-data",placeholder:" user-data string (optional)"}), + input({id:"priv-networking",placeholder:"Private Networking (boolean, optional)"}) + ]) + )} +}) + Droplet = React.createClass({ dropletAction:function(id, action){ urb.send({ @@ -17,13 +99,6 @@ Droplet = React.createClass({ id: id}}) }, - rebootDroplet: function() { - urb.send({ - appl: "cloud", - data: {action: 'reboot', - id: this.props.id}}) - }, - render: function() { var $this = this //local var, else it always points at second var acts = ["reboot","power_cycle","shutdown","power_off","power_on","password_reset", @@ -79,65 +154,13 @@ Page = recl({ mark: "json"}) }, - createDroplet: function(){ - urb.send({appl: "cloud", - data: { - action:'create', - name:$('#name').val(), - region:$('#region').val(), - size:$('#size').val(), - image:$('#image').val(), - ssh:[], // $('#ssh').val()] - backups:null,//$('#backups').val(), - ipv6:null,//$('#ipv6').val(), - priv_networking:null,//$('#priv-networking').val(), - user_data:null//$('#user-data').val() - }, - mark: "json"}) - }, render: function(){ - href = "https://cloud.digitalocean.com/v1/oauth/authorize?client_id=d8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f&redirect_uri=http%3A%2F%2Flocalhost%3A8443%2Fhome%2Fpub%2Fcloud%2Ffab&response_type=code&scope=read+write" - ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&state=someinfo&redirect_uri=http://localhost:8443/home/pub/cloud/fab&client_id=720541965785-jr3c6ijo8abonu9qj77qre1itsdra52r.apps.googleusercontent.com" - return (div({}, [ - div({}, - a({href:href},[ - "get authcode" - ]), - b({onClick:this.handleClick('do')}, "Send Authcode") - ), - div({}, [ - input({id:"appsecret"}, - b({onClick:this.sendSecret('do','#appsecret')}, "Send Secret")) - ]), - b({onClick:this.getList}, "Get List"), - div({}, - a({href:ghref},[ - "Get Google Authcode" - ]), - b({onClick:this.handleClick('gce','#gappsecret')}, "Send Google Authcode") - ), - div({}, [ - input({id:"gappsecret"}, - b({onClick:this.sendSecret('gce')}, "Send Google Secret")) - ]), - div({}, [ - b({onClick:this.createDroplet}, "Create Droplet"), - input({id:"name",placeholder:"Name of droplet"}), - input({id:"region",placeholder:"Region"}), - input({id:"size",placeholder:"Size (str ending in mb"}), - input({id:"image",placeholder:"Image"}), - input({id:"ssh",placeholder:"ssh keys (optional)"}), - input({id:"backups",placeholder:"backups (optional)"}), - input({id:"ipv6",placeholder:"ipv6 (boolean, optional)"}), - input({id:"user-data",placeholder:" user-data string (optional)"}), - input({id:"priv-networking",placeholder:"Private Networking (boolean, optional)"}) - ]), - div({}, - this.props.droplets.map(Droplet) - ) - ]) - ) + return (div({}, + DOControls({handleClick:this.handleClick,sendSecret:this.sendSecret}), + GCEControls({handleClick:this.handleClick,sendSecret:this.sendSecret}) + )) + //this.props.droplets.map(Droplet) } }) From 71754c764b4cad588f2234fe9dad5eac729cdd08 Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Sat, 23 May 2015 13:45:42 -0700 Subject: [PATCH 19/34] question about error msgs --- base/ape/cloud/core.hook | 115 ++++++++++++++++++++++++++----------- base/pub/cloud/src/main.js | 37 ++++++------ 2 files changed, 102 insertions(+), 50 deletions(-) diff --git a/base/ape/cloud/core.hook b/base/ape/cloud/core.hook index 4912b3188..bb9651ce3 100644 --- a/base/ape/cloud/core.hook +++ b/base/ape/cloud/core.hook @@ -32,12 +32,17 @@ $: id=@ud name=@t distribution=@t slug=(unit ,@t) public=? regions=(list , $: memory=@ud price-monthly=@t price-hourly=@t disk=@ud vcpus=@ud slug=@t transfer=@t available=? regions=(list ,@t) == -++ reqbody +++ create-req-do $: -name=@t region=@t size=@t image=@ud ssh=(list cord) -backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t) +name=@t region=@t size=@t image=@t ssh=(list cord) +backups=(unit ,?) ipv6=(unit ,?) +private-networking=(unit ,?) user-data=(unit ,@t) +== +++ create-req-gce ,[project=@t zone=@t name=@t machine-type=@t] +++ axle +$: auth=[do=keys gcp=keys] toke=[do=tokens gcp=tokens] + drops=(list droplet) == -++ axle ,[auth=[do=keys gcp=keys] toke=tokens drops=(list droplet)] ++ keys ,[authc=(unit ,@t) client-secret=(unit ,@t)] ++ tokens ,[access=@t refresh=@t] ++ move ,[bone card] @@ -71,12 +76,12 @@ $% [%diff %json json] ++ parse-region => jo (ot name/so slug/so sizes/(ar so) ~) -++ create-body - |= $: name=@t region=@t size=@t image=@ud ssh-keys=(list cord) +++ create-do-body + |= $: name=@t region=@t size=@t image=@t ssh-keys=(list cord) backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t) == %- jobe - :~ name/s/name region/s/region size/s/size image/(jone image) ::(jone image) + :~ name/s/name region/s/region size/s/size image/s/image ::(jone image) backups/?~(backups ~ b/u.backups) ipv6/?~(ipv6 ~ b/u.ipv6) 'user_data'^?~(user-data ~ s/u.user-data) 'private_networking'^?~(private-networking ~ b/u.private-networking) == @@ -136,7 +141,7 @@ $% [%diff %json json] !: |_ [hid=hide vat=axle] :: -++ prep ,_`. +::++ prep ,_`. ::: ++ spam |= jon=json @@ -189,14 +194,15 @@ $% [%diff %json json] [~ cde] :_ +>.$ ~ - =. authc.gcp.auth.vat - [~ cde] + =. access.gcp.toke.vat + cde :_ +>.$ ~ :: ++ poke-cloud-secret |= [[ost=bone you=ship] secret=cord typ=cord] ^- [(list move) _+>.$] + ~& [secret typ] ::=+ [newvat code path]=[vat(auth auth.vat) ...] ::=. vat newvat ?+ typ ~|(missing-platform=typ !!) @@ -205,7 +211,7 @@ $% [%diff %json json] [~ secret] :_ +>.$ :_ ~ - %^ httpreq ost /auth + %^ httpreq ost /auth-do :^ ~[%digitalocean %cloud] `path`/v1/oauth/token [%post ~] :- ~ `quay`['client_secret'^secret (auth-queries (need authc.do.auth.vat))] @@ -214,26 +220,35 @@ $% [%diff %json json] [~ secret] :_ +>.$ :_ ~ - %^ httpreq ost /auth + %^ httpreq ost /auth-gce :^ ~[%google %cloud] `path`/v1/oauth/token [%post ~] - :- ~ `quay`['client_secret'^secret (auth-queries (need authc.gcp.auth.vat))] + :- (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) + `quay`['client_secret'^secret %'access_token'^(need authc.gcp.auth.vat) ~] ::(auth-queries (need authc.gcp.auth.vat))] == :: ++ receive-auth - |= [ost=bone pour-path=path resp=httr] + |= [ost=bone pour-path=cord resp=httr] ^- [(list move) _+>.$] ~| resp =+ body=(rash q:(need r.resp) apex:poja) ~| recieve-auth/resp(r body) + ?+ pour-path !! + %auth-do =+ [ac re]=(need ((ot 'access_token'^so 'refresh_token'^so ~):jo body)) - =: access.toke.vat ac - refresh.toke.vat re + =: access.do.toke.vat ac + refresh.do.toke.vat re == :_ +>.$ :~ (list-droplets ost) (publish ost our.hid [%lin & 'successfully authenticated']~) == + %auth-gce + ::=+ ac=(need ((ot ~):jo + ~& [body resp] + :_ +>.$ + ~ + == :: ++ poke-json |= [[ost=bone you=ship] act=json] @@ -245,18 +260,32 @@ $% [%diff %json json] :- (list-droplets ost) ~ :: - %create + %create-do :_ +>.$ - =+ ^- deets=reqbody + =+ ^- deets=create-req-do %- need %. act => jo %- ot - :~ name/so region/so size/so image/(su dem) :: id key:img object + :~ name/so region/so size/so image/so :: id key:img object ssh/(ar so) backups/(mu bo) 'ipv6'^(mu bo) 'priv_networking'^(mu bo) 'user_data'^(mu so) == - :- (create-droplet ost deets) + :- (create-do ost deets) + ~ + :: + %create-gce + ~& 'chamado' + :_ +>.$ + =+ ^- deets=create-req-gce + %- need + %. act + => jo + %- ot + :~ project/so zone/so name/so %'machine_type'^so + == + ~& 'dois' + :- (create-gce ost deets) ~ :: $? %reboot %'power_cycle' %shutdown %'power_off' %'power_on' @@ -283,7 +312,7 @@ $% [%diff %json json] os /reboot ~[%digitalocean %api] /v2/droplets/[id]/actions [%post `json`(jobe type/s/action ~)] - (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] ~) + (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) *quay == req @@ -294,12 +323,12 @@ $% [%diff %json json] :~ os /list ~[%digitalocean %api] /v2/droplets %get - (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] ~) + (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) == (httpreq lis) :: ++ receive-list - |= [ost=bone pour-path=path resp=httr] + |= [ost=bone plat=cord resp=httr] ^- [(list move) _+>.$] =+ parsed=(rash q:(need r.resp) apex:poja) ~| recieve-list/parsed @@ -326,24 +355,41 @@ $% [%diff %json json] :_ (spam (state-to-json drops.vat)) [ost %wait /refresh buf] :: -++ create-droplet - |= [os=bone reqbody] +++ create-do + |= [os=bone create-req-do] =- ~& - - =+ ^- body=json - %- create-body :* + %- create-do-body :* name region size image ssh backups ipv6 private-networking user-data == %- httpreq :* - os /create + os /create-do ~[%digitalocean %api] /v2/droplets [%post body] %^ mo ['Content-Type' 'application/json' ~] - ['Authorization' (cat 3 'Bearer ' access.toke.vat) ~] + ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~ ~ == -:: +++ create-gce + |= [os=bone create-req-gce] + ~& 'called' + =+ ^- body=json + %- jobe + ~[name/s/name %'machine-type'^s/machine-type] + ~& body + =+ ^= req + %- httpreq + :* `bone`os `path`/create-gce + `(list cord)`~['googleapis' 'www'] `path`/v1/[project]/zones/[zone]/'instances' + ~& 'here' + [%post `json`body] + `math`%^(mo ['Authorization' (cat 3 'Bearer ' access.gcp.toke.vat) ~] ~ ~) + `quay`~ + == + ~& req req + ++ wake |= [[ost=bone him=ship pour-path=path] ~] ?+ -.pour-path !! @@ -355,17 +401,20 @@ $% [%diff %json json] |= [[ost=bone him=ship pour-path=path] resp=httr] ^- [(list move) _+>.$] ?+ -.pour-path !! - %auth - (receive-auth `bone`ost `path`pour-path resp) + %auth-do + (receive-auth ost -.pour-path resp) + :: + %auth-gce + (receive-auth ost -.pour-path resp) :: %list - (receive-list ost pour-path resp) + (receive-list ost -.pour-path resp) :: $? %delete %reboot %'power_cycle' %shutdown %'power_off' %'power_on' %'password_reset' %'enable_ipv6' %'enable_private_networking' %snapshot %upgrade :: add retrieve droplet action - %create + %create-do %create-gce == ~& resp :_ +>.$ ~ diff --git a/base/pub/cloud/src/main.js b/base/pub/cloud/src/main.js index 399503ada..9e4d82867 100644 --- a/base/pub/cloud/src/main.js +++ b/base/pub/cloud/src/main.js @@ -13,7 +13,7 @@ DOControls = React.createClass({ createDroplet: function(){ urb.send({appl: "cloud", data: { - action:'create', + action:'create-do', name:$('#name').val(), region:$('#region').val(), size:$('#size').val(), @@ -59,36 +59,39 @@ DOControls = React.createClass({ GCEControls = React.createClass({ createDroplet: function(){ - urb.send({ - - }) - } + urb.send({ + appl: 'cloud', + data: {action:'create-gce', + project:$('#project').val(), + zone:$('#zone').val(), + name:$('#gname').val(), + machine_type:$('#machine_type').val() + }, + mark: 'json'}) + }, + render: function(){ - ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&state=someinfo&redirect_uri=http://localhost:8443/home/pub/cloud/fab&client_id=720541965785-jr3c6ijo8abonu9qj77qre1itsdra52r.apps.googleusercontent.com" + ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&redirect_uri=http://localhost:8443/home/pub/cloud/fab&client_id=719712694742-6htfj2t9s1j2jid92rc4dfq9psrr9qpo.apps.googleusercontent.com" return( div({}, [ div({}, [ a({href:ghref},"Get Google Authcode"), - b({onClick:this.props.handleClick('gce','#gappsecret')}, "Send Google Authcode") + b({onClick:this.props.handleClick('gce')}, "Send Google Authcode") ]), div({}, [ input({id:"gappsecret"}, - b({onClick:this.props.sendSecret('gce')}, "Send Google Secret")) + b({onClick:this.props.sendSecret('gce','#gappsecret')}, "Send Google Secret")) ]), div({}, [ b({onClick:this.createDroplet}, "Create Droplet"), input({id:"project",placeholder:"project"}), input({id:"zone",placeholder:"zone"}), - input({id:"name",placeholder:"Name of droplet"}), - input({id:"size",placeholder:"Size (str ending in mb"}), - input({id:"image",placeholder:"Image"}), - input({id:"ssh",placeholder:"ssh keys (optional)"}), - input({id:"backups",placeholder:"backups (optional)"}), - input({id:"ipv6",placeholder:"ipv6 (boolean, optional)"}), - input({id:"user-data",placeholder:" user-data string (optional)"}), - input({id:"priv-networking",placeholder:"Private Networking (boolean, optional)"}) + input({id:"gname",placeholder:"Name of droplet"}), + input({id:"machine_type",placeholder:"Machine Type"}), + //input({id:"image",placeholder:"Image"}), ]) - )} + ])) + } }) Droplet = React.createClass({ From 58e4cf42c8ae1bdc6fd2d91bf0dec11bfd7f4fd8 Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Sat, 23 May 2015 14:21:47 -0700 Subject: [PATCH 20/34] question 2 --- base/ape/cloud/core.hook | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base/ape/cloud/core.hook b/base/ape/cloud/core.hook index bb9651ce3..6d5d20c74 100644 --- a/base/ape/cloud/core.hook +++ b/base/ape/cloud/core.hook @@ -385,7 +385,9 @@ $% [%diff %json json] `(list cord)`~['googleapis' 'www'] `path`/v1/[project]/zones/[zone]/'instances' ~& 'here' [%post `json`body] + ~& 'here' `math`%^(mo ['Authorization' (cat 3 'Bearer ' access.gcp.toke.vat) ~] ~ ~) + ~& 'no' `quay`~ == ~& req req From ed2ba93eb24dd9a9d86d7b4c319407e3cc3c5fe8 Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Sat, 23 May 2015 14:40:20 -0700 Subject: [PATCH 21/34] outbound gce create request --- base/ape/cloud/core.hook | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/base/ape/cloud/core.hook b/base/ape/cloud/core.hook index 6d5d20c74..7528d5e6a 100644 --- a/base/ape/cloud/core.hook +++ b/base/ape/cloud/core.hook @@ -386,8 +386,9 @@ $% [%diff %json json] ~& 'here' [%post `json`body] ~& 'here' - `math`%^(mo ['Authorization' (cat 3 'Bearer ' access.gcp.toke.vat) ~] ~ ~) - ~& 'no' + %^ mo ['Content-Type' 'application/json' ~] + ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] + ~ `quay`~ == ~& req req From 9c96a3da76a23dd630e8f487f01b23d817c06ff6 Mon Sep 17 00:00:00 2001 From: ault011 Date: Mon, 25 May 2015 11:32:14 -0700 Subject: [PATCH 22/34] delete coin --- base/ape/coin/core.hook | 302 ---------------------------------------- 1 file changed, 302 deletions(-) delete mode 100644 base/ape/coin/core.hook diff --git a/base/ape/coin/core.hook b/base/ape/coin/core.hook deleted file mode 100644 index 3f55b7754..000000000 --- a/base/ape/coin/core.hook +++ /dev/null @@ -1,302 +0,0 @@ -:: -:: -:::: - :: -/? 314 -/- *talk -/+ talk, sole -!: -:::: sivtyv-barnel - :: be sure to have oauth2-code mark -|% -++ redirect-uri (crip (urle "http://localhost:8444/gen/main/pub/fab/coin")) -++ client-id '2e688dde3f7655e7c261313a286e69e7c61ec5502459408b7818c4c74c77bf45' -++ auth-url "https://www.coinbase.com/oauth/authorize?". - "response_type=code". - "&client_id=2e688dde3f7655e7c261313a286e69e7c61ec5502459408b7818c4c74c77bf45". - "&redirect_uri={(urle "http://localhost:8443/gen/main/pub/fab/coin")}". - "&scope=user+balance+buy+sell+send+transactions". - "&{(urle "meta[send_limit_amount]")}=1&{(urle "meta[send_limit_curency]")}=BTC&{(urle "meta[send_limit_period]")}=day" - -++ axle - $: - key=[atok=@t secr=@t refr=@t] - ::outbox=[p=@u q=(map ,@u hiss)] - account-info=(unit ,[bitbal=@t usdval=@t lasttrans=@t]) - == -++ move ,[bone (mold note gift)] -++ note - $% $: %e - $% [%them p=(unit hiss)] - [%nice ~] - == == - [%g %mess [ship path] ship cage] - == -++ coin-args :: passed as hoon type from shell - $% - [%buy qty=@u currency=@tas ~] - [%view-balance ~] - [%refresh-manually ~] - [%get-updates ~] - [%sell qty=@u currency=@tas ~] - [%send to=@t qty=@u currency=@tas ~] - == -++ gift - $% [%nice ~] - [%rush %json json] - == -++ sign - $% $: %e - $% [%thou p=httr] - [%nice ~] - == == - $: %g - $% [%mean p=ares] - [%nice ~] - == == == -:: --- -:: -!: -|_ [hid=hide vat=axle] -++ peer ,_`. -++ poke-keys::oauth2-code - |= [ost=bone his=ship arg=(list cord)] - =: secr.key.vat -.arg - atok.key.vat &2.arg - == - ~& key.vat - =+ ^- thot=thought - :+ `serial``@uv`eny.hid - `audience`[[`partner`[%& our.hid %court] `(pair envelope delivery)`[`envelope`[& ~] `delivery`%pending]] ~ ~] - `statement`[lat.hid ~ [%lin & 'keys stored']] -:: =+ prl=`purl`(need (epur (crip auth-url))) -:: =+ ^- url=thought -:: :+ `serial``@uv`eny.hid -:: `audience`[[`partner`[%& our.hid %court] `(pair envelope delivery)`[`envelope`[& ~] `delivery`%pending]] ~ ~] -:: `statement`[lat.hid ~ [%url prl]] - =+ cag=`cage`[%talk-command !>([%publish `(list thought)`[thot ~]])] - :_ +>.$ - :- [ost %pass /test %g %mess [our.hid /talk] his cag] - (get-token ost) -++ prep ,_`. -++ hisser - |= [ost=bone move-data=wire endpoint=path reqtype=$|(%get [%post p=json]) args=quay] - ^- [(list move) _+>.$] - =+ ^= prl - :+ hrt=[security=%.y port=~ host=[%.y path=/com/coinbase]] - prk=[extension=~ path=endpoint] - quy=args - =+ ^- hiz=hiss - :- prl - ?@ reqtype - `moth`[reqtype ~ ~] - `moth`[-.reqtype ~ `(tact (pojo p.reqtype))] - :- :_ ~ - :^ ost %pass - =- ~& hiss/- - - [(scot %ud p.outbox.vat) move-data] - :^ %e %them ~ - hiz - +>.$ - :: p.outbox.vat +(p.outbox.vat) - ::q.outbox.vat [(~(put by q.outbox.vat) p.outbox.vat hiz)] -++ spam - |= newtranz=(list ,@t) - ^- (list move) - %+ turn (~(tap by sup.hid)) :: listify subscribers - |= [ost=bone *] - ^- move - :^ ost %give %rush - :+ %json %a - %+ turn newtranz - |=(a=cord [%s a]) - -++ get-token - |= os=bone - ^+ [*(list move) +>] - =+ ^= queries - :~ ['grant_type' 'authorization_code'] - ['code' atok.key.vat] - ['redirect_uri' redirect-uri] - ['client_id' client-id] - ['client_secret' secr.key.vat] - == - =^ hiz +>.$ :: =+ hiz as head of hisser, change +>.$ to tail of hisser to reflect outbox changes - (hisser os /code /oauth/token [%post ~] queries) - [[[ost %give %nice ~] hiz] +>.$] -:: -++ poke-coin-args - |= [ost=bone you=ship arg=coin-args] - ^+ [*(list move) +>] - :: send to parent app, as :coin args spawns an ephemeral app. ask me if this confuses you. - ?. =(/coin imp.hid) ::?= makes imp.hid too specific a type for +>.$ - =+ cag=`cage`[%coin-args !>(arg)] - ~& instance/arg - :_(+>.$ [ost %pass /foreign %g %mess [our.hid /coin] you cag]~) ::sending to parent app - ?- -.arg - %buy - =+ quy=['access_token' atok.key.vat]~ - =+ jon=(jobe qty/(jone qty.arg) currency/s/(cuss (trip currency.arg)) ~) - [(hisser ost /bought /api/v1/buys [%post p=jon] quy)] - %sell - =+ quy=['access_token' atok.key.vat]~ - =+ jon=(jobe qty/(jone qty.arg) currency/s/(cuss (trip currency.arg)) ~) - [(hisser ost /sold /api/v1/sells [%post p=jon] quy)] - %send - =+ quy=['access_token' atok.key.vat]~ - =+ jon=(joba transaction/(jobe to/[%s to.arg] 'amount_currency_iso'^[%s (cuss (trip currency.arg))] 'amount_string'^(jone qty.arg) ~)) - =+ quy=['access_token' atok.key.vat]~ - ~& sending/(crip (pojo jon)) - (hisser ost /view /api/v1/transactions/'send_money' [%post jon] quy) - %view-balance - =+ quy=['access_token' atok.key.vat]~ - (hisser ost /view /api/v1/accounts %get quy) - %refresh-manually - ~& %trying-to-r-m - =+ ^= queries - :~ ['grant_type' 'refresh_token'] - ['redirect_uri' redirect-uri] - ['client_id' client-id] - ['client_secret' secr.key.vat] - ['refresh_token' refr.key.vat] - == - (hisser ost /refresh /oauth/token [%post ~] queries) :: refresh - %get-updates - (auto-updates ost) - == - -:: -++ return |=(a=(list move) [a +>.$]) -++ parse-error :: parses the various error messages we receive - |= [ost=bone pax=path jon=json] - ^- (unit ,[(list move) _+>.$]) - =+ misc-error=%.(jon =>(jo (ot errors/(ar so) ~))) - ?^ misc-error - %- some :: HAVE TO SOME BECAUSE RESULT IS UNIT - ~& miscellaneous-error/u.misc-error - (return) :: - =+ token-error=%.(jon =>(jo (ot 'invalid_grant'^so 'error_description'^so ~))) - ?^ token-error - %- some - ~& token-err/jon - ?: ?=([%refresh ~] pax) :: if refresh failure, stop - ~& coin/oauth/%refresh-loop - [~ +>.$] - =+ ^= queries - :~ ['grant_type' 'refresh_token'] - ['redirect_uri' redirect-uri] - ['client_id' client-id] - ['client_secret' secr.key.vat] - ['refresh_token' refr.key.vat] - == - [(hisser ost /refresh /oauth/token [%post ~] queries)] :: refresh - ~ :: no error parsed -:: -++ peer :: call when someone subscribes to you - |= [ost=bone *] :: need ost to send confirmation back - :_ +>.$ - :- [ost %give %nice ~] - ?~ account-info.vat ~ - [ost %give %rush %json [%a [%s lasttrans.u.account-info.vat]~]]~ :: have to send arr of str - -++ pour - |= [ost=bone pax=path sih=sign] - ^+ [*(list move) +>] - ~& pour-pax/pax - ?- &2.sih - %nice :: receive positive acknowledgement - ~& %nice - [[ost %give %nice ~]~ +>.$] - %mean :: receive negative acknowledgement - ~& mean/p.sih - [~ +>.$] - %thou :: receive response - ?: =(401 p.p.sih) :: handle 401, then try to reauth using %refresh-token - =+ ^= queries - :~ ['grant_type' 'refresh_token'] - ['redirect_uri' redirect-uri] - ['client_id' client-id] - ['client_secret' secr.key.vat] - ['refresh_token' refr.key.vat] - == - [(hisser ost /refresh /oauth/token [%post ~] queries)] :: send refresh token - ?: =(5 (div p.p.sih 100)) :: catch http 5xx - ~& [%server-error pax=pax] :: print error - :: XX resend - [~ +>.$] :: return state and no moves - =+ ~| parse-error/[pax p.sih] :: parse error - respbody=(rash q:(need r.p.sih) apex:poja) :: rash unwraps unit; octs is [p q] - =+ error=(parse-error ost pax respbody) - ?^ error - u.error :: If parse-error succeeds, return move, context - ?~ pax [[ost %give %nice ~]~ +>.$] :: ~|(%nil-path !!) - ::=. q.outbox.vat ~| pax (~(del by q.outbox.vat) (slav %ud i.pax)) - => .(pax t.pax) - ?+ pax ~|(unhandled-path/pax !!) :: switch on path of your initial request - [%bought ~] - ~& successful-buy-request/respbody - `+>.$ - :: - [%sold ~] - ~& successful-sell-request/respbody - `+>.$ - [%view ~] - ~& %viewed - ~& respbody - ~& %. respbody - => jo - =+ bal=`$+(json (unit ,[num=@t in=@t]))`(ot amount/so currency/so ~) - (ot accounts/(ar (ot name/so balance/bal 'native_balance'^bal ~)) ~) - :_(+>.$ ~) - :: - [?(%code %refresh) ~] - |- - =+ state=`[atoken=@t secr=@t]`(need ((ot 'access_token'^so 'refresh_token'^so ~):jo respbody)) - =: atok.key.vat atoken.state - secr.key.vat secr.state - == - ~& [%authorized i.pax] - [[ost %give %nice ~]~ +>.^$] :: ^$ because $ contains other =+'s that would change type of state - [%update ~] - =+ ^= updatez - ^+ =< *(unit .) :: - $: [@ btc=@t] - [@ usd=@t] - transhistory=(list ,id=@t) - == - ~& respbody - %. respbody - => jo - %- ot :~ - %balance^(ot currency/so amount/so ~) - 'native_balance'^(ot currency/so amount/so ~) - 'account_changes'^(ar (ot id/so ~)) - == - ~& bal/updatez - =+ old-lasttrans=`(unit ,@t)`?~(account-info.vat ~ `lasttrans.u.account-info.vat):: for recursing down to last trans - =. account-info.vat :: doesn't change type, although it does assert that the new type fits - ?~ updatez - ~& update-unparsable/respbody - account-info.vat - `[btc.u.updatez usd.u.updatez -.transhistory.u.updatez] :: end =. ; if bal is empty do nothing by returning old state - :: - =+ ^= newtrans ^- (list ,@t) :: LIST NEW TRANSACTIONS - ?~ updatez ~ :: allow us to address updatez later - =+ b=u.updatez - ?~ old-lasttrans transhistory.b - |-(?~(transhistory.b ~ ?:(=(i.transhistory.b u.old-lasttrans) ~ [i.transhistory.b $(transhistory.b t.transhistory.b)]))) - ~& :- %new-transactions-received newtrans - :_ +>.$ - ?~ newtrans - ~ - (spam newtrans) - == - == -++ auto-updates - |= ost=bone - =+ ^= query - ['access_token' atok.key.vat]~ - (hisser ost /update /api/v1/'account_changes' %get query) --- - From 593aa0970138f512a2bab692dc177ecb2a37a337 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Mon, 25 May 2015 18:17:59 -0700 Subject: [PATCH 23/34] wip --- base/arvo/clay.hoon | 145 +++++++++++++++---------------- base/arvo/eyre.hoon | 4 +- base/arvo/ford.hoon | 205 ++++++++++++++++++++++++-------------------- base/arvo/gall.hoon | 19 ++-- base/arvo/hoon.hoon | 1 - base/arvo/zuse.hoon | 11 ++- 6 files changed, 199 insertions(+), 186 deletions(-) diff --git a/base/arvo/clay.hoon b/base/arvo/clay.hoon index 83c19e1ac..3fe828268 100644 --- a/base/arvo/clay.hoon +++ b/base/arvo/clay.hoon @@ -72,7 +72,7 @@ [%writ p=riot] :: == == :: $: %f :: - $% [%made p=@uvH q=(each gage (list tank))] :: + $% [%made p=@uvH q=gage] :: == == :: $: %t :: $% [%wake ~] :: timer activate @@ -175,28 +175,42 @@ :: ~& [%aver-mun nao [%from syd lim q.mun]] ?~(nao ~ (read-at-aeon:ze u.nao mun)) :: - ++ made-to-tage - |= res=(each gage tang) - ^- tage - ?: ?=(%| -.res) - ~| %ford-fail - |- - ?~ p.res !! - ~> %mean.|.(i.p.res) :: interpolate ford fail into stack trace - $(p.res t.p.res) - ?@ p.p.res - ~|(%bad-marc !!) - p.res + ++ ford-fail + |= tan=tang + ~| %ford-fail + |- + ?~ tan !! + ~> %mean.|.(i.tan) :: interpolate into stack trace + $(tan t.tan) :: - ++ tage-to-cages - |= tab=tage - ^- (list (pair cage cage)) - ?~ p.tab - ~ - :_ $(p.tab t.p.tab, q.tab (slot 3 q.tab)) - ~| %strange-gage - :- [?^(p.i.p.tab !! p.i.p.tab) (slot 4 q.tab)] - [?^(q.i.p.tab !! q.i.p.tab) (slot 5 q.tab)] + ++ unwrap-tang + |* res=(each ,* tang) + ?: ?=(%& -.res) + p.res + (ford-fail p.res) + :: + ++ gage-to-cages + |= gag=gage ^- (list (pair cage cage)) + (unwrap-tang (gage-to-tage gag)) + :: + ++ gage-to-tage + |= gag=gage + ^- (each (list (pair cage cage)) tang) + ?. ?=(%tabl -.gag) + (mule |.(`~`(ford-fail >%strange-gage< ~))) + =< ?+(. [%& .] [@ *] .) + |- ^- ?((list ,[cage cage]) (each ,~ tang)) + ?~ p.gag ~ + =* hed i.p.gag + ?- -.p.hed + %tabl (mule |.(`~`(ford-fail >%strange-gage< ~))) + %| (mule |.(`~`(ford-fail p.p.hed))) + %& ?- -.q.hed + %tabl (mule |.(`~`(ford-fail >%strange-gage< ~))) + %| (mule |.(`~`(ford-fail p.q.hed))) + %& =+ $(p.gag t.p.gag) + ?+(- [[p.p p.q]:hed -] [@ *] -) + == == :: ++ balk :: read and send |= [hen=duct cay=(unit (each cage lobe)) mun=mood] @@ -538,7 +552,7 @@ (checkout-ankh(lat.ran lat.ran.+.hat) u.-.hat) :: ++ take-inserting - |= [wen=@da res=(each gage tang)] + |= [wen=@da res=gage] ^+ +> ?~ dok ~& %clay-take-inserting-unexpected-made +>.$ @@ -551,14 +565,14 @@ (apply-edit wen) +>.$ ^- (list (pair path cage)) - %+ turn (tage-to-cages (made-to-tage res)) + %+ turn (gage-to-cages res) |= [pax=cage cay=cage] ?. ?=(%path p.pax) ~|(%clay-take-inserting-strange-path-mark !!) [((hard path) q.q.pax) cay] :: ++ take-diffing - |= [wen=@da res=(each gage tang)] + |= [wen=@da res=gage] ^+ +> ?~ dok ~& %clay-take-diffing-unexpected-made +>.$ @@ -571,7 +585,7 @@ (apply-edit wen) +>.$ ^- (list (trel path lobe cage)) - %+ turn (tage-to-cages (made-to-tage res)) + %+ turn (gage-to-cages res) |= [pax=cage cay=cage] ^- (pair path (pair lobe cage)) ?. ?=(%path p.pax) @@ -580,14 +594,14 @@ [paf (page-to-lobe:ze [p q.q]:cay) (~(got by dig.u.dok) paf)] :: ++ take-castify - |= [wen=@da res=(each gage tang)] + |= [wen=@da res=gage] ^+ +> ?~ dok ~& %clay-take-castifying-unexpected-made +>.$ ?. =(~ muh.u.dok) ~& %clay-take-castifying-redundant-made +>.$ =+ ^- cat=(list (pair path cage)) - %+ turn (tage-to-cages (made-to-tage res)) + %+ turn (gage-to-cages res) |= [pax=cage cay=cage] ?. ?=(%path p.pax) ~|(%castify-bad-path-mark !!) @@ -610,7 +624,7 @@ == :: ++ take-mutating - |= [wen=@da res=(each gage tang)] + |= [wen=@da res=gage] ^+ +> ?~ dok ~& %clay-take-mutating-unexpected-made +>.$ @@ -623,7 +637,7 @@ (apply-edit wen) +>.$ ^- (list (trel path lobe cage)) - %+ murn (tage-to-cages (made-to-tage res)) + %+ murn (gage-to-cages res) |= [pax=cage cay=cage] ^- (unit (pair path (pair lobe cage))) ?. ?=(%path p.pax) @@ -634,7 +648,7 @@ `[paf (~(got by muh.u.dok) paf) cay] :: ++ take-patch - |= res=(each gage tang) + |= res=gage ^+ +> :: ~& %taking-patch ?: ?=(%| -.res) @@ -675,29 +689,15 @@ (echo now %& *cart sim) == ?~ dok ~& %no-dok +>.$ - =+ cay=p.res - ?@ p.cay ~| %patch-bad-marc !! - :: ~& %canning - =+ ^= can - |- ^- (list ,[path cage]) - ?~ p.p.cay - ~ - :_ %_($ cay [[%tabl t.p.p.cay] (slot 3 q.cay)]) - ?. ?=(%path p.i.p.p.cay) - ~| %patch-strange-marc-a - !! - ?. ?=(@ q.i.p.p.cay) - ~| %patch-strange-marc-b - !! - =+ coy=(slot 2 q.cay) - ?@ q.coy - ~| %patch-strange-coy - !! - :- ((hard path) -.q.coy) - [q.i.p.p.cay (slot 3 coy)] + =+ ^- cat=(list (pair path cage)) + %+ turn (gage-to-cages res) + |= [pax=cage cay=cage] + ?. ?=(%path p.pax) + ~|(%patch-bad-path-mark !!) + [((hard path) q.q.pax) cay] :: ~& %canned :: ~& %checking-out - =. ank.dom (checkout-ankh:ze (mo can)) + =. ank.dom (checkout-ankh:ze (mo cat)) =. +>.$ =>(wake ?>(?=(^ dok) .)) :: ~& %checked-out ?~ hez +>.$(dok ~) @@ -734,7 +734,7 @@ == :: ++ take-ergo - |= res=(each gage tang) + |= res=gage ^+ +> ?: ?=(%| -.res) %_ +>.$ @@ -743,30 +743,19 @@ == ?~ hez ~|(%no-sync-duct !!) ?. syn ~|(%sync-off !!) - =+ cay=p.res - ?@ p.cay ~| %patch-bad-marc !! %= +>.$ reg :_ reg :* u.hez %ergo who syd let.dom - |- ^- (list ,[path (unit mime)]) - ?~ p.p.cay + ^- (list ,[path (unit mime)]) + %+ turn (gage-to-cages res) + |= [pax=cage mim=cage] + ?. ?=(%path p.pax) + ~|(%ergo-bad-path-mark !!) + :- ((hard path) q.q.pax) + ?. ?=(%mime p.mim) ~ - :_ %_($ cay [[%tabl t.p.p.cay] (slot 3 q.cay)]) - ?. ?=(%path p.i.p.p.cay) - ~| %ergo-strange-marc-a - !! - ?. ?=(@ q.i.p.p.cay) - ~| %ergo-strange-marc-b - !! - =+ coy=(slot 2 q.cay) - ?@ q.coy - ~| %ergo-strange-coy - !! - :- ((hard path) -.q.coy) - ?. ?=(%mime q.i.p.p.cay) - ~ - `((hard mime) q:(slot 3 coy)) + `((hard mime) q:(slot 3 q.mim)) == == :: @@ -1898,7 +1887,7 @@ (diff-bas %bob bob.dat bob ali.dat) :: ++ diffed-bob - |= res=(each gage tang) + |= res=(each tage tang) ^+ +> ?: ?=(%| -.res) (error:he %diff-bob-bad-made leaf/"merge diff bob failed" p.res) @@ -1977,7 +1966,7 @@ == :: ++ merged - |= res=(each gage tang) + |= res=(each tage tang) ?: ?=(%| -.res) (error:he %merge-bad-made leaf/"merging failed" p.res) =+ cay=p.res @@ -2034,7 +2023,7 @@ :: ++ built - |= res=(each gage tang) + |= res=(each tage tang) ^+ +> ?: ?=(%| -.res) (error:he %build-bad-made leaf/"delta building failed" p.res) @@ -2170,7 +2159,7 @@ == :: ++ checked-out - |= res=(each gage tang) + |= res=(each tage tang) ^+ +> ?: ?=(%| -.res) (error:he %checkout-bad-made leaf/"merge checkout failed" p.res) @@ -2230,8 +2219,8 @@ == :: ++ ergoed - |= res=(each gage tang) - ^+ +> + |= res=(each tage tang) + ^+ + ?: ?=(%| -.res) (error:he %ergo-bad-made leaf/"merge ergo failed" p.res) =+ cay=p.res diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index facb1b7a9..9790fd224 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -39,7 +39,7 @@ $% [%thou p=httr] :: response for proxy == == :: $: %f :: by %ford - $% [%made p=@uvH q=(each gage tang)] :: + $% [%made p=@uvH q=gage] :: [%news ~] :: == == :: $: %t :: by %time @@ -577,7 +577,7 @@ == :: %made - ?> ?=(?([%| *] [%& @ *]) q.sih) + ?< ?=(%tabl -.q.sih) =. our (need hov) :: XX |- ^+ ..axon ?- tee diff --git a/base/arvo/ford.hoon b/base/arvo/ford.hoon index 26a197661..1267a56ea 100644 --- a/base/arvo/ford.hoon +++ b/base/arvo/ford.hoon @@ -55,7 +55,7 @@ dep=(set beam) :: dependencies == :: ++ calx :: concrete cache line - $% [%hood p=calm q=(pair beam gage) r=hood] :: compile + $% [%hood p=calm q=(pair beam cage) r=hood] :: compile [%bake p=calm q=(trel mark beam heel) r=(unit vase)]:: load [%slit p=calm q=[p=type q=type] r=type] :: slam type [%slim p=calm q=[p=type q=twig] r=(pair type nock)]:: mint @@ -105,8 +105,21 @@ ^- cafe :: [(grom p.a p.b) (grum q.a q.b)] :: :: :: -++ faun |=([a=cafe b=vase] (fine a `gage`[%noun b])) :: vase to cage -++ feel |=([a=cafe b=gage] (fine a q.b)) :: cage to vase +++ faun |=([a=cafe b=vase] (fine a [%& %noun b])) :: vase to gage +++ feel |=([a=cafe b=cage] (fine a q.b)) :: cage to vase +++ furl :: unwrap gage to cage + |= [a=cafe b=gage] ^- (bolt cage) + ?- -.b + %tabl (flaw a >%bad-marc< ~) + %| (flaw a p.b) + %& (fine a p.b) + == +:: +++ fret :: lift error + |= a=(bolt gage) ^- (bolt gage) + ?. ?=(%2 -.q.a) a + [p.a [%0 p.q.a `gage`[%| q.q.a]]] +:: ++ fest :: bolt to success |= a=beam :: |*([b=cafe c=*] (flag a (fine b [~ u=c]))) :: @@ -413,6 +426,23 @@ == fun :: + ++ tabl-run :: apply to all elems + |= fun=(burg cage gage) + |= [cof=cafe gag=gage] + ^- (bolt gage) + ?. ?=(%tabl -.gag) + (cope (furl cof gag) fun) + %+ cope + |- ^- (bolt (list (pair gage gage))) + ?~ p.gag (fine cof ~) + %+ cope (fret ^$(gag q.i.p.gag)) + |= [cof=cafe val=gage] + %+ cope ^$(p.gag t.p.gag) + |= [cof=cafe rex=(list (pair gage gage))] + (fine cof [[p.i.p.gag val] rex]) + |= [cof=cafe rex=(list (pair gage gage))] + (fine cof %tabl rex) + :: ++ dash :: process cache |= cof=cafe ^+ +> @@ -424,17 +454,15 @@ %. [cof kas kos] ;~ cope ;~ coax - |=([cof=cafe p=silk q=silk] (make cof p)) - |=([cof=cafe p=silk q=silk] (make cof q)) + |=([cof=cafe p=silk q=silk] (cope (make cof p) furl)) + |=([cof=cafe p=silk q=silk] (cope (make cof q) furl)) == - |= [cof=cafe cay=gage coy=gage] - ?. &(?=(@ p.cay) ?=(@ p.coy)) - (flaw cof leaf/"bad diff marc" ~) + |= [cof=cafe cay=cage coy=cage] ?. =(p.cay p.coy) %+ flaw cof :_ ~ leaf/"diff on data of different marks: {(trip p.cay)} {(trip p.coy)}" ?: =(q.q.cay q.q.coy) - (fine cof %null [%atom %n] ~) + (fine cof %& %null [%atom %n] ~) %+ cope (fang cof p.cay) |= [cof=cafe pro=vase] ?. (slab %grad p.pro) @@ -461,7 +489,7 @@ =+ for=((soft ,@tas) q:(slap gar [%cnzy %form])) ?~ for (flaw cof leaf/"bad ++form:grad" ~) - (fine cof u.for dif) + (fine cof %& u.for dif) == :: ++ daze :: remember depends @@ -480,7 +508,7 @@ =. ..exec (dash p.bot) ?- -.q.bot %0 =^ dep deh.bay (daze p.q.bot) - amok:(expo [%made dep %& q.q.bot]) + amok:(expo [%made dep q.q.bot]) %2 =^ dep deh.bay (daze p.q.bot) amok:(expo [%made dep %| q.q.bot]) %1 =+ zuk=(~(tap by p.q.bot) ~) @@ -499,11 +527,11 @@ |= [cof=cafe for=mark bem=beam] ^- (bolt hood) %+ cool |.(leaf/"ford: fade {<[(tope bem)]>}") - %+ cope (make cof [%bake for bem ~]) - |= [cof=cafe cay=gage] + %+ cope (cope (make cof [%bake for bem ~]) furl) + |= [cof=cafe cay=cage] %+ (clef %hood) (fine cof bem(r [%ud 0]) cay) - ^- (burg (pair beam gage) hood) - |= [cof=cafe bum=beam cay=gage] + ^- (burg (pair beam cage) hood) + |= [cof=cafe bum=beam cay=cage] :: ~& fade/clef-miss/bem =+ rul=(fair bum) ?. ?=(@ q.q.cay) @@ -678,12 +706,10 @@ %. [cof kas kos] ;~ cope ;~ coax - |=([cof=cafe p=silk q=silk] (make cof p)) - |=([cof=cafe p=silk q=silk] (make cof q)) + |=([cof=cafe p=silk q=silk] (cope (make cof p) furl)) + |=([cof=cafe p=silk q=silk] (cope (make cof q) furl)) == - |= [cof=cafe cay=gage coy=gage] - ?. &(?=(@ p.cay) ?=(@ p.coy)) - (flaw cof leaf/"bad join marc: {} {}" ~) + |= [cof=cafe cay=cage coy=cage] %+ cope (fang cof for) |= [cof=cafe pro=vase] ?. (slab %grad p.pro) @@ -704,7 +730,7 @@ leaf/"join on data of bad marks: {(trip p.cay)} {(trip p.coy)}" leaf/"expected mark {(trip u.fom)}" ?: =(q.q.cay q.q.coy) - (fine cof cay) + (fine cof %& cay) ?. (slab %join p.gar) (flaw cof leaf/"no ++join:grad" ~) %+ cope @@ -713,8 +739,8 @@ (slop q.cay q.coy) |= [cof=cafe dif=vase] ?@ q.dif - (fine cof %null dif) - (fine cof u.fom (slot 3 dif)) + (fine cof %& %null dif) + (fine cof %& u.fom (slot 3 dif)) == :: ++ mash @@ -723,12 +749,10 @@ %. [cof r.mas r.mos] ;~ cope ;~ coax - |=([cof=cafe p=silk q=silk] (make cof p)) - |=([cof=cafe p=silk q=silk] (make cof q)) + |=([cof=cafe p=silk q=silk] (cope (make cof p) furl)) + |=([cof=cafe p=silk q=silk] (cope (make cof q) furl)) == - |= [cof=cafe cay=gage coy=gage] - ?. &(?=(@ p.cay) ?=(@ p.coy)) - (flaw cof leaf/"bad mash marc: {} {}" ~) + |= [cof=cafe cay=cage coy=cage] %+ cope (fang cof for) |= [cof=cafe pro=vase] ?. (slab %grad p.pro) @@ -750,9 +774,9 @@ leaf/"mash on data of bad marks: {(trip p.cay)} {(trip p.coy)}" leaf/"expected mark {(trip u.fom)}" ?: =(q.q.cay q.q.coy) - (fine cof cay) + (fine cof %& cay) ?. (slab %mash p.gar) - (fine cof %null [%atom %n] ~) + (fine cof %& %null [%atom %n] ~) %+ cope %^ maul cof (slap (slap pro [%cnzy %grad]) [%cnzy %mash]) @@ -763,7 +787,7 @@ q.coy == |= [cof=cafe dif=vase] - (fine cof u.fom dif) + (fine cof %& u.fom dif) == :: ++ kale :: mutate @@ -772,17 +796,18 @@ %+ cope |- ^- (bolt (list (pair wing vase))) ?~ muy (flue cof) - %+ cope (make cof q.i.muy) - |= [cof=cafe cay=gage] + %+ cope (cope (make cof q.i.muy) furl) + |= [cof=cafe cay=cage] %+ cope ^$(muy t.muy) |= [cof=cafe rex=(list (pair wing vase))] (fine cof [[p.i.muy q.cay] rex]) |= [cof=cafe yom=(list (pair wing vase))] %+ cope (make cof kas) - |= [cof=cafe cay=gage] + %- tabl-run + |= [cof=cafe cay=cage] %+ cope (keel cof q.cay yom) |= [cof=cafe vax=vase] - (fine cof p.cay vax) + (fine cof %& p.cay vax) :: ++ keel :: apply mutations |= [cof=cafe suh=vase yom=(list (pair wing vase))] @@ -872,13 +897,13 @@ :: ++ lear :: load vase |= [cof=cafe bem=beam] - ^- (bolt cage) + ^- (bolt gage) =+ von=(save ~ %cx bem) ?~ von [p=*cafe q=[%1 [[%x bem ~] ~ ~]]] ?~ u.von (flaw cof leaf/"lear: file unavailable" (smyt (tope bem)) ~) - (fine cof u.u.von) + (fine cof %& u.u.von) :: ++ lend :: load arch |= [cof=cafe bem=beam] @@ -929,8 +954,8 @@ %+ cope (lion cof for haz) |= [cof=cafe wuy=(list ,@tas)] ?~ wuy (flue cof) - %+ cope (make cof %bake i.wuy bem arg) - |= [cof=cafe hoc=gage] + %+ cope (cope (make cof %bake i.wuy bem arg) furl) + |= [cof=cafe hoc=cage] %+ cope (lope cof i.wuy t.wuy q.hoc) |= [cof=cafe vax=vase] ((fest bem) cof vax) @@ -1040,12 +1065,12 @@ %. [cof p.kas q.kas] ;~ cope ;~ coax - |=([cof=cafe p=silk q=silk] ^$(cof cof, kas p.kas)) - |=([cof=cafe p=silk q=silk] ^$(cof cof, kas q.kas)) - == + |=([cof=cafe p=silk q=silk] (cope ^$(cof cof, kas p.kas) furl)) + |=([cof=cafe p=silk q=silk] (cope ^$(cof cof, kas q.kas) furl)) + == :: XX merge %tabl :: - |= [cof=cafe bor=gage heg=gage] ^- (bolt gage) - [p=cof q=[%0 ~ [%$ (slop q.bor q.heg)]]] + |= [cof=cafe bor=cage heg=cage] ^- (bolt gage) + (faun cof (slop q.bor q.heg)) == :: %bake @@ -1055,7 +1080,7 @@ |= [cof=cafe vux=(unit vase)] ?~ vux (flaw cof leaf/"bake failed" (smyt (tope q.kas)) ~) - (fine cof [p.kas u.vux]) + (fine cof [%& p.kas u.vux]) :: %boil ^- (bolt gage) @@ -1064,49 +1089,48 @@ |= [cof=cafe bem=beam] %+ cope (lime cof p.kas bem r.kas) |= [cof=cafe vax=vase] - (fine cof `gage`[p.kas vax]) + (fine cof `gage`[%& p.kas vax]) :: %bunt %+ cool |.(leaf/"ford: bunt {}") ?: ?=(?(%hoon %hook) p.kas) - (fine cof p.kas [%atom %t] '') + (fine cof %& p.kas [%atom %t] '') %+ cope (fang cof p.kas) |= [cof=cafe tux=vase] - (fine cof [p.kas (slot 6 tux)]) + (fine cof [%& p.kas (slot 6 tux)]) :: %call :: %+ cool |.(leaf/"ford: call {<`@p`(mug kas)>}") %. [cof p.kas q.kas] ;~ cope ;~ coax - |=([cof=cafe p=silk q=silk] ^$(cof cof, kas p)) + |=([cof=cafe p=silk q=silk] (cope ^$(cof cof, kas p) furl)) |=([cof=cafe p=silk q=silk] ^$(cof cof, kas q)) == :: - |= [cof=cafe gat=gage sam=gage] - (maul cof q.gat q.sam) - :: - |= [cof=cafe vax=vase] - (fine cof %noun vax) + |= [cof=cafe gat=cage sam=gage] + %. [cof sam] + %- tabl-run + |= [cof=cafe sam=cage] + (cope (maul cof q.gat q.sam) faun) == :: %cast %+ cool |.(leaf/"ford: cast {}") %+ cope $(kas q.kas) - |= [cof=cafe cay=gage] + %- tabl-run + |= [cof=cafe cay=cage] ^- (bolt gage) %+ cool |.(leaf/"ford: casting {} to {}") - ?. ?=(@ p.cay) - (flaw cof leaf/"bad cast marc" ~) %+ cope (link cof p.kas p.cay q.cay) |= [cof=cafe vax=vase] - (fine cof [p.kas vax]) + (fine cof [%& p.kas vax]) :: %diff %+ cool |.(leaf/"ford: diff {<`@p`(mug p.kas)>} {<`@p`(mug q.kas)>}") (diff cof p.kas q.kas) :: - %done [cof %0 p.kas q.kas] + %done [cof %0 p.kas %& q.kas] %dude (cool |.(p.kas) $(kas q.kas)) %dune ?~ q.kas [cof [%2 p.kas [%leaf "no data"]~]] @@ -1142,46 +1166,44 @@ %+ cool |.(leaf/"ford: pact {<`@p`(mug p.kas)>} {<`@p`(mug q.kas)>}") (pact cof p.kas q.kas) :: - %plan - %+ cope (abut:(meow p.kas q.kas) cof r.kas) - |= [cof=cafe vax=vase] - (fine cof %noun vax) - :: - %reef (fine cof %noun pit) + %plan (cope (abut:(meow p.kas q.kas) cof r.kas) faun) + %reef (faun cof pit) %ride %+ cool |.(leaf/"ford: ride {<`@p`(mug kas)>}") %+ cope $(kas q.kas) - |= [cof=cafe cay=gage] + %- tabl-run + |= [cof=cafe cay=cage] %+ cope (maim cof q.cay p.kas) |= [cof=cafe vax=vase] - (fine cof %noun vax) + (faun cof vax) :: %tabl %+ cope - |- ^- (bolt (pair (list (pair marc marc)) vase)) - ?~ p.kas (fine cof ~ *vase) + |- ^- (bolt (list (pair gage gage))) + ?~ p.kas (fine cof ~) %+ cope (make cof p.i.p.kas) |= [cof=cafe key=gage] %+ cope (make cof q.i.p.kas) |= [cof=cafe val=gage] %+ cope ^^$(p.kas t.p.kas) - |= [cof=cafe rex=(list (pair marc marc)) rey=vase] - (fine cof [[p.key p.val] rex] (slop (slop q.key q.val) rey)) - |= [cof=cafe rex=(list (pair marc marc)) rey=vase] - (fine cof [%tabl rex] rey) + |= [cof=cafe rex=(list (pair gage gage))] + (fine cof [[key val] rex]) + |= [cof=cafe rex=(list (pair gage gage))] + (fine cof [%tabl rex]) :: %vale %+ cool |.(leaf/"ford: vale {} {} {<`@p`(mug r.kas)>}") %+ cope (lave cof p.kas q.kas r.kas) |= [cof=cafe vax=vase] - (fine cof `cage`[p.kas vax]) + (fine cof `gage`[%& p.kas vax]) :: %volt %+ cool |.(leaf/"ford: volt {}") %+ cope $(kas [%bunt p.q.kas]) - |= [cof=cafe cay=gage] + %- tabl-run + |= [cof=cafe cay=cage] ^- (bolt gage) - [cof %0 p.kas p.q.kas p.q.cay q.q.kas] + [cof %0 p.kas %& p.q.kas p.q.cay q.q.kas] == :: ++ malt :: cached slit @@ -1403,7 +1425,7 @@ (flaw cof [%leaf "type error: {} {}"]~) (fine cof [p.tug q.vax]) :: - %toy (cope (make cof %boil p.hon how ~) feel) + %toy (cope (cope (make cof %boil p.hon how ~) furl) feel) == :: ++ head :: consume structures @@ -1511,12 +1533,10 @@ %. [cof kas kos] ;~ cope ;~ coax - |=([cof=cafe p=silk q=silk] (make cof p)) - |=([cof=cafe p=silk q=silk] (make cof q)) + |=([cof=cafe p=silk q=silk] (cope (make cof p) furl)) + |=([cof=cafe p=silk q=silk] (cope (make cof q) furl)) == - |= [cof=cafe cay=gage coy=gage] - ?. &(?=(@ p.cay) ?=(@ p.coy)) - (flaw cof leaf/"bad pact marc" ~) + |= [cof=cafe cay=cage coy=cage] ^- (bolt gage) ?: ?=(?(%hoon %hook) p.cay) ?. ?=(%txt-diff p.coy) (flaw cof leaf/"{} mark with bad diff type: {}" ~) @@ -1528,7 +1548,7 @@ =- (flaw cof leaf/"{} data with bad diff" -) [>type=p.q.coy< >shouldbe=-:!>(*(urge cord))< ~] =+ pac=(role (lurk (lore (cat 3 u.txt '\0a')) u.dif)) - (fine cof p.cay [%atom %t] (end 3 (dec (met 3 pac)) pac)) + (fine cof %& p.cay [%atom %t] (end 3 (dec (met 3 pac)) pac)) %+ cope (fang cof p.cay) |= [cof=cafe pro=vase] ?. (slab %grad p.pro) @@ -1557,7 +1577,7 @@ (slap (slap pox [%cnzy %grad]) [%cnzy %pact]) q.coy |= [cof=cafe pat=vase] - (fine cof p.cay pat) + (fine cof %& p.cay pat) == :: ++ resp @@ -1622,8 +1642,8 @@ ~ :: ++ load :: highly forgiving - |= old=axle - ..^$(+>- old) +:: |= old=axle +:: ..^$(+>- old) ::=. old :: ?. ?=([%0 *] old) old :: remove at 1 :: :- %1 @@ -1632,12 +1652,13 @@ :: ?> ?=([n=[p=* q=[tad=* dym=* deh=* jav=*]] l=* r=*] +.old) :: :- [p.n.+.old [tad.q.n.+.old dym.q.n.+.old deh.q.n.+.old ~]] :: [$(+.old l.+.old) $(+.old r.+.old)] -:: =+ lox=((soft axle) old) -:: ^+ ..^$ -:: ?~ lox -:: ~& %ford-reset -:: ..^$ -:: ..^$(+>- u.lox) + |= old=* + =+ lox=((soft axle) old) + ^+ ..^$ + ?~ lox + ~& %ford-reset + ..^$ + ..^$(+>- u.lox) :: ++ scry |= [fur=(unit (set monk)) ren=@tas who=ship syd=desk lot=coin tyl=path] diff --git a/base/arvo/gall.hoon b/base/arvo/gall.hoon index b3d36bb2b..ecfefcbcf 100644 --- a/base/arvo/gall.hoon +++ b/base/arvo/gall.hoon @@ -130,9 +130,10 @@ (~(nest ut -:!>(*hide)) %| p:(slot 12 vax)) :: ++ mo-boom :: complete new boot - |= [dap=dude pup=scup dep=@uvH gux=(each gage tang)] + |= [dap=dude pup=scup dep=@uvH gux=gage] ^+ +> ?- -.gux + %tabl ~|(%made-tabl !!) %| =. +> (mo-bold dap dep) =. +> (mo-give %onto %| p.gux) @@ -169,13 +170,14 @@ == :: ++ mo-boon :: complete old boot - |= [dap=dude pup=scup dep=@uvH gux=(each gage tang)] + |= [dap=dude pup=scup dep=@uvH gux=gage] ^+ +> ?. (~(has by bum) dap) ~& [%gall-old-boon dap] +> =. +> (mo-bold dap dep) ?- -.gux + %tabl ~|(%made-tabl !!) %| (mo-give %onto %| p.gux) %& ?> ?=(@ p.p.gux) ap-abet:(ap-peep:(ap-abed:ap dap [%high [~ our]]) q.p.gux) @@ -321,9 +323,9 @@ num=(slav %ud i.t.t.t.pax) == ?- -.q.+>.sih + %tabl ~|(%made-tabl !!) %| (mo-give %mack `p.q.+>.sih) :: XX should crash - %& ?> ?=(@ p.p.q.+>.sih) - =. +>.$ (mo-give %mack ~) :: XX pump should ack + %& =. +>.$ (mo-give %mack ~) :: XX pump should ack (mo-give(hen (mo-ball him num)) %unto %diff `cage`p.q.+>.sih) == :: @@ -335,9 +337,9 @@ == ?: ?=([%f %made *] sih) ?- -.q.+>.sih + %tabl ~|(%made-tabl !!) %| (mo-give %mack `p.q.+>.sih) :: XX should crash - %& ?> ?=(@ p.p.q.+>.sih) - (mo-pass [%sys pax] %g %deal [him our] i.t.t.pax %poke p.q.+>.sih) + %& (mo-pass [%sys pax] %g %deal [him our] i.t.t.pax %poke p.q.+>.sih) == ?: ?=([%a %woot *] sih) +>.$ :: quit ack, boring ?> ?=([%g %unto *] sih) @@ -805,9 +807,7 @@ ^+ +> =+ cug=(ap-find /lame) ?~ cug - ~> %slog. - :- ~ - rose/[" " "[" "]"]^[>%ap-lame< >wut< why] + ~& [%ap-lame wut why] +>.$ =^ cam +>.$ %+ ap-call q.u.cug @@ -986,7 +986,6 @@ %merg `%c %plug `%c %them `%e - %wait `%t %want `%a == -- diff --git a/base/arvo/hoon.hoon b/base/arvo/hoon.hoon index 6dd8980ee..81a81c151 100644 --- a/base/arvo/hoon.hoon +++ b/base/arvo/hoon.hoon @@ -9618,7 +9618,6 @@ == :: ++ curd ,[p=@tas q=*] :: typeless card ++ duct (list wire) :: causal history -++ gage (pair marc vase) :: structured cage ++ from ,[ost=bone src=ship] :: forward problem ++ hide :: standard app state $: $: our=ship :: owner/operator diff --git a/base/arvo/zuse.hoon b/base/arvo/zuse.hoon index b76695f44..e25448684 100644 --- a/base/arvo/zuse.hoon +++ b/base/arvo/zuse.hoon @@ -2475,9 +2475,9 @@ [%call p=silk q=silk] :: slam [%cast p=mark q=silk] :: translate [%diff p=silk q=silk] :: diff - [%done p=(set beam) q=gage] :: literal + [%done p=(set beam) q=cage] :: literal [%dude p=tank q=silk] :: error wrap - [%dune p=(set beam) q=(unit gage)] :: unit literal + [%dune p=(set beam) q=(unit cage)] :: unit literal [%file p=beam] :: from clay [%flag p=@uvH q=silk] :: re-apply user deps [%join p=mark q=silk r=silk] :: merge @@ -2492,8 +2492,13 @@ [%volt p=(set beam) q=(cask ,*)] :: unsafe add type == :: :::: +++ gage :: recursive cage/tang + $% [%& p=cage] :: success + [%| p=tang] :: error + [%tabl p=(list (pair gage gage))] :: table of results + == ++ gift-ford :: out result <-$ - $% [%made p=@uvH q=(each gage tang)] :: computed result + $% [%made p=@uvH q=gage] :: computed result [%mass p=mass] :: memory usage [%news ~] :: fresh depends == :: From 8918885dd5498695d509cfcdccef825f6b6d2a14 Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Mon, 25 May 2015 19:28:08 -0700 Subject: [PATCH 24/34] create disk, check status --- base/ape/cloud/core.hook | 138 ++++++++++++++++++++++++++++------- base/pub/cloud/fab/hymn.hook | 1 + base/pub/cloud/src/main.js | 16 ++++ 3 files changed, 128 insertions(+), 27 deletions(-) diff --git a/base/ape/cloud/core.hook b/base/ape/cloud/core.hook index 7528d5e6a..9a6377f70 100644 --- a/base/ape/cloud/core.hook +++ b/base/ape/cloud/core.hook @@ -40,7 +40,7 @@ private-networking=(unit ,?) user-data=(unit ,@t) == ++ create-req-gce ,[project=@t zone=@t name=@t machine-type=@t] ++ axle -$: auth=[do=keys gcp=keys] toke=[do=tokens gcp=tokens] +$: auth=[do=keys gce=keys] toke=[do=tokens gce=tokens] drops=(list droplet) == ++ keys ,[authc=(unit ,@t) client-secret=(unit ,@t)] @@ -141,7 +141,7 @@ $% [%diff %json json] !: |_ [hid=hide vat=axle] :: -::++ prep ,_`. +++ prep ,_`. ::: ++ spam |= jon=json @@ -194,9 +194,10 @@ $% [%diff %json json] [~ cde] :_ +>.$ ~ - =. access.gcp.toke.vat + =. access.gce.toke.vat cde :_ +>.$ + :- (list-droplets-gce ost) ~ :: ++ poke-cloud-secret @@ -216,7 +217,7 @@ $% [%diff %json json] [%post ~] :- ~ `quay`['client_secret'^secret (auth-queries (need authc.do.auth.vat))] %gce - =. client-secret.gcp.auth.vat + =. client-secret.gce.auth.vat [~ secret] :_ +>.$ :_ ~ @@ -224,7 +225,7 @@ $% [%diff %json json] :^ ~[%google %cloud] `path`/v1/oauth/token [%post ~] :- (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) - `quay`['client_secret'^secret %'access_token'^(need authc.gcp.auth.vat) ~] ::(auth-queries (need authc.gcp.auth.vat))] + `quay`['client_secret'^secret %'access_token'^(need authc.gce.auth.vat) ~] ::(auth-queries (need authc.gcp.auth.vat))] == :: ++ receive-auth @@ -240,7 +241,7 @@ $% [%diff %json json] refresh.do.toke.vat re == :_ +>.$ - :~ (list-droplets ost) + :~ (list-droplets-do ost) (publish ost our.hid [%lin & 'successfully authenticated']~) == %auth-gce @@ -257,7 +258,7 @@ $% [%diff %json json] ?+ do !! %list :_ +>.$ - :- (list-droplets ost) + :- (list-droplets-do ost) ~ :: %create-do @@ -273,9 +274,16 @@ $% [%diff %json json] == :- (create-do ost deets) ~ + :: + %create-gce-disk + =+ name=(need ((ot name/so ~):jo act)) + =+ snap=(need ((ot snap/so ~):jo act)) + :_ +>.$ + :- (create-gce-disk ost name snap) + ~ + :: %create-gce - ~& 'chamado' :_ +>.$ =+ ^- deets=create-req-gce %- need @@ -284,7 +292,6 @@ $% [%diff %json json] %- ot :~ project/so zone/so name/so %'machine_type'^so == - ~& 'dois' :- (create-gce ost deets) ~ :: @@ -317,10 +324,21 @@ $% [%diff %json json] == req -++ list-droplets +++ list-droplets-gce |= os=bone =+ ^= lis - :~ os /list + :* os /list-gce + ~[%googleapis %www] /compute/v1/projects/urbcloud/zones/['us-central1-a']/'instances' + %get ~ + ^- quay + [%'access_token' access.gce.toke.vat]~ + == + (httpreq lis) + +++ list-droplets-do + |= os=bone + =+ ^= lis + :~ os /list-do ~[%digitalocean %api] /v2/droplets %get (mo ['Content-Type' 'application/json' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~) @@ -353,7 +371,7 @@ $% [%diff %json json] =+ buf=`@da`(add ~s10 lat.hid) :_ +>.$ :_ (spam (state-to-json drops.vat)) - [ost %wait /refresh buf] + [ost %wait /refresh-do buf] :: ++ create-do |= [os=bone create-req-do] @@ -367,51 +385,111 @@ $% [%diff %json json] os /create-do ~[%digitalocean %api] /v2/droplets [%post body] - %^ mo ['Content-Type' 'application/json' ~] + %^ mo ['Content-Type' 'application/json; charset=utf-8' ~] ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~ ~ == +::++ batch-request +::|= [os=bone name=@t number=@ud snap=@t] +::(list httr) ^- httr + +++ create-gce-disk + |= [os=bone name=@t snap=@t] :: num=(unit ,@u) + :: =. name ?~(num name ... + =+ ^- body=json + (jobe name/s/name %'sourceSnapshot'^s/'compute/v1/projects/urbcloud/global/snapshots/snapshot-1' ~) ::^so/snap ~) + %- httpreq + :* os /create-gce-disk + ~['googleapis' 'www'] /compute/v1/projects/urbcloud/zones/us-central1-b/disks + [%post body] + %^ mo ['Content-Type' 'application/json' ~] + ['Authorization' (cat 3 'Bearer ' access.gce.toke.vat) ~] + ~ + ~ + == + +::++ receive-gce-disk +:: |= [os=bone resp=httr] +:: ~& insert/resp +:: =+ hcode=p.resp +:: ?: =('200' hcode) +:: ~| 'did not receive 200' !! +:: =+ parsed=(rash q:(need r.resp) apex:poja) +:: =+ link=(need ((ot 'targetLink'^(su auri:epur) ~):jo parsed)) +:: :_ +>.$ +:: :_(~ (ask-disk-status os link)) + +++ ask-disk-status + |= [os=bone pax=path] ^- move + =+ safe=(slav %uv ?~(pax !! -.pax)) + =+ link=(need (epur ?~(pax !! safe))) + =. r.link ['access_token'^access.gce.toke.vat r.link] + :^ os %them `wire`/disk-status + `(unit hiss)`[~ [link [%get ~ ~]]] + +++ disk-status ::receive + |= [ost=bone resp=httr] + ^- [(list move) _+>.$] + ~& resp + =+ parsed=(rash q:(need r.resp) apex:poja) +:: =+ =< [status link]=. +:: %- need + =+ jo + =+ :- status=(need ((ot status/so ~) parsed)) + link=(scot %uv (need ((ot 'selfLink'^so ~) parsed))) + :: ?=(%running....) + ~& status/status + :_ +>.$ + [ost %wait `path`[%check-status link ~] `@da`(add ~s3 lat.hid)]~ :: refresh every 10 sec + ++ create-gce |= [os=bone create-req-gce] - ~& 'called' + =+ src='compute/v1/projects/urbcloud/zones/us-central1-b/disks/disk-1' =+ ^- body=json %- jobe - ~[name/s/name %'machine-type'^s/machine-type] - ~& body - =+ ^= req + :~ name/s/'name-provided' 'machineType'^s/'zones/us-central1-b/machineTypes/n1-standard-1' + :- %disks :- %a :_ ~ + (jobe boot/b/%.y type/s/'persistent' source/s/src ~) + :- 'networkInterfaces' :- %a :_ ~ + (joba 'network' `json`[%s 'global/networks/default']) + == %- httpreq :* `bone`os `path`/create-gce - `(list cord)`~['googleapis' 'www'] `path`/v1/[project]/zones/[zone]/'instances' - ~& 'here' + `(list cord)`~['googleapis' 'www'] `path`/compute/v1/projects/urbcloud/zones/us-central1-b/'instances' [%post `json`body] - ~& 'here' %^ mo ['Content-Type' 'application/json' ~] - ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] + ['Authorization' (cat 3 'Bearer ' access.gce.toke.vat) ~] ~ - `quay`~ + `quay`[%key access.gce.toke.vat]~ == - ~& req req ++ wake |= [[ost=bone him=ship pour-path=path] ~] ?+ -.pour-path !! - %refresh + %refresh-do :_ +>.$ - [(list-droplets ost)]~ + [(list-droplets-do ost)]~ + %check-status + :_ +>.$ + [(ask-disk-status ost +.pour-path)]~ == ++ thou |= [[ost=bone him=ship pour-path=path] resp=httr] ^- [(list move) _+>.$] - ?+ -.pour-path !! + ?+ -.pour-path ~& pour-path !! %auth-do (receive-auth ost -.pour-path resp) :: %auth-gce (receive-auth ost -.pour-path resp) :: - %list + %list-do (receive-list ost -.pour-path resp) + %list-gce + ~& resp + :_ +>.$ + ~ :: $? %delete %reboot %'power_cycle' %shutdown %'power_off' @@ -421,6 +499,12 @@ $% [%diff %json json] == ~& resp :_ +>.$ ~ + :: + ?(%create-gce-disk %disk-status) + (disk-status ost resp) + :: + %check-status + :_ +>.$ ~[(ask-disk-status ost +.pour-path)] :: %pub :_ +>.$ ~ diff --git a/base/pub/cloud/fab/hymn.hook b/base/pub/cloud/fab/hymn.hook index 78bffedd9..75735100a 100644 --- a/base/pub/cloud/fab/hymn.hook +++ b/base/pub/cloud/fab/hymn.hook @@ -23,6 +23,7 @@ ;body ;* =+ d=?~(do ~ (trip u.do)) =+ g=?~(g ~ (trip u.g)) + ~& d :_ ~ ;script: authcode='{?~(d g d)}'; console.log(authcode) ;div#container; diff --git a/base/pub/cloud/src/main.js b/base/pub/cloud/src/main.js index 9e4d82867..e31be854c 100644 --- a/base/pub/cloud/src/main.js +++ b/base/pub/cloud/src/main.js @@ -70,10 +70,26 @@ GCEControls = React.createClass({ mark: 'json'}) }, + createDisk: function(){ + urb.send({ + appl: 'cloud', + data: {action:'create-gce-disk', + snap:$('#gsnap').val(), + number:$('#number').val(), + name:$('#gcpName').val()}, + mark: 'json'}) + }, + render: function(){ ghref = "https://accounts.google.com/o/oauth2/auth?response_type=token&scope=https://www.googleapis.com/auth/compute&redirect_uri=http://localhost:8443/home/pub/cloud/fab&client_id=719712694742-6htfj2t9s1j2jid92rc4dfq9psrr9qpo.apps.googleusercontent.com" return( div({}, [ + div({}, [ + b({onClick:this.createDisk}, 'Create Disk From Image'), + input({id:'gcpName',placeholder:'Name for GCE Disk and Instance'}), + input({id:'number',placeholder:'Number of instances'}), + input({id:'gsnap',placeholder:'Snapshot'}) + ]), div({}, [ a({href:ghref},"Get Google Authcode"), b({onClick:this.props.handleClick('gce')}, "Send Google Authcode") From cab4b671a6aa872e9f5fcebb2f32f46bb885f8c2 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 26 May 2015 13:20:44 -0700 Subject: [PATCH 25/34] reloads --- base/ape/dojo/core.hook | 4 +- base/arvo/clay.hoon | 304 +++++++++++++--------------------------- 2 files changed, 96 insertions(+), 212 deletions(-) diff --git a/base/ape/dojo/core.hook b/base/ape/dojo/core.hook index 7ce98b071..998c7e9fb 100644 --- a/base/ape/dojo/core.hook +++ b/base/ape/dojo/core.hook @@ -133,9 +133,9 @@ [%call p=silk q=silk] :: slam [%cast p=mark q=silk] :: translate [%diff p=silk q=silk] :: diff - [%done p=(set beam) q=gage] :: literal + [%done p=(set beam) q=cage] :: literal [%dude p=tank q=silk] :: error wrap - [%dune p=(set beam) q=(unit gage)] :: unit literal + [%dune p=(set beam) q=(unit cage)] :: unit literal [%file p=beam] :: from clay [%join p=mark q=silk r=silk] :: merge [%mash p=mark q=milk r=milk] :: annotate diff --git a/base/arvo/clay.hoon b/base/arvo/clay.hoon index 3fe828268..cd4a8bb5c 100644 --- a/base/arvo/clay.hoon +++ b/base/arvo/clay.hoon @@ -212,6 +212,16 @@ ?+(- [[p.p p.q]:hed -] [@ *] -) == == :: + ++ cages-to-map + |= tay=(list (pair cage cage)) + =| can=(map path cage) + |- ^- (each (map path cage) tang) + ?~ tay [%& can] + =* pax p.i.tay + ?. ?=(%path p.pax) + (mule |.(`~`~|([%expected-path got=p.pax] !!))) + $(tay t.tay, can (~(put by can) ((hard path) q.q.pax) q.i.tay)) + ++ balk :: read and send |= [hen=duct cay=(unit (each cage lobe)) mun=mood] ^+ +> @@ -931,12 +941,13 @@ == :: ++ take-foreign-x - |= [car=care cas=case pax=path res=(each gage tang)] + |= [car=care cas=case pax=path res=gage] ^+ +> ?> ?=(^ ref) - ?: ?=(%| -.res) + ?. ?=(%& -.res) ~| "validate foreign plops failed" - ~| [%plop-fail (turn p.res |=(tank ~(ram re +<)))] + =+ tan=?-(-.res %| p.res, %tabl ~[>%bad-marc<]) + ~> %mean.|.(rose/[" " "[" "]"]^[>%plop-fail< tan]) !! ?> ?=(@ p.p.res) wake(haw.u.ref (~(put by haw.u.ref) [car cas pax] `p.res)) @@ -965,34 +976,24 @@ == :: ++ take-foreign-plops - |= res=(each gage tang) + |= res=gage ^+ +> ?> ?=(^ ref) ?> ?=(^ nak.u.ref) - ?: ?=(%| -.res) + ?. ?=(%| -.res) ~| "validate foreign plops failed" - ~| [%plop-fail (turn p.res |=(tank ~(ram re +<)))] + ~> %mean.|.(rose/[" " "[" "]"]^[>%plop-fail< p.res]) !! - =+ cay=p.res - ?@ p.cay ~| %plop-bad-marc !! - =+ |- ^- lat=(list blob) - ?~ p.p.cay - ~ - :_ %_($ cay [[%tabl t.p.p.cay] (slot 3 q.cay)]) - ?. ?=(%blob p.i.p.p.cay) - ~| %plop-strange-marc-a + =+ ^- lat=(list blob) + %+ turn (gage-to-cages res) + |= [bob=cage cay=cage] + ?. ?=(%blob p.bob) + ~| %plop-not-blob !! - ?. ?=(@ q.i.p.p.cay) - ~| %plop-strange-marc-b - !! - =+ coy=(slot 2 q.cay) - ?@ q.coy - ~| %plop-strange-coy - !! - =+ bol=((hard blob) -.q.coy) + =+ bol=((hard blob) q.bob) ?- -.bol - %delta [-.bol p.bol q.bol q.i.p.p.cay +.q.coy] - %direct [-.bol p.bol q.i.p.p.cay +.q.coy] + %delta [-.bol p.bol q.bol p.cay q.q.cay] + %direct [-.bol p.bol p.cay q.q.cay] %indirect ~| %plop-indirect-not-implemented !! == %^ apply-foreign-update @@ -1583,16 +1584,16 @@ ..me(mer (~(del by mer) ali), reg :_(reg [hen %mere gon.dat])) :: ++ route - |= [sat=term res=(each riot (each gage tang))] + |= [sat=term res=(each riot gage)] ^+ +>.$ - ?+ sat ~|((crip <[%bad-stage sat]>) !!) - %ali %- fetched-ali ?> ?=(%& -.res) p.res - %diff-ali %- diffed-ali ?> ?=(%| -.res) p.res - %diff-bob %- diffed-bob ?> ?=(%| -.res) p.res - %merge %- merged ?> ?=(%| -.res) p.res - %build %- built ?> ?=(%| -.res) p.res - %checkout %- checked-out ?> ?=(%| -.res) p.res - %ergo %- ergoed ?> ?=(%| -.res) p.res + ?+ +< ~|((crip <[%bad-stage sat ?~(-.res %riot %gage)]>) !!) + [%ali %& *] %.(p.res fetched-ali) + [%diff-ali %| *] %.(p.res diffed-ali) + [%diff-bob %| *] %.(p.res diffed-bob) + [%merge %| *] %.(p.res merged) + [%build %| *] %.(p.res built) + [%checkout %| *] %.(p.res checked-out) + [%ergo %| *] %.(p.res ergoed) == :: ++ start @@ -1827,34 +1828,14 @@ (diff-bas %ali ali.dat ali bob.dat) :: ++ diffed-ali - |= res=(each gage tang) + |= res=gage ^+ +> - ?: ?=(%| -.res) - (error:he %diff-ali-bad-made leaf/"merge diff ali failed" p.res) - =+ cay=p.res - ?@ p.cay - (error:he %diff-ali-bad-marc >p.cay< ~) - =| can=(map path cage) - => - |- ^+ + - ?~ p.p.cay - +.$(can ~) - =+ tal=%_($ cay [[%tabl t.p.p.cay] (slot 3 q.cay)]) - ?: ?=(%| -.gon.dat.tal) - tal - ?. ?=(%path p.i.p.p.cay) - +.$(+>.$ (error:he %diff-ali-strange-marc-a >p.i.p.p.cay< ~)) - ?. ?=(@ q.i.p.p.cay) - +.$(+>.$ (error:he %diff-ali-strange-marc-b >q.i.p.p.cay< ~)) - =+ coy=(slot 2 q.cay) - ?@ q.coy - +.$(+>.$ (error:he %diff-ali-strange-coy ~)) - %_ +.$ - can - %+ ~(put by can:tal) - ((hard path) -.q.coy) - [q.i.p.p.cay (slot 3 coy)] - == + =+ tay=(gage-to-tage res) + ?: ?=(%| -.tay) + (error:he %diff-ali-bad-made leaf/"merge diff ali failed" p.tay) + =+ can=(cages-to-map p.tay) + ?: ?=(%| -.can) + (error:he %diff-ali p.can) ?: ?=(%| -.gon.dat) +>.$ =. new.dal.dat @@ -1872,7 +1853,7 @@ !=([~ lob] a) =([~ lob] b) == - =. can.dal.dat can + =. can.dal.dat p.can =. old.dal.dat %- mo ^- (list ,[path ~]) %+ murn (~(tap by q.bas.dat)) @@ -1887,34 +1868,14 @@ (diff-bas %bob bob.dat bob ali.dat) :: ++ diffed-bob - |= res=(each tage tang) + |= res=gage ^+ +> - ?: ?=(%| -.res) - (error:he %diff-bob-bad-made leaf/"merge diff bob failed" p.res) - =+ cay=p.res - ?@ p.cay - (error:he %diff-bob-bad-marc >p.cay< ~) - =| can=(map path cage) - => - |- ^+ + - ?~ p.p.cay - +.$(can ~) - =+ tal=%_($ cay [[%tabl t.p.p.cay] (slot 3 q.cay)]) - ?: ?=(%| -.gon.dat.tal) - tal - ?. ?=(%path p.i.p.p.cay) - +.$(+>.$ (error:he %diff-bob-strange-marc-a >p.i.p.p.cay< ~)) - ?. ?=(@ q.i.p.p.cay) - +.$(+>.$ (error:he %diff-bob-strange-marc-b >q.i.p.p.cay< ~)) - =+ coy=(slot 2 q.cay) - ?@ q.coy - +.$(+>.$ (error:he %diff-bob-strange-coy ~)) - %_ +.$ - can - %+ ~(put by can:tal) - ((hard path) -.q.coy) - [q.i.p.p.cay (slot 3 coy)] - == + =+ tay=(gage-to-tage res) + ?: ?=(%| -.tay) + (error:he %diff-bob-bad-made leaf/"merge diff bob failed" p.tay) + =+ can=(cages-to-map p.tay) + ?: ?=(%| -.can) + (error:he %diff-bob p.can) ?: ?=(%| -.gon.dat) +>.$ =. new.dob.dat @@ -1932,7 +1893,7 @@ !=([~ lob] b) =([~ lob] a) == - =. can.dob.dat can + =. can.dob.dat p.can =. old.dob.dat %- mo ^- (list ,[path ~]) %+ murn (~(tap by q.bas.dat)) @@ -1966,35 +1927,14 @@ == :: ++ merged - |= res=(each tage tang) - ?: ?=(%| -.res) - (error:he %merge-bad-made leaf/"merging failed" p.res) - =+ cay=p.res - ?@ p.cay - (error:he %merge-bad-marc >p.cay< ~) - =| bof=(map path (unit cage)) - => - |- ^+ + - ?~ p.p.cay - +.$(bof ~) - =+ tal=%_($ cay [[%tabl t.p.p.cay] (slot 3 q.cay)]) - ?: ?=(%| -.gon.dat.tal) - tal - ?. ?=(%path p.i.p.p.cay) - +.$(+>.$ (error:he %merge-strange-marc-a >p.i.p.p.cay< ~)) - ?. ?=(@ q.i.p.p.cay) - +.$(+>.$ (error:he %merge-strange-marc-b >q.i.p.p.cay< ~)) - =+ coy=(slot 2 q.cay) - ?@ q.coy - +.$(+>.$ (error:he %merge-strange-coy ~)) - %_ +.$ - bof - %+ ~(put by bof:tal) - ((hard path) -.q.coy) - ?: ?=(%null q.i.p.p.cay) - ~ - `[q.i.p.p.cay (slot 3 coy)] - == + |= res=gage + =+ tay=(gage-to-tage res) + ?: ?=(%| -.tay) + (error:he %merge-bad-made leaf/"merging failed" p.tay) + =+ can=(cages-to-map p.tay) + ?: ?=(%| -.can) + (error:he %merge p.can) + =+ bof=(~(run by p.can) (flit |=([a=mark ^] !?=(%null a)))) ?: ?=(%| -.gon.dat) +>.$ =. bof.dat bof @@ -2023,37 +1963,17 @@ :: ++ built - |= res=(each tage tang) + |= res=gage ^+ +> - ?: ?=(%| -.res) - (error:he %build-bad-made leaf/"delta building failed" p.res) - =+ cay=p.res - ?@ p.cay - (error:he %build-bad-marc >p.cay< ~) - =| bop=(map path cage) - => - |- ^+ + - ?~ p.p.cay - +.$(bop ~) - =+ tal=%_($ cay [[%tabl t.p.p.cay] (slot 3 q.cay)]) - ?: ?=(%| -.gon.dat.tal) - tal - ?. ?=(%path p.i.p.p.cay) - +.$(+>.$ (error:he %build-strange-marc-a >p.i.p.p.cay< ~)) - ?. ?=(@ q.i.p.p.cay) - +.$(+>.$ (error:he %build-strange-marc-b >q.i.p.p.cay< ~)) - =+ coy=(slot 2 q.cay) - ?@ q.coy - +.$(+>.$ (error:he %build-strange-coy ~)) - %_ +.$ - bop - %+ ~(put by bop:tal) - ((hard path) -.q.coy) - [q.i.p.p.cay (slot 3 coy)] - == + =+ tay=(gage-to-tage res) + ?: ?=(%| -.tay) + (error:he %build-bad-made leaf/"delta building failed" p.tay) + =+ bop=(cages-to-map p.tay) + ?: ?=(%| -.bop) + (error:he %built p.bop) ?: ?=(%| -.gon.dat) +>.$ - =. bop.dat bop + =. bop.dat p.bop =+ ^- con=(map path ,*) :: 2-change conflict %- mo %+ skim (~(tap by bof.dat)) @@ -2159,39 +2079,19 @@ == :: ++ checked-out - |= res=(each tage tang) + |= res=gage ^+ +> - ?: ?=(%| -.res) - (error:he %checkout-bad-made leaf/"merge checkout failed" p.res) - =+ cay=p.res - ?@ p.cay - (error:he %patch-bad-marc >p.cay< ~) - =| can=(list ,[path cage]) - => - |- ^+ + - ?~ p.p.cay - +.$(can ~) - =+ tal=%_($ cay [[%tabl t.p.p.cay] (slot 3 q.cay)]) - ?: ?=(%| -.gon.dat.tal) - tal - ?. ?=(%path p.i.p.p.cay) - +.$(+>.$ (error:he %patch-strange-marc-a >p.i.p.p.cay< ~)) - ?. ?=(@ q.i.p.p.cay) - +.$(+>.$ (error:he %patch-strange-marc-b >q.i.p.p.cay< ~)) - =+ coy=(slot 2 q.cay) - ?@ q.coy - +.$(+>.$ (error:he %patch-strange-coy ~)) - %_ +.$ - can - :_ can:tal - :- ((hard path) -.q.coy) - [q.i.p.p.cay (slot 3 coy)] - == + =+ tay=(gage-to-tage res) + ?: ?=(%| -.tay) + (error:he %checkout-bad-made leaf/"merge checkout failed" p.tay) + =+ can=(cages-to-map p.tay) + ?: ?=(%| -.can) + (error:he %checkout p.can) ?: ?=(%| -.gon.dat) +>.$ =. let.dom +(let.dom) =. hit.dom (~(put by hit.dom) let.dom r.new.dat) - =. ank.dat (checkout-ankh:ze (~(uni by bop.dat) (mo can))) + =. ank.dat (checkout-ankh:ze (~(uni by bop.dat) p.can)) =. ank.dom ank.dat ?~ hez (done:he ~) @@ -2219,44 +2119,30 @@ == :: ++ ergoed - |= res=(each tage tang) - ^+ + - ?: ?=(%| -.res) - (error:he %ergo-bad-made leaf/"merge ergo failed" p.res) - =+ cay=p.res - ?@ p.cay ~| %patch-bad-marc !! - =| can=(list ,[path (unit mime)]) - => - |- ^+ + - ?~ p.p.cay - +.$(can ~) - =+ tal=%_($ cay [[%tabl t.p.p.cay] (slot 3 q.cay)]) - ?: ?=(%| -.gon.dat.tal) - tal - ?. ?=(%path p.i.p.p.cay) - +.$(+>.$ (error:he %patch-strange-marc-a >p.i.p.p.cay< ~)) - ?. ?=(@ q.i.p.p.cay) - +.$(+>.$ (error:he %patch-strange-marc-b >p.i.p.p.cay< ~)) - =+ coy=(slot 2 q.cay) - ?@ q.coy - +.$(+>.$ (error:he %patch-strange-coy ~)) - %_ +.$ - can - :_ can:tal - :- ((hard path) -.q.coy) - ?. ?=(%mime q.i.p.p.cay) - ~ - `((hard mime) q:(slot 3 coy)) - == + |= res=gage + ^+ +> + =+ tay=(gage-to-tage res) + ?: ?=(%| -.tay) + (error:he %ergo-bad-made leaf/"merge ergo failed" p.tay) + =+ =| can=mick + |- ^- tan=$&(mick [p=term q=tang]) + ?~ p.tay can + =* pax p.i.p.tay + ?. ?=(%path p.pax) + [%ergo >[%expected-path got=p.pax]< ~] + =* mim q.i.p.tay + =+ mit=?.(?=(%mime p.mim) ~ `((hard mime) q.q.mim)) + $(p.tay t.p.tay, can :_(can [((hard path) q.q.pax) mit])) + ?: ?=([@ *] tan) (error:he tan) ?~ hez (error:he %ergo-no-hez ~) ?. syn (error:he %ergo-sync-off ~) ?: ?=(%| -.gon.dat) +>.$ - %= +>.$ + %_ +>.$ don %| - reg [[u.hez %ergo who syd let.dom can] reg] + reg [[u.hez %ergo who syd let.dom tan] reg] == :: ++ he @@ -2680,12 +2566,10 @@ == ?: ?=([%blab care @ @ *] tea) ?> ?=(%made +<.q.hin) - ?: ?=(%| -.q.q.hin) + ?. ?=(%& -.q.q.hin) ~| %blab-fail - ~> %mean.|.(p.q.q.hin) :: interpolate ford fail into stack trace - !! - ?^ p.p.q.q.hin - ~|(%bad-marc !!) + ~> %mean.|.(?+(-.q.q.hin -.q.q.hin %| p.q.q.hin)) + !! :: interpolate ford fail into stack trace :_ ..^$ :_ ~ :* hen %give %writ ~ `[care case @tas]`[i.t.tea ((hard case) +>:(slay i.t.t.tea)) i.t.t.t.tea] From e6a6f4040508b9c5bf66f855802de084ee1dbf0c Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Tue, 26 May 2015 13:47:57 -0700 Subject: [PATCH 26/34] pre-state unification --- base/ape/cloud/core.hook | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/base/ape/cloud/core.hook b/base/ape/cloud/core.hook index 9a6377f70..942ea0ff0 100644 --- a/base/ape/cloud/core.hook +++ b/base/ape/cloud/core.hook @@ -141,7 +141,7 @@ $% [%diff %json json] !: |_ [hid=hide vat=axle] :: -++ prep ,_`. +::++ prep ,_`. ::: ++ spam |= jon=json @@ -413,8 +413,6 @@ $% [%diff %json json] :: |= [os=bone resp=httr] :: ~& insert/resp :: =+ hcode=p.resp -:: ?: =('200' hcode) -:: ~| 'did not receive 200' !! :: =+ parsed=(rash q:(need r.resp) apex:poja) :: =+ link=(need ((ot 'targetLink'^(su auri:epur) ~):jo parsed)) :: :_ +>.$ @@ -431,21 +429,28 @@ $% [%diff %json json] ++ disk-status ::receive |= [ost=bone resp=httr] ^- [(list move) _+>.$] - ~& resp - =+ parsed=(rash q:(need r.resp) apex:poja) -:: =+ =< [status link]=. -:: %- need - =+ jo - =+ :- status=(need ((ot status/so ~) parsed)) - link=(scot %uv (need ((ot 'selfLink'^so ~) parsed))) - :: ?=(%running....) - ~& status/status + =+ hcode=p.resp + ?: =('200' hcode) + ~| 'did not receive 200' !! + =+ :-(parsed=(rash q:(need r.resp) apex:poja) jo) + =+ :- status=(need ((ot status/so ~) parsed)) + lin=(need ((ot 'selfLink'^so ~) parsed)) + =+ link=(scot %uv lin) + ~& lin + ?: =('DONE' status) + ~& resp + ~& 'boot disk now running, now starting instance' + =+ target=(need ((ot 'targetLink'^so ~):jo parsed)) + =+ nam=-:(flop q.q:(need (epur target))) + ~& nam + ::(create-gce-disk ost nam 'tbd') + :- ~ +>.$ :_ +>.$ [ost %wait `path`[%check-status link ~] `@da`(add ~s3 lat.hid)]~ :: refresh every 10 sec ++ create-gce |= [os=bone create-req-gce] - =+ src='compute/v1/projects/urbcloud/zones/us-central1-b/disks/disk-1' + =+ src=(cat 3 'compute/v1/projects/urbcloud/zones/us-central1-b/disks/' name) =+ ^- body=json %- jobe :~ name/s/'name-provided' 'machineType'^s/'zones/us-central1-b/machineTypes/n1-standard-1' From c2641a464a6cb7af5a863e6d42c2d76c55611fc3 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 26 May 2015 13:56:21 -0700 Subject: [PATCH 27/34] gage unwinding stable --- base/ape/dojo/core.hook | 12 ++++----- base/ape/hood/core.hook | 2 +- base/arvo/clay.hoon | 2 +- base/lib/kiln/core.hook | 58 +++++++++++++++++++++++++++-------------- 4 files changed, 46 insertions(+), 28 deletions(-) diff --git a/base/ape/dojo/core.hook b/base/ape/dojo/core.hook index 998c7e9fb..b65b9d8d6 100644 --- a/base/ape/dojo/core.hook +++ b/base/ape/dojo/core.hook @@ -149,7 +149,7 @@ [%volt p=(set beam) q=(cask ,*)] :: unsafe add type == :: ++ sign :: - $% [%made p=@uvH q=(each gage tang)] :: + $% [%made p=@uvH q=gage] :: [%unto p=cuft] :: == :: -- :: @@ -227,7 +227,7 @@ (ifix [sel ser] (stag %tu (most ace dp-source))) == :: - ++ dp-goal :: ++goal + ++ dp-goal :: ++goal %+ cook |=(a=goal a) ;~ pose ;~ plug @@ -627,13 +627,12 @@ [& %$ "> "] :: ++ he-made :: result from ford - |= [way=wire dep=@uvH reg=(each gage tang)] + |= [way=wire dep=@uvH reg=gage] ^+ +> ?> ?=(^ poy) =< he-pine ?- -.reg - %& ?> ?=(@ p.p.reg) - %. p.reg + %& %. p.reg =+ dye=~(. dy u.poy(pux ~)) ?+ way !! [%hand ~] dy-hand:dye @@ -642,6 +641,7 @@ [%edit ~] dy-made-edit:dye == %| (he-diff(poy ~) %tan p.reg) + %tabl !! == :: ++ he-unto :: result from behn @@ -742,7 +742,7 @@ he-abet:(~(he-type he [ost ~] (~(got by hoc) ost)) act) :: ++ made - |= [then dep=@uvH reg=(each gage tang)] + |= [then dep=@uvH reg=gage] he-abet:(~(he-made he [[ost ~] (~(got by hoc) ost)]) way dep reg) :: ++ unto diff --git a/base/ape/hood/core.hook b/base/ape/hood/core.hook index f73c83de8..7463e67da 100644 --- a/base/ape/hood/core.hook +++ b/base/ape/hood/core.hook @@ -119,7 +119,7 @@ (ably (take-mere:(kiln-work [hid ost src] (able %kiln)) way +<+)) :: ++ made-kiln :: - |= [then @uvH (each gage tang)] + |= [then @uvH gage] (ably (take-made:(kiln-work [hid ost src] (able %kiln)) way +<+)) :: ++ init-helm :: diff --git a/base/arvo/clay.hoon b/base/arvo/clay.hoon index cd4a8bb5c..e1e1f6943 100644 --- a/base/arvo/clay.hoon +++ b/base/arvo/clay.hoon @@ -765,7 +765,7 @@ :- ((hard path) q.q.pax) ?. ?=(%mime p.mim) ~ - `((hard mime) q:(slot 3 q.mim)) + `((hard mime) q.q.mim) == == :: diff --git a/base/lib/kiln/core.hook b/base/lib/kiln/core.hook index 69e2070a2..035e32b11 100644 --- a/base/lib/kiln/core.hook +++ b/base/lib/kiln/core.hook @@ -57,8 +57,6 @@ $% [%talk-command command:talk] :: [%hood-merge hood-merge] :: == :: - ++ tage :: %tabl gage - ,[[%tabl p=(list (pair marc marc))] q=vase] :: ++ move (pair bone card) :: user-level move -- |_ moz=(list move) @@ -89,7 +87,7 @@ abet:abet:(mere:(take way) are) :: ++ take-made :: - |= [way=wire dep=@uvH reg=(each gage tang)] + |= [way=wire dep=@uvH reg=gage] abet:abet:(made:(take way) dep reg) :: ++ take-coup-fancy :: @@ -117,22 +115,42 @@ ~| %kiln-work-fail !! :: - ++ gage-to-tage :: - |= res=gage - ^- tage - ?@ p.res - ~|(%bad-marc !!) - res + ++ ford-fail + |= tan=tang + ~| %ford-fail + |- + ?~ tan !! + ~> %mean.|.(i.tan) :: interpolate into stack trace + $(tan t.tan) :: - ++ tage-to-cages :: - |= tab=tage - ^- (list (pair cage cage)) - ?~ p.tab - ~ - :_ $(p.tab t.p.tab, q.tab (slot 3 q.tab)) - ~| %strange-gage - :- [?^(p.i.p.tab !! p.i.p.tab) (slot 4 q.tab)] - [?^(q.i.p.tab !! q.i.p.tab) (slot 5 q.tab)] + ++ unwrap-tang + |* res=(each ,* tang) + ?: ?=(%& -.res) + p.res + (ford-fail p.res) + :: + ++ gage-to-cages + |= gag=gage ^- (list (pair cage cage)) + (unwrap-tang (gage-to-tage gag)) + :: + ++ gage-to-tage + |= gag=gage + ^- (each (list (pair cage cage)) tang) + ?. ?=(%tabl -.gag) + (mule |.(`~`(ford-fail >%strange-gage< ~))) + =< ?+(. [%& .] [@ *] .) + |- ^- ?((list ,[cage cage]) (each ,~ tang)) + ?~ p.gag ~ + =* hed i.p.gag + ?- -.p.hed + %tabl (mule |.(`~`(ford-fail >%strange-gage< ~))) + %| (mule |.(`~`(ford-fail p.p.hed))) + %& ?- -.q.hed + %tabl (mule |.(`~`(ford-fail >%strange-gage< ~))) + %| (mule |.(`~`(ford-fail p.q.hed))) + %& =+ $(p.gag t.p.gag) + ?+(- [[p.p p.q]:hed -] [@ *] -) + == == :: ++ perform :: ^+ . @@ -260,13 +278,13 @@ == :: ++ made - |= [dep=@uvH reg=(each gage tang)] + |= [dep=@uvH reg=gage] ^+ +> ?: ?=(%| -.reg) =+ "failed to mash" lose:(spam leaf/- p.reg) =+ ^- can=(list (pair path (unit miso))) - %+ turn (tage-to-cages (gage-to-tage p.reg)) + %+ turn (gage-to-cages reg) |= [pax=cage dif=cage] ^- (pair path (unit miso)) ?. ?=(%path p.pax) From 809c524e700c05e32ce98b74cbd441e8a8c209a2 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 26 May 2015 14:22:49 -0700 Subject: [PATCH 28/34] working tree js --- base/pub/tree/src/js/main.js | 1627 +++++++++++++++++++++++++++++++++- 1 file changed, 1626 insertions(+), 1 deletion(-) diff --git a/base/pub/tree/src/js/main.js b/base/pub/tree/src/js/main.js index bd931c056..13fe9c736 100644 --- a/base/pub/tree/src/js/main.js +++ b/base/pub/tree/src/js/main.js @@ -1 +1,1626 @@ -console.error("Error: Cannot find module '/Users/pittyp/temp/urb/zod/base/pub/tree/src/js/node_modules/coffeeify/index.js' from '/Users/pittyp/temp/urb/zod/base/pub/tree/src/js'") \ No newline at end of file +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { + p = curr.split("/"); + curr = p.pop(); + up = p.join("/"); + ci = 0; + k = 0; + sibs = _.map(_.keys(this.state.sibs).sort(), (function(_this) { + return function(i) { + var c; + c = ""; + if (curr === i) { + c = "active"; + ci = k; + } + k++; + href = window.tree.basepath(up + "/" + i); + return div({ + className: c + }, a({ + key: i + "-a", + href: href, + onClick: _this._click + }, i)); + }; + })(this)); + offset = 0; + if (ci > 0) { + offset = 0; + } + s = { + marginTop: ((ci * -24) - offset) + "px" + }; + parts.push(div({ + key: "sibs", + id: "sibs", + style: s + }, sibs)); + } + obj = { + onMouseOver: this._mouseOver, + onMouseOut: this._mouseOut, + onClick: this._click, + onTouchStart: this._touchStart, + onTouchEnd: this._touchEnd + }; + if (_.keys(window).indexOf("ontouchstart") !== -1) { + delete obj.onMouseOver; + delete obj.onMouseOut; + } + return div(obj, parts); + } +}); + + + +},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14}],3:[function(require,module,exports){ +var TreeActions, TreeStore, div, input, load, recl, ref, textarea; + +TreeStore = require('../stores/TreeStore.coffee'); + +TreeActions = require('../actions/TreeActions.coffee'); + +load = require('./LoadComponent.coffee'); + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; + +module.exports = recl({ + stateFromStore: function() { + return { + body: TreeStore.getBody(), + load: TreeStore.getLoad(), + curr: TreeStore.getCurr(), + cont: TreeStore.getCont() + }; + }, + componentDidMount: function() { + return TreeStore.addChangeListener(this._onChangeStore); + }, + componentDidUpdate: function(_props, _state) { + if (_state.curr !== this.state.curr) { + return setTimeout(((function(_this) { + return function() { + return _this.getPath(_state.curr); + }; + })(this)), 0); + } + }, + getInitialState: function() { + return this.stateFromStore(); + }, + _onChangeStore: function() { + return this.setState(this.stateFromStore()); + }, + getPath: function(path) { + if (this.state.cont[path] == null) { + TreeActions.setLoading(true); + return TreeActions.getPath(path, (function(_this) { + return function() { + return TreeActions.setLoading(false); + }; + })(this)); + } + }, + render: function() { + var parts, ref1; + parts = []; + parts.push(div({ + id: 'body', + key: "body" + this.state.curr + }, (ref1 = this.state.body) != null ? ref1 : div({ + className: "loading" + }, load({}, "")))); + return div({}, parts); + } +}); + + + +},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14,"./LoadComponent.coffee":7}],4:[function(require,module,exports){ +var div, recl, ref, textarea; + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.textarea], div = ref[0], textarea = ref[1]; + +module.exports = recl({ + render: function() { + return div({}, textarea({ + ref: 'ed', + value: this.props.value + })); + }, + componentDidMount: function() { + return CodeMirror.fromTextArea(this.refs.ed.getDOMNode(), { + readOnly: true + }); + } +}); + + + +},{}],5:[function(require,module,exports){ +var TreeActions, TreeStore, a, div, hr, li, recl, ref, ul; + +TreeStore = require('../stores/TreeStore.coffee'); + +TreeActions = require('../actions/TreeActions.coffee'); + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.a, React.DOM.ul, React.DOM.li, React.DOM.hr], div = ref[0], a = ref[1], ul = ref[2], li = ref[3], hr = ref[4]; + +module.exports = recl({ + stateFromStore: function() { + var path, ref1; + path = (ref1 = this.props.dataPath) != null ? ref1 : TreeStore.getCurr(); + return { + cont: TreeStore.getCont(), + tree: TreeStore.getTree(path.split("/")), + path: path + }; + }, + componentDidMount: function() { + return TreeStore.addChangeListener(this._onChangeStore); + }, + getInitialState: function() { + return this.stateFromStore(); + }, + _onChangeStore: function() { + return this.setState(this.stateFromStore()); + }, + componentDidMount: function() { + var cont, i, k, len, ref1; + cont = true; + ref1 = _.keys(this.state.tree); + for (i = 0, len = ref1.length; i < len; i++) { + k = ref1[i]; + if (!this.state.cont[this.state.path + "/" + k]) { + cont = false; + } + } + if (!this.state.tree || _.keys(this.state.tree).length === 0 || !cont) { + return TreeActions.getPath(this.state.path, "kids"); + } + }, + render: function() { + var _list, doc, ref1; + doc = (ref1 = this.state.tree) != null ? ref1 : []; + _list = _.map(_.keys(doc).sort(), (function(_this) { + return function(v) { + var _path; + _path = _this.state.path + "/" + v; + return [ + div({ + key: "kid-" + v + }, _this.state.cont[_path]), hr({}, "") + ]; + }; + })(this)); + return div({ + key: "kids-" + this.state.path, + className: "kids" + }, _list); + } +}); + + + +},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14}],6:[function(require,module,exports){ +var TreeActions, TreeStore, a, div, h1, li, load, recl, ref, ul; + +TreeStore = require('../stores/TreeStore.coffee'); + +TreeActions = require('../actions/TreeActions.coffee'); + +load = require('./LoadComponent.coffee'); + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.a, React.DOM.ul, React.DOM.li, React.DOM.h1], div = ref[0], a = ref[1], ul = ref[2], li = ref[3], h1 = ref[4]; + +module.exports = recl({ + stateFromStore: function() { + var path, ref1; + path = (ref1 = this.props.dataPath) != null ? ref1 : TreeStore.getCurr(); + return { + snip: TreeStore.getSnip(), + tree: TreeStore.getTree(path.split("/")), + path: path + }; + }, + componentDidMount: function() { + return TreeStore.addChangeListener(this._onChangeStore); + }, + getInitialState: function() { + return this.stateFromStore(); + }, + _onChangeStore: function() { + return this.setState(this.stateFromStore()); + }, + getCont: function() { + var cont, i, k, keys, len; + cont = true; + keys = _.keys(this.state.tree); + for (i = 0, len = keys.length; i < len; i++) { + k = keys[i]; + if (!this.state.snip[this.state.path + "/" + k]) { + cont = false; + } + } + if (keys.length === 0) { + cont = false; + } + return cont; + }, + componentDidMount: function() { + var cont; + cont = this.getCont(); + if (!this.state.tree || _.keys(this.state.tree).length === 0 || !cont) { + return TreeActions.getPath(this.state.path, "snip"); + } + }, + render: function() { + var _list, doc, ref1; + doc = (ref1 = this.state.tree) != null ? ref1 : []; + if (!this.getCont()) { + _list = div({ + className: "loading" + }, load({}, "")); + } else { + _list = _.map(_.keys(doc).sort(), (function(_this) { + return function(v) { + var _path, c, href, prev; + _path = _this.state.path + "/" + v; + if (_this.props.dataPreview != null) { + c = "preview"; + if (_this.props.titlesOnly) { + prev = _this.state.snip[_path].head; + } else { + prev = _this.state.snip[_path]; + } + } else { + c = ""; + prev = h1({}, v); + } + href = window.tree.basepath(_path); + return li({}, a({ + href: href, + className: c, + key: "list-a-" + _path + }, prev)); + }; + })(this)); + } + return ul({ + className: "list", + key: "list-" + this.state.path + }, _list); + } +}); + + + +},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14,"./LoadComponent.coffee":7}],7:[function(require,module,exports){ +var div, input, recl, ref, textarea; + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; + +module.exports = recl({ + getInitialState: function() { + return { + anim: 0 + }; + }, + componentDidMount: function() { + return this.interval = setInterval(this.setAnim, 100); + }, + componentWillUnmount: function() { + return clearInterval(this.interval); + }, + setAnim: function() { + var anim; + anim = this.state.anim + 1; + if (anim > 3) { + anim = 0; + } + return this.setState({ + anim: anim + }); + }, + render: function() { + return div({ + className: "spin state-" + this.state.anim + }, ""); + } +}); + + + +},{}],8:[function(require,module,exports){ +var Dispatcher; + +Dispatcher = require('flux').Dispatcher; + +module.exports = _.extend(new Dispatcher(), { + handleServerAction: function(action) { + return this.dispatch({ + source: 'server', + action: action + }); + }, + handleViewAction: function(action) { + return this.dispatch({ + source: 'view', + action: action + }); + } +}); + + + +},{"flux":10}],9:[function(require,module,exports){ +var rend; + +rend = React.render; + +$(function() { + var $body, TreeActions, TreePersistence, body, checkMove, checkScroll, codemirror, frag, head, kids, list, lost, po, setSo, so; + $body = $('body'); + React.initializeTouchEvents(true); + codemirror = React.createFactory(require('./components/CodeMirror.coffee')); + head = React.createFactory(require('./components/AnchorComponent.coffee')); + body = React.createFactory(require('./components/BodyComponent.coffee')); + list = React.createFactory(require('./components/ListComponent.coffee')); + kids = React.createFactory(require('./components/KidsComponent.coffee')); + lost = React.createClass({ + render: function() { + return React.DOM.div({}, "lost"); + } + }); + window.tree._basepath = window.location.pathname; + window.tree._basepath = window.tree._basepath.split("/"); + window.tree._basepath = window.tree._basepath.slice(0, window.tree._basepath.indexOf("tree") + 1); + window.tree._basepath = window.tree._basepath.join("/"); + window.tree.basepath = function(path) { + if (path[0] !== "/") { + path = "/" + path; + } + return window.tree._basepath + path; + }; + window.tree.fragpath = function(path) { + return path.replace(window.tree._basepath, ""); + }; + window.tree.init({ + kids: kids, + list: list, + lost: lost, + codemirror: codemirror + }); + window.tree.reactify = function(str) { + return eval(str); + }; + TreeActions = require('./actions/TreeActions.coffee'); + TreePersistence = require('./persistence/TreePersistence.coffee'); + frag = window.tree.fragpath(window.location.pathname); + TreeActions.setCurr(frag); + TreeActions.loadPath(frag, window.tree.body, window.tree.kids); + rend(head({}, ""), $('#nav')[0]); + rend(body({}, ""), $('#cont')[0]); + checkScroll = function() { + if ($(window).scrollTop() > 20) { + return $('#nav').addClass('scrolling'); + } else { + return $('#nav').removeClass('scrolling'); + } + }; + setInterval(checkScroll, 500); + po = {}; + po.cm = null; + po.lm = null; + po.cs = $(window).scrollTop(); + po.ls = $(window).scrollTop(); + $(document).mousemove(function(e) { + return po.cm = { + x: e.pageX, + y: e.pageY + }; + }); + checkMove = function() { + var ds, dx, dy; + if (po.lm !== null && po.cm !== null) { + po.cs = $(window).scrollTop(); + ds = Math.abs(po.cs - po.ls); + dx = Math.abs(po.cm.x - po.lm.x); + dy = Math.abs(po.cm.y - po.lm.y); + $('#nav').toggleClass('moving', dx > 20 || dy > 20); + } + po.lm = po.cm; + return po.ls = po.cs; + }; + setInterval(checkMove, 200); + so = {}; + so.ls = $(window).scrollTop(); + so.cs = $(window).scrollTop(); + so.w = null; + so.$n = $('#nav'); + so.$d = $('#nav > div'); + so.nh = $('#nav').outerHeight(true); + setSo = function() { + so.w = $(window).width(); + return so.$n = $('#nav'); + }; + setInterval(setSo, 200); + $(window).on('resize', function(e) { + if (so.w > 1170) { + return so.$n.removeClass('m-up m-down m-fixed'); + } + }); + return $(window).on('scroll', function(e) { + var dy, sto, top; + so.cs = $(window).scrollTop(); + if (so.w > 1170) { + so.$n.removeClass('m-up m-down m-fixed'); + } + if (so.w < 1170) { + dy = so.ls - so.cs; + so.$d.removeClass('focus'); + if (so.cs <= 0) { + so.$n.removeClass('m-up'); + so.$n.addClass('m-down m-fixed'); + return; + } + if (so.$n.hasClass('m-fixed' && so.w < 1024)) { + so.$n.css({ + left: -1 * $(window).scrollLeft() + }); + } + if (dy > 0) { + if (!so.$n.hasClass('m-down')) { + so.$n.removeClass('m-up').addClass('m-down'); + top = so.cs - so.nh; + if (top < 0) { + top = 0; + } + so.$n.offset({ + top: top + }); + } + if (so.$n.hasClass('m-down') && !so.$n.hasClass('m-fixed') && so.$n.offset().top >= so.cs) { + so.$n.addClass('m-fixed'); + so.$n.attr({ + style: '' + }); + } + } + if (dy < 0) { + if (!so.$n.hasClass('m-up')) { + so.$n.removeClass('m-down m-fixed').addClass('m-up'); + so.$n.attr({ + style: '' + }); + top = so.cs; + sto = so.$n.offset().top; + if (top < 0) { + top = 0; + } + if (top > sto && top < sto + so.nh) { + top = sto; + } + so.$n.offset({ + top: top + }); + } + } + } + return so.ls = so.cs; + }); +}); + + + +},{"./actions/TreeActions.coffee":1,"./components/AnchorComponent.coffee":2,"./components/BodyComponent.coffee":3,"./components/CodeMirror.coffee":4,"./components/KidsComponent.coffee":5,"./components/ListComponent.coffee":6,"./persistence/TreePersistence.coffee":13}],10:[function(require,module,exports){ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +module.exports.Dispatcher = require('./lib/Dispatcher') + +},{"./lib/Dispatcher":11}],11:[function(require,module,exports){ +/* + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Dispatcher + * @typechecks + */ + +"use strict"; + +var invariant = require('./invariant'); + +var _lastID = 1; +var _prefix = 'ID_'; + +/** + * Dispatcher is used to broadcast payloads to registered callbacks. This is + * different from generic pub-sub systems in two ways: + * + * 1) Callbacks are not subscribed to particular events. Every payload is + * dispatched to every registered callback. + * 2) Callbacks can be deferred in whole or part until other callbacks have + * been executed. + * + * For example, consider this hypothetical flight destination form, which + * selects a default city when a country is selected: + * + * var flightDispatcher = new Dispatcher(); + * + * // Keeps track of which country is selected + * var CountryStore = {country: null}; + * + * // Keeps track of which city is selected + * var CityStore = {city: null}; + * + * // Keeps track of the base flight price of the selected city + * var FlightPriceStore = {price: null} + * + * When a user changes the selected city, we dispatch the payload: + * + * flightDispatcher.dispatch({ + * actionType: 'city-update', + * selectedCity: 'paris' + * }); + * + * This payload is digested by `CityStore`: + * + * flightDispatcher.register(function(payload) { + * if (payload.actionType === 'city-update') { + * CityStore.city = payload.selectedCity; + * } + * }); + * + * When the user selects a country, we dispatch the payload: + * + * flightDispatcher.dispatch({ + * actionType: 'country-update', + * selectedCountry: 'australia' + * }); + * + * This payload is digested by both stores: + * + * CountryStore.dispatchToken = flightDispatcher.register(function(payload) { + * if (payload.actionType === 'country-update') { + * CountryStore.country = payload.selectedCountry; + * } + * }); + * + * When the callback to update `CountryStore` is registered, we save a reference + * to the returned token. Using this token with `waitFor()`, we can guarantee + * that `CountryStore` is updated before the callback that updates `CityStore` + * needs to query its data. + * + * CityStore.dispatchToken = flightDispatcher.register(function(payload) { + * if (payload.actionType === 'country-update') { + * // `CountryStore.country` may not be updated. + * flightDispatcher.waitFor([CountryStore.dispatchToken]); + * // `CountryStore.country` is now guaranteed to be updated. + * + * // Select the default city for the new country + * CityStore.city = getDefaultCityForCountry(CountryStore.country); + * } + * }); + * + * The usage of `waitFor()` can be chained, for example: + * + * FlightPriceStore.dispatchToken = + * flightDispatcher.register(function(payload) { + * switch (payload.actionType) { + * case 'country-update': + * flightDispatcher.waitFor([CityStore.dispatchToken]); + * FlightPriceStore.price = + * getFlightPriceStore(CountryStore.country, CityStore.city); + * break; + * + * case 'city-update': + * FlightPriceStore.price = + * FlightPriceStore(CountryStore.country, CityStore.city); + * break; + * } + * }); + * + * The `country-update` payload will be guaranteed to invoke the stores' + * registered callbacks in order: `CountryStore`, `CityStore`, then + * `FlightPriceStore`. + */ + + function Dispatcher() { + this.$Dispatcher_callbacks = {}; + this.$Dispatcher_isPending = {}; + this.$Dispatcher_isHandled = {}; + this.$Dispatcher_isDispatching = false; + this.$Dispatcher_pendingPayload = null; + } + + /** + * Registers a callback to be invoked with every dispatched payload. Returns + * a token that can be used with `waitFor()`. + * + * @param {function} callback + * @return {string} + */ + Dispatcher.prototype.register=function(callback) { + var id = _prefix + _lastID++; + this.$Dispatcher_callbacks[id] = callback; + return id; + }; + + /** + * Removes a callback based on its token. + * + * @param {string} id + */ + Dispatcher.prototype.unregister=function(id) { + invariant( + this.$Dispatcher_callbacks[id], + 'Dispatcher.unregister(...): `%s` does not map to a registered callback.', + id + ); + delete this.$Dispatcher_callbacks[id]; + }; + + /** + * Waits for the callbacks specified to be invoked before continuing execution + * of the current callback. This method should only be used by a callback in + * response to a dispatched payload. + * + * @param {array} ids + */ + Dispatcher.prototype.waitFor=function(ids) { + invariant( + this.$Dispatcher_isDispatching, + 'Dispatcher.waitFor(...): Must be invoked while dispatching.' + ); + for (var ii = 0; ii < ids.length; ii++) { + var id = ids[ii]; + if (this.$Dispatcher_isPending[id]) { + invariant( + this.$Dispatcher_isHandled[id], + 'Dispatcher.waitFor(...): Circular dependency detected while ' + + 'waiting for `%s`.', + id + ); + continue; + } + invariant( + this.$Dispatcher_callbacks[id], + 'Dispatcher.waitFor(...): `%s` does not map to a registered callback.', + id + ); + this.$Dispatcher_invokeCallback(id); + } + }; + + /** + * Dispatches a payload to all registered callbacks. + * + * @param {object} payload + */ + Dispatcher.prototype.dispatch=function(payload) { + invariant( + !this.$Dispatcher_isDispatching, + 'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.' + ); + this.$Dispatcher_startDispatching(payload); + try { + for (var id in this.$Dispatcher_callbacks) { + if (this.$Dispatcher_isPending[id]) { + continue; + } + this.$Dispatcher_invokeCallback(id); + } + } finally { + this.$Dispatcher_stopDispatching(); + } + }; + + /** + * Is this Dispatcher currently dispatching. + * + * @return {boolean} + */ + Dispatcher.prototype.isDispatching=function() { + return this.$Dispatcher_isDispatching; + }; + + /** + * Call the callback stored with the given id. Also do some internal + * bookkeeping. + * + * @param {string} id + * @internal + */ + Dispatcher.prototype.$Dispatcher_invokeCallback=function(id) { + this.$Dispatcher_isPending[id] = true; + this.$Dispatcher_callbacks[id](this.$Dispatcher_pendingPayload); + this.$Dispatcher_isHandled[id] = true; + }; + + /** + * Set up bookkeeping needed when dispatching. + * + * @param {object} payload + * @internal + */ + Dispatcher.prototype.$Dispatcher_startDispatching=function(payload) { + for (var id in this.$Dispatcher_callbacks) { + this.$Dispatcher_isPending[id] = false; + this.$Dispatcher_isHandled[id] = false; + } + this.$Dispatcher_pendingPayload = payload; + this.$Dispatcher_isDispatching = true; + }; + + /** + * Clear bookkeeping used for dispatching. + * + * @internal + */ + Dispatcher.prototype.$Dispatcher_stopDispatching=function() { + this.$Dispatcher_pendingPayload = null; + this.$Dispatcher_isDispatching = false; + }; + + +module.exports = Dispatcher; + +},{"./invariant":12}],12:[function(require,module,exports){ +/** + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule invariant + */ + +"use strict"; + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +var invariant = function(condition, format, a, b, c, d, e, f) { + if (false) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + } + + if (!condition) { + var error; + if (format === undefined) { + error = new Error( + 'Minified exception occurred; use the non-minified dev environment ' + + 'for the full error message and additional helpful warnings.' + ); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error( + 'Invariant Violation: ' + + format.replace(/%s/g, function() { return args[argIndex++]; }) + ); + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +}; + +module.exports = invariant; + +},{}],13:[function(require,module,exports){ +var TreeActions; + +TreeActions = require('../actions/TreeActions.coffee'); + +module.exports = { + get: function(path, query, cb) { + var url; + url = (window.tree.basepath(path)) + ".json"; + if (query) { + url += "?" + query; + } + return $.get(url, {}, function(data) { + if (cb) { + return cb(null, data); + } + }); + } +}; + + + +},{"../actions/TreeActions.coffee":1}],14:[function(require,module,exports){ +var EventEmitter, MessageDispatcher, TreeStore, _cont, _curr, _load, _snip, _tree; + +EventEmitter = require('events').EventEmitter; + +MessageDispatcher = require('../dispatcher/Dispatcher.coffee'); + +_tree = {}; + +_cont = {}; + +_snip = {}; + +_load = false; + +_curr = ""; + +TreeStore = _.extend(EventEmitter.prototype, { + addChangeListener: function(cb) { + return this.on('change', cb); + }, + removeChangeListener: function(cb) { + return this.removeListener("change", cb); + }, + emitChange: function() { + return this.emit('change'); + }, + pathToArr: function(_path) { + return _path.split("/"); + }, + pathToObj: function(_path, _obj, kids) { + var __path, i, j, l, ref, ref1, results; + __path = this.pathToArr(_path); + for (i = j = 0, ref = __path.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { + _obj = _obj[__path[i]] = {}; + } + if ((kids != null ? kids.length : void 0) > 0) { + results = []; + for (i = l = 0, ref1 = kids.length - 1; 0 <= ref1 ? l <= ref1 : l >= ref1; i = 0 <= ref1 ? ++l : --l) { + results.push(_obj[kids[i]] = {}); + } + return results; + } + }, + getTree: function(_path) { + var i, j, ref, tree; + tree = _tree; + if (_path.length > 0) { + for (i = j = 0, ref = _path.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { + if (tree[_path[i]]) { + tree = tree[_path[i]]; + } else { + return null; + } + } + } + return tree; + }, + setCurr: function(path) { + return _curr = path; + }, + getCurr: function() { + return _curr; + }, + getCont: function() { + return _cont; + }, + setLoad: function(load) { + return _load = load; + }, + getLoad: function() { + return _load; + }, + mergePathToTree: function(path, kids) { + var _obj; + _obj = {}; + this.pathToObj(path, _obj, kids); + return _.merge(_tree, _obj); + }, + getSnip: function() { + return _snip; + }, + loadSnip: function(path, snip) { + var k, results, v; + this.mergePathToTree(path, _.pluck(snip, "name")); + results = []; + for (k in snip) { + v = snip[k]; + results.push(_snip[path + "/" + v.name] = { + head: window.tree.reactify(v.body.head), + body: window.tree.reactify(v.body.body) + }); + } + return results; + }, + loadKids: function(path, kids) { + var k, results, v; + this.mergePathToTree(path, _.pluck(kids, "name")); + results = []; + for (k in kids) { + v = kids[k]; + results.push(_cont[path + "/" + v.name] = window.tree.reactify(v.body)); + } + return results; + }, + loadPath: function(path, body, kids) { + this.mergePathToTree(path, kids); + return _cont[path] = window.tree.reactify(body); + }, + getKids: function() { + return _.keys(this.getTree(_curr.split("/"))); + }, + getSiblings: function() { + var curr; + curr = _curr.split("/"); + curr.pop(); + if (curr.length !== 0) { + return this.getTree(curr); + } else { + return {}; + } + }, + getPrev: function() { + var ind, key, par, sibs, win; + sibs = _.keys(this.getSiblings()).sort(); + if (sibs.length < 2) { + return null; + } else { + par = _curr.split("/"); + key = par.pop(); + ind = sibs.indexOf(key); + win = ind - 1 >= 0 ? sibs[ind - 1] : sibs[sibs.length - 1]; + par.push(win); + return par.join("/"); + } + }, + getNext: function() { + var ind, key, par, sibs, win; + sibs = _.keys(this.getSiblings()).sort(); + if (sibs.length < 2) { + return null; + } else { + par = _curr.split("/"); + key = par.pop(); + ind = sibs.indexOf(key); + win = ind + 1 < sibs.length ? sibs[ind + 1] : sibs[0]; + par.push(win); + return par.join("/"); + } + }, + getPare: function() { + var _path; + _path = this.pathToArr(_curr); + if (_path.length > 1) { + _path.pop(); + _path = _path.join("/"); + if (_path === "") { + _path = "/"; + } + return _path; + } else { + return null; + } + }, + getCrumbs: function() { + var _path, crum, crums, k, v; + _path = this.pathToArr(_curr); + crum = ""; + crums = []; + for (k in _path) { + v = _path[k]; + crum += "/" + v; + crums.push({ + name: v, + path: crum + }); + } + return crums; + }, + getBody: function() { + if (_cont[_curr]) { + return _cont[_curr]; + } else { + return null; + } + } +}); + +TreeStore.dispatchToken = MessageDispatcher.register(function(payload) { + var action; + action = payload.action; + switch (action.type) { + case 'path-load': + TreeStore.loadPath(action.path, action.body, action.kids, action.snip); + return TreeStore.emitChange(); + case 'snip-load': + TreeStore.loadSnip(action.path, action.snip); + return TreeStore.emitChange(); + case 'kids-load': + TreeStore.loadKids(action.path, action.kids); + return TreeStore.emitChange(); + case 'set-curr': + TreeStore.setCurr(action.path); + return TreeStore.emitChange(); + case 'set-load': + TreeStore.setLoad(action.load); + return TreeStore.emitChange(); + } +}); + +module.exports = TreeStore; + + + +},{"../dispatcher/Dispatcher.coffee":8,"events":15}],15:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } + throw TypeError('Uncaught, unspecified "error" event.'); + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + len = arguments.length; + args = new Array(len - 1); + for (i = 1; i < len; i++) + args[i - 1] = arguments[i]; + handler.apply(this, args); + } + } else if (isObject(handler)) { + len = arguments.length; + args = new Array(len - 1); + for (i = 1; i < len; i++) + args[i - 1] = arguments[i]; + + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + var m; + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.listenerCount = function(emitter, type) { + var ret; + if (!emitter._events || !emitter._events[type]) + ret = 0; + else if (isFunction(emitter._events[type])) + ret = 1; + else + ret = emitter._events[type].length; + return ret; +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + +},{}]},{},[9]); From 5ffead0ec0dce8db3c5f21c92882492232599556 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 26 May 2015 14:23:39 -0700 Subject: [PATCH 29/34] re-add CM react --- base/pub/tree/src/js/components/CodeMirror.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 base/pub/tree/src/js/components/CodeMirror.coffee diff --git a/base/pub/tree/src/js/components/CodeMirror.coffee b/base/pub/tree/src/js/components/CodeMirror.coffee new file mode 100644 index 000000000..0e4f36c22 --- /dev/null +++ b/base/pub/tree/src/js/components/CodeMirror.coffee @@ -0,0 +1,8 @@ +recl = React.createClass +[div,textarea] = [React.DOM.div,React.DOM.textarea] + +module.exports = recl + render: -> div {}, textarea ref:'ed', value:@props.value + componentDidMount: -> + CodeMirror.fromTextArea @refs.ed.getDOMNode(), + readOnly:true From 06384f6bc0b8355579ef909ed001cc36b2206ce4 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 26 May 2015 14:23:39 -0700 Subject: [PATCH 30/34] re-add CM react --- base/pub/tree/src/js/components/CodeMirror.coffee | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 base/pub/tree/src/js/components/CodeMirror.coffee diff --git a/base/pub/tree/src/js/components/CodeMirror.coffee b/base/pub/tree/src/js/components/CodeMirror.coffee new file mode 100644 index 000000000..0e4f36c22 --- /dev/null +++ b/base/pub/tree/src/js/components/CodeMirror.coffee @@ -0,0 +1,8 @@ +recl = React.createClass +[div,textarea] = [React.DOM.div,React.DOM.textarea] + +module.exports = recl + render: -> div {}, textarea ref:'ed', value:@props.value + componentDidMount: -> + CodeMirror.fromTextArea @refs.ed.getDOMNode(), + readOnly:true From 991bc3fb3daa4db19a447c0ae1a034eea9b6fde8 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 26 May 2015 14:22:49 -0700 Subject: [PATCH 31/34] working tree js --- base/pub/tree/src/js/main.js | 1627 +++++++++++++++++++++++++++++++++- 1 file changed, 1626 insertions(+), 1 deletion(-) diff --git a/base/pub/tree/src/js/main.js b/base/pub/tree/src/js/main.js index bd931c056..13fe9c736 100644 --- a/base/pub/tree/src/js/main.js +++ b/base/pub/tree/src/js/main.js @@ -1 +1,1626 @@ -console.error("Error: Cannot find module '/Users/pittyp/temp/urb/zod/base/pub/tree/src/js/node_modules/coffeeify/index.js' from '/Users/pittyp/temp/urb/zod/base/pub/tree/src/js'") \ No newline at end of file +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { + p = curr.split("/"); + curr = p.pop(); + up = p.join("/"); + ci = 0; + k = 0; + sibs = _.map(_.keys(this.state.sibs).sort(), (function(_this) { + return function(i) { + var c; + c = ""; + if (curr === i) { + c = "active"; + ci = k; + } + k++; + href = window.tree.basepath(up + "/" + i); + return div({ + className: c + }, a({ + key: i + "-a", + href: href, + onClick: _this._click + }, i)); + }; + })(this)); + offset = 0; + if (ci > 0) { + offset = 0; + } + s = { + marginTop: ((ci * -24) - offset) + "px" + }; + parts.push(div({ + key: "sibs", + id: "sibs", + style: s + }, sibs)); + } + obj = { + onMouseOver: this._mouseOver, + onMouseOut: this._mouseOut, + onClick: this._click, + onTouchStart: this._touchStart, + onTouchEnd: this._touchEnd + }; + if (_.keys(window).indexOf("ontouchstart") !== -1) { + delete obj.onMouseOver; + delete obj.onMouseOut; + } + return div(obj, parts); + } +}); + + + +},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14}],3:[function(require,module,exports){ +var TreeActions, TreeStore, div, input, load, recl, ref, textarea; + +TreeStore = require('../stores/TreeStore.coffee'); + +TreeActions = require('../actions/TreeActions.coffee'); + +load = require('./LoadComponent.coffee'); + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; + +module.exports = recl({ + stateFromStore: function() { + return { + body: TreeStore.getBody(), + load: TreeStore.getLoad(), + curr: TreeStore.getCurr(), + cont: TreeStore.getCont() + }; + }, + componentDidMount: function() { + return TreeStore.addChangeListener(this._onChangeStore); + }, + componentDidUpdate: function(_props, _state) { + if (_state.curr !== this.state.curr) { + return setTimeout(((function(_this) { + return function() { + return _this.getPath(_state.curr); + }; + })(this)), 0); + } + }, + getInitialState: function() { + return this.stateFromStore(); + }, + _onChangeStore: function() { + return this.setState(this.stateFromStore()); + }, + getPath: function(path) { + if (this.state.cont[path] == null) { + TreeActions.setLoading(true); + return TreeActions.getPath(path, (function(_this) { + return function() { + return TreeActions.setLoading(false); + }; + })(this)); + } + }, + render: function() { + var parts, ref1; + parts = []; + parts.push(div({ + id: 'body', + key: "body" + this.state.curr + }, (ref1 = this.state.body) != null ? ref1 : div({ + className: "loading" + }, load({}, "")))); + return div({}, parts); + } +}); + + + +},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14,"./LoadComponent.coffee":7}],4:[function(require,module,exports){ +var div, recl, ref, textarea; + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.textarea], div = ref[0], textarea = ref[1]; + +module.exports = recl({ + render: function() { + return div({}, textarea({ + ref: 'ed', + value: this.props.value + })); + }, + componentDidMount: function() { + return CodeMirror.fromTextArea(this.refs.ed.getDOMNode(), { + readOnly: true + }); + } +}); + + + +},{}],5:[function(require,module,exports){ +var TreeActions, TreeStore, a, div, hr, li, recl, ref, ul; + +TreeStore = require('../stores/TreeStore.coffee'); + +TreeActions = require('../actions/TreeActions.coffee'); + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.a, React.DOM.ul, React.DOM.li, React.DOM.hr], div = ref[0], a = ref[1], ul = ref[2], li = ref[3], hr = ref[4]; + +module.exports = recl({ + stateFromStore: function() { + var path, ref1; + path = (ref1 = this.props.dataPath) != null ? ref1 : TreeStore.getCurr(); + return { + cont: TreeStore.getCont(), + tree: TreeStore.getTree(path.split("/")), + path: path + }; + }, + componentDidMount: function() { + return TreeStore.addChangeListener(this._onChangeStore); + }, + getInitialState: function() { + return this.stateFromStore(); + }, + _onChangeStore: function() { + return this.setState(this.stateFromStore()); + }, + componentDidMount: function() { + var cont, i, k, len, ref1; + cont = true; + ref1 = _.keys(this.state.tree); + for (i = 0, len = ref1.length; i < len; i++) { + k = ref1[i]; + if (!this.state.cont[this.state.path + "/" + k]) { + cont = false; + } + } + if (!this.state.tree || _.keys(this.state.tree).length === 0 || !cont) { + return TreeActions.getPath(this.state.path, "kids"); + } + }, + render: function() { + var _list, doc, ref1; + doc = (ref1 = this.state.tree) != null ? ref1 : []; + _list = _.map(_.keys(doc).sort(), (function(_this) { + return function(v) { + var _path; + _path = _this.state.path + "/" + v; + return [ + div({ + key: "kid-" + v + }, _this.state.cont[_path]), hr({}, "") + ]; + }; + })(this)); + return div({ + key: "kids-" + this.state.path, + className: "kids" + }, _list); + } +}); + + + +},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14}],6:[function(require,module,exports){ +var TreeActions, TreeStore, a, div, h1, li, load, recl, ref, ul; + +TreeStore = require('../stores/TreeStore.coffee'); + +TreeActions = require('../actions/TreeActions.coffee'); + +load = require('./LoadComponent.coffee'); + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.a, React.DOM.ul, React.DOM.li, React.DOM.h1], div = ref[0], a = ref[1], ul = ref[2], li = ref[3], h1 = ref[4]; + +module.exports = recl({ + stateFromStore: function() { + var path, ref1; + path = (ref1 = this.props.dataPath) != null ? ref1 : TreeStore.getCurr(); + return { + snip: TreeStore.getSnip(), + tree: TreeStore.getTree(path.split("/")), + path: path + }; + }, + componentDidMount: function() { + return TreeStore.addChangeListener(this._onChangeStore); + }, + getInitialState: function() { + return this.stateFromStore(); + }, + _onChangeStore: function() { + return this.setState(this.stateFromStore()); + }, + getCont: function() { + var cont, i, k, keys, len; + cont = true; + keys = _.keys(this.state.tree); + for (i = 0, len = keys.length; i < len; i++) { + k = keys[i]; + if (!this.state.snip[this.state.path + "/" + k]) { + cont = false; + } + } + if (keys.length === 0) { + cont = false; + } + return cont; + }, + componentDidMount: function() { + var cont; + cont = this.getCont(); + if (!this.state.tree || _.keys(this.state.tree).length === 0 || !cont) { + return TreeActions.getPath(this.state.path, "snip"); + } + }, + render: function() { + var _list, doc, ref1; + doc = (ref1 = this.state.tree) != null ? ref1 : []; + if (!this.getCont()) { + _list = div({ + className: "loading" + }, load({}, "")); + } else { + _list = _.map(_.keys(doc).sort(), (function(_this) { + return function(v) { + var _path, c, href, prev; + _path = _this.state.path + "/" + v; + if (_this.props.dataPreview != null) { + c = "preview"; + if (_this.props.titlesOnly) { + prev = _this.state.snip[_path].head; + } else { + prev = _this.state.snip[_path]; + } + } else { + c = ""; + prev = h1({}, v); + } + href = window.tree.basepath(_path); + return li({}, a({ + href: href, + className: c, + key: "list-a-" + _path + }, prev)); + }; + })(this)); + } + return ul({ + className: "list", + key: "list-" + this.state.path + }, _list); + } +}); + + + +},{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14,"./LoadComponent.coffee":7}],7:[function(require,module,exports){ +var div, input, recl, ref, textarea; + +recl = React.createClass; + +ref = [React.DOM.div, React.DOM.input, React.DOM.textarea], div = ref[0], input = ref[1], textarea = ref[2]; + +module.exports = recl({ + getInitialState: function() { + return { + anim: 0 + }; + }, + componentDidMount: function() { + return this.interval = setInterval(this.setAnim, 100); + }, + componentWillUnmount: function() { + return clearInterval(this.interval); + }, + setAnim: function() { + var anim; + anim = this.state.anim + 1; + if (anim > 3) { + anim = 0; + } + return this.setState({ + anim: anim + }); + }, + render: function() { + return div({ + className: "spin state-" + this.state.anim + }, ""); + } +}); + + + +},{}],8:[function(require,module,exports){ +var Dispatcher; + +Dispatcher = require('flux').Dispatcher; + +module.exports = _.extend(new Dispatcher(), { + handleServerAction: function(action) { + return this.dispatch({ + source: 'server', + action: action + }); + }, + handleViewAction: function(action) { + return this.dispatch({ + source: 'view', + action: action + }); + } +}); + + + +},{"flux":10}],9:[function(require,module,exports){ +var rend; + +rend = React.render; + +$(function() { + var $body, TreeActions, TreePersistence, body, checkMove, checkScroll, codemirror, frag, head, kids, list, lost, po, setSo, so; + $body = $('body'); + React.initializeTouchEvents(true); + codemirror = React.createFactory(require('./components/CodeMirror.coffee')); + head = React.createFactory(require('./components/AnchorComponent.coffee')); + body = React.createFactory(require('./components/BodyComponent.coffee')); + list = React.createFactory(require('./components/ListComponent.coffee')); + kids = React.createFactory(require('./components/KidsComponent.coffee')); + lost = React.createClass({ + render: function() { + return React.DOM.div({}, "lost"); + } + }); + window.tree._basepath = window.location.pathname; + window.tree._basepath = window.tree._basepath.split("/"); + window.tree._basepath = window.tree._basepath.slice(0, window.tree._basepath.indexOf("tree") + 1); + window.tree._basepath = window.tree._basepath.join("/"); + window.tree.basepath = function(path) { + if (path[0] !== "/") { + path = "/" + path; + } + return window.tree._basepath + path; + }; + window.tree.fragpath = function(path) { + return path.replace(window.tree._basepath, ""); + }; + window.tree.init({ + kids: kids, + list: list, + lost: lost, + codemirror: codemirror + }); + window.tree.reactify = function(str) { + return eval(str); + }; + TreeActions = require('./actions/TreeActions.coffee'); + TreePersistence = require('./persistence/TreePersistence.coffee'); + frag = window.tree.fragpath(window.location.pathname); + TreeActions.setCurr(frag); + TreeActions.loadPath(frag, window.tree.body, window.tree.kids); + rend(head({}, ""), $('#nav')[0]); + rend(body({}, ""), $('#cont')[0]); + checkScroll = function() { + if ($(window).scrollTop() > 20) { + return $('#nav').addClass('scrolling'); + } else { + return $('#nav').removeClass('scrolling'); + } + }; + setInterval(checkScroll, 500); + po = {}; + po.cm = null; + po.lm = null; + po.cs = $(window).scrollTop(); + po.ls = $(window).scrollTop(); + $(document).mousemove(function(e) { + return po.cm = { + x: e.pageX, + y: e.pageY + }; + }); + checkMove = function() { + var ds, dx, dy; + if (po.lm !== null && po.cm !== null) { + po.cs = $(window).scrollTop(); + ds = Math.abs(po.cs - po.ls); + dx = Math.abs(po.cm.x - po.lm.x); + dy = Math.abs(po.cm.y - po.lm.y); + $('#nav').toggleClass('moving', dx > 20 || dy > 20); + } + po.lm = po.cm; + return po.ls = po.cs; + }; + setInterval(checkMove, 200); + so = {}; + so.ls = $(window).scrollTop(); + so.cs = $(window).scrollTop(); + so.w = null; + so.$n = $('#nav'); + so.$d = $('#nav > div'); + so.nh = $('#nav').outerHeight(true); + setSo = function() { + so.w = $(window).width(); + return so.$n = $('#nav'); + }; + setInterval(setSo, 200); + $(window).on('resize', function(e) { + if (so.w > 1170) { + return so.$n.removeClass('m-up m-down m-fixed'); + } + }); + return $(window).on('scroll', function(e) { + var dy, sto, top; + so.cs = $(window).scrollTop(); + if (so.w > 1170) { + so.$n.removeClass('m-up m-down m-fixed'); + } + if (so.w < 1170) { + dy = so.ls - so.cs; + so.$d.removeClass('focus'); + if (so.cs <= 0) { + so.$n.removeClass('m-up'); + so.$n.addClass('m-down m-fixed'); + return; + } + if (so.$n.hasClass('m-fixed' && so.w < 1024)) { + so.$n.css({ + left: -1 * $(window).scrollLeft() + }); + } + if (dy > 0) { + if (!so.$n.hasClass('m-down')) { + so.$n.removeClass('m-up').addClass('m-down'); + top = so.cs - so.nh; + if (top < 0) { + top = 0; + } + so.$n.offset({ + top: top + }); + } + if (so.$n.hasClass('m-down') && !so.$n.hasClass('m-fixed') && so.$n.offset().top >= so.cs) { + so.$n.addClass('m-fixed'); + so.$n.attr({ + style: '' + }); + } + } + if (dy < 0) { + if (!so.$n.hasClass('m-up')) { + so.$n.removeClass('m-down m-fixed').addClass('m-up'); + so.$n.attr({ + style: '' + }); + top = so.cs; + sto = so.$n.offset().top; + if (top < 0) { + top = 0; + } + if (top > sto && top < sto + so.nh) { + top = sto; + } + so.$n.offset({ + top: top + }); + } + } + } + return so.ls = so.cs; + }); +}); + + + +},{"./actions/TreeActions.coffee":1,"./components/AnchorComponent.coffee":2,"./components/BodyComponent.coffee":3,"./components/CodeMirror.coffee":4,"./components/KidsComponent.coffee":5,"./components/ListComponent.coffee":6,"./persistence/TreePersistence.coffee":13}],10:[function(require,module,exports){ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +module.exports.Dispatcher = require('./lib/Dispatcher') + +},{"./lib/Dispatcher":11}],11:[function(require,module,exports){ +/* + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule Dispatcher + * @typechecks + */ + +"use strict"; + +var invariant = require('./invariant'); + +var _lastID = 1; +var _prefix = 'ID_'; + +/** + * Dispatcher is used to broadcast payloads to registered callbacks. This is + * different from generic pub-sub systems in two ways: + * + * 1) Callbacks are not subscribed to particular events. Every payload is + * dispatched to every registered callback. + * 2) Callbacks can be deferred in whole or part until other callbacks have + * been executed. + * + * For example, consider this hypothetical flight destination form, which + * selects a default city when a country is selected: + * + * var flightDispatcher = new Dispatcher(); + * + * // Keeps track of which country is selected + * var CountryStore = {country: null}; + * + * // Keeps track of which city is selected + * var CityStore = {city: null}; + * + * // Keeps track of the base flight price of the selected city + * var FlightPriceStore = {price: null} + * + * When a user changes the selected city, we dispatch the payload: + * + * flightDispatcher.dispatch({ + * actionType: 'city-update', + * selectedCity: 'paris' + * }); + * + * This payload is digested by `CityStore`: + * + * flightDispatcher.register(function(payload) { + * if (payload.actionType === 'city-update') { + * CityStore.city = payload.selectedCity; + * } + * }); + * + * When the user selects a country, we dispatch the payload: + * + * flightDispatcher.dispatch({ + * actionType: 'country-update', + * selectedCountry: 'australia' + * }); + * + * This payload is digested by both stores: + * + * CountryStore.dispatchToken = flightDispatcher.register(function(payload) { + * if (payload.actionType === 'country-update') { + * CountryStore.country = payload.selectedCountry; + * } + * }); + * + * When the callback to update `CountryStore` is registered, we save a reference + * to the returned token. Using this token with `waitFor()`, we can guarantee + * that `CountryStore` is updated before the callback that updates `CityStore` + * needs to query its data. + * + * CityStore.dispatchToken = flightDispatcher.register(function(payload) { + * if (payload.actionType === 'country-update') { + * // `CountryStore.country` may not be updated. + * flightDispatcher.waitFor([CountryStore.dispatchToken]); + * // `CountryStore.country` is now guaranteed to be updated. + * + * // Select the default city for the new country + * CityStore.city = getDefaultCityForCountry(CountryStore.country); + * } + * }); + * + * The usage of `waitFor()` can be chained, for example: + * + * FlightPriceStore.dispatchToken = + * flightDispatcher.register(function(payload) { + * switch (payload.actionType) { + * case 'country-update': + * flightDispatcher.waitFor([CityStore.dispatchToken]); + * FlightPriceStore.price = + * getFlightPriceStore(CountryStore.country, CityStore.city); + * break; + * + * case 'city-update': + * FlightPriceStore.price = + * FlightPriceStore(CountryStore.country, CityStore.city); + * break; + * } + * }); + * + * The `country-update` payload will be guaranteed to invoke the stores' + * registered callbacks in order: `CountryStore`, `CityStore`, then + * `FlightPriceStore`. + */ + + function Dispatcher() { + this.$Dispatcher_callbacks = {}; + this.$Dispatcher_isPending = {}; + this.$Dispatcher_isHandled = {}; + this.$Dispatcher_isDispatching = false; + this.$Dispatcher_pendingPayload = null; + } + + /** + * Registers a callback to be invoked with every dispatched payload. Returns + * a token that can be used with `waitFor()`. + * + * @param {function} callback + * @return {string} + */ + Dispatcher.prototype.register=function(callback) { + var id = _prefix + _lastID++; + this.$Dispatcher_callbacks[id] = callback; + return id; + }; + + /** + * Removes a callback based on its token. + * + * @param {string} id + */ + Dispatcher.prototype.unregister=function(id) { + invariant( + this.$Dispatcher_callbacks[id], + 'Dispatcher.unregister(...): `%s` does not map to a registered callback.', + id + ); + delete this.$Dispatcher_callbacks[id]; + }; + + /** + * Waits for the callbacks specified to be invoked before continuing execution + * of the current callback. This method should only be used by a callback in + * response to a dispatched payload. + * + * @param {array} ids + */ + Dispatcher.prototype.waitFor=function(ids) { + invariant( + this.$Dispatcher_isDispatching, + 'Dispatcher.waitFor(...): Must be invoked while dispatching.' + ); + for (var ii = 0; ii < ids.length; ii++) { + var id = ids[ii]; + if (this.$Dispatcher_isPending[id]) { + invariant( + this.$Dispatcher_isHandled[id], + 'Dispatcher.waitFor(...): Circular dependency detected while ' + + 'waiting for `%s`.', + id + ); + continue; + } + invariant( + this.$Dispatcher_callbacks[id], + 'Dispatcher.waitFor(...): `%s` does not map to a registered callback.', + id + ); + this.$Dispatcher_invokeCallback(id); + } + }; + + /** + * Dispatches a payload to all registered callbacks. + * + * @param {object} payload + */ + Dispatcher.prototype.dispatch=function(payload) { + invariant( + !this.$Dispatcher_isDispatching, + 'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.' + ); + this.$Dispatcher_startDispatching(payload); + try { + for (var id in this.$Dispatcher_callbacks) { + if (this.$Dispatcher_isPending[id]) { + continue; + } + this.$Dispatcher_invokeCallback(id); + } + } finally { + this.$Dispatcher_stopDispatching(); + } + }; + + /** + * Is this Dispatcher currently dispatching. + * + * @return {boolean} + */ + Dispatcher.prototype.isDispatching=function() { + return this.$Dispatcher_isDispatching; + }; + + /** + * Call the callback stored with the given id. Also do some internal + * bookkeeping. + * + * @param {string} id + * @internal + */ + Dispatcher.prototype.$Dispatcher_invokeCallback=function(id) { + this.$Dispatcher_isPending[id] = true; + this.$Dispatcher_callbacks[id](this.$Dispatcher_pendingPayload); + this.$Dispatcher_isHandled[id] = true; + }; + + /** + * Set up bookkeeping needed when dispatching. + * + * @param {object} payload + * @internal + */ + Dispatcher.prototype.$Dispatcher_startDispatching=function(payload) { + for (var id in this.$Dispatcher_callbacks) { + this.$Dispatcher_isPending[id] = false; + this.$Dispatcher_isHandled[id] = false; + } + this.$Dispatcher_pendingPayload = payload; + this.$Dispatcher_isDispatching = true; + }; + + /** + * Clear bookkeeping used for dispatching. + * + * @internal + */ + Dispatcher.prototype.$Dispatcher_stopDispatching=function() { + this.$Dispatcher_pendingPayload = null; + this.$Dispatcher_isDispatching = false; + }; + + +module.exports = Dispatcher; + +},{"./invariant":12}],12:[function(require,module,exports){ +/** + * Copyright (c) 2014, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule invariant + */ + +"use strict"; + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +var invariant = function(condition, format, a, b, c, d, e, f) { + if (false) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + } + + if (!condition) { + var error; + if (format === undefined) { + error = new Error( + 'Minified exception occurred; use the non-minified dev environment ' + + 'for the full error message and additional helpful warnings.' + ); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error( + 'Invariant Violation: ' + + format.replace(/%s/g, function() { return args[argIndex++]; }) + ); + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +}; + +module.exports = invariant; + +},{}],13:[function(require,module,exports){ +var TreeActions; + +TreeActions = require('../actions/TreeActions.coffee'); + +module.exports = { + get: function(path, query, cb) { + var url; + url = (window.tree.basepath(path)) + ".json"; + if (query) { + url += "?" + query; + } + return $.get(url, {}, function(data) { + if (cb) { + return cb(null, data); + } + }); + } +}; + + + +},{"../actions/TreeActions.coffee":1}],14:[function(require,module,exports){ +var EventEmitter, MessageDispatcher, TreeStore, _cont, _curr, _load, _snip, _tree; + +EventEmitter = require('events').EventEmitter; + +MessageDispatcher = require('../dispatcher/Dispatcher.coffee'); + +_tree = {}; + +_cont = {}; + +_snip = {}; + +_load = false; + +_curr = ""; + +TreeStore = _.extend(EventEmitter.prototype, { + addChangeListener: function(cb) { + return this.on('change', cb); + }, + removeChangeListener: function(cb) { + return this.removeListener("change", cb); + }, + emitChange: function() { + return this.emit('change'); + }, + pathToArr: function(_path) { + return _path.split("/"); + }, + pathToObj: function(_path, _obj, kids) { + var __path, i, j, l, ref, ref1, results; + __path = this.pathToArr(_path); + for (i = j = 0, ref = __path.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { + _obj = _obj[__path[i]] = {}; + } + if ((kids != null ? kids.length : void 0) > 0) { + results = []; + for (i = l = 0, ref1 = kids.length - 1; 0 <= ref1 ? l <= ref1 : l >= ref1; i = 0 <= ref1 ? ++l : --l) { + results.push(_obj[kids[i]] = {}); + } + return results; + } + }, + getTree: function(_path) { + var i, j, ref, tree; + tree = _tree; + if (_path.length > 0) { + for (i = j = 0, ref = _path.length - 1; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) { + if (tree[_path[i]]) { + tree = tree[_path[i]]; + } else { + return null; + } + } + } + return tree; + }, + setCurr: function(path) { + return _curr = path; + }, + getCurr: function() { + return _curr; + }, + getCont: function() { + return _cont; + }, + setLoad: function(load) { + return _load = load; + }, + getLoad: function() { + return _load; + }, + mergePathToTree: function(path, kids) { + var _obj; + _obj = {}; + this.pathToObj(path, _obj, kids); + return _.merge(_tree, _obj); + }, + getSnip: function() { + return _snip; + }, + loadSnip: function(path, snip) { + var k, results, v; + this.mergePathToTree(path, _.pluck(snip, "name")); + results = []; + for (k in snip) { + v = snip[k]; + results.push(_snip[path + "/" + v.name] = { + head: window.tree.reactify(v.body.head), + body: window.tree.reactify(v.body.body) + }); + } + return results; + }, + loadKids: function(path, kids) { + var k, results, v; + this.mergePathToTree(path, _.pluck(kids, "name")); + results = []; + for (k in kids) { + v = kids[k]; + results.push(_cont[path + "/" + v.name] = window.tree.reactify(v.body)); + } + return results; + }, + loadPath: function(path, body, kids) { + this.mergePathToTree(path, kids); + return _cont[path] = window.tree.reactify(body); + }, + getKids: function() { + return _.keys(this.getTree(_curr.split("/"))); + }, + getSiblings: function() { + var curr; + curr = _curr.split("/"); + curr.pop(); + if (curr.length !== 0) { + return this.getTree(curr); + } else { + return {}; + } + }, + getPrev: function() { + var ind, key, par, sibs, win; + sibs = _.keys(this.getSiblings()).sort(); + if (sibs.length < 2) { + return null; + } else { + par = _curr.split("/"); + key = par.pop(); + ind = sibs.indexOf(key); + win = ind - 1 >= 0 ? sibs[ind - 1] : sibs[sibs.length - 1]; + par.push(win); + return par.join("/"); + } + }, + getNext: function() { + var ind, key, par, sibs, win; + sibs = _.keys(this.getSiblings()).sort(); + if (sibs.length < 2) { + return null; + } else { + par = _curr.split("/"); + key = par.pop(); + ind = sibs.indexOf(key); + win = ind + 1 < sibs.length ? sibs[ind + 1] : sibs[0]; + par.push(win); + return par.join("/"); + } + }, + getPare: function() { + var _path; + _path = this.pathToArr(_curr); + if (_path.length > 1) { + _path.pop(); + _path = _path.join("/"); + if (_path === "") { + _path = "/"; + } + return _path; + } else { + return null; + } + }, + getCrumbs: function() { + var _path, crum, crums, k, v; + _path = this.pathToArr(_curr); + crum = ""; + crums = []; + for (k in _path) { + v = _path[k]; + crum += "/" + v; + crums.push({ + name: v, + path: crum + }); + } + return crums; + }, + getBody: function() { + if (_cont[_curr]) { + return _cont[_curr]; + } else { + return null; + } + } +}); + +TreeStore.dispatchToken = MessageDispatcher.register(function(payload) { + var action; + action = payload.action; + switch (action.type) { + case 'path-load': + TreeStore.loadPath(action.path, action.body, action.kids, action.snip); + return TreeStore.emitChange(); + case 'snip-load': + TreeStore.loadSnip(action.path, action.snip); + return TreeStore.emitChange(); + case 'kids-load': + TreeStore.loadKids(action.path, action.kids); + return TreeStore.emitChange(); + case 'set-curr': + TreeStore.setCurr(action.path); + return TreeStore.emitChange(); + case 'set-load': + TreeStore.setLoad(action.load); + return TreeStore.emitChange(); + } +}); + +module.exports = TreeStore; + + + +},{"../dispatcher/Dispatcher.coffee":8,"events":15}],15:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } + throw TypeError('Uncaught, unspecified "error" event.'); + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + len = arguments.length; + args = new Array(len - 1); + for (i = 1; i < len; i++) + args[i - 1] = arguments[i]; + handler.apply(this, args); + } + } else if (isObject(handler)) { + len = arguments.length; + args = new Array(len - 1); + for (i = 1; i < len; i++) + args[i - 1] = arguments[i]; + + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + var m; + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.listenerCount = function(emitter, type) { + var ret; + if (!emitter._events || !emitter._events[type]) + ret = 0; + else if (isFunction(emitter._events[type])) + ret = 1; + else + ret = emitter._events[type].length; + return ret; +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + +},{}]},{},[9]); From 23b190e9dec35803e57c445b18d1532d4188925a Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 26 May 2015 14:52:59 -0700 Subject: [PATCH 32/34] line numbers --- base/pub/tree/src/js/components/CodeMirror.coffee | 1 + base/pub/tree/src/js/main.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/base/pub/tree/src/js/components/CodeMirror.coffee b/base/pub/tree/src/js/components/CodeMirror.coffee index 0e4f36c22..c3121c143 100644 --- a/base/pub/tree/src/js/components/CodeMirror.coffee +++ b/base/pub/tree/src/js/components/CodeMirror.coffee @@ -6,3 +6,4 @@ module.exports = recl componentDidMount: -> CodeMirror.fromTextArea @refs.ed.getDOMNode(), readOnly:true + lineNumbers:true diff --git a/base/pub/tree/src/js/main.js b/base/pub/tree/src/js/main.js index 13fe9c736..d15456b4f 100644 --- a/base/pub/tree/src/js/main.js +++ b/base/pub/tree/src/js/main.js @@ -376,7 +376,8 @@ module.exports = recl({ }, componentDidMount: function() { return CodeMirror.fromTextArea(this.refs.ed.getDOMNode(), { - readOnly: true + readOnly: true, + lineNumbers: true }); } }); From ae094a05dc4bb460500341a01654a087ef1f42b8 Mon Sep 17 00:00:00 2001 From: Henry Ault Date: Tue, 26 May 2015 17:29:02 -0700 Subject: [PATCH 33/34] updating joint state --- base/ape/cloud/core.hook | 227 ++++++++++++------------------------- base/pub/cloud/src/main.js | 7 +- 2 files changed, 73 insertions(+), 161 deletions(-) diff --git a/base/ape/cloud/core.hook b/base/ape/cloud/core.hook index 942ea0ff0..4e355647d 100644 --- a/base/ape/cloud/core.hook +++ b/base/ape/cloud/core.hook @@ -13,24 +13,8 @@ !: |% -++ droplet -$: id=@ud name=@t memory=@ud vcpus=@ud disk=@ud locked=? - created=@t status=@t backup-ids=(list ,@t) snapshot-ids=(list ,@ud) - features=(list ,@t) region=regi image=img - size=syze size-slug=@t networks=ntwrks kernel=kern - next-backup-window=json -== -++ regi ,[name=@t slug=@t sizes=(list ,@t)] -++ kern ,[id=@ud name=@t version=@t] -++ img -$: id=@ud name=@t distribution=@t slug=(unit ,@t) public=? regions=(list ,@t) - created-at=@t type=@t min-disk-size=@ud -== -++ ntwrks ,[v4=(list v) v6=(list v)] -++ v ,[ip-address=@t netmask=@t gateway=@t type=@t] -++ syze -$: memory=@ud price-monthly=@t price-hourly=@t disk=@ud vcpus=@ud - slug=@t transfer=@t available=? regions=(list ,@t) +++ instance +$: name=@t id=@ud status=@t created=@t region=@t snapshot=json disk=@u ip=(list ,@if) == ++ create-req-do $: @@ -41,7 +25,7 @@ private-networking=(unit ,?) user-data=(unit ,@t) ++ create-req-gce ,[project=@t zone=@t name=@t machine-type=@t] ++ axle $: auth=[do=keys gce=keys] toke=[do=tokens gce=tokens] - drops=(list droplet) + insts=(list instance) == ++ keys ,[authc=(unit ,@t) client-secret=(unit ,@t)] ++ tokens ,[access=@t refresh=@t] @@ -61,21 +45,14 @@ $% [%diff %json json] :~ id/ni name/so distribution/so slug/(mu so) public/bo regions/(ar so) 'created_at'^so type/so 'min_disk_size'^ni == -++ parse-ntwrks +++ parse-ip => jo %- ot - :+ v4/(ar (ot 'ip_address'^so netmask/so gateway/so type/so ~)) - v6/(ar (ot 'ip_address'^so netmask/so gateway/so type/so ~)) + :- v4/(ar (ot 'ip_address'^(su lip:ag) ~)) ~ -++ parse-size - => jo - %- ot - :~ memory/ni 'price_monthly'^no 'price_hourly'^no disk/ni - vcpus/ni slug/so transfer/no available/bo regions/(ar so) - == ++ parse-region => jo - (ot name/so slug/so sizes/(ar so) ~) + (ot name/so ~) ++ create-do-body |= $: name=@t region=@t size=@t image=@t ssh-keys=(list cord) backups=(unit ,?) ipv6=(unit ,?) private-networking=(unit ,?) user-data=(unit ,@t) @@ -86,62 +63,26 @@ $% [%diff %json json] 'user_data'^?~(user-data ~ s/u.user-data) 'private_networking'^?~(private-networking ~ b/u.private-networking) == ++ state-to-json - |= a=(list droplet) + |= a=(list instance) :- %a %+ turn a - |= droplet + |= instance ^- json %- jobe - :~ id/`json`(jone id) - name/`json`s/name - vcpus/`json`(jone vcpus) - disk/`json`(jone disk) - locked/b/locked - created/s/created + :~ name/`json`s/name + id/`json`(jone id) status/s/status - backup-ids/a/(turn backup-ids |=(el=cord s/el)) - snapshot-ids/a/(turn snapshot-ids jone) - features/a/(turn features |=(el=cord s/el)) - =+ ^= reg - :~ name/s/name.region slug/s/slug.region - sizes/a/(turn sizes.region |=(el=cord s/el)) - == - region/(jobe reg) - =+ ^= im - :~ id/(jone id.image) name/s/name.image distribution/s/distribution.image - slug/?~(slug.image ~ s/u.slug.image) public/b/public.image - regions/a/(turn regions.image |=(el=cord s/el)) - created-at/s/created-at.image type/s/type.image - min-disk-size/(jone min-disk-size.image) - == - image/(jobe im) - =+ ^= sz - :~ memory/(jone memory.size) price-monthly/s/price-monthly.size - price-hourly/s/price-hourly.size disk/(jone disk.size) vcpus/(jone vcpus.size) - slug/s/slug.size transfer/s/transfer.size available/b/available.size - regions/a/(turn regions.size |=(el=cord s/el)) - == - size/(jobe sz) - size-slug/s/size-slug - =+ ^= nt - =+ ^= vobj - |= v - %- jobe :~ - ip-address/s/ip-address netmask/s/netmask - gateway/s/gateway type/s/type - == - :~ v4/[%a (turn v4.networks vobj)] - v6/[%a (turn v4.networks vobj)] - == - networks/(jobe nt) - kernel/s/'kernel' - next-backup-window/s/'valid' + created/s/created + region/s/region + snapshot/s/'xx replace' + disk/`json`(jone disk) + ip/a/(turn ip |=(a=@if s/(rsh 3 1 (scot %if a)))) == -- !: |_ [hid=hide vat=axle] :: -::++ prep ,_`. +++ prep ,_`. ::: ++ spam |= jon=json @@ -183,7 +124,7 @@ $% [%diff %json json] |= [[ost=bone you=ship] pax=path] ^- [(list move) _+>.$] :_ +>.$ - [ost %diff %json (state-to-json drops.vat)]~ + [ost %diff %json (state-to-json insts.vat)]~ :: ++ poke-cloud-auth |= [[ost=bone you=ship] [cde=cord typ=cord]] @@ -197,7 +138,7 @@ $% [%diff %json json] =. access.gce.toke.vat cde :_ +>.$ - :- (list-droplets-gce ost) + :- (list-instances-gce ost) ~ :: ++ poke-cloud-secret @@ -241,7 +182,7 @@ $% [%diff %json json] refresh.do.toke.vat re == :_ +>.$ - :~ (list-droplets-do ost) + :~ (list-instances-do ost) (publish ost our.hid [%lin & 'successfully authenticated']~) == %auth-gce @@ -255,65 +196,35 @@ $% [%diff %json json] |= [[ost=bone you=ship] act=json] ^- [(list move) _+>.$] =+ do=(need ((ot action/so ~):jo act)) + :_ +>.$ + :_ ~ ?+ do !! %list - :_ +>.$ - :- (list-droplets-do ost) - ~ + ^- move (list-instances-do ost) :: %create-do - :_ +>.$ - =+ ^- deets=create-req-do - %- need - %. act - => jo - %- ot - :~ name/so region/so size/so image/so :: id key:img object - ssh/(ar so) backups/(mu bo) - 'ipv6'^(mu bo) 'priv_networking'^(mu bo) 'user_data'^(mu so) - == - :- (create-do ost deets) - ~ + ^- move (create-do ost act) :: %create-gce-disk - =+ name=(need ((ot name/so ~):jo act)) - =+ snap=(need ((ot snap/so ~):jo act)) - :_ +>.$ - :- (create-gce-disk ost name snap) - ~ +^- move (create-gce-disk ost act) :: %create-gce - :_ +>.$ - =+ ^- deets=create-req-gce - %- need - %. act - => jo - %- ot - :~ project/so zone/so name/so %'machine_type'^so - == - :- (create-gce ost deets) - ~ + ^- move (create-gce ost act) :: - $? %reboot %'power_cycle' %shutdown %'power_off' %'power_on' - %'password_reset' %'enable_ipv6' %'enable_private_networking' - %snapshot %upgrade - == + ?(%start %stop %reboot %delete) ::%'power_on' %'power_off' %reboot %'power_cycle' + ^- move =+ id=(need ((ot id/no ~):jo act)) - (droplet-action ost id do) + (instance-action ost id do) == :: -++ droplet-action +++ instance-action |= $: os=bone id=@t $= action $? - %delete %reboot %'power_cycle' %shutdown %'power_off' - %'power_on' %'password_reset' %'enable_ipv6' %'enable_private_networking' - %snapshot %upgrade :: add retrieve droplet action + %start %stop %reboot %delete == == :: restore, resize, rebuild, change_kernelm, retrieve droplet action - :_ +>.$ - ^- (list move) - :_ ~ + ^- move =+ ^= req %- httpreq :* os /reboot @@ -324,7 +235,7 @@ $% [%diff %json json] == req -++ list-droplets-gce +++ list-instances-gce |= os=bone =+ ^= lis :* os /list-gce @@ -335,7 +246,7 @@ $% [%diff %json json] == (httpreq lis) -++ list-droplets-do +++ list-instances-do |= os=bone =+ ^= lis :~ os /list-do @@ -345,41 +256,44 @@ $% [%diff %json json] == (httpreq lis) :: -++ receive-list - |= [ost=bone plat=cord resp=httr] +++ receive-list-do + |= [ost=bone resp=httr] ^- [(list move) _+>.$] - =+ parsed=(rash q:(need r.resp) apex:poja) + =+ parsed=(rash q:(need r.resp) apex:poja) :: parse httr to json ~| recieve-list/parsed - =+ dar=(need ((ot droplets/(ar some) ~):jo parsed)) - =+ ^- dropz=(list droplet) + =+ dar=(need ((ot droplets/(ar some) ~):jo parsed)) :: reparse ar of insts + =+ ^- dropz=(list instance) ~| bad-json/-.dar %+ turn dar |= drp=json %- need %. drp =+ jo %- ot - :~ id/ni name/so - memory/ni vcpus/ni disk/ni - locked/bo 'created_at'^so status/so - 'backup_ids'^(ar so) 'snapshot_ids'^(ar ni) features/(ar so) - region/parse-region image/parse-img size/parse-size - 'size_slug'^so networks/parse-ntwrks kernel/(ot id/ni name/so version/so ~) - 'next_backup_window'^some + :~ name/so id/ni status/so 'created_at'^so region/parse-region + image/some disk/ni networks/parse-ip == - =. drops.vat + =. insts.vat dropz =+ buf=`@da`(add ~s10 lat.hid) :_ +>.$ - :_ (spam (state-to-json drops.vat)) + :_ (spam (state-to-json insts.vat)) [ost %wait /refresh-do buf] -:: + ++ create-do - |= [os=bone create-req-do] - =- ~& - - + |= [os=bone act=json] + =+ ^- deets=create-req-do + %- need + %. act + => jo + %- ot + :~ name/so region/so size/so image/so :: id key:img object + ssh/(ar so) backups/(mu bo) + 'ipv6'^(mu bo) 'priv_networking'^(mu bo) 'user_data'^(mu so) + == =+ ^- body=json %- create-do-body :* - name region size image ssh backups - ipv6 private-networking user-data + name.deets region.deets size.deets image.deets ssh.deets backups.deets + ipv6.deets private-networking.deets user-data.deets == %- httpreq :* os /create-do @@ -395,8 +309,10 @@ $% [%diff %json json] ::(list httr) ^- httr ++ create-gce-disk - |= [os=bone name=@t snap=@t] :: num=(unit ,@u) + |= [os=bone act=json] :: num=(unit ,@u) :: =. name ?~(num name ... + =+ :- name=(need ((ot name/so ~):jo act)) + snap=(need ((ot snap/so ~):jo act)) =+ ^- body=json (jobe name/s/name %'sourceSnapshot'^s/'compute/v1/projects/urbcloud/global/snapshots/snapshot-1' ~) ::^so/snap ~) %- httpreq @@ -408,16 +324,6 @@ $% [%diff %json json] ~ ~ == - -::++ receive-gce-disk -:: |= [os=bone resp=httr] -:: ~& insert/resp -:: =+ hcode=p.resp -:: =+ parsed=(rash q:(need r.resp) apex:poja) -:: =+ link=(need ((ot 'targetLink'^(su auri:epur) ~):jo parsed)) -:: :_ +>.$ -:: :_(~ (ask-disk-status os link)) - ++ ask-disk-status |= [os=bone pax=path] ^- move =+ safe=(slav %uv ?~(pax !! -.pax)) @@ -446,11 +352,18 @@ $% [%diff %json json] ::(create-gce-disk ost nam 'tbd') :- ~ +>.$ :_ +>.$ - [ost %wait `path`[%check-status link ~] `@da`(add ~s3 lat.hid)]~ :: refresh every 10 sec + [ost %wait `path`[%check-status link ~] `@da`(add ~s3 lat.hid)]~ :: refesh every 10 sec ++ create-gce - |= [os=bone create-req-gce] - =+ src=(cat 3 'compute/v1/projects/urbcloud/zones/us-central1-b/disks/' name) + |= [os=bone act=json] + =+ ^- deets=create-req-gce + %- need + %. act + => jo + %- ot + :~ project/so zone/so name/so %'machine_type'^so + == + =+ src=(cat 3 'compute/v1/projects/urbcloud/zones/us-central1-b/disks/' name.deets) =+ ^- body=json %- jobe :~ name/s/'name-provided' 'machineType'^s/'zones/us-central1-b/machineTypes/n1-standard-1' @@ -474,7 +387,7 @@ $% [%diff %json json] ?+ -.pour-path !! %refresh-do :_ +>.$ - [(list-droplets-do ost)]~ + [(list-instances-do ost)]~ %check-status :_ +>.$ [(ask-disk-status ost +.pour-path)]~ @@ -490,7 +403,7 @@ $% [%diff %json json] (receive-auth ost -.pour-path resp) :: %list-do - (receive-list ost -.pour-path resp) + (receive-list-do ost resp) %list-gce ~& resp :_ +>.$ diff --git a/base/pub/cloud/src/main.js b/base/pub/cloud/src/main.js index e31be854c..7fe39025d 100644 --- a/base/pub/cloud/src/main.js +++ b/base/pub/cloud/src/main.js @@ -120,8 +120,7 @@ Droplet = React.createClass({ render: function() { var $this = this //local var, else it always points at second - var acts = ["reboot","power_cycle","shutdown","power_off","power_on","password_reset", - "enable_ipv6","enable_private_networking","snapshot","upgrade"] + var acts = ["start","stop","reboot","delete"] var buttons = []; var buttons = acts.map(function(act){ console.log($this.props.id) @@ -177,9 +176,9 @@ Page = recl({ render: function(){ return (div({}, DOControls({handleClick:this.handleClick,sendSecret:this.sendSecret}), - GCEControls({handleClick:this.handleClick,sendSecret:this.sendSecret}) + GCEControls({handleClick:this.handleClick,sendSecret:this.sendSecret}), + this.props.droplets.map(Droplet) )) - //this.props.droplets.map(Droplet) } }) From f2e0911933db45fab365e80ba3af0f3f9ebef9a4 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 27 May 2015 15:34:01 -0700 Subject: [PATCH 34/34] hiss/sigh typed http requests --- base/ape/curl/core.hook | 11 +++++++++ base/arvo/eyre.hoon | 38 +++++++++++++++++++++++++++-- base/arvo/gall.hoon | 48 ++++++++++++++++++++++++++++++++++--- base/arvo/zuse.hoon | 2 ++ base/cat/curl/url/gate.hook | 9 +++++++ base/lib/mean/core.hook | 9 +++++++ base/mar/httr/door.hook | 16 +++++++++++++ base/mar/purl/door.hook | 13 ++++++++++ 8 files changed, 141 insertions(+), 5 deletions(-) create mode 100644 base/ape/curl/core.hook create mode 100644 base/cat/curl/url/gate.hook create mode 100644 base/lib/mean/core.hook create mode 100644 base/mar/httr/door.hook create mode 100644 base/mar/purl/door.hook diff --git a/base/ape/curl/core.hook b/base/ape/curl/core.hook new file mode 100644 index 000000000..61c5a651e --- /dev/null +++ b/base/ape/curl/core.hook @@ -0,0 +1,11 @@ +/+ mean +!: +:::: + :: +|_ [^ ~] +++ poke |*([[a=@ @] b=[mark *]] :_(+> [a %hiss / %wain b]~)) +::++ poke-purl |=([[a=@ @] b=purl] :_(+> [a %hiss / %wain %purl b]~)) +++ poke-noun |=([a=from b=tape] (poke a %purl (scan b auri:epur))) +++ sigh-wain |=([^ a=wain] ~&(a `+>)) +++ sigh-tang |=([^ a=tang] `_+>`(mean a)) +-- diff --git a/base/arvo/eyre.hoon b/base/arvo/eyre.hoon index 9790fd224..41b00c1a6 100644 --- a/base/arvo/eyre.hoon +++ b/base/arvo/eyre.hoon @@ -16,6 +16,7 @@ == == :: $: %e :: to self $% [%this p=? q=clip r=httq] :: proxied request + [%meta vase:,[%them (unit httr)]] :: type check == == :: $: %f :: to %ford $% [%exec p=@p q=beak r=(unit silk)] :: @@ -53,6 +54,8 @@ $% [%at p=hole q=whir] :: authenticated [%ay p=span:ship q=span:,@uvH ~] :: remote duct [%he p=whir] :: HEAD request + [%hi p=mark ~] :: outbound HTTP + [%si ~] :: response done [%of p=ixor q=$|(~ whir-of)] :: associated view [%on p=span:,@uvH ~] :: dependency [%to p=ixor q=span:ship r=term s=wire] :: associated app @@ -478,6 +481,20 @@ q.ask (~(put by q.ask) p.ask hen u.p.kyz) kes (~(put by kes) hen p.ask) == + :: + %hiss :: outbound cage + ::?~ p.kyz :: XX cancel + :: =+ sud=(need (~(get by kes) hen)) + :: %= +>.$ + :: mow :_(mow [ged [%give %thus sud ~]]) + :: q.ask (~(del by q.ask) sud) + :: kes (~(del by kes) hen) + :: == + :: ~& eyre-them/(earn p.u.p.kyz) + %+ pass-note hi//[p.kyz] + ?: ?=(%hiss p.q.kyz) + [%e %meta :(slop !>(%them) !>(~) q.q.kyz)] + (ford-req root-beak [%cast %hiss %done ~ q.kyz]) :: %they :: inbound response =+ kas=(need (~(get by q.ask) p.kyz)) @@ -539,8 +556,12 @@ :: %went +>.$ %thou - ?> ?=([%ay ^] tee) - (ames-gram (slav %p p.tee) got/~ (slav %uv q.tee) |2.sih) + ?+ -.tee !! + %ay (ames-gram (slav %p p.tee) got/~ (slav %uv q.tee) |2.sih) + %hi =+ cay=[%httr !>(`httr`p.sih)] + ?: ?=(%httr p.tee) (give-sigh ~ cay) + (pass-note si/~ (ford-req root-beak [%cast p.tee %done `cay])) + == :: %unto :: XX horrible =+ cuf=`cuft`+>.sih @@ -582,6 +603,13 @@ |- ^+ ..axon ?- tee [?(%on %ay) *] ~|(e/ford/lost/-.tee !!) + [%si ~] (give-sigh q.sih) + [%hi ^] + ?: ?=(%| -.q.sih) + (give-sigh q.sih) :: XX crash? + =* cay p.q.sih + ?> ?=(%hiss p.cay) + (pass-note tee [%e %meta :(slop !>(%them) !>(~) q.cay)]) [%he *] :: XX hack =. ..axon $(tee p.tee) %_ ..axon @@ -696,6 +724,12 @@ +>(ded (~(del in ded) hen)) +>(mow :_(mow [hen %give %thou hit])) :: + ++ give-sigh :: userspace done + |= res=(each cage tang) + =- +>.$(mow :_(mow [hen %give %sigh `cage`-])) + ?. ?=(%| -.res) p.res + [%tang !>(p.res)] + :: ++ mean-json |=([sas=@uG err=ares] (give-json sas ~ (ares-to-json err))) ++ nice-json |=(* (give-json 200 ~ (joba %ok %b &))) :: diff --git a/base/arvo/gall.hoon b/base/arvo/gall.hoon index ecfefcbcf..0b64e1cc0 100644 --- a/base/arvo/gall.hoon +++ b/base/arvo/gall.hoon @@ -22,6 +22,7 @@ ++ cote :: ++ap note $% [%meta p=@tas q=vase] :: [%send p=ship q=cush] :: + [%hiss p=mark q=cage] == :: ++ cove (pair bone (mold cote cuft)) :: internal move ++ move ,[p=duct q=(mold note-arvo gift-arvo)] :: typed move @@ -366,7 +367,7 @@ ++ mo-cook :: take in /use |= [pax=path hin=(hypo sign-arvo)] ^+ +> - ?. ?=([@ @ ?(%inn %out) *] pax) + ?. ?=([@ @ ?(%inn %out %enn) *] pax) ~& [%mo-cook-bad-pax pax] !! =+ dap=`@tas`i.pax @@ -374,7 +375,13 @@ =+ pap=(ap-abed:ap dap pry) =+ vax=(slot 3 `vase`hin) ?- i.t.t.pax - %inn ap-abet:(ap-pour:pap t.t.t.pax (slot 3 `vase`hin)) + %inn ap-abet:(ap-pour:pap t.t.t.pax (slot 3 `vase`hin)) + %enn ?. ?=([%e %sigh *] q.hin) + ~& [%mo-cook-weird q.hin] + ~& [%mo-cook-weird-path pax] + +>.$ + ap-abet:(ap-sigh:pap t.t.t.pax +>.q.hin) + :: %out ?. ?=([%g %unto *] q.hin) ~& [%mo-cook-weird q.hin] ~& [%mo-cook-weird-path pax] @@ -506,6 +513,7 @@ %pass :+ %pass `path`[%use dap p.q.cov] ?- -.q.q.cov + %hiss `note-arvo`[%e %hiss p.q.q.cov q.q.q.cov] %send `note-arvo`[%g %deal [our p.q.q.cov] q.q.q.cov] %meta `note-arvo`[`@tas`p.q.q.cov %meta `vase`q.q.q.cov] == @@ -643,6 +651,7 @@ ?+ +<.q.vax (ap-move-pass -.q.vax +<.q.vax cav) %diff (ap-move-diff -.q.vax cav) + %hiss (ap-move-hiss -.q.vax cav) %peer (ap-move-peer -.q.vax cav) %pull (ap-move-pull -.q.vax cav) %poke (ap-move-poke -.q.vax cav) @@ -664,6 +673,21 @@ [%| (ap-suck "move: improper diff")] [%& sto %give %diff `cage`[-.q.vax (slot 3 (spec vax))]] :: + ++ ap-move-hiss :: pass %hiss + |= [sto=bone vax=vase] + ^- (each cove tang) + ?. &(?=([p=* q=@ q=^] q.vax) ((sane %tas) q.q.vax)) + [%| (ap-suck "move: malformed hiss ask.[%hiss path mark cage]")] + =+ gaw=(slot 7 vax) + ?. &(?=([p=@ q=^] q.gaw) ((sane %tas) p.q.gaw)) + [%| (ap-suck "move: malformed cage")] + =+ pux=((soft path) p.q.vax) + ?. &(?=(^ pux) (levy u.pux (sane %ta))) + [%| (ap-suck "move: malformed path")] + :^ %& sto %pass + :- [(scot %p q.q.pry) %enn u.pux] + [%hiss q.q.vax [p.q.gaw (slot 3 (spec gaw))]] + :: ++ ap-move-mess :: extract path, target |= vax=vase ^- (each (trel path ship term) tang) @@ -807,7 +831,8 @@ ^+ +> =+ cug=(ap-find /lame) ?~ cug - ~& [%ap-lame wut why] + =. why (turn why |=(a=tank rose/[~ "! " ~]^[a]~)) + ~> %slog.`rose/[" " "[" "]"]^[>%ap-lame< >wut< why] +>.$ =^ cam +>.$ %+ ap-call q.u.cug @@ -832,6 +857,22 @@ ?^ cam (ap-lame -.q.vax u.cam) +>.$ :: + ++ ap-sigh :: http response + |= [pax=path cag=cage] + ^+ +> + =. q.cag (spec q.cag) + =+ cug=(ap-find [%sigh p.cag pax]) + ?~ cug + (ap-lame %sigh (ap-suck "sigh: no {<`path`[p.cag pax]>}")) + =+ ^= arg ^- vase + %- slop + ?: =(0 p.u.cug) + [!>([`@ud`ost `@p`q.q.pry `path`pax]) !>(cag)] + [!>([`@ud`ost `@p`q.q.pry (slag (dec p.u.cug) `path`pax)]) q.cag] + =^ cam +>.$ (ap-call q.u.cug arg) + ?^ cam (ap-lame q.u.cug u.cam) + +>.$ + :: ++ ap-pout :: specific take |= [pax=path cuf=cuft] ^+ +> @@ -986,6 +1027,7 @@ %merg `%c %plug `%c %them `%e + %hiss `%e %want `%a == -- diff --git a/base/arvo/zuse.hoon b/base/arvo/zuse.hoon index 3fc9b911a..f69eeae90 100644 --- a/base/arvo/zuse.hoon +++ b/base/arvo/zuse.hoon @@ -2418,6 +2418,7 @@ ++ kiss-eyre :: in request ->$ $% [%born ~] :: new unix process [%crud p=@tas q=(list tank)] :: XX rethink + [%hiss p=mark q=cage] :: outbound user req [%init p=@p] :: report install [%them p=(unit hiss)] :: outbound request [%they p=@ud q=httr] :: inbound response @@ -2428,6 +2429,7 @@ == :: ++ gift-eyre :: out result <-$ $% [%mass p=mass] :: memory usage + [%sigh p=cage] :: marked http response [%thou p=httr] :: raw http response [%thus p=@ud q=(unit hiss)] :: http request/cancel [%veer p=@ta q=path r=@t] :: drop-through diff --git a/base/cat/curl/url/gate.hook b/base/cat/curl/url/gate.hook new file mode 100644 index 000000000..f3435f011 --- /dev/null +++ b/base/cat/curl/url/gate.hook @@ -0,0 +1,9 @@ +:: +:::: + :: +/? 310 +:: +::::: + !: +|= [^ [arg=tape ~] ~] +purl/(scan arg auri:epur) diff --git a/base/lib/mean/core.hook b/base/lib/mean/core.hook new file mode 100644 index 000000000..6c9f65f53 --- /dev/null +++ b/base/lib/mean/core.hook @@ -0,0 +1,9 @@ +|% ++ mean |=(a=tang (mean-wrap a |.(!!))) + ++ mean-wrap + |* [a=tang _|?(**)] + ^+ (+<+) + => .(a `tang`a) + ?~ a (+<+) + ~> %mean.|.(i.a) + $(a t.a) +-- diff --git a/base/mar/httr/door.hook b/base/mar/httr/door.hook new file mode 100644 index 000000000..f3094c7eb --- /dev/null +++ b/base/mar/httr/door.hook @@ -0,0 +1,16 @@ +:: +:::: /hook/door/httr/mar + :: +/? 314 +|_ hit=httr +:: +++ grow |% ++ wall (turn wain trip) + ++ wain ~| hit + ?> =(2 (div p.hit 100)) + (lore q:(need r.hit)) + -- +++ grab :: convert from + |% + ++ noun httr :: clam from %noun + -- +-- diff --git a/base/mar/purl/door.hook b/base/mar/purl/door.hook new file mode 100644 index 000000000..2e481abe9 --- /dev/null +++ b/base/mar/purl/door.hook @@ -0,0 +1,13 @@ +:: +:::: /hook/door/purl/mar + :: +/? 314 +|_ url=purl +:: +++ grow |% ++ hiss [url %get ~ ~] + -- +++ grab :: convert from + |% + ++ noun purl :: clam from %noun + -- +--