urbit/lib/write.hoon

102 lines
2.6 KiB
Plaintext
Raw Normal View History

2015-12-08 04:46:18 +03:00
:: File writer module
::
:::: /hoon/write/lib
::
2016-02-18 02:36:43 +03:00
/? 310
/- plan-diff, plan-acct
2015-12-08 04:46:18 +03:00
|%
2016-02-01 09:16:26 +03:00
++ part {$write $0 pith} :: no state
++ pith $~
2015-12-08 04:46:18 +03:00
--
::
::::
::
|%
2016-02-01 09:16:26 +03:00
++ data $%({$json json} {$mime mime})
++ card $% {$exec wire @p $~ {beak silk}}
{$info wire @p toro}
2015-12-08 04:46:18 +03:00
==
--
::
::::
::
2016-02-12 02:29:52 +03:00
|= {bowl part}
2015-12-08 04:46:18 +03:00
=* par +<+
2016-02-01 09:16:26 +03:00
|_ moz/(list {bone card})
2015-12-08 04:46:18 +03:00
++ abet [(flop moz) `part`par]
2016-02-01 09:16:26 +03:00
++ emit |=(a/card %_(+> moz :_(moz [ost a])))
2015-12-08 04:46:18 +03:00
++ beak-now byk(r [%da now])
2015-12-11 01:04:59 +03:00
++ poke-wipe
2016-02-12 02:29:52 +03:00
|= sup/spur ^+ abet :: XX determine extension, beak
2015-12-11 01:04:59 +03:00
=+ ext=%md
?~ (file (tope beak-now [ext sup]))
2016-02-12 02:29:52 +03:00
~|(not-found+[ext `path`(flop sup)] !!)
=- abet:(emit %info write+~ our -)
2015-12-11 01:04:59 +03:00
(fray (tope beak-now [ext sup]))
::
2015-12-10 01:12:59 +03:00
++ poke-tree
|= {sup/spur mim/mime} ^+ abet :: XX determine extension, beak
2015-12-11 01:04:59 +03:00
(poke--data [`%md (flop sup)] %mime mim)
2015-12-08 04:46:18 +03:00
::
++ poke-plan-account
|= {sev/knot usr/plan-acct} ^+ abet
2016-03-25 03:15:12 +03:00
=; sob/soba
?~(sob abet abet:(emit %info write+~ our `toro`[q.byk %& sob]))
=+ pax=`path`/web/plan
=+ paf=(tope beak-now (flop pax))
=+ new=`(map knot plan-acct)`[[sev usr] ~ ~]
2016-03-25 03:15:12 +03:00
?~ [fil:.^(arch %cy paf)]
[pax %ins plan+!>([['' /] new])]~
=+ ole=.^({^ acc/(map knot plan-acct)} %cx paf)
?: =([~ usr] (~(get by acc.ole) sev))
2016-03-25 03:15:12 +03:00
~
[pax %dif plan-diff+!>(`plan-diff`[~ ~ new])]~
2016-03-25 02:31:37 +03:00
::
2015-12-08 04:46:18 +03:00
++ poke-paste
2016-02-01 09:16:26 +03:00
|= {typ/?($hoon $md $txt) txt/@t} ^+ abet
2016-02-12 02:29:52 +03:00
(poke--data [`typ /web/paste/(scot %da now)] %mime / (taco txt))
2015-12-08 04:46:18 +03:00
::
++ poke-comment
|= {pax/path him/ship txt/@t} ^+ abet
=. pax [%web (welp pax /comments/(scot %da now))]
2016-03-04 03:36:39 +03:00
=. txt
%+ rap 3 :~
'## `' (scot %p him) '`'
'\0a' txt
==
(poke--data [`%md pax] %mime / (taco txt))
::
++ ames-secret
^- @t
=- (crip +:<.^(@p %a pax)>)
pax=/(scot %p our)/code/(scot %da now)/(scot %p our)
::
2016-02-05 02:03:51 +03:00
++ poke-sec-atom
2016-02-19 23:33:56 +03:00
|= {hot/host dat/@}
?> ?=($& -.hot)
=. p.hot (scag 2 p.hot) :: ignore subdomain
=. dat (scot %uw (en:crua ames-secret dat)) :: XX clay permissions
2016-02-05 02:03:51 +03:00
(poke--data [`%atom [%sec p.hot]] %mime / (taco dat))
::
2015-12-08 04:46:18 +03:00
++ poke--data
2016-02-01 09:16:26 +03:00
|= {{ext/(unit @t) pax/path} dat/data} ^+ abet
2015-12-08 04:46:18 +03:00
?~ ext $(ext [~ -.dat])
2016-02-01 09:16:26 +03:00
=+ cay=?-(-.dat $json [-.dat !>(+.dat)], $mime [-.dat !>(+.dat)])
?: =(u.ext -.dat)
2016-02-12 02:29:52 +03:00
(made pax ~ &+cay)
2015-12-08 04:46:18 +03:00
=< abet
2016-02-01 09:16:26 +03:00
%^ emit %exec write+pax :: XX defer %nice
2016-02-12 02:29:52 +03:00
[our ~ beak-now %cast u.ext $+cay]
2015-12-08 04:46:18 +03:00
::
++ made
2016-02-01 09:16:26 +03:00
|= {pax/wire @ res/gage} ^+ abet
:: ?. =(our src)
:: ~|(foreign-write/[our=our src=src] !!)
2016-02-12 02:29:52 +03:00
?+ -.res ~|(gage+-.res !!)
2016-02-01 09:16:26 +03:00
$| (mean p.res)
$& =- abet:(emit %info write+~ our -)
2015-12-08 04:46:18 +03:00
(foal :(welp (tope beak-now ~) pax /[-.p.res]) p.res)
==
--
2016-02-12 02:29:52 +03:00