Merge pull request #9 from morelazers/feat/sss

added solid state subscriptions for integration with portal
This commit is contained in:
tadad 2023-06-16 10:07:48 -05:00 committed by GitHub
commit 706827e3ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 157 additions and 73 deletions

View File

@ -1,5 +1,5 @@
/- blog
/+ blog-lib=blog, dbug, default-agent
/- blog, blog-paths
/+ blog-lib=blog, dbug, default-agent, *sss
::
%- agent:dbug
^- agent:gall
@ -7,6 +7,7 @@
+$ versioned-state
$% state-1
state-2
state-3
==
+$ state-1
$: %1
@ -19,13 +20,22 @@
drafts=(map path md=@t)
themes=(map @tas css=@t)
==
+$ state-3
$: %3
files=(map path [html=@t md=@t theme=@tas])
drafts=(map path md=@t)
themes=(map @tas css=@t)
pub-paths=_(mk-pubs blog-paths ,[%paths ~])
==
+$ card $+(card card:agent:gall)
--
=| state-2
=| state-3
=* state -
|_ =bowl:gall
+* this .
def ~(. (default-agent this %.n) bowl)
+* this .
def ~(. (default-agent this %.n) bowl)
du-paths =/ du (du blog-paths ,[%paths ~])
(du pub-paths bowl -:!>(*result:du))
++ on-init
^- (quip card _this)
`this(themes (~(gas by themes) [%default default-theme:blog-lib]~))
@ -44,16 +54,39 @@
==
%= this
state
:^ %2
:* %3
(~(urn by files.old) |=([=path html=@t md=@t] [html md %none]))
drafts.old
(~(gas by *(map @tas @t)) [%default default-theme:blog-lib]~)
drafts.old
(~(gas by *(map @tas @t)) [%default default-theme:blog-lib]~)
pub-paths
==
==
::
%2
=. state [%3 files.old drafts.old themes.old pub-paths]
=^ cards pub-paths (give:du-paths [%paths ~] [%init ~(key by files)])
:_ this
%+ welp cards
%- zing %+ turn ~(tap by files.old)
|= [=path html=@t md=@t theme=@tas]
:~ [%pass /bind %arvo %e %disconnect `path]
:* %pass /bind %arvo %e
%set-response (spat path)
~ %.n %payload
[200 ['Content-Type' 'text/html; charset=utf-8']~]
=/ tem=@t (~(gut by themes.old) theme '')
`(as-octs:mimes:^html (cat 3 html (add-style:blog-lib tem)))
==
:* %pass /bind %arvo %e
%set-response (cat 3 (spat path) '.md')
~ %.n %payload
[200 ['Content-Type' 'text/plain; charset=utf-8']~]
`(as-octs:mimes:^html md)
== ==
::
%3
:_ this(state old)
%- zing
%+ turn ~(tap by files.old)
%- zing %+ turn ~(tap by files.old)
|= [=path html=@t md=@t theme=@tas]
:~ [%pass /bind %arvo %e %disconnect `path]
:* %pass /bind %arvo %e
@ -74,67 +107,83 @@
++ on-poke
|= [=mark =vase]
^- (quip card _this)
~| "unexpected poke to {<dap.bowl>} with mark {<mark>}"
?> =(%blog-action mark)
=+ !<(act=action:blog vase)
?> =(src.bowl our.bowl)
?- -.act
%publish
:_ this(files (~(put by files) [path html md theme]:act))
:~ :* %pass /bind %arvo %e
%set-response (cat 3 (spat path.act) '.md')
~ %.n %payload
[200 ['Content-Type' 'text/plain; charset=utf-8']~]
`(as-octs:mimes:html md.act)
==
?+ mark
~|("unexpected poke to {<dap.bowl>} with mark {<mark>}" !!)
::
:* %pass /bind %arvo %e
%set-response (spat path.act)
~ %.n %payload
[200 ['Content-Type' 'text/html; charset=utf-8']~]
=/ tem=@t (~(gut by themes) theme.act '')
`(as-octs:mimes:html (cat 3 html.act (add-style:blog-lib tem)))
== ==
::
%unpublish
:_ this(files (~(del by files) path.act))
:~ [%pass /bind %arvo %e %set-response `@t`(cat 3 (spat path.act) '.md') ~]
[%pass /bind %arvo %e %set-response (spat path.act) ~]
==
::
%export
=/ soba-html=soba:clay
%- zing
%+ turn ~(tap by files)
|= [=path html=@t md=@t theme=@tas]
^- soba:clay
=/ tem (~(gut by themes) theme '')
:~ :- [%export %published %html (snoc path %html)]
[%ins %html !>((cat 3 html (add-style:blog-lib tem)))]
%blog-action
=+ !<(act=action:blog vase)
?> =(src.bowl our.bowl)
?- -.act
%publish
=^ cards pub-paths (give:du-paths [%paths ~] [%post path.act])
:_ this(files (~(put by files) [path html md theme]:act))
%+ welp cards
:~ :* %pass /bind %arvo %e
%set-response (cat 3 (spat path.act) '.md')
~ %.n %payload
[200 ['Content-Type' 'text/plain; charset=utf-8']~]
`(as-octs:mimes:html md.act)
==
::
:- [%export %published %md (snoc path %md)]
[%ins %md !>([md ~])]
:* %pass /bind %arvo %e
%set-response (spat path.act)
~ %.n %payload
[200 ['Content-Type' 'text/html; charset=utf-8']~]
=/ tem=@t (~(gut by themes) theme.act '')
`(as-octs:mimes:html (cat 3 html.act (add-style:blog-lib tem)))
== ==
::
%unpublish
=^ cards pub-paths (give:du-paths [%paths ~] [%depost path.act])
:_ this(files (~(del by files) path.act))
%+ welp cards
:~ [%pass /bind %arvo %e %set-response `@t`(cat 3 (spat path.act) '.md') ~]
[%pass /bind %arvo %e %set-response (spat path.act) ~]
==
=/ soba-md=soba:clay
%+ turn ~(tap by drafts)
|= [=path md=@t]
^- (pair ^path miso:clay)
[[%export %drafts (snoc path %md)] %ins %md !>([md ~])]
=/ soba-css=soba:clay
%+ turn ~(tap by themes)
|= [theme=@tas css=@t]
^- (pair path miso:clay)
[[%export %themes theme %css ~] %ins %css !>(css)]
:_ this
:~ [%pass /info %arvo %c %info %blog %& soba-html]
[%pass /info %arvo %c %info %blog %& soba-md]
[%pass /info %arvo %c %info %blog %& soba-css]
::
%export
=/ soba-html=soba:clay
%- zing
%+ turn ~(tap by files)
|= [=path html=@t md=@t theme=@tas]
^- soba:clay
=/ tem (~(gut by themes) theme '')
:~ :- [%export %published %html (snoc path %html)]
[%ins %html !>((cat 3 html (add-style:blog-lib tem)))]
::
:- [%export %published %md (snoc path %md)]
[%ins %md !>([md ~])]
==
=/ soba-md=soba:clay
%+ turn ~(tap by drafts)
|= [=path md=@t]
^- (pair ^path miso:clay)
[[%export %drafts (snoc path %md)] %ins %md !>([md ~])]
=/ soba-css=soba:clay
%+ turn ~(tap by themes)
|= [theme=@tas css=@t]
^- (pair path miso:clay)
[[%export %themes theme %css ~] %ins %css !>(css)]
:_ this
:~ [%pass /info %arvo %c %info %blog %& soba-html]
[%pass /info %arvo %c %info %blog %& soba-md]
[%pass /info %arvo %c %info %blog %& soba-css]
==
::
%save-draft `this(drafts (~(put by drafts) [path md]:act))
%delete-draft `this(drafts (~(del by drafts) path.act))
%save-theme `this(themes (~(put by themes) [theme css]:act))
%delete-theme `this(themes (~(del by themes) theme.act))
::
%update-uri
=^ cards pub-paths (give:du-paths [%paths ~] [%uri uri.act])
[cards this]
==
::
%save-draft `this(drafts (~(put by drafts) [path md]:act))
%delete-draft `this(drafts (~(del by drafts) path.act))
%save-theme `this(themes (~(put by themes) [theme css]:act))
%delete-theme `this(themes (~(del by themes) theme.act))
::
%sss-to-pub
=/ msg !<(into:du-paths (fled vase))
=^ cards pub-paths (apply:du-paths msg)
[cards this]
==
::
++ on-peek
@ -146,6 +195,7 @@
[%x %html ^] ``blog+!>(-:(~(got by files) t.t.path))
[%x %draft ^] ``blog+!>((~(got by drafts) t.t.path))
[%x %theme @ ~] ``blog+!>((~(got by themes) i.t.t.path))
[%x %uri ~] ``blog+!>(uri:rock:(~(got by read:du-paths) [%paths ~]))
::
[%x %pages ~]
=; pages ``json+!>([%a pages])
@ -188,12 +238,7 @@
==
==
::
++ on-arvo
|= [=wire =sign-arvo]
^- (quip card _this)
?+ wire (on-arvo:def wire sign-arvo)
[%bind ~] ?>(?=([%eyre %bound %.y *] sign-arvo) `this)
==
++ on-arvo on-arvo:def
++ on-agent on-agent:def
++ on-watch on-watch:def
++ on-leave on-leave:def

