shrub/pkg/arvo/lib/hood/write.hoon

125 lines
3.0 KiB
Plaintext
Raw Normal View History

2015-12-08 04:46:18 +03:00
:: File writer module
::
2017-11-29 23:40:44 +03:00
:::: /hoon/write/hood/lib
2015-12-08 04:46:18 +03:00
::
2016-02-18 02:36:43 +03:00
/? 310
2016-12-02 02:59:17 +03:00
=, format
2016-12-03 03:56:54 +03:00
=* as-octs as-octs:mimes:html
2016-12-02 02:59:17 +03:00
=, space:userlib
2015-12-08 04:46:18 +03:00
|%
2018-06-02 00:31:10 +03:00
+$ part {$write $0 pith} :: no state
+$ pith ~
2015-12-08 04:46:18 +03:00
--
::
::::
::
|%
++ data $%({$json json} {$mime mime})
2018-12-13 09:34:12 +03:00
++ card $% {$build wire ? schematic:ford}
2018-12-13 10:59:53 +03:00
{$info wire toro:clay}
2015-12-08 04:46:18 +03:00
==
--
2016-11-17 04:42:58 +03:00
::
2015-12-08 04:46:18 +03:00
::::
::
|= {bowl:gall 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-11-08 04:40:00 +03:00
|= sup/path ^+ abet :: XX determine extension, beak
2015-12-11 01:04:59 +03:00
=+ ext=%md
2016-12-02 02:59:17 +03:00
?~ (file (en-beam beak-now [ext sup]))
2016-02-12 02:29:52 +03:00
~|(not-found+[ext `path`(flop sup)] !!)
2018-12-13 10:59:53 +03:00
=- abet:(emit %info write+~ -)
2016-12-02 02:59:17 +03:00
(fray (en-beam beak-now [ext sup]))
2015-12-11 01:04:59 +03:00
::
2015-12-10 01:12:59 +03:00
++ poke-tree
|= {sup/path 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-paste
2016-02-01 09:16:26 +03:00
|= {typ/?($hoon $md $txt) txt/@t} ^+ abet
2016-12-03 03:56:54 +03:00
(poke--data [`typ /web/paste/(scot %da now)] %mime / (as-octs txt))
2015-12-08 04:46:18 +03:00
::
++ poke-comment
2016-11-08 04:40:00 +03:00
|= {sup/path him/ship txt/@t} ^+ abet
=+ pax=(welp (flop sup) /comments/(scot %da now))
=. txt
2016-03-04 03:36:39 +03:00
%+ rap 3 :~
'## `' (scot %p him) '`'
'\0a' txt
==
2016-12-03 03:56:54 +03:00
(poke--data [`%md pax] %mime / (as-octs txt))
::
++ poke-fora-post
2016-11-08 04:40:00 +03:00
|= {sup/path 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)}
"""
2016-12-03 03:56:54 +03:00
(poke--data [`%md pax] %mime / (as-octs txt))
::
++ ames-secret
^- @t
=- (crip +:<.^(@p %j pax)>)
pax=/(scot %p our)/code/(scot %da now)/(scot %p our)
::
2016-02-05 02:03:51 +03:00
++ poke-sec-atom
|= {hot/host:eyre dat/@}
2018-03-19 06:54:47 +03:00
?> ?=(%& -.hot)
=. p.hot (scag 2 p.hot) :: ignore subdomain
=. dat (scot %uw (en:crub:crypto ames-secret dat))
2016-12-03 03:56:54 +03:00
(poke--data [`%atom [%sec p.hot]] %mime / (as-octs dat))
2016-02-05 02:03:51 +03:00
::
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)
2018-08-09 21:22:37 +03:00
(made pax now [%complete %success %$ cay])
2015-12-08 04:46:18 +03:00
=< abet
2018-08-09 21:22:37 +03:00
%- emit :*
%build
write+pax
live=%.n :: XX defer %nice
^- schematic:ford :: SYNTAX ERROR AT START OF LINE?
=/ =beak beak-now
[%cast [p q]:beak u.ext [%$ cay]]
==
2015-12-08 04:46:18 +03:00
::
++ made
|= [pax=wire date=@da result=made-result:ford]
^+ abet
2018-08-09 21:22:37 +03:00
:: |= {pax/wire @ res/gage:ford} ^+ abet
:: ?. =(our src)
:: ~|(foreign-write/[our=our src=src] !!)
2018-08-09 21:22:37 +03:00
?: ?=(%incomplete -.result)
(mean tang.result)
::
=/ build-result build-result.result
::
?: ?=([%error *] build-result)
(mean message.build-result)
::
=/ =cage (result-to-cage:ford build-result)
::
2018-12-13 10:59:53 +03:00
=- abet:(emit %info write+~ -)
2018-08-09 21:22:37 +03:00
::
(foal :(welp (en-beam beak-now ~) pax /[-.cage]) cage)
2015-12-08 04:46:18 +03:00
--