From 5acce9cc04314e7742267832ee123cd23a762fe4 Mon Sep 17 00:00:00 2001 From: pcmonk Date: Fri, 11 Jul 2014 16:44:33 -0700 Subject: [PATCH] checkpoint --- arvo/ames.hoon | 1 + arvo/eyre.hoon | 55 +++++---- arvo/gall.hoon | 4 +- main/app/status/core.hoon | 234 ++++++++++++++++++++++++++++++++++++++ main/app/status/urb.js | 121 ++++++++++++++++++++ 5 files changed, 395 insertions(+), 20 deletions(-) create mode 100644 main/app/status/core.hoon create mode 100644 main/app/status/urb.js diff --git a/arvo/ames.hoon b/arvo/ames.hoon index c81bca440..66951d862 100644 --- a/arvo/ames.hoon +++ b/arvo/ames.hoon @@ -1660,6 +1660,7 @@ == :: %ouzo + :: ~& [%send now p.bon `@p`(mug (shaf %flap q.bon))] :_ fox [[gad.fox [%give %send p.bon q.bon]] ~] :: diff --git a/arvo/eyre.hoon b/arvo/eyre.hoon index 69bddb359..30842aee4 100644 --- a/arvo/eyre.hoon +++ b/arvo/eyre.hoon @@ -14,6 +14,7 @@ ++ hasp ,[p=ship q=term] :: see %gall ++ kiss :: in request ->$ $% [%born ~] :: new unix process + [%clug p=ship q=hole r=@ud] :: XX terrible [%crud p=@tas q=(list tank)] :: XX rethink [%init p=@p] :: report install [%them p=(unit hiss)] :: outbound request @@ -39,7 +40,9 @@ $% [%flog p=[%crud p=@tas q=(list tank)]] :: == == :: $: %e :: to %eyre - $% [%this p=? q=clip r=httq] :: + $% [%clug p=ship q=hole r=@ud] :: XX terrible + [%crud p=@tas q=(list tank)] :: XX rethink + [%this p=? q=clip r=httq] :: [%thud ~] :: == == :: $: %f :: to %ford @@ -326,13 +329,14 @@ :: ?(%dumb %mean %nice %rush %rust) ?> ?=([%hoop @ @ @ @ ~] tea) + ~& [%dumb-tea tea] =+ ^= ouy %- yolk:(gale (slav %p i.t.tea) i.t.t.tea) (slav %ud i.t.t.t.tea) ?~ ouy +>.$ ~& [%axon-fun `@dr`(sub now tim.bet.siq:beat:u.ouy)] - ?: (lth ~m2 (sub now tim.bet.siq:beat:u.ouy)) + ?: (lth ~s20 (sub now tim.bet.siq:beat:u.ouy)) abet:work:amok:u.ouy =+ woy=(yule:u.ouy (slav %ud i.t.t.t.t.tea)) =< abet =< work =< abet @@ -400,6 +404,17 @@ ^+ +> ?- -.kyz %born +>.$(ged hen) :: register external + %clug + =+ ^= ouy + %- yolk:(gale p.kyz q.kyz) + r.kyz + ?~ ouy + +>.$ + ~& [%axon-fun `@dr`(sub now tim.bet.siq:beat:u.ouy)] + ?: (lth ~m2 (sub now tim.bet.siq:beat:u.ouy)) + abet:work:amok:u.ouy + =< abet =< work =< abet + (hear:(yule:u.ouy 2) ~ %& %json !>((joba %i-see %s %you))) %crud +>.$(mow [[hen %slip %d %flog kyz] mow]) %init :: register ownership @@ -1046,7 +1061,7 @@ method = "put" perm = "tih" - url = [perm,user,appl,port,this.seqn] + url = [perm,user,appl,port,heart.seqn] url = "/"+url.join("/") $this = this @@ -1056,13 +1071,13 @@ xhr.setRequestHeader("content-type", "text/json") xhr.send(JSON.stringify({oryx:oryx, xyro: {heart:"beat"}})) xhr.onload = function () { - $this.seqn++ - $this.trys = 0 - setTimeout($this.beat,$this.dely) + heart.seqn++ + heart.trys = 0 + setTimeout(heart.beat,heart.dely) } xhr.onerror = function() { - $this.trys++ - setTimeout($this.beat,$this.dely*$this.trys) + heart.trys++ + setTimeout(heart.beat,heart.dely*heart.trys) } } } @@ -2050,9 +2065,13 @@ ^+ +> ?. =(cnt num.bet.siq) +>.$(..yo (bust 204 num)) - =. bet.siq [+(num.bet.siq) now] - ~& [%beat jon] - (hear:(yule:(hire:(yule 2) cnt num) 2) ~ %& %json !>((joba %ok %b %&))) + =. +>.$ + ?. =(cnt num.bet.siq) +>.$ + %+ pass(bet.siq [+(num.bet.siq) now]) + 2 + `note`[%e %clug our ses nap] + ~& [%beat cnt num jon] + (hire:(yule 2) cnt num) :: ++ hoop :: request path |= suq=@ud @@ -2143,6 +2162,7 @@ == sip sip som ^- seam + ~& [%busk-realz suq] :+ %sil ?:(-.u.huq 200 203) =+ bek=`beak`[our %main [%da now]] @@ -2167,12 +2187,11 @@ =< abet =+ cnt=cnt.wig =+ dul=(~(get by wan.wig) cnt) - ~& [%hear-dul cnt dul] - :: ~& :~ %yu-hear - :: [%instance nap] - :: [%produced cnt] - :: ?~(dul %unrequested [%requester u.dul]) - :: == + ~& :~ %yu-hear + [%instance nap] + [%produced cnt] + ?~(dul %unrequested [%requester u.dul]) + == =: cnt.wig +(cnt.wig) wan.wig ?~(dul wan.wig (~(del by wan.wig) cnt.wig)) red.wig (~(put by red.wig) cnt.wig huq) @@ -2193,14 +2212,12 @@ ?: |((lth +(cnt) toy.wig) (gth cnt toy.wig)) ~& [%hire-improper [%request cnt] [%dispatched toy.wig]] +>.$(..yo (bust 204 num)) - ~& [%hire-1 cnt cnt.wig] ?: (gte cnt cnt.wig) :: ~& %hire-wait =+ old=(~(get by wan.wig) cnt) =. wan.wig (~(put by wan.wig) cnt num) +>.$(..yo ?~(old ..yo (bust 204 u.old))) =+ rud=(~(get by red.wig) cnt) - ~& [%hire-2 cnt ?=(~ rud)] ?~ rud :: ~& %hire-bust +>.$(..yo (bust 204 num)) diff --git a/arvo/gall.hoon b/arvo/gall.hoon index a6c55d03e..772651f3c 100644 --- a/arvo/gall.hoon +++ b/arvo/gall.hoon @@ -74,7 +74,7 @@ == :: ++ scar :: opaque duct system $: p=@ud :: bone sequence - q=(map duct ,[p=bone q=(unit cuff)]) :: by duct + q=(map path ,[p=bone q=(unit cuff)]) :: by duct r=(map bone duct) :: by bone == :: ++ roon :: foreign response @@ -761,6 +761,7 @@ deal:(drum u.gad) :: %pull + ~& [%ach-pulled ost] =^ gud +>.$ (mack q.hin) ?^ gud +>.$ =+ pax=+:(fall (~(get by sup.sat) ost) *[ship path]) @@ -917,6 +918,7 @@ (give(qic.sat ~) %crud p.kon q.kon) :: %nuke + ~& %nukate ?. (warm %pull) +>.$(qic.sat ~) ?> ?=(^ huv.sat) diff --git a/main/app/status/core.hoon b/main/app/status/core.hoon new file mode 100644 index 000000000..38aede216 --- /dev/null +++ b/main/app/status/core.hoon @@ -0,0 +1,234 @@ +!: +=> |% + ++ perm + $% [%all ~] + [%list p=(list ,@p) q=?] + == + ++ axle + $% [%0 p=(map key stat)] + == + ++ comm + $% [%change chan=(list key) newchan=key] + [%update chan=(list key) sta=stat] + == + ++ gilt + $% [%json p=json] + [%hymn p=manx] + == + ++ gift + $% [%lean ~] + [%mean p=(unit ,[p=term q=(list tank)])] + [%nice ~] + [%rust gilt] + [%verb ~] + == + ++ hasp ,[p=ship q=term] + ++ key ,@tas + ++ move ,[p=bone q=mess] + ++ mess + $% [%give p=gift] + [%pass p=path q=note] + == + ++ note + $? $: %a + $% [%want p=sock q=path r=*] + == == + $: %e + $% [%wart p=sock q=@tas r=path s=*] + == == + $: %g + $% [%mess p=hasp q=ship r=cage] + == == == + ++ sign + $% $: %a + $% [%send p=lane q=@] + [%went p=ship q=cape] + == == + $: %g + $% [%rasp (unit (pair logo noun))] + == == == + ++ stat ,[p=perm q=value] + ++ value + $% [%list p=(list value)] + [%text p=@t] + [%map p=(map key stat)] + == + -- +|_ [hid=hide vat=axle] +++ incl + |= wal=wall + %+ turn wal + |= tape ;script(type "text/javascript", src +<); +:: +++ page + ^- manx + ;html + ;head + ;title: Foobug! + ;style + ; #cont {border-collapse: collapse; right: 0px} + ; #news, .status { + ; left: 0px; + ; right: 0px; + ; background: blue; + ; color: white; + ; min-width: 100px; + ; min-height: 18px; + ; } + ; #news { + ; display: inline-block; + ; } + == + ;* %- incl :~ + "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js" + == + ;script ;- (trip ;;(,@ .^(%cx (welp root /urb/js)))) + == + ;script ;- (trip ;;(,@ .^(%cx (welp root /app/js)))) + == + == + ;body + ;p: Hello. + ;table#cont:tbody; + ;button#newb: New Channel + ;div#news(contenteditable "true"); + ;p: Enter your current status + ;div#status(contenteditable "true"); + == + == +:: +++ peer + |= [ost=bone you=ship pax=path] + ^- [(list move) _+>] + ?: =(~ pax) + [[ost %give %rust %hymn page]~ +>] + :_ +> + [ost msg]~ +:: +++ parse-acl + |= acl=@t ^- perm + ?: =(%everyone acl) + [%all ~] + [%list (fall (rush acl (more com ;~(pfix sig fed:ag))) ~) &] +:: +++ poke-json + |= [ost=bone you=ship jon=json] + ^- [(list move) _+>] + ~& [%poke [%state p.vat] ost you jon] + =+ ^= sta %- %- hard ,[%o p=(map ,@t jval)] jon + =+ ^= chan %- %- hard ,[~ %s p=@t] (~(get by p.sta) %chan) + =+ ^= newc %- %- soft ,[~ %s p=@t] (~(get by p.sta) %newc) + =+ ^= acl %- %- soft ,[~ %s p=@t] (~(get by p.sta) %acl) + =+ ^= val %- %- soft ,[~ p=jval] (~(get by p.sta) %value) + =+ ^= pchan + ^- (list key) + (turn `(list tape)`(rash p.chan (more fas (plus ;~(pose low hep)))) crip) + ?~ newc + ?~ val !! + ?~ acl !! + %^ poke-stat ost you :+ %update pchan + |- ^- stat + :- (parse-acl p.u.acl) + ?+ -.p.u.val !! + %a + [%list (turn p.p.u.val |=(j=jval q:^$(p.u.val j)))] + %o + :- %map + %+ ~(rep by p.p.u.val) *(map key stat) + |= [p=[p=@t q=jval] q=(map key stat)] + (~(put by q) p.p ^$(p.u.val q.p)) + %s + [%text p.p.u.val] + == + (poke-stat ost you [%change pchan p.u.newc]) +:: +++ poke-stat + |= [ost=bone you=ship com=comm] + =. p.vat + |- ^- (map key stat) + ?< ?=(~ chan.com) + ?. ?=(~ t.chan.com) + %+ ~(put by p.vat) i.chan.com + =+ ^= cur + %- fall :_ [~ p=all// %map q=*(map key stat)] + %- (soft ,[~ p=perm %map q=(map key stat)]) + (~(get by p.vat) i.chan.com) + :- p.cur + :- %map + %= $ + chan.com t.chan.com + p.vat q.cur + == + ?- -.com + %update (~(put by p.vat) i.chan.com sta.com) + %change + %- %~ del by + %+ ~(put by p.vat) newchan.com + (fall (~(get by p.vat) i.chan.com) *stat) + i.chan.com + == + :_ +>.$ + :* ^- move +:: :* ost %pass /howdy %a %want [our.hid our.hid] /r/pc +:: 'hi' +:: == +:: `move`[ost %pass /hi %g %mess [~zod %appbug-2] ~zod %hi !>(~)] + :^ ost %give %mean ~ + (send /status msg) + == +:: +++ pour + |= [way=path sih=sign] + ^- [(list move) _+>] + ~& [%status-pour sih] + [~ +>] +:: +++ pull + |= ost=bone + ~& [%status-pull ost] + [~ +>.$] +:: +++ root + /(scot %p our.hid)/main/(scot %da lat.hid)/app/[app.hid] +:: +++ send + |= [pax=path msg=mess] + %- turn :_ |=(ost=bone [ost msg]) + =- ~& [%bones -] - + ^- (list bone) + %+ ~(rep by sup.hid) *(list bone) + |= [p=[p=bone q=[ship path]] q=(list bone)] ^- (list bone) + ?. =(pax +.q.p) q + [p.p q] +:: +++ msg + ^- mess + :* %give %rust %json %o + %- mo + %+ turn (~(tap by p.vat)) + |= [p=key q=stat] + :- p + |- + ?- -.q.q + %list + [%a (turn p.q.q |=(v=value ^$(q.q v)))] + %map + :- %o + %. :+ %acl %s + ?- -.p.q + %all %everyone + %list + %+ roll p.p.q + |= [p=@p q=@t] + (cat 3 (cat 3 q ',') (scot %p p)) + == + %~ put by + ^- (map ,@t jval) + %+ ~(rep by p.q.q) *(map ,@t jval) + |= [p=[p=key q=stat] q=(map ,@t jval)] + (~(put by q) p.p ^$(q q.p)) + %text + [%s p.q.q] + == + == +-- diff --git a/main/app/status/urb.js b/main/app/status/urb.js new file mode 100644 index 000000000..f1aed9689 --- /dev/null +++ b/main/app/status/urb.js @@ -0,0 +1,121 @@ +window.urb = { + ship: ship, + port: port, + auto: auto, + oryx: oryx, + user: user, + appl: appl, + seqn: 0, + + seqp: 1, + seqs: 3, + dely: 0, + + met: function(str) { + beg = str[0] + end = str[1] + if (ship == user) + return perm = beg+"o"+end + else + return perm = beg+"i"+end+"/"+user + }, + + req: function(method,url,data,json,cb) { + var xhr = new XMLHttpRequest() + xhr.open(method.toUpperCase(), url) + if(json) + xhr.setRequestHeader("content-type", "text/json") + if(data) + xhr.send(JSON.stringify({oryx: oryx, xyro: data})) + else + xhr.send({oryx: oryx}) + if(cb) { + xhr.onload = function() { + cb(null,{ + "status":this.status, + "data":JSON.parse(this.responseText) + }) + } + xhr.onerror = function() { + cb({ + "status":this.status, + "data":this.responseText + }) + } + } + }, + + subscribe: function(path,cb) { + if(!cb) + throw new Error("You must supply a callback to urb.subscribe.") + + var method, perm, url, $this + + method = "put" + + url = [this.met("ts"),this.appl,this.port] + if(path) { + url.push(this.seqs) + url.push(path) + } + console.log(url) + url = "/"+url.join("/") + + + $this = this + this.req(method,url,{},true,function(err,data) { + cb.apply(this,arguments) + if(!err) { $this.poll($this.seqs++,cb); } + }) + }, + + send: function(data,cb) { + if(!data) { data = {}; } + if(!cb) { cb = function() {}; } + + var method, perm, url, $this + + method = "put" + url = [this.met("tm"),this.appl,this.port,this.seqn] + url = "/"+url.join("/") + + this.seqn++ + + $this = this + this.req(method,url,data,true,function(err,data) { + if(err) { $this.seqn--; } + cb.apply(this,arguments) + }) + }, + + poll: function(stream,cb) { + if(!stream) + throw new Error("You must supply a stream to urb.poll.") + if(!cb) + throw new Error("You must supply a callback to urb.poll.") + + var method, perm, url, $this + + method = "get" + if(!stream) { return false; } + url = [this.met("ge"),this.appl,this.port,stream,this.seqp] + url = "/"+url.join("/") + console.log(url) + + $this = this + this.req(method,url,null,false,function(err,data) { + if(cb.apply(this,arguments) === false) { return; } + + if(err) + $this.dely += 1000 + else { + $this.dely = 0 + $this.seqp++ + } + + setTimeout(function() { + $this.poll(stream,cb) + },$this.dely) + }) + } +}