From 0ac5d47e53f7a976ddba2c3aa5eeb683c8480eec Mon Sep 17 00:00:00 2001 From: dachus Date: Thu, 11 May 2023 11:14:21 -0400 Subject: [PATCH 1/3] 413 upgrade --- app/blog.hoon | 74 ++++++++++++++++++++++++++----------------------- mar/kelvin.hoon | 1 + sys.kelvin | 2 -- 3 files changed, 41 insertions(+), 36 deletions(-) create mode 120000 mar/kelvin.hoon diff --git a/app/blog.hoon b/app/blog.hoon index 35f5710..6875c4e 100644 --- a/app/blog.hoon +++ b/app/blog.hoon @@ -19,13 +19,13 @@ drafts=(map path md=@t) themes=(map @tas css=@t) == + +$ card $+(card card:agent:gall) -- =| state-2 =* state - |_ =bowl:gall +* this . def ~(. (default-agent this %.n) bowl) - card card:agent:gall ++ on-init ^- (quip card _this) `this(themes (~(gas by themes) [%default default-theme:blog-lib]~)) @@ -50,44 +50,35 @@ (~(gas by *(map @tas @t)) [%default default-theme:blog-lib]~) == :: - %2 `this(state old) + %2 + :_ this(state old) + %- 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) + == == == :: ++ on-poke |= [=mark =vase] |^ ?+ mark (on-poke:def mark vase) - %handle-http-request - (handle-http-request bowl !<([@tas inbound-request:eyre] vase)) - :: %blog-action (handle-action bowl !<(act=action:blog vase)) == :: - ++ handle-http-request - |= [=bowl:gall rid=@tas req=inbound-request:eyre] - ^- (quip card _this) - =/ url-len (met 3 url.request.req) - ?: =('.md' (cut 3 [(sub url-len 3) 3] url.request.req)) :: get MARKDOWN - =/ file (rash (end [3 (sub url-len 3)] url.request.req) stap) - :_ this - %^ http-response-cards:blog-lib - rid - [200 ['Content-Type' 'text/plain; charset=utf-8']~] - `(as-octs:mimes:html md:(~(got by files) file)) - :: - =? url.request.req =('.html' (cut 3 [(sub url-len 5) 5] url.request.req)) - (end [3 (sub url-len 5)] url.request.req) - =/ file (~(got by files) (rash url.request.req stap)) - =/ theme ?~(got=(~(get by themes) theme.file) '' u.got) - =/ post-with-style - (cat 3 html:file (add-style:blog-lib theme)) - :_ this - %^ http-response-cards:blog-lib - rid - [200 ['Content-Type' 'text/html; charset=utf-8']~] - `(as-octs:mimes:html post-with-style) - :: ++ handle-action |= [=bowl:gall act=action:blog] ^- (quip card _this) @@ -95,11 +86,26 @@ ?- -.act %publish :_ this(files (~(put by files) [path html md theme]:act)) - [%pass /bind %arvo %e %connect `path.act dap.bowl]~ + :~ :* %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) + == + + :* %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 %disconnect `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 @@ -181,15 +187,15 @@ |= [=binding:eyre * =action:eyre] ^- [@t json] :- (spat path.binding) - ?+ -.action [%s 'unknown'] + ?- -.action %gen [%s (crip "desk: {}")] %app [%s (crip "app: {}")] %authentication [%s '%authentication'] %logout [%s '%logout'] %channel [%s '%channel'] %scry [%s '%scry'] - :: %name [%s '%name'] :: TODO next release - :: %four-oh-four [%s '%four-oh-four'] + %name [%s '%name'] + %four-oh-four [%s '%four-oh-four'] == == :: diff --git a/mar/kelvin.hoon b/mar/kelvin.hoon new file mode 120000 index 0000000..195ebe0 --- /dev/null +++ b/mar/kelvin.hoon @@ -0,0 +1 @@ +../../base-dev/mar/kelvin.hoon \ No newline at end of file diff --git a/sys.kelvin b/sys.kelvin index 290bb35..3fbd858 100644 --- a/sys.kelvin +++ b/sys.kelvin @@ -1,3 +1 @@ -[%zuse 415] -[%zuse 414] [%zuse 413] \ No newline at end of file From 43b4c1bc8fa2a92c4999416ca6eba7c019d72bfc Mon Sep 17 00:00:00 2001 From: dachus Date: Tue, 16 May 2023 14:42:55 -0300 Subject: [PATCH 2/3] working --- app/blog.hoon | 130 ++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 68 deletions(-) diff --git a/app/blog.hoon b/app/blog.hoon index 6875c4e..d2a07ea 100644 --- a/app/blog.hoon +++ b/app/blog.hoon @@ -73,76 +73,70 @@ :: ++ on-poke |= [=mark =vase] - |^ - ?+ mark (on-poke:def mark vase) - %blog-action - (handle-action bowl !<(act=action:blog vase)) - == - :: - ++ handle-action - |= [=bowl:gall act=action:blog] - ^- (quip card _this) - ?> =(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) - == - - :* %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 - =/ t ?~(got=(~(get by themes) theme) '' u.got) - :~ :^ [%export %published %html (snoc path %html)] - %ins %html - !>((cat 3 html (add-style:blog-lib t))) - :^ [%export %published %md (snoc path %md)] - %ins %md - !>([md ~]) + ^- (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) == - =/ 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 (snoc [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)) + + :* %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 + =/ t ?~(got=(~(get by themes) theme) '' u.got) + :~ :^ [%export %published %html (snoc path %html)] + %ins %html + !>((cat 3 html (add-style:blog-lib t))) + :^ [%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 (snoc [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)) + == :: ++ on-agent on-agent:def ++ on-watch From d8c865447f5b41d43ed1521246402da5316720fb Mon Sep 17 00:00:00 2001 From: dachus Date: Tue, 16 May 2023 14:48:15 -0300 Subject: [PATCH 3/3] style changes to export --- app/blog.hoon | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/blog.hoon b/app/blog.hoon index d2a07ea..a5e8989 100644 --- a/app/blog.hoon +++ b/app/blog.hoon @@ -108,13 +108,12 @@ %+ turn ~(tap by files) |= [=path html=@t md=@t theme=@tas] ^- soba:clay - =/ t ?~(got=(~(get by themes) theme) '' u.got) - :~ :^ [%export %published %html (snoc path %html)] - %ins %html - !>((cat 3 html (add-style:blog-lib t))) - :^ [%export %published %md (snoc path %md)] - %ins %md - !>([md ~]) + =/ 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) @@ -125,7 +124,7 @@ %+ turn ~(tap by themes) |= [theme=@tas css=@t] ^- (pair path miso:clay) - [[%export %themes (snoc [theme]~ %css)] %ins %css !>(css)] + [[%export %themes theme %css ~] %ins %css !>(css)] :_ this :~ [%pass /info %arvo %c %info %blog %& soba-html] [%pass /info %arvo %c %info %blog %& soba-md]