1
lib/mip.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/mip.hoon

1
lib/sss.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/lib/sss.hoon

View File

@ -13,6 +13,7 @@
[%delete-draft (ot ~[path+pa])]
[%save-theme (ot ~[theme+so css+so])]
[%delete-theme (ot ~[theme+so])]
[%update-uri (ot ~[uri+so])]
==
--
::

3
mar/sss/blog-paths.hoon Normal file
View File

@ -0,0 +1,3 @@
/- blog-paths
/+ *sss
(mk-mar blog-paths)

12
mar/sss/to-pub.hoon Normal file
View File

@ -0,0 +1,12 @@
/- *sss
|_ =(request:poke)
++ grow
|%
++ noun request
--
++ grab
|%
++ noun (request:poke)
--
++ grad %noun
--

18
sur/blog-paths.hoon Normal file
View File

@ -0,0 +1,18 @@
|%
++ name %blog-paths
+$ rock [uri=@t paths=(set path)]
+$ wave
$% [%init paths=(set path)]
[%post =path]
[%depost =path]
[%uri uri=@t]
==
++ wash
|= [=rock =wave]
?- -.wave
%init rock(paths paths.wave)
%post rock(paths (~(put in paths.rock) path.wave))
%depost rock(paths (~(del in paths.rock) path.wave))
%uri rock(uri uri.wave)
==
--

View File

@ -7,5 +7,7 @@
[%delete-draft =path]
[%save-theme theme=@tas css=@t]
[%delete-theme theme=@tas]
[%update-uri uri=@t]
==
+$ sub [%sub =ship]
--

1
sur/sss.hoon Symbolic link
View File

@ -0,0 +1 @@
../../base-dev/sur/sss.hoon