Merge branch 'test' of https://github.com/urbit/urbit into test

This commit is contained in:
Anton Dyudin 2015-05-08 17:14:04 -07:00
commit 372928b4ee
11 changed files with 235 additions and 25 deletions

View File

@ -1674,7 +1674,7 @@
::
++ diff-talk-report ::
|= [then rad=report]
%+ etch-friend [%friend way] |= [man=span cuz=station]
%+ etch-friend way |= [man=span cuz=station]
ra-abet:(~(ra-diff-talk-report ra ost ~) man cuz rad)
::
++ coup-repeat ::

195
base/ape/ucto/core.hook Normal file
View File

@ -0,0 +1,195 @@
:: :::::::::::::::
:::: /hook/core/octo/ape :: :: :: build
:: :::::::::::::::
/- *sole :: structures
/+ sole :: libraries
:: :::::::::::::::
:::: :: :: :: logic
!: :::::::::::::::
=> |% :: board logic
++ board ,@ :: one-player bitfield
++ point ,[x=@ y=@] :: coordinate
++ game ,[who=? box=board boo=board] :: game state
++ icon |=(? ?:(+< 'X' 'O')) :: display at
++ bo :: per board
|_ bud=board ::
++ get |=(point =(1 (cut 0 [(off +<) 1] bud))) :: get point
++ off |=(point (add x (mul 3 y))) :: bitfield address
++ set |=(point (con bud (bex (off +<)))) :: set point
++ win %- lien :_ |=(a=@ =(a (dis a bud))) :: test for win
(rip 4 0wl04h0.4A0Aw.4A00s.0e070) :: with bitmasks
-- ::
++ go :: per game
|_ game ::
++ at |_ point :: per point
++ g +>+< :: game
++ k !|(x o) :: ok move
++ m ?.(k [| g] [& g:t:?:(who y p)]) :: move
++ o (~(get bo boo) +<) :: old at o
++ p .(boo (~(set bo boo) +<)) :: play at o
++ t .(who !who) :: take turn
++ v ?:(x (icon &) ?:(o (icon |) '.')) :: view
++ x (~(get bo box) +<) :: old at x
++ y .(box (~(set bo box) +<)) :: play at x
-- ::
++ res ?: ~(win bo box) `"{~[(icon &)]} wins" :: result
?: ~(win bo boo) `"{~[(icon |)]} wins" ::
?: =(511 (con boo box)) `"tie :-(" ~ ::
++ row |= y=@ :~ (add y '1') :: print row
' ' ~(v at y 0) ::
' ' ~(v at y 1) ::
' ' ~(v at y 2) ::
== ::
++ tab ~["+ 1 2 3" (row 0) (row 1) (row 2)] :: print table
-- ::
-- ::
:: :::::::::::::::
:::: :: :: :: agent
:: :::::::::::::::
=> |% :: arvo structures
++ axle ,[%1 eye=face but=tube gam=game] :: agent state
++ axon $?(axle [%0 eye=face gam=game]) :: historical state
++ card $% [%diff lime] :: update
[%quit ~] :: cancel
[%peer wire dock path] :: subscribe
[%pull wire dock ~]
== ::
++ face (pair (list ,@c) (map bone sole-share)) :: interface
++ lime $% [%sole-effect sole-effect] :: :sole update
[%octo-game game] :: :octo update
== ::
++ move (pair bone card) :: cause and action
++ mote (pair ship ,?) :: remote binding
++ sink (trel bone ship path) :: promote
++ tube (unit (pair ,? mote)) :: alive, remote
-- ::
=> |% :: promote
++ pick
|* [a=_rule b=_rule]
;~ pose
(stag %& a)
(stag %| b)
==
++ punt
|* [a=_rule]
;~(pose (stag ~ a) (easy ~))
::
++ flag
|= [sic=@t non=@t]
;~(pose (cold %& (jest sic)) (cold %| (jest non)))
-- ::
=> |% :: parsers
++ colm (cook |=(a=@ (sub a '1')) (shim '1' '3')) :: row or column
++ come ;~(plug colm ;~(pfix fas colm)) :: coordinate
++ comb (pick come (punt ;~(pfix sig comp))) :: all command input
++ comp ;~(plug fed:ag ;~(pfix ace (flag %x %o))) :: login command
++ cope |=(? ?:(+< (stag %| (cold ~ sig)) comb)) :: with wait mode
-- ::
|_ [hid=hide moz=(list move) axle] :: per agent
++ et ::
|_ [from say=sole-share] :: per console client
++ abet +>(q.eye (~(put by q.eye) ost say)) :: continue
++ amok +>(q.eye (~(del by q.eye) ost)) :: discontinue
++ beep (emit %bel ~) :: bad user
++ cusp (cope wait) :: parsing rule
++ delt |= cal=sole-change :: input line change
=^ cul say (remit:sole cal good) ::
?~ cul (park:abet(p.eye buf.say) | ~) ::
abet:beep:(emit det/u.cul) ::
++ emit |= fec=sole-effect ^+ +> :: send effect
?< =(0 ost)
+>(moz [[ost %diff %sole-effect fec] moz]) ::
++ emil |= fex=(list sole-effect) :: send effects
?~(fex +> $(fex t.fex, +> (emit i.fex))) ::
++ good |=((list ,@c) -:(rose (tufa +<) cusp)) :: valid input
++ kick |= point :: move command
=^ dud gam ~(m ~(at go gam) +<) ::
?. dud abet:beep =+ mus=~(res go gam) ::
(park:abet(gam ?^(mus *game gam)) %2 mus) ::
++ line =^ cal say (transmit:sole set/p.eye) :: update command
(emit %det cal) ::
++ make =+ dur=(rust (tufa p.eye) comb) ::
?~ dur abet:beep ::
=. + line(p.eye ~) ::
?-(+<.dur & (kick +>.dur), | (plan +>.dur)) ::
++ mean |=((unit tape) ?~(+< +> (emit txt/+<+))) :: optional message
++ play |= lev=?(%0 %1 %2) :: update by level
?-(lev %0 +>, %1 line, %2 line:show:prom) ::
++ plow |= [lev=?(%0 %1 %2) mus=(unit tape)] :: complete print
abet:(mean:(play lev) mus) ::
++ prom %^ emit %pro %& :- %octo :: update prompt
?: wait "(xir turn) " ::
": {~[(icon who.gam)]} to move (row/col): " ::
++ plan |= mut=(unit mote) :: peer command
?~ mut ?~(but abet:beep stop:abet) ::
?^(but abet:beep (link:abet u.mut)) ::
++ rend (turn `wall`~(tab go gam) |=(tape txt/+<)) :: table print
++ show (emit %mor rend) :: update board
++ sole ~(. cs say) :: console library
++ wait &(?=(^ but) !=(q.q.u.but who.gam)) :: waiting turn
++ work |= act=sole-action :: console input
?:(?=(%det -.act) (delt +.act) make) ::
-- ::
++ abet [(flop moz) .(moz ~)] :: resolve core
++ dump %_(+> moz [mov moz]) :: send move
++ 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
++ link |= mot=mote %- dish(but `[| mot]) :: subscribe to friend
peer/((like p.mot) /octo/[?:(q.mot %x %o)]) ::
++ pale |=(f=$+(sink ?) (skim (~(tap by sup.hid)) f)) :: filter peers
++ pals %+ turn (pale (prix /sole)) |= sink :: per console
[[p=p.+< q=q.+<] r=(~(got by q.eye) p.+<)] ::
++ park |= [lev=?(%0 %1 %2) mus=(unit tape)] :: update all
=. +> ?:(=(%2 lev) push +>) ::
=+ pals ::
|- ^+ +>.^$ ?~ +< +>.^$ ::
$(+< t.+<, +>.^$ (~(plow et i.+<) lev mus)) ::
++ prix |= pax=path |= sink ^- ? :: filter gate
?~ pax & ?~ r.+< | ::
&(=(i.pax i.r.+<) $(pax t.pax, r.+< t.r.+<)) ::
++ push =+ pey=(pale (prix /octo)) |- ^+ +> :: update friends
?~(pey +> $(pey t.pey, +> (sell p.i.pey))) ::
++ sell |=(ost=bone (dump ost %diff %octo-game gam)) :: update friend
++ stop (dish(but ~) pull/((like +>-.but) ~)) :: cancel subscribe
:: :::::::::::::::
:::: :: :: :: hooks
:: :::::::::::::::
++ diff-octo-game :: friend update
|= [then gam=game] =< abet ::
?. &(?=([~ %& *] but) =(src p.q.u.but)) +> ::
?: =(^gam gam) +> ::
(park(gam gam) %2 ~) ::
++ peer-octo :: linked by friend
|= [from pax=path] =< abet ::
=+ who==(%x -.pax) ::
?^ but (park %2 ~) :: [~ %& !who src]
(park:(link src !who) %2 `"link by {<src>}") ::
++ peer-sole :: console subscribe
|= [from *] =< abet ::
(plow:(fret +<-) %2 ~) ::
++ poke-sole-action :: console input
|= [from act=sole-action] =< abet ::
(work:(flet +<-) act) ::
++ prep |= [from old=(unit ,[(list move) axon])] :: initialize
=< abet ?~ old +> ::
=< (park %2 ~) ::
?- -.+>.old ::
%1 +>(+<+ u.old) ::
%0 +>(eye.+< eye.+>.old, gam.+< gam.+>.old)::
== ::
++ pull-octo ::
|= [from ~] =< abet ::
(park(but ~) %0 `"dropped") ::
++ pull-sole :: disconnect console
|= [from *] =< abet ::
amok:(flet +<-) ::
++ quit-octo :: unlinked by friend
|=([then ~] abet:(park(but ~) %0 `"removed")) ::
++ reap-octo :: linked to friend
|= [then saw=(unit tang)] =< abet ::
?> ?=([~ %| *] but) ::
?^ saw (park:stop %0 `"fail to {<src>}") ::
(park(p.u.but %&) %0 `"link to {<src>}") ::
--

View File

@ -513,8 +513,9 @@
++ mo-beak :: build beak
|= dap=dude
^- beak
=+ pup=pup:(~(got by bum) dap)
[p.pup q.pup [%da now]] :: XX this is wrong; save the build case
:: =+ pup=pup:(~(got by bum) dap)
:: [p.pup q.pup [%da now]] :: XX this is wrong; save the build case
[our %base %da now] :: XX really wrong
::
++ mo-club :: local action
|= [dap=dude pry=prey cub=club]
@ -992,7 +993,7 @@
^+ +>
=+ cug=(ap-find cog pax)
?~ cug
~& [%ap-punk-none pax]
~& [%ap-punk-none cog pax]
+>.$
=^ cam +>.$
%+ ap-call q.u.cug

View File

@ -1198,18 +1198,18 @@
::
++ new-mess
|= [a=hasp b=wire c=cage] ^+ ..ix
(hurl-note [a b] [%g %mess [- + ~]:a him c])
:: (hurl-note [a b] [%b %deal [him -.a] +.a %poke c])
:: (hurl-note [a b] [%g %mess [- + ~]:a him c])
(hurl-note [a b] [%b %deal [him -.a] +.a %poke c])
::
++ add-subs
|= [a=hasp %json b=wire c=path] ^+ ..ix
(hurl-note [a b] [%g %show [- + ~]:a him c])
:: (hurl-note [a b] [%b %deal [him -.a] +.a %peer c])
:: (hurl-note [a b] [%g %show [- + ~]:a him c])
(hurl-note [a b] [%b %deal [him -.a] +.a %peer c])
::
++ del-subs :: XX per path?
|= [a=hasp %json b=wire c=path] ^+ ..ix
(hurl-note [a b] [%g %nuke [- + ~]:a him])
:: (hurl-note [a b] [%b %deal [him -.a] +.a %pull ~])
:: (hurl-note [a b] [%g %nuke [- + ~]:a him])
(hurl-note [a b] [%b %deal [him -.a] +.a %pull ~])
::
++ get-rush
|= [a=whir-of b=json] ^+ ..ix
@ -1254,7 +1254,9 @@
::
++ pass-took
|= a=[p=hasp wire]
(pass-note(hen `~) [%of ire (gsig a)] [%g %took [- + ~]:p.a him])
%+ pass-note(hen `~)
[%of ire (gsig a)]
[%b %deal [him -.p.a] +.p.a %pump ~]
::
++ pop-duct =^(ned med ~(get to med) abet(hen ned))
++ poll

View File

@ -54,7 +54,7 @@
==
++ react-js (crip tape)
:: ++ js react-js :: convert to %js
++ mime [/text/javascript (taco react-js)] :: convert to %mime
++ mime [/text/javascript (taco react-js)] :: convert to %mime
--
++ grab |% :: convert from
++ noun manx :: clam from %noun

View File

@ -55,8 +55,7 @@ module.exports = recl
$('#audi').focus()
return
if @state.audi.length is 0 and $('#audi').text().trim().length > 0
audi = @state.ludi
@_setAudi()
audi = if @_setAudi() then @_setAudi() else @state.ludi
else
audi = @state.audi
audi = @addCC audi
@ -138,10 +137,13 @@ module.exports = recl
if valid is true
v = $('#audi').text()
v = v.split " "
v = window.util.expandAudi v
for k,_v of v
if _v[0] isnt "~" then v[k] = "~#{_v}"
v = window.util.expandAudi v
StationActions.setAudience v
v
else
false
getTime: ->
d = new Date()

View File

@ -720,8 +720,7 @@ module.exports = recl({
return;
}
if (this.state.audi.length === 0 && $('#audi').text().trim().length > 0) {
audi = this.state.ludi;
this._setAudi();
audi = this._setAudi() ? this._setAudi() : this.state.ludi;
} else {
audi = this.state.audi;
}
@ -806,14 +805,17 @@ module.exports = recl({
if (valid === true) {
v = $('#audi').text();
v = v.split(" ");
v = window.util.expandAudi(v);
for (k in v) {
_v = v[k];
if (_v[0] !== "~") {
v[k] = "~" + _v;
}
}
return StationActions.setAudience(v);
v = window.util.expandAudi(v);
StationActions.setAudience(v);
return v;
} else {
return false;
}
},
getTime: function() {

View File

@ -75,6 +75,7 @@ html {
font-family: "bau", "Helvetica Neue", helvetica, arial, sans-serif;
}
code,
pre,
li:before,
.spin,
#bred a {
@ -126,13 +127,16 @@ h3 code {
font-size: inherit;
padding: 0.3rem;
}
pre,
code {
font-size: 0.8rem;
}
pre {
background-color: #f5f5f5;
padding: 0.3rem;
margin-left: -0.3rem;
}
code {
font-size: 0.8rem;
line-height: 1.2rem;
background-color: #f4f4f4;
margin-top: -0.05rem;

View File

@ -5,6 +5,7 @@ html
font-family "bau","Helvetica Neue",helvetica,arial,sans-serif
code
pre
li:before
.spin
#bred a
@ -56,13 +57,16 @@ h3 code
font-size inherit
padding .3rem
pre
code
font-size .8rem
pre
background-color #f5f5f5
padding .3rem
margin-left -.3rem
code
font-size .8rem
line-height 1.2rem
background-color #f4f4f4
margin-top -.05rem

View File

@ -1,7 +1,7 @@
::
/? 314
/= gas /$ fuel
/= ral /: /=home=/pub /% /react-js/
/= ral /: /=home= /% /react-js/
::
::::
::

View File

@ -1,13 +1,13 @@
::
/? 314
/= gas /$ fuel
/= ral /: /=home=/pub /% /react-js/
/= pal /: /=home=/pub
/= ral /: /=home= /% /react-js/
/= pal /: /=home=
/; |= a=(map ,@ta cord) a
/% 2
/_ /react-js/
::
/= sal /: /=home=/pub
/= sal /: /=home=
/; |= a=(map ,@ta json) a
/% 2
/_ /react-snip-json/