urbit/lib/write.hoon

142 lines
3.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-03-30 00:17:45 +03:00
!:
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
(poke-plan-diff [~ ~ [[sev usr] ~ ~]])
::
++ poke-plan-info
|= {who/@t loc/@t}
(poke-plan-diff [[~ who loc] ~ ~])
::
++ poke-plan-diff
|= dif/plan-diff ^+ abet
?. =(our src)
~|(foreign-write+[our=our src=src] !!)
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))
2016-03-31 03:27:18 +03:00
?~ [fil:.^(arch %cy paf)]
=+ ins=(pact-plan [['' ''] ~] dif)
2016-03-31 03:27:18 +03:00
[pax %ins plan+!>(ins)]~
=+ ole=.^({{@t @t} (map iden plan-acct)} %cx paf)
2016-03-31 03:27:18 +03:00
=+ neu=(pact-plan ole dif)
?: =(ole neu) ~
[pax %dif plan-diff+!>(dif)]~
2016-03-25 02:31:37 +03:00
::
2016-03-31 03:27:18 +03:00
++ pact-plan :: XX clay should handle fused insert+diff
|= {all/{{who/@t loc/@t} acc/(map iden plan-acct)} dif/plan-diff}
2016-03-31 03:27:18 +03:00
^+ all
:- (fall inf.dif -.all)
=; neu (~(uni by neu) put.dif)
=+ del=(~(tap by del.dif)) :: XXX map functions
|- ^+ acc.all
?~ del acc.all
$(del t.del, acc.all (~(del by acc.all) p.i.del))
::
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
|= {sup/spur him/ship txt/@t} ^+ abet
=+ pax=(welp (flop sup) /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))
::
++ poke-fora-post
|= {sup/spur him/ship hed/@t txt/@t} ^+ abet
=+ pax=(welp (flop sup) /posts/(cat 3 (scot %da now) '~'))
=. txt
%- crip
"""
---
type: post
date: {<now>}
title: {(trip hed)}
author: {<him>}
navsort: bump
navuptwo: true
2016-07-29 22:41:16 +03:00
comments: reverse
---
{(trip 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