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

This commit is contained in:
C. Guy Yarvin 2014-12-07 20:01:45 -08:00
commit d2b48300f3
6 changed files with 253 additions and 2 deletions

View File

@ -782,6 +782,11 @@
++ bu :: boolean not
|=(jon=json ?.(?=([%b *] jon) ~ [~ u=!p.jon]))
::
++ ci :: maybe transform
|* [poq=$+(* *) wit=fist]
|= jon=json
(biff (wit jon) poq)
::
++ cu :: transform
|* [poq=$+(* *) wit=fist]
|= jon=json

View File

@ -0,0 +1,54 @@
/- *radio
!:
::::
::
|_ [hide ~]
++ peek
|= [@ pax=path]
:: ?: |
:: radio-report/(report grams/[7 "foo" ~])
=+ :+ dat=(trip '{ping: {party:"rom", presence:"talk"}}')
=- dat2=(trip -)
'''
{ publish:
[{ serial:
"0vs.tteei.qlhhr.v09gs.s3iml.7him6.2injj.uiiu6.hg990.fha70.cqdtm",
statement:
{ now: Date.now(),
speech:
{ say: "Hello world"
}
},
audience:
{ "~zod/rume": "received",
"twitter/_urbit": "pending"
}
}]
}
'''
^= js
%- trip
'''
function come(a){
urb.send({
appl: 'radio-test',
mark: 'radio-command',
data: a
})
}
'''
:- %hymn
^- manx
;html
;head
;script(src "/gen/main/lib/urb.js");
;script: {js}
;script: dat = {dat2}
==
;body:button(onclick "come(dat)"):"Ping"
==
++ poke-radio-command
|= [ost=bone ship com=command]
~& got/com
[[ost %give /nice]~ +>]
--

View File

@ -196,7 +196,7 @@
[[ost %give +.sih] (spam [p.tel q.tel new])]
==
==
==
==
::
++ send
|= mez=mess
@ -259,4 +259,15 @@
?. ?=(?(%fork %resp %txt %kyev) i.pax) !!
=+ abet:(pour:(se hid ost our.hid hiz t.pax) i.pax sih)
[-< +>.$(hiz ->)]
::
++ prep
|= old=(unit (unit axle))
^- [(list move) _+>]
:- ~
%_ +>.$
hiz
?. ?=([~ ~ *] old) hiz
%- ~(run by hiz.u.u.old)
|=(term-line [p q ~])
==
--

View File

@ -0,0 +1,89 @@
::
:::: /hook/door/radio-command/mar
::
/? 314
/- *radio
!:
|_ cod=command
::
++ grab :: convert from
|%
++ noun command :: clam from %noun
++ json
=> [jo ..command]
|= a=json ^- command
=- (need ((of -) a))
=< :~ publish/(ar thot)
review/(ar thot)
design/(ot party/so config/(mu conf) ~)
ping/(ot party/so presence/(ci (soft presence) so) ~)
==
|%
++ op :: parse keys of map
|* [fel=_rule wit=fist]
%+ cu mo
%- ci :_ (om wit)
|= a=(map cord ,_(need *wit))
^- (unit (list ,_[(wonk *fel) (need *wit)]))
(zl (turn (~(tap by a)) (head-rush fel)))
::
++ as :: array as set
:: |*(a=fist (cu sa (ar a))) :: XX types
|* a=fist
%- cu :_ (ar a)
~(gas in *(set ,_(need *a)))
::
++ lake |*(a=_,* $+(json (unit a)))
++ peach
|* a=_[rule rule]
|= tub=nail
^- (like (each ,_(wonk (-.a)) ,_(wonk (+.a))))
%. tub
;~(pose (stag %& -.a) (stag %| +.a))
::
++ head-rush
|* a=_rule
|* [b=cord c=*]
=+ nit=(rush b a)
?~ nit ~
(some [u.nit c])
::
::
++ thot
^- $+(json (unit thought))
%- ot :~
serial/(ci (slat %uv) so)
audience/audi
statement/stam
==
::
++ audi (op stati (ci (soft delivery) so)) :: audience
::
++ stati
^- $+(nail (like station))
%+ peach
;~((glue fas) ;~(pfix sig fed:ag) urs:ab)
%+ sear (soft partner)
;~((glue fas) sym (cook crip (star prn))) :: XX [a-z0-9_]+
::
++ stam
^- $+(json (unit statement))
=- (ot now/di speech/(of -) ~)
:~ own/so
say/so
exp/(cu |=(a=cord [a ~]) so)
inv/(ot ship/(su fed:ag) party/(su urs:ab) ~)
==
::
::
++ conf
^- $+(json (unit config))
%- ot :~
sources/(as (su stati))
:- %cordon
%+ cu |*(a=^ ?~(-.a a a)) :: XX do type stuff
(ot white/bu list/(as (su fed:ag)) ~)
==
--
-- --

