diff --git a/app/blog.hoon b/app/blog.hoon index 6d83f26..5a73669 100644 --- a/app/blog.hoon +++ b/app/blog.hoon @@ -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 {} with 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 {} with 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 diff --git a/lib/mip.hoon b/lib/mip.hoon new file mode 120000 index 0000000..0ac9e55 --- /dev/null +++ b/lib/mip.hoon @@ -0,0 +1 @@ +../../base-dev/lib/mip.hoon \ No newline at end of file diff --git a/lib/sss.hoon b/lib/sss.hoon new file mode 120000 index 0000000..6eb67e5 --- /dev/null +++ b/lib/sss.hoon @@ -0,0 +1 @@ +../../base-dev/lib/sss.hoon \ No newline at end of file diff --git a/mar/blog/action.hoon b/mar/blog/action.hoon index 62d9ba0..8d329b1 100644 --- a/mar/blog/action.hoon +++ b/mar/blog/action.hoon @@ -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])] == -- :: diff --git a/mar/sss/blog-paths.hoon b/mar/sss/blog-paths.hoon new file mode 100644 index 0000000..db02bfe --- /dev/null +++ b/mar/sss/blog-paths.hoon @@ -0,0 +1,3 @@ +/- blog-paths +/+ *sss +(mk-mar blog-paths) diff --git a/mar/sss/to-pub.hoon b/mar/sss/to-pub.hoon new file mode 100644 index 0000000..2f57c3b --- /dev/null +++ b/mar/sss/to-pub.hoon @@ -0,0 +1,12 @@ +/- *sss +|_ =(request:poke) +++ grow + |% + ++ noun request + -- +++ grab + |% + ++ noun (request:poke) + -- +++ grad %noun +-- diff --git a/sur/blog-paths.hoon b/sur/blog-paths.hoon new file mode 100644 index 0000000..3fd3d10 --- /dev/null +++ b/sur/blog-paths.hoon @@ -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) + == +-- \ No newline at end of file diff --git a/sur/blog.hoon b/sur/blog.hoon index 0e9b0d4..f333a59 100644 --- a/sur/blog.hoon +++ b/sur/blog.hoon @@ -7,5 +7,7 @@ [%delete-draft =path] [%save-theme theme=@tas css=@t] [%delete-theme theme=@tas] + [%update-uri uri=@t] == ++$ sub [%sub =ship] -- \ No newline at end of file diff --git a/sur/sss.hoon b/sur/sss.hoon new file mode 120000 index 0000000..12024e1 --- /dev/null +++ b/sur/sss.hoon @@ -0,0 +1 @@ +../../base-dev/sur/sss.hoon \ No newline at end of file