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

This commit is contained in:
Galen Wolfe-Pauly 2015-04-10 10:55:24 -07:00
commit 01a8563bc4
7 changed files with 297 additions and 40 deletions

View File

@ -226,8 +226,9 @@
++ add-poll :: inject dependency
|= [dep=@uvH max=[[%html ~] [[%head ~] hed=marl] [[%body ~] manx marl] ~]]
^- manx
=. hed.max :_(hed.max ;meta(charset "utf-8", urb_injected "");)
?~ dep max
max(hed :_(hed.max ;script@"/~/on/{<dep>}.js";))
max(hed :_(hed.max ;script@"/~/on/{<dep>}.js"(urb_injected "");))
::
++ add-json :: inject window.urb
|= [urb=json jaz=cord] ^- cord
@ -554,7 +555,11 @@
(fail 404 p.sih p.q.sih)
=* cay p.q.sih
?. ?=(%mime p.cay)
(back tee p.sih %mime cay)
=- (back tee p.sih %mime cay(q.q -))
?+ p.cay q.q.cay :: inject dependency long-poll
%urb =| urb=[[%html ~] [[%head ~] marl] [[%body ~] manx marl] ~]
.*(.(urb q.q.cay) !=((add-poll p.sih urb)))
==
~| q.q.cay
=+ ((hard ,[mit=mite rez=octs]) q.q.cay)
(give-thou 200 [content-type/(moon mit)]~ ~ rez)

View File

