commit 497675ba2efb659135cf253aa9c7a59e113b348c Author: dachus Date: Sat Feb 11 18:46:49 2023 -0600 initial diff --git a/app/blog.hoon b/app/blog.hoon new file mode 100644 index 0000000..4c2a279 --- /dev/null +++ b/app/blog.hoon @@ -0,0 +1,119 @@ +/- blog +/+ dbug, default-agent, blog-lib=blog +:: +%- agent:dbug +^- agent:gall +=> |% + +$ versioned-state $%(state-0) + +$ state-0 a=@ + -- +=| state-0 +=* state - +=< +|_ bowl=bowl:gall ++* this . + def ~(. (default-agent this %.n) bowl) + hc ~(. +> bowl) + card card:agent:gall +++ on-init + :_ this + :: TODO this should go through docket later... + [%pass /bind %arvo %e %connect `/blog dap.bowl]~ +++ on-save on-save:def +++ on-load on-load:def +++ on-poke + |= [=mark =vase] + ?+ mark (on-poke:def mark vase) + %handle-http-request + =+ !<([rid=@tas req=inbound-request:eyre] vase) + :: if it's /edit then enforce authentication, otherwise just serve the blog + :_ this + %^ make-http-response:hc + [/http-response/[rid]]~ + [200 ~] + (as-octs:mimes:html '

hello world

') + :: + %blog-action + =+ !<(act=action:blog vase) + ?- -.act + %blog-bind + :_ this + [%pass /bind %arvo %e %connect `path.act dap.bowl]~ + :: + %blog-unbind + :_ this + [%pass /bind %arvo %e %disconnect `path.act]~ + :: + %save-file + ~& > text.act + ~& > file.act + :: /=blog=/blogs/... + =* file + %+ weld + /(scot %p our.bowl)/blog/(scot %da now.bowl)/blogs + file.act + =* nor `nori:clay`[%& [file %ins %html !>(text.act)]~] + [%pass / %arvo %c %info %blog nor]~^this + :: + %delete-file + =* nor `nori:clay`[%& [file.act %del ~]~] + [%pass / %arvo %c %info %blog nor]~^this + == + == +++ on-agent on-agent:def +++ on-watch + |= =path + ^- (quip card _this) + ?>(?=([%http-response *] path) `this) +++ on-peek + |= =path + ^- (unit (unit cage)) + ?+ path ~ + :: + :: [%x %existing-bindings ~] + :: =* pax /(scot %p our.bowl)/bindings/(scot %da now.bowl) + :: :^ ~ ~ %bindings !> + :: .^((list [binding:eyre duct action:eyre]) %e pax) + :: + [%x %blog ^] + :^ ~ ~ %html + !> ^- cord + %- of-wain:format + .^ wain + %cx + %+ weld + /(scot %p our.bowl)/blog/(scot %da now.bowl)/blog + t.t.path + == + :: + == +:: +++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + ?+ wire (on-arvo:def wire sign-arvo) + [%bind ~] + ?> ?=(%eyre -.sign-arvo) + ?> ?=(%bound +<.sign-arvo) + ?- accepted.sign-arvo + %| ~&(>>> "%blog: {} failed bind" `this) + %& ~&("%blog: {} successful bind" `this) + == + == +:: +++ on-leave on-leave:def +++ on-fail on-fail:def +-- +:: +|_ =bowl:gall +++ make-http-response + |= $: paths=(list path) + header=response-header:http + data=octs + == + ^- (list card:agent:gall) + :~ [%give %fact paths [%http-response-header !>(header)]] + [%give %fact paths [%http-response-data !>(`data)]] + [%give %kick paths ~] + == +-- diff --git a/desk.bill b/desk.bill new file mode 100644 index 0000000..9348e6e --- /dev/null +++ b/desk.bill @@ -0,0 +1,2 @@ +:~ %blog +== \ No newline at end of file diff --git a/lib/blog.hoon b/lib/blog.hoon new file mode 100644 index 0000000..497c474 --- /dev/null +++ b/lib/blog.hoon @@ -0,0 +1,11 @@ +|% +++ template + |= $: paths=(list path) + header=response-header:http + data=octs + == + :~ [%give %fact paths %http-resposne-header !>(header)] + [%give %fact paths %http-response-data !>(`data)] + [%give %kick paths ~] + == +-- \ No newline at end of file diff --git a/mar/blog/action.hoon b/mar/blog/action.hoon new file mode 100644 index 0000000..44c7a6b --- /dev/null +++ b/mar/blog/action.hoon @@ -0,0 +1,25 @@ +/- blog +:: +|_ =action:blog +++ grab + |% + ++ noun action:blog + ++ json + |= jon=^json + =, dejs:format + ^- action:pyro + %- of + :~ [%blog-bind pa] + [%blog-unbind pa] + [%save-file (ot ~[file+pa text+so])] + [%delete-file pa] + == + -- +:: +++ grow + |% + ++ noun action + -- +:: +++ grad %noun +-- diff --git a/sur/blog.hoon b/sur/blog.hoon new file mode 100644 index 0000000..ccb31a2 --- /dev/null +++ b/sur/blog.hoon @@ -0,0 +1,8 @@ +|% ++$ action + $% [%blog-bind =path] + [%blog-unbind =path] + [%save-file file=path text=@t] + [%delete-file file=path] + == +-- \ No newline at end of file diff --git a/sys.kelvin b/sys.kelvin new file mode 100644 index 0000000..5bd0cc6 --- /dev/null +++ b/sys.kelvin @@ -0,0 +1 @@ +[%zuse 415]