View File

@ -0,0 +1,90 @@
::
:::: /hook/door/radio-report/mar
::
/? 314
/- *radio
!:
=< ~& json:~(grow . (report grams/[7 "foo" ~])) .
|_ rep=report
::
++ grab :: convert from
|%
++ noun report :: clam from %noun
--
++ grow
|%
++ mime [/text/json (taco (crip (pojo json)))]
++ json
|^ %+ joba -.rep
?- -.rep
%config ~! rep (conf +.rep)
%house [%a (turn (~(tap by +.rep)) joce)]
%grams (jobe num/(jone p.rep) tele/[%a (turn q.rep gram)] ~)
%group %.(+.rep (jome phon stas))
==
++ joce |=(a=span [%s a])
++ jope |=(a=ship (jape +:<a>))
++ joke |=(a=tank [%s (role (turn (wash 0^80 a) crip))])
++ jode |=(a=time (jone (div (mul (sub a ~1970.1.1) 1.000) ~s1)))
:: ++ jase
:: |* a=,json
:: |= b=(set ,_+<.a) ^- json
:: ~! b
:: [%a (turn (~(tap in b)) a)]
::
++ jome :: stringify keys
|* [a=_cord b=_json]
|= c=(map ,_+<.a ,_+<.b)
(jobe (turn (~(tap by c)) (both a b)))
::
++ both :: cons two gates
|* [a=_,* b=_,*]
|=(c=_[+<.a +<.b] [(a -.c) (b +.c)])
::
::
++ phon |=(a=ship (scot %p a))
++ gram |=(telegram (jobe ship/(jope p) thought/(thot q) ~))
++ thot
|= thought
(jobe serial/(jape <p>) audience/(audi q) statement/(stam r) ~)
::
++ audi (jome stan joce)
++ stan
|= a=station ^- cord
%- crip
?~ -.a "{<p.p.a>}/{(trip q.p.a)}"
?- -.p.a
%twitter "{(trip -.p.a)}/{(trip p.p.a)}"
==
::
++ stam |=(statement (jobe time/(jode p) speech/(spec q) ~))
++ spec
|= a=speech
%+ joba -.a
?- -.a
?(%own %say) [%s p.a]
%exp (jobe code/[%s p.a] done/?~(q.a ~ (joke u.q.a)) ~)
%inv (jobe ship/(jope p.a) party/[%s q.a] ~)
==
::
++ stas |=(status (jobe presence/(joce p) time/(jode q) human/(huma r) ~))
++ huma
|= human
%^ jobe
hand/?~(hand ~ [%s u.hand])
:- %true
?~ true ~
=+ u.true
(jobe first/[%s p] middle/?~(q ~ [%s u.q]) last/[%s r] ~)
~
::
++ conf
|= config
%- jobe :~
sources/[%a (turn (~(tap in sources)) |=(a=station [%s (stan a)]))]
=- cordon/(jobe white/[%b -.cordon] list/[%a -] ~)
(turn (~(tap in p.cordon)) jope) :: XX jase
==
--
-- --

View File

@ -9,6 +9,8 @@
[%publish (list thought)] :: originate
[%review (list thought)] :: deliver
[%ping (pair span presence)] :: declare status
:: ping:{room:"foo" presence:"hear"}
:: ping:["foo", "hear"]
== ::
++ config :: party configuration
$: sources=(set station) :: pulls from
@ -34,7 +36,7 @@
++ status (trel presence ,@da human) :: participant
++ speech :: party action
$% [%own p=@t] :: @ or /me
[%exp p=@t q=tank] :: program output
[%exp p=@t q=(unit tank)] :: program output
[%say p=@t] :: normal line
[%inv p=ship q=span] :: invite to
== ::