@ -439,10 +439,6 @@
==
fun
::
++ coze :: pass dependencies
|* [hoc=(bolt) fon=$+((set beam) (burg))]
?+(-.q.hoc hoc %0 (cope hoc (fon p.q.hoc)))
::
++ dash :: process cache
|= cof=cafe
^+ +>
@ -505,7 +501,7 @@
(fine cof p.u.q.vex)
::
++ fang :: protocol door
|= [cof=cafe dep=(set beam) for=mark bek=beak]
|= [cof=cafe for=mark bek=beak]
^- (bolt vase)
=+ pax=/door/[for]/mar
=+ ^= bem ^- beam
@ -516,9 +512,7 @@
?: ?=([~ ~ *] (ska %cy (tope [oak pax])))
oak
bek
=^ deh r.cof (daze(deh.bay r.cof) dep) :: XX sanity
=+ arg=`spur`[%dep (scot %uv deh) ~]
(cope (fade cof %hook bem) abut:(meow bem arg))
(cope (fade cof %hook bem) abut:(meow bem ~))
::
++ fair :: hood parsing rule
|= bem=beam
@ -729,7 +723,7 @@
?: ?=(?(%gate %core %door %hoon %hook) for)
:: ~& [%lake-easy for bek]
(fine cof sam)
%+ cope (fang cof ~ for bek)
%+ cope (fang cof for bek)
|= [cof=cafe tux=vase]
=+ bob=(slot 6 tux)
?: (~(nest ut p.bob) | p.sam)
@ -792,7 +786,7 @@
++ lily :: translation targets
|= [cof=cafe for=mark bek=beak]
^- (bolt (list ,@tas))
=+ raf=(fang cof ~ for bek)
=+ raf=(fang cof for bek)
?: =(%2 -.q.raf) (fine p.raf ~)
%+ cope raf
|= [cof=cafe vax=vase]
@ -821,9 +815,9 @@
%+ cope (lion cof for -.bem haz)
|= [cof=cafe wuy=(list ,@tas)]
?~ wuy (flue cof)
%+ coze (make cof %bake i.wuy bem arg)
|= dep=(set beam) |= [cof=cafe hoc=cage]
%+ cope (lope cof dep i.wuy t.wuy -.bem q.hoc)
%+ cope (make cof %bake i.wuy bem arg)
|= [cof=cafe hoc=cage]
%+ cope (lope cof i.wuy t.wuy -.bem q.hoc)
|= [cof=cafe vax=vase]
((fest bem) cof vax)
::
@ -839,18 +833,18 @@
^$(s.mob t.s.mob, mer [i.s.mob mer])
::
++ link :: translate
|= [cof=cafe dep=(set beam) too=mark for=mark bek=beak vax=vase]
|= [cof=cafe too=mark for=mark bek=beak vax=vase]
^- (bolt vase)
?: =(too for) (fine cof vax)
?: |(=(%noun for) =(%$ for))
((lake too bek) cof vax)
%+ cope (fang cof dep for bek)
%+ cope (fang cof for bek)
|= [cof=cafe pro=vase]
?: &((slob %grow p.pro) (slob too p:(slap pro [%cnzy %grow])))
%+ cope (keel cof pro [[%& 6]~ vax]~)
|= [cof=cafe pox=vase]
(maim cof pox [%tsgr [%cnzy %grow] [%cnzy too]])
%+ cope (fang cof dep too bek)
%+ cope (fang cof too bek)
|= [cof=cafe pro=vase]
=+ ^= zat ^- (unit vase)
?. (slob %grab p.pro) ~
@ -895,10 +889,10 @@
--
::
++ lope :: translation pipe
|= [cof=cafe dep=(set beam) for=mark yaw=(list mark) bek=beak vax=vase]
|= [cof=cafe for=mark yaw=(list mark) bek=beak vax=vase]
^- (bolt vase)
?~ yaw (fine cof vax)
%+ cope (link cof dep i.yaw for bek vax)
%+ cope (link cof i.yaw for bek vax)
|= [cof=cafe yed=vase]
^$(cof cof, for i.yaw, yaw t.yaw, vax yed)
::
@ -973,18 +967,18 @@
::
%cast
%+ cool |.(leaf/"ford: cast {<p.kas>}")
%+ coze $(kas q.kas)
|= dep=(set beam) |= [cof=cafe cay=cage]
%+ cope $(kas q.kas)
|= [cof=cafe cay=cage]
=+ bek=[our %main %da now] :: XX
:: VV ::
%+ cope (link cof dep p.kas p.cay bek q.cay)
%+ cope (link cof p.kas p.cay bek q.cay)
|= [cof=cafe vax=vase]
(fine cof [p.kas vax])
::
:: %+ coze (lion cof p.kas bek [p.cay]~)
:: |= dep=(set beam) |= [cof=cafe wuy=(list ,@tas)]
:: %+ cope (lion cof p.kas bek [p.cay]~)
:: |= [cof=cafe wuy=(list ,@tas)]
:: ?~ wuy (flaw cof [%leaf "ford: no path: {<[p.cay p.kas]>}"]~)
:: %+ cope (lope cof dep i.wuy t.wuy bek q.cay)
:: %+ cope (lope cof i.wuy t.wuy bek q.cay)
:: |= [cof=cafe vax=vase]
:: (fine cof [p.kas vax])
::

View File

@ -104,7 +104,7 @@
^- [sole-edit sole-share]
?> &(=(his.ler his.ven) (lte own.ler own.ven))
?> &(=(his.ler his.ven) (lte own.ler own.ven))
?> |(!=(own.ler own.ven) =(haw (sham buf)))
?> |(!=(own.ler own.ven) =(haw (sham buf)) =(haw 0)) :: trust the clock
=. leg (scag (sub own.ven own.ler) leg)
:: ~? !=(own.ler own.ven) [%miss-leg leg]
=+ dat=(transmute [%mor leg] ted)

View File

@ -0,0 +1,38 @@
::
:::: /hook/door/sole-action/mar
::
/? 314
/- *sole
!:
::::
::
|_ sole-action
::
++ grab :: convert from
|%
++ json
|= jon=^json ^- sole-action
%- need %. jon
=> [jo ..sole-action]
|^ =- ~! (-) -
(fo %ret (of det/change ~))
++ fo
|* [a=term b=fist]
|=(c=json ?.(=([%s a] c) (b c) (some [a ~])))
::
++ ra
|* [a=[p=term q=fist] b=fist]
|= c=json %. c
?.(=(%a -.c) b (pe p.a (ar q.a)))
::
++ change (ot ler/(at ni ni ~) ted/(cu |*(a=* [0v0 a]) edit) ~)
++ char (cu turf so)
++ edit
%+ fo %nop
%+ ra mor/|=(json (edit +<))
(of del/ni set/(cu tuba sa) ins/(ot at/ni new/char ~) ~)
--
::
++ noun sole-action :: clam from %noun
--
--

