mall: convert write to mall

This commit is contained in:
Philip Monk 2019-09-05 21:35:42 -07:00
parent 0f6bd70aa3
commit 7f5ac366c9
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
2 changed files with 146 additions and 8 deletions

View File

@ -12,7 +12,7 @@
:: they have been bundled into :hood
::
:: |command handlers
hood-helm-mall, hood-kiln-mall, hood-drum-mall, hood-write
hood-helm-mall, hood-kiln-mall, hood-drum-mall, hood-write-mall
:: :: ::
:::: :: ::
:: :: ::
@ -49,7 +49,7 @@
$drum ?>(?=($drum -.paw) `part:hood-drum-mall`paw)
$helm ?>(?=($helm -.paw) `part:hood-helm-mall`paw)
$kiln ?>(?=($kiln -.paw) `part:hood-kiln-mall`paw)
$write ?>(?=($write -.paw) `part:hood-write`paw)
$write ?>(?=($write -.paw) `part:hood-write-mall`paw)
==
--
++ hood-head _-:$:hood-part :: initialize state
@ -60,7 +60,7 @@
$drum (make:hood-drum-mall our)
$helm *part:hood-helm-mall
$kiln *part:hood-kiln-mall
$write *part:hood-write
$write *part:hood-write-mall
==
--
++ hood-part-old hood-part :: old state for ++prep
@ -72,7 +72,7 @@
$% {$drum $2 pith-2:hood-drum-mall} ::
{$helm $0 pith:hood-helm-mall} ::
{$kiln $0 pith:hood-kiln-mall} ::
{$write $0 pith:hood-write} ::
{$write $0 pith:hood-write-mall} ::
== ::
-- ::
:: :: ::
@ -124,7 +124,7 @@
++ from-drum (from-module %drum [..$ _se-abet]:(hood-drum-mall))
++ from-helm (from-module %helm [..$ _abet]:(hood-helm-mall))
++ from-kiln (from-module %kiln [..$ _abet]:(hood-kiln-mall))
++ from-write (from-module %write [..$ _abet]:(hood-write))
++ from-write (from-module %write [..$ _abet]:(hood-write-mall))
--
|_ hid/bowl:mall :: gall environment
++ handle-init
@ -237,6 +237,14 @@
(need !<([desk ship desk] vase))
%kiln-permission %- (wrap poke-permission):from-kiln:h
(need !<([desk path ?] vase))
%write-sec-atom %- (wrap poke-sec-atom):from-write:h
(need !<([host:eyre @] vase))
%write-paste %- (wrap poke-paste):from-write:h
(need !<([?(%hoon %md %txt) @t] vase))
%write-tree %- (wrap poke-tree):from-write:h
(need !<([path mime] vase))
%write-wipe %- (wrap poke-wipe):from-write:h
(need !<(path vase))
==
[moves ..handle-init]
::
@ -290,9 +298,10 @@
=/ h (help hid)
=^ moves lac
?+ wire ~|([%hood-bad-wire wire] !!)
[%helm *] ((wrap take):from-helm:h t.wire vase)
[%drum *] ((wrap take):from-drum:h t.wire vase)
[%kiln *] ((wrap take-general):from-kiln:h t.wire vase)
[%helm *] ((wrap take):from-helm:h t.wire vase)
[%drum *] ((wrap take):from-drum:h t.wire vase)
[%kiln *] ((wrap take-general):from-kiln:h t.wire vase)
[%write *] ((wrap take):from-write:h t.wire vase)
==
[moves ..handle-init]
::

View File

@ -0,0 +1,129 @@
:: File writer module
::
:::: /hoon/write/hood/lib
::
/? 310
=, format
=* as-octs as-octs:mimes:html
=, space:userlib
|%
+$ part {$write $0 pith} :: no state
+$ pith ~
--
::
::::
::
|%
++ data $%({$json json} {$mime mime})
--
::
::::
::
|= {bowl:gall part}
=* par +<+
|_ moz/(list move:agent:mall)
++ abet [(flop moz) `part`par]
++ emit
|= a/(wind internal-note:mall internal-gift:mall)
%_(+> moz :_(moz [ost a]))
::
++ beak-now byk(r [%da now])
++ poke-wipe
|= sup/path ^+ abet :: XX determine extension, beak
=+ ext=%md
?~ (file (en-beam beak-now [ext sup]))
~|(not-found+[ext `path`(flop sup)] !!)
=- abet:(emit %pass /write %meta %c !>([%info -]))
(fray (en-beam beak-now [ext sup]))
::
++ poke-tree
|= {sup/path mim/mime} ^+ abet :: XX determine extension, beak
(poke--data [`%md (flop sup)] %mime mim)
::
++ poke-paste
|= {typ/?($hoon $md $txt) txt/@t} ^+ abet
(poke--data [`typ /web/paste/(scot %da now)] %mime / (as-octs txt))
::
++ poke-comment
|= {sup/path him/ship txt/@t} ^+ abet
=+ pax=(welp (flop sup) /comments/(scot %da now))
=. txt
%+ rap 3 :~
'## `' (scot %p him) '`'
'\0a' txt
==
(poke--data [`%md pax] %mime / (as-octs txt))
::
++ poke-fora-post
|= {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
comments: reverse
---
{(trip txt)}
"""
(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)
::
++ poke-sec-atom
|= {hot/host:eyre dat/@}
?> ?=(%& -.hot)
=. p.hot (scag 2 p.hot) :: ignore subdomain
=. dat (scot %uw (en:crub:crypto ames-secret dat))
(poke--data [`%atom [%sec p.hot]] %mime / (as-octs dat))
::
++ poke--data
|= {{ext/(unit @t) pax/path} dat/data} ^+ abet
?~ ext $(ext [~ -.dat])
=+ cay=?-(-.dat $json [-.dat !>(+.dat)], $mime [-.dat !>(+.dat)])
?: =(u.ext -.dat)
(made pax now [%complete %success %$ cay])
=< abet
%- emit :*
%pass write+pax %meta %f !>
:* %build
live=%.n :: XX defer %nice
^- schematic:ford :: SYNTAX ERROR AT START OF LINE?
=/ =beak beak-now
[%cast [p q]:beak u.ext [%$ cay]]
== ==
::
++ made
|= [pax=wire date=@da result=made-result:ford]
^+ abet
:: |= {pax/wire @ res/gage:ford} ^+ abet
:: ?. =(our src)
:: ~|(foreign-write/[our=our src=src] !!)
?: ?=(%incomplete -.result)
(mean tang.result)
::
=/ build-result build-result.result
::
?: ?=([%error *] build-result)
(mean message.build-result)
::
=/ =cage (result-to-cage:ford build-result)
::
=- abet:(emit %pass /write %meta %c !>([%info -]))
::
(foal :(welp (en-beam beak-now ~) pax /[-.cage]) cage)
::
++ take ::
|= [=wire =vase]
%+ made wire
+:(need !<([%made @da made-result:ford] vase))
--