Merge pull request #3 from tadad/drafts

Drafts
This commit is contained in:
tadad 2023-02-16 17:56:52 -06:00 committed by GitHub
commit dde929fb05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 21 deletions

View File

@ -4,12 +4,17 @@
%- agent:dbug
^- agent:gall
=> |%
+$ versioned-state $%(state-0)
+$ state-0
$: files=(map path (pair html=@t md=@t))
+$ versioned-state
$% state-1
==
+$ state-0 (map path (pair html=@t md=@t))
+$ state-1
$: %1
files=(map path (pair html=@t md=@t))
drafts=(map path md=@t)
==
--
=| state-0
=| state-1
=* state -
|_ bowl=bowl:gall
+* this .
@ -18,21 +23,36 @@
++ on-init on-init:def
++ on-save !>(state)
++ on-load
|= =vase
=+ !<(old=state-0 vase)
`this(state old)
|= =vase
^- (quip card _this)
:: this is super messed up because state-0 wasn't tagged with %0
:: for later updates need to add %2, %3, etc. on -.q.vase
?. &(?=(^ q.vase) =(-.q.vase %1))
=+ !<(old=state-0 vase)
`this(state [%1 old ~])
=+ !<(old=versioned-state vase)
?- -.old
%1 `this(state old)
==
::
++ on-poke
|= [=mark =vase]
?> =(%blog-action mark)
=+ !<(act=action:blog vase)
?- -.act
%save-file
%publish
:_ this(files (~(put by files) [path html md]:act))
[%pass /bind %arvo %e %serve `path.act dap.bowl /gen/blog/hoon ~]~
::
%delete-file
%unpublish
:_ this(files (~(del by files) path.act))
[%pass /bind %arvo %e %disconnect `path.act]~
::
%save-draft
`this(drafts (~(put by drafts) [path md]:act))
::
%delete-draft
`this(drafts (~(del by drafts) path.act))
==
++ on-agent on-agent:def
++ on-watch on-watch:def
@ -41,17 +61,20 @@
^- (unit (unit cage))
?+ path ~
::
[%x %md ^] ``blog+!>(q:(~(got by files) t.t.path))
[%x %html ^] ``blog+!>(p:(~(got by files) t.t.path))
[%x %md ^] ``blog+!>(q:(~(got by files) t.t.path))
[%x %html ^] ``blog+!>(p:(~(got by files) t.t.path))
[%x %draft ^] ``blog+!>((~(got by drafts) t.t.path))
::
[%x %pages ~]
:^ ~ ~ %json
!> :- %a
%+ turn ~(tap by files)
|=([=^path *] `json`(path:enjs:format path))
=; pages ``json+!>([%a pages])
(turn ~(tap by files) |=([=^path *] (path:enjs:format path)))
::
[%x %drafts ~]
=; names ``json+!>([%a names])
(turn ~(tap by drafts) |=([=^path *] (path:enjs:format path)))
::
[%x %all-bindings ~]
:^ ~ ~ %json !>
=; the-thing ``json+!>(the-thing)
%- pairs:enjs:format
%+ turn
.^ (list [binding:eyre * action:eyre]) %e
@ -67,7 +90,7 @@
%logout [%s '%logout']
%channel [%s '%channel']
%scry [%s '%scry']
%name [%s '%name']
:: %name [%s '%name'] :: TODO next release
%four-oh-four [%s '%four-oh-four']
==
==

View File

@ -9,6 +9,8 @@
--
++ grow
|%
:: TODO you actually do want separate html and md marks
:: because md is /text/plain while html is text/html
++ mime [/text/plain (as-octs:mimes:html txt)]
++ json [%s txt]
--

View File

@ -7,8 +7,10 @@
++ json
=, dejs:format
%- of
:~ [%save-file (ot ~[path+pa html+so md+so])]
[%delete-file (ot ~[path+pa])]
:~ [%publish (ot ~[path+pa html+so md+so])]
[%unpublish (ot ~[path+pa])]
[%save-draft (ot ~[path+pa md+so])]
[%delete-draft (ot ~[path+pa])]
==
--
::

1
mar/json.hoon Symbolic link
View File

@ -0,0 +1 @@
../../arvo/mar/json.hoon

View File

@ -1,6 +1,8 @@
|%
+$ action
$% [%save-file =path html=@t md=@t] :: TODO needs to be text and md
[%delete-file =path]
$% [%publish =path html=@t md=@t] :: TODO needs to be text and md
[%unpublish =path]
[%save-draft =path md=@t]
[%delete-draft =path]
==
--