View File

@ -0,0 +1,55 @@
::
:::: /hook/door/sole-effect/mar
::
/? 314
/- *sole
!:
::::
::
|%
++ mar-sole-change :: XX dependency
|_ cha=sole-change
++ grow
|% ++ json
^- ^json
=+ cha
=< (jobe ted/(. ted) ler/a/~[(jone own.ler) (jone his.ler)] ~)
|= ted=sole-edit
?- -.ted
%nop [%s 'nop']
%mor [%a (turn p.ted ..$)]
%del (joba %del (jone p.ted))
%set (joba %set (jape (tufa p.ted)))
%ins (joba %ins (jobe at/(jone p.ted) new/s/(tuft q.ted) ~))
==
--
--
++ wush
|= [wid=@u tan=tang]
^- tape
=+ rolt=|=(a=wall `tape`?~(a ~ :(weld i.a "\0a" $(a t.a))))
(rolt (turn tan |=(a=tank (rolt (wash 0^wid a)))))
::
--
!:
|_ sef=sole-effect
::
++ grab :: convert from
|%
++ noun sole-effect :: clam from %noun
--
++ grow
|%
++ json
^- ^json
?+ -.sef ~|(unsupported-effect/-.sef !!)
%mor [%a (turn p.sef |=(a=sole-effect json(sef a)))]
%err (joba %hop (jone p.sef))
%txt (joba %txt (jape p.sef))
%tan (joba %tan (jape (wush 160 p.sef)))
%det json:~(grow mar-sole-change +.sef)
%pro (jobe vis/b/vis.sef tag/s/tag.sef cad/(jape cad.sef) ~)
?(%bel %clr %nex) (joba %act %s -.sef)
==
--
--

View File

@ -2,7 +2,7 @@
:::: /hook/door/urb/mar
::
/? 314
/= dep /$ |=([^ but=path] `@uvH`?>(?=([%dep @ ~] but) (slav %uv i.t.but)))
:: /= dep /$ |=([^ but=path] `@uvH`?>(?=([%dep @ ~] but) (slav %uv i.t.but)))
!:
|_ own=manx
::
@ -15,17 +15,17 @@
|% :: convert from
++ noun manx :: clam from %noun
++ hymn :: inject into %hymn
|= old=manx
~| hymn//mal-formed
:: ~| old
?> ?=([[%html ~] [[%head ~] *] [[%body ~] ^] ~] old) :: XX static
:: =+ bek=(sa (turn (turn dep) |=(a=beam (tope a(s ~)))))
%_ old
c.i.c
:- ;meta(charset "utf-8", urb_injected "");
?~ dep c.i.c.old
:- ;script@"/~/on/{<dep>}.js";
c.i.c.old
==
|= old=manx old :: moved to %eyre
:: ~| hymn//mal-formed
:: :: ~| old
:: ?> ?=([[%html ~] [[%head ~] *] [[%body ~] ^] ~] old) :: XX static
:: :: =+ bek=(sa (turn (turn dep) |=(a=beam (tope a(s ~)))))
:: %_ old
:: c.i.c
:: :- ;meta(charset "utf-8", urb_injected "");
:: ?~ dep c.i.c.old
:: :- ;script@"/~/on/{<dep>}.js";
:: c.i.c.old
:: ==
--
--

165
main/pub/sole/fab/hymn.hook Normal file
View File

