diff --git a/ape/ask.hoon b/ape/ask.hoon new file mode 100644 index 000000000..d6953849c --- /dev/null +++ b/ape/ask.hoon @@ -0,0 +1,57 @@ +:: +:::: /hoon+ask+ape + :: +/? 314 +/+ sole +[. sole] +|% + ++ card + $% {$diff $sole-effect sole-effect} + == +-- +!: +|_ {bow/bowl adr/(set cord) sos/(map bone sole-share)} +++ peer-sole + |= path + ^- (quip {bone card} +>) + ~| [%not-in-whitelist src.bow] + ?> (~(has in (sa (limo ~zod our.bow ~talsur-todres ~))) src.bow) + :_ +>.$(sos (~(put by sos) ost.bow *sole-share)) + =- [(effect %mor pro+[& %$ ""] -)]~ + =+ all=adrs + [tan+(turn all message) (turn all put-mail)] +:: +++ adrs (sort (~(tap by adr)) aor) +++ effect |=(fec/sole-effect [ost.bow %diff %sole-effect fec]) +++ message |=(ask/@t leaf+"ask: {(trip ask)}") +++ put-mail |=(ask/@t =+(pax=(rash ask unix-path) [%sav pax ''])) +++ unix-path :: split into path of "name" and "extension" + ;~ (glue dot) + (cook crip (star ;~(less dot next))) + ;~(plug (cook crip (star next)) (easy ~)) + == +:: +++ poke-ask-mail + |= ask/@t + ^- (quip {bone card} +>) + ~| have-mail+ask + ?< (~(has in adr) ask) + :_ +>.$(adr (~(put in adr) ask)) + =+ [mez=[(message ask)]~ sav=(put-mail ask)] + %+ turn (prey /sole bow) + |=({ost/bone ^} (effect(ost.bow ost) %mor tan+mez sav ~)) +:: +++ poke-sole-action + |= act/sole-action + ^- (quip {bone card} +>) + ?- -.act + $clr `+>.$ + $ret [[(effect tan+(turn adrs message))]~ +>.$] :: re-print list + $det :: reject all input + =+ som=(~(got by sos) ost.bow) :: XX this code belongs in a library + =^ inv som (~(transceive sole som) +.act) + =^ det som (~(transmit sole som) inv) + =. sos (~(put by sos) ost.bow som) + [[(effect det+det)]~ +>.$] + == +-- diff --git a/ape/bit.hoon b/ape/bit.hoon new file mode 100644 index 000000000..dee970827 --- /dev/null +++ b/ape/bit.hoon @@ -0,0 +1,220 @@ +:: +:: +:::: + :: +/? 314 +/- talk, bit-api +/+ talk, sole, http +!: +:::: sivtyv-barnel + :: be sure to have oauth2-code markk +[talk bit-api .] +|% +++ axle +$: cred/(unit {app-secret/@t client-id/@t}) + oauth-code/(unit @t) + auth/(unit {access/@t refresh/@t}) + contacts/(map @t @t) + outgoing/(map ship @t) incoming/(map @t ship) +== +++ move {bone note} +++ hapt {ship path} +++ note + $% {$send wire {ship term} $poke mesa} + {$them wire (unit hiss)} + {$hiss wire mark bit-any} + == +++ gift + $% {$nice $~} + {$mean ares} + == +++ sign + $% {$thou p/httr} + {$unto $coup p/(unit tang)} + == +++ mesa + $% {$bit-addr-request $~} + {$bit-addr-made @t} + {$talk-command command} + == +-- +:: +!: +|_ {hid/bowl vat/axle} +:: ++ prep ~&(%bit-prep-wipe ,_`.) +++ return [*(list move) .] +++ redirect-uri [hostname `/~~/home+pub+bit+fab ~] +++ hostname ^- hart + ?+ (clan our.hid) !! + $czar [| ?+(our.hid `8.443 $~fyr `8.444) `/localhost] + $duke [| `8.444 `/org+urbit+(crip +:)] + == +++ auth-url + %+ weld "https://sandbox.coinbase.com+oauth+authorize" + %- tail:earn :~ + 'response_type'^%code + 'client_id'^client-id:(need cred.vat) + 'redirect_uri'^(crip (earn redirect-uri)) + 'scope'^'user balance buy sell send transactions addresses' + 'meta[send_limit_amount]'^'1' + 'meta[send_limit_curency]'^'BTC' + 'meta[send_limit_period]'^'day' + == +++ old-api + |= {pour-path/wire end-point/path req/$@($get {$post p/json})} + ^- move + %^ send:http ost.hid pour-path + [/com+coinbase+api v1/end-point req ~ ['access_token' access:(need auth.vat)]~] +:: +++ api-call + |= {res/mark req/bit-api-call} ^+ return + ~| %missing-access-token + [[ost.hid %hiss / res bit-api-call+[access:(need auth.vat) req]]~ +>.$] +:: +++ print |=(msg/tape [[(publish [%lin & (crip msg)]~)]~ +>.$]) +++ callback-uri [hostname [`%json /~/to+[dap.hid]/json] ~[anon+'' wire+'/']] +++ poke-auth + |= arg/{secr/cord id/cord} + =. cred.vat `arg + =+ prl=`purl`(need (epur (crip auth-url))) + :_ +>.$ + :- %- publish + :~ [%lin & 'secret and client id saved successfully'] + [%lin & 'please click on the url below to continue authentication'] + [%url prl ~] + == + ~ +:: +++ sigh-tang |=({* err/tang} (mean err)) +++ send-friend :: inter-app interface + |= {way/wire his/ship mez/$%({$bit-addr-request $~} {$bit-addr-made @t})} + ^- move + [ost.hid %send way [his dap.hid] %poke mez] +:: +++ poke-bit-send |=(req/bit-send (api-call %bit-transaction send+req)) +++ sigh-bit-transaction + |=({* trid/@t} (print "transaction success {(trip trid)}")) +:: +++ poke-bit-ship-send :: send to ship + |= {to/ship amount/@t} + =. outgoing.vat (~(put by outgoing.vat) to amount) + :_ +>.$ + :_ ~ + (send-friend /sent to %bit-addr-request ~) +:: +++ poke-bit-addr-request :: give your address to receive bit + |= $~ :: gen new address with callback + :_ +>.$ + :_ ~ + %+ old-api /addr-request+(scot %p src.hid) + :+ /addresses %post + %+ joba %address + %- jobe :~ + label+(jape "address for {}") + 'callback_url'^(jape (earn callback-uri)) + == + :: +++ pour-addr-request :: send new address to sender + |= {pax/path rez/json} + =+ adr=(need ((ot address+so ~):jo rez)) + =+ his=(slav %p +<.pax) + ~! incoming.vat + =. incoming.vat + (~(put by incoming.vat) adr his) + :_ +>.$ + :_ ~ + (send-friend [%message ~] his %bit-addr-made adr) +:: +++ poke-bit-addr-made :: receive address for sending + |= addr/@t + =+ amount=(~(got by outgoing.vat) src.hid) :: get amount to send + (api-call %bit-transaction txt-send+[addr amount]) +:: +++ poke-oauth2-code + |= code/cord + =. oauth-code.vat + [~ code] + ?< ?=($~ cred.vat) + =+ req=[code [client-id app-secret]:u.cred.vat redirect-uri] + [[ost.hid %hiss / %oauth-tokens bit-get-token+req]~ +>.$] +:: +++ sigh-oauth-tokens + |= {wire toke/{access/@t refresh/@t}} + =.(auth.vat `toke (print "authenticated.")) +:: +++ poke-buy + |=(arg/{amount/@t currency/@t} ?<(=(amount.arg ~) (api-call %json %buy arg))) +:: +++ poke-sell + |=(arg/{amount/@t currency/@t} ?<(=(amount.arg ~) (api-call %json %sell arg))) +++ sigh-json |=({* a/json} ~&(a return)) +++ poke-list |=($~ (api-call %bit-accounts %list ~)) +++ sigh-bit-accounts |=({* acc/bit-accounts} ~&(accounts=acc return)) +++ poke-send-raw + |= arg/{to/@t amone/(unit @t) cur/(unit @t) amtwo/(unit @t) nt/(unit @t)} + =+ ^= adr + ?~ (~(get by contacts.vat) to.arg) to + ~&('contact-exists' (~(get by contacts.vat) to.arg)) + =+ ^= info + ?~ cur.arg + [to+s+to.arg amount+s+(need amone.arg) ~] + ?~ nt.arg + :* to+s+to.arg + 'amount_currency_iso'^s+(need cur.arg) + 'amount_string'^s+(need amtwo.arg) + ~ + == + :* to+s+to.arg + amount+s+(need amtwo.arg) + 'amount_string'^s+(need amtwo.arg) + ~ + == + =+ ^= pst + (jobe transaction+(jobe info) ~) + [[(old-api /send /transactions+'send_money' %post pst) ~] +>.$] +:: +++ poke-json + |= arg/json + ~& arg + =+ [adr amo]=(need %.(arg (ot address+so amount+no ~):jo)) + =+ frm=(~(get by incoming.vat) adr) + (print "just received {(trip amo)} BTC from {}") + ::(old-api /get-id /transactions+[transaction-id] %get) +:: +++ pour-get-id :: display transaction info + |= {pax/path rez/json} + :_ +>.$ + :_ ~ + !! +:: +++ thou + |= {way/wire res/httr} + ?+ -.way !! + $message `+>.$ + ?($addr-request $get-id) + ~| 'must receive a 200' + ~| res + ?> =(200 p.res) + %- ?-(-.way $addr-request pour-addr-request, $get-id pour-get-id) + [way (rash q:(need r.res) apex:poja)] + == +:: +++ publish + |= act/(list speech) + ^- move + =+ ^= thotz + %+ turn act + |= sp/speech ^- thought + =+ ^= tail + :- ^- audience + :+ :- ^- partner + [%& our.hid ?+((clan our.hid) !! $czar %court, $duke %porch)] + ^- (pair envelope delivery) + [`envelope`[& ~] %pending] + ~ + ~ + `statement`[now.hid ~ sp] + :- `@`(sham eny.hid tail) + tail + [ost.hid %send /auth [our.hid %talk] %poke [%talk-command %publish thotz]] +-- diff --git a/ape/cloud.hoon b/ape/cloud.hoon new file mode 100644 index 000000000..b644549a6 --- /dev/null +++ b/ape/cloud.hoon @@ -0,0 +1,691 @@ +:: digital ocean fleet management +:: +:::: + :: +/? 314 +/- talk +:: +:: +:::: sivtyv-barnel + :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: data structures :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +!: +[talk .] +|% +++ instance + $: plat/?($do $gce) + name/@t + id/@t + status/@t + created/@da + snapshot/name/@t + == +++ image + $: plat/?($do $gce) + name/@t + id/@t + == +++ create-req-do + $: name/@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 gce/keys} + toke/{do/tokens gce/tokens} + insts/(map @t instance) + images/(map {@t @t} image) + == +++ keys {authc/(unit @t) client-secret/(unit @t)} +++ tokens {access/@t refresh/@t} +++ move {bone card} +++ card + $% {$diff $json json} + {$wait wire @da} + {$send wire {ship term} $poke $talk-command command} + {$them wire (unit hiss)} + == +++ droplet-action + $% {$start $~} + {$stop $~} + {$reboot $~} + {$delete $~} + {$snapshot p/@t} + == +++ cloud-command + $% {$action id/@t name/@t act/droplet-action} + {$create-do p/json} + {$create-gce p/json} + == +-- +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: miscellaneous functions :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +!: +|% +++ auth-queries + |= code/cord + :~ 'grant_type'^'authorization_code' + 'code'^code + :- 'client_id' + 'd8f46b95af38c1ab3d78ad34c2157a6959c23eb0eb5d8e393f650f08e6a75c6f' + 'redirect_uri'^'http://localhost:8443/home+pub+cloud+fab' + == +:: +++ parse-iso8601 + =< (cook to-time (parsf ;"{parse-day}T{parse-seconds}{parse-zone}")) + |% + ++ to-time + |= {{y/@u m/@u d/@u} t/{h/@u m/@u s/@u ms/@u} {syn/? zh/@u zm/@u}} + ^- @da + %- year + ^- date + =: h.t ?:(syn (sub h.t zh) (add h.t zh)) + m.t ?:(syn (sub m.t zm) (add m.t zm)) + == + [[& y] m d h.t m.t s.t (div (mul ms.t 0x1.0000) 1.000) ~] + ++ parse-day (parsf ;"{dem}\-{dem}\-{dem}") + ++ parse-seconds (parsf ;"{dem}:{dem}:{dem}{(optional ;~(pfix dot dem))}") + ++ optional |*(fel/rule ;~(pose fel (easy 0))) + ++ parse-zone + ;~ pose + (cold [& 0 0] (jest 'Z')) + (parsf ;"{parse-zone-sign}{dem}:{dem}") + == + ++ parse-zone-sign ;~(plug ;~(pose (cold & lus) (cold | hep))) + -- +++ parse-cloud-command + =+ jo + %- of :~ + [%create-gce some] + [%create-do some] + ::[%create-gce some] + :- %action + (ot id+so name+so act+parse-droplet-action ~) + == +++ parse-droplet-action + => jo + %- of :~ + [%start ul] + [%stop ul] + [%reboot ul] + [%delete ul] + [%snapshot so] + == +++ key-do + (mo [%start 'power_on'] [%stop 'shutdown'] [%reboot 'power_cycle'] ~) +:: +++ adapter-do + |= a/cord + (~(got by key-do) a) +:: +++ parse-ip-do + => jo + %- ot + :_ ~ v4/(ar (ot 'ip_address'^(su lip:ag) ~)) +:: +++ parse-ip-gce + => jo + %+ cu |=(a/(list (list @if)) `(list @if)`(zing a)) + (ar (ot 'accessConfigs'^(ar (ot 'natIP'^(su lip:ag) ~)) ~)) +:: +++ tail-url + |= a/cord + -:(flop q.q:(need (epur a))) +:: +++ parse-region + => jo + (ot name+so ~) +:: +++ parse-id-text + |= jon/json + ?.(?=({?($n $s) *} jon) ~ (some p.jon)) +:: +++ create-do-body + |= $: name/@t + size/@t + image/@t + ssh-keys/(list cord) + backups/(unit ?) + ipv6+(unit ?) + private-networking/(unit ?) + user-data/(unit @t) + == + %- jobe + :~ name+s+name + size+s+size + image+s+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) + == +:: +++ convert-do + |= a/?($start $stop $reboot $snapshot) + ?- a + $start + 'power_on' + $stop + 'shutdown' + $reboot + 'power_cycle' + $snapshot + 'snapshot' + == +:: +++ instance-to-json + |= a/(list instance) + ^- json + %+ joba 'instances' + :- %a + %+ turn a + |= instance + ^- json + %- jobe + :~ name+`json`s+name + id+s+id + status+s+status + created+s+(crip (dust (yore created))) + snapshot+s+snapshot + == +++ map-to-list + |= a/(map {@t @t} image) + ^- liz/(list image) + %+ turn (~(tap by a) *(list {{@t @t} image})) + |=(a/{{@t @t} image} `image`+.a) +:: +++ image-to-json + |= a/(list image) + %+ joba 'images' + :- %a + %+ turn a + |= image + ^- json + %- jobe + :~ name+s+name id+s+id == +-- +:::::::::::::::: +:: main door :: +:::::::::::::::: +!: +|_ {bowl vat/axle} +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: miscellaneous arms that have to be in main door for scope reasons :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +++ thou + |= {pour-path/path resp/?(httr *)} + ^- {(list move) _+>.$} + ~& unhandled-pour-path+resp + :_ +>.$ ~ +:: +++ httpreq + |= $: pour-path/wire :: must be in main door because of scope + domain/(list cord) + end-point/path + req-type/$?($get $delt {$post json}) + headers/math + queries/quay + == + ^- move + =+ ^- parsed-url/purl + :+ ^= host-port :: ++hart + :+ security=%.y + port=~ + host=[%.y [path=[%com domain]]] + endpoint=[extensions=~ point=end-point] :: ++pork, + q-strings=queries :: ++quay + =+ ^- request/hiss :: cast to hiss + :- parsed-url + ?@ req-type + [req-type headers ~] + [%post headers ~ (tact (pojo +.req-type))] + :^ ost %them pour-path + `(unit hiss)`[~ request] +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: manage supscriptions and publish to talk :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +++ peer + |= pax/path + ^- {(list move) _+>.$} + :_ +>.$ + =+ lis=(~(tap by insts.vat)) + [ost %diff %json (instance-to-json (turn lis |=(a/{@t instance} +.a)))]~ +:: +++ spam + |= jon/json + %+ turn (~(tap by sup)) + |= {sub/bone @ pax/path} + ^- move + [sub %diff %json jon] +:: +++ publish + |= {act/(list speech)} + ^- move + =+ ^= spchz + %+ turn act + |= sp/speech + =+ ^= tail + :- ^- audience + :+ :- `partner`[%& our ?+((clan our) !! $czar %court, $duke %porch)] + ^- (pair envelope delivery) + [`envelope`[& ~] %pending] + ~ + ~ + `statement`[now ~ sp] + ^- thought + :- `@`(sham eny tail) + tail + =+ mez=[%talk-command [%publish `(list thought)`spchz]] + [ost %send /pub [our %talk] %poke mez] +++ thou-pub |=($~ :_(+>.$ ~)) +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: authentication :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +++ poke-cloud-auth + |= {cde/cord typ/cord} + ^- {(list move) _+>.$} + ?: =(%do typ) + =. authc.do.auth.vat + [~ cde] + :_ +>.$ ~ + =. access.gce.toke.vat + cde + :_ +>.$ + :_ list-gce + (publish [%lin & 'successfully authenticated to gce']~) +:: +++ poke-cloud-secret + |= {secret/cord typ/cord} + ^- {(list move) _+>.$} + ?+ typ ~|(missing-platform=typ !!) + $do + =. client-secret.do.auth.vat + [~ secret] + :_ +>.$ + :_ ~ + %+ httpreq /do/auth + :^ ~[%digitalocean %cloud] `path`/v1/oauth/token + [%post ~] + :- ~ `quay`['client_secret'^secret (auth-queries (need authc.do.auth.vat))] + == +:: +++ thou-do-auth + |= {$~ resp/httr} + ^- {(list move) _+>.$} + ~| resp + =+ body=(rash q:(need r.resp) apex:poja) + ~| receive-auth+resp(r body) + =+ [ac re]=(need ((ot 'access_token'^so 'refresh_token'^so ~):jo body)) + =: access.do.toke.vat ac + refresh.do.toke.vat re + == + :_ +>.$ + :- (publish [%lin & 'successfully authenticated']~) + list-do +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: create digital ocean droplets :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +++ create-do + |= act/json + =+ ^- deets/create-req-do + %- need + %. act + => jo + %- ot + :~ name+so + size+so + image+so + ssh+(ar so) + backups+(mu bo) + 'ipv6'^(mu bo) + 'priv_networking'^(mu bo) + 'user_data'^(mu so) + == + =+ ^- body/json + %- create-do-body + :* name.deets + size.deets + image.deets + ssh.deets + backups.deets + ipv6.deets + private-networking.deets + user-data.deets + == + %- httpreq :* + /create-do + ~[%digitalocean %api] /v2/droplets + [%post body] + %^ mo ['Content-Type' 'application+json; charset=utf-8' ~] + ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] + ~ + ~ + == +:: +++ thou-create-do |=({path resp/httr} ~&(resp :_(+>.$ ~))) +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: create google instances :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +++ reserve-ip + |= name/json + =+ nam=(need ((ot name+so ~):jo name)) + %- httpreq + :* /reserve-ip/[nam] + ~['googleapis' 'www'] + /compute/v1/projects/urbcloud/regions/us-central1/addresses + [%post (joba name+s+nam)] + %^ mo ['Content-Type' 'application+json' ~] + ['Authorization' (cat 3 'Bearer ' access.gce.toke.vat) ~] + ~ + *quay + == +:: +++ thou-reserve-ip + |= {pax/path resp/httr} + ~& resp + ~| r.resp + =+ parsed=(rash q:(need r.resp) apex:poja) + =+ ur=(need ((ot 'targetLink'^so ~):jo parsed)) + ~& initial-response+parsed + =+ name=-:(flop q.q:(need (epur ur))) + =+ buf=`@da`(add ~s10 now) + :_(+>.$ [ost %wait `path`/check-ip-status/[name] buf]~) +:: +++ wake-check-ip-status + |= {name/path $~} + ~& this-is-the-name+name + =+ nam=?~(name !! -.name) + :_ +>.$ + :_ ~ + %- httpreq + :* `path`/check-ip-status/[nam] + ~['googleapis' 'www'] + `path`/compute/v1/projects/urbcloud/regions/us-central1/addresses/[nam] + %get + %^ mo ['Content-Type' 'application+json' ~] + ['Authorization' (cat 3 'Bearer ' access.gce.toke.vat) ~] + ~ + *quay + == +++ thou-check-ip-status + |= {name/path resp/httr} + ~& api-resp+resp + =+ parsed=(rash q:(need r.resp) apex:poja) + !! + ::?. =('RESERVED' (need ((ot status+so ~):jo parsed))) +:: +++ create-gce + |= jon/json + =+ ^- {name/@t image/@t number/@ud} + (need ((ot name+so 'instance_img'^so number+ni ~):jo jon)) + |- ^- (list move) + ?~ number ~ + :_ $(number (dec number)) + =+ nam=(cat 3 name (scot %ud number)) + =+ ^- body/json + %- jobe + :~ name+s+nam + 'machineType'^s+'zones+us-central1-a+machineTypes+n1-standard-1' + :- %disks :- %a :_ ~ + %- jobe + :+ 'initializeParams'^`json`(joba 'sourceImage'^s+image) + boot+b+%.y + ~ + :- 'networkInterfaces' :- %a :_ ~ + (joba 'network' `json`[%s 'global+networks+default']) + == + ^- move + %- httpreq + :* `path`/create-gce + `(list cord)`~['googleapis' 'www'] + `path`/compute/v1/projects/urbcloud/zones/us-central1-a/'instances' + [%post `json`body] + %^ mo ['Content-Type' 'application+json' ~] + ['Authorization' (cat 3 'Bearer ' access.gce.toke.vat) ~] + ~ + `quay`[%key access.gce.toke.vat]~ + == +:: +++ thou-create-gce |=({path resp/httr} ~&(resp :_(+>.$ ~))) +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: perform actions on instances (both kinds) :: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +++ poke-json :: receive action from client + |= jon/json + ^- {(list move) _+>.$} + =+ action=`cloud-command`(need (parse-cloud-command jon)) + :_ +>.$ + ?- -.action + $create-gce [(reserve-ip p.action)]~ + $create-do [(create-do p.action)]~ + ::$create-gce [(create-gce p.action)] + $action [(instance-action [id name act]:action)]~ + == +++ instance-action + |= {id/@t name/@t action/droplet-action} + =+ d=(~(got by insts.vat) id) + ~| 'can\'t find id' + =+ typ=?~(d !! -.d) + ?- typ + $do + =+ ^= meth + ?: ?=($delete -.action) + %delt + :- %post + %+ jobe type+s+(convert-do -.action) + ?.(?=($snapshot -.action) ~ [name+s+p.action ~]) + ^- move + =+ ^= req + %- httpreq :* + /do/[-.action] + ~[%digitalocean %api] + ?:(?=($delt meth) /v2/droplets/[id] /v2/droplets/[id]/actions) + meth + %^ mo ['Content-Type' 'application+json' ~] + ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] ~ + *quay + == + req + :: + $gce + =+ ^= head-query + :- %^ mo ['Content-Type' 'application+json' ~] + ['Authorization' (cat 3 'Bearer ' access.gce.toke.vat) ~] ~ + *quay + ?- -.action + ?($start $stop $reboot $'snapshot') + =+ end=/compute/v1/projects/urbcloud/zones/us-central1-a/instances/[name] + %- httpreq + :* /gce-act/[-.action] ~['googleapis' 'www'] + (welp end [?:(?=($reboot -.action) 'reset' -.action) ~]) + [%post ~] + head-query + == + :: + $delete + =+ end=/compute/v1/projects/urbcloud/zones/us-central1-a/instances/[name] + %- httpreq + :* /gce-act/[-.action] ~['googleapis' 'www'] + end + %delt + head-query + == + == + == +++ thou-do-act + |= {pax/path resp/httr} + ~& [resp act+pax] + :_ +>.$ ~ +:: +++ thou-gce-act + |= {pax/path resp/httr} + ~& [resp act+pax] + :_ +>.$ ~ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: retrieve google instances and images :: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +++ list-gce +^- (list move) +:+ (list-something-gce /zones/['us-central1-a']/instances) + (list-something-gce /global/snapshots) + ~ +:: +++ list-something-gce + |= endpoint/path + =+ ^= lis + :* + /list-gce/[-.endpoint] + ~[%googleapis %www] (welp /compute/v1/projects/urbcloud endpoint) + %get ~ + ^- quay + [%'access_token' access.gce.toke.vat]~ + == + ~! lis + ~! +<:httpreq + (httpreq lis) +:: +++ thou-list-gce-zones :: instances + |= {pax/path resp/httr} + ^- {(list move) _+>.$} + =+ parsed=(rash q:(need r.resp) apex:poja) :: body httr to json + ~| 'no list received or bad json' + =+ items=(need ((ot items+(ar some) ~):jo parsed)) + =+ ^- ins/(list {@t instance}) + ~| 'bad-json'^items + %+ turn items + |= in/json + =< [id .] + ^- instance + :- %gce + %- need + %. in =+ jo + %- ot + :~ name+so + id+so + status+so + 'creationTimestamp'^(su parse-iso8601) ::zone+so + 'machineType'^(cu tail-url so) +:: 'networkInterfaces'^parse-ip-gce + == + =. insts.vat + %- mo + %+ weld ins + %+ skip (~(tap by insts.vat)) :: keep non-gce + |=(a/{@t instance} ?=($gce +<.a)) + =+ buf=`@da`(add ~s10 now) + =+ liz=(~(tap by insts.vat)) + =+ tail=(turn liz |=(a/{@t instance} +.a)) + :_ +>.$ :: + :- [ost %wait /refresh-gce buf] + (spam (instance-to-json tail)) +:: +++ thou-list-gce-global :: imgs + |= {pax/path resp/httr} + ^- {(list move) _+>.$} + =+ parsed=(rash q:(need r.resp) apex:poja) + =+ imgz=(need ((ot items+(ar some) ~):jo parsed)) + =. images.vat + %- mo + %+ weld + %+ skip (~(tap by images.vat) *(list {{@t @t} image})) + |=(a/{{@t @t} image} ?=($gce ->.a)) + %+ turn imgz + |= a/json + =< [[name %gce] .] + ^- image + :- %gce + %- need + %. a =+ jo + %- ot + [name+so id+so ~] + :_ +>.$ [(spam `json`(image-to-json `(list image)`(map-to-list images.vat)))] +:: +++ wake-refresh-gce |=({path $~} [list-gce +>.$]) +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: list digital ocean droplets and images :: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +++ list-do + :+((list-something-do %droplets) (list-something-do %images) ~) +++ list-something-do + |= som/@tas + =+ ^= lis + :~ /list-do/[som] + ~[%digitalocean %api] + /v2/[som] + %get + %- mo + :~ ['Content-Type' 'application+json' ~] + ['Authorization' (cat 3 'Bearer ' access.do.toke.vat) ~] + == + == + (httpreq lis) +:: +++ thou-list-do-droplets + |= {pax/path resp/httr} + ^- {(list move) _+>.$} + =+ parsed=(rash q:(need r.resp) apex:poja) :: parse httr to json + ~| receive-list+parsed + =+ dar=(need ((ot droplets+(ar some) ~):jo parsed)) :: reparse ar of insts + =+ ^- dropz/(list {@t instance}) + ~| bad-json+-.dar + %+ turn dar + |= drp/json ^- {@t instance} + =- ~! - - + =< [id .] + ^- instance + :- %do + %- need + %. drp + =+ jo + %- ot + :~ name+so + id+parse-id-text + status+so + 'created_at'^(su parse-iso8601) + image+(ot name+so ~) + == + =. insts.vat + %- mo + %+ weld dropz + %+ skip (~(tap by insts.vat) *(list {@t instance})) + |=(a/{@t instance} ?=($do +>.$)) + =+ buf=`@da`(add ~s10 now) + :_ +>.$ + :- [ost %wait /refresh-do buf] + %- spam + %- instance-to-json + %+ turn (~(tap by insts.vat) *(list {@t instance})) + |=(a/{@t instance} +.a) +:: +++ thou-list-do-images + |= {pax/path resp/httr} + =+ parsed=(rash q:(need r.resp) apex:poja) + ~| crashed-do-images+parsed + =+ ^= imgz + %- need + ((ot images+(ar (ot [name+so distribution+so id+no ~])) ~):jo parsed) + =+ ^- images/(list {{@t @t} image}) + %+ turn imgz + |= {name/@t dist/@t id/@t} + =+ nom=(cat 3 name dist) + [[%do nom] `image`[%do nom id]] + =. images.vat + %- mo + %+ weld images + %+ skip (~(tap by images.vat) *(list {{@t @t} image})) + |=(a/{{@t @t} image} ?=($do ->.a)) + :_ +>.$ + ~[(spam `json`(image-to-json `(list image)`(map-to-list images.vat)))] +:: +++ wake-refresh-do |=({path $~} [list-do +>.$]) +-- diff --git a/ape/oct1.hoon b/ape/oct1.hoon new file mode 100644 index 000000000..559c3d8d5 --- /dev/null +++ b/ape/oct1.hoon @@ -0,0 +1,85 @@ +:: :: :: +:::: /hoon+oct1/ape :::::: dependencies + :: :: :: +/? 310 :: arvo version +/- sole, oct1 :: structures +/+ sole, oct1 :: libraries +[. sole oct1] :: :: +:: :: :: +:::: :::::: interfaces + !: :: :: +=> |% :: + ++ axon {$0 eye/face gam/game} :: agent state + ++ card {$diff $sole-effect sole-effect} :: update + ++ face (map bone sole-share) :: console state + ++ move (pair bone card) :: cause and action + -- :: +:: :: :: +:::: :::::: parsers + :: :: :: +=> |% :: + ++ colm (cook |=(a/@ (sub a '1')) (shim '1' '3')) :: row or column + ++ come ;~(plug colm ;~(pfix fas colm)) :: coordinate + -- :: +:: :: :: +:::: :::::: process core + :: :: :: +|_ $: bowl :: system state + moz/(list move) :: pending actions + axon :: server state, v0 + == :: +:: :: :: +:::: :::::: process tools + :: :: :: +++ abet [(flop moz) .(moz ~)] :: resolve +++ bike $+(_. _+>) :: self-transformer +++ dish |=(cad/card %_(+> moz [[ost cad] moz])) :: request +++ eels (~(tap by sup)) :: all clients +++ echo |= {all/(list sink) fun/bike} =+ old=+>+<- :: + |- ^+ +>.^$ ?~ all +>.^$(+<- old) :: + =. ost p.i.all :: + $(all t.all, +>.^$ (fun +>.^$)) :: +++ flap |=(con/bike (echo eels con)) :: update all clients +++ here ~(. go gam) :: game core +:: :: :: +:::: :::::: process logic + :: :: :: +++ fail (fect %bel ~) :: user error +++ fect |=(sole-effect (dish %diff %sole-effect +<)) :: update console +++ kick |= point =^ dud gam ~(m at:here +<) :: + ?.(dud fail wild:kind) :: +++ kind =+(res:here ?~(- + (word(gam new:here) ->))) :: move result +++ prom (fect %pro %& %oct1 voy:here) :: update prompt +++ rend (turn `wall`tab:here |=(tape txt++<)) :: table print +++ sawn .(eye (~(del by eye) ost)) :: console unsubscribe +++ seen .(eye (~(put by eye) ost *sole-share)) :: console subscribe +++ show prom:(fect %mor rend) :: update console +++ tame (flap |=(_. prom:+<)) :: light update +++ wild (flap |=(_. show:+<)) :: full update +++ word |=(tape (flap |=(_+> (fect:+< txt++>+<)))) :: +:: :: :: +:::: :::::: process UI + :: :: :: +++ work :: console action + |= act/sole-action :: + =+ say=(~(got by eye) ost) :: + |^ ?+(-.act abet $det (delt +.act), $ret dive) :: + ++ abet ..work(eye (~(put by eye) ost say)) :: resolve + ++ delt |= cal/sole-change :: edit command line + =^ cul say (~(remit sole say) cal good) :: + ?~(cul abet fail:(fect:abet det+u.cul)) :: + ++ dive =+ (rust (tufa buf.say) (punt come)) :: apply command line + ?~(- fail ?~(-> show (kick:wipe ->+))) :: + ++ good |=((list @c) -:(rose (tufa +<) come)) :: validate input + ++ wipe =^ cal say (~(transmit sole say) set+~) :: clear line + (fect:abet %det cal) :: + -- :: +:: :: :: +:::: :::::: arvo handlers + :: :: :: +++ peer-sole |=(* abet:show:seen) :: console subscribe +++ prep |= (unit (pair (list move) axon)) :: update self + abet:?~(+< +> wild(+<+ +<+)) :: +++ poke-sole-action |=(sole-action abet:(work +<)) :: console input +++ pull-sole |=(* abet:sawn) :: console unsubscribe +-- diff --git a/ape/oct2.hoon b/ape/oct2.hoon new file mode 100644 index 000000000..b839c8e8b --- /dev/null +++ b/ape/oct2.hoon @@ -0,0 +1,103 @@ +:: :: :: +:::: /hoon+oct2/ape :::::: dependencies + :: :: :: +/? 310 :: arvo version +/- sole, oct2 :: structures +/+ sole, oct2 :: libraries +[. sole oct2] :: :: +:: :: :: +:::: :::::: interfaces + !: :: :: +=> |% :: + ++ axle {eye/face gam/game} :: agent state + ++ card $% {$diff lime} :: update + {$quit $~} :: cancel + == :: + ++ face (map bone sole-share) :: console state + ++ lime {$sole-effect sole-effect} :: :sole update + ++ move (pair bone card) :: cause and action + -- :: +:: :: :: +:::: :::::: past state + :: :: :: +=> |% :: + ++ axon $%({$1 axle} {$0 axle-0}) :: all states + ++ axle-0 {eye/face gam/game-0} :: old axle + ++ game-0 {who/? box/board boo/board} :: old game + ++ wake |= axon :- %1 ?- +<- $1 +<+ :: rough upgrade + $0 [eye [who ~^~ ~ box boo]:gam]:+<+ :: + == -- :: +:: :: :: +:::: :::::: parsers + :: :: :: +=> |% :: + ++ colm (cook |=(a/@ (sub a '1')) (shim '1' '3')) :: row or column + ++ come ;~(plug colm ;~(pfix fas colm)) :: coordinate + ++ cope |=(? ?:(+< (stag %| (cold ~ sig)) come)) :: with wait mode + -- :: +:: :: :: +:::: :::::: process core + :: :: :: +|_ $: bowl :: + moz/(list move) :: pending actions + {$1 axle} :: process state v1 + == :: +:: :: :: +:::: :::::: process tools + :: :: :: +++ abet [(flop moz) .(moz ~)] :: resolve +++ bike $+(_. _+>) :: self-transformer +++ dish |=(cad/card %_(+> moz [[ost cad] moz])) :: request +++ echo |= {all/(list sink) fun/bike} =+ old=+>+<- :: publish to all + |- ^+ +>.^$ ?~ all +>.^$(+<- old) :: + => .(ost p.i.all, src q.i.all) :: + $(all t.all, +>.^$ (fun +>.^$)) :: +++ flap |=(con/bike (echo (~(tap by sup)) con)) :: update all clients +++ here ~(. go src gam) :: game core +:: :: :: +:::: :::::: server logic + :: :: :: +++ fail (fect %bel ~) :: user error +++ fect |=(sole-effect (dish %diff %sole-effect +<)) :: update console +++ heal |= old/axon =. +>+<+> (wake old) :: complete update + =- +>.$(gam -) ?. !=(1 +<-) gam :: + (muy:here (turn (~(tap by sup)) |=(sink q))) :: +++ kick |= point =^ dud gam ~(m at:here +<) :: + ?.(dud fail wild:kind) :: +++ kind =+(res:here ?~(- + (word(gam new:here) ->))) :: move result +++ hail |=(? tame(gam (hey:here +<))) :: toggle subscriber +++ prom (fect %pro %& %oct2 voy:here) :: update prompt +++ rend (turn `wall`tab:here |=(tape txt++<)) :: table print +++ sawn (hail(eye (~(del by eye) ost)) |) :: console unsubscribe +++ seen (hail(eye (~(put by eye) ost *sole-share)) &) :: console subscribe +++ show prom:(fect %mor rend) :: update console +++ tame (flap |=(_. prom:+<)) :: light update +++ wild (flap |=(_. show:+<)) :: full update +++ word |=(tape (flap |=(_+> (fect:+< txt++>+<)))) :: +:: :: :: +:::: :::::: console UI + :: :: :: +++ work :: console action + |= act/sole-action :: + =+ say=(~(got by eye) ost) :: + |^ ?+(-.act abet $det (delt +.act), $ret dive) :: + ++ abet ..work(eye (~(put by eye) ost say)) :: resolve + ++ cusp (cope !ept:here) :: parsing rule + ++ delt |= cal/sole-change :: edit command line + =^ cul say (~(remit sole say) cal good) :: + ?~(cul abet fail:(fect:abet det+u.cul)) :: + ++ dive =+ (rust (tufa buf.say) (punt come)) :: apply command line + ?~(- fail ?~(-> show (kick:wipe ->+))) :: + ++ good |=((list @c) -:(rose (tufa +<) cusp)) :: validate input + ++ wipe =^ cal say (~(transmit sole say) set+~) :: clear line + (fect:abet %det cal) :: + -- :: +:: :: :: +:::: :::::: arvo handlers + :: :: :: +++ peer-sole |=(* abet:show:seen) :: console subscribe +++ poke-sole-action |=(sole-action abet:(work +<)) :: console input +++ prep |= (unit (pair (list move) axon)) :: update self + abet:?~(+< +> wild:(heal +<+>)) :: +++ pull-sole |=(* abet:sawn) :: console unsubscribe +-- diff --git a/ape/oct3.hoon b/ape/oct3.hoon new file mode 100644 index 000000000..43c2d8275 --- /dev/null +++ b/ape/oct3.hoon @@ -0,0 +1,116 @@ +:: :: :: +:::: /hoon+oct3/ape :::::: dependencies + :: :: :: +/? 310 :: arvo version +/- sole, oct3 :: structures +/+ sole, oct3 :: libraries +[. sole oct3] :: :: +:: :: :: +:::: :::::: interfaces + !: :: :: +=> |% :: + ++ axle {eye/face gam/game} :: agent state + ++ card $% {$diff lime} :: update + {$quit $~} :: cancel + == :: + ++ face (map bone sole-share) :: console state + ++ lime $% {$sole-effect sole-effect} :: :sole update + {$oct3-update play} :: :oct3 update + == :: + ++ move (pair bone card) :: cause and action + -- :: +:: :: :: +:::: :::::: past state + :: :: :: +=> |% :: + ++ axon $%({$1 axle} {$0 axle-0}) :: all states + ++ axle-0 {eye/face gam/game-0} :: old axle + ++ game-0 {who/? box/board boo/board} :: old game + ++ wake |= axon :- %1 ?- +<- $1 +<+ :: coarse upgrade + $0 [eye [who ~^~ ~ box boo]:gam]:+<+ :: + == -- :: +:: :: :: +:::: :::::: parsers + :: :: :: +=> |% :: + ++ colm (cook |=(a/@ (sub a '1')) (shim '1' '3')) :: row or column + ++ come ;~(plug colm ;~(pfix fas colm)) :: coordinate + ++ cope |=(? ?:(+< (stag %| (cold ~ sig)) come)) :: with wait mode + -- :: +:: :: :: +:::: :::::: process core + :: :: :: +|_ $: bowl :: + moz/(list move) :: pending actions + {$1 axle} :: process state v1 + == :: +:: :: :: +:::: :::::: process tools + :: :: :: +++ abet [(flop moz) .(moz ~)] :: resolve +++ bike $+(_. _+>) :: self-transformer +++ dish |=(cad/card %_(+> moz [[ost cad] moz])) :: request +++ echo |= {all/(list sink) fun/bike} =+ old=+>+<- :: publish to all + |- ^+ +>.^$ ?~ all +>.^$(+<- old) :: + => .(ost p.i.all, src q.i.all) :: + $(all t.all, +>.^$ (fun +>.^$)) :: +++ eels (~(tap by sup)) :: all clients +++ elfs (prey /oct3 +<-) :: network clients +++ elks (prey /sole +<-) :: console clients +++ flap |= {net/bike con/bike} :: update all clients + (echo:(echo elks con) elfs net) :: +++ here ~(. go src gam) :: game core +:: :: :: +:::: :::::: server logic + :: :: :: +++ fail ?:(soul (fect %bel ~) ~|(%invalid-move !!)) :: user error +++ fect |=(sole-effect (dish %diff %sole-effect +<)) :: update console +++ fact |=(play (dish %diff %oct3-update +<)) :: update partner +++ hail |=(? tame(gam (hey:here +<))) :: toggle subscriber +++ heal |= old/axon =. +>+<+> (wake old) :: complete update + =- +>.$(gam -) ?. !=(1 +<-) gam :: + (muy:here (turn eels |=(sink q))) :: +++ kick |= point =^ dud gam ~(m at:here +<) :: + ?.(dud fail wild:kind) :: +++ kind =+(res:here ?~(- + (word(gam new:here) ->))) :: move result +++ prom (fect %pro %& %oct3 voy:here) :: update prompt +++ rend (turn `wall`tab:here |=(tape txt++<)) :: table print +++ sawn (hail(eye (~(del by eye) ost)) |) :: console unsubscribe +++ seen (hail(eye (~(put by eye) ost *sole-share)) &) :: console subscribe +++ show prom:(fect %mor rend) :: update console +++ soul =+((~(get by sup) ost) ?=([~ * %sole *] -)) :: is console +++ tame (flap |=(_. (fact:+< &/gam)) |=(_. prom:+<)) :: light update +++ wild (flap |=(_. (fact:+< &/gam)) |=(_. show:+<)) :: full update +++ word |= txt/tape %+ flap :: game message + |=(_+> (fact:+< |/txt)) :: + |=(_+> (fect:+< txt+txt)) :: +:: :: :: +:::: :::::: console UI + :: :: :: +++ work :: console action + |= act/sole-action :: + =+ say=(~(got by eye) ost) :: + |^ ?+(-.act abet $det (delt +.act), $ret dive) :: + ++ abet ..work(eye (~(put by eye) ost say)) :: resolve + ++ cusp (cope !ept:here) :: parsing rule + ++ delt |= cal/sole-change :: edit command line + =^ cul say (~(remit sole say) cal good) :: + ?~(cul abet fail:(fect:abet det+u.cul)) :: + ++ dive =+ (rust (tufa buf.say) (punt come)) :: apply command line + ?~(- fail ?~(-> show (kick:wipe ->+))) :: + ++ good |=((list @c) -:(rose (tufa +<) cusp)) :: validate input + ++ wipe =^ cal say (~(transmit sole say) set+~) :: clear line + (fect:abet %det cal) :: + -- :: +:: :: :: +:::: :::::: arvo handlers + :: :: :: +++ peer-oct3 |=(* abet:tame:(hail &)) :: urbit subscribe +++ peer-sole |=(* abet:show:seen) :: console subscribe +++ poke-sole-action |=(sole-action abet:(work +<)) :: console input +++ poke-oct3-move |=(point abet:wild:(kick +<)) :: urbit move +++ prep |= (unit (pair (list move) axon)) :: update self + abet:?~(+< +> wild:(heal +<+>)) :: +++ pull-oct3 |=(* abet:(hail |)) :: urbit unsubscribe +++ pull-sole |=(* abet:sawn) :: console unsubscribe +-- diff --git a/ape/oct4.hoon b/ape/oct4.hoon new file mode 100644 index 000000000..28144dc62 --- /dev/null +++ b/ape/oct4.hoon @@ -0,0 +1,139 @@ +:: :: :: +:::: /hoon+oct4/ape :::::: dependencies + :: :: :: +/? 310 :: arvo version +/- sole, oct4 :: structures +/+ sole, oct4 :: libraries +[. sole oct4] :: :: +:: :: :: +:::: :::::: interfaces + !: :: :: +=> |% :: + ++ axle {eye/face rem/(unit ship) gam/game} :: agent state + ++ card $% {$diff lime} :: update + {$quit $~} :: cancel + {$peer wire dock path} :: subscribe + {$poke wire dock pear} :: send move + {$pull wire dock $~} :: unsubscribe + == :: + ++ face (map bone sole-share) :: console state + ++ lime $% {$sole-effect sole-effect} :: :sole update + {$oct4-update play} :: :oct4 update + == :: + ++ move (pair bone card) :: cause and action + ++ pear {$oct4-move point} :: outgoing move + -- :: +:: :: :: +:::: :::::: past state + :: :: :: +=> |% :: + ++ agon (unit {(list move) axon}) :: boot argument + ++ axon $%({$1 axle} {$0 axle-0}) :: all states + ++ axle-0 {eye/face gam/game-0} :: old axle + ++ game-0 {who/? box/board boo/board} :: old game + ++ wake |= axon :- %1 ?- +<- $1 +<+ :: coarse upgrade + $0 [eye ~ [who ~^~ ~ box boo]:gam]:+<+ :: + == -- :: +:: :: :: +:::: :::::: parsers + :: :: :: +=> |% :: + ++ colm (cook |=(a/@ (sub a '1')) (shim '1' '3')) :: row or column + ++ come ;~(plug colm ;~(pfix fas colm)) :: coordinate + ++ comb (pick come ;~(pfix sig (punt fed:ag))) :: all command input + ++ cope |=(? ?:(+< (stag %| (cold ~ sig)) comb)) :: with wait mode + -- :: +:: :: :: +:::: :::::: process core + :: :: :: +|_ $: bowl :: + moz/(list move) :: pending actions + {$1 axle} :: process state v1 + == :: +:: :: :: +:::: :::::: process tools + :: :: :: +++ abet [(flop moz) .(moz ~)] :: resolve +++ bike $+(_. _+>) :: self-transformer +++ dish |=(cad/card %_(+> moz [[ost cad] moz])) :: request +++ done (echo eels |=(_. (dish:+< %quit ~))) :: cancel everyone +++ echo |= {all/(list sink) fun/bike} =+ old=+>+<- :: publish to all + |- ^+ +>.^$ ?~ all +>.^$(+<- old) :: + => .(ost p.i.all, src q.i.all) :: + $(all t.all, +>.^$ (fun +>.^$)) :: +++ eels (~(tap by sup)) :: all clients +++ elfs (prey /oct4 +<-) :: network clients +++ elks (prey /sole +<-) :: console clients +++ emit |=(lime (dish %diff +<)) :: publish +++ flap |= {net/bike con/bike} :: update all clients + (echo:(echo elks con) elfs net) :: +++ here ~(. go src gam) :: game core +:: :: :: +:::: :::::: server logic + :: :: :: +++ fail ?:(soul (fect %bel ~) ~|(%invalid-move !!)) :: user error +++ fect |=(sole-effect (emit %sole-effect +<)) :: update console +++ fact |=(play (emit %oct4-update +<)) :: update partner +++ hail |=(? ?^(rem +> tame(gam (hey:here +<)))) :: toggle subscriber +++ harp |=(game ?:(=(gam +<) +> wild(gam +<))) :: update game +++ heal |= old/axon =. +>+<+> (wake old) :: complete update + =- +>.$(gam -) ?. !=(1 +<-) gam :: + (muy:here (turn eels |=(sink q))) :: +++ hear |=(play ?-(+<- $| (word +<+), $& (harp +<+))) :: network update +++ kick |= point =^ dud gam ~(m at:here +<) :: + ?.(dud fail wild:?~(rem kind (send +>-))) :: +++ kind =+(res:here ?~(- + (word(gam new:here) ->))) :: move result +++ plan |= (unit ship) ?~ +< stop(gam new:here) :: link+unlink + ?^(rem fail link(rem +<)) :: +++ plot |= (each point (unit ship)) :: apply command + ?-(+<- $& (kick +<+), $| (plan +<+)) :: +++ like |*(* [/oct4 [+.rem dap] +<]) :: friend message +++ link (dish peer+(like /oct4)) :: subscribe to friend +++ prom (fect %pro %& %oct4 stat) :: update prompt +++ rend (turn `wall`tab:here |=(tape txt++<)) :: table print +++ sawn (hail(eye (~(del by eye) ost)) |) :: console unsubscribe +++ seen (hail(eye (~(put by eye) ost *sole-share)) &) :: console subscribe +++ send |=(point (dish poke+(like %oct4-move +<))) :: send move +++ show prom:(fect %mor rend) :: update console +++ soul =+((~(get by sup) ost) ?=([~ * %sole *] -)) :: is console +++ stat (weld ?~(rem ~ "@{(scow p+u.rem)}") voy:here) :: prompt line +++ stop ?~(rem done wild:(dish pull+(like ~))) :: unsubscribe +++ tame (flap |=(_. (fact:+< &/gam)) |=(_. prom:+<)) :: light update +++ wild (flap |=(_. (fact:+< &/gam)) |=(_. show:+<)) :: full update +++ with |=(? (word(rem ?:(+< rem ~)) "{<[+< src]>}")) :: +++ word |= txt/tape %+ flap :: game message + |=(_+> (fact:+< |/txt)) :: + |=(_+> (fect:+< txt+txt)) :: +:: :: :: +:::: :::::: console UI + :: :: :: +++ work :: console action + |= act/sole-action :: + =+ say=(~(got by eye) ost) :: + |^ ?+(-.act abet $det (delt +.act), $ret dive) :: + ++ abet ..work(eye (~(put by eye) ost say)) :: resolve + ++ cusp (cope !ept:here) :: parsing rule + ++ delt |= cal/sole-change :: edit command line + =^ cul say (~(remit sole say) cal good) :: + ?~(cul abet fail:(fect:abet det+u.cul)) :: + ++ dive =+ (rust (tufa buf.say) (punt comb)) :: apply command line + ?~(- fail ?~(-> show (plot:wipe ->+))) :: + ++ good |=((list @c) -:(rose (tufa +<) cusp)) :: validate input + ++ wipe =^ cal say (~(transmit sole say) set+~) :: clear line + (fect:abet %det cal) :: + -- :: +:: :: :: +:::: :::::: arvo handlers + :: :: :: +++ reap-oct4 |=({* (unit)} abet:(with =(~ +<+))) :: linked to friend +++ coup-oct4 |=({* (unit)} abet:?~(+<+ +> fail)) :: move acknowledge +++ diff-oct4-update |=({* play} abet:(hear +<+)) :: network update +++ peer-oct4 |=(* abet:tame:(hail &)) :: urbit subscribe +++ peer-sole |=(* abet:show:seen) :: console subscribe +++ poke-sole-action |=(sole-action abet:(work +<)) :: console input +++ poke-oct4-move |=(point abet:wild:(kick +<)) :: urbit move +++ prep |=(agon abet:?~(+< +> (heal +<+>))) :: load state +++ pull-oct4 |=(* abet:(hail |)) :: urbit unsubscribe +++ pull-sole |=(* abet:sawn) :: console unsubscribe +++ quit-oct4 |=(* abet:?~(rem +> wild(rem ~))) :: unlinked by friend +-- diff --git a/ape/twif.hoon b/ape/twif.hoon new file mode 100644 index 000000000..6bc4e3f59 --- /dev/null +++ b/ape/twif.hoon @@ -0,0 +1,8 @@ +/- twitter +!: +[twitter .] +|_ [bowl ~] +++ poke-noun |=(span (onwards [%peer / [our %twit] /user+[+<]])) +++ onwards |*({mark *} [[ost +<]~ +>.$]) +++ diff-twit-feed |=({* a/(list twit-stat)} ?~(a `+>.$ ~&(i.a $(a t.a)))) +-- diff --git a/ape/twit.hoon b/ape/twit.hoon new file mode 100644 index 000000000..510675e68 --- /dev/null +++ b/ape/twit.hoon @@ -0,0 +1,221 @@ +:: Twitter daemon +:: +:::: /hook+core+twit+app + :: +/- twitter +/+ twitter, talk +:: +:::: ~fyr + :: +[twitter .] +|% +++ twit-path :: valid peer path + $% :: [%home $~] :: home timeline + {$user p/@t $~} :: user's tweets + {$post p/span $~} :: status of status + == +:: +++ axle :: app state + $: $0 + kes/(map span keys:twit-do) :: auth + out/(map @uvI (each {span cord} stat)) :: sent tweets + ran/(map path {p/@ud q/@da}) :: polls active + fed/(jar path stat) :: feed cache + == +:: +++ gift :: subscription action + $% {$quit $~} :: terminate + {$diff gilt} :: send data + == +++ gilt + $% {$twit-feed p/(list stat)} :: posts in feed + {$twit-stat p/stat} :: tweet accepted + {$ares term (list tank)} + == +:: +++ move {bone card} +++ card :: arvo request + $? gift + $% {$them path $~ u/hiss} :: HTTP request + {$poke wire dock $talk-command command:talk} :: + {$wait path p/@da} :: timeout + == == +:: +++ sign :: arvo response + $% {$e $thou p/httr} :: HTTP result + {$t $wake $~} :: timeout ping + == +:: +++ stat twit-stat :: recieved tweet +-- +!: +:::: + :: +|_ {bowl axle} +++ any-auth ?~(kes (auth) (auth p.n.kes)) :: use any keys +++ auth :: build API door + |= a/span + ~| [%no-auth a] + ~(. twit (~(got by kes) a) now `@`eny) +:: +++ cull :: remove seen tweets + |= {pax/path rep/(list stat)} ^+ rep + =+ pev=(sa (turn (~(get ja fed) pax) |=(stat id))) + (skip rep |=(stat (~(has in pev) id))) +:: +++ done [*(list move) .] +++ dely :: next polling timeout + |= pax/path + ^- {(unit time) _ran} + =+ cur=(~(get by ran) pax) + =+ tym=(add now (mul ~s8 (bex ?~(cur 0 p.u.cur)))) + :: ~& dely+`@dr`(sub tym now) + ?: &(?=(^ cur) (gte tym q.u.cur) (gth q.u.cur now)) + [~ ran] + [`tym (~(put by ran) pax ?~(cur 0 (min 5 +(p.u.cur))) tym)] +:: +++ wait :: ensure poll by path + |= {pax/path mof/(list move)} + =^ tym ran (dely pax) + :_ +>.$ + ?~ tym + :: ~& no-wait+ran + mof + :: ~& will-wait+u.tym + :- [ost %wait pax u.tym] + mof +:: +++ poke-twit-do :: recieve request + |= act/twit-do + ^+ [*(list move) +>] + ?- -.q.act + $auth + :- [(print "authed @{(trip p.act)}")]~ + +>.$(kes (~(put by kes) p.act p.q.act)) :: XX verify key + $post + =: out (~(put by out) p.q.act %& p.act q.q.act) + ran (~(del by ran) /peer+home) + == + %+ wait /peer+home + =+ mez=(stat-upda:(auth p.act) [%status q.q.act]~ ~) + [ost %them /post+(scot %uv p.q.act) ~ mez]~ + == +:: +++ wake-peer + |= {pax/path ~} ^+ done + ~& twit-wake+peer+pax + :_ +>.$ + ?. (~(has by ran) peer+pax) :: ignore if retracted + ~ + =+ => |=({a/bone @ b/path} [b a]) + pus=(~(gas ju *(jug path bone)) (turn (~(tap by sup)) .)) + ?~ (~(get ju pus) pax) + ~ + ~& peer-again+[pax ran] + (pear | our pax) +:: +++ thou + |= {pax/path hit/httr} ^+ done + ?+ p.hit ~|([%unknown-code p.hit] !!) + 429 :: Rate-limit + =. ran (~(put by ran) pax 6 now) + =+ lim=%.(%x-rate-limit-reset ;~(biff ~(get by (mo q.hit)) poja ni:jo)) + =+ tym=?~(lim (add ~m7.s30 now) (add ~1970.1.1 (mul ~s1 u.lim))) + ~& retrying-in+`@dr`(sub tym now) + :_(+>.$ [ost %wait pax tym]~) + :: + 200 :: OK + =+ jon=(need (poja q:(need r.hit))) + :: ~& twit-resp+%.(jon ?+(-.jon !! %o stat:twir, %a (ar:jo stat:twir))) + ?+ pax ~|([%http-missed pax] !!) + {$post @ $~} :: post acknowledged + =+ ^= rep + ~| [%bad-post jon] + (need %.(jon stat:twir)) + =. out (~(put by out) (slav %uv i.t.pax) %| rep) + :_ +>.$ + =+ pax=/[who.rep]/status+(rsh 3 2 (scot %ui id.rep)) + :- (print (earn [& ~ `/com+twitter] `pax ~)) + (spam pax (tweet-good rep)) + :: + {$peer *} :: feed data + =+ ^= rep + ~| [%bad-feed jon] + (need %.(jon (ar:jo stat:twir))) + :: ~& got-feed+[(scag 5 (turn rep |=(stat id))) fed] + =+ ren=(cull t.pax rep) :: new messages + ?~ ren + (wait pax ~) :: pump polling + :: ~& spam-feed+ren + =: ran (~(del by ran) pax) :: clear poll delay + fed (~(put by fed) t.pax rep) :: saw last message + == + (wait pax (spam t.pax [%diff twit-feed+(flop ren)] ~)) + == + :: + ?($400 $401 $403 $404) :: Err + =+ ^- git/gift + =+ err=%.(q:(need r.hit) ;~(biff poja mean:twir)) + :^ %diff %ares %bad-http + [leaf+"HTTP Code {}" (turn (need err) mean:twip)] + ?+ pax [[ost git]~ +>.$] + {$post @ ~} + [(spam pax git ~) +>.$] + == + == +++ tweet-good |=(rep/stat `(list gift)`~[[%diff %twit-stat rep] [%quit ~]]) +++ peer |=(pax/path :_(+> (pear & src pax))) :: accept subscription +++ pear :: poll, possibly returning current data + |= {ver/? @ pax/path} + ^- (list move) + ?. ?=(twit-path pax) + ~|([%missed-path pax] !!) + => .(pax `twit-path`pax) + ?: ?=($post -.pax) + ?. ver ~ + =+ sta=(~(get by out) (slav %uv p.pax)) + ?. ?=({$~ $| ^} sta) :: post not received + ~ + ~[[ost %diff %twit-stat p.u.sta] [ost %quit ~]] + =+ ole=(~(get ja fed) pax) + :_ ^- (list move) + ?. ver ~ + ?~ ole ~ + [ost %diff %twit-feed (flop ole)]~ + =- `move`[ost %them peer+pax ~ `hiss`-] + =+ opt=?~(ole ~ ['since_id' (lutt:twit id.i.ole)]~) + =+ aut=any-auth + ?- -.pax + $user (stat-user:aut [(to-sd p.pax)]~ opt) +:: $home (stat-home:auth ~ opt) + == +:: +++ to-sd :: parse user name+numb + |= a/span ^- sd:twit + ~| [%not-user a] + %+ rash a + ;~(pose (stag %user-id dem) (stag %screen-name user:twir)) +:: +:: ++ pull :: release subscription +:: |= ost/bone +:: ?. (~(has by sup) ost) `+>.$ :: XX should not occur +:: =+ [his pax]=(~(got by sup) ost) +:: ?: (lth 1 ~(wyt in (~(get ju pus) pax))) +:: `+>.$ +:: =: ran (~(del by ran) [%peer pax]) +:: fed (~(del by fed) pax) +:: == +:: `+>.$ +:: +++ spam :: send by path + |= {a/path b/(list gift)} ^- (list move) + %- zing ^- (list (list move)) + %+ turn (~(tap by sup)) + |= {ost/bone @ pax/path} + ?. =(pax a) ~ + (turn b |=(c/gift [ost c])) +:: +++ print + |= mes/tape + [ost %poke / [our %talk] (said:^talk our %twit now eny leaf+mes ~)] +-- diff --git a/ape/work.hoon b/ape/work.hoon new file mode 100644 index 000000000..551594921 --- /dev/null +++ b/ape/work.hoon @@ -0,0 +1,337 @@ +:: +:::: + :: +/? 314 +/- work +/+ talk +!: +:::: + :: +[. work] +|% +++ move (pair bone card) :: all actions +++ card :: general card + $% {$diff $work-report client} :: + {$peer wire dock path} :: + {$poke wire dock pear} :: + == :: +++ pear :: poke fruit + $% {$talk-command command:talk} :: + == :: +-- +!: +:::: + :: +|_ $: bowl + client + connected/? :: subscribed to talk + count/@ud :: / messages from talk + unordered/(map {@uvH @u} (pair ship flesh:work-stuff:talk)) + == +++ at + |= client-task + =| moves/(list move) + |% + ++ abet + ^- {(list move) _+>.$} + [(flop moves) +>.$(tasks (~(put by tasks) id.tax +<.$))] + :: + ++ abut + ^- {(list move) _+>.$} + [(flop moves) +>.$] + :: + ++ send-audience + |= {to/(set station:talk) action/duty:work-stuff:talk} + %_ +>.$ + eny (sham eny action) + moves + :_ moves + ^- move + :* ost %poke + /sending+(scot %uv id.tax)/(scot %ud version.tax) + [our %talk] + %talk-command + => [. talk] ^- command:talk + :- %publish + |- ^- (list thought) + :_ ~ + :+ (shaf %task eny) + %- mo ^- (list {partner envelope delivery}) + %+ turn (~(tap in to)) + |=(sat/station [[%& sat] [*envelope %pending]]) + [now *bouquet [%tax action]] + == + == + :: + ++ send + |= action/duty:work-stuff:talk + (send-audience audience action) + :: + ++ send-archive + |= to/(set station:talk) + (send-audience to %archive id.tax) + :: + ++ send-create (send %create tax) + ++ send-change |* * + ?: =(our creator.tax) + (send-update +(version.tax) our +<) + %+ send-audience + [[creator.tax (main:talk creator.tax)] ~ ~] + [%change id.tax +<] + ++ send-update |*(* (send %update id.tax +<)) + ++ process-update + |= up/update + ^+ +> + ?- -.up + $add ?>(?=($comment +<.up) (send-change %add-comment our +>.up)) + $doer + ?- +<.up + $release (send-change %set-doer ~) + $claim (send-change %set-doer `our) + == + :: + $set + ?- +<.up + $audience (process-audience to.up) + $date-due (send-change %set-date-due +>.up) + $title (send-change %set-title +>.up) + $description (send-change %set-description +>.up) + $tags (send-change %set-tags +>.up) + $done (send-change %set-done +>.up) + == + == + ++ process-audience + |= to/(set station:talk) + ^+ +> + =. +>.$ (send-archive (~(dif in audience) to)) + =. +>.$ (send-audience (~(dif in to) audience) %create tax) + +>.$(audience to) + -- +:: +++ prep + |= $= old + $_ + =< $ + %- unit + $: client + ? + @ud + (map {@uvH @u} (pair ship flesh:work-stuff:talk)) + == + ^- {(list move) _+>.$} + initialize(+<+ ?~(old +<+.+>.$ u.old)) +:: +++ initialize + ^- {(list move) _.} + ?: connected + [~ .] + :_ .(connected %&) :_ ~ + [ost %peer /peering [our %talk] /f+(main:talk our)/(scot %ud count)] +:: +++ process-duty + |= {when/@da her/ship from/(set station:talk) action/duty:work-stuff:talk} + ^- {(list move) _+>.$} + =- =^ mof con mirror-to-web:con + [(welp mof mos) con] + ^- {mos/(list move) con/_+>.$} + ?- -.action + $create + =+ existing-task=(~(get by tasks) id.tax.action) + ?: ?& ?=(^ existing-task) + !=(tax.action tax.u.existing-task) + !archived.u.existing-task + == + ~& :* %new-task-with-old-id + her=her + from=from + new-task=tax.action + existing-task=u.existing-task + == + [~ +>.$] + ?. =(her creator.tax.action) + ~& :* %created-with-bad-creator + her=her + from=from + new-task=tax.action + existing-task=existing-task + == + [~ +>.$] + =. tasks + %^ ~(put by tasks) id.tax.action | + :_ tax.action + ?~ existing-task from + (~(uni in audience.u.existing-task) from) + =. sort ?^(existing-task sort [id.tax.action sort]) + [~ +>.$] + :: + $archive + =+ tax=(~(get by tasks) id.action) + ?~ tax + ~& :* %archive-for-nonexistent-task + her=her + from=from + action=action + == + [~ +>.$] + ?: !=(her creator.tax.u.tax) + ~& :* %archiver-not-creator + her=her + from=from + action=action + tax=tax + == + [~ +>.$] + =. tasks + %+ ~(put by tasks) id.action + :* =(~ (~(dif in audience.u.tax) from)) + (~(dif in audience.u.tax) from) + tax.u.tax + == + [~ +>.$] + :: + $change + =+ tax=(~(get by tasks) id.action) + ?~ tax + ~& :* %change-for-nonexistent-task + her=her + from=from + action=action + == + [~ +>.$] + ?: !=(our creator.tax.u.tax) + ~& :* %me-not-creator + her=her + from=from + action=action + tax=tax + == + [~ +>.$] + abet:(send-update:(at u.tax) +(version.tax.u.tax) her meat.action) + :: + $update + =+ tax=(~(get by tasks) id.action) + ?~ tax + ~& :* %update-for-nonexistent-task + her=her + from=from + action=action + == + [~ +>.$] + ?: !=(her creator.tax.u.tax) + ~& :* %her-not-creator + her=her + from=from + action=action + tax=tax + == + [~ +>.$] + ?. =(version.action +(version.tax.u.tax)) + ~& :* %update-bad-version + her + from=from + action=action + tax=tax + == + ?: (lte version.action version.tax.u.tax) + ~& %really-bad-version + [~ +>.$] + :- ~ + %_ +>.$ + unordered + %+ ~(put by unordered) + [id.action version.action] + [her.action meat.action] + == + |- + =. tasks + %+ ~(put by tasks) id.action + :+ archived.u.tax + (~(uni in audience.u.tax) from) + =. version.tax.u.tax version.action + =. date-modified.tax.u.tax when + ?- -.meat.action + $set-doer tax.u.tax(doer her.meat.action) + $set-date-due tax.u.tax(date-due wen.meat.action) + $set-tags tax.u.tax(tags tag.meat.action) + $set-title tax.u.tax(title til.meat.action) + $set-description tax.u.tax(description des.meat.action) + $set-done tax.u.tax(done ?.(don.meat.action ~ `when)) + $add-comment + %= tax.u.tax + discussion [[when [who com]:meat.action] discussion.tax.u.tax] + == + == + =+ ooo=(~(get by unordered) id.action +(version.action)) + ?~ ooo + [~ +>.^$] + %= $ + version.action +(version.action) + her.action p.u.ooo + meat.action q.u.ooo + == + == +:: +++ mirror-to-web + ^- {(list move) _.} + ~& [%mirroring sort=(turn sort |=(a/@uv `@uv`(rsh 2 25 a)))] + :_ . + %+ murn (~(tap by sup)) + |= {ust/bone her/ship pax/path} + ^- (unit move) + ?:(?=({$sole *} pax) ~ `[ust full-report]) +:: +++ full-report [%diff %work-report tasks sort] +++ peer-repo |=(path [[ost full-report]~ +>.$]) +++ coup + |= {way/wire saw/(unit tang)} + ^- {(list move) _+>.$} + ?> ?=($~ saw) + [~ +>.$] +:: +++ quit-peering |=(way/wire ?>(?=($~ way) initialize(connected |))) +++ reap-peering + |= {way/wire saw/(unit tang)} + ^- {(list move) _+>.$} + ?> ?=({$~ $~} +<) + [~ +>.$] +:: +++ poke-work-command + |= cod/command + ?. =(our src) + ~|([%wrong-user our=our src=src] !!) + ?- -.cod + $sort mirror-to-web(sort p.cod) + $old + =^ mow +>.$ + =+ (at (~(got by tasks) id.cod)) + abet:(process-update:- dif.cod) + =^ mov +>.$ mirror-to-web + [(welp mov mow) +>.$] + $new + =. +>.cod +>.cod(date-created now, version 0, date-modified now) + abut:send-create:(at | +.cod) + == +:: +:: XX test the disconnection case +++ diff-talk-report + |= {way/wire rep/report:talk} + ^- {(list move) _+>.$} + ?> ?=($grams -.rep) + |- ^- {(list move) _+>.^$} + ?~ q.rep [~ +>.^$] + =. count +(count) + =* her p.i.q.rep + =* when p.r.q.i.q.rep + =* said r.r.q.i.q.rep + ?. ?=($tax -.said) + $(p.rep +(p.rep), q.rep t.q.rep) + =+ ^- from/(set station:talk) + %- sa ^- (list station:talk) + %+ murn (~(tap by q.q.i.q.rep)) + => talk + |= {par/partner *} + `(unit station)`?.(?=($& -.par) ~ `p.par) + =^ mos +>.^$ (process-duty when her from +.said) + =^ mof +>.^$ $(p.rep +(p.rep), q.rep t.q.rep) + [(weld mos mof) +>.^$] +-- diff --git a/ape/write.hoon b/ape/write.hoon new file mode 100644 index 000000000..3b3c60032 --- /dev/null +++ b/ape/write.hoon @@ -0,0 +1,36 @@ +:: File writer +:: +:::: /hoon+write+app + :: +|_ {bowl $~} +++ beak-now byk(r [%da now]) +++ poke-json + |= jon/json + =- (poke--data (need (- jon.+))) + => jo + %- ot :~ + pax+(cu deft (su fel:stab)) + dat+(of json+some mime+(pe / (cu taco so)) ~) :: XX mite + == +:: +++ poke-write-paste + |= {typ/?($hoon $md $txt) txt/@t} + (poke--data [`typ /pub+paste+(scot %da now)] %mime / (taco txt)) +:: +++ poke--data + |= {{ext/(unit @t) pax/path} dat/$$({$json json} {$mime mime})} + ?~ ext $(ext [~ -.dat]) + =+ cay=?-(-.dat %json [-.dat !>(+.dat)], %mime [-.dat !>(+.dat)]) + ?: =(u.ext -.dat) (made pax ~ `cay) + [[ost %exec pax our ~ beak-now %cast u.ext `cay]~ +>.$] :: XX defer %nice +:: +++ made + |= {pax/wire @ res/gage} + ?. =(our src) + ~|(foreign-write+[our=our src=src] !!) + ?+ -.res ~|(gage+-.res !!) + $| (mean p.res) + $& =- [[ost %info / our -]~ +>.$] + (foal :(welp (tope beak-now ~) pax /[-.p.res]) p.res) + == +-- diff --git a/arvo/jael.hoon b/arvo/jael.hoon new file mode 100644 index 000000000..785cc7f5f --- /dev/null +++ b/arvo/jael.hoon @@ -0,0 +1,146 @@ +:: %jael, secret storage +:: +:::: /hoon+jael + :: +!? 164 +:::: +:: %jael is logically homogeneous, but please follow these conventions: +:: +:: /cap :: foreign app keys +:: /service :: service name, eg %face for FB +:: /appid :: your ship's app-id +:: /@uvH :: by hash +:: /@ud :: by number +:: /@tas :: by name +:: +:: /key :: foreign user secrets +:: /service :: service name, eg %face +:: /userid :: user identity +:: +:: /urb :: urbit secrets +:: /tok+hash + +|= pit=vase +=> =~ +:: structures +|% +++ axle :: %jael state + $: %0 :: %jael version + ent=@ :: entropy + sef=safe :: secret tree + red=(map duct (set path)) :: reverse subscribers + == :: +++ gift :: out result <-$ + $% [%dead p=path] :: key expired + [%live p=path q=@] :: key created + == :: +++ kiss :: in request ->$ + $% [%kill p=path] :: discard secret + [%make p=@uw q=(unit ,@da) r=@ud s=path] :: generate random + [%nuke ~] :: erase subscriber + [%tell p=@uw q=(unit ,@da) r=path] :: save secret + == :: +++ move ,[p=duct q=(mold note gift)] :: typed move +++ note :: out request $-> + $% $: %b :: to %behn + $% [%wait p=@da] :: + [%rest p=@da] :: + == == == :: +++ perm (pair ,@ud (list ,@ud)) :: prime definition +++ safe :: + $: nub=(unit ,@uw) :: secret + dex=(unit ,@da) :: expiration + sud=(set duct) :: subscribers + kin=(map term safe) :: children + == :: +-- :: +:: programs +|% +++ bu + |_ $: xap=path + fes=(list safe) + moz=(list move) + == + axle + :: + ++ bu-abet :: resolve + ^- axle + ?~ xap +<+ + %= bu-abet + xap t.xap + fes t.fes + sef %= i.fes + kin + ?: =(*safe sef) + (~(del by kin.i.fes) i.xap) + (~(put by kin.i.fes) i.xap sef) + == + == + :: + ++ bu-kill :: destroy + ^+ . + =+ dus=(~(tap by + + :: + ++ bu-ajar :: descend + |= pax=path + ^+ +> + ?~ pax +>.$ + %= $ + pax t.pax + xap [i.pax xap] + fes [sef fes] + sef (fall (~(get by kin.sef) i.pax) *safe) + == + -- +++ bury + |= [pax=path lex=axle] + (~(bu-ajar bu [~ ~ ~] tof.lex lex) pax) +-- +. == +=| axle +|= [now=@da eny=@ ski=sled] :: activate +^? :: opaque core +|% :: +++ call :: request + |= [hen=duct hic=(hypo (hobo kiss))] + ^- [p=(list move) q=_..^$] + => .(q.hic ?.(?=(%soft -.q.hic) q.hic ((hard kiss) p.q.hic))) + =^ moz +>+>- + =< bu-abet + ?- -.p.q.hic + %kill + kill:(bury p.p.q.hic +>+>-) + :: + %make + %nuke + %tell + == +:: +++ doze + |= [now=@da hen=duct] + ^- (unit ,@da) + ~ +:: +++ load :: highly forgiving + |= old=* + =+ lox=((soft axle) old) + ^+ ..^$ + ?~ lox + ~& %jael-reset + ..^$ + ..^$(+>- u.lox) +:: +++ scry + |= [fur=(unit (set monk)) ren=@tas who=ship syd=desk lot=coin tyl=path] + ^- (unit (unit (pair mark ,*))) + :: actually scry + ~ +:: +++ stay :: save w+o cache + `axle`+>-.$(pol (~(run by pol) |=(a=baby [tad.a dym.a ~]))) +:: +++ take :: response + |= [tea=wire hen=duct hin=(hypo noun)] + !! +-- diff --git a/arvo/kahn.hoon b/arvo/kahn.hoon new file mode 100644 index 000000000..d8d39b791 --- /dev/null +++ b/arvo/kahn.hoon @@ -0,0 +1,103 @@ +:: %kahn, social state +:: +:::: /hoon+kahn + :: +!? 164 +:::: +|= pit=vase +=> =~ +:: structures +|% +++ axle :: %kahn state + $: %0 :: + soc=(map monk node) :: social graph + red=(map duct (set monk)) :: reverse subscribers + == :: +++ cert (each will ,*) :: urbit or other +++ gift :: out result <-$ + $: [%then p=node] :: propagate change + == :: +++ node :: social identity + $: tin=(map monk link) :: inbound links + oud=(map monk link) :: outbound links + cet=cert :: certificate + sud=(set duct) :: subscribers + == :: +++ khan ,[p=@tas q=@ta] :: foreign identity +++ kiss :: social update + $: [%cert p=monk q=cert] :: set certificate + [%hear p=monk] :: watch identity + [%know p=monk q=(map monk link)] :: set forward links + [%nuke ~] :: erase subscriber + == :: +++ link (pair rank ,@da) :: trust+expiration +++ monk (each ship khan) :: general identity +++ rank :: privilege ring + $? %0 :: complete trust + %1 :: structural trust + %2 :: social trust + %3 :: neutral trust + %4 :: negative trust + == :: +-- :: +. == +=| axle +=* lex - +|= [now=@da eny=@ ski=sled] :: activate +^? :: opaque core +|% :: +++ call :: request + |= [hen=duct hic=(hypo (hobo kiss))] + ^- [p=(list move) q=_..^$] + => .(q.hic ?.(?=(%soft -.q.hic) q.hic ((hard kiss) p.q.hic))) + !! +:: +++ doze + |= [now=@da hen=duct] + ^- (unit ,@da) + ~ +:: +++ load :: highly forgiving + |= old=* + =+ lox=((soft axle) old) + ^+ ..^$ + ?~ lox + ~& %khan-reset + ..^$ + ..^$(+>- u.lox) +:: +++ scry + |= [fur=(unit (set monk)) ren=@tas who=ship syd=desk lot=coin tyl=path] + ^- (unit (unit (pair mark ,*))) + ?. =(big [~ who]) ~ + =+ ^= yub ^- [(unit monk) + ?: =(%urb syd) + ?. ?=([* ~] tyl) ~ + =+ goy=(slaw %p + + ?+ ?=([%$ %da @] + ?+ lot ~ + [%$ %ud @] + %+ bind + (perm who u.hun q.p.lot [syd t.tyl]) + |=(a=* [%noun a]) + :: + ?. =(now q.p.lot) ~ + %+ bind + (temp who u.hun [syd t.tyl]) + |=(a=* [%noun a]) + == + ?. ?=([%da + =+ mok ^- (unit monk) + ?: =(%urb face) + ( + +:: +++ stay :: save w+o cache + `axle`+>-.$ +:: +++ take :: response + |= [tea=wire hen=duct hin=(hypo noun)] + !! +-- + diff --git a/arvo/lunt.hoon b/arvo/lunt.hoon new file mode 100644 index 000000000..d76d1837d --- /dev/null +++ b/arvo/lunt.hoon @@ -0,0 +1,104 @@ +:: %lunt, fleet job control +:: +:::: /hoon+lunt + :: +!? 164 +:::: +|= pit=vase +=> =~ +:: structures +|% +++ axle :: %lunt state + $: %0 :: + all=(map ship axil) :: state by owner + == :: +++ born ,[p=brat q=(unit ship)] :: task identity +++ brat ,@ud :: task number +++ bulb :: + $: p=@p :: ship identity + q=home :: server data + == :: +++ home :: storage access + $: pad=@uvH :: passcode + huc=husk :: log server + sog=hulk :: storage server + == :: +++ hulk :: checkpoint service + $% [%astr p=@ud q=@ud] :: S3 + == :: +++ husk :: log server + $: pro=@tas :: protocol + cap=@uvH :: access code + srv=(list (pair ,@ud clip)) :: server cluster + == :: +++ gift :: result + $: [%die p=brat] :: kill + [%int p=brat] :: interrupt + [%run p=brat q=@p r=home] :: load + [%say p=brat q=(list ovum)] :: send events + [%new p=brat q=@p r=home s=(list ovum)] :: create + == :: +++ kiss :: request + $: [%com p=@p] :: toggle compute svr + [%end p=brat] :: local end + [%fan p=@ud] :: set local fanout + [%kil ~] :: terminate ship + [%int ~] :: interrupt ship + [%new p=@p q=(set ,@p) q=home r=@uvI] :: create ship + [%run p=@p q=home] :: run existing ship + [%say p=(list ovum)] :: remote events + [%sto p=husk] :: toggle logger + == :: +++ axil :: + $: bus=(unit ,@p) :: master + loc=@ud :: local resources + hen=(unit duct) :: effect duct + ent=@ :: entropy + seq=@ :: brat sequence + why=(map duct born) :: hosted ships + how=(map born duct) :: reverse why + hut=(map born home) :: storage control + ham=(set hulk) :: block stores + sto=(set husk) :: log stores + com=(set ship) :: compute resources + == :: +-- :: +. == +=| axle +=* lex - +|= [now=@da eny=@ ski=sled] :: activate +^? :: opaque core +|% :: +++ call :: request + |= [hen=duct hic=(hypo (hobo kiss))] + ^- [p=(list move) q=_..^$] + => .(q.hic ?.(?=(%soft -.q.hic) q.hic ((hard kiss) p.q.hic))) + !! +:: +++ doze + |= [now=@da hen=duct] + ^- (unit ,@da) + ~ +:: +++ load :: highly forgiving + |= old=* + =+ lox=((soft axle) old) + ^+ ..^$ + ?~ lox + ~& %lunt-reset + ..^$ + ..^$(+>- u.lox) +:: +++ scry + |= [fur=(unit (set monk)) ren=@tas who=ship syd=desk lot=coin tyl=path] + ^- (unit (unit (pair mark ,*))) + ~ +:: +++ stay :: save w+o cache + `axle`+>-.$ +:: +++ take :: response + |= [tea=wire hen=duct hin=(hypo noun)] + !! +-- + diff --git a/arvo/musk.hoon b/arvo/musk.hoon new file mode 100644 index 000000000..a8187eb66 --- /dev/null +++ b/arvo/musk.hoon @@ -0,0 +1,94 @@ +:: %musk, realm management +:: +:::: /hoon+musk + :: +!? 164 +:::: +|= pit=vase +=> =~ +:: structures +|% +++ axle :: %musk state + $: %0 :: + all=(map ship axil) :: state by owner + == :: +++ axil :: + $: kid=(map ship girl) :: daughters + deq=(map narc ship) :: reverse address + siq=(map ship (list clan)) :: ship to clans + kes=(map clan (list ship)) :: clan to ships + == :: +++ clan ,@tas :: group identity +++ narc :: contact address + $: [%$ p=ship] :: urbit + [%m p=@t q=@t] :: email p@q + [%f p=@t] :: facebook + [%g p=@t] :: google + [%p p=@t] :: phone message + [%t p=@t] :: twitter + == :: +++ pony :: daughter status + $% [%cold ~] :: virginal + [%dead ~] :: written off + [%fake ~] :: virtual + [%free ~] :: downloaded + [%here ~] :: hosted + [%left p=(unit ship)] :: run away to + == :: +++ rank :: relative privilege + $? %0 :: enemy + %1 :: neighbor + %2 :: guest+customer + %3 :: friend+employee + %4 :: officer+family + %5 :: self+admin + == :: +++ girl :: + $: hop=pony :: status + tag=(unit ,@tas) :: petname + tip=rank :: rank + fig=(set narc) :: identities + loc=(unit ,[p=@da q=@ud r=clip]) :: last position + sym=(set ,[p=@ q=@uvH]) :: symmetric keys? + wyl=will :: crypto will + == :: +-- :: +. == +=| axle +=* lex - +|= [now=@da eny=@ ski=sled] :: activate +^? :: opaque core +|% :: +++ call :: request + |= [hen=duct hic=(hypo (hobo kiss))] + ^- [p=(list move) q=_..^$] + => .(q.hic ?.(?=(%soft -.q.hic) q.hic ((hard kiss) p.q.hic))) + !! +:: +++ doze + |= [now=@da hen=duct] + ^- (unit ,@da) + ~ +:: +++ load :: highly forgiving + |= old=* + =+ lox=((soft axle) old) + ^+ ..^$ + ?~ lox + ~& %lunt-reset + ..^$ + ..^$(+>- u.lox) +:: +++ scry + |= [fur=(unit (set monk)) ren=@tas who=ship syd=desk lot=coin tyl=path] + ^- (unit (unit (pair mark ,*))) + ~ +:: +++ stay :: save w+o cache + `axle`+>-.$ +:: +++ take :: response + |= [tea=wire hen=duct hin=(hypo noun)] + !! +-- + diff --git a/gen/bit/address-contact.hoon b/gen/bit/address-contact.hoon new file mode 100644 index 000000000..bbc6289b7 --- /dev/null +++ b/gen/bit/address-contact.hoon @@ -0,0 +1,14 @@ + +:: +:::: + :: +/? 310 +:: +::::::: + !: +:- %say +|= {^ arg/{address/@t contact/@t $~} $~} +:- %address-contact +[address.arg contact.arg] + + diff --git a/gen/bit/auth.hoon b/gen/bit/auth.hoon new file mode 100644 index 000000000..c1f3bdc4e --- /dev/null +++ b/gen/bit/auth.hoon @@ -0,0 +1,11 @@ +:: +:::: + :: +/? 310 +:: +::::: + !: +:- %say +|= {^ {arg1+cord arg2+cord $~} $~} +:- %auth +[arg1 arg2] diff --git a/gen/bit/buy.hoon b/gen/bit/buy.hoon new file mode 100644 index 000000000..b1c52d590 --- /dev/null +++ b/gen/bit/buy.hoon @@ -0,0 +1,11 @@ +:: +:::: + :: +/? 310 +:: +::::::: + !: +:- %say +|= {^ {amount/@t currency/@t $~} $~} +:- %buy +[amount currency] diff --git a/gen/bit/contact-address.hoon b/gen/bit/contact-address.hoon new file mode 100644 index 000000000..9c55a7430 --- /dev/null +++ b/gen/bit/contact-address.hoon @@ -0,0 +1,14 @@ + +:: +:::: + :: +/? 310 +:: +::::::: + !: +:- %say +|= {^ arg/{contact/@t address/@t $~} $~} +:- %bit-contact +[contact.arg address.arg] + + diff --git a/gen/bit/list.hoon b/gen/bit/list.hoon new file mode 100644 index 000000000..1829b3b32 --- /dev/null +++ b/gen/bit/list.hoon @@ -0,0 +1,12 @@ +:: +:::: + :: +/? 310 +:: +::::::: + !: +:- %say +|= {^ $~ $~} +:- %list +~ + diff --git a/gen/bit/sell.hoon b/gen/bit/sell.hoon new file mode 100644 index 000000000..3ed11ff45 --- /dev/null +++ b/gen/bit/sell.hoon @@ -0,0 +1,12 @@ +:: +:::: + :: +/? 310 +:: +::::::: + !: +:- %say +|= {^ {amount/@t currency/@t $~} $~} +:- %sell +[amount currency] + diff --git a/gen/bit/send.hoon b/gen/bit/send.hoon new file mode 100644 index 000000000..1f8a983ad --- /dev/null +++ b/gen/bit/send.hoon @@ -0,0 +1,12 @@ +:: +:::: + :: +/? 310 +:: +::::::: + !: +:- %say +|= {^ {to/@uc amo/@t $~} $~} +[%bit-send to amo] + + diff --git a/gen/cat.hoon b/gen/cat.hoon new file mode 100644 index 000000000..9339d22e1 --- /dev/null +++ b/gen/cat.hoon @@ -0,0 +1,33 @@ +:: ConCATenate file listings +:: +:::: /hoon+gen+cat + :: +// /%%/ls+subdir +// /%/pretty +!: +:::: + :: +:- %say +|= {^ {arg/(list path)} $~} +=- tang+(flop `tang`(zing -)) +%+ turn arg +|= pax/path +^- tang +=+ ark=;;(arch .^(%cy pax)) +?^ fil.ark + ?: =(%sched -:(flop pax)) + [>;;((map ,@da cord) .^(%cx pax))<]~ + [leaf+(spud pax) (pretty-file .^(%cx pax))] +?- dir.ark :: handle ambiguity + $~ + [rose+[" " `~]^~[leaf+"~" (smyt pax)]]~ +:: + {{@t $~} $~ $~} + $(pax (welp pax /[p.n.dir.ark])) +:: + * + =- [palm+[": " ``~]^-]~ + :~ rose+[" " `~]^~[leaf+"*" (smyt pax)] + `tank`(subdir pax dir.ark) + == +== diff --git a/gen/cat/pretty.hoon b/gen/cat/pretty.hoon new file mode 100644 index 000000000..ff8973e2b --- /dev/null +++ b/gen/cat/pretty.hoon @@ -0,0 +1,25 @@ +!: +|% +++ pretty-noun + |= pri=* ^- tank + ?~ pri + leaf+"~" + ?@ pri + leaf+?:(((sane %tas) pri) <`@tas`pri> ) + =< rose+[" " ?:(- "~[" "[") "]"]^+ + |- ^- [? (list tank)] + ?~ +.pri + [& ^$(pri -.pri) ~] + ?@ +.pri + [| ^$(pri -.pri) ^$(pri +.pri) ~] + [+< - +>]:[^$(pri -.pri) $(pri +.pri)] +:: +++ vale-cord |=(a=cord `?`(levy (trip a) |=(b=@ |((gte b 32) =(10 b))))) +:: +++ pretty-file + =+ wain-to-tang=|=(a=wain (turn a |=(b=cord leaf+(trip b)))) + |= fyl=* ^- tang + =+ `(unit wain)`?@(fyl `(lore fyl) ((soft wain) fyl)) + ?^ - (wain-to-tang u) + [(pretty-noun fyl)]~ +-- diff --git a/gen/coin/keys.hoon b/gen/coin/keys.hoon new file mode 100644 index 000000000..7cdbd3935 --- /dev/null +++ b/gen/coin/keys.hoon @@ -0,0 +1,11 @@ +:: +:::: + :: +/? 310 +:: +:::: + !: +:- %say +|= [^ [arg=(list cord) ~]] +:- %keys +arg diff --git a/gen/curl.hoon b/gen/curl.hoon new file mode 100644 index 000000000..f813331c2 --- /dev/null +++ b/gen/curl.hoon @@ -0,0 +1,6 @@ +/- sole +[sole] +:- %get |= {^ {a/tape $~} $~} +%+ sole-at (scan a auri:epur) +|= hit/httr +(sole-so %httr hit) diff --git a/gen/curl/url.hoon b/gen/curl/url.hoon new file mode 100644 index 000000000..db33d0e56 --- /dev/null +++ b/gen/curl/url.hoon @@ -0,0 +1,10 @@ +:: +:::: + :: +/? 310 +:: +::::: + !: +:- %say +|= {^ {arg/tape $~} $~} +purl+(scan arg auri:epur) diff --git a/gen/hello.hoon b/gen/hello.hoon new file mode 100644 index 000000000..23cec09c9 --- /dev/null +++ b/gen/hello.hoon @@ -0,0 +1,11 @@ +:: +:::: /hoon+hello+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= {^ {{txt/@tas $~} $~}} +:- %noun +(crip (weld "hello, " (flop (trip txt)))) diff --git a/gen/hood/ask.hoon b/gen/hood/ask.hoon new file mode 100644 index 000000000..90942a322 --- /dev/null +++ b/gen/hood/ask.hoon @@ -0,0 +1,6 @@ +:- %say +|= {^ {mel/cord $~} $~} +=+ adr=(star ;~(less (mask "\"\\()[],:;<>@") prn)) +=+ dom=[;~(plug dlab dot (most dot dlab))]:urlp +=+ ~|(bad-email+mel (rash mel ;~((glue pat) adr dom))) +helm-send-ask+mel diff --git a/gen/hood/begin.hoon b/gen/hood/begin.hoon new file mode 100644 index 000000000..3e1c72bcd --- /dev/null +++ b/gen/hood/begin.hoon @@ -0,0 +1,58 @@ +:: +:::: /hoon+begin+hood+gun + :: +/? 314 +/- sole +:: +:::: + !: +=> |% + ++ begs {his/@p tic/@p yen/@t ges/gens} + ++ scug |*({a/@ b/(pole)} ?~(b ~ ?~(a ~ [-.b $(b +.b, a (dec a))]))) + -- +[sole .] +:- %ask +|= $: {now/@da eny/@uvI bec/beak} + {arg/_(scug *@ ~{his/*@p tic/*@p})} + safety/?($on $off) + == +^- (sole-result (cask begs)) +?. =(safety %off) + %+ sole-yo + :- %leaf + "|begin is deprecated, please invoke urbit with -w [name] -t [ticket]" + sole-no +=- ?~ arg - + =+ (fun.q.q his.arg) + ?~ +.arg - + (fun.q.q tic.arg) +%+ sole-lo + [%& %helm-begin "your urbit: ~"] +%+ sole-go fed:ag +|= his/@p +%+ sole-lo + [%& %helm-ticket "your ticket: ~"] +%+ sole-go fed:ag +|= tic/@p +%+ sole-lo + [%& %helm-entropy "some entropy: "] +%+ sole-go (boss 256 (more gon qit)) +|= yen/@t +=+ ney=(shax yen) +%+ sole-yo `tank`[%leaf "entropy check: {(scow %p `@p`(mug ney))}"] +%+ sole-so %helm-begin +:* his + tic + ney +:: + ^- gens + :- %en + =+ can=(clan his) + ?- can + $czar [%czar ~] + $duke [%duke %anon ~] + $earl [%earl (scot %p his)] + $king [%king ?:(=(~doznec his) 'Urban Republic' (scot %p his))] + $pawn [%pawn ~] + == +== diff --git a/gen/hood/breload.hoon b/gen/hood/breload.hoon new file mode 100644 index 000000000..650bf1614 --- /dev/null +++ b/gen/hood/breload.hoon @@ -0,0 +1,13 @@ +:: +:::: /hoon+reload+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {arg/(list term) $~} + == +:+ %helm-reload-desk %base +arg diff --git a/gen/hood/cancel.hoon b/gen/hood/cancel.hoon new file mode 100644 index 000000000..aa5ac15ca --- /dev/null +++ b/gen/hood/cancel.hoon @@ -0,0 +1,13 @@ +:: +:::: /hoon+cancel+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {{syd/@tas $~} $~} + == +:- %kiln-cancel +syd diff --git a/gen/hood/cp.hoon b/gen/hood/cp.hoon new file mode 100644 index 000000000..cbccfbddb --- /dev/null +++ b/gen/hood/cp.hoon @@ -0,0 +1,2 @@ +:- %say +|=({^ {input/path output/path $~} $~} kiln-cp+[input output]) diff --git a/gen/hood/deset.hoon b/gen/hood/deset.hoon index 1de540735..6dfadfe73 100644 --- a/gen/hood/deset.hoon +++ b/gen/hood/deset.hoon @@ -1,5 +1,9 @@ :: +<<<<<<< HEAD :::: /hoon/deset/hood/gen +======= +:::: /hoon+deset+hood+gen +>>>>>>> parent of afcc1cb... Stripdown part 2. :: /? 314 :: diff --git a/gen/hood/hi.hoon b/gen/hood/hi.hoon new file mode 100644 index 000000000..508f78e60 --- /dev/null +++ b/gen/hood/hi.hoon @@ -0,0 +1,2 @@ +:- %say +|=({^ {who/ship mez/$@($~ {a/tape $~})} $~} helm-send-hi+[who ?~(mez ~ `a.mez)]) diff --git a/gen/hood/init.hoon b/gen/hood/init.hoon new file mode 100644 index 000000000..e19ed47eb --- /dev/null +++ b/gen/hood/init.hoon @@ -0,0 +1,13 @@ +:: +:::: /hoon+reload+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {$~ $~} + == +:- %hood-init +p.bec diff --git a/gen/hood/invite.hoon b/gen/hood/invite.hoon new file mode 100644 index 000000000..be5ee36c5 --- /dev/null +++ b/gen/hood/invite.hoon @@ -0,0 +1,12 @@ +:: +:::: /hoon+invite+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {{who/@p myl/@t $~} $~} + == +[%helm-invite who myl] diff --git a/gen/hood/label.hoon b/gen/hood/label.hoon new file mode 100644 index 000000000..1fa5f3282 --- /dev/null +++ b/gen/hood/label.hoon @@ -0,0 +1,13 @@ +:: +:::: /hoon+label+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {arg/{syd/desk lab/@tas $~} $~} + == +:- %kiln-label +[syd lab]:arg diff --git a/gen/hood/link.hoon b/gen/hood/link.hoon new file mode 100644 index 000000000..811e8a463 --- /dev/null +++ b/gen/hood/link.hoon @@ -0,0 +1,15 @@ +:: +:::: /hoon+link+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI byk/beak} + {arg/$?({dap/term $~} {who/ship dap/term $~}) $~} + == +:- %drum-link +?~ +.arg + [p.byk dap.arg] +[who.arg dap.arg] diff --git a/gen/hood/mass.hoon b/gen/hood/mass.hoon new file mode 100644 index 000000000..5ff359a54 --- /dev/null +++ b/gen/hood/mass.hoon @@ -0,0 +1,12 @@ +:: +:::: /hoon+mass+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {arg/$~ $~} + == +[%helm-mass ~] diff --git a/gen/hood/merge.hoon b/gen/hood/merge.hoon new file mode 100644 index 000000000..4ce5ca8df --- /dev/null +++ b/gen/hood/merge.hoon @@ -0,0 +1,33 @@ +:: +:::: /hoon+merge+hood+gen + :: +/? 314 +!: +|% +++ beaky {span span span $~} +++ sorc ?({bek/beaky $~} {her/@p sud/@tas $~}) +-- +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bek/beak} + {arg/{?(sorc {syd/$@(desk beaky) sorc})} gem/?($auto germ)} + == +=* our p.bek +|^ :- %kiln-merge + ^- {syd/desk her/ship sud/desk gem/?($auto germ)} + ?- arg + {@ @ $~} =+(arg [sud ?.(=(our her) her (sein her)) sud gem]) + {^ $~} =+((pars bek.arg) [dez ?.(=(our who) who (sein who)) dez gem]) + {* @ @ $~} [(pars-src syd.arg) =+(arg [her sud gem])] + {* ^ $~} [(pars-src syd.arg) =+((pars bek.arg) [who dez gem])] + == +++ pars |=(a/beaky =+((need (tome a)) `{who/ship dez/desk}`{p q})) +++ pars-src + |= syd=$@(desk beaky) + ?@ syd syd + =+ (pars syd) + ~| [%into-foreign who `path`syd] + ?>(=(our who) dez) +-- diff --git a/gen/hood/mv.hoon b/gen/hood/mv.hoon new file mode 100644 index 000000000..88f4df57e --- /dev/null +++ b/gen/hood/mv.hoon @@ -0,0 +1,2 @@ +:- %say +|=({^ {input/path output/path $~} $~} kiln-mv+[input output]) diff --git a/gen/hood/overload.hoon b/gen/hood/overload.hoon new file mode 100644 index 000000000..517e2fbee --- /dev/null +++ b/gen/hood/overload.hoon @@ -0,0 +1,13 @@ +:: +:::: /hoon+overload+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {{arg/term $~} $~} + == +:- %kiln-overload +arg diff --git a/gen/hood/rc.hoon b/gen/hood/rc.hoon new file mode 100644 index 000000000..f7711656c --- /dev/null +++ b/gen/hood/rc.hoon @@ -0,0 +1,12 @@ +:: +:::: /hoon+reload+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {arg/$~ $~} + == +[%helm-reload ~[%c]] diff --git a/gen/hood/reboot.hoon b/gen/hood/reboot.hoon new file mode 100644 index 000000000..57d9f85b6 --- /dev/null +++ b/gen/hood/reboot.hoon @@ -0,0 +1,12 @@ +:: +:::: /hoon+reload+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {arg/$~ $~} + == +[%helm-reload ~[%z %a %b %c %d %e %f %g]] diff --git a/gen/hood/reload-desk.hoon b/gen/hood/reload-desk.hoon new file mode 100644 index 000000000..3560a4202 --- /dev/null +++ b/gen/hood/reload-desk.hoon @@ -0,0 +1,13 @@ +:: +:::: /hoon+reload+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {arg/{desk (list term)} $~} + == +:- %helm-reload-desk +arg diff --git a/gen/hood/rf.hoon b/gen/hood/rf.hoon new file mode 100644 index 000000000..ce9a62474 --- /dev/null +++ b/gen/hood/rf.hoon @@ -0,0 +1,12 @@ +:: +:::: /hoon+reload+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {arg/$~ $~} + == +[%helm-reload ~[%f]] diff --git a/gen/hood/rm.hoon b/gen/hood/rm.hoon new file mode 100644 index 000000000..b350b79d4 --- /dev/null +++ b/gen/hood/rm.hoon @@ -0,0 +1,2 @@ +:- %say +|=({^ {input/path $~} $~} kiln-rm+input) diff --git a/gen/hood/schedule.hoon b/gen/hood/schedule.hoon new file mode 100644 index 000000000..86ac4c3b1 --- /dev/null +++ b/gen/hood/schedule.hoon @@ -0,0 +1,2 @@ +:- %say +|=({^ {where/path tym/@da eve/@t $~} $~} kiln-schedule+[where tym eve]) diff --git a/gen/hood/sync.hoon b/gen/hood/sync.hoon new file mode 100644 index 000000000..d70ff4815 --- /dev/null +++ b/gen/hood/sync.hoon @@ -0,0 +1,13 @@ +:: +:::: /hoon+sync+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {arg/{syd/@tas her/@p sud/@tas $~} $~} + == +:- %kiln-sync +[syd her sud]:arg diff --git a/gen/hood/unix.hoon b/gen/hood/unix.hoon new file mode 100644 index 000000000..ab9412c94 --- /dev/null +++ b/gen/hood/unix.hoon @@ -0,0 +1,16 @@ +:: +:::: /hoon+unix+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {{syd/@tas syn/?($~ {? $~})} $~} + == +:+ %hood-unix + syd +?~ syn + ~ +`-.syn diff --git a/gen/hood/unlink.hoon b/gen/hood/unlink.hoon new file mode 100644 index 000000000..9d6f2d69b --- /dev/null +++ b/gen/hood/unlink.hoon @@ -0,0 +1,15 @@ +:: +:::: /hoon+link+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI byk/beak} + {arg/$?({dap/term $~} {who/ship dap/term $~}) $~} + == +:- %drum-unlink +?~ +.arg + [p.byk dap.arg] +[who.arg dap.arg] diff --git a/gen/hood/unmount.hoon b/gen/hood/unmount.hoon new file mode 100644 index 000000000..38eb415b4 --- /dev/null +++ b/gen/hood/unmount.hoon @@ -0,0 +1,13 @@ +:: +:::: /hoon+mount+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {{mon/$@(term {span path}) $~} $~} + == +:- %kiln-unmount +mon diff --git a/gen/hood/unsync.hoon b/gen/hood/unsync.hoon new file mode 100644 index 000000000..c2144f7bd --- /dev/null +++ b/gen/hood/unsync.hoon @@ -0,0 +1,13 @@ +:: +:::: /hoon+unsync+hood+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {arg/{syd/@tas her/@p sud/@tas $~} $~} + == +:- %kiln-unsync +[syd her sud]:arg diff --git a/gen/ls.hoon b/gen/ls.hoon new file mode 100644 index 000000000..f63a9b276 --- /dev/null +++ b/gen/ls.hoon @@ -0,0 +1,12 @@ +:: LiSt directory subnodes +:: +:::: /hoon+ls+gen + :: +// /%/subdir +!: +:::: + :: +:- %say +|= {^ {arg/path $~} $~} +=+ lon=((hard arch) .^(%cy arg)) +tang+[?~(dir.lon leaf+"~" (subdir arg dir.lon))]~ diff --git a/gen/ls/subdir.hoon b/gen/ls/subdir.hoon new file mode 100644 index 000000000..500922f3a --- /dev/null +++ b/gen/ls/subdir.hoon @@ -0,0 +1,20 @@ +|% +++ subdir + |= {pax/path des/(map @t $~)} + ^- tank + :+ %rose [" " `~] + %+ turn (sort (~(tap by des)) aor) + |= {kid/@ta $~} + =+ paf=`path`/[kid] + =- :+ %rose ["/" ~ ?:(dir "/" ~)] + (turn paf |=(a/span leaf+(trip a))) + |- ^- {dir/? paf/path} + =+ arf=;;(arch .^(%cy (weld pax paf))) + ?^ fil.arf + [| paf] + ?~ dir.arf + [& paf] :: !! + ?. ?+({^ $~ $~} dir.arf) + [& paf] + $(paf (welp paf /[p.n.dir.arf])) +-- diff --git a/gen/make.hoon b/gen/make.hoon new file mode 100644 index 000000000..9e7527560 --- /dev/null +++ b/gen/make.hoon @@ -0,0 +1,2 @@ +:- %say +|=({^ arg/(list @) foo/_`@`1 bar/_`@`2} noun+[arg foo bar]) diff --git a/gen/moon.hoon b/gen/moon.hoon new file mode 100644 index 000000000..2d797ccac --- /dev/null +++ b/gen/moon.hoon @@ -0,0 +1,16 @@ +:: +:::: /hoon+ticket+gen + :: +/? 314 +:: +:::: + !: +:- %say +|= $: {now/@da eny/@uvI bec/beak} + [$~ $~] + == +:- %noun +?> =(1 (met 5 p.bec)) +=+ mon=(mix (lsh 5 1 (end 5 1 eny)) p.bec) +=+ tic=((hard @p) .^(/a+(scot %p p.bec)/tick+(scot %da now)/(scot %p mon))) +"moon: {<`@p`mon>}; ticket: {}" diff --git a/gen/pope.hoon b/gen/pope.hoon new file mode 100644 index 000000000..b16171e0a --- /dev/null +++ b/gen/pope.hoon @@ -0,0 +1,24 @@ +:: Input twitter keys +/- sole +!: +=+ cryp=bruw :: XX change to ec2 ++brew eventually +=+ [sole] +:- %ask +|= $: {now/@da eny/@uvI bec/beak} + {{who/ship $~} $~} + == +^- (sole-result (cask tang)) +%+ sole-yo leaf+"generating carrier {(scow %p who)} (#{(scow %ud who)})" +%+ sole-lo [%| %pope-pass "passphrase: "] +%+ sole-go (boss 256 (star prn)) +|= fra/@t +%+ sole-lo [%| %pope-none "[press enter to compute]"] :: XX oy +%+ sole-go (easy ~) +|= $~ +=+ bur=(shax (add who (shax fra))) +~& %computing-fingerprint +=+ arc=(cryp 2.048 bur) +%+ sole-so %tang +:~ leaf+"generator: {(scow %uw bur)}" + leaf+"fingerprint: {(scow %uw fig:ex:arc)}" +== diff --git a/gen/tree.hoon b/gen/tree.hoon new file mode 100644 index 000000000..fe2486910 --- /dev/null +++ b/gen/tree.hoon @@ -0,0 +1,21 @@ +:: Tree view recursive directory contents +:: +:::: /hoon+tree+gen + :: +!: +:::: + :: +:- %say +|= {^ {pax/path fla/$@($~ {$full $~})} $~} +=+ len=(lent pax) +=+ rend=?^(fla smyt |=(a/path (smyt (slag len a)))) +:- %tang %- flop +|- ^- tang +=+ ark=;;(arch .^(cy+pax)) +=- ?~ fil.ark - + [(rend pax) -] +%- zing +%+ turn + (sort (~(tap by dir.ark)) aor) +|= {a/@t $~} +^$(pax (welp pax /[a])) diff --git a/gen/twit/as.hoon b/gen/twit/as.hoon new file mode 100644 index 000000000..2fc5671c5 --- /dev/null +++ b/gen/twit/as.hoon @@ -0,0 +1,10 @@ +/- twitter +:: +:::: + :: +[twitter .] +:- %say +|= $: {now/@da eny/@uvI bec/beak} + {{who/span msg/cord $~} $~} + == +[%twit-do [who %post eny msg]] diff --git a/gen/twit/auth.hoon b/gen/twit/auth.hoon new file mode 100644 index 000000000..030f10c2a --- /dev/null +++ b/gen/twit/auth.hoon @@ -0,0 +1,20 @@ +:: Input twitter keys +/- sole, twitter +!: +[sole twitter .] +|% +++ baz64 (cook crip (star alp)) +-- +!: +:- %ask +|= $: {now/@da eny/@uvI bec/beak} + {$~ $~} + == +^- (sole-result (cask twit-do)) +%+ sole-lo [%& %$ "User: "] %+ sole-go urs:ab |= acc=span +%+ sole-lo [%& %$ "App token: "] %+ sole-go baz64 |= ctok=cord +%+ sole-lo [%& %$ "App secret: "] %+ sole-go baz64 |= csec=cord +%+ sole-lo [%& %$ "User token: "] %+ sole-go baz64 |= atok=cord +%+ sole-lo [%& %$ "User secret: "] %+ sole-go baz64 |= asec=cord +(sole-so %twit-do [acc %auth [ctok csec] atok asec]) + diff --git a/gen/twit/tweet.hoon b/gen/twit/tweet.hoon new file mode 100644 index 000000000..f4eb808ab --- /dev/null +++ b/gen/twit/tweet.hoon @@ -0,0 +1,13 @@ +/+ sh-utils +!: +|_ {hide $~} +++ peer _`. +++ poke--args + %+ add-subs [[our /twit] our /post+(scot %uv eny)] + %^ gate-mess . + |=([a=span b=cord ~] [/twit %twit-do !>([a %post eny b])]) + ,_`. +++ posh-twit-stat + (args-into-gate . |=({@ @ a/@da @} tang+~[leaf+"tweet received {}"])) +++ pour |*({ost/@ * sih/{@ ^}} :_(+>.$ [ost %give +.sih]~)) +-- diff --git a/gen/twit/twitter-feed.hoon b/gen/twit/twitter-feed.hoon new file mode 100644 index 000000000..f92f1f78a --- /dev/null +++ b/gen/twit/twitter-feed.hoon @@ -0,0 +1,22 @@ +:: Display twitter feed +:: +:::: /hook+core+twitter-feed+app + :: +/+ sh-utils +!: +:: +:::: ~fyr + :: +|_ {hide $~} +++ stat {id/@u who/@ta now/@da txt/@t} +++ rens +:- %say + |=(stat rose+[": " `~]^~[leaf+"{} @{(trip who)}" leaf+(trip txt)]) +++ peer _`. +++ poke--args + |= {ost/bone his/ship who/span $~} + %.(+< (add-subs [[our /twit] our /user+[who]] ,_`+>.$)) +:: +++ posh-twit-feed + (args-into-gate . |+(a=(list stat) tang+(turn a rens))) +-- diff --git a/lib/down-jet.hoon b/lib/down-jet.hoon new file mode 100644 index 000000000..2f5813a11 --- /dev/null +++ b/lib/down-jet.hoon @@ -0,0 +1,19 @@ +:: +:::: /hoon+down-jet+lib + :: +/- markdown +:: +:::: + :: +[markdown .] +// /%/parse :: inli donp parse +// /%/rend :: sing sung sang flat into-inner +~% %down ..is ~ +|% +++ mark + ~/ %mark + |= p/@t + (normalize (rash p parse)) +:: +++ print sing +-- diff --git a/lib/down-jet/parse.hoon b/lib/down-jet/parse.hoon new file mode 100644 index 000000000..b35e4db92 --- /dev/null +++ b/lib/down-jet/parse.hoon @@ -0,0 +1,1002 @@ +:: Core markdown parser, exposed as ++parse +:: +:::: + :: +=+ =~ +|% +++ loca |*(a/_* {p/@u q/a}) +++ stack (list (loca tops)) +-- +|% +++ htm-enty :: XX belongs in zuse + ~+ + =- |= tub/nail ^- (like @t) %. tub :: export context + =+(poxa enty(ent mapping)) + ^- mapping/(map span @tF) + =+ pax=/==5%%/html5-entities/json :: XX %%/ + =+ maf=%.(pax ;~(biff file (soft json) (om so):jo)) + ?^ maf u.maf + ~& no-enty+pax + (mo amp+'&' quot+'"' apos+'\'' lt+'<' gt+'>' ~) :: fallback +:: +++ skem-symb (star ;~(pose dot alp)) +++ skem-set ~+ ^- (set cord) :: URI schemes + :: (sa `wain`/http+https+javascript) + =- (sa `wain`(rash - (more gah (cook crip skem-symb)))) + ''' + coap doi javascript aaa aaas about acap cap cid crid data dav dict dns file + ftp geo go gopher h323 http https iax icap im imap info ipp iris iris.beep + iris.xpc iris.xpcs iris.lwz ldap mailto mid msrp msrps mtqp mupdate news nfs + ni nih nntp opaquelocktoken pop pres rtsp service session shttp sieve sip sips + sms snmp soap.beep soap.beeps tag tel telnet tftp thismessage tn3270 tip tv + urn vemmi ws wss xcon xcon-userid xmlrpc.beep xmlrpc.beeps xmpp z39.50r + z39.50s adiumxtra afp afs aim apt attachment aw beshare bitcoin bolo callto + chrome chrome-extension content cvs com-eventbrite-attendee dlna-playsingle + dlna-playcontainer dtn dvb ed2k facetime feed finger fish gg git gizmoproject + gtalk hcp icon ipn irc irc6 ircs itms jar jms keyparc lastfm ldaps magnet maps + market message mms ms-help msnim mumble mvn notes oid palm paparazzi platform + proxy psyc query res resource rmi rsync rtmp secondlife sftp sgn skype smb + soldat spotify ssh steam svn teamspeak things udp unreal ut2004 ventrilo + view-source webcal wtai wyciwyg xfire xri ymsgr + ''' +:: +++ uri-skem (sear (flit |=(a/tape (~(has in skem-set) (cass a)))) skem-symb) +-- +:: +:::: + :: +|% +++ nal (just `@`10) +++ end (full (easy ~)) +++ eol ;~(pose (cold ~ nal) end) +::++ match |=(a/rege (curr scan (ra a))) +:: +++ tab + |= tub/nail + ^- (like cord) + ?. ?=({$9 *} q.tub) + (fail tub) + =+ sto=+((~(inv fe 1) (dec q.p.tub))) :: virt spaces produced + =+ neu=(weld (reap sto ' ') t.q.tub) + (next tub(q neu)) +:: +++ whif |*(a/rule ;~(sfix a (star ace))) +++ ahed |*(a/rule ;~(simu a (easy ~))) +++ opts |*(a/rule ;~((bend) (easy ~) a)) +++ lots |*({a/@u b/rule} ;~(pfix (stun [a a] b) (star b))) +++ leas |*(a/rule ;~(pfix ;~(less (stun 4^4 ace) (stun 0^3 ace)) a)) +++ pech + |* a/{rule rule} + |= tub/nail + ^- (like (each _(wonk (-.a)) _(wonk (+.a)))) + %. tub + ;~(pose (stag %& -.a) (stag %| +.a)) +:: +++ lite :: literal matched + |* a/rule + |= tub/nail ^- (like tape) + =+ vex=(a tub) + ?~ q.vex vex + =+ tap=q.q.u.q.vex + =- vex(p.u.q -) + |- ^+ "" + ?: =(tap q.tub) ~ + ?~ q.tub !! + [i.q.tub $(q.tub t.q.tub)] +:: +++ enrule :: XX + |* a/$+(tape *) + |= tub/nail + ^- (like a) + [[0 0] ~ (a q.tub) [0 0] ~] +-- == + =~ +|% +++ strip + |= {a/$+(nail edge) b/tape} + ^- tape + =+ q:(a 1^1 b) + ?~(- b q.q.u.-) +:: +++ inli :: inline parsers + =+ [bug=| rec="" nol=|] + |_ ref/(map cord {p/tape q/(unit tape)}) + ++ unesc + |= a/tape + (scan a (star ;~(pose nore(rec ~) nal))) :: XX + :: + ++ esc + ;~ pfix bas + (mask "!\"#$%&'()*+,-./:;<=>?@[\\]^_`\{|}~") + == + ++ spec (mask rec) + ++ norc ~+ ;~(pose esc ;~(less spec prn)) + ++ nore ~+ ;~(pose htm-enty norc) + :: + ++ trim-sp + |= a/tape + ^- tape + %+ strip (star gah) + (flop (strip (star gah) (flop a))) + :: + ++ child + =< |= tub/nail ^- (like inline) %. tub :: expose parsers + %+ cook |=(a/inline ~?(bug a a)) + ;~(pose code line link blot:link htmt) + |% + ++ fens + |= a/tape + %+ knee *tape |. ~+ + |= tub/nail ^- (like tape) + =+ vex=((plus tec) tub) + ?~ q.vex + (plug (codc tub) ^^$) + ?: =(a p.u.q.vex) + vex(p.u.q ~) + =+ neu=|=(b/tape (weld `tape`p.u.q.vex b)) + ((cook neu ^^$) q.u.q.vex) + :: + ++ codc ;~(pose (cold ' ' (plus gah)) prn) + ++ code + =- ;~(pose - (stag %$ (plus tec))) + %+ stag %code + %+ cook trim-sp + |= tub/nail + ?. ?=({$'`' ^} q.tub) + (fail tub) + =+ vex=((plus tec) tub) + (pfix vex (fens (wonk vex))) + :: + ++ madn + |= a/mane ^- ? + => |=(b/span ?=(^ (rush b ;~(plug alf (star aln))))) + ?@ a (. a) + &((. -.a) (. +.a)) + :: + ++ htmt + %+ stag %htmt + =- (cook crip (lite -)) :: XX + %- sear :_ + ;~(pose empt:poxa (pech [head tail]:poxa)) + %- flit + |= a/$^({marx $~} $%({$& marx} {$| p/mane})) + ?- -.a + ^ (madn n.a) + $& (madn n.a) + $| (madn p.a) + == + :: + ++ line + %+ cold [%line ~] + ;~(plug ;~(pose (lots 2 ace) bas) nal) + :: + ++ empty + |= a/inline + ^- ? + ?& ?=($$ -.a) + ?=($~ (strip (star ;~(pose ace nal)) p.a)) + == + :: + ++ link ::=+(blot=fail |=(nail (fail +<))) + =< =- |=(tub/nail (pra tub)) :: expose parsers + ?: nol pra=auto ::;~(pose auto pexp) + =- pra=;~(pose auto (cook - apex)) + |=({a/kids b/{tape (unit tape)}} [[%link b] a]) + |% + ++ apex + =+ ^- rob/$+(nail (like {kids $@(cord {tape (unit tape)})})) + ;~(plug text(nol &) labe) + :: + |= tub/nail + ^- (like (pair kids {tape (unit tape)})) + :: (fail tub) + =+ vex=(rob tub) + ?~ q.vex + vex + =- ?~(rez vex(q ~) vex(+.p.u.q u.rez)) + ^- rez/(unit {tape (unit tape)}) + =+ [~ atr]=(wonk vex) + ?^ atr + `atr + ?. ?=($~ atr) + (~(get by ref) atr) + =+ vux=(text:href tub) + ?~ q.vux ~ + (~(get by ref) (wonk vux)) + :: + ++ text + =. rec ['[' ']' rec] + (ifix sel^ser many) + :: + ++ titl (opts ;~(pfix (plus gah) titl:href)) + ++ labe + =+ wra=[;~(plug pel .) ;~(plug . per)]:(star gah) + ;~ pose + (ifix wra ;~(plug dest:href titl)) + ;~(pfix (star gah) text:href) + (easy '') + == + :: + ++ blot + %- cook :_ ;~(pfix zap [.(rob ;~(plug text labe))]:apex) + |=({a/kids b/{tape (unit tape)}} [[%blot b] a]) + :: + ++ mail + %+ cook |=(_[a="" b='' c="" d=*wall] :(welp a b^c (zing d))) + ;~ plug + (plus ;~(less (mask "\"\\ (),:;<>@[]") prn)) + pat + (plus alp) + (star ;~(plug dot (plus alp))) + == + :: + ++ auto + %+ ifix gal^gar + ;~ pose + (cook |=(a/tape [link+["mailto:{a}" ~] ~[`a]]) mail) + :: + =+ cha=;~(pose htm-enty ;~(less (mask "<> ") prn)) + %+ cook + |= a/_["" ""] + [link+[(weld a) ~] ~[`(weld a)]] + ;~(plug uri-skem col (star cha)) + == + :: + ++ pexp :: XX non-link nested + %- cook :_ (ifix sel^ser many) + |=(a/kids (reso:many "[" (welp a `"]" ~))) + -- + -- + :: + ++ href + =< |= tub/nail %. tub :: expose parsers + ;~ plug + ;~(sfix text col (star gah)) + (sear (flit |=(tape ?=(^ +<))) dest) + ;~(sfix (opts ;~(pfix (plus gah) titl)) (star ace) eol) + == + |% + ++ dest + ;~ pose + (ifix gal^gar (star ;~(pose esc nore(rec "<>")))) + (pexp nore(rec " ")) + == + ++ pexp + |* cha/rule + =+ chu=;~(less pel per cha) + |- :: XX Chesterton fence + %+ knee *tape |. ~+ + ;~ pose + ;~(plug chu ^$) + ;~(plug pel (cook welp ;~(plug (star chu) per ^$))) + (easy ~) + == + ++ text + =- (ifix sel^ser (cook cass (star -))) + ;~ pose + (cook |=(a/char (cat 3 '\\' a)) esc) + (cold ' ' (plus gah)) + ;~(less sel ser prn) + == + ++ titl + %. ~[soq^soq doq^doq pel^per] + |* a/(pole {rule rule}) + ?~ a fail + ;~ pose + (ifix -.a (star ;~(pose esc htm-enty ;~(less ->.a prn)))) + $(a +.a) + == + -- + ++ consol + |= a/kids + ^- kids + ?~ a ~ + ?+ -.i.a [i.a $(a t.a)] + $$ + ?~ t.a a + ?: ?=(_-.i.a -.i.t.a) + $(a t.a(p.i (weld p.i.a p.i.t.a))) + [i.a $(a t.a)] + == + ++ pars :: XX + => |% + ++ nufh {tape kids} + ++ fens ?($'*' $'_') + ++ nuft {nufh ?(tape {tape ?($| fens)})} + ++ reso + |= a/nufh + ^- kids + ?~ -.a +.a + [[%$ -.a] +.a] + :: + ++ veld + |= {a/$@(char inline) _[b c]=*nuft} + ^- nuft + :_ c + ?@ a + [[a -.b] +.b] + ?~ -.a + [(weld p.a -.b) +.b] + [~ a (reso b)] + :: + ++ rend + |= nuf/nufh + %. (reso nuf) + |= a/kids + ^- tape + ?~ a ~ + %- weld :_ $(a t.a) + ?@ -.i.a + ?+ -.i.a + $~ p.i.a + == + =+ [p q]=i.a + ?+ -.p "[{(trip -.p)}]<{$(a q)}>" + $emph "({$(a q)})" + == + -- + |= tap/tape ^- kids + =. tap (trim-sp tap) + =+ vex=(many 1^1 tap) + ?~ q.vex + ~ + =+ [a ~ b]=u.q.vex + ?~(b a (welp a [`b]~)) + :: + ++ many + => pars :: XX + |= tub/nail ^- (like kids) + =- [[0 0] ~ (reso -<) [0 0] ;;(tape ->)] :: XX + =+ [ins=`?(fens $~)`~ bof=| noz=|] + ?~ q.tub [`~ ~] + =+ [p=*char [i t]=[i t]:q.tub] :: prev current next + =< ?<(&(?=({* @} +) !?=($~ +>)) .) :: XX do type stuff + |^ ^- nuft + ?: ?=(?($'*' $'_') i) + dlim + =+ elm=(;~(pose child ;~(pfix (star ace) nal) nore) [1 1] i t) + ?~ q.elm + done(t [i t]) :: XX next? + =+ [a ~ b]=u.q.elm + ~? bug [a b] + (push(t b) a) + :: + ++ next (push i) + ++ push :: continue with head + |= a/$@(char inline) + ^- nuft + ~? ?@(a | bug) fon+a + ?~ t (veld a done) + =: noz & + i i ::?+(i i fens p) + == + (veld a ^$(+< [i t])) + :: + ++ done [[~ ~] ?~(ins t [t %|])] + :: + ++ pull :: consume chunk + ^- nuft + ?> ?=(fens i) :: XX do type stuff + =: bof ?~(ins | |(bof !=(ins i))) + ins i + noz | + == + ?~ t + (veld i done) + $(+<+ t) + :: + ++ flome + |= a/_+:*nuft + ^- {(unit ?($| fens)) tape} + ?. ?=({* ?($| fens)} a) + [~ a] + [[~ +.a] -.a] + :: + ++ empa + |= a/nufh + ^- inline + [[%emph |] (reso a)] + :: + ++ ends + |= {a/tape b/tape} + ?: &(?=(^ b) =(i i.b)) + $(b t.b) + ?: &(?=(^ a) =(i i.a)) + $(a t.a) + ?> ?=(fens i) :: XX do type stuff + ?& |(?=($~ b) !=(' ' i.b)) + |(=('*' i) [?=($~ q)]:(aln 1^1 a)) + == + :: + ++ dlim + ^- nuft + ~? bug [&3 &2] + =+ clo=&(noz !=(~ ins) (ends t p ~)) :: can close delim + ?: &(clo =(ins i)) :: correct close + [`~ t] + ?: &(bof !=(ins i)) :: outer close + ?> ?=(fens i) :: XX do type stuff + [`~ t i] + ?~ t + (veld i done) + ?. (ends [p]~ t) + next + =+ [a tak]=pull + => .(t `_""`t) :: XX do type stuff + =^ b t (flome tak) + ?~ b + (push (empa a)) + ~? > bug clot+[a i t] + ?: =(i u.b) + (push (empa a)) + ?~ ins :: outermost + [a(- [i -.a]) t] ::(veld i a t) + [a(- [i -.a]) t u.b] ::(veld i a t u.b) + -- + :: + -- +-- +:: +:::: + :: +|% +++ nesting $% {$bloq *} :: Used for fishing + {$item *} + {$list {$item $~}} + == +++ accepting ?($para $code) +++ list-nest :: can add list item? + =+ sam=[?>(?=($list -.p..) p..)]:(tops [%list ~]~) :: XX do type stuff + |= {a/_sam b/_sam} ^- ? + .= ?@(q.a q.a q.q.a) :: by checking delimiter characters + ?@(q.b q.b q.q.b) +:: +:: =- =((cha p.a) (cha p.b)) +:: ^= cha +:: |= a=_sam +:: ?@(q.a q.a q.q.a) +:: +++ closes-code + =+ sam=[?>(?=($code -) p..)]:(node [%code ~]) :: XX do type stuff + |= {a/_sam b/_sam} + ?~ a ?=($~ b) + ?~ b | + ?^ r.u.b | + ?& =(p.u.a p.u.b) + (gte q.u.b q.u.a) + == +:: +++ blank + |= a/tape ^- ? + ?~ a & + &(=(' ' i.a) $(a t.a)) +:: +++ dehax :: strip trailing hax + =+ nobas=;~(sfix (plus hax) ;~(pose ace end)) + |= a/tape + %- flop + :(strip nobas (star ace) (flop a)) +:: +++ scab + |* {a/tape b/rule} + (wonk (b [1 1] a)) +:: +++ donp + |% + ++ blok + :~ %article %aside %blockquote %body %button %canvas %caption %col + %colgroup %dd %div %dl %dt %embed %fieldset %figcaption %figure + %footer %footer %form %h1 %h2 %h3 %h4 %h5 %h6 %header %hgroup + %hr %iframe %li %map %object %ol %output %p %pre %progress + %script %section %style %table %tbody %td %textarea %tfoot + %th %thead %tr %ul %video + == + ++ htm-head =+ blu=(flit ~(has in (sa `wain`blok))) + =+ blo=(sear blu (cook cass (star aln))) + %+ stag %html + ;~ plug gal + ;~ pose + ;~(plug blo ;~(pose fas gar gah)) + ;~(plug fas blo ;~(pose gar gah)) + (mask "?!") + == + == + ++ leaf (leas ;~(pose head hrul fcode)) :: any node + ++ head + %+ cook |=(a/tape [%head (lent a) ~]) + ;~(sfix (stun 1^6 hax) ;~(pose ace (ahed eol))) + :: + ++ hrul + %+ cold [%hrul ~] + %. ~[tar hep cab] :: (vary "*-_") + |* a/(pole rule) + ?~ a fail + ;~(pose ;~(plug (lots 3 (whif -.a)) (ahed eol)) $(a +.a)) + :: + ++ limar :: list marker + %+ stag %list + %- leas + %+ stag & + =- ;~(sfix - ;~(pose (ahed eol) ;~(sfix ace ;~(pose (leas) (easy))))) + ;~ pose + (mask "*+-") + ;~(plug dem (mask ".)")) + == + :: + ++ line + ;~(sfix (star prn) eol) + :: + ++ blomar + %+ cold [%bloq ~] + %- leas + ;~ pose + ;~(plug gar ace) + gar + == + ++ setext + %- leas + ;~(sfix ;~(pose (cold 2 (plus hep)) (cold 1 (plus tis))) (star ace)) + ++ icode (cold `node`[%code ~ ~] (stun 4^4 ace)) + ++ fcode + %. ~['`' '~'] :: (vary "`~") + |* a/(pole char) + ?~ a fail + =- ;~(pose fel $(a +.a)) + ^= fel + %- cook :_ ;~ plug + (lots 3 (just -.a)) + (star ;~(less tec prn)) + (ahed eol) + == + |= {b/(list) c/tape $~} + ^+ [?>(?=($code -) .)]:*node :: XX do type stuff + [%code `[-.a (add 3 (lent b)) c] ~] + -- +:: +++ normalize + |= a/down ^- down + %+ turn a |= b/elem + ?^ -.b b(q (turn q.b ..$)) + =- ?+(-.b b $para b(p (- p.b)), $head b(q (- q.b))) + |= c/kids ^- kids + ?~ c ~ + ?: ?& ?=(^ t.c) + ?=($$ -.i.c) + ?=($$ -.i.t.c) + == + $(c t.c(p.i (weld p.i.c p.i.t.c))) + =. i.c + ?.(?=($$ -.i.c) i.c [%$ (trip (crip p.i.c))]) :: XX valid tapes + :_ $(c t.c) + ?@ -.i.c i.c + =* d q.i.c + ?~ d + i.c + ?. ?& ?=({* $~} d) + ?=({$emph $|} -.i.c) + ?=({$emph $|} -.i.d) + == + i.c(q $(c d)) + [[%emph %&] $(c q.i.d)] +:: +++ parseb =>(parse .(bug &)) +++ parse + =+ [bug=| bugi=|] + |= tub/nail + =. q.tub + %+ scan q.tub :: tab hackery :: XX per line + (star ;~(pose prn tab nal)) + =| $: $: top/down :: finished toplevel elements + {sap/@u nod/node} :: spacing currrent leaf block + cur/stack :: stack of nested current blocks + == + {bun/_| hat/_|} :: prev blank? halt? + ref/(map cord {p/tape q/(unit tape)}) :: link references + == + |^ ^- (like _top) + ?. hat + $:eat-line + ?^ cur + $:pop + => cull + =- [p.tub `[- tub]] + (flop (turn top (proc-inline [-(bug bugi)]:[~(pars inli ref) .]))) + :: + ++ self . + :: + ++ halt .(hat &) + :: + ++ debu [&2 &2.-]:&2 + :: + ++ proc-inline :: parse inline kids + |= pac/_pars:inli :: cache + |= a/elem + ?^ -.a a(q (flop (turn q.a ..$))) + ?+ -.a a + $code + ?~ p.a a + a(r.u.p (unesc:inli r.u.p.a)) + $para + ?> ?=({{$$ *} $~} p.a) :: XX do type stuff + a(p (pac p.i.p.a)) + $head + ?~ q.a a + ?> ?=({{$$ *} $~} q.a) :: XX do type stuff + a(q (pac p.i.q.a)) + == + :: + ++ snack :: advance by parser + |* a/rule + ^- {(unit _(wonk (a))) nail} + =+ vex=(a tub) + ?~ q.vex [~ tub] + [`p q]:u.q.vex + :: + ++ snake :: advance with trace + |* fel/rule + =- (snack (here - fel)) + |*({{{@ a/@u} {@ b/@u}} c/*} [p=(sub b a) q=c]) + :: + :: + ++ pop :: resolve container + ^+ self + => cull + ?~ cur self + =- => .(cur t.cur, q.p.tub p.i.cur) + ?~ cur self(top [hed top]) + self(q.q.i.cur [hed q.q.i.cur]) + ^- hed/tops + =+ cub=q.i.cur + ?+ -.p.cub cub + $list + %_ cub + p.p + p.p.cub :: XX set this upon parsing blank-headed block + == + == + :: + ++ bye :: resolution arms + |% + ++ leaf :: resolve node + ^+ self + =^ nol nod + [nod [%defn ~]] + ?: ?=($defn -.nol) self + ~? > bug clod+[nol tub] + ?~ cur self(top [nol top]) + self(q.q.i.cur [nol q.q.i.cur]) + :: + ++ pop-til :: unwind stack + |= a/stack + ^+ self + ?~ cur self + ?: =(a cur) self + $(self pop) + :: + ++ top-list + =+ laz=cur + |- + ?~ cur laz + =. laz ?:(?=($list -.p.q.i.cur) cur laz) + $(cur t.cur) + :: + ++ top-bloq + =+ laz=cur + |- + ?~ cur laz + =. laz ?:(?=($bloq -.p.q.i.cur) cur laz) + $(cur t.cur) + -- + :: + ++ cull :: resolve node block + =< leaf:bye + ^+ self + =. sap 0 + ?+ -.nod self + $html + self(p.nod (flop p.nod)) + $code + =< self(q.nod (flop q.nod)) + |- + ?^ p.nod . + ?~ q.nod . + ?: (blank (trip i.q.nod)) $(q.nod t.q.nod) + . + $para + ?~ p.nod self(nod [%defn ~]) + =+ olt=tub + =. q.tub + =- (trip (role -)) + %+ turn + ;;((list {$$ p/tape}) (flop p.nod)) :: XX do type stuff + |=({@ a/tape} (crip a)) + |- ^+ self + =^ ren tub (snack (leas href):inli) + ?^ ren + ?: (~(has by ref) -.u.ren) $ + $(ref (~(put by ref) u.ren)) + =. q.tub (strip (star gah) q.tub) + ?~ q.tub self(nod [%defn ~], tub olt) + self(nod [%para [%$ q.tub]~], tub olt) + == + :: + ++ push :: open block + |= nit/(loca _p:*tops) ^+ +> + =. self cull + =+ toz=[q.nit ~] + ?. ?=({$list ^} q.nit) + (shove p.nit toz) + =. self (shove p.nit toz) + (shove p.nit [%item ~]~) + :: + ++ shove + |= a/(loca tops) ^+ +> + ?~ cur +>(cur [a cur]) + :: =* cub q.i.cur + ?. ?=(nesting [-.p.q.i.cur -.q.a]) + $(+> pop) + +>(cur [a cur]) + :: + ++ pump :: push leaf block + |= a/$^({p/node q/@u} node) + ^+ +> + =+ nex=cull + ?@ -.a nex(nod a) + nex(nod p.a, sap q.a) + :: + ++ match :: check top element + |= a/elem ^- ? + ?~ cur | + =(-.a -.q.i.cur) + :: + :: + ++ collapse :: skim elems off top + |= a/(list (pair @ tops)) ^+ +> + ?~ a +> + :: ?: ?=([[@ *] ~] a) +> + ~? bug yank+[i.a blos] + ?> (match q.i.a) + :: ~& [%no-match a cur] + :: !! + $(a t.a, +> pop) + :: + ++ offset + ^- @u + ?~ cur 0 + ?: ?=($bloq -.p.q.i.cur) + p.i.cur + offset(cur t.cur) + :: + ++ delist (pop-til top-list):bye + ++ debloq + |= ruc/_(flop cur) + ^+ self + ?~ ruc self + ?. ?=($bloq -.p.q.i.ruc) + $(ruc t.ruc) + (collapse (flop ruc)) + :: + ++ nil-li + ?& ?=($defn -.nod) + ?=(^ cur) + ?=({{$item $~} $~} q.i.cur) + == + ++ widen ^+ cur :: list loosening + =< ?~ cur ~ + ?. ?=($item -.p.q.i.cur) + (. cur) + [i.cur (. t.cur)] + |= a/_cur ^+ a + ~? > bug naro+[debu nil-li a cur] + ?~ a a + ?: ?=({{$item $~} $~} q.i.a) + a + ?. ?=($list -.p.q.i.a) + [i.a $(a t.a)] + a(p.p.q.i |) + :: + ++ blos :: extract elem list + (flop (turn cur |*({@ a/tops} a))) + :: + ++ eat-line :: high-level line nom + ^+ . + ~? >> bug line+curlin + :: => [bup=bun sepa:eat] + :: ?: bun:+ + :: blank line nommed + :: =< .(bun |) + :: =. bun bup + ~? bug line-stat+[debu cur] + ?: ?=($html -.nod) + =+ sep=(sepa:eat) + ?: bun.sep sep + span:eat.+ + => [ruc .]=olds:eat + ?: &(?=($~ ruc) ?=({$code ^ *} nod)) + code:eat + =+ sep=(sepa:eat ruc) + ?: bun.sep + ~? bug nilli+[debu nil-li nod cur]:sep + =. bun.sep + ?^(ruc & ?^(cur | !nil-li:sep)) :: XX Chesterton fence + sep + =< .(bun |) + =~ [ruc=ruc sep(bun bun)] + (lazy:eat ruc) + news:eat + node:eat + span:eat + :: ~? bug seated+[nod blos] . + == + :: + ++ curlin (scab q.tub (star prn)) + ++ eat + |% + ++ sepa :: consume blank line + |= ruc/_(flop cur) ^+ self + ?: ?=({$code ^ *} nod) :: ignore in blocks + self + =^ buf tub (snack ;~(sfix (star ace) nal)) + ?~ buf + self(bun |) + ~? bug seat+cur + =. self + ?: bun + delist + =. bun & + (debloq ruc) + ?+ -.nod self + $para cull + $html cull + $code =- self(q.nod -) + ?~ q.nod q.nod + [(crip (slag 4 u.buf)) q.nod] + == + :: + ++ horz :: horizontal rule + ^+ self + =^ neu tub (snack (leas hrul:donp)) + ?~ neu self + (pump u.neu) + :: + ++ olds :: previous nest levels + =+ [ruc=(flop cur) ovs=0] + |- ^+ [ruc self] + ?: =(~ q.tub) + [~ halt] + ?~ ruc [ruc self] + ~? bug heat+[debu q.i.ruc cur] + ?- -.p.q.i.ruc + $bloq + =^ neu tub (snack blomar:donp) + ?^ neu $(ruc t.ruc, ovs p.i.ruc) + [ruc self] + :: + $list + ?~ t.ruc !! + :: $(t.ruc [p.i.ruc [%item ~] ~]~) :: XX why this + ?> ?=($item -.p.q.i.t.ruc) + ~? bug leat+[p.i.t.ruc debu] + =^ den tub (snack (stun [p p]:i.t.ruc ace)) + ?^ den $(ruc t.t.ruc) + ?. =(self horz) [ruc self] :: XX efficiency + ?: ?=({$code ^ *} nod) + [~ self] :: XX correct? + =^ neu tub (snake limar:donp) + ?~ neu [ruc self] + => .(q.u.neu ^+(p.q.i.ruc q.u.neu)) :: XX do type stuff + ?. (list-nest p.q.i.ruc q.u.neu) + =. self (collapse (flop ruc)) + [~ (push u.neu)] + =. self (collapse (flop t.ruc)) + [~ (push p.u.neu [%item ~])] + :: + $item + !! + == + :: + ++ aces |=(a/@u ^+(tub +:(snack (stun 0^a ace)))) :: nom optional leading + :: + ++ lazy :: errant prev bloqs + |= ruc/(list (pair @ tops)) + ^+ self + ~? bug laze+[debu ruc] + ?. ?=($para -.nod) + (collapse (flop ruc)) + ?: |([?=(^ -)]:lead [?=(^ -)]:(snack leaf:donp)) :: XX efficiency + (collapse (flop ruc)) + :: =. tub +:(snack (star ace)) + self + ::self(tub (aces p.i.cur)) :: XX correct? + :: =< (collapse (flop ruc)) + :: |- ^+ . + :: ?~ ruc ..$ + :: ?. ?=([%bloq ~] -.q.i.ruc) + :: ..$ + :: $(ruc t.ruc) + :: + ++ lead :: enter into tops + %- snake + => donp + ;~(plug ;~(pose blomar limar)) + :: + ++ news :: enter nest levels + |- ^+ self + ?. =(self horz) self :: XX efficiency + =^ neu tub + lead + ?~ neu + self + =. bun | :: don't wide new lists + $(self (push u.neu)) + :: + ++ node :: consume leaf node + ^+ self + ~? bug neat+curlin + ::=. self ?.(bun self cull) + ?^ [q]:((leas htm-head):donp tub) :: XX efficiency + (pump [%html ~]) + =+ ^= hez + %+ stag %heas + ?. ?=({$para {$$ *} $~} nod) + fail + ;~(plug setext:donp (cold p.nod (ahed eol))) + =+ ico=?:(?=($para -.nod) fail icode:donp) + =+ saf=q.p.+:(snack (star ace)) :: XX efficiency + =^ neu tub + (snack ;~(pose hez ico leaf:donp)) + ~? bug feat+[bun saf blos neu] + =. cur + ?.(bun cur widen) + ?~ neu + =. tub +:(snack (star ace)) + ?. ?=($para -.nod) + cull + self + ?+ -.u.neu (pump u.neu) + $heas self(nod u.neu(- %head)) :: replace extant para + $code ?^ p.u.neu + (pump u.neu (dec saf)) + ?: ?=({$code $~ *} nod) + self + (pump u.neu) + == + :: + ++ code + ^+ self + ?> ?=({$code ^ *} nod) :: XX do type stuff + ~? bug ceas+[sap] + =. tub (aces sap) + =+ [neu tup]=(snack ;~(sfix (leas fcode):donp eol)) + ?: &(?=(^ neu) (closes-code p.nod p.u.neu)) + =. q.nod q.nod + cull(tub tup) + =^ buf tub (snack ;~(sfix (star ace) nal)) + ?^ buf + self(q.nod [(crip u.buf) q.nod]) + span + :: + ++ span :: raw text + ^+ self + ?: =(~ q.tub) halt + =^ lin tub + (snack line:donp) + ?~ lin + halt + ~? bug adva+u.lin + |- + ?~ u.lin + ?+ -.nod cull + $code self + $html self(p.nod ['' p.nod]) + == + ?+ -.nod (pump para+~[`u.lin]) + $para self(p.nod :_(p.nod `u.lin)) + $head ?^ q.nod $(self cull) + self(q.nod [`(dehax u.lin)]~) + $code self(q.nod :_(q.nod (crip u.lin))) + $html self(p.nod :_(p.nod (crip u.lin))) + == + :: + -- +-- -- + == diff --git a/lib/down-jet/rend.hoon b/lib/down-jet/rend.hoon new file mode 100644 index 000000000..c00f8c449 --- /dev/null +++ b/lib/down-jet/rend.hoon @@ -0,0 +1,239 @@ +:: ++down rendering arms +!: +:::: + :: +|% +++ into-inner + |= {a/marl b/manx} + ?~ c.b b(c a) + $(b i.c.b) +:: +++ flat + |= a/marl + ^- tape + ?~ a ~ + %- weld :_ $(a t.a) + ^- tape + ?~ n.g.i.a + ?>(?=(_:/(**) i.a) v.i.a.g.i.a) + ?+ n.g.i.a $(a c.i.a) + $img + %- zing ^- wall + %+ murn a.g.i.a |= {a/mane b/tape} + ^- (unit tape) + ?+ a ~ + $alt [~ b] + == + == +++ sanitize + |= a/marl ^- tape + =- (zing `wall`(scan (flat a) fel)) + =< fel=;~(sfix (star ;~(plug (cold '-' -) (plus +))) (star next)) + [(star ;~(less aln prn)) ;~(pose nud low (cook |=(a/@ (add a ' ')) hig))] +:: +++ sang :: tight item children + |= a/(list elem) + ^- marl + ?~ a ~ + %- weld :_ $(a t.a) + ?. ?=($para -.i.a) + (sing i.a ~) + (sung p.i.a) +:: +++ sing :: elem to manx + => |% + ++ first-word + |= a/tape + =. a (trip (crip a)) :: XX valid tapes + ^- (unit tape) + =. a q.q:(need q:((star ace) [1 1] a)) + =+ vex=((plus ;~(less ace prn)) [1 1] a) + ?~ q.vex ~ + (some (wonk vex)) + -- + =+ [tig=| had=*(unit mane)] + |= lum/(list elem) + |^ ^- marl + =+ a=apex + ?~ q.a + p.a + (weld p.a $(lum q.a)) + :: + ++ apex + ^- {p/marl q/_lum} + ?~ lum + ?~ had [~ ~] + (lose "unclosed {}") + => [ele=i.lum .(lum t.lum)] + ?. ?=($html -.ele) + (push (reso ele) ~) + :: begin reparsing of html that the spec jankily lets through :: + =+ tex=(trip (role p.ele)) + =^ mar lum (chomp tex (sear |=(a/marl ?~(a ~ (some a))) many:poxa)) + ?^ mar + (push u.mar) + =^ hed lum (chomp tex head:poxa) + ?^ hed + =+ max=`marx`u.hed + (push(lum q) [max p] ~):[apex(had `n.max) .] + =^ tal lum (chomp tex tail:poxa) + ?~ tal + =^ cha lum (chomp tex prn) + ?^ cha + (push :/([u.cha]~) ~) + (push ;lost:"{tex}" ~) + ?: =(had tal) + [~ lum] + ?^ had + =. lum [ele lum] + (lose "unclosed {}") + (lose "close {}") + :: end reparsing of html that the spec jankily lets through :: + :: + ++ lose |=(a/tape [[;lost:"{a}"]~ lum]) + ++ chomp + |* {tap/tape fel/rule} + ^- {(unit _(wonk *fel)) _lum} + =+ vex=(fel 1^1 tap) + ?~ q.vex [~ lum] + :- [~ (wonk vex)] + ?~(q.q.u.q.vex lum [[%html (lore (crip q.q.u.q.vex))] lum]) + :: + ++ push + |= a/marl + ^+ apex + ?~ a apex + [[b p] q]:[b=i.a (push t.a)] + :: + ++ reso + |= a/elem + ?^ -.a + =. tig ?.(?=($list -.p.a) tig p.p.a) + ?: &(tig ?=($item -.p.a)) + [/li (sang q.a)] + %+ into-inner ^$(lum q.a) + ?- -.p.a + $bloq ;blockquote; + $item ;li; + $list ?@ q.p.a ;ul; + ?: =(1 p.q.p.a) ;ol; + =+ num=(pojo (jone p.q.p.a)) + ;ol(start num); + == + ?- -.a :: :/("unimplemented {}") + $html !! :: handled earlier XX do type stuff + $para [/p (sung p.a)] + $head + =+ [hed=(add %h0 (lsh 3 1 p.a)) kid=(sung q.a)] + [[hed id+(sanitize kid) ~] kid] + :: + $hrul ;hr; + $meta =+ jon=`json`o+(~(run by p.a) |=(cord s++<)) + ;meta(value "{(pojo jon)}", name "frontmatter", urb_front ""); + :: %html + ::=+ tex=(role (turn p.a crip)) + ::=+ (poxa tex) + ::?^ - u.- + ::=+ (rush tex (star ;~(pose gah comt:poxa))) + ::?^ - :/(~) + ::;lost: {} + :: :/([(role (turn p.a crip))]~) :: XX haaaaaaack + $defn :/(~) + $code =+ lan=?~(p.a ~ (first-word r.u.p.a)) + =+ tex=(trip (role q.a)) + ?~ lan ;pre:code:"{tex}" + ;pre:code(class "language-{u.lan}"):"{tex}" + + == + -- +:: +++ sung + |= lim/kids + =+ had=*(unit mane) + |^ ^- marl + =+ a=apex + ?~ q.a + p.a + (weld p.a $(lim q.a)) + :: + ++ apex + ^- {p/marl q/_lim} + ?~ lim + ?~ had [~ ~] + (lose "unclosed {}") + => [ele=i.lim .(lim t.lim)] + ?. ?=($htmt -.ele) + ?: &(?=($$ -.ele) ?=({{$$ *} *} lim)) + apex(p.i.lim (weld p.ele p.i.lim)) + (push (reso ele) ~) + =+ tex=(trip p.ele) + =^ emo lim (chomp tex empt:poxa) + ?^ emo + =+ man=`manx`u.emo + (push man ~) + =^ hed lim (chomp tex head:poxa) + ?^ hed + =+ max=`marx`u.hed + (push(lim q) [max p] ~):[apex(had `n.max) .] + =^ tal lim (chomp tex tail:poxa) + ?~ tal + (push ;lost:"{tex}" ~) + ?: =(had tal) + [~ lim] + ?^ had + =. lim [ele lim] + (lose "unclosed {}") + (lose "unopened {}") + :: + ++ lose |=(a/tape [[;lost:"{a}"]~ lim]) + ++ chomp + |* {tap/tape fel/rule} + ^- {(unit _(wonk *fel)) _lim} + =+ vex=(fel 1^1 tap) + ?~ q.vex [~ lim] + :- [~ (wonk vex)] + ?~(q.q.u.q.vex lim [[%htmt (crip q.q.u.q.vex)] lim]) + :: + ++ push + |= a/marl + ^+ apex + ?~ a apex + [[b p] q]:[b=i.a (push t.a)] + :: + ++ urly + |= a/tape ^- tape + ?~ a ~ + :: ?: (gth i.a 0xff) "XX" :: XX + ?: ?| [?=(^ q)]:(alp 1^1 a) + (~(has in (sa "!*'();:@&=+$,/?/%.~_")) i.a) :: XX reparse + == + [i.a $(a t.a)] + (weld (urle (trip i.a)) $(a t.a)) + :: + ++ reso + |= b/inline + ^- manx + ?@ -.b + ?- -.b + $$ :/(p.b) + $line ;br; + $code ;code:"{p.b}" + $htmt !! ::p.b :: handled earlier :: XX do type stuff + == + ?: ?=($blot -.p.b) + =+ res=`manx`;img(src (urly p.p.b), alt (flat (turn q.b ..$))); + :: ;img@"{p.p.b}"; + ?~ q.p.b res + res(a.g (welp a.g.res title+u.q.p.b ~)) + =+ kid=(sung q.b) + %+ into-inner kid + ?- p.b + {$emph ?} ?.(p.p.b ;em; ;strong;) + {$delt $~} ;del; + {$link ^} =+ url=(urly p.p.b) + =. url ?^(url url "#{(sanitize kid)}") + ?~ q.p.b ;a/"{url}"; + ;a/"{url}"(title u.q.p.b); + == + -- +-- diff --git a/lib/frontmatter.hoon b/lib/frontmatter.hoon new file mode 100644 index 000000000..cdb4639b5 --- /dev/null +++ b/lib/frontmatter.hoon @@ -0,0 +1,34 @@ +:: +:::: /hoon+frontmatter+lib + :: +/? 314 +!: +|% +++ atr-lines + |= atr/(map cord cord) + %+ turn (sort (~(tap by atr)) |=({{a/@ @} {b/@ @}} (aor a b))) + |= {k/cord v/cord} + (rap 3 k ': ' v ~) +:: +++ atr-key ;~(sfix (star ;~(less col prn)) col ace) +++ print + |= {atr/(map cord cord) src/wain} + ?~ atr src + ['---' (welp (atr-lines atr) '---' src)] +++ parse + =| atr/(map cord cord) + |= wan/wain ^+ [atr mud=''] + ?~ wan [~ ''] + ?^ (rush i.wan (star ace)) + $(wan t.wan) + ?. =('---' i.wan) [~ (role wan)] + |- ^+ [atr mud=''] + ?~ t.wan ~|(%unclosed-metadata !!) + ?: =('---' i.t.wan) [atr (role t.t.wan)] + ?^ (rush i.t.wan (star ace)) + $(wan t.wan) + =- $(wan t.wan, atr (~(put by atr) (crip key) (crip val))) + ~| malformed-attribute+i.t.wan + ^- {key/tape ^ val/tape} + +>:(atr-key 1^1 (trip i.t.wan)) +-- diff --git a/lib/oct1.hoon b/lib/oct1.hoon new file mode 100644 index 000000000..d52df9d46 --- /dev/null +++ b/lib/oct1.hoon @@ -0,0 +1,43 @@ +:: :: :: +:::: /hoon+oct1/lib :::::: dependencies + :: :: :: +/? 310 :: arvo version +/- oct1 :: structures +=> ^oct1 :: namespace +:: :: :: +:::: :::::: semantics + !: :: :: +|% :: +++ icon |=(? ?:(+< 'X' 'O')) :: display at +++ bo :: per board + |_ bud/board :: + ++ bit |=(@ =(1 (cut 0 [+< 1] bud))) :: moved at address + ++ get |=(point (bit (off +<))) :: 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 :: play from + |_ game:oct1 :: + ++ at |_ point :: per point + ++ g +>+< :: game + ++ k !|(x o) :: legal 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 + -- :: + ++ new +<(boo 0, box 0, who &) :: reset game + ++ res ?. |(~(win bo box) ~(win bo boo)) :: possible result + ?: =(511 (con boo box)) :: + `"tie :-(" ~ `"{<~[(icon who)]>} wins" :: + ++ row |= y/@ :- (add y '1') %- zing :: print row + (turn (gulf 0 3) |=(@ ~[' ' ~(v at y +<)])) :: + ++ tab ~["+ 1 2 3" (row 0) (row 1) (row 2)] :: print table + ++ voy ": {<~[(icon who)]>} (row+col): " :: print prompt + -- +-- diff --git a/lib/oct2.hoon b/lib/oct2.hoon new file mode 100644 index 000000000..de39e05ee --- /dev/null +++ b/lib/oct2.hoon @@ -0,0 +1,59 @@ +:: :: :: +:::: /hoon+oct2/lib :::::: dependencies + :: :: :: +/? 310 :: arvo version +/- oct2 :: structures +=> ^oct2 :: namespace +:: :: :: +:::: :::::: semantics + !: :: :: +|% :: +++ icon |=(? ?:(+< 'X' 'O')) :: display at +++ bo :: per board + |_ bud/board :: + ++ bit |=(@ =(1 (cut 0 [+< 1] bud))) :: moved at address + ++ get |=(point (bit (off +<))) :: 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 :: play from + |_ {src/ship game} :: + ++ at |_ point :: per point + ++ g `game`+>+<+ :: game + ++ k &(!|(x o) ept) :: legal move + ++ m ?.(k [| g] [& g:t:?:(who y p)]) :: move + ++ o (~(get bo boo) +<) :: old at o + ++ p .(boo (~(set bo boo) +<), q.sag `src) :: 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) +<), p.sag `src) :: play at x + -- :: + ++ ept =+(own |(&(=(~ -) !=(oth `src)) =(`src -))) :: we can play + ++ hey |=(? +>+<+(aud ((stat ship) +< src aud))) :: enter+leave + ++ muy |= (list ship) ?~ +< +>+<+ :: many in audience + $(+< t.+<, aud ((stat ship) & i.+< aud)) :: + ++ nam =+ ?: =(p.sag `src) ['=' (icon &) ~] :: print name + ?: =(q.sag `src) ['=' (icon |) ~] :: + "" (welp (scow %p src) `tape`-) :: + ++ new +<+(boo 0, box 0, who &, sag [~ ~]) :: reset game + ++ oth own(who !who) :: who owns other turn + ++ own ?:(who p.sag q.sag) :: who owns this turn + ++ res ?. |(~(win bo box) ~(win bo boo)) :: possible result + ?: =(511 (con boo box)) :: + `"tie :-(" ~ `"{} wins" :: + ++ row |= y/@ :- (add y '1') %- zing :: print row + (turn (gulf 0 3) |=(@ ~[' ' ~(v at y +<)])) :: + ++ str =+ [own ~[(icon who)]] ^- tape :: print player + ?~(-< -> (scow %p u.-<)) :: + ++ tab ~["+ 1 2 3" (row 0) (row 1) (row 2)] :: print table + ++ vew =- ?: =(~ -) ~ :(weld "[" - "]") :: print watchers + =+ dow=(~(tap by aud)) |- ^- tape :: + ?~ dow ~ =+ mor=$(dow t.dow) :: + :(weld nam(src p.i.dow) ?~(mor "" ", ") mor) :: + ++ voy =+ ~[(icon who)] %+ weld vew :: print prompt + ?.(ept " ({-}'s turn) " ": {-} (row+col): "):: + -- +-- diff --git a/lib/oct3.hoon b/lib/oct3.hoon new file mode 100644 index 000000000..f3e3c1390 --- /dev/null +++ b/lib/oct3.hoon @@ -0,0 +1,60 @@ +:: :: :: +:::: /hoon+oct3/lib :::::: dependencies + :: :: :: +/? 310 :: arvo version +/- oct3 :: structures +:: :: :: +:::: :::::: semantics + !: :: :: +[. ^oct3] +|% :: +++ icon |=(? ?:(+< 'X' 'O')) :: display at +++ bo :: per board + |_ bud/board :: + ++ bit |=(@ =(1 (cut 0 [+< 1] bud))) :: moved at address + ++ get |=(point (bit (off +<))) :: get point + ++ jon a+(turn (gulf 0 9) |=(@ b+(bit +<))) :: to json + ++ 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 :: play from + |_ {src/ship game} :: + ++ at |_ point :: per point + ++ g `game`+>+<+ :: game + ++ k &(!|(x o) ept) :: legal move + ++ m ?.(k [| g] [& g:t:?:(who y p)]) :: move + ++ o (~(get bo boo) +<) :: old at o + ++ p .(boo (~(set bo boo) +<), q.sag `src) :: 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) +<), p.sag `src) :: play at x + -- :: + ++ ept =+(own |(&(=(~ -) !=(oth `src)) =(`src -))) :: we can play + ++ hey |=(? +>+<+(aud ((stat ship) +< src aud))) :: enter+leave + ++ muy |= (list ship) ?~ +< +>+<+ :: many in audience + $(+< t.+<, aud ((stat ship) & i.+< aud)) :: + ++ nam =+ ?: =(p.sag `src) ['=' (icon &) ~] :: print name + ?: =(q.sag `src) ['=' (icon |) ~] :: + "" (welp (scow %p src) `tape`-) :: + ++ new +<+(boo 0, box 0, who &, sag [~ ~]) :: reset game + ++ oth own(who !who) :: who owns other turn + ++ own ?:(who p.sag q.sag) :: who owns this turn + ++ res ?. |(~(win bo box) ~(win bo boo)) :: possible result + ?: =(511 (con boo box)) :: + `"tie :-(" ~ `"{} wins" :: + ++ row |= y/@ :- (add y '1') %- zing :: print row + (turn (gulf 0 3) |=(@ ~[' ' ~(v at y +<)])) :: + ++ str =+ [own ~[(icon who)]] ^- tape :: print player + ?~(-< -> (scow %p u.-<)) :: + ++ tab ~["+ 1 2 3" (row 0) (row 1) (row 2)] :: print table + ++ vew =- ?: =(~ -) ~ :(weld "[" - "]") :: print watchers + =+ dow=(~(tap by aud)) |- ^- tape :: + ?~ dow ~ =+ mor=$(dow t.dow) :: + :(weld nam(src p.i.dow) ?~(mor "" ", ") mor) :: + ++ voy =+ ~[(icon who)] %+ weld vew :: print prompt + ?.(ept " ({-}'s turn) " ": {-} (row+col): "):: + -- +-- diff --git a/lib/oct4.hoon b/lib/oct4.hoon new file mode 100644 index 000000000..20db78ff5 --- /dev/null +++ b/lib/oct4.hoon @@ -0,0 +1,60 @@ +:: :: :: +:::: /hoon+oct4/lib :: :: dependencies + :: :: :: +/? 310 :: arvo version +/- oct4 :: structures +:: :: :: +:::: :: :: semantics + !: :: :: +[. ^oct4] +|% +++ icon |=(? ?:(+< 'X' 'O')) :: display at +++ bo :: per board + |_ bud/board :: + ++ bit |=(@ =(1 (cut 0 [+< 1] bud))) :: moved at address + ++ get |=(point (bit (off +<))) :: get point + ++ jon a+(turn (gulf 0 9) |=(@ b+(bit +<))) :: to json + ++ 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 :: play from + |_ {src/ship game} :: + ++ at |_ point :: per point + ++ g `game`+>+<+ :: game + ++ k &(!|(x o) ept) :: legal move + ++ m ?.(k [| g] [& g:t:?:(who y p)]) :: move + ++ o (~(get bo boo) +<) :: old at o + ++ p .(boo (~(set bo boo) +<), q.sag `src) :: 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) +<), p.sag `src) :: play at x + -- :: + ++ ept =+(own |(&(=(~ -) !=(oth `src)) =(`src -))) :: we can play + ++ hey |=(? +>+<+(aud ((stat ship) +< src aud))) :: enter+leave + ++ muy |= (list ship) ?~ +< +>+<+ :: many in audience + $(+< t.+<, aud ((stat ship) & i.+< aud)) :: + ++ nam =+ ?: =(p.sag `src) ['=' (icon &) ~] :: print name + ?: =(q.sag `src) ['=' (icon |) ~] :: + "" (welp (scow %p src) `tape`-) :: + ++ new +<+(boo 0, box 0, who &, sag [~ ~]) :: reset game + ++ oth own(who !who) :: who owns other turn + ++ own ?:(who p.sag q.sag) :: who owns this turn + ++ res ?. |(~(win bo box) ~(win bo boo)) :: possible result + ?: =(511 (con boo box)) :: + `"tie :-(" ~ `"{} wins" :: + ++ row |= y/@ :- (add y '1') %- zing :: print row + (turn (gulf 0 3) |=(@ ~[' ' ~(v at y +<)])) :: + ++ str =+ [own ~[(icon who)]] ^- tape :: print player + ?~(-< -> (scow %p u.-<)) :: + ++ tab ~["+ 1 2 3" (row 0) (row 1) (row 2)] :: print table + ++ vew =- ?: =(~ -) ~ :(weld "[" - "]") :: print watchers + =+ dow=(~(tap by aud)) |- ^- tape :: + ?~ dow ~ =+ mor=$(dow t.dow) :: + :(weld nam(src p.i.dow) ?~(mor "" ", ") mor) :: + ++ voy =+ ~[(icon who)] %+ weld vew :: print prompt + ?.(ept " ({-}'s turn) " ": {-} (row+col): "):: + -- +-- diff --git a/lib/react.hoon b/lib/react.hoon new file mode 100644 index 000000000..472c49bc2 --- /dev/null +++ b/lib/react.hoon @@ -0,0 +1,132 @@ +!: +|% +++ react-elems :: XX /~ + ~+ %- sa ^- (list term) + :~ %a %abbr %address %area %article %aside %audio %b %base + %bdi %bdo %big %blockquote %body %br %button %canvas %caption + %cite %code %col %colgroup %data %datalist %dd %del %details + %dfn %dialog %div %dl %dt %em %embed %fieldset %figcaption + %figure %footer %form %h1 %h2 %h3 %h4 %h5 %h6 %head %header + %hr %html %i %iframe %img %input %ins %kbd %keygen %label + %legend %li %link %main %map %mark %menu %menuitem %meta + %meter %nav %noscript %object %ol %optgroup %option %output %p + %param %picture %pre %progress %q %rp %rt %ruby %s %samp + %script %section %select %small %source %span %strong %style + %sub %summary %sup %table %tbody %td %textarea %tfoot %th + %thead %time %title %tr %track %u %ul %var %video %wbr + %circle %defs %ellipse %g %line %linear-gradient %mask %path + %pattern %polygon %polyline %radial-gradient %rect %stop %svg + %text %tspan + == +++ react-attrs + ~+ ^- (map term cord) + %- mo ^- (list {term cord}) + :- [%class 'className'] + =- (rash - (more next (cook |=(a/tape [(cass a) (crip a)]) (star alf)))) + ''' + accept acceptCharset accessKey action allowFullScreen allowTransparency alt + async autoComplete autoFocus autoPlay cellPadding cellSpacing charSet checked + classID className colSpan cols content contentEditable contextMenu controls + coords crossOrigin data dateTime defer dir disabled download draggable encType + form formAction formEncType formMethod formNoValidate formTarget frameBorder + headers height hidden high href hrefLang htmlFor httpEquiv icon id label lang + list loop low manifest marginHeight marginWidth max maxLength media mediaGroup + method min multiple muted name noValidate open optimum pattern placeholder + poster preload radioGroup readOnly rel required role rowSpan rows sandbox scope + scoped scrolling seamless selected shape size sizes span spellCheck src srcDoc + srcSet start step style tabIndex target title type useMap value width wmode + ''' +++ react-vale + ~(has in react-elems) +:: +++ react-to-json + |= src/manx ^- json + ?: ?=(_:/(**) src) + (jape v.i.a.g.src) + =+ atr=(mo a.g.src) + ?: (~(has by atr) [%urb %codemirror]) + ?> ?=({{$pre *} _:/(**) $~} src) + $(src ;codemirror(value "{v.i.a.g.i.c.src}");) + ?: (~(has by atr) [%urb %exec]) :: runnable code attribute tag + ?> ?=({{$pre *} _:/(**) $~} src) :: verify its only a text node + =* code v.i.a.g.i.c.src + %_ $ + src + =+ =< result=(mule .) + !.(|.((slap !>(.) (ream (crip code))))) :: compile and run safely + =+ claz=?:(-.result "rancode" "failedcode") + ;div(class "{claz}") + ;pre:"{code}" + ;+ ?: ?=($& -.result) + ;code:"{~(ram re (sell p.result))}" + ;pre + ;div:"error" + ;* %+ turn p.result + |= a/tank + ^- manx + ;div:"{~(ram re a)}" + == == + == + %- jobe :~ + c+a+(turn c.src ..$) + gn+s+(mane-to-cord n.g.src) + =< ga+(jobe (turn a.g.src .)) + |= {a/mane b/tape} ^- {cord json} + :_ (jape b) + ?^ a (mane-to-cord a) + (fall (~(get by react-attrs) a) a) + == +:: +++ mane-to-cord |=(a/mane `cord`?@(a a (rap 3 -.a ':' +.a ~))) +:: generates React javascript XX deprecated +++ react-to-tape + |= src/manx ^- tape + ?: (~(has by (mo a.g.src)) [%urb %codemirror]) + ?> ?=({{$pre *} _:/(**) $~} src) + $(src ;codemirror(value "{v.i.a.g.i.c.src}");) + ?: (~(has by (mo a.g.src)) [%urb %exec]) :: runnable code attribute tag + ?> ?=({{$pre *} _:/(**) $~} src) :: verify its only a text node + =* code v.i.a.g.i.c.src + =+ ^= result + (mule |.((slap !>(.) (ream (crip code))))) :: compile and run safely + ?: ?=($.y -.result) :: it was ok + =+ ^= new + ;div(class "rancode") + ;pre:"{code}" + ;code:"{~(ram re (sell p.result))}" + == + $(src new) + =+ ^= error + ;div(class "failedcode") + ;pre:"{code}" + ;pre + ;div:"error" + ;* %+ turn + (scag (dec (lent p.result)) p.result) :: hide react trace + |= a/tank + ^- manx + ;div:"{~(ram re a)}" + == + == + $(src error) + ;: weld + "React.createElement(" + =* tan n.g.src + ?^ tan !! :: namespaces unsupported + ?: (react-vale tan) + "'{(trip tan)}'" + (trip tan) + ", " + =- (pojo (jobe (turn a.g.src -))) + |= {a/mane b/tape} + =. a ?+(a a $class 'className') + ?^(a !! [a (jape b)]) + ", " + =< ~(ram re %rose [", " "[" "]"] (turn c.src .)) + |= a/manx + ?: ?=(_:/(**) a) + leaf+(pojo (jape v.i.a.g.a)) + leaf+^$(src a) + ")" + == +-- diff --git a/lib/tree.hoon b/lib/tree.hoon new file mode 100644 index 000000000..d1f4e26c3 --- /dev/null +++ b/lib/tree.hoon @@ -0,0 +1,65 @@ +/- tree-include +!: +|% +++ extract + |= a/marl ^- tape + ?~ a ~ + %- weld :_ $(a t.a) + ?. ?=(_:/(**) i.a) + $(a c.i.a) + v.i.a.g.i.a +:: +++ getall + |= tag/(list mane) + |= ele/manx ^- marl + ?: (lien tag |=(a/mane =(a n.g.ele))) + ~[ele] + (zing (turn c.ele ..$)) +:: +++ baff |*({a/(unit) b/(trap)} ?^(a a *b)) +++ find-in-tree + |* {paz/fist:jo fun/$+(* (unit))} + |= jon/json + =+ a=`(list json)`~[jon] + |^ (try) + ++ try + |. ^+ *fun + ?~ a ~ + %+ biff (paz i.a) + |* {b/(list json) c/*} ^+ *fun + (baff (baff (fun c) try(a b)) try(a t.a)) + -- +:: +++ map-to-json + |* {a/$+(* cord) b/$+(* json)} + |* c/(map) ^- json + ~! c + (jobe (turn (~(tap by c)) |*({k/* v/*} [(a k) (b v)]))) +:: +++ json-front + |= a/json ^- json + =- (fall `(unit json)`- ~) + %. a + %+ find-in-tree (ot c+(ar some) gn+so ga+(om so) ~):jo + |= {nom/span atr/(map span cord)} ^- (unit json) + ?. (~(has by atr) 'urb:front') ~ + ?> ?=($meta nom) + (biff (~(get by atr) %value) poja) +:: +++ read-schem + =< (cook to-noun (cook to-tree apex)) + |% + ++ noun $@(term [noun noun]) :: shadow + ++ data $@(term {n/@ l/noun r/data}) + ++ apex ;~(plug sym (star ;~(plug delim sym))) + ++ delim ;~(pose (cold 0 dot) (cook lent (plus cab))) + ++ to-noun |=(a/data ?@(a a [l.a $(a r.a)])) + ++ to-tree + |= {acc/data a/(list {p/@u q/term})} + %+ roll a =< .(acc ^acc) + |= {{n/@u v/term} acc/data} + ?@ acc [n acc v] + ?: (gth n n.acc) [n (to-noun acc) v] + acc(r $(acc r.acc)) + -- +-- diff --git a/lib/twitter.hoon b/lib/twitter.hoon new file mode 100644 index 000000000..ac1ececd4 --- /dev/null +++ b/lib/twitter.hoon @@ -0,0 +1,544 @@ +:: A Twitter API library. +:: +:::: /hoon+twitter+lib + :: +/? 314 +/- twitter +=+ twit:^twitter +!: +:::: functions + :: +|% +++ fass :: rewrite path + |= a/path + %- trip + %^ gsub '-' '_' + %+ reel a + |= {p/@t q/@t} + (cat 3 '/' (cat 3 p q)) +:: +++ gsub :: replace chars + |= {a/@t b/@t t/@t} + ^- @t + ?~ t t + %+ add (lsh 3 1 $(t (rsh 3 1 t))) + =+ c=(mod t (bex 8)) + ?:(=(a c) b c) +:: +++ oauth :: OAuth 1.0 header + |= $: med/meth + url/tape + pas/(list tape) + key/keys + zet/@ + ken/@ + == + ^- @t + =+ non=(turn (rip 2 (shaw zet 128 ken)) |=(a/@ ~(x ne a))) + =+ tim=(slag 2 (scow %ui (unt zet))) + =+ sky=(crip :(weld (urle (trip sec.con.key)) "&" (urle (trip sec.acc.key)))) + =+ ^= bas + ^- tape + =+ ^= hds + %- reel :_ |=({p/tape q/tape} :(weld p "&" q)) + %- sort :_ aor + %- weld :- pas + ^- (list tape) + :~ :(weld "oauth_consumer_key=" (trip tok.con.key)) + :(weld "oauth_nonce=" non) + :(weld "oauth_signature_method=HMAC-SHA1") + :(weld "oauth_timestamp=" tim) + :(weld "oauth_token=" (trip tok.acc.key)) + :(weld "oauth_version=1.0") + == + ;: weld + (trip (cuss (trip `@t`med))) "&" + (urle url) "&" + (urle (scag (dec (lent hds)) `tape`hds)) + == + =+ sig=`tape`(sifo (swap 3 (hmac (swap 3 sky) (crip bas)))) + %- crip + ;: weld "OAuth " + "oauth_consumer_key=" "\"" (trip tok.con.key) "\", " + "oauth_nonce=" "\"" non "\", " + "oauth_signature=" "\"" (urle sig) "\", " + "oauth_signature_method=\"HMAC-SHA1\", " + "oauth_timestamp=" "\"" tim "\", " + "oauth_token=" "\"" (trip tok.acc.key) "\", " + "oauth_version=1.0" + == +:: +++ valve :: produce request + |= $: med/meth + {rus/tape quy/quay} + key/keys + est/time + eny/@ + == + ^- hiss + =+ url="https://api.twitter.com+1.1{rus}.json" + =+ req=|=(a/tape (scan a auri:epur)) + =+ ^= help + |= quy/(list {tape tape}) + ^- (list tape) + %+ turn quy + |= a/{p/tape q/tape} + :(weld (urle p.a) "=" (urle q.a)) + =+ tan=(turn quy |=({p/@t q/@t} [(trip p) (trip q)])) + =+ har=(help (turn tan |=(p/{p/tape q/tape} [p.p (urle q.p)]))) + =+ hab=(help tan) + =+ lav=(reel har |=({p/tape q/tape} :(weld p "&" q))) + =+ voy=?:(=(0 (lent lav)) ~ (scag (dec (lent lav)) `tape`lav)) + =+ vab=(reel hab |=({p/tape q/tape} :(weld p "&" q))) + =+ vur=(crip ?:(=(0 (lent vab)) ~ (scag (dec (lent vab)) `tape`vab))) + =+ ^= head + %- ~(gas by *math) + :~ ['authorization' [(oauth med url hab key est eny) ~]] + ['content-type' ['application+x-www-form-urlencoded' ~]] + == + ?: =(%get med) + ?~ voy + [(req url) med head ~] + [(req :(weld url "?" voy)) med head ~] + [(req url) med head (some [(met 3 vur) vur])] +-- +!: +:::: library + :: +|% +++ twip :: response printers + |% + ++ mean + |= {msg/@t num/@ud} ^- tank + rose+[": " `~]^~[leaf+"Error {}" leaf+(trip msg)] + -- +++ twir :: response parsers + |% + ++ fasp |*({a/@tas b/*} [(gsub '-' '_' a) b]) + ++ user (cook crip (plus ;~(pose aln cab))) + ++ mean (ot errors+(ar (ot message+so code+ni ~)) ~):jo + ++ stat + =+ jo + ^- $+(json (unit {id/@u who/@ta now/@da txt/@t})) + %- ot + :~ id+ni + user+(ot (fasp screen-name+(su user)) ~) + (fasp created-at+da) + text+so + == + ++ usel + =+ jo + ^- $+(json (unit (list who/@ta))) + =- (ot users+(ar -) ~) + (ot (fasp screen-name+(su user)) ~) + -- +++ twit + => |% :: request structures + ++ dev @t :: device name + ++ gat @t :: grant type + ++ lat @t :: latitude + ++ lid (list tid) + ++ lon @t :: longitude + ++ lsc (list scr) + ++ lst (list @t) + ++ nam @t :: location name + ++ pla @t :: place-id + ++ scr @t :: screen name + ++ slu @t :: category name + ++ tid @u + ++ tok @t :: oauth token + ++ url @t :: callback url + :: + ++ at {$access-token p/tok} + ++ de {$device p/dev} + ++ fo {$follow p/lid} + ++ gr {$grant-type p/gat} + ++ id {$id p/tid} + ++ ii {$'!inline' p/@t} + ++ is {$id p/lid} + ++ la {$lat p/lat} + ++ lo {$long p/lon} + ++ na {$name p/lid} + ++ oa {$oauth-callback p/url} + ++ os {$source-screen-name p/scr} + ++ pl {$place-id p/pla} + ++ qq {$q p/@t} + ++ sc {$screen-name p/scr} + ++ sd ?(ui sc) + ++ ss {$screen-name p/lsc} + ++ sl {$slug p/slu} + ++ si {$source-id p/tid} + ++ st {$status p/@t} + ++ te {$text p/@t} + ++ ti {$target-id p/tid} + ++ ts {$target-screen-name p/scr} + ++ tr {$track p/lst} + ++ ur {$url p/url} + ++ ui {$user-id p/tid} + ++ us {$user-id p/lid} + -- + |_ {key/keys est/time eny/@uw} + ++ lutt |=(@ `@t`(rsh 3 2 (scot %ui +<))) + ++ llsc + |= (list scr) + (roll +< |=({p/scr q/@t} (cat 3 (cat 3 q ',') p))) + :: + ++ llst + |= (list @t) + (roll +< |=({p/@t q/@t} (cat 3 (cat 3 q ',') p))) + :: + ++ llid + |= (list tid) + (roll +< |=({p/tid q/@t} (cat 3 (cat 3 q ',') (lutt p)))) + :: + ++ mold :: construct request + |* {med/meth pax/path a/$+(* *)} + |= {args/a quy/quay} + (valve med (cowl pax args quy) key est eny) + :: + ++ cowl :: handle parameters + |= $: pax/path + ban/(list {p/@t q/?(@ (list @))}) + quy/quay + == + ^- {path quay} + ?~ ban + [(fass pax) quy] + ?: =('!inline' p.i.ban) + ?@ q.i.ban + [(fass (welp pax /[`@t`q.i.ban])) quy] + !! + :- (fass pax) + %+ welp quy + %+ turn `(list {p/@t q/?(@ (list @))})`ban + |= {p/@t q/?(@ (list @))} + ^- {@t @t} + :- (gsub '-' '_' p) + ?@ q + ?- p + ?($id $source-id $target-id $user-id) (lutt q) + @ `@t`q + == + ?- p + ?($follow $id $name $user-id) (llid q) + $track (llst q) + $screen-name (llsc q) + * !! + == + :: + ++ stat-ment + (mold %get /statuses+mentions-timeline $~) + :: + ++ stat-user + (mold %get /statuses+user-timeline {sd $~}) + :: + ++ stat-home + (mold %get /statuses+home-timeline $~) + :: + ++ stat-retw + (mold %get /statuses+retweets-of-me $~) + :: + ++ stat-rets-iddd + (mold %get /statuses+retweets {ii $~}) + :: + ++ stat-show + (mold %get /statuses+show {id $~}) + :: + ++ stat-dest-iddd + (mold %post /statuses+destroy {ii $~}) + :: + ++ stat-upda + (mold %post /statuses+update {st $~}) + :: + ++ stat-retw-iddd + (mold %post /statuses+retweet {ii $~}) + :: + ++ stat-oemb-iddd + (mold %get /statuses+oembed {id $~}) + :: + ++ stat-oemb-urll + (mold %get /statuses+oembed {ur $~}) + :: + ++ stat-retw-idss + (mold %get /statuses+retweeters+ids {id $~}) + :: + ++ sear-twee + (mold %get /search+tweets {qq $~}) + :: + ++ stat-filt-foll + (mold %post /statuses+filter {?(fo tr) $~}) + :: + ++ stat-samp + (mold %get /statuses+sample $~) + :: + ++ stat-fire + (mold %get /statuses+firehose $~) + :: + ++ user + (mold %get /user $~) + :: + ++ site + (mold %get /site {fo $~}) + :: + ++ dire + (mold %get /direct-messages $~) + :: + ++ dire-sent + (mold %get /direct-messages+sent $~) + :: + ++ dire-show + (mold %get /direct-messages+show {id $~}) + :: + ++ dire-dest + (mold %post /direct-messages+destroy {id $~}) + :: + ++ dire-neww + (mold %post /direct-messages+new {sd te $~}) + :: + ++ frie-nore-idss + (mold %get /friendships+no-retweets+ids $~) + :: + ++ frie-idss + (mold %get /friends+ids {sd $~}) + :: + ++ foll-idss + (mold %get /followers+ids {sd $~}) + :: + ++ frie-inco + (mold %get /friendships+incoming $~) + :: + ++ frie-outg + (mold %get /friendships+outgoing $~) + :: + ++ frie-crea + (mold %post /friendships+create {sd $~}) + :: + ++ frie-dest + (mold %post /friendships+destroy {sd $~}) + :: + ++ frie-upda + (mold %post /friendships+update {sd $~}) + :: + ++ frie-show + (mold %get /friendships+show {?(si os) ?(ti ts) $~}) + :: + ++ frie-list + (mold %get /friends+list {sd $~}) + :: + ++ foll-list + (mold %get /followers+list {sd $~}) + :: + ++ frie-look + (mold %get /friendships+lookup {?(us ss) $~}) + :: + ++ acco-sett-gett + (mold %get /account+settings $~) + :: + ++ acco-veri + (mold %get /account+verify-credentials $~) + :: + ++ acco-sett-post + (mold %post /account+settings $~) + :: + ++ acco-upda-deli + (mold %post /account+update-delivery-device {de $~}) + :: + ++ acco-upda-prof + (mold %post /account+update-profile $~) + :: + ++ acco-upda-prof-back + (mold %post /account+update-profile-background-image $~) + :: + ++ acco-upda-prof-colo + (mold %post /account+update-profile-colors $~) + :: + ++ bloc-list + (mold %get /blocks+list $~) + :: + ++ bloc-idss + (mold %get /blocks+ids $~) + :: + ++ bloc-crea + (mold %post /blocks+create {sd $~}) + :: + ++ bloc-dest + (mold %post /blocks+destroy {sd $~}) + :: + ++ user-look + (mold %get /users+lookup {?(us ss) $~}) + :: + ++ user-show + (mold %get /users+show {sd $~}) + :: + ++ user-sear + (mold %get /users+search {qq $~}) + :: + ++ user-cont-tees + (mold %get /users+contributees {sd $~}) + :: + ++ user-cont-tors + (mold %get /users+contributors {sd $~}) + :: + ++ acco-remo + (mold %post /account+remove-profile-banner $~) + :: + ++ user-prof + (mold %get /users+profile-banner {sd $~}) + :: + ++ mute-user-crea + (mold %post /mutes+users+create {sd $~}) + :: + ++ mute-user-dest + (mold %post /mutes+users+destroy {sd $~}) + :: + ++ mute-user-idss + (mold %get /mutes+users+ids $~) + :: + ++ mute-user-list + (mold %get /mutes+users+list $~) + :: + ++ user-sugg-slug + (mold %get /users+suggestions {sl $~}) + :: + ++ user-sugg + (mold %get /users+suggestions $~) + :: + ++ favo-list + (mold %get /favorites+list $~) + :: + ++ favo-dest + (mold %post /favorites+destroy {id $~}) + :: + ++ favo-crea + (mold %post /favorites+create {id $~}) + :: + ++ list-list + (mold %get /lists+list $~) + :: + ++ list-stat + (mold %get /lists+statuses $~) + :: + ++ list-memb-dest + (mold %post /lists+members+destroy $~) + :: + ++ list-memb-hips + (mold %get /lists+memberships {sd $~}) + :: + ++ list-subs-bers + (mold %get /lists+subscribers $~) + :: + ++ list-subs-crea + (mold %post /lists+subscribers+create $~) + :: + ++ list-subs-show + (mold %get /lists+subscribers+show {sd $~}) + :: + ++ list-subs-dest + (mold %post /lists+subscribers+destroy $~) + :: + ++ list-memb-crea-alll + (mold %post /lists+members+create-all {?(us ss) $~}) + :: + ++ list-memb-show + (mold %get /lists+members+show {sd $~}) + :: + ++ list-memb-bers + (mold %get /lists+members $~) + :: + ++ list-memb-crea + (mold %post /lists+members+create {sd $~}) + :: + ++ list-dest + (mold %post /lists+destroy $~) + :: + ++ list-upda + (mold %post /lists+update $~) + :: + ++ list-crea + (mold %post /lists+create {na $~}) + :: + ++ list-show + (mold %get /lists+show $~) + :: + ++ list-subs-ions + (mold %get /lists+subscriptions {sd $~}) + :: + ++ list-memb-dest-alll + (mold %post /lists+members+destroy-all {?(us ss) $~}) + :: + ++ list-owne + (mold %get /lists+ownerships {sd $~}) + :: + ++ save-list + (mold %get /saved-searches+list $~) + :: + ++ save-show-iddd + (mold %get /saved-searches+show {ii $~}) + :: + ++ save-crea + (mold %post /saved-searches+create {qq $~}) + :: + ++ save-dest-iddd + (mold %post /saved-searches+destroy {ii $~}) + :: + ++ geoo-iddd-plac + (mold %get /geo+id {ii $~}) + :: + ++ geoo-reve + (mold %get /geo+reverse-geocode {la lo $~}) + :: + ++ geoo-sear + (mold %get /geo+search $~) + :: + ++ geoo-simi + (mold %get /geo+similar-places {la lo na $~}) + :: + ++ tren-plac + (mold %get /trends+place {id $~}) + :: + ++ tren-avai + (mold %get /trends+available $~) + :: + ++ tren-clos + (mold %get /trends+closest {la lo $~}) + :: + ++ user-repo + (mold %post /users+report-spam {sd $~}) + :: + ++ oaut-auth-cate + (mold %get /oauth+authenticate $~) + :: + ++ oaut-auth-rize + (mold %get /oauth+authorize $~) + :: + ++ oaut-acce + (mold %post /oauth+access-token $~) + :: + ++ oaut-requ + (mold %post /oauth+request-token {oa $~}) + :: + ++ oaut-toke + (mold %post /oauth2/token {gr $~}) + :: + ++ oaut-inva + (mold %post /oauth2/invalidate-token {at $~}) + :: + ++ help-conf + (mold %get /help+configuration $~) + :: + ++ help-lang + (mold %get /help+languages $~) + :: + ++ help-priv + (mold %get /help+privacy $~) + :: + ++ help-toss + (mold %get /help+tos $~) + :: + ++ appl-rate + (mold %get /application+rate-limit-status $~) + :: + ++ stat-look + (mold %get /statuses+lookup {us $~}) + -- +-- diff --git a/sur/bit-api.hoon b/sur/bit-api.hoon new file mode 100644 index 000000000..0bd035dbb --- /dev/null +++ b/sur/bit-api.hoon @@ -0,0 +1,18 @@ +|% +++ bit-any + $% {$bit-get-token bit-get-token} + {$bit-api-call tok/@t bit-api-call} + == +++ bit-api-call + $% {$send bit-send} + {$txt-send to/@t btc/@t} + {$buy amount/@t currency/@t} + {$sell amount/@t currency/@t} + {$list $~} + == +++ bit-send {adr/@uc btc/@t} +++ bit-ship-send {who/@p btc/@t} +++ bit-get-token {oat/@t {cid/@t sec/@t} red/purl} +++ bit-accounts (list {id/@t name/@t balance/{num/@t cur/term}}) +-- + diff --git a/sur/down.hoon b/sur/down.hoon new file mode 100644 index 000000000..2e08b5380 --- /dev/null +++ b/sur/down.hoon @@ -0,0 +1,7 @@ +:: +:::: /hoon+gate+down+sur + :: +/? 314 +/- markdown +down.markdown + diff --git a/sur/foobar.hoon b/sur/foobar.hoon new file mode 100644 index 000000000..4d54e60dd --- /dev/null +++ b/sur/foobar.hoon @@ -0,0 +1 @@ +,@ diff --git a/sur/markdown.hoon b/sur/markdown.hoon new file mode 100644 index 000000000..f6952a66a --- /dev/null +++ b/sur/markdown.hoon @@ -0,0 +1,39 @@ +|% +++ down (list elem) +++ kids (list inline) +++ inline + =+ ^= inlik + $% {$emph p/?} :: strong? + {$delt $~} :: strikethrough + {$link p/tape q/(unit tape)} + {$blot p/tape q/(unit tape)} :: image + == + =+ ^= inlin + $% {$$ p/tape} + {$line $~} + {$code p/tape} + {$htmt p/cord} :: XX (each marx mane) + == + $^({p/inlik q/kids} inlin) +:: +:: +++ elem $^(tops node) +++ tops :: childful block + $: $= p + $% {$bloq $~} + {$list p/? q/$@(char {p/@u q/char})} :: tight ordered? + {$item $~} + == + q/down + == +++ node :: childless block + $% {$para p/kids} + {$meta p/(map cord cord)} :: front matter + {$hrul $~} + {$head p/@u q/kids} + {$code p/(unit {p/char q/@u r/tape}) q/wain} :: info contents + {$html p/wain} + {$defn $~} :: empty para + == +-- + diff --git a/sur/oct1.hoon b/sur/oct1.hoon new file mode 100644 index 000000000..69d89c852 --- /dev/null +++ b/sur/oct1.hoon @@ -0,0 +1,16 @@ +:: :: :: +:::: /hoon+oct1/sur :::::: dependencies + :: :: :: +/? 310 :: arvo version +:: :: :: +:::: :::::: semantics + :: :: :: +|% :: +++ board @ :: one-player bitfield +++ point {x/@ y/@} :: coordinate +++ game :: game state + $: who/? :: whose turn + box/board :: X board + boo/board :: O board + == :: +-- diff --git a/sur/oct2.hoon b/sur/oct2.hoon new file mode 100644 index 000000000..e077aa0fc --- /dev/null +++ b/sur/oct2.hoon @@ -0,0 +1,19 @@ +:: :: :: +:::: /hoon+oct2/sur :::::: dependencies + :: :: :: +/? 310 :: arvo version +:: :: :: +:::: :::::: semantics + :: :: :: +|% :: +++ board @ :: one-player bitfield +++ point {x/@ y/@} :: coordinate +++ stage (pair (unit ship) (unit ship)) :: players +++ game :: game state + $: who/? :: whose turn + sag/stage :: who's playing + aud/(map ship @ud) :: who's watching + box/board :: X board + boo/board :: O board + == :: +-- diff --git a/sur/oct3.hoon b/sur/oct3.hoon new file mode 100644 index 000000000..2b6634ba8 --- /dev/null +++ b/sur/oct3.hoon @@ -0,0 +1,20 @@ +:: :: :: +:::: /hoon+oct3/sur :::::: dependencies + :: :: :: +/? 310 :: arvo version +:: :: :: +:::: :::::: semantics + :: :: :: +|% :: +++ board @ :: one-player bitfield +++ point {x/@ y/@} :: coordinate +++ stage (pair (unit ship) (unit ship)) :: players +++ play (each game tape) :: update +++ game :: game state + $: who/? :: whose turn + sag/stage :: who's playing + aud/(map ship @ud) :: who's watching + box/board :: X board + boo/board :: O board + == :: +-- diff --git a/sur/oct4.hoon b/sur/oct4.hoon new file mode 100644 index 000000000..1007cb349 --- /dev/null +++ b/sur/oct4.hoon @@ -0,0 +1,20 @@ +:: :: :: +:::: /hoon+oct4/sur :::::: dependencies + :: :: :: +/? 310 :: +:: :: :: +:::: :::::: semantics + :: :: :: +|% :: +++ board @ :: one-player bitfield +++ point {x/@ y/@} :: coordinate +++ stage (pair (unit ship) (unit ship)) :: players +++ play (each game tape) :: update +++ game :: game state + $: who/? :: whose turn + sag/stage :: who's playing + aud/(map ship @ud) :: who's watching + box/board :: X board + boo/board :: O board + == :: +-- diff --git a/sur/term-ctrl.hoon b/sur/term-ctrl.hoon new file mode 100644 index 000000000..31b413aa2 --- /dev/null +++ b/sur/term-ctrl.hoon @@ -0,0 +1 @@ +,%hail diff --git a/sur/term-in.hoon b/sur/term-in.hoon new file mode 100644 index 000000000..d13ff357f --- /dev/null +++ b/sur/term-in.hoon @@ -0,0 +1,7 @@ +$: pax=path :: +$= jof :: +$% [%line p=cord] :: + [%res p=span] :: + [%cmd p=char] :: + [%type p=?] :: +== == :: diff --git a/sur/term-line.hoon b/sur/term-line.hoon new file mode 100644 index 000000000..5d433a4ce --- /dev/null +++ b/sur/term-line.hoon @@ -0,0 +1,4 @@ +$: p=[p=cord q=prom r=cord] + q=(list cord) + r=(list ?(tank [%stem p=@da q=tank r=tank])) +== diff --git a/sur/tree-include.hoon b/sur/tree-include.hoon new file mode 100644 index 000000000..027c3fee8 --- /dev/null +++ b/sur/tree-include.hoon @@ -0,0 +1,7 @@ +|- +$: body/json + head/json + snip/json + meta/json + sect/json +== diff --git a/sur/twitter.hoon b/sur/twitter.hoon new file mode 100644 index 000000000..98fb51175 --- /dev/null +++ b/sur/twitter.hoon @@ -0,0 +1,16 @@ +|% +++ twit-do => twit {p/span q/command} :: user and action +++ twit-stat {id/@u who/@ta now/@da txt/@t} :: received tweet +++ twit + |% + ++ keys :: twitter-key type + $: con/{tok/@t sec/@t} :: user key pair + acc/{tok/@t sec/@t} :: app key pair + == + :: + ++ command :: poke action + $% {$auth p/keys} :: set API keys + {$post p/@uvI q/cord} :: post a tweet + == + -- +-- diff --git a/sur/user.hoon b/sur/user.hoon new file mode 100644 index 000000000..ff1cbbed1 --- /dev/null +++ b/sur/user.hoon @@ -0,0 +1,3 @@ +$% {$in p/{p/@p q/@t}} + {$out p/{p/@p q/@t}} +== diff --git a/sur/users.hoon b/sur/users.hoon new file mode 100644 index 000000000..91b11bff3 --- /dev/null +++ b/sur/users.hoon @@ -0,0 +1 @@ +(list {p/@p q/@t}) diff --git a/sur/wand.hoon b/sur/wand.hoon new file mode 100644 index 000000000..80d8c9594 --- /dev/null +++ b/sur/wand.hoon @@ -0,0 +1,6 @@ +:: +:::: /hoon+gate+down+sur + :: +/? 314 +/- markdown +down diff --git a/sur/work.hoon b/sur/work.hoon new file mode 100644 index 000000000..92b811cc9 --- /dev/null +++ b/sur/work.hoon @@ -0,0 +1,58 @@ +:: +:::: /hoon+work+sur + :: + :: A block comment might go here! + :: +/- talk +|% +++ client + $: tasks/(map @uvH client-task) + sort/(list @uvH) + == +++ client-task + $: archived/_| + audience/(set station:talk) + tax/task + == +++ task + $: id/@uvH + date-created/@da + version/@u + date-modified/@da + creator/@p + doer/(unit @p) + tags/(set @t) + date-due/(unit @da) + done/(unit @da) + title/@t + description/@t :: XX (list @t) + discussion/(list comment) + == +++ comment + $: date/@da + ship/@p + body/@t :: XX (list @t) + == +++ command + $% {$new audience/(set station:talk) task} + {$old id/@uvH dif/update} + {$sort p/(list @uvH)} + == +++ update :: XX rename, web-edit? + $% $: $set + $% {$audience to/(set station:talk)} + {$date-due p/(unit @da)} + {$title p/@t} + {$description p/@t} + {$tags p/(set @t)} + {$done p/?} + == == + $: $add + $% {$comment @t} + == == + $: $doer + $% {$release $~} + {$claim $~} + == == + == +-- diff --git a/sur/zing.hoon b/sur/zing.hoon new file mode 100644 index 000000000..9484ab6e8 --- /dev/null +++ b/sur/zing.hoon @@ -0,0 +1,6 @@ +$: %mess p=path + $= q + $% [%do p=@t] + [%exp p=@t q=tank] + [%say p=@t] +== == diff --git a/sur/zong.hoon b/sur/zong.hoon new file mode 100644 index 000000000..fa07797d2 --- /dev/null +++ b/sur/zong.hoon @@ -0,0 +1,6 @@ +$% $: %mess p=@da q=ship + $= r + $% [%do p=@t] + [%exp p=@t q=tank] + [%say p=@t] +== == == diff --git a/sur/zung.hoon b/sur/zung.hoon new file mode 100644 index 000000000..22522b35b --- /dev/null +++ b/sur/zung.hoon @@ -0,0 +1,8 @@ +$% $: %mess p=path + $= q + $% [%do p=@t] + [%exp p=@t q=tank] + [%say p=@t] + == == + [%init p=ship q=path] +==