@ -0,0 +1,165 @@
:: Console front-end
::
:::: /hook/hymn/fab/sole/pub
::
/? 310
|%
++ cdnj |=(a=tape ;script(src "//cdnjs.cloudflare.com/ajax/libs/{a}");)
--
::
::::
::
^- manx
;html
;head
;title: Sole
;* %- turn :_ cdnj ^- wall
:~ "jquery/2.1.1/jquery.min.js"
"mousetrap/1.4.6/mousetrap.js"
"react/0.11.0/react.js"
==
;script(src "/~/at/main/lib/urb.js");
;script: urb.appl = 'dojo'
;style:'''
#term {
width: 100%;
}
#term * {
margin: 0px;
}
'''
==
;body
;div#err;
;div#term:""
;script(type "text/coffeescript") ;- %- trip
'''
[DOM,recl,rend] = [React.DOM, React.createClass, React.renderComponent]
[div, pre] = [DOM.div, DOM.pre]
Matr = recl render: ->
[pro,cur] = [@props.prompt + " ", @props.cursor + 1]
prompt = "#{pro.slice(0,cur)}\u0332#{pro.slice(cur)}"
lines = [prompt, @props.rows...]
div {}, lines.slice().reverse().map (lin)->
pre {}, lin
$ ->
termRev = 0
pressed = []
deltim = null
met = $('<pre>').text('m').css(display: 'none').appendTo(term).width()
subs = ""
# $(window).resize ->
# window.termWif = ($(term).width() / met).toFixed()
# path = "/new/#{termWif}"
# if path is subs
# return
# if subs
# urb.unsubscribe {path:subs}
# subs = path
# urb.subscribe {path}, (err,dat)->
# if err or dat.data.ok
# return;
# syncRev = dat.data.rev
# unless termRev > syncRev
# termRev = syncRev
# matr.setProps rows: dat.data.stak
# document.title = "Matrix" # XX debug
# $(window).resize()
matr = rend (Matr rows:[], prompt:"", cursor:1), term
flash = ($el, background)->
$el.css {background}
if background
setTimeout (()-> flash $el,''), 50
peer = (ruh) ->
switch false
when !ruh.map then ruh.map peer
# when !ruh.pro then matr.setProps prompt: ruh.pro
# when !ruh.hop then matr.setProps cursor: ruh.hop
# when !ruh.out
# matr.setProps rows: [ruh.out, matr.props.rows...]
# when !ruh.act then switch ruh.act
# when 'clr' then matr.setProps rows:[]
# when 'bel' then flash ($ 'body'), 'black'
# else throw "Unknown "+(JSON.stringify ruh)
else console.log ruh
urb.bind "/sole", {wire:"/"}, (err,d)->
if d.data then peer d.data
#later = (data)->
# if data
# pressed.push data
# clearTimeout deltim
# setTimeout (->
# if urb.reqq.length > 0
# return deltim = later()
# urb.send data: pressed
# pressed = []
# ), 500
Mousetrap.handleKey = (char, mod, e)->
norm = {
capslock: 'caps'
pageup: 'pgup'
pagedown: 'pgdn'
backspace: 'baxp'
enter: 'entr'
}
key =
if char.length is 1
if e.type is 'keypress'
str: char
else if e.type is 'keydown'
if char isnt 'space'
act: norm[char] ? char
else if e.type is 'keyup' and norm[key] is 'caps'
act: 'uncap'
if key
e.preventDefault()
urb.send mark: 'dill-belt', data: {mod,key}
# amod = (arr)->
# for i in arr
# unless mod.indexOf(i) < 0
# return yes
# no
# if key.str or key.act is 'baxp' or key.act is 'entr'
# termRev++
# [bot, rest...] = old = matr.props.rows
# matr.setProps rows:(
# switch key.act
# when 'baxp'
# if amod ['ctrl', 'meta']
# ['', rest...]
# else if amod ['alt']
# [(bot.replace /\ *[^ ]*$/, ''), rest...]
# else if bot and bot.length
# [bot.slice(0, -1), rest...]
# else if rest[0] and rest[0].length
# res = rest.slice()
# res[0] = res[0].slice(0, -1)
# res
# else rest
# when 'entr'
# ['', old...]
# when undefined
# if mod.length > 1 or (mod.length and !amod ['shift'])
# old
# else unless old and bot isnt null
# [key.str]
# #else if bot.length is termWif
# # [key.str, old...]
# else [bot + key.str, rest...]
# )
# document.title = "Matri" # XX debug
# later {mod, key}
'''
==
;+ (cdnj "coffee-script/1.7.1/coffee-script.min.js